@pie-players/pie-section-player 0.3.3 → 0.3.5
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.
- package/README.md +123 -5
- package/dist/components/section-player-item-card-element.d.ts +2 -0
- package/dist/components/section-player-item-card-element.d.ts.map +1 -0
- package/dist/components/section-player-items-pane-element.d.ts +2 -0
- package/dist/components/section-player-items-pane-element.d.ts.map +1 -0
- package/dist/components/section-player-kernel-host-element.d.ts +2 -0
- package/dist/components/section-player-kernel-host-element.d.ts.map +1 -0
- package/dist/components/section-player-passage-card-element.d.ts +2 -0
- package/dist/components/section-player-passage-card-element.d.ts.map +1 -0
- package/dist/components/section-player-passages-pane-element.d.ts +2 -0
- package/dist/components/section-player-passages-pane-element.d.ts.map +1 -0
- package/dist/components/section-player-shell-element.d.ts +2 -0
- package/dist/components/section-player-shell-element.d.ts.map +1 -0
- package/dist/components/shared/outer-scrollbars.d.ts +6 -0
- package/dist/components/shared/outer-scrollbars.d.ts.map +1 -0
- package/dist/components/shared/player-action.d.ts +1 -0
- package/dist/components/shared/player-action.d.ts.map +1 -1
- package/dist/components/shared/player-preload.d.ts +5 -0
- package/dist/components/shared/player-preload.d.ts.map +1 -1
- package/dist/components/shared/section-player-card-context.d.ts +15 -0
- package/dist/components/shared/section-player-card-context.d.ts.map +1 -0
- package/dist/components/shared/section-player-props.d.ts +2 -0
- package/dist/components/shared/section-player-props.d.ts.map +1 -0
- package/dist/components/shared/section-player-readiness.d.ts +14 -0
- package/dist/components/shared/section-player-readiness.d.ts.map +1 -0
- package/dist/components/shared/section-player-runtime.d.ts +4 -4
- package/dist/components/shared/section-player-runtime.d.ts.map +1 -1
- package/dist/components/shared/section-player-view-state.d.ts +9 -0
- package/dist/components/shared/section-player-view-state.d.ts.map +1 -1
- package/dist/contracts/layout-contract.d.ts +18 -0
- package/dist/contracts/layout-contract.d.ts.map +1 -0
- package/dist/contracts/layout-parity-metadata.d.ts +4 -0
- package/dist/contracts/layout-parity-metadata.d.ts.map +1 -0
- package/dist/contracts/public-events.d.ts +25 -0
- package/dist/contracts/public-events.d.ts.map +1 -0
- package/dist/contracts/runtime-host-contract.d.ts +29 -0
- package/dist/contracts/runtime-host-contract.d.ts.map +1 -0
- package/dist/controllers/SectionController.d.ts +10 -14
- package/dist/controllers/SectionController.d.ts.map +1 -1
- package/dist/controllers/toolkit-section-contracts.d.ts +1 -1
- package/dist/controllers/toolkit-section-contracts.d.ts.map +1 -1
- package/dist/controllers/types.d.ts +27 -13
- package/dist/controllers/types.d.ts.map +1 -1
- package/dist/index-CGEKDUBQ-C-8EFMUk.js +216 -0
- package/dist/index-DF-Dk87f-lxErM8bo.js +178 -0
- package/dist/pie-section-player.d.ts +7 -0
- package/dist/pie-section-player.d.ts.map +1 -1
- package/dist/pie-section-player.js +8249 -7564
- package/dist/{player-preload-9v0AQsMd.js → player-preload-Boa1VXUc.js} +2707 -2649
- package/dist/policies/guards.d.ts +3 -0
- package/dist/policies/guards.d.ts.map +1 -0
- package/dist/policies/index.d.ts +3 -0
- package/dist/policies/index.d.ts.map +1 -0
- package/dist/policies/types.d.ts +23 -0
- package/dist/policies/types.d.ts.map +1 -0
- package/dist/tool-annotation-toolbar-DJvpXk1K.js +4917 -0
- package/dist/utils/player-preload.js +1 -1
- package/package.json +54 -13
- package/dist/tool-annotation-toolbar-m4Mv2j0H.js +0 -4305
- package/src/components/ItemShellElement.svelte +0 -302
- package/src/components/PassageShellElement.svelte +0 -217
- package/src/components/PieSectionPlayerBaseElement.svelte +0 -245
- package/src/components/PieSectionPlayerSplitPaneElement.svelte +0 -675
- package/src/components/PieSectionPlayerVerticalElement.svelte +0 -439
- package/src/components/shared/SectionItemCard.svelte +0 -92
- package/src/components/shared/SectionPassageCard.svelte +0 -88
|
@@ -76,6 +76,12 @@ export interface SectionAttemptSessionSlice {
|
|
|
76
76
|
itemIdentifiers: string[];
|
|
77
77
|
visitedItemIdentifiers: string[];
|
|
78
78
|
itemSessions: Record<string, unknown>;
|
|
79
|
+
loadingComplete: boolean;
|
|
80
|
+
totalRegistered: number;
|
|
81
|
+
totalLoaded: number;
|
|
82
|
+
itemsComplete: boolean;
|
|
83
|
+
completedCount: number;
|
|
84
|
+
totalItems: number;
|
|
79
85
|
}
|
|
80
86
|
export interface SessionChangedResult {
|
|
81
87
|
testAttemptSession: TestAttemptSession;
|
|
@@ -110,12 +116,13 @@ export interface SectionNavigationState {
|
|
|
110
116
|
}
|
|
111
117
|
export type SectionContentKind = "item" | "passage" | "rubric" | "unknown";
|
|
112
118
|
interface SectionControllerEventBase {
|
|
113
|
-
type: "item-session-data-changed" | "item-session-meta-changed" | "item-selected" | "content-loaded" | "item-player-error" | "item-complete-changed" | "section-loading-complete" | "section-items-complete-changed" | "section-error";
|
|
114
|
-
currentItemIndex: number;
|
|
119
|
+
type: "item-session-data-changed" | "item-session-meta-changed" | "item-selected" | "section-navigation-change" | "content-loaded" | "item-player-error" | "item-complete-changed" | "section-loading-complete" | "section-items-complete-changed" | "section-error";
|
|
115
120
|
timestamp: number;
|
|
116
|
-
replayed?: boolean;
|
|
117
121
|
}
|
|
118
|
-
|
|
122
|
+
interface ItemScopedControllerEventBase extends SectionControllerEventBase {
|
|
123
|
+
currentItemIndex: number;
|
|
124
|
+
}
|
|
125
|
+
export interface ItemSessionDataChangedEvent extends ItemScopedControllerEventBase {
|
|
119
126
|
type: "item-session-data-changed";
|
|
120
127
|
itemId: string;
|
|
121
128
|
canonicalItemId: string;
|
|
@@ -124,53 +131,60 @@ export interface ItemSessionDataChangedEvent extends SectionControllerEventBase
|
|
|
124
131
|
complete?: boolean;
|
|
125
132
|
component?: string;
|
|
126
133
|
}
|
|
127
|
-
export interface ItemSessionMetaChangedEvent extends
|
|
134
|
+
export interface ItemSessionMetaChangedEvent extends ItemScopedControllerEventBase {
|
|
128
135
|
type: "item-session-meta-changed";
|
|
129
136
|
itemId: string;
|
|
130
137
|
canonicalItemId: string;
|
|
131
138
|
complete?: boolean;
|
|
132
139
|
component?: string;
|
|
133
140
|
}
|
|
134
|
-
export interface ItemSelectedEvent extends
|
|
141
|
+
export interface ItemSelectedEvent extends ItemScopedControllerEventBase {
|
|
135
142
|
type: "item-selected";
|
|
136
143
|
previousItemId: string;
|
|
137
144
|
currentItemId: string;
|
|
138
145
|
itemIndex: number;
|
|
139
146
|
totalItems: number;
|
|
140
147
|
}
|
|
141
|
-
export interface
|
|
148
|
+
export interface SectionNavigationChangeEvent extends SectionControllerEventBase {
|
|
149
|
+
type: "section-navigation-change";
|
|
150
|
+
previousSectionId?: string;
|
|
151
|
+
currentSectionId?: string;
|
|
152
|
+
attemptId?: string;
|
|
153
|
+
reason?: "input-change" | "runtime-transition";
|
|
154
|
+
}
|
|
155
|
+
export interface ContentLoadedEvent extends ItemScopedControllerEventBase {
|
|
142
156
|
type: "content-loaded";
|
|
143
157
|
contentKind: SectionContentKind;
|
|
144
158
|
itemId: string;
|
|
145
159
|
canonicalItemId: string;
|
|
146
160
|
detail?: unknown;
|
|
147
161
|
}
|
|
148
|
-
export interface ItemPlayerErrorEvent extends
|
|
162
|
+
export interface ItemPlayerErrorEvent extends ItemScopedControllerEventBase {
|
|
149
163
|
type: "item-player-error";
|
|
150
164
|
contentKind: SectionContentKind;
|
|
151
165
|
itemId: string;
|
|
152
166
|
canonicalItemId: string;
|
|
153
167
|
error: unknown;
|
|
154
168
|
}
|
|
155
|
-
export interface ItemCompleteChangedEvent extends
|
|
169
|
+
export interface ItemCompleteChangedEvent extends ItemScopedControllerEventBase {
|
|
156
170
|
type: "item-complete-changed";
|
|
157
171
|
itemId: string;
|
|
158
172
|
canonicalItemId: string;
|
|
159
173
|
complete: boolean;
|
|
160
174
|
previousComplete: boolean;
|
|
161
175
|
}
|
|
162
|
-
export interface SectionLoadingCompleteEvent extends
|
|
176
|
+
export interface SectionLoadingCompleteEvent extends ItemScopedControllerEventBase {
|
|
163
177
|
type: "section-loading-complete";
|
|
164
178
|
totalRegistered: number;
|
|
165
179
|
totalLoaded: number;
|
|
166
180
|
}
|
|
167
|
-
export interface SectionItemsCompleteChangedEvent extends
|
|
181
|
+
export interface SectionItemsCompleteChangedEvent extends ItemScopedControllerEventBase {
|
|
168
182
|
type: "section-items-complete-changed";
|
|
169
183
|
complete: boolean;
|
|
170
184
|
completedCount: number;
|
|
171
185
|
totalItems: number;
|
|
172
186
|
}
|
|
173
|
-
export interface SectionErrorEvent extends
|
|
187
|
+
export interface SectionErrorEvent extends ItemScopedControllerEventBase {
|
|
174
188
|
type: "section-error";
|
|
175
189
|
source: "item-player" | "section-runtime" | "toolkit" | "controller";
|
|
176
190
|
error: unknown;
|
|
@@ -178,7 +192,7 @@ export interface SectionErrorEvent extends SectionControllerEventBase {
|
|
|
178
192
|
canonicalItemId?: string;
|
|
179
193
|
contentKind?: SectionContentKind;
|
|
180
194
|
}
|
|
181
|
-
export type SectionControllerChangeEvent = ItemSessionDataChangedEvent | ItemSessionMetaChangedEvent | ItemSelectedEvent | ContentLoadedEvent | ItemPlayerErrorEvent | ItemCompleteChangedEvent | SectionLoadingCompleteEvent | SectionItemsCompleteChangedEvent | SectionErrorEvent;
|
|
195
|
+
export type SectionControllerChangeEvent = ItemSessionDataChangedEvent | ItemSessionMetaChangedEvent | ItemSelectedEvent | SectionNavigationChangeEvent | ContentLoadedEvent | ItemPlayerErrorEvent | ItemCompleteChangedEvent | SectionLoadingCompleteEvent | SectionItemsCompleteChangedEvent | SectionErrorEvent;
|
|
182
196
|
export type SectionControllerChangeListener = (event: SectionControllerChangeEvent) => void;
|
|
183
197
|
export {};
|
|
184
198
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/controllers/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC/E,OAAO,KAAK,E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C;IACvB,UAAU,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,iBAAkB,SAAQ,6BAA6B;IACvE,IAAI,EAAE,eAAe,CAAC;IACtB,MAAM,EAAE,aAAa,GAAG,iBAAiB,GAAG,SAAS,GAAG,YAAY,CAAC;IACrE,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,kBAAkB,CAAC;CACjC;AAED,MAAM,MAAM,4BAA4B,GACrC,2BAA2B,GAC3B,2BAA2B,GAC3B,iBAAiB,GACjB,4BAA4B,GAC5B,kBAAkB,GAClB,oBAAoB,GACpB,wBAAwB,GACxB,2BAA2B,GAC3B,gCAAgC,GAChC,iBAAiB,CAAC;AAErB,MAAM,MAAM,+BAA+B,GAAG,CAC7C,KAAK,EAAE,4BAA4B,KAC/B,IAAI,CAAC"}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
var v = Object.defineProperty, y = (h, t, i) => t in h ? v(h, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : h[t] = i, o = (h, t, i) => y(h, typeof t != "symbol" ? t + "" : t, i);
|
|
2
|
+
class T {
|
|
3
|
+
constructor(t) {
|
|
4
|
+
o(this, "config"), o(this, "currentAudio", null), o(this, "pausedState", !1), o(this, "wordTimings", []), o(this, "highlightInterval", null), o(this, "intentionallyStopped", !1), o(this, "onWordBoundary"), this.config = t;
|
|
5
|
+
}
|
|
6
|
+
async speak(t) {
|
|
7
|
+
this.stop(), this.intentionallyStopped = !1;
|
|
8
|
+
const { audioUrl: i, wordTimings: e } = await this.synthesizeSpeech(t), r = this.config.rate || 1;
|
|
9
|
+
return this.wordTimings = e.map((n) => ({
|
|
10
|
+
...n,
|
|
11
|
+
time: n.time / r
|
|
12
|
+
})), new Promise((n, a) => {
|
|
13
|
+
const s = new Audio(i);
|
|
14
|
+
this.currentAudio = s, this.config.rate && (s.playbackRate = Math.max(0.25, Math.min(4, this.config.rate))), this.config.volume !== void 0 && (s.volume = Math.max(0, Math.min(1, this.config.volume))), s.onplay = () => {
|
|
15
|
+
this.pausedState = !1, this.onWordBoundary && this.wordTimings.length > 0 && this.startWordHighlighting();
|
|
16
|
+
}, s.onended = () => {
|
|
17
|
+
this.stopWordHighlighting(), URL.revokeObjectURL(i), this.currentAudio = null, this.wordTimings = [], n();
|
|
18
|
+
}, s.onerror = (d) => {
|
|
19
|
+
this.stopWordHighlighting(), URL.revokeObjectURL(i), this.currentAudio = null, this.wordTimings = [], this.intentionallyStopped ? n() : a(new Error("Failed to play audio from server"));
|
|
20
|
+
}, s.onpause = () => {
|
|
21
|
+
this.stopWordHighlighting(), this.pausedState = !0;
|
|
22
|
+
}, s.play().catch(a);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Call server API to synthesize speech
|
|
27
|
+
*/
|
|
28
|
+
async synthesizeSpeech(t) {
|
|
29
|
+
const i = {
|
|
30
|
+
"Content-Type": "application/json",
|
|
31
|
+
...this.config.headers
|
|
32
|
+
};
|
|
33
|
+
this.config.authToken && (i.Authorization = `Bearer ${this.config.authToken}`);
|
|
34
|
+
const e = this.config.providerOptions || {}, r = typeof this.config.engine == "string" ? this.config.engine : typeof e.engine == "string" ? e.engine : void 0, n = typeof e.sampleRate == "number" && Number.isFinite(e.sampleRate) ? e.sampleRate : void 0, a = e.format === "mp3" || e.format === "ogg" || e.format === "pcm" ? e.format : void 0, s = Array.isArray(e.speechMarkTypes) ? e.speechMarkTypes.filter((u) => u === "word" || u === "sentence" || u === "ssml") : void 0, d = {
|
|
35
|
+
text: t,
|
|
36
|
+
provider: this.config.provider || "polly",
|
|
37
|
+
voice: this.config.voice,
|
|
38
|
+
language: this.config.language,
|
|
39
|
+
rate: this.config.rate,
|
|
40
|
+
engine: r,
|
|
41
|
+
sampleRate: n,
|
|
42
|
+
format: a,
|
|
43
|
+
speechMarkTypes: s,
|
|
44
|
+
includeSpeechMarks: !0
|
|
45
|
+
}, l = await fetch(`${this.config.apiEndpoint}/synthesize`, {
|
|
46
|
+
method: "POST",
|
|
47
|
+
headers: i,
|
|
48
|
+
body: JSON.stringify(d)
|
|
49
|
+
});
|
|
50
|
+
if (!l.ok) {
|
|
51
|
+
const u = await l.json().catch(() => ({})), m = u.message || u.error?.message || `Server returned ${l.status}`;
|
|
52
|
+
throw new Error(m);
|
|
53
|
+
}
|
|
54
|
+
const c = await l.json(), g = this.base64ToBlob(c.audio, c.contentType), p = URL.createObjectURL(g), f = this.parseSpeechMarks(c.speechMarks);
|
|
55
|
+
return { audioUrl: p, wordTimings: f };
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Convert base64 to Blob
|
|
59
|
+
*/
|
|
60
|
+
base64ToBlob(t, i) {
|
|
61
|
+
const e = atob(t), r = new Array(e.length);
|
|
62
|
+
for (let a = 0; a < e.length; a++)
|
|
63
|
+
r[a] = e.charCodeAt(a);
|
|
64
|
+
const n = new Uint8Array(r);
|
|
65
|
+
return new Blob([n], { type: i });
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Parse speech marks into word timings
|
|
69
|
+
*/
|
|
70
|
+
parseSpeechMarks(t) {
|
|
71
|
+
return t.filter((i) => i.type === "word").map((i, e) => ({
|
|
72
|
+
time: i.time,
|
|
73
|
+
wordIndex: e,
|
|
74
|
+
charIndex: i.start,
|
|
75
|
+
length: i.end - i.start
|
|
76
|
+
}));
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Start word highlighting synchronized with audio playback
|
|
80
|
+
*/
|
|
81
|
+
startWordHighlighting() {
|
|
82
|
+
if (this.stopWordHighlighting(), !this.currentAudio || !this.onWordBoundary || this.wordTimings.length === 0) {
|
|
83
|
+
console.log("[ServerTTSProvider] Cannot start highlighting:", {
|
|
84
|
+
hasAudio: !!this.currentAudio,
|
|
85
|
+
hasCallback: !!this.onWordBoundary,
|
|
86
|
+
wordTimingsCount: this.wordTimings.length
|
|
87
|
+
});
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
console.log("[ServerTTSProvider] Starting word highlighting with", this.wordTimings.length, "word timings"), console.log("[ServerTTSProvider] Playback rate:", this.currentAudio.playbackRate), console.log("[ServerTTSProvider] First 3 timings:", this.wordTimings.slice(0, 3));
|
|
91
|
+
let t = -1;
|
|
92
|
+
this.highlightInterval = window.setInterval(() => {
|
|
93
|
+
if (!this.currentAudio) {
|
|
94
|
+
this.stopWordHighlighting();
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const i = this.currentAudio.currentTime * 1e3;
|
|
98
|
+
for (let e = 0; e < this.wordTimings.length; e++) {
|
|
99
|
+
const r = this.wordTimings[e];
|
|
100
|
+
if (i >= r.time && e > t) {
|
|
101
|
+
this.onWordBoundary && (console.log("[ServerTTSProvider] Highlighting word at charIndex:", r.charIndex, "length:", r.length, "time:", r.time, "currentTime:", i), this.onWordBoundary("", r.charIndex, r.length)), t = e;
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}, 50);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Stop word highlighting
|
|
109
|
+
*/
|
|
110
|
+
stopWordHighlighting() {
|
|
111
|
+
this.highlightInterval !== null && (clearInterval(this.highlightInterval), this.highlightInterval = null);
|
|
112
|
+
}
|
|
113
|
+
pause() {
|
|
114
|
+
this.currentAudio && !this.pausedState && (this.currentAudio.pause(), this.stopWordHighlighting(), this.pausedState = !0);
|
|
115
|
+
}
|
|
116
|
+
resume() {
|
|
117
|
+
this.currentAudio && this.pausedState && (this.currentAudio.play(), this.pausedState = !1, this.onWordBoundary && this.wordTimings.length > 0 && this.startWordHighlighting());
|
|
118
|
+
}
|
|
119
|
+
stop() {
|
|
120
|
+
this.stopWordHighlighting(), this.currentAudio && (this.intentionallyStopped = !0, this.currentAudio.pause(), this.currentAudio.src && URL.revokeObjectURL(this.currentAudio.src), this.currentAudio.src = "", this.currentAudio = null), this.pausedState = !1, this.wordTimings = [];
|
|
121
|
+
}
|
|
122
|
+
isPlaying() {
|
|
123
|
+
return this.currentAudio !== null && !this.pausedState;
|
|
124
|
+
}
|
|
125
|
+
isPaused() {
|
|
126
|
+
return this.pausedState;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Update settings dynamically (rate, pitch, voice)
|
|
130
|
+
* Note: Voice changes require resynthesis, so voice updates are stored but
|
|
131
|
+
* take effect on the next speak() call. Rate can be applied to current playback.
|
|
132
|
+
*/
|
|
133
|
+
updateSettings(t) {
|
|
134
|
+
t.rate !== void 0 && (this.config.rate = t.rate, this.currentAudio && (this.currentAudio.playbackRate = Math.max(0.25, Math.min(4, t.rate)))), t.pitch !== void 0 && (this.config.pitch = t.pitch), t.voice !== void 0 && (this.config.voice = t.voice);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
class w {
|
|
138
|
+
constructor() {
|
|
139
|
+
o(this, "providerId", "server-tts"), o(this, "providerName", "Server TTS"), o(this, "version", "1.0.0"), o(this, "config", null);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Initialize the server TTS provider.
|
|
143
|
+
*
|
|
144
|
+
* This is designed to be fast by default (no API calls).
|
|
145
|
+
* Set validateEndpoint: true in config to test API availability during initialization.
|
|
146
|
+
*
|
|
147
|
+
* @performance Default: <10ms, With validation: 100-500ms
|
|
148
|
+
*/
|
|
149
|
+
async initialize(t) {
|
|
150
|
+
const i = t;
|
|
151
|
+
if (!i.apiEndpoint)
|
|
152
|
+
throw new Error("apiEndpoint is required for ServerTTSProvider");
|
|
153
|
+
if (this.config = i, i.validateEndpoint && !await this.testAPIAvailability())
|
|
154
|
+
throw new Error(`Server TTS API not available at ${i.apiEndpoint}`);
|
|
155
|
+
return new T(i);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Test if API endpoint is available (with timeout).
|
|
159
|
+
*
|
|
160
|
+
* @performance 100-500ms depending on network
|
|
161
|
+
*/
|
|
162
|
+
async testAPIAvailability() {
|
|
163
|
+
if (!this.config)
|
|
164
|
+
return !1;
|
|
165
|
+
try {
|
|
166
|
+
const t = { ...this.config.headers };
|
|
167
|
+
this.config.authToken && (t.Authorization = `Bearer ${this.config.authToken}`);
|
|
168
|
+
const i = new AbortController(), e = setTimeout(() => i.abort(), 5e3);
|
|
169
|
+
try {
|
|
170
|
+
const r = await fetch(`${this.config.apiEndpoint}/voices`, {
|
|
171
|
+
headers: t,
|
|
172
|
+
signal: i.signal
|
|
173
|
+
});
|
|
174
|
+
return clearTimeout(e), r.ok;
|
|
175
|
+
} catch {
|
|
176
|
+
return clearTimeout(e), !1;
|
|
177
|
+
}
|
|
178
|
+
} catch {
|
|
179
|
+
return !1;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
supportsFeature(t) {
|
|
183
|
+
switch (t) {
|
|
184
|
+
case "pause":
|
|
185
|
+
case "resume":
|
|
186
|
+
case "wordBoundary":
|
|
187
|
+
case "voiceSelection":
|
|
188
|
+
case "rateControl":
|
|
189
|
+
return !0;
|
|
190
|
+
case "pitchControl":
|
|
191
|
+
return !1;
|
|
192
|
+
default:
|
|
193
|
+
return !1;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
getCapabilities() {
|
|
197
|
+
return {
|
|
198
|
+
supportsPause: !0,
|
|
199
|
+
supportsResume: !0,
|
|
200
|
+
supportsWordBoundary: !0,
|
|
201
|
+
// ✅ Via speech marks from server
|
|
202
|
+
supportsVoiceSelection: !0,
|
|
203
|
+
supportsRateControl: !0,
|
|
204
|
+
supportsPitchControl: !1,
|
|
205
|
+
// Depends on server provider
|
|
206
|
+
maxTextLength: 3e3
|
|
207
|
+
// Conservative estimate
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
destroy() {
|
|
211
|
+
this.config = null;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
export {
|
|
215
|
+
w as ServerTTSProvider
|
|
216
|
+
};
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
var n = Object.defineProperty, l = (i, e, t) => e in i ? n(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, o = (i, e, t) => l(i, typeof e != "symbol" ? e + "" : e, t);
|
|
2
|
+
class p {
|
|
3
|
+
constructor() {
|
|
4
|
+
o(this, "providerId", "desmos"), o(this, "providerName", "Desmos"), o(this, "supportedTypes", [
|
|
5
|
+
"basic",
|
|
6
|
+
"scientific",
|
|
7
|
+
"graphing"
|
|
8
|
+
]), o(this, "version", "1.10"), o(this, "initialized", !1), o(this, "apiKey"), o(this, "proxyEndpoint"), o(this, "isDevelopment", !1);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Get the configured API key
|
|
12
|
+
* @internal Used internally by calculator instances
|
|
13
|
+
*/
|
|
14
|
+
getApiKey() {
|
|
15
|
+
return this.apiKey;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Dynamically load the Desmos calculator library
|
|
19
|
+
* @private
|
|
20
|
+
*/
|
|
21
|
+
async loadDesmosScript() {
|
|
22
|
+
return new Promise((e, t) => {
|
|
23
|
+
const s = document.createElement("script"), r = this.apiKey ? `https://www.desmos.com/api/v1.10/calculator.js?apiKey=${this.apiKey}` : "https://www.desmos.com/api/v1.10/calculator.js";
|
|
24
|
+
s.src = r, s.async = !0, s.onload = () => {
|
|
25
|
+
window.Desmos ? (console.log("[DesmosProvider] Desmos API loaded successfully"), e()) : t(new Error("Desmos API loaded but window.Desmos is undefined"));
|
|
26
|
+
}, s.onerror = () => {
|
|
27
|
+
t(new Error("Failed to load Desmos API from CDN"));
|
|
28
|
+
}, document.head.appendChild(s);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Initialize Desmos library
|
|
33
|
+
* @param config Configuration with API key (development) or proxy endpoint (production)
|
|
34
|
+
*/
|
|
35
|
+
async initialize(e) {
|
|
36
|
+
if (!this.initialized) {
|
|
37
|
+
if (typeof window > "u")
|
|
38
|
+
throw new Error("Desmos calculators can only be initialized in the browser");
|
|
39
|
+
if (this.isDevelopment = process.env.NODE_ENV === "development" || typeof process > "u" || !process.env.NODE_ENV, e?.proxyEndpoint) {
|
|
40
|
+
this.proxyEndpoint = e.proxyEndpoint;
|
|
41
|
+
try {
|
|
42
|
+
const t = await fetch(e.proxyEndpoint);
|
|
43
|
+
if (!t.ok)
|
|
44
|
+
throw new Error(`Proxy endpoint returned ${t.status}`);
|
|
45
|
+
const s = await t.json();
|
|
46
|
+
this.apiKey = s.apiKey, console.log("[DesmosProvider] Initialized with server-side proxy (SECURE)");
|
|
47
|
+
} catch (t) {
|
|
48
|
+
throw new Error(`[DesmosProvider] Failed to fetch API key from proxy: ${t}`);
|
|
49
|
+
}
|
|
50
|
+
} else e?.apiKey ? (this.apiKey = e.apiKey, this.isDevelopment ? console.log("[DesmosProvider] Initialized with direct API key (DEVELOPMENT MODE)") : console.error(`⚠️ [DesmosProvider] SECURITY WARNING: API key exposed in client-side code!
|
|
51
|
+
This is insecure for production. Use proxyEndpoint instead.
|
|
52
|
+
See: https://pie-players.dev/docs/calculator-desmos#security`)) : console.warn(`[DesmosProvider] No API key or proxy endpoint provided.
|
|
53
|
+
Production usage requires authentication. Obtain API key from https://www.desmos.com/api
|
|
54
|
+
Recommended: Use proxyEndpoint for production, apiKey for development only.`);
|
|
55
|
+
window.Desmos || (console.log("[DesmosProvider] Loading Desmos API library..."), await this.loadDesmosScript()), this.initialized = !0;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Create a calculator instance
|
|
60
|
+
*/
|
|
61
|
+
async createCalculator(e, t, s) {
|
|
62
|
+
if (this.initialized || await this.initialize(), !this.supportsType(e))
|
|
63
|
+
throw new Error(`Desmos does not support calculator type: ${e}`);
|
|
64
|
+
return new c(this, e, t, s, this.apiKey);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Check if type is supported
|
|
68
|
+
*/
|
|
69
|
+
supportsType(e) {
|
|
70
|
+
return this.supportedTypes.includes(e);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Cleanup
|
|
74
|
+
*/
|
|
75
|
+
destroy() {
|
|
76
|
+
this.initialized = !1;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Get provider capabilities
|
|
80
|
+
*/
|
|
81
|
+
getCapabilities() {
|
|
82
|
+
return {
|
|
83
|
+
supportsHistory: !1,
|
|
84
|
+
// Desmos doesn't expose history API
|
|
85
|
+
supportsGraphing: !0,
|
|
86
|
+
supportsExpressions: !0,
|
|
87
|
+
canExport: !0,
|
|
88
|
+
maxPrecision: 15,
|
|
89
|
+
inputMethods: ["keyboard", "mouse", "touch"]
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
class c {
|
|
94
|
+
constructor(e, t, s, r, a) {
|
|
95
|
+
if (o(this, "provider"), o(this, "type"), o(this, "Desmos"), o(this, "calculator"), o(this, "container"), this.provider = e, this.type = t, this.container = s, this.Desmos = window.Desmos, !this.Desmos)
|
|
96
|
+
throw new Error("Desmos API not available");
|
|
97
|
+
this._initializeCalculator(r, a);
|
|
98
|
+
}
|
|
99
|
+
_initializeCalculator(e, t) {
|
|
100
|
+
const s = {
|
|
101
|
+
...e?.desmos || {},
|
|
102
|
+
apiKey: t || e?.desmos?.apiKey
|
|
103
|
+
};
|
|
104
|
+
switch (e?.restrictedMode && Object.assign(s, {
|
|
105
|
+
expressionsTopbar: !1,
|
|
106
|
+
settingsMenu: !1,
|
|
107
|
+
zoomButtons: !1,
|
|
108
|
+
expressions: !1,
|
|
109
|
+
links: !1
|
|
110
|
+
}), this.type) {
|
|
111
|
+
case "graphing":
|
|
112
|
+
this.calculator = this.Desmos.GraphingCalculator(this.container, s);
|
|
113
|
+
break;
|
|
114
|
+
case "scientific":
|
|
115
|
+
this.calculator = this.Desmos.ScientificCalculator(this.container, s);
|
|
116
|
+
break;
|
|
117
|
+
case "basic":
|
|
118
|
+
this.calculator = this.Desmos.FourFunctionCalculator(this.container, s);
|
|
119
|
+
break;
|
|
120
|
+
default:
|
|
121
|
+
throw new Error(`Unsupported calculator type: ${this.type}`);
|
|
122
|
+
}
|
|
123
|
+
console.log(`[DesmosCalculator] Created ${this.type} calculator`);
|
|
124
|
+
}
|
|
125
|
+
getValue() {
|
|
126
|
+
if (this.type === "graphing" && this.calculator.getState) {
|
|
127
|
+
const e = this.calculator.getState();
|
|
128
|
+
return JSON.stringify(e);
|
|
129
|
+
}
|
|
130
|
+
return "";
|
|
131
|
+
}
|
|
132
|
+
setValue(e) {
|
|
133
|
+
if (this.type === "graphing" && this.calculator.setState)
|
|
134
|
+
try {
|
|
135
|
+
const t = JSON.parse(e);
|
|
136
|
+
this.calculator.setState(t);
|
|
137
|
+
} catch (t) {
|
|
138
|
+
console.error("[DesmosCalculator] Failed to set state:", t);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
clear() {
|
|
142
|
+
this.calculator.setBlank && this.calculator.setBlank();
|
|
143
|
+
}
|
|
144
|
+
async evaluate(e) {
|
|
145
|
+
return this.type === "graphing" ? new Promise((t) => {
|
|
146
|
+
const s = `eval_${Date.now()}`;
|
|
147
|
+
this.calculator.setExpression({ id: s, latex: e }), setTimeout(() => {
|
|
148
|
+
const r = this.calculator.HelperExpression({
|
|
149
|
+
latex: e
|
|
150
|
+
}).numericValue || e;
|
|
151
|
+
this.calculator.removeExpression({ id: s }), t(String(r));
|
|
152
|
+
}, 100);
|
|
153
|
+
}) : e;
|
|
154
|
+
}
|
|
155
|
+
resize() {
|
|
156
|
+
this.calculator.resize && this.calculator.resize();
|
|
157
|
+
}
|
|
158
|
+
exportState() {
|
|
159
|
+
let e = {};
|
|
160
|
+
return this.type === "graphing" && this.calculator.getState && (e = this.calculator.getState()), {
|
|
161
|
+
type: this.type,
|
|
162
|
+
provider: "desmos",
|
|
163
|
+
value: this.getValue(),
|
|
164
|
+
providerState: e
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
importState(e) {
|
|
168
|
+
if (e.provider !== "desmos")
|
|
169
|
+
throw new Error(`Cannot import state from provider: ${e.provider}`);
|
|
170
|
+
e.providerState && this.calculator.setState ? this.calculator.setState(e.providerState) : e.value && this.setValue(e.value);
|
|
171
|
+
}
|
|
172
|
+
destroy() {
|
|
173
|
+
this.calculator && this.calculator.destroy && this.calculator.destroy(), this.container.replaceChildren(), console.log("[DesmosCalculator] destroyed");
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
export {
|
|
177
|
+
p as DesmosCalculatorProvider
|
|
178
|
+
};
|
|
@@ -1 +1,8 @@
|
|
|
1
|
+
export type { SectionPlayerLayoutContract, SectionPlayerLayoutName, SectionPlayerLayoutCapability, SectionPlayerBasicPropName, SectionPlayerAdvancedPropName, SectionPlayerLayoutPropName, SectionPlayerLayoutCommandName, } from './contracts/layout-contract.js';
|
|
2
|
+
export type { SectionPlayerPublicEventName, SectionPlayerReadinessPhase, SectionPlayerReadinessChangeDetail, SectionPlayerControllerReadyDetail, } from './contracts/public-events.js';
|
|
3
|
+
export { SECTION_PLAYER_PUBLIC_EVENTS } from './contracts/public-events.js';
|
|
4
|
+
export type { SectionPlayerRuntimeHostContract, SectionPlayerNavigationSnapshot, SectionPlayerSnapshot, } from './contracts/runtime-host-contract.js';
|
|
5
|
+
export { SPLITPANE_LAYOUT_CONTRACT, VERTICAL_LAYOUT_CONTRACT, } from './contracts/layout-parity-metadata.js';
|
|
6
|
+
export type { ReadinessPolicyAdapter, SectionPlayerPolicies, SectionPlayerReadinessPolicy, SectionPlayerPreloadPolicy, SectionPlayerFocusPolicy, SectionPlayerTelemetryPolicy, } from './policies/types.js';
|
|
7
|
+
export { DEFAULT_SECTION_PLAYER_POLICIES } from './policies/index.js';
|
|
1
8
|
//# sourceMappingURL=pie-section-player.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pie-section-player.d.ts","sourceRoot":"","sources":["../src/pie-section-player.ts"],"names":[],"mappings":"AAAA,OAAO,+CAA+C,CAAC;AACvD,OAAO,8CAA8C,CAAC"}
|
|
1
|
+
{"version":3,"file":"pie-section-player.d.ts","sourceRoot":"","sources":["../src/pie-section-player.ts"],"names":[],"mappings":"AAAA,OAAO,+CAA+C,CAAC;AACvD,OAAO,8CAA8C,CAAC;AACtD,OAAO,+CAA+C,CAAC;AACvD,OAAO,kDAAkD,CAAC;AAC1D,OAAO,gDAAgD,CAAC;AACxD,OAAO,mDAAmD,CAAC;AAC3D,OAAO,2CAA2C,CAAC;AACnD,OAAO,iDAAiD,CAAC;AAEzD,YAAY,EACX,2BAA2B,EAC3B,uBAAuB,EACvB,6BAA6B,EAC7B,0BAA0B,EAC1B,6BAA6B,EAC7B,2BAA2B,EAC3B,8BAA8B,GAC9B,MAAM,gCAAgC,CAAC;AACxC,YAAY,EACX,4BAA4B,EAC5B,2BAA2B,EAC3B,kCAAkC,EAClC,kCAAkC,GAClC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAC5E,YAAY,EACX,gCAAgC,EAChC,+BAA+B,EAC/B,qBAAqB,GACrB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACN,yBAAyB,EACzB,wBAAwB,GACxB,MAAM,uCAAuC,CAAC;AAC/C,YAAY,EACX,sBAAsB,EACtB,qBAAqB,EACrB,4BAA4B,EAC5B,0BAA0B,EAC1B,wBAAwB,EACxB,4BAA4B,GAC5B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,+BAA+B,EAAE,MAAM,qBAAqB,CAAC"}
|