@pie-players/pie-section-player 0.3.17 → 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.
Files changed (29) hide show
  1. package/README.md +76 -2
  2. package/dist/components/shared/player-action.d.ts +0 -2
  3. package/dist/components/shared/player-action.d.ts.map +1 -1
  4. package/dist/components/shared/player-preload.d.ts.map +1 -1
  5. package/dist/components/shared/section-player-runtime.d.ts +38 -7
  6. package/dist/components/shared/section-player-runtime.d.ts.map +1 -1
  7. package/dist/components/shared/section-player-view-state.d.ts.map +1 -1
  8. package/dist/contracts/layout-contract.d.ts +1 -1
  9. package/dist/contracts/layout-contract.d.ts.map +1 -1
  10. package/dist/contracts/layout-parity-metadata.d.ts.map +1 -1
  11. package/dist/controllers/SectionController.d.ts.map +1 -1
  12. package/dist/defineProperty-CyepwRr5-eHUSgEtz.js +33 -0
  13. package/dist/defineProperty-CyepwRr5.js +33 -0
  14. package/dist/dist-BCuSaTvi.js +393 -0
  15. package/dist/dist-BIgX-aC4-C5B4fLQK.js +389 -0
  16. package/dist/dist-DwP27yIs-gkxodgFn.js +201 -0
  17. package/dist/dist-S3IAfazl.js +201 -0
  18. package/dist/{index-BZq66Ke6-D8dZwpj4.js → module-COIydQYl-2o-TlgiW.js} +38152 -30086
  19. package/dist/pie-section-player.js +7438 -8680
  20. package/dist/player-preload-C_CjM5hv.js +6317 -0
  21. package/dist/tool-annotation-toolbar-BS_MjvXd.js +3974 -0
  22. package/dist/utils/player-preload.js +5 -5
  23. package/package.json +14 -14
  24. package/dist/index-CGqExkh0-DYpgzOOU.js +0 -338
  25. package/dist/index-CGqExkh0.js +0 -354
  26. package/dist/index-DF-Dk87f-lxErM8bo.js +0 -178
  27. package/dist/index-DF-Dk87f.js +0 -192
  28. package/dist/player-preload-Dxvgw3gW.js +0 -7023
  29. package/dist/tool-annotation-toolbar-BOoJpOXj.js +0 -4845
