@pie-players/pie-assessment-toolkit 0.3.67 → 0.3.69

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 (73) hide show
  1. package/README.md +81 -9
  2. package/dist/attempt/AssessmentSession.d.ts +7 -27
  3. package/dist/components/ItemToolBar.custom-element.js +1 -1
  4. package/dist/components/PieAssessmentToolkit.custom-element.js +14 -14
  5. package/dist/components/SectionToolBar.custom-element.js +1 -1
  6. package/dist/components/chunks/ItemToolBar-pe5szfyx.js +46 -0
  7. package/dist/components/chunks/ItemToolBar-rd7te9r0.js +51 -0
  8. package/dist/components/item-toolbar-element.js +1 -0
  9. package/dist/components/pie-assessment-toolkit-element.js +1 -0
  10. package/dist/components/section-toolbar-element.js +1 -0
  11. package/dist/context/assessment-toolkit-context.d.ts +28 -0
  12. package/dist/index.d.ts +7 -3
  13. package/dist/index.js +4 -2
  14. package/dist/policy/core/compose-decision.js +14 -0
  15. package/dist/policy/core/decision-types.d.ts +1 -1
  16. package/dist/policy/sources/PnpPolicySource.d.ts +8 -0
  17. package/dist/policy/sources/PnpPolicySource.js +19 -10
  18. package/dist/runtime/SectionRuntimeEngine.d.ts +56 -0
  19. package/dist/runtime/SectionRuntimeEngine.js +66 -1
  20. package/dist/runtime/core/engine-resolver.d.ts +25 -1
  21. package/dist/runtime/registration-events.d.ts +52 -0
  22. package/dist/runtime/registration-events.js +2 -0
  23. package/dist/services/AccessibilityCatalogResolver.js +21 -5
  24. package/dist/services/I18nService.d.ts +28 -100
  25. package/dist/services/I18nService.js +43 -233
  26. package/dist/services/TTSService.d.ts +12 -0
  27. package/dist/services/TTSService.js +18 -17
  28. package/dist/services/ToolRegistry.d.ts +120 -2
  29. package/dist/services/ToolRegistry.js +64 -0
  30. package/dist/services/ToolkitCoordinator.d.ts +39 -37
  31. package/dist/services/ToolkitCoordinator.js +40 -0
  32. package/dist/services/audio-handoff.d.ts +39 -0
  33. package/dist/services/audio-handoff.js +58 -0
  34. package/dist/services/catalog-media.d.ts +35 -4
  35. package/dist/services/catalog-media.js +92 -3
  36. package/dist/services/framework-error.d.ts +15 -1
  37. package/dist/services/interfaces.d.ts +28 -0
  38. package/dist/services/pnp-standard-features.d.ts +1 -1
  39. package/dist/services/section-controller-types.d.ts +218 -7
  40. package/dist/services/selection-action.d.ts +49 -0
  41. package/dist/services/selection-action.js +10 -0
  42. package/dist/services/spoken-audio-cards.js +5 -1
  43. package/dist/services/tool-context.d.ts +6 -5
  44. package/dist/services/tool-context.js +205 -155
  45. package/dist/services/tool-icons.d.ts +18 -0
  46. package/dist/services/tool-icons.js +31 -0
  47. package/dist/services/tool-providers/CortexToolProvider.d.ts +18 -0
  48. package/dist/services/tool-providers/CortexToolProvider.js +32 -0
  49. package/dist/services/tool-providers/DesmosToolProvider.d.ts +13 -101
  50. package/dist/services/tool-providers/DesmosToolProvider.js +14 -145
  51. package/dist/services/tool-providers/GeoGebraToolProvider.d.ts +21 -0
  52. package/dist/services/tool-providers/GeoGebraToolProvider.js +32 -0
  53. package/dist/services/tool-providers/LazyCalculatorToolProvider.d.ts +35 -0
  54. package/dist/services/tool-providers/LazyCalculatorToolProvider.js +95 -0
  55. package/dist/services/tool-providers/index.d.ts +4 -0
  56. package/dist/services/tool-providers/index.js +2 -0
  57. package/dist/services/tool-request.d.ts +106 -0
  58. package/dist/services/tool-request.js +127 -0
  59. package/dist/services/toolbar-items.d.ts +6 -0
  60. package/dist/tools/client.d.ts +0 -2
  61. package/dist/tools/client.js +0 -4
  62. package/dist/tools/internal.d.ts +7 -1
  63. package/dist/tools/internal.js +8 -1
  64. package/dist/tools/tool-surface-host.d.ts +57 -0
  65. package/dist/tools/tool-surface-host.js +610 -0
  66. package/dist/tools/types.d.ts +1 -66
  67. package/package.json +22 -12
  68. package/dist/components/chunks/ItemToolBar-8jgdz50p.js +0 -51
  69. package/dist/components/chunks/ItemToolBar-cvs646j3.js +0 -36
  70. package/dist/tools/calculators/desmos-provider.d.ts +0 -46
  71. package/dist/tools/calculators/desmos-provider.js +0 -393
  72. package/dist/tools/library-loader.d.ts +0 -62
  73. package/dist/tools/library-loader.js +0 -261
