@pie-players/pie-assessment-toolkit 0.2.0
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 +520 -0
- package/dist/attempt/TestSession.d.ts +90 -0
- package/dist/attempt/TestSession.d.ts.map +1 -0
- package/dist/attempt/TestSession.js +174 -0
- package/dist/attempt/TestSession.js.map +1 -0
- package/dist/core/TypedEventBus.d.ts +48 -0
- package/dist/core/TypedEventBus.d.ts.map +1 -0
- package/dist/core/TypedEventBus.js +63 -0
- package/dist/core/TypedEventBus.js.map +1 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +44 -0
- package/dist/index.js.map +1 -0
- package/dist/item-loader.d.ts +45 -0
- package/dist/item-loader.d.ts.map +1 -0
- package/dist/item-loader.js +62 -0
- package/dist/item-loader.js.map +1 -0
- package/dist/player/AssessmentPlayer.d.ts +388 -0
- package/dist/player/AssessmentPlayer.d.ts.map +1 -0
- package/dist/player/AssessmentPlayer.js +965 -0
- package/dist/player/AssessmentPlayer.js.map +1 -0
- package/dist/player/index.d.ts +17 -0
- package/dist/player/index.d.ts.map +1 -0
- package/dist/player/index.js +15 -0
- package/dist/player/index.js.map +1 -0
- package/dist/player/navigation-types.d.ts +63 -0
- package/dist/player/navigation-types.d.ts.map +1 -0
- package/dist/player/navigation-types.js +7 -0
- package/dist/player/navigation-types.js.map +1 -0
- package/dist/player/qti-navigation.d.ts +29 -0
- package/dist/player/qti-navigation.d.ts.map +1 -0
- package/dist/player/qti-navigation.js +160 -0
- package/dist/player/qti-navigation.js.map +1 -0
- package/dist/reference-layout/index.d.ts +19 -0
- package/dist/reference-layout/index.d.ts.map +1 -0
- package/dist/reference-layout/index.js +20 -0
- package/dist/reference-layout/index.js.map +1 -0
- package/dist/services/AccessibilityCatalogResolver.d.ts +141 -0
- package/dist/services/AccessibilityCatalogResolver.d.ts.map +1 -0
- package/dist/services/AccessibilityCatalogResolver.js +249 -0
- package/dist/services/AccessibilityCatalogResolver.js.map +1 -0
- package/dist/services/AssessmentAuthoringService.d.ts +60 -0
- package/dist/services/AssessmentAuthoringService.d.ts.map +1 -0
- package/dist/services/AssessmentAuthoringService.js +183 -0
- package/dist/services/AssessmentAuthoringService.js.map +1 -0
- package/dist/services/ContextVariableStore.d.ts +114 -0
- package/dist/services/ContextVariableStore.d.ts.map +1 -0
- package/dist/services/ContextVariableStore.js +207 -0
- package/dist/services/ContextVariableStore.js.map +1 -0
- package/dist/services/ElementToolStateStore.d.ts +125 -0
- package/dist/services/ElementToolStateStore.d.ts.map +1 -0
- package/dist/services/ElementToolStateStore.js +200 -0
- package/dist/services/ElementToolStateStore.js.map +1 -0
- package/dist/services/HighlightCoordinator.d.ts +179 -0
- package/dist/services/HighlightCoordinator.d.ts.map +1 -0
- package/dist/services/HighlightCoordinator.js +446 -0
- package/dist/services/HighlightCoordinator.js.map +1 -0
- package/dist/services/I18nService.d.ts +121 -0
- package/dist/services/I18nService.d.ts.map +1 -0
- package/dist/services/I18nService.js +276 -0
- package/dist/services/I18nService.js.map +1 -0
- package/dist/services/PNPMapper.d.ts +71 -0
- package/dist/services/PNPMapper.d.ts.map +1 -0
- package/dist/services/PNPMapper.js +98 -0
- package/dist/services/PNPMapper.js.map +1 -0
- package/dist/services/PNPToolResolver.d.ts +127 -0
- package/dist/services/PNPToolResolver.d.ts.map +1 -0
- package/dist/services/PNPToolResolver.js +222 -0
- package/dist/services/PNPToolResolver.js.map +1 -0
- package/dist/services/SSMLExtractor.d.ts +61 -0
- package/dist/services/SSMLExtractor.d.ts.map +1 -0
- package/dist/services/SSMLExtractor.js +181 -0
- package/dist/services/SSMLExtractor.js.map +1 -0
- package/dist/services/TTSService.d.ts +162 -0
- package/dist/services/TTSService.d.ts.map +1 -0
- package/dist/services/TTSService.js +465 -0
- package/dist/services/TTSService.js.map +1 -0
- package/dist/services/ThemeProvider.d.ts +95 -0
- package/dist/services/ThemeProvider.d.ts.map +1 -0
- package/dist/services/ThemeProvider.js +299 -0
- package/dist/services/ThemeProvider.js.map +1 -0
- package/dist/services/ToolConfigResolver.d.ts +162 -0
- package/dist/services/ToolConfigResolver.d.ts.map +1 -0
- package/dist/services/ToolConfigResolver.js +230 -0
- package/dist/services/ToolConfigResolver.js.map +1 -0
- package/dist/services/ToolCoordinator.d.ts +137 -0
- package/dist/services/ToolCoordinator.d.ts.map +1 -0
- package/dist/services/ToolCoordinator.js +318 -0
- package/dist/services/ToolCoordinator.js.map +1 -0
- package/dist/services/ToolkitCoordinator.d.ts +188 -0
- package/dist/services/ToolkitCoordinator.d.ts.map +1 -0
- package/dist/services/ToolkitCoordinator.js +252 -0
- package/dist/services/ToolkitCoordinator.js.map +1 -0
- package/dist/services/interfaces.d.ts +391 -0
- package/dist/services/interfaces.d.ts.map +1 -0
- package/dist/services/interfaces.js +12 -0
- package/dist/services/interfaces.js.map +1 -0
- package/dist/services/tool-providers/DesmosToolProvider.d.ts +103 -0
- package/dist/services/tool-providers/DesmosToolProvider.d.ts.map +1 -0
- package/dist/services/tool-providers/DesmosToolProvider.js +127 -0
- package/dist/services/tool-providers/DesmosToolProvider.js.map +1 -0
- package/dist/services/tool-providers/IToolProvider.d.ts +137 -0
- package/dist/services/tool-providers/IToolProvider.d.ts.map +1 -0
- package/dist/services/tool-providers/IToolProvider.js +13 -0
- package/dist/services/tool-providers/IToolProvider.js.map +1 -0
- package/dist/services/tool-providers/TIToolProvider.d.ts +107 -0
- package/dist/services/tool-providers/TIToolProvider.d.ts.map +1 -0
- package/dist/services/tool-providers/TIToolProvider.js +123 -0
- package/dist/services/tool-providers/TIToolProvider.js.map +1 -0
- package/dist/services/tool-providers/TTSToolProvider.d.ts +143 -0
- package/dist/services/tool-providers/TTSToolProvider.d.ts.map +1 -0
- package/dist/services/tool-providers/TTSToolProvider.js +168 -0
- package/dist/services/tool-providers/TTSToolProvider.js.map +1 -0
- package/dist/services/tool-providers/ToolProviderRegistry.d.ts +165 -0
- package/dist/services/tool-providers/ToolProviderRegistry.d.ts.map +1 -0
- package/dist/services/tool-providers/ToolProviderRegistry.js +240 -0
- package/dist/services/tool-providers/ToolProviderRegistry.js.map +1 -0
- package/dist/services/tool-providers/index.d.ts +18 -0
- package/dist/services/tool-providers/index.d.ts.map +1 -0
- package/dist/services/tool-providers/index.js +15 -0
- package/dist/services/tool-providers/index.js.map +1 -0
- package/dist/services/tts/browser-provider.d.ts +24 -0
- package/dist/services/tts/browser-provider.d.ts.map +1 -0
- package/dist/services/tts/browser-provider.js +177 -0
- package/dist/services/tts/browser-provider.js.map +1 -0
- package/dist/services/tts/provider-interface.d.ts +131 -0
- package/dist/services/tts/provider-interface.d.ts.map +1 -0
- package/dist/services/tts/provider-interface.js +10 -0
- package/dist/services/tts/provider-interface.js.map +1 -0
- package/dist/tools/calculators/desmos-provider.d.ts +54 -0
- package/dist/tools/calculators/desmos-provider.d.ts.map +1 -0
- package/dist/tools/calculators/desmos-provider.js +384 -0
- package/dist/tools/calculators/desmos-provider.js.map +1 -0
- package/dist/tools/calculators/mathjs-provider.d.ts +50 -0
- package/dist/tools/calculators/mathjs-provider.d.ts.map +1 -0
- package/dist/tools/calculators/mathjs-provider.js +660 -0
- package/dist/tools/calculators/mathjs-provider.js.map +1 -0
- package/dist/tools/calculators/ti-provider.d.ts +122 -0
- package/dist/tools/calculators/ti-provider.d.ts.map +1 -0
- package/dist/tools/calculators/ti-provider.js +587 -0
- package/dist/tools/calculators/ti-provider.js.map +1 -0
- package/dist/tools/client.d.ts +17 -0
- package/dist/tools/client.d.ts.map +1 -0
- package/dist/tools/client.js +26 -0
- package/dist/tools/client.js.map +1 -0
- package/dist/tools/index.d.ts +8 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +10 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/library-loader.d.ts +63 -0
- package/dist/tools/library-loader.d.ts.map +1 -0
- package/dist/tools/library-loader.js +292 -0
- package/dist/tools/library-loader.js.map +1 -0
- package/dist/tools/response-discovery.d.ts +72 -0
- package/dist/tools/response-discovery.d.ts.map +1 -0
- package/dist/tools/response-discovery.js +183 -0
- package/dist/tools/response-discovery.js.map +1 -0
- package/dist/tools/tool-coordinator.d.ts +76 -0
- package/dist/tools/tool-coordinator.d.ts.map +1 -0
- package/dist/tools/tool-coordinator.js +197 -0
- package/dist/tools/tool-coordinator.js.map +1 -0
- package/dist/tools/types.d.ts +427 -0
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/tools/types.js +13 -0
- package/dist/tools/types.js.map +1 -0
- package/dist/tools/variant-resolver.d.ts +48 -0
- package/dist/tools/variant-resolver.d.ts.map +1 -0
- package/dist/tools/variant-resolver.js +214 -0
- package/dist/tools/variant-resolver.js.map +1 -0
- package/dist/types/events.d.ts +157 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/events.js +11 -0
- package/dist/types/events.js.map +1 -0
- package/dist/utils/logger.d.ts +7 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +11 -0
- package/dist/utils/logger.js.map +1 -0
- package/package.json +71 -0
- package/src/README.md +626 -0
- package/src/components/QuestionToolBar.svelte +406 -0
- package/src/player/AssessmentLayout.svelte +68 -0
- package/src/player/README.md +154 -0
- package/src/reference-layout/README.md +135 -0
- package/src/reference-layout/ReferenceLayout.svelte +209 -0
- package/src/reference-layout/components/AssessmentContent.svelte +259 -0
- package/src/reference-layout/components/AssessmentFooter.svelte +89 -0
- package/src/reference-layout/components/AssessmentHeader.svelte +250 -0
- package/src/reference-layout/components/AssessmentNavigation.svelte +134 -0
- package/src/reference-layout/components/AssessmentToolsBar.svelte +176 -0
- package/src/reference-layout/components/ItemPanel.svelte +200 -0
- package/src/reference-layout/components/NotesPanel.svelte +179 -0
- package/src/reference-layout/components/PassagePanel.svelte +76 -0
- package/src/tools/README.md +616 -0
- package/src/tools/calculators/README.md +395 -0
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Desmos Calculator Provider
|
|
3
|
+
* Implementation of CalculatorProvider for Desmos calculators
|
|
4
|
+
*
|
|
5
|
+
* Supports: Basic, Scientific, and Graphing calculators
|
|
6
|
+
* Based on Desmos API v1.10+
|
|
7
|
+
*/
|
|
8
|
+
import { COMMON_LIBRARIES, libraryLoader } from "../library-loader";
|
|
9
|
+
/**
|
|
10
|
+
* Desmos Calculator Provider Implementation
|
|
11
|
+
*/
|
|
12
|
+
export class DesmosCalculatorProvider {
|
|
13
|
+
providerId = "desmos";
|
|
14
|
+
providerName = "Desmos";
|
|
15
|
+
supportedTypes = [
|
|
16
|
+
"basic",
|
|
17
|
+
"scientific",
|
|
18
|
+
"graphing",
|
|
19
|
+
];
|
|
20
|
+
version = "1.10";
|
|
21
|
+
initialized = false;
|
|
22
|
+
apiKey;
|
|
23
|
+
/**
|
|
24
|
+
* Get the configured API key
|
|
25
|
+
*/
|
|
26
|
+
getApiKey() {
|
|
27
|
+
return this.apiKey;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Initialize Desmos library
|
|
31
|
+
* @param config Optional configuration including API key
|
|
32
|
+
*/
|
|
33
|
+
async initialize(config) {
|
|
34
|
+
if (this.initialized)
|
|
35
|
+
return;
|
|
36
|
+
// SSR guard: Desmos calculators should NEVER run on the server
|
|
37
|
+
if (typeof window === "undefined") {
|
|
38
|
+
throw new Error("Desmos calculators can only be initialized in the browser");
|
|
39
|
+
}
|
|
40
|
+
// Store API key from config, environment variable, or global
|
|
41
|
+
this.apiKey =
|
|
42
|
+
config?.apiKey ||
|
|
43
|
+
(typeof process !== "undefined" && process.env?.DESMOS_API_KEY) ||
|
|
44
|
+
(typeof window !== "undefined" && window.PIE_DESMOS_API_KEY);
|
|
45
|
+
// Warn if no API key is provided (production usage requires it)
|
|
46
|
+
if (!this.apiKey) {
|
|
47
|
+
console.warn("[DesmosProvider] No API key provided. Production usage requires a Desmos API key. " +
|
|
48
|
+
"Obtain one from https://www.desmos.com/api or contact partnerships@desmos.com");
|
|
49
|
+
}
|
|
50
|
+
// Load Desmos library
|
|
51
|
+
await libraryLoader.loadScript(COMMON_LIBRARIES.desmos);
|
|
52
|
+
// Verify Desmos API is available
|
|
53
|
+
if (!window.Desmos) {
|
|
54
|
+
throw new Error("Desmos API not loaded");
|
|
55
|
+
}
|
|
56
|
+
this.initialized = true;
|
|
57
|
+
console.log(`[DesmosProvider] Initialized successfully${this.apiKey ? " with API key" : " (no API key)"}`);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Create a calculator instance
|
|
61
|
+
*/
|
|
62
|
+
async createCalculator(type, container, config) {
|
|
63
|
+
if (!this.initialized) {
|
|
64
|
+
await this.initialize();
|
|
65
|
+
}
|
|
66
|
+
if (!this.supportsType(type)) {
|
|
67
|
+
throw new Error(`Desmos does not support calculator type: ${type}`);
|
|
68
|
+
}
|
|
69
|
+
return new DesmosCalculator(this, type, container, config);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Check if type is supported
|
|
73
|
+
*/
|
|
74
|
+
supportsType(type) {
|
|
75
|
+
return this.supportedTypes.includes(type);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Cleanup (no-op for Desmos)
|
|
79
|
+
*/
|
|
80
|
+
destroy() {
|
|
81
|
+
// Desmos doesn't require global cleanup
|
|
82
|
+
this.initialized = false;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Get provider capabilities
|
|
86
|
+
*/
|
|
87
|
+
getCapabilities() {
|
|
88
|
+
return {
|
|
89
|
+
supportsHistory: true,
|
|
90
|
+
supportsGraphing: true,
|
|
91
|
+
supportsExpressions: true,
|
|
92
|
+
canExport: true,
|
|
93
|
+
maxPrecision: 15, // JavaScript number precision
|
|
94
|
+
inputMethods: ["keyboard", "mouse", "touch"],
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Desmos Calculator Instance
|
|
100
|
+
*/
|
|
101
|
+
class DesmosCalculator {
|
|
102
|
+
provider;
|
|
103
|
+
type;
|
|
104
|
+
desmosCalculator;
|
|
105
|
+
container;
|
|
106
|
+
config;
|
|
107
|
+
constructor(provider, type, container, config) {
|
|
108
|
+
this.provider = provider;
|
|
109
|
+
this.type = type;
|
|
110
|
+
this.container = container;
|
|
111
|
+
this.config = config;
|
|
112
|
+
this._initializeCalculator();
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Initialize Desmos calculator instance
|
|
116
|
+
* Based on production implementation patterns
|
|
117
|
+
*/
|
|
118
|
+
_initializeCalculator() {
|
|
119
|
+
const Desmos = window.Desmos;
|
|
120
|
+
// Get Desmos-specific config or empty object
|
|
121
|
+
const desmosConfig = this.config?.desmos || {};
|
|
122
|
+
// Determine API key (config overrides provider-level)
|
|
123
|
+
const apiKey = desmosConfig.apiKey ||
|
|
124
|
+
this.provider.getApiKey();
|
|
125
|
+
// Apply restricted mode defaults if enabled
|
|
126
|
+
const restrictedDefaults = this._getRestrictedModeDefaults();
|
|
127
|
+
// Merge order: type-specific defaults < restricted mode defaults < explicit config
|
|
128
|
+
// This ensures explicit config can override restricted mode when needed
|
|
129
|
+
const options = {
|
|
130
|
+
...this._getTypeSpecificDefaults(),
|
|
131
|
+
...restrictedDefaults,
|
|
132
|
+
...desmosConfig,
|
|
133
|
+
...this._mapConfigToDesmos(this.config),
|
|
134
|
+
};
|
|
135
|
+
// Add API key if available
|
|
136
|
+
if (apiKey) {
|
|
137
|
+
options.apiKey = apiKey;
|
|
138
|
+
}
|
|
139
|
+
// Create appropriate calculator type
|
|
140
|
+
switch (this.type) {
|
|
141
|
+
case "basic":
|
|
142
|
+
this.desmosCalculator = Desmos.FourFunctionCalculator(this.container, options);
|
|
143
|
+
break;
|
|
144
|
+
case "scientific":
|
|
145
|
+
this.desmosCalculator = Desmos.ScientificCalculator(this.container, options);
|
|
146
|
+
break;
|
|
147
|
+
case "graphing":
|
|
148
|
+
this.desmosCalculator = Desmos.GraphingCalculator(this.container, options);
|
|
149
|
+
break;
|
|
150
|
+
default:
|
|
151
|
+
throw new Error(`Unknown Desmos calculator type: ${this.type}`);
|
|
152
|
+
}
|
|
153
|
+
console.log(`[DesmosCalculator] Created ${this.type} calculator with options:`, options);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Get type-specific default options
|
|
157
|
+
*/
|
|
158
|
+
_getTypeSpecificDefaults() {
|
|
159
|
+
const defaults = {
|
|
160
|
+
border: false, // No border around calculator (production implementation pattern)
|
|
161
|
+
};
|
|
162
|
+
switch (this.type) {
|
|
163
|
+
case "basic":
|
|
164
|
+
// Basic calculator: no keypad, no graph paper (just the calculator itself)
|
|
165
|
+
// Matches production FourFunctionCalculator setup
|
|
166
|
+
defaults.keypad = false;
|
|
167
|
+
defaults.graphpaper = false;
|
|
168
|
+
break;
|
|
169
|
+
case "scientific":
|
|
170
|
+
// Scientific calculator: minimal defaults, mostly controlled by config
|
|
171
|
+
break;
|
|
172
|
+
case "graphing":
|
|
173
|
+
// Graphing calculator: enable expressions, zoom buttons, topbar by default
|
|
174
|
+
defaults.expressions = true;
|
|
175
|
+
defaults.zoomButtons = true;
|
|
176
|
+
defaults.expressionsTopbar = true;
|
|
177
|
+
defaults.settingsMenu = true;
|
|
178
|
+
defaults.notes = true;
|
|
179
|
+
defaults.folders = true;
|
|
180
|
+
defaults.images = false; // Images disabled by default (production pattern)
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
return defaults;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Get restricted mode defaults (test mode options)
|
|
187
|
+
* Based on production test mode configuration
|
|
188
|
+
*/
|
|
189
|
+
_getRestrictedModeDefaults() {
|
|
190
|
+
if (!this.config?.restrictedMode) {
|
|
191
|
+
return {};
|
|
192
|
+
}
|
|
193
|
+
// Restricted mode defaults based on production test mode settings
|
|
194
|
+
const restricted = {
|
|
195
|
+
border: false,
|
|
196
|
+
links: false,
|
|
197
|
+
qwertyKeyboard: true,
|
|
198
|
+
degreeMode: true,
|
|
199
|
+
decimalToFraction: true,
|
|
200
|
+
};
|
|
201
|
+
// Type-specific restricted mode options
|
|
202
|
+
if (this.type === "graphing") {
|
|
203
|
+
Object.assign(restricted, {
|
|
204
|
+
images: false,
|
|
205
|
+
folders: false,
|
|
206
|
+
notes: false,
|
|
207
|
+
restrictedFunctions: true,
|
|
208
|
+
plotSingleVariableImplicitEquations: false,
|
|
209
|
+
plotImplicits: false,
|
|
210
|
+
plotInequalities: false,
|
|
211
|
+
sliders: false,
|
|
212
|
+
settingsMenu: false,
|
|
213
|
+
zoomButtons: false,
|
|
214
|
+
geometryComputationFunctions: true,
|
|
215
|
+
distributions: true,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
else if (this.type === "scientific") {
|
|
219
|
+
Object.assign(restricted, {
|
|
220
|
+
functionDefinition: false,
|
|
221
|
+
brailleExpressionDownload: false,
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
return restricted;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Map provider config to Desmos options
|
|
228
|
+
* Legacy mapping for backwards compatibility
|
|
229
|
+
*/
|
|
230
|
+
_mapConfigToDesmos(config) {
|
|
231
|
+
if (!config)
|
|
232
|
+
return {};
|
|
233
|
+
const desmosOptions = {};
|
|
234
|
+
// Map locale to Desmos language option
|
|
235
|
+
if (config.locale) {
|
|
236
|
+
desmosOptions.language = config.locale;
|
|
237
|
+
}
|
|
238
|
+
// Theme mapping (Desmos may support this via CSS, not API)
|
|
239
|
+
// Note: Desmos doesn't have a theme option in the API, but we keep this
|
|
240
|
+
// for potential future use or CSS-based theming
|
|
241
|
+
return desmosOptions;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Get current value/expression
|
|
245
|
+
*/
|
|
246
|
+
getValue() {
|
|
247
|
+
// For graphing calculator, get all expressions
|
|
248
|
+
if (this.type === "graphing") {
|
|
249
|
+
const state = this.desmosCalculator.getState();
|
|
250
|
+
return JSON.stringify(state.expressions.list);
|
|
251
|
+
}
|
|
252
|
+
// For basic/scientific, get current expression
|
|
253
|
+
const state = this.desmosCalculator.getState();
|
|
254
|
+
return state.expression || "";
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Set value/expression
|
|
258
|
+
*/
|
|
259
|
+
setValue(value) {
|
|
260
|
+
if (this.type === "graphing") {
|
|
261
|
+
try {
|
|
262
|
+
const expressions = JSON.parse(value);
|
|
263
|
+
this.desmosCalculator.setState({ expressions: { list: expressions } });
|
|
264
|
+
}
|
|
265
|
+
catch (error) {
|
|
266
|
+
console.error("[DesmosCalculator] Invalid expression format:", error);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
// Basic/Scientific calculators
|
|
271
|
+
this.desmosCalculator.setExpression({ latex: value });
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Clear calculator
|
|
276
|
+
*/
|
|
277
|
+
clear() {
|
|
278
|
+
if (this.type === "graphing") {
|
|
279
|
+
this.desmosCalculator.setBlank();
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
282
|
+
this.setValue("");
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Get calculation history (not natively supported by Desmos)
|
|
287
|
+
*/
|
|
288
|
+
getHistory() {
|
|
289
|
+
// Desmos doesn't provide history natively
|
|
290
|
+
// Would need to implement custom tracking
|
|
291
|
+
return [];
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Clear history
|
|
295
|
+
*/
|
|
296
|
+
clearHistory() {
|
|
297
|
+
// No-op - Desmos doesn't have history
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Resize calculator when container dimensions change
|
|
301
|
+
* Matches production pattern: calculatorInstance.resize()
|
|
302
|
+
*/
|
|
303
|
+
resize() {
|
|
304
|
+
if (this.desmosCalculator &&
|
|
305
|
+
typeof this.desmosCalculator.resize === "function") {
|
|
306
|
+
this.desmosCalculator.resize();
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Evaluate expression (for graphing calculator)
|
|
311
|
+
*/
|
|
312
|
+
async evaluate(expression) {
|
|
313
|
+
return new Promise((resolve, reject) => {
|
|
314
|
+
try {
|
|
315
|
+
// Set expression and wait for computation
|
|
316
|
+
this.desmosCalculator.setExpression({ latex: expression });
|
|
317
|
+
// For basic math, Desmos evaluates automatically
|
|
318
|
+
// Get the result from state
|
|
319
|
+
setTimeout(() => {
|
|
320
|
+
const result = this.getValue();
|
|
321
|
+
resolve(result);
|
|
322
|
+
}, 100); // Small delay for Desmos to compute
|
|
323
|
+
}
|
|
324
|
+
catch (error) {
|
|
325
|
+
reject(error);
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Export calculator state
|
|
331
|
+
*/
|
|
332
|
+
exportState() {
|
|
333
|
+
const state = this.desmosCalculator.getState();
|
|
334
|
+
return {
|
|
335
|
+
type: this.type,
|
|
336
|
+
provider: "desmos",
|
|
337
|
+
value: this.getValue(),
|
|
338
|
+
providerState: state,
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Import calculator state
|
|
343
|
+
*/
|
|
344
|
+
importState(state) {
|
|
345
|
+
if (state.provider !== "desmos") {
|
|
346
|
+
throw new Error(`Cannot import state from provider: ${state.provider}`);
|
|
347
|
+
}
|
|
348
|
+
if (state.providerState) {
|
|
349
|
+
this.desmosCalculator.setState(state.providerState);
|
|
350
|
+
}
|
|
351
|
+
else if (state.value) {
|
|
352
|
+
this.setValue(state.value);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Destroy calculator
|
|
357
|
+
*/
|
|
358
|
+
destroy() {
|
|
359
|
+
if (this.desmosCalculator) {
|
|
360
|
+
try {
|
|
361
|
+
this.desmosCalculator.destroy();
|
|
362
|
+
}
|
|
363
|
+
catch (error) {
|
|
364
|
+
console.warn("[DesmosCalculator] Error during destroy:", error);
|
|
365
|
+
}
|
|
366
|
+
this.desmosCalculator = null;
|
|
367
|
+
}
|
|
368
|
+
// Clear the container to ensure Desmos releases all references
|
|
369
|
+
if (this.container) {
|
|
370
|
+
// Remove any Desmos-specific attributes
|
|
371
|
+
this.container.removeAttribute("data-desmos-id");
|
|
372
|
+
// Use modern API - more efficient and cleaner
|
|
373
|
+
this.container.replaceChildren();
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Singleton provider instance (deprecated)
|
|
379
|
+
* @deprecated Instantiate DesmosCalculatorProvider directly instead:
|
|
380
|
+
* const provider = new DesmosCalculatorProvider();
|
|
381
|
+
* await provider.initialize();
|
|
382
|
+
*/
|
|
383
|
+
export const desmosProvider = new DesmosCalculatorProvider();
|
|
384
|
+
//# sourceMappingURL=desmos-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"desmos-provider.js","sourceRoot":"","sources":["../../../src/tools/calculators/desmos-provider.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAYH,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEpE;;GAEG;AACH,MAAM,OAAO,wBAAwB;IAC3B,UAAU,GAAG,QAAQ,CAAC;IACtB,YAAY,GAAG,QAAQ,CAAC;IACxB,cAAc,GAAqB;QAC3C,OAAO;QACP,YAAY;QACZ,UAAU;KACV,CAAC;IACO,OAAO,GAAG,MAAM,CAAC;IAElB,WAAW,GAAG,KAAK,CAAC;IACpB,MAAM,CAAU;IAExB;;OAEG;IACH,SAAS;QACR,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,UAAU,CAAC,MAA4B;QAC5C,IAAI,IAAI,CAAC,WAAW;YAAE,OAAO;QAE7B,+DAA+D;QAC/D,IAAI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,EAAE,CAAC;YACpB,wCAAwC;YACxC,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,gBAAgB,CAAC,CAAC;YAEjD,8CAA8C;YAC9C,IAAI,CAAC,SAAS,CAAC,eAAe,EAAE,CAAC;QAClC,CAAC;IACF,CAAC;CACD;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,wBAAwB,EAAE,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Math.js Calculator Provider
|
|
3
|
+
* Implementation of CalculatorProvider for Math.js-based calculators
|
|
4
|
+
*
|
|
5
|
+
* Supports: Basic and Scientific calculators
|
|
6
|
+
* License: Apache 2.0 (Math.js) - Commercial-friendly, no licensing fees
|
|
7
|
+
* Based on: https://mathjs.org/
|
|
8
|
+
*
|
|
9
|
+
* NOTE: This is a working implementation that provides basic/scientific
|
|
10
|
+
* calculator functionality without requiring external licenses.
|
|
11
|
+
*/
|
|
12
|
+
import type { Calculator, CalculatorProvider, CalculatorProviderCapabilities, CalculatorProviderConfig, CalculatorType } from "@pie-players/pie-calculator";
|
|
13
|
+
/**
|
|
14
|
+
* Math.js Calculator Provider Implementation
|
|
15
|
+
*/
|
|
16
|
+
export declare class MathJsCalculatorProvider implements CalculatorProvider {
|
|
17
|
+
readonly providerId = "mathjs";
|
|
18
|
+
readonly providerName = "Math.js";
|
|
19
|
+
readonly supportedTypes: CalculatorType[];
|
|
20
|
+
readonly version = "12.0.0";
|
|
21
|
+
private initialized;
|
|
22
|
+
/**
|
|
23
|
+
* Initialize Math.js library
|
|
24
|
+
*/
|
|
25
|
+
initialize(): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Create a calculator instance
|
|
28
|
+
*/
|
|
29
|
+
createCalculator(type: CalculatorType, container: HTMLElement, config?: CalculatorProviderConfig): Promise<Calculator>;
|
|
30
|
+
/**
|
|
31
|
+
* Check if type is supported
|
|
32
|
+
*/
|
|
33
|
+
supportsType(type: CalculatorType): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Cleanup
|
|
36
|
+
*/
|
|
37
|
+
destroy(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Get provider capabilities
|
|
40
|
+
*/
|
|
41
|
+
getCapabilities(): CalculatorProviderCapabilities;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Singleton provider instance (deprecated)
|
|
45
|
+
* @deprecated Instantiate MathJsCalculatorProvider directly instead:
|
|
46
|
+
* const provider = new MathJsCalculatorProvider();
|
|
47
|
+
* await provider.initialize();
|
|
48
|
+
*/
|
|
49
|
+
export declare const mathjsProvider: MathJsCalculatorProvider;
|
|
50
|
+
//# sourceMappingURL=mathjs-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mathjs-provider.d.ts","sourceRoot":"","sources":["../../../src/tools/calculators/mathjs-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAEX,UAAU,EACV,kBAAkB,EAClB,8BAA8B,EAC9B,wBAAwB,EAExB,cAAc,EACd,MAAM,6BAA6B,CAAC;AAGrC;;GAEG;AACH,qBAAa,wBAAyB,YAAW,kBAAkB;IAClE,QAAQ,CAAC,UAAU,YAAY;IAC/B,QAAQ,CAAC,YAAY,aAAa;IAClC,QAAQ,CAAC,cAAc,EAAE,cAAc,EAAE,CAA2B;IACpE,QAAQ,CAAC,OAAO,YAAY;IAE5B,OAAO,CAAC,WAAW,CAAS;IAE5B;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAsBjC;;OAEG;IACG,gBAAgB,CACrB,IAAI,EAAE,cAAc,EACpB,SAAS,EAAE,WAAW,EACtB,MAAM,CAAC,EAAE,wBAAwB,GAC/B,OAAO,CAAC,UAAU,CAAC;IActB;;OAEG;IACH,YAAY,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO;IAI3C;;OAEG;IACH,OAAO,IAAI,IAAI;IAIf;;OAEG;IACH,eAAe,IAAI,8BAA8B;CAUjD;AAkoBD;;;;;GAKG;AACH,eAAO,MAAM,cAAc,0BAAiC,CAAC"}
|