@pie-players/pie-section-player 0.3.17 → 0.3.19
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 +76 -2
- package/dist/components/shared/player-action.d.ts +0 -2
- package/dist/components/shared/player-action.d.ts.map +1 -1
- package/dist/components/shared/player-preload.d.ts.map +1 -1
- package/dist/components/shared/section-player-runtime.d.ts +38 -7
- package/dist/components/shared/section-player-runtime.d.ts.map +1 -1
- package/dist/components/shared/section-player-view-state.d.ts.map +1 -1
- package/dist/contracts/layout-contract.d.ts +1 -1
- package/dist/contracts/layout-contract.d.ts.map +1 -1
- package/dist/contracts/layout-parity-metadata.d.ts.map +1 -1
- package/dist/controllers/SectionController.d.ts.map +1 -1
- package/dist/index-BRKsQ6Im-_GY8ip1I.js +442 -0
- package/dist/index-BRKsQ6Im.js +460 -0
- package/dist/{index-DF-Dk87f-lxErM8bo.js → index-QLtHZ4Yz-B0r-CUMY.js} +88 -37
- package/dist/{index-DF-Dk87f.js → index-QLtHZ4Yz.js} +102 -50
- package/dist/pie-section-player.js +4511 -3508
- package/dist/{player-preload-Dxvgw3gW.js → player-preload-DGzat3U_.js} +2481 -2464
- package/dist/{tool-annotation-toolbar-BOoJpOXj.js → tool-annotation-toolbar-BCBoCQa5.js} +1172 -1087
- package/dist/utils/player-preload.js +1 -1
- package/package.json +10 -10
- package/dist/index-CGqExkh0-DYpgzOOU.js +0 -338
- package/dist/index-CGqExkh0.js +0 -354
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
var l = Object.defineProperty;
|
|
2
|
-
var n = (
|
|
3
|
-
var
|
|
4
|
-
class
|
|
2
|
+
var n = (s, e, o) => e in s ? l(s, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : s[e] = o;
|
|
3
|
+
var r = (s, e, o) => n(s, typeof e != "symbol" ? e + "" : e, o);
|
|
4
|
+
class p {
|
|
5
5
|
constructor() {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
r(this, "providerId", "desmos");
|
|
7
|
+
r(this, "providerName", "Desmos");
|
|
8
|
+
r(this, "supportedTypes", [
|
|
9
9
|
"basic",
|
|
10
10
|
"scientific",
|
|
11
11
|
"graphing"
|
|
12
12
|
]);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
r(this, "version", "1.10");
|
|
14
|
+
r(this, "initialized", !1);
|
|
15
|
+
r(this, "apiKey");
|
|
16
|
+
r(this, "proxyEndpoint");
|
|
17
|
+
r(this, "isDevelopment", !1);
|
|
18
|
+
r(this, "onTelemetry");
|
|
19
|
+
}
|
|
20
|
+
async emitTelemetry(e, o) {
|
|
21
|
+
try {
|
|
22
|
+
await this.onTelemetry?.(e, o);
|
|
23
|
+
} catch (t) {
|
|
24
|
+
console.warn("[DesmosProvider] telemetry callback failed:", t);
|
|
25
|
+
}
|
|
18
26
|
}
|
|
19
27
|
/**
|
|
20
28
|
* Get the configured API key
|
|
@@ -28,13 +36,13 @@ class d {
|
|
|
28
36
|
* @private
|
|
29
37
|
*/
|
|
30
38
|
async loadDesmosScript() {
|
|
31
|
-
return new Promise((e,
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
window.Desmos ? (console.log("[DesmosProvider] Desmos API loaded successfully"), e()) :
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
}, document.head.appendChild(
|
|
39
|
+
return new Promise((e, o) => {
|
|
40
|
+
const t = document.createElement("script"), i = this.apiKey ? `https://www.desmos.com/api/v1.10/calculator.js?apiKey=${this.apiKey}` : "https://www.desmos.com/api/v1.10/calculator.js";
|
|
41
|
+
t.src = i, t.async = !0, t.onload = () => {
|
|
42
|
+
window.Desmos ? (console.log("[DesmosProvider] Desmos API loaded successfully"), e()) : o(new Error("Desmos API loaded but window.Desmos is undefined"));
|
|
43
|
+
}, t.onerror = () => {
|
|
44
|
+
o(new Error("Failed to load Desmos API from CDN"));
|
|
45
|
+
}, document.head.appendChild(t);
|
|
38
46
|
});
|
|
39
47
|
}
|
|
40
48
|
/**
|
|
@@ -43,34 +51,78 @@ class d {
|
|
|
43
51
|
*/
|
|
44
52
|
async initialize(e) {
|
|
45
53
|
if (!this.initialized) {
|
|
46
|
-
if (typeof window > "u")
|
|
54
|
+
if (this.onTelemetry = e?.onTelemetry, typeof window > "u")
|
|
47
55
|
throw new Error("Desmos calculators can only be initialized in the browser");
|
|
48
56
|
if (this.isDevelopment = process.env.NODE_ENV === "development" || typeof process > "u" || !process.env.NODE_ENV, e?.proxyEndpoint) {
|
|
49
57
|
this.proxyEndpoint = e.proxyEndpoint;
|
|
58
|
+
const o = Date.now();
|
|
59
|
+
await this.emitTelemetry("pie-tool-backend-call-start", {
|
|
60
|
+
toolId: "calculator",
|
|
61
|
+
backend: "desmos",
|
|
62
|
+
operation: "proxy-auth-fetch"
|
|
63
|
+
});
|
|
50
64
|
try {
|
|
51
65
|
const t = await fetch(e.proxyEndpoint);
|
|
52
66
|
if (!t.ok)
|
|
53
67
|
throw new Error(`Proxy endpoint returned ${t.status}`);
|
|
54
|
-
const
|
|
55
|
-
this.apiKey =
|
|
68
|
+
const i = await t.json();
|
|
69
|
+
this.apiKey = i.apiKey, await this.emitTelemetry("pie-tool-backend-call-success", {
|
|
70
|
+
toolId: "calculator",
|
|
71
|
+
backend: "desmos",
|
|
72
|
+
operation: "proxy-auth-fetch",
|
|
73
|
+
duration: Date.now() - o
|
|
74
|
+
}), console.log("[DesmosProvider] Initialized with server-side proxy (SECURE)");
|
|
56
75
|
} catch (t) {
|
|
57
|
-
throw
|
|
76
|
+
throw await this.emitTelemetry("pie-tool-backend-call-error", {
|
|
77
|
+
toolId: "calculator",
|
|
78
|
+
backend: "desmos",
|
|
79
|
+
operation: "proxy-auth-fetch",
|
|
80
|
+
duration: Date.now() - o,
|
|
81
|
+
errorType: "CalculatorProxyAuthError",
|
|
82
|
+
message: t instanceof Error ? t.message : String(t)
|
|
83
|
+
}), new Error(`[DesmosProvider] Failed to fetch API key from proxy: ${t}`);
|
|
58
84
|
}
|
|
59
85
|
} 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!
|
|
60
86
|
This is insecure for production. Use proxyEndpoint instead.
|
|
61
87
|
See: https://pie-players.dev/docs/calculator-desmos#security`)) : console.warn(`[DesmosProvider] No API key or proxy endpoint provided.
|
|
62
88
|
Production usage requires authentication. Obtain API key from https://www.desmos.com/api
|
|
63
89
|
Recommended: Use proxyEndpoint for production, apiKey for development only.`);
|
|
64
|
-
|
|
90
|
+
if (!window.Desmos) {
|
|
91
|
+
console.log("[DesmosProvider] Loading Desmos API library...");
|
|
92
|
+
const o = Date.now();
|
|
93
|
+
await this.emitTelemetry("pie-tool-library-load-start", {
|
|
94
|
+
toolId: "calculator",
|
|
95
|
+
backend: "desmos",
|
|
96
|
+
operation: "desmos-script-load"
|
|
97
|
+
});
|
|
98
|
+
try {
|
|
99
|
+
await this.loadDesmosScript(), await this.emitTelemetry("pie-tool-library-load-success", {
|
|
100
|
+
toolId: "calculator",
|
|
101
|
+
backend: "desmos",
|
|
102
|
+
operation: "desmos-script-load",
|
|
103
|
+
duration: Date.now() - o
|
|
104
|
+
});
|
|
105
|
+
} catch (t) {
|
|
106
|
+
throw await this.emitTelemetry("pie-tool-library-load-error", {
|
|
107
|
+
toolId: "calculator",
|
|
108
|
+
backend: "desmos",
|
|
109
|
+
operation: "desmos-script-load",
|
|
110
|
+
duration: Date.now() - o,
|
|
111
|
+
errorType: "ToolLibraryLoadError",
|
|
112
|
+
message: t instanceof Error ? t.message : String(t)
|
|
113
|
+
}), t;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
this.initialized = !0;
|
|
65
117
|
}
|
|
66
118
|
}
|
|
67
119
|
/**
|
|
68
120
|
* Create a calculator instance
|
|
69
121
|
*/
|
|
70
|
-
async createCalculator(e,
|
|
122
|
+
async createCalculator(e, o, t) {
|
|
71
123
|
if (this.initialized || await this.initialize(), !this.supportsType(e))
|
|
72
124
|
throw new Error(`Desmos does not support calculator type: ${e}`);
|
|
73
|
-
return new c(this, e,
|
|
125
|
+
return new c(this, e, o, t, this.apiKey);
|
|
74
126
|
}
|
|
75
127
|
/**
|
|
76
128
|
* Check if type is supported
|
|
@@ -82,7 +134,7 @@ Recommended: Use proxyEndpoint for production, apiKey for development only.`);
|
|
|
82
134
|
* Cleanup
|
|
83
135
|
*/
|
|
84
136
|
destroy() {
|
|
85
|
-
this.initialized = !1;
|
|
137
|
+
this.initialized = !1, this.onTelemetry = void 0;
|
|
86
138
|
}
|
|
87
139
|
/**
|
|
88
140
|
* Get provider capabilities
|
|
@@ -100,22 +152,22 @@ Recommended: Use proxyEndpoint for production, apiKey for development only.`);
|
|
|
100
152
|
}
|
|
101
153
|
}
|
|
102
154
|
class c {
|
|
103
|
-
constructor(e,
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
if (this.provider = e, this.type =
|
|
155
|
+
constructor(e, o, t, i, a) {
|
|
156
|
+
r(this, "provider");
|
|
157
|
+
r(this, "type");
|
|
158
|
+
r(this, "Desmos");
|
|
159
|
+
r(this, "calculator");
|
|
160
|
+
r(this, "container");
|
|
161
|
+
if (this.provider = e, this.type = o, this.container = t, this.Desmos = window.Desmos, !this.Desmos)
|
|
110
162
|
throw new Error("Desmos API not available");
|
|
111
|
-
this._initializeCalculator(
|
|
163
|
+
this._initializeCalculator(i, a);
|
|
112
164
|
}
|
|
113
|
-
_initializeCalculator(e,
|
|
114
|
-
const
|
|
165
|
+
_initializeCalculator(e, o) {
|
|
166
|
+
const t = {
|
|
115
167
|
...e?.desmos || {},
|
|
116
|
-
apiKey:
|
|
168
|
+
apiKey: o || e?.desmos?.apiKey
|
|
117
169
|
};
|
|
118
|
-
switch (e?.restrictedMode && Object.assign(
|
|
170
|
+
switch (e?.restrictedMode && Object.assign(t, {
|
|
119
171
|
expressionsTopbar: !1,
|
|
120
172
|
settingsMenu: !1,
|
|
121
173
|
zoomButtons: !1,
|
|
@@ -123,13 +175,13 @@ class c {
|
|
|
123
175
|
links: !1
|
|
124
176
|
}), this.type) {
|
|
125
177
|
case "graphing":
|
|
126
|
-
this.calculator = this.Desmos.GraphingCalculator(this.container,
|
|
178
|
+
this.calculator = this.Desmos.GraphingCalculator(this.container, t);
|
|
127
179
|
break;
|
|
128
180
|
case "scientific":
|
|
129
|
-
this.calculator = this.Desmos.ScientificCalculator(this.container,
|
|
181
|
+
this.calculator = this.Desmos.ScientificCalculator(this.container, t);
|
|
130
182
|
break;
|
|
131
183
|
case "basic":
|
|
132
|
-
this.calculator = this.Desmos.FourFunctionCalculator(this.container,
|
|
184
|
+
this.calculator = this.Desmos.FourFunctionCalculator(this.container, t);
|
|
133
185
|
break;
|
|
134
186
|
default:
|
|
135
187
|
throw new Error(`Unsupported calculator type: ${this.type}`);
|
|
@@ -146,23 +198,23 @@ class c {
|
|
|
146
198
|
setValue(e) {
|
|
147
199
|
if (this.type === "graphing" && this.calculator.setState)
|
|
148
200
|
try {
|
|
149
|
-
const
|
|
150
|
-
this.calculator.setState(
|
|
151
|
-
} catch (
|
|
152
|
-
console.error("[DesmosCalculator] Failed to set state:",
|
|
201
|
+
const o = JSON.parse(e);
|
|
202
|
+
this.calculator.setState(o);
|
|
203
|
+
} catch (o) {
|
|
204
|
+
console.error("[DesmosCalculator] Failed to set state:", o);
|
|
153
205
|
}
|
|
154
206
|
}
|
|
155
207
|
clear() {
|
|
156
208
|
this.calculator.setBlank && this.calculator.setBlank();
|
|
157
209
|
}
|
|
158
210
|
async evaluate(e) {
|
|
159
|
-
return this.type === "graphing" ? new Promise((
|
|
160
|
-
const
|
|
161
|
-
this.calculator.setExpression({ id:
|
|
211
|
+
return this.type === "graphing" ? new Promise((o) => {
|
|
212
|
+
const t = `eval_${Date.now()}`;
|
|
213
|
+
this.calculator.setExpression({ id: t, latex: e }), setTimeout(() => {
|
|
162
214
|
const a = this.calculator.HelperExpression({
|
|
163
215
|
latex: e
|
|
164
216
|
}).numericValue || e;
|
|
165
|
-
this.calculator.removeExpression({ id:
|
|
217
|
+
this.calculator.removeExpression({ id: t }), o(String(a));
|
|
166
218
|
}, 100);
|
|
167
219
|
}) : e;
|
|
168
220
|
}
|
|
@@ -188,5 +240,5 @@ class c {
|
|
|
188
240
|
}
|
|
189
241
|
}
|
|
190
242
|
export {
|
|
191
|
-
|
|
243
|
+
p as DesmosCalculatorProvider
|
|
192
244
|
};
|