@@ -1,393 +0,0 @@
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.12+
7
- */
8
- import { COMMON_LIBRARIES, libraryLoader } from "../library-loader.js";
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.12";
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
- */
229
- _mapConfigToDesmos(config) {
230
- if (!config)
231
- return {};
232
- const desmosOptions = {};
233
- // Map locale to Desmos language option
234
- if (config.locale) {
235
- desmosOptions.language = config.locale;
236
- }
237
- // Theme mapping (Desmos may support this via CSS, not API)
238
- // Note: Desmos doesn't have a theme option in the API, but we keep this
239
- // for potential future use or CSS-based theming
240
- return desmosOptions;
241
- }
242
- /**
243
- * Get current value/expression
244
- */
245
- getValue() {
246
- // For graphing calculator, get all expressions
247
- if (this.type === "graphing") {
248
- const state = this.desmosCalculator.getState();
249
- return JSON.stringify(state.expressions.list);
250
- }
251
- // For basic/scientific, get current expression
252
- const state = this.desmosCalculator.getState();
253
- return state.expression || "";
254
- }
255
- /**
256
- * Set value/expression
257
- */
258
- setValue(value) {
259
- if (this.type === "graphing") {
260
- try {
261
- const expressions = JSON.parse(value);
262
- this.desmosCalculator.setState({ expressions: { list: expressions } });
263
- }
264
- catch (error) {
265
- console.error("[DesmosCalculator] Invalid expression format:", error);
266
- }
267
- }
268
- else {
269
- // Basic/Scientific calculators
270
- this.desmosCalculator.setExpression({ latex: value });
271
- }
272
- }
273
- /**
274
- * Clear calculator
275
- */
276
- clear() {
277
- if (this.type === "graphing") {
278
- this.desmosCalculator.setBlank();
279
- }
280
- else {
281
- this.setValue("");
282
- }
283
- }
284
- /**
285
- * Get calculation history (not natively supported by Desmos)
286
- */
287
- getHistory() {
288
- // Desmos doesn't provide history natively
289
- // Would need to implement custom tracking
290
- return [];
291
- }
292
- /**
293
- * Clear history
294
- */
295
- clearHistory() {
296
- // No-op - Desmos doesn't have history
297
- }
298
- /**
299
- * Resize calculator when container dimensions change
300
- * Matches production pattern: calculatorInstance.resize()
301
- */
302
- resize() {
303
- if (this.desmosCalculator &&
304
- typeof this.desmosCalculator.resize === "function") {
305
- this.desmosCalculator.resize();
306
- }
307
- }
308
- /**
309
- * Move keyboard focus to the primary input/expression field so keyboard
310
- * users can begin typing immediately after the calculator opens.
311
- */
312
- focus() {
313
- try {
314
- if (this.type === "graphing" &&
315
- typeof this.desmosCalculator?.focusFirstExpression === "function") {
316
- this.desmosCalculator.focusFirstExpression();
317
- return;
318
- }
319
- const target = this.container.querySelector('.dcg-mq-editable-field[tabindex="0"], textarea, [contenteditable="true"], [tabindex]:not([tabindex="-1"])');
320
- target?.focus();
321
- }
322
- catch (error) {
323
- console.warn("[DesmosCalculator] focus() failed:", error);
324
- }
325
- }
326
- /**
327
- * Evaluate expression (for graphing calculator)
328
- */
329
- async evaluate(expression) {
330
- return new Promise((resolve, reject) => {
331
- try {
332
- // Set expression and wait for computation
333
- this.desmosCalculator.setExpression({ latex: expression });
334
- // For basic math, Desmos evaluates automatically
335
- // Get the result from state
336
- setTimeout(() => {
337
- const result = this.getValue();
338
- resolve(result);
339
- }, 100); // Small delay for Desmos to compute
340
- }
341
- catch (error) {
342
- reject(error);
343
- }
344
- });
345
- }
346
- /**
347
- * Export calculator state
348
- */
349
- exportState() {
350
- const state = this.desmosCalculator.getState();
351
- return {
352
- type: this.type,
353
- provider: "desmos",
354
- value: this.getValue(),
355
- providerState: state,
356
- };
357
- }
358
- /**
359
- * Import calculator state
360
- */
361
- importState(state) {
362
- if (state.provider !== "desmos") {
363
- throw new Error(`Cannot import state from provider: ${state.provider}`);
364
- }
365
- if (state.providerState) {
366
- this.desmosCalculator.setState(state.providerState);
367
- }
368
- else if (state.value) {
369
- this.setValue(state.value);
370
- }
371
- }
372
- /**
373
- * Destroy calculator
374
- */
375
- destroy() {
376
- if (this.desmosCalculator) {
377
- try {
378
- this.desmosCalculator.destroy();
379
- }
380
- catch (error) {
381
- console.warn("[DesmosCalculator] Error during destroy:", error);
382
- }
383
- this.desmosCalculator = null;
384
- }
385
- // Clear the container to ensure Desmos releases all references
386
- if (this.container) {
387
- // Remove any Desmos-specific attributes
388
- this.container.removeAttribute("data-desmos-id");
389
- // Use modern API - more efficient and cleaner
390
- this.container.replaceChildren();
391
- }
392
- }
393
- }
@@ -1,62 +0,0 @@
1
- /**
2
- * Library Loader Service
3
- * Dynamically loads external JavaScript libraries with retry logic and fallback URLs
4
- *
5
- * Based on architectural enhancements from renaissance-tool-analyses.md
6
- * Supports both static and dynamic library loading
7
- */
8
- import type { LibraryConfig, LibraryLoader, LoaderStats } from "./types.js";
9
- /**
10
- * Implementation of LibraryLoader service
11
- */
12
- export declare class LibraryLoaderImpl implements LibraryLoader {
13
- private loadedLibraries;
14
- private pendingLoads;
15
- private failedLibraries;
16
- private stats;
17
- /**
18
- * Load a JavaScript library
19
- */
20
- loadScript(library: LibraryConfig): Promise<void>;
21
- /**
22
- * Load a stylesheet
23
- */
24
- loadStylesheet(url: string, targetRoot?: Document | ShadowRoot): Promise<void>;
25
- /**
26
- * Check if a library is already loaded
27
- */
28
- isLoaded(libraryId: string): boolean;
29
- /**
30
- * Preload multiple libraries in parallel
31
- */
32
- preload(libraries: LibraryConfig[]): Promise<void>;
33
- /**
34
- * Unload a library (remove script tag)
35
- */
36
- unload(libraryId: string): void;
37
- /**
38
- * Get loader statistics
39
- */
40
- getStats(): LoaderStats;
41
- /**
42
- * Load script with retry logic
43
- */
44
- private _loadScriptWithRetry;
45
- /**
46
- * Load script from a specific URL
47
- */
48
- private _loadScriptFromUrl;
49
- /**
50
- * Sleep utility for retry delays
51
- */
52
- private _sleep;
53
- }
54
- /**
55
- * Singleton instance
56
- */
57
- export declare const libraryLoader: LibraryLoaderImpl;
58
- /**
59
- * Common library configurations
60
- * Based on industry best practices and platform analyses
61
- */
62
- export declare const COMMON_LIBRARIES: Record<string, LibraryConfig>;