@@ -1,192 +0,0 @@
1
- var l = Object.defineProperty;
2
- var n = (i, e, t) => e in i ? l(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
- var o = (i, e, t) => n(i, typeof e != "symbol" ? e + "" : e, t);
4
- class d {
5
- constructor() {
6
- o(this, "providerId", "desmos");
7
- o(this, "providerName", "Desmos");
8
- o(this, "supportedTypes", [
9
- "basic",
10
- "scientific",
11
- "graphing"
12
- ]);
13
- o(this, "version", "1.10");
14
- o(this, "initialized", !1);
15
- o(this, "apiKey");
16
- o(this, "proxyEndpoint");
17
- o(this, "isDevelopment", !1);
18
- }
19
- /**
20
- * Get the configured API key
21
- * @internal Used internally by calculator instances
22
- */
23
- getApiKey() {
24
- return this.apiKey;
25
- }
26
- /**
27
- * Dynamically load the Desmos calculator library
28
- * @private
29
- */
30
- async loadDesmosScript() {
31
- return new Promise((e, t) => {
32
- 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";
33
- s.src = r, s.async = !0, s.onload = () => {
34
- window.Desmos ? (console.log("[DesmosProvider] Desmos API loaded successfully"), e()) : t(new Error("Desmos API loaded but window.Desmos is undefined"));
35
- }, s.onerror = () => {
36
- t(new Error("Failed to load Desmos API from CDN"));
37
- }, document.head.appendChild(s);
38
- });
39
- }
40
- /**
41
- * Initialize Desmos library
42
- * @param config Configuration with API key (development) or proxy endpoint (production)
43
- */
44
- async initialize(e) {
45
- if (!this.initialized) {
46
- if (typeof window > "u")
47
- throw new Error("Desmos calculators can only be initialized in the browser");
48
- if (this.isDevelopment = process.env.NODE_ENV === "development" || typeof process > "u" || !process.env.NODE_ENV, e?.proxyEndpoint) {
49
- this.proxyEndpoint = e.proxyEndpoint;
50
- try {
51
- const t = await fetch(e.proxyEndpoint);
52
- if (!t.ok)
53
- throw new Error(`Proxy endpoint returned ${t.status}`);
54
- const s = await t.json();
55
- this.apiKey = s.apiKey, console.log("[DesmosProvider] Initialized with server-side proxy (SECURE)");
56
- } catch (t) {
57
- throw new Error(`[DesmosProvider] Failed to fetch API key from proxy: ${t}`);
58
- }
59
- } 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
- This is insecure for production. Use proxyEndpoint instead.
61
- See: https://pie-players.dev/docs/calculator-desmos#security`)) : console.warn(`[DesmosProvider] No API key or proxy endpoint provided.
62
- Production usage requires authentication. Obtain API key from https://www.desmos.com/api
63
- Recommended: Use proxyEndpoint for production, apiKey for development only.`);
64
- window.Desmos || (console.log("[DesmosProvider] Loading Desmos API library..."), await this.loadDesmosScript()), this.initialized = !0;
65
- }
66
- }
67
- /**
68
- * Create a calculator instance
69
- */
70
- async createCalculator(e, t, s) {
71
- if (this.initialized || await this.initialize(), !this.supportsType(e))
72
- throw new Error(`Desmos does not support calculator type: ${e}`);
73
- return new c(this, e, t, s, this.apiKey);
74
- }
75
- /**
76
- * Check if type is supported
77
- */
78
- supportsType(e) {
79
- return this.supportedTypes.includes(e);
80
- }
81
- /**
82
- * Cleanup
83
- */
84
- destroy() {
85
- this.initialized = !1;
86
- }
87
- /**
88
- * Get provider capabilities
89
- */
90
- getCapabilities() {
91
- return {
92
- supportsHistory: !1,
93
- // Desmos doesn't expose history API
94
- supportsGraphing: !0,
95
- supportsExpressions: !0,
96
- canExport: !0,
97
- maxPrecision: 15,
98
- inputMethods: ["keyboard", "mouse", "touch"]
99
- };
100
- }
101
- }
102
- class c {
103
- constructor(e, t, s, r, a) {
104
- o(this, "provider");
105
- o(this, "type");
106
- o(this, "Desmos");
107
- o(this, "calculator");
108
- o(this, "container");
109
- if (this.provider = e, this.type = t, this.container = s, this.Desmos = window.Desmos, !this.Desmos)
110
- throw new Error("Desmos API not available");
111
- this._initializeCalculator(r, a);
112
- }
113
- _initializeCalculator(e, t) {
114
- const s = {
115
- ...e?.desmos || {},
116
- apiKey: t || e?.desmos?.apiKey
117
- };
118
- switch (e?.restrictedMode && Object.assign(s, {
119
- expressionsTopbar: !1,
120
- settingsMenu: !1,
121
- zoomButtons: !1,
122
- expressions: !1,
123
- links: !1
124
- }), this.type) {
125
- case "graphing":
126
- this.calculator = this.Desmos.GraphingCalculator(this.container, s);
127
- break;
128
- case "scientific":
129
- this.calculator = this.Desmos.ScientificCalculator(this.container, s);
130
- break;
131
- case "basic":
132
- this.calculator = this.Desmos.FourFunctionCalculator(this.container, s);
133
- break;
134
- default:
135
- throw new Error(`Unsupported calculator type: ${this.type}`);
136
- }
137
- console.log(`[DesmosCalculator] Created ${this.type} calculator`);
138
- }
139
- getValue() {
140
- if (this.type === "graphing" && this.calculator.getState) {
141
- const e = this.calculator.getState();
142
- return JSON.stringify(e);
143
- }
144
- return "";
145
- }
146
- setValue(e) {
147
- if (this.type === "graphing" && this.calculator.setState)
148
- try {
149
- const t = JSON.parse(e);
150
- this.calculator.setState(t);
151
- } catch (t) {
152
- console.error("[DesmosCalculator] Failed to set state:", t);
153
- }
154
- }
155
- clear() {
156
- this.calculator.setBlank && this.calculator.setBlank();
157
- }
158
- async evaluate(e) {
159
- return this.type === "graphing" ? new Promise((t) => {
160
- const s = `eval_${Date.now()}`;
161
- this.calculator.setExpression({ id: s, latex: e }), setTimeout(() => {
162
- const a = this.calculator.HelperExpression({
163
- latex: e
164
- }).numericValue || e;
165
- this.calculator.removeExpression({ id: s }), t(String(a));
166
- }, 100);
167
- }) : e;
168
- }
169
- resize() {
170
- this.calculator.resize && this.calculator.resize();
171
- }
172
- exportState() {
173
- let e = {};
174
- return this.type === "graphing" && this.calculator.getState && (e = this.calculator.getState()), {
175
- type: this.type,
176
- provider: "desmos",
177
- value: this.getValue(),
178
- providerState: e
179
- };
180
- }
181
- importState(e) {
182
- if (e.provider !== "desmos")
183
- throw new Error(`Cannot import state from provider: ${e.provider}`);
184
- e.providerState && this.calculator.setState ? this.calculator.setState(e.providerState) : e.value && this.setValue(e.value);
185
- }
186
- destroy() {
187
- this.calculator && this.calculator.destroy && this.calculator.destroy(), this.container.replaceChildren(), console.log("[DesmosCalculator] destroyed");
188
- }
189
- }
190
- export {
191
- d as DesmosCalculatorProvider
192
- };