@pie-players/pie-section-player 0.3.64 → 0.3.65
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 +64 -19
- package/dist/components/shared/card-media-region.d.ts +50 -0
- package/dist/components/shared/section-player-view-state.d.ts +35 -0
- package/dist/pie-section-player.js +17093 -18705
- package/package.json +9 -9
- package/dist/chunks/defineProperty-f7fab5da.js +0 -33
- package/dist/chunks/dist-c770ad18.js +0 -213
- package/dist/chunks/dist-fed7cb49.js +0 -492
- package/dist/components/shared/section-item-media.d.ts +0 -88
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-players/pie-section-player",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.65",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Web component for rendering QTI 3.0 assessment sections with passages and items",
|
|
6
6
|
"license": "MIT",
|
|
@@ -94,24 +94,24 @@
|
|
|
94
94
|
"test": "bun test '.test.ts'"
|
|
95
95
|
},
|
|
96
96
|
"dependencies": {
|
|
97
|
-
"@pie-players/pie-assessment-toolkit": "0.3.
|
|
98
|
-
"@pie-players/pie-default-tool-loaders": "0.3.
|
|
99
|
-
"@pie-players/pie-item-player": "0.3.
|
|
100
|
-
"@pie-players/pie-context": "0.3.
|
|
101
|
-
"@pie-players/pie-players-shared": "0.3.
|
|
97
|
+
"@pie-players/pie-assessment-toolkit": "0.3.65",
|
|
98
|
+
"@pie-players/pie-default-tool-loaders": "0.3.65",
|
|
99
|
+
"@pie-players/pie-item-player": "0.3.65",
|
|
100
|
+
"@pie-players/pie-context": "0.3.65",
|
|
101
|
+
"@pie-players/pie-players-shared": "0.3.65"
|
|
102
102
|
},
|
|
103
103
|
"devDependencies": {
|
|
104
104
|
"@axe-core/playwright": "^4.12.1",
|
|
105
|
-
"@biomejs/biome": "^2.5.
|
|
105
|
+
"@biomejs/biome": "^2.5.7",
|
|
106
106
|
"@happy-dom/global-registrator": "^20.11.1",
|
|
107
107
|
"@playwright/test": "^1.62.1",
|
|
108
108
|
"@sveltejs/vite-plugin-svelte": "^7.2.0",
|
|
109
109
|
"@types/node": "^25.1.0",
|
|
110
110
|
"svelte": "^5.56.8",
|
|
111
|
-
"svelte-check": "^4.
|
|
111
|
+
"svelte-check": "^4.7.5",
|
|
112
112
|
"typescript": "^5.9.3",
|
|
113
113
|
"vite": "^8.0.10",
|
|
114
|
-
"vite-plugin-dts": "^
|
|
114
|
+
"vite-plugin-dts": "^5.0.3"
|
|
115
115
|
},
|
|
116
116
|
"homepage": "https://github.com/pie-framework/pie-players/tree/master/packages/section-player#readme",
|
|
117
117
|
"bugs": {
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
function o(e) {
|
|
2
|
-
"@babel/helpers - typeof";
|
|
3
|
-
return o = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(t) {
|
|
4
|
-
return typeof t;
|
|
5
|
-
} : function(t) {
|
|
6
|
-
return t && typeof Symbol == "function" && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
|
|
7
|
-
}, o(e);
|
|
8
|
-
}
|
|
9
|
-
function i(e, t) {
|
|
10
|
-
if (o(e) != "object" || !e) return e;
|
|
11
|
-
var r = e[Symbol.toPrimitive];
|
|
12
|
-
if (r !== void 0) {
|
|
13
|
-
var n = r.call(e, t || "default");
|
|
14
|
-
if (o(n) != "object") return n;
|
|
15
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
16
|
-
}
|
|
17
|
-
return (t === "string" ? String : Number)(e);
|
|
18
|
-
}
|
|
19
|
-
function u(e) {
|
|
20
|
-
var t = i(e, "string");
|
|
21
|
-
return o(t) == "symbol" ? t : t + "";
|
|
22
|
-
}
|
|
23
|
-
function f(e, t, r) {
|
|
24
|
-
return (t = u(t)) in e ? Object.defineProperty(e, t, {
|
|
25
|
-
value: r,
|
|
26
|
-
enumerable: !0,
|
|
27
|
-
configurable: !0,
|
|
28
|
-
writable: !0
|
|
29
|
-
}) : e[t] = r, e;
|
|
30
|
-
}
|
|
31
|
-
export {
|
|
32
|
-
f as t
|
|
33
|
-
};
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
import { t as s } from "./defineProperty-f7fab5da.js";
|
|
2
|
-
var n = class {
|
|
3
|
-
constructor() {
|
|
4
|
-
s(this, "providerId", "desmos"), s(this, "providerName", "Desmos"), s(this, "supportedTypes", [
|
|
5
|
-
"basic",
|
|
6
|
-
"scientific",
|
|
7
|
-
"graphing"
|
|
8
|
-
]), s(this, "version", "1.12"), s(this, "initialized", !1), s(this, "apiKey", void 0), s(this, "proxyEndpoint", void 0), s(this, "isDevelopment", !1), s(this, "onTelemetry", void 0);
|
|
9
|
-
}
|
|
10
|
-
async emitTelemetry(e, o) {
|
|
11
|
-
try {
|
|
12
|
-
await this.onTelemetry?.(e, o);
|
|
13
|
-
} catch (t) {
|
|
14
|
-
console.warn("[DesmosProvider] telemetry callback failed:", t);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
getApiKey() {
|
|
18
|
-
return this.apiKey;
|
|
19
|
-
}
|
|
20
|
-
async loadDesmosScript() {
|
|
21
|
-
return new Promise((e, o) => {
|
|
22
|
-
const t = document.createElement("script");
|
|
23
|
-
t.src = this.apiKey ? `https://www.desmos.com/api/v1.12/calculator.js?apiKey=${this.apiKey}` : "https://www.desmos.com/api/v1.12/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"));
|
|
25
|
-
}, t.onerror = () => {
|
|
26
|
-
o(/* @__PURE__ */ new Error("Failed to load Desmos API from CDN"));
|
|
27
|
-
}, document.head.appendChild(t);
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
async initialize(e) {
|
|
31
|
-
if (!this.initialized) {
|
|
32
|
-
if (this.onTelemetry = e?.onTelemetry, typeof window > "u") throw new Error("Desmos calculators can only be initialized in the browser");
|
|
33
|
-
if (this.isDevelopment = process.env.NODE_ENV === "development" || typeof process > "u" || !process.env.NODE_ENV, e?.proxyEndpoint) {
|
|
34
|
-
this.proxyEndpoint = e.proxyEndpoint;
|
|
35
|
-
const o = Date.now();
|
|
36
|
-
await this.emitTelemetry("pie-tool-backend-call-start", {
|
|
37
|
-
toolId: "calculator",
|
|
38
|
-
backend: "desmos",
|
|
39
|
-
operation: "proxy-auth-fetch"
|
|
40
|
-
});
|
|
41
|
-
try {
|
|
42
|
-
const t = await fetch(e.proxyEndpoint);
|
|
43
|
-
if (!t.ok) throw new Error(`Proxy endpoint returned ${t.status}`);
|
|
44
|
-
const r = await t.json();
|
|
45
|
-
this.apiKey = r.apiKey, await this.emitTelemetry("pie-tool-backend-call-success", {
|
|
46
|
-
toolId: "calculator",
|
|
47
|
-
backend: "desmos",
|
|
48
|
-
operation: "proxy-auth-fetch",
|
|
49
|
-
duration: Date.now() - o
|
|
50
|
-
}), console.log("[DesmosProvider] Initialized with server-side proxy (SECURE)");
|
|
51
|
-
} catch (t) {
|
|
52
|
-
throw await this.emitTelemetry("pie-tool-backend-call-error", {
|
|
53
|
-
toolId: "calculator",
|
|
54
|
-
backend: "desmos",
|
|
55
|
-
operation: "proxy-auth-fetch",
|
|
56
|
-
duration: Date.now() - o,
|
|
57
|
-
errorType: "CalculatorProxyAuthError",
|
|
58
|
-
message: t instanceof Error ? t.message : String(t)
|
|
59
|
-
}), new Error(`[DesmosProvider] Failed to fetch API key from proxy: ${t}`);
|
|
60
|
-
}
|
|
61
|
-
} 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!
|
|
62
|
-
This is insecure for production. Use proxyEndpoint instead.
|
|
63
|
-
See: https://pie-players.dev/docs/calculator-desmos#security`)) : console.warn(`[DesmosProvider] No API key or proxy endpoint provided.
|
|
64
|
-
Production usage requires authentication. Obtain API key from https://www.desmos.com/api
|
|
65
|
-
Recommended: Use proxyEndpoint for production, apiKey for development only.`);
|
|
66
|
-
if (!window.Desmos) {
|
|
67
|
-
console.log("[DesmosProvider] Loading Desmos API library...");
|
|
68
|
-
const o = Date.now();
|
|
69
|
-
await this.emitTelemetry("pie-tool-library-load-start", {
|
|
70
|
-
toolId: "calculator",
|
|
71
|
-
backend: "desmos",
|
|
72
|
-
operation: "desmos-script-load"
|
|
73
|
-
});
|
|
74
|
-
try {
|
|
75
|
-
await this.loadDesmosScript(), await this.emitTelemetry("pie-tool-library-load-success", {
|
|
76
|
-
toolId: "calculator",
|
|
77
|
-
backend: "desmos",
|
|
78
|
-
operation: "desmos-script-load",
|
|
79
|
-
duration: Date.now() - o
|
|
80
|
-
});
|
|
81
|
-
} catch (t) {
|
|
82
|
-
throw await this.emitTelemetry("pie-tool-library-load-error", {
|
|
83
|
-
toolId: "calculator",
|
|
84
|
-
backend: "desmos",
|
|
85
|
-
operation: "desmos-script-load",
|
|
86
|
-
duration: Date.now() - o,
|
|
87
|
-
errorType: "ToolLibraryLoadError",
|
|
88
|
-
message: t instanceof Error ? t.message : String(t)
|
|
89
|
-
}), t;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
this.initialized = !0;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
async createCalculator(e, o, t) {
|
|
96
|
-
if (this.initialized || await this.initialize(), !this.supportsType(e)) throw new Error(`Desmos does not support calculator type: ${e}`);
|
|
97
|
-
return new a(this, e, o, t, this.apiKey);
|
|
98
|
-
}
|
|
99
|
-
supportsType(e) {
|
|
100
|
-
return this.supportedTypes.includes(e);
|
|
101
|
-
}
|
|
102
|
-
destroy() {
|
|
103
|
-
this.initialized = !1, this.onTelemetry = void 0;
|
|
104
|
-
}
|
|
105
|
-
getCapabilities() {
|
|
106
|
-
return {
|
|
107
|
-
supportsHistory: !1,
|
|
108
|
-
supportsGraphing: !0,
|
|
109
|
-
supportsExpressions: !0,
|
|
110
|
-
canExport: !0,
|
|
111
|
-
maxPrecision: 15,
|
|
112
|
-
inputMethods: [
|
|
113
|
-
"keyboard",
|
|
114
|
-
"mouse",
|
|
115
|
-
"touch"
|
|
116
|
-
]
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
}, a = class {
|
|
120
|
-
constructor(e, o, t, r, i) {
|
|
121
|
-
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");
|
|
122
|
-
this._initializeCalculator(r, i);
|
|
123
|
-
}
|
|
124
|
-
_initializeCalculator(e, o) {
|
|
125
|
-
const t = {
|
|
126
|
-
...e?.desmos || {},
|
|
127
|
-
apiKey: o || e?.desmos?.apiKey
|
|
128
|
-
};
|
|
129
|
-
switch (e?.restrictedMode && Object.assign(t, {
|
|
130
|
-
expressionsTopbar: !1,
|
|
131
|
-
settingsMenu: !1,
|
|
132
|
-
zoomButtons: !1,
|
|
133
|
-
expressions: !1,
|
|
134
|
-
links: !1
|
|
135
|
-
}), this.type) {
|
|
136
|
-
case "graphing":
|
|
137
|
-
this.calculator = this.Desmos.GraphingCalculator(this.container, t);
|
|
138
|
-
break;
|
|
139
|
-
case "scientific":
|
|
140
|
-
this.calculator = this.Desmos.ScientificCalculator(this.container, t);
|
|
141
|
-
break;
|
|
142
|
-
case "basic":
|
|
143
|
-
this.calculator = this.Desmos.FourFunctionCalculator(this.container, t);
|
|
144
|
-
break;
|
|
145
|
-
default:
|
|
146
|
-
throw new Error(`Unsupported calculator type: ${this.type}`);
|
|
147
|
-
}
|
|
148
|
-
console.log(`[DesmosCalculator] Created ${this.type} calculator`);
|
|
149
|
-
}
|
|
150
|
-
getValue() {
|
|
151
|
-
if (this.type === "graphing" && this.calculator.getState) {
|
|
152
|
-
const e = this.calculator.getState();
|
|
153
|
-
return JSON.stringify(e);
|
|
154
|
-
}
|
|
155
|
-
return "";
|
|
156
|
-
}
|
|
157
|
-
setValue(e) {
|
|
158
|
-
if (this.type === "graphing" && this.calculator.setState) try {
|
|
159
|
-
const o = JSON.parse(e);
|
|
160
|
-
this.calculator.setState(o);
|
|
161
|
-
} catch (o) {
|
|
162
|
-
console.error("[DesmosCalculator] Failed to set state:", o);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
clear() {
|
|
166
|
-
this.calculator.setBlank && this.calculator.setBlank();
|
|
167
|
-
}
|
|
168
|
-
async evaluate(e) {
|
|
169
|
-
return this.type === "graphing" ? new Promise((o) => {
|
|
170
|
-
const t = `eval_${Date.now()}`;
|
|
171
|
-
this.calculator.setExpression({
|
|
172
|
-
id: t,
|
|
173
|
-
latex: e
|
|
174
|
-
}), setTimeout(() => {
|
|
175
|
-
const r = this.calculator.HelperExpression({ latex: e }).numericValue || e;
|
|
176
|
-
this.calculator.removeExpression({ id: t }), o(String(r));
|
|
177
|
-
}, 100);
|
|
178
|
-
}) : e;
|
|
179
|
-
}
|
|
180
|
-
resize() {
|
|
181
|
-
this.calculator.resize && this.calculator.resize();
|
|
182
|
-
}
|
|
183
|
-
focus() {
|
|
184
|
-
try {
|
|
185
|
-
if (this.type === "graphing" && typeof this.calculator?.focusFirstExpression == "function") {
|
|
186
|
-
this.calculator.focusFirstExpression();
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
this.container.querySelector('.dcg-mq-editable-field[tabindex="0"], textarea, [contenteditable="true"], [tabindex]:not([tabindex="-1"])')?.focus();
|
|
190
|
-
} catch (e) {
|
|
191
|
-
console.warn("[DesmosCalculator] focus() failed:", e);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
exportState() {
|
|
195
|
-
let e = {};
|
|
196
|
-
return this.type === "graphing" && this.calculator.getState && (e = this.calculator.getState()), {
|
|
197
|
-
type: this.type,
|
|
198
|
-
provider: "desmos",
|
|
199
|
-
value: this.getValue(),
|
|
200
|
-
providerState: e
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
importState(e) {
|
|
204
|
-
if (e.provider !== "desmos") throw new Error(`Cannot import state from provider: ${e.provider}`);
|
|
205
|
-
e.providerState && this.calculator.setState ? this.calculator.setState(e.providerState) : e.value && this.setValue(e.value);
|
|
206
|
-
}
|
|
207
|
-
destroy() {
|
|
208
|
-
this.calculator && this.calculator.destroy && this.calculator.destroy(), this.container.replaceChildren(), console.log("[DesmosCalculator] destroyed");
|
|
209
|
-
}
|
|
210
|
-
};
|
|
211
|
-
export {
|
|
212
|
-
n as DesmosCalculatorProvider
|
|
213
|
-
};
|