@pie-players/pie-section-player 0.3.19 → 0.3.20
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/dist/defineProperty-CyepwRr5-eHUSgEtz.js +33 -0
- package/dist/defineProperty-CyepwRr5.js +33 -0
- package/dist/dist-BCuSaTvi.js +393 -0
- package/dist/dist-BIgX-aC4-C5B4fLQK.js +389 -0
- package/dist/dist-DwP27yIs-gkxodgFn.js +201 -0
- package/dist/{index-QLtHZ4Yz-B0r-CUMY.js → dist-S3IAfazl.js} +36 -64
- package/dist/{index-BZq66Ke6-D8dZwpj4.js → module-COIydQYl-2o-TlgiW.js} +38152 -30086
- package/dist/pie-section-player.js +7042 -9287
- package/dist/player-preload-C_CjM5hv.js +6317 -0
- package/dist/tool-annotation-toolbar-BS_MjvXd.js +3974 -0
- package/dist/utils/player-preload.js +5 -5
- package/package.json +14 -14
- package/dist/index-BRKsQ6Im-_GY8ip1I.js +0 -442
- package/dist/index-BRKsQ6Im.js +0 -460
- package/dist/index-QLtHZ4Yz.js +0 -244
- package/dist/player-preload-DGzat3U_.js +0 -7040
- package/dist/tool-annotation-toolbar-BCBoCQa5.js +0 -4930
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
class
|
|
1
|
+
import { t as s } from "./defineProperty-CyepwRr5.js";
|
|
2
|
+
var n = class {
|
|
3
3
|
constructor() {
|
|
4
4
|
s(this, "providerId", "desmos"), s(this, "providerName", "Desmos"), s(this, "supportedTypes", [
|
|
5
5
|
"basic",
|
|
6
6
|
"scientific",
|
|
7
7
|
"graphing"
|
|
8
|
-
]), s(this, "version", "1.10"), s(this, "initialized", !1), s(this, "apiKey"), s(this, "proxyEndpoint"), s(this, "isDevelopment", !1), s(this, "onTelemetry");
|
|
8
|
+
]), s(this, "version", "1.10"), s(this, "initialized", !1), s(this, "apiKey", void 0), s(this, "proxyEndpoint", void 0), s(this, "isDevelopment", !1), s(this, "onTelemetry", void 0);
|
|
9
9
|
}
|
|
10
10
|
async emitTelemetry(e, o) {
|
|
11
11
|
try {
|
|
@@ -14,35 +14,22 @@ class p {
|
|
|
14
14
|
console.warn("[DesmosProvider] telemetry callback failed:", t);
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
/**
|
|
18
|
-
* Get the configured API key
|
|
19
|
-
* @internal Used internally by calculator instances
|
|
20
|
-
*/
|
|
21
17
|
getApiKey() {
|
|
22
18
|
return this.apiKey;
|
|
23
19
|
}
|
|
24
|
-
/**
|
|
25
|
-
* Dynamically load the Desmos calculator library
|
|
26
|
-
* @private
|
|
27
|
-
*/
|
|
28
20
|
async loadDesmosScript() {
|
|
29
21
|
return new Promise((e, o) => {
|
|
30
|
-
const t = document.createElement("script")
|
|
31
|
-
t.src =
|
|
32
|
-
window.Desmos ? (console.log("[DesmosProvider] Desmos API loaded successfully"), e()) : o(new Error("Desmos API loaded but window.Desmos is undefined"));
|
|
22
|
+
const t = document.createElement("script");
|
|
23
|
+
t.src = this.apiKey ? `https://www.desmos.com/api/v1.10/calculator.js?apiKey=${this.apiKey}` : "https://www.desmos.com/api/v1.10/calculator.js", t.async = !0, t.onload = () => {
|
|
24
|
+
window.Desmos ? (console.log("[DesmosProvider] Desmos API loaded successfully"), e()) : o(/* @__PURE__ */ new Error("Desmos API loaded but window.Desmos is undefined"));
|
|
33
25
|
}, t.onerror = () => {
|
|
34
|
-
o(new Error("Failed to load Desmos API from CDN"));
|
|
26
|
+
o(/* @__PURE__ */ new Error("Failed to load Desmos API from CDN"));
|
|
35
27
|
}, document.head.appendChild(t);
|
|
36
28
|
});
|
|
37
29
|
}
|
|
38
|
-
/**
|
|
39
|
-
* Initialize Desmos library
|
|
40
|
-
* @param config Configuration with API key (development) or proxy endpoint (production)
|
|
41
|
-
*/
|
|
42
30
|
async initialize(e) {
|
|
43
31
|
if (!this.initialized) {
|
|
44
|
-
if (this.onTelemetry = e?.onTelemetry, typeof window > "u")
|
|
45
|
-
throw new Error("Desmos calculators can only be initialized in the browser");
|
|
32
|
+
if (this.onTelemetry = e?.onTelemetry, typeof window > "u") throw new Error("Desmos calculators can only be initialized in the browser");
|
|
46
33
|
if (this.isDevelopment = process.env.NODE_ENV === "development" || typeof process > "u" || !process.env.NODE_ENV, e?.proxyEndpoint) {
|
|
47
34
|
this.proxyEndpoint = e.proxyEndpoint;
|
|
48
35
|
const o = Date.now();
|
|
@@ -53,10 +40,8 @@ class p {
|
|
|
53
40
|
});
|
|
54
41
|
try {
|
|
55
42
|
const t = await fetch(e.proxyEndpoint);
|
|
56
|
-
if (!t.ok)
|
|
57
|
-
|
|
58
|
-
const i = await t.json();
|
|
59
|
-
this.apiKey = i.apiKey, await this.emitTelemetry("pie-tool-backend-call-success", {
|
|
43
|
+
if (!t.ok) throw new Error(`Proxy endpoint returned ${t.status}`);
|
|
44
|
+
this.apiKey = (await t.json()).apiKey, await this.emitTelemetry("pie-tool-backend-call-success", {
|
|
60
45
|
toolId: "calculator",
|
|
61
46
|
backend: "desmos",
|
|
62
47
|
operation: "proxy-auth-fetch",
|
|
@@ -106,46 +91,34 @@ Recommended: Use proxyEndpoint for production, apiKey for development only.`);
|
|
|
106
91
|
this.initialized = !0;
|
|
107
92
|
}
|
|
108
93
|
}
|
|
109
|
-
/**
|
|
110
|
-
* Create a calculator instance
|
|
111
|
-
*/
|
|
112
94
|
async createCalculator(e, o, t) {
|
|
113
|
-
if (this.initialized || await this.initialize(), !this.supportsType(e))
|
|
114
|
-
|
|
115
|
-
return new c(this, e, o, t, this.apiKey);
|
|
95
|
+
if (this.initialized || await this.initialize(), !this.supportsType(e)) throw new Error(`Desmos does not support calculator type: ${e}`);
|
|
96
|
+
return new a(this, e, o, t, this.apiKey);
|
|
116
97
|
}
|
|
117
|
-
/**
|
|
118
|
-
* Check if type is supported
|
|
119
|
-
*/
|
|
120
98
|
supportsType(e) {
|
|
121
99
|
return this.supportedTypes.includes(e);
|
|
122
100
|
}
|
|
123
|
-
/**
|
|
124
|
-
* Cleanup
|
|
125
|
-
*/
|
|
126
101
|
destroy() {
|
|
127
102
|
this.initialized = !1, this.onTelemetry = void 0;
|
|
128
103
|
}
|
|
129
|
-
/**
|
|
130
|
-
* Get provider capabilities
|
|
131
|
-
*/
|
|
132
104
|
getCapabilities() {
|
|
133
105
|
return {
|
|
134
106
|
supportsHistory: !1,
|
|
135
|
-
// Desmos doesn't expose history API
|
|
136
107
|
supportsGraphing: !0,
|
|
137
108
|
supportsExpressions: !0,
|
|
138
109
|
canExport: !0,
|
|
139
110
|
maxPrecision: 15,
|
|
140
|
-
inputMethods: [
|
|
111
|
+
inputMethods: [
|
|
112
|
+
"keyboard",
|
|
113
|
+
"mouse",
|
|
114
|
+
"touch"
|
|
115
|
+
]
|
|
141
116
|
};
|
|
142
117
|
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
throw new Error("Desmos API not available");
|
|
148
|
-
this._initializeCalculator(i, a);
|
|
118
|
+
}, a = class {
|
|
119
|
+
constructor(e, o, t, r, i) {
|
|
120
|
+
if (s(this, "provider", void 0), s(this, "type", void 0), s(this, "Desmos", void 0), s(this, "calculator", void 0), s(this, "container", void 0), this.provider = e, this.type = o, this.container = t, this.Desmos = window.Desmos, !this.Desmos) throw new Error("Desmos API not available");
|
|
121
|
+
this._initializeCalculator(r, i);
|
|
149
122
|
}
|
|
150
123
|
_initializeCalculator(e, o) {
|
|
151
124
|
const t = {
|
|
@@ -181,13 +154,12 @@ class c {
|
|
|
181
154
|
return "";
|
|
182
155
|
}
|
|
183
156
|
setValue(e) {
|
|
184
|
-
if (this.type === "graphing" && this.calculator.setState)
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
157
|
+
if (this.type === "graphing" && this.calculator.setState) try {
|
|
158
|
+
const o = JSON.parse(e);
|
|
159
|
+
this.calculator.setState(o);
|
|
160
|
+
} catch (o) {
|
|
161
|
+
console.error("[DesmosCalculator] Failed to set state:", o);
|
|
162
|
+
}
|
|
191
163
|
}
|
|
192
164
|
clear() {
|
|
193
165
|
this.calculator.setBlank && this.calculator.setBlank();
|
|
@@ -195,11 +167,12 @@ class c {
|
|
|
195
167
|
async evaluate(e) {
|
|
196
168
|
return this.type === "graphing" ? new Promise((o) => {
|
|
197
169
|
const t = `eval_${Date.now()}`;
|
|
198
|
-
this.calculator.setExpression({
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
this.calculator.
|
|
170
|
+
this.calculator.setExpression({
|
|
171
|
+
id: t,
|
|
172
|
+
latex: e
|
|
173
|
+
}), setTimeout(() => {
|
|
174
|
+
const r = this.calculator.HelperExpression({ latex: e }).numericValue || e;
|
|
175
|
+
this.calculator.removeExpression({ id: t }), o(String(r));
|
|
203
176
|
}, 100);
|
|
204
177
|
}) : e;
|
|
205
178
|
}
|
|
@@ -216,14 +189,13 @@ class c {
|
|
|
216
189
|
};
|
|
217
190
|
}
|
|
218
191
|
importState(e) {
|
|
219
|
-
if (e.provider !== "desmos")
|
|
220
|
-
throw new Error(`Cannot import state from provider: ${e.provider}`);
|
|
192
|
+
if (e.provider !== "desmos") throw new Error(`Cannot import state from provider: ${e.provider}`);
|
|
221
193
|
e.providerState && this.calculator.setState ? this.calculator.setState(e.providerState) : e.value && this.setValue(e.value);
|
|
222
194
|
}
|
|
223
195
|
destroy() {
|
|
224
196
|
this.calculator && this.calculator.destroy && this.calculator.destroy(), this.container.replaceChildren(), console.log("[DesmosCalculator] destroyed");
|
|
225
197
|
}
|
|
226
|
-
}
|
|
198
|
+
};
|
|
227
199
|
export {
|
|
228
|
-
|
|
200
|
+
n as DesmosCalculatorProvider
|
|
229
201
|
};
|