@pie-players/pie-assessment-toolkit 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 +45 -17
- package/dist/components/ItemToolBar.custom-element.js +1 -1
- package/dist/components/PieAssessmentToolkit.custom-element.js +6 -6
- package/dist/components/SectionToolBar.custom-element.js +1 -1
- package/dist/components/chunks/ItemToolBar-cckwpz6c.js +51 -0
- package/dist/components/chunks/ItemToolBar-pryf0rtz.js +22 -0
- package/dist/index.d.ts +5 -6
- package/dist/index.js +9 -4
- package/dist/runtime/composition-emit-scheduler.d.ts +78 -0
- package/dist/runtime/composition-emit-scheduler.js +154 -0
- package/dist/runtime/core/engine-resolver.d.ts +1 -1
- package/dist/services/ToolRegistry.d.ts +218 -8
- package/dist/services/ToolRegistry.js +124 -8
- package/dist/services/ToolkitCoordinator.d.ts +2 -1
- package/dist/services/ToolkitCoordinator.js +23 -6
- package/dist/services/createDefaultToolRegistry.d.ts +25 -58
- package/dist/services/createDefaultToolRegistry.js +24 -104
- package/dist/services/defaultPersonalNeedsProfile.d.ts +16 -14
- package/dist/services/defaultPersonalNeedsProfile.js +17 -38
- package/dist/services/pnp-standard-features.d.ts +1 -1
- package/dist/services/tool-config-defaults.d.ts +7 -23
- package/dist/services/tool-config-defaults.js +7 -46
- package/dist/services/tool-config-validation.d.ts +1 -1
- package/dist/services/tool-config-validation.js +44 -4
- package/dist/services/tts/browser-provider.js +2 -1
- package/dist/services/tts-runtime-config.js +7 -2
- package/dist/tools/internal.d.ts +34 -0
- package/dist/tools/internal.js +33 -0
- package/dist/tools/tool-tag-map.d.ts +15 -3
- package/dist/tools/tool-tag-map.js +21 -18
- package/package.json +14 -10
- package/dist/components/chunks/ItemToolBar-3cppre9r.js +0 -51
- package/dist/components/chunks/ItemToolBar-7rq2gj8b.js +0 -22
- package/dist/services/sign-language-cards.d.ts +0 -82
- package/dist/services/sign-language-cards.js +0 -133
- package/dist/tools/registrations/accessibility-tools.d.ts +0 -34
- package/dist/tools/registrations/accessibility-tools.js +0 -217
- package/dist/tools/registrations/calculator.d.ts +0 -20
- package/dist/tools/registrations/calculator.js +0 -228
- package/dist/tools/registrations/interaction-tools.d.ts +0 -27
- package/dist/tools/registrations/interaction-tools.js +0 -143
- package/dist/tools/registrations/measurement-tools.d.ts +0 -24
- package/dist/tools/registrations/measurement-tools.js +0 -130
- package/dist/tools/registrations/subject-specific-tools.d.ts +0 -27
- package/dist/tools/registrations/subject-specific-tools.js +0 -158
- package/dist/tools/registrations/tts.d.ts +0 -21
- package/dist/tools/registrations/tts.js +0 -184
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Subject-Specific Tools Registrations
|
|
3
|
-
*
|
|
4
|
-
* Registers tools for specific subject areas:
|
|
5
|
-
* - Graph (graphing calculator/coordinate plane)
|
|
6
|
-
* - Periodic Table (chemistry reference)
|
|
7
|
-
*
|
|
8
|
-
* Maps to QTI 3.0 standard access features:
|
|
9
|
-
* - graphingCalculator (assessment tool)
|
|
10
|
-
* - graph (assessment tool)
|
|
11
|
-
* - periodicTable (assessment tool)
|
|
12
|
-
*/
|
|
13
|
-
import { hasMathContent, hasScienceContent, } from "../../services/tool-context.js";
|
|
14
|
-
import { createToolElement, } from "../tool-tag-map.js";
|
|
15
|
-
import { createScopedVisibilityBinding, syncButtonAndOverlayVisibility, } from "./toolbar-registration-helpers.js";
|
|
16
|
-
/**
|
|
17
|
-
* Graph tool registration
|
|
18
|
-
*
|
|
19
|
-
* Provides graphing calculator and coordinate plane functionality.
|
|
20
|
-
* Context-smart: appears automatically for math content or when explicitly enabled.
|
|
21
|
-
*/
|
|
22
|
-
export const graphToolRegistration = {
|
|
23
|
-
toolId: "graph",
|
|
24
|
-
name: "Graph",
|
|
25
|
-
description: "Graphing calculator and coordinate plane",
|
|
26
|
-
icon: "chart-bar",
|
|
27
|
-
// Graph is a section-level floating tool.
|
|
28
|
-
supportedLevels: ["section"],
|
|
29
|
-
// PNP support IDs
|
|
30
|
-
// Maps to QTI 3.0 standard features: graph, graphingCalculator
|
|
31
|
-
pnpSupportIds: [
|
|
32
|
-
"graph", // QTI 3.0 standard (assessment.graph)
|
|
33
|
-
"graphingCalculator", // QTI 3.0 standard (assessment.graphingCalculator)
|
|
34
|
-
"coordinatePlane", // Common variant
|
|
35
|
-
"graphingTool", // Common variant
|
|
36
|
-
],
|
|
37
|
-
/**
|
|
38
|
-
* Pass 2: Graph is relevant when math content is present
|
|
39
|
-
*/
|
|
40
|
-
isVisibleInContext(context) {
|
|
41
|
-
return hasMathContent(context);
|
|
42
|
-
},
|
|
43
|
-
renderToolbar(context, toolbarContext) {
|
|
44
|
-
const visibility = createScopedVisibilityBinding(this.toolId, toolbarContext);
|
|
45
|
-
const button = {
|
|
46
|
-
toolId: this.toolId,
|
|
47
|
-
label: this.name,
|
|
48
|
-
icon: typeof this.icon === "function" ? this.icon(context) : this.icon,
|
|
49
|
-
disabled: false,
|
|
50
|
-
ariaLabel: "Graph - Graphing calculator",
|
|
51
|
-
tooltip: "Graph",
|
|
52
|
-
onClick: () => toolbarContext.toggleTool(this.toolId),
|
|
53
|
-
active: visibility.isActive(),
|
|
54
|
-
};
|
|
55
|
-
const componentOverrides = toolbarContext.componentOverrides ?? {};
|
|
56
|
-
const overlay = createToolElement(this.toolId, context, toolbarContext, componentOverrides);
|
|
57
|
-
overlay.setAttribute("tool-id", visibility.fullToolId);
|
|
58
|
-
return {
|
|
59
|
-
toolId: this.toolId,
|
|
60
|
-
button,
|
|
61
|
-
elements: [
|
|
62
|
-
{
|
|
63
|
-
element: overlay,
|
|
64
|
-
mount: "after-buttons",
|
|
65
|
-
shell: {
|
|
66
|
-
title: this.name,
|
|
67
|
-
draggable: true,
|
|
68
|
-
resizable: true,
|
|
69
|
-
closeable: true,
|
|
70
|
-
initialWidth: 920,
|
|
71
|
-
initialHeight: 680,
|
|
72
|
-
minWidth: 640,
|
|
73
|
-
minHeight: 500,
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
],
|
|
77
|
-
sync: () => {
|
|
78
|
-
syncButtonAndOverlayVisibility({
|
|
79
|
-
button,
|
|
80
|
-
overlay,
|
|
81
|
-
isActive: visibility.isActive,
|
|
82
|
-
});
|
|
83
|
-
},
|
|
84
|
-
subscribeActive: visibility.subscribeActive,
|
|
85
|
-
};
|
|
86
|
-
},
|
|
87
|
-
};
|
|
88
|
-
/**
|
|
89
|
-
* Periodic Table tool registration
|
|
90
|
-
*
|
|
91
|
-
* Provides chemistry periodic table reference.
|
|
92
|
-
* Context-smart: appears automatically for science content or when explicitly enabled.
|
|
93
|
-
*/
|
|
94
|
-
export const periodicTableToolRegistration = {
|
|
95
|
-
toolId: "periodicTable",
|
|
96
|
-
name: "Periodic Table",
|
|
97
|
-
description: "Chemistry periodic table reference",
|
|
98
|
-
icon: "beaker",
|
|
99
|
-
// Periodic table is a section-level floating tool.
|
|
100
|
-
supportedLevels: ["section"],
|
|
101
|
-
// PNP support IDs
|
|
102
|
-
// Maps to QTI 3.0 standard feature: periodicTable
|
|
103
|
-
pnpSupportIds: [
|
|
104
|
-
"periodicTable", // QTI 3.0 standard (assessment.periodicTable)
|
|
105
|
-
"chemistryReference", // Common variant
|
|
106
|
-
"elementReference", // Common variant
|
|
107
|
-
],
|
|
108
|
-
/**
|
|
109
|
-
* Pass 2: Periodic table is relevant when science content is present
|
|
110
|
-
*/
|
|
111
|
-
isVisibleInContext(context) {
|
|
112
|
-
return hasScienceContent(context);
|
|
113
|
-
},
|
|
114
|
-
renderToolbar(context, toolbarContext) {
|
|
115
|
-
const visibility = createScopedVisibilityBinding(this.toolId, toolbarContext);
|
|
116
|
-
const button = {
|
|
117
|
-
toolId: this.toolId,
|
|
118
|
-
label: this.name,
|
|
119
|
-
icon: typeof this.icon === "function" ? this.icon(context) : this.icon,
|
|
120
|
-
disabled: false,
|
|
121
|
-
ariaLabel: "Periodic table - Chemistry reference",
|
|
122
|
-
tooltip: "Periodic Table",
|
|
123
|
-
onClick: () => toolbarContext.toggleTool(this.toolId),
|
|
124
|
-
active: visibility.isActive(),
|
|
125
|
-
};
|
|
126
|
-
const componentOverrides = toolbarContext.componentOverrides ?? {};
|
|
127
|
-
const overlay = createToolElement(this.toolId, context, toolbarContext, componentOverrides);
|
|
128
|
-
overlay.setAttribute("tool-id", visibility.fullToolId);
|
|
129
|
-
return {
|
|
130
|
-
toolId: this.toolId,
|
|
131
|
-
button,
|
|
132
|
-
elements: [
|
|
133
|
-
{
|
|
134
|
-
element: overlay,
|
|
135
|
-
mount: "after-buttons",
|
|
136
|
-
shell: {
|
|
137
|
-
title: this.name,
|
|
138
|
-
draggable: true,
|
|
139
|
-
resizable: true,
|
|
140
|
-
closeable: true,
|
|
141
|
-
initialWidth: 1160,
|
|
142
|
-
initialHeight: 760,
|
|
143
|
-
minWidth: 920,
|
|
144
|
-
minHeight: 620,
|
|
145
|
-
},
|
|
146
|
-
},
|
|
147
|
-
],
|
|
148
|
-
sync: () => {
|
|
149
|
-
syncButtonAndOverlayVisibility({
|
|
150
|
-
button,
|
|
151
|
-
overlay,
|
|
152
|
-
isActive: visibility.isActive,
|
|
153
|
-
});
|
|
154
|
-
},
|
|
155
|
-
subscribeActive: visibility.subscribeActive,
|
|
156
|
-
};
|
|
157
|
-
},
|
|
158
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Text-to-Speech (TTS) Tool Registration
|
|
3
|
-
*
|
|
4
|
-
* Registers the TTS tool for reading content aloud.
|
|
5
|
-
*
|
|
6
|
-
* Maps to QTI 3.0 standard access features:
|
|
7
|
-
* - textToSpeech (auditory support)
|
|
8
|
-
* - readAloud (auditory support)
|
|
9
|
-
*/
|
|
10
|
-
import type { ToolRegistration } from "../../services/ToolRegistry.js";
|
|
11
|
-
export declare const TOOL_ELEMENT_UNMOUNT_CALLBACK_PROP = "__pieToolElementUnmount";
|
|
12
|
-
export declare const TOOL_ACTIVE_CHANGE_EVENT = "pie-tool-active-change";
|
|
13
|
-
/**
|
|
14
|
-
* Text-to-Speech tool registration
|
|
15
|
-
*
|
|
16
|
-
* Supports:
|
|
17
|
-
* - Reading content aloud using browser TTS or external providers
|
|
18
|
-
* - Context-aware visibility (shows when readable text is available)
|
|
19
|
-
* - All levels except assessment and element
|
|
20
|
-
*/
|
|
21
|
-
export declare const ttsToolRegistration: ToolRegistration;
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Text-to-Speech (TTS) Tool Registration
|
|
3
|
-
*
|
|
4
|
-
* Registers the TTS tool for reading content aloud.
|
|
5
|
-
*
|
|
6
|
-
* Maps to QTI 3.0 standard access features:
|
|
7
|
-
* - textToSpeech (auditory support)
|
|
8
|
-
* - readAloud (auditory support)
|
|
9
|
-
*/
|
|
10
|
-
import { hasReadableText } from "../../services/tool-context.js";
|
|
11
|
-
import { createScopedToolId } from "../../services/tool-instance-id.js";
|
|
12
|
-
import { buildRuntimeTTSConfig, normalizeTTSLayoutMode, normalizeTTSSpeedControlOptions, resolveTTSHostToolbarLayout, resolveTTSLayoutMode, resolveTTSBackend, resolveTTSRuntimeSettings, resolveRuntimeProvider, resolveTransportMode, } from "../../services/tts-runtime-config.js";
|
|
13
|
-
import { TTSToolProvider } from "../../services/tool-providers/index.js";
|
|
14
|
-
const inlineTTSControls = new Map();
|
|
15
|
-
export const TOOL_ELEMENT_UNMOUNT_CALLBACK_PROP = "__pieToolElementUnmount";
|
|
16
|
-
export const TOOL_ACTIVE_CHANGE_EVENT = "pie-tool-active-change";
|
|
17
|
-
/**
|
|
18
|
-
* Text-to-Speech tool registration
|
|
19
|
-
*
|
|
20
|
-
* Supports:
|
|
21
|
-
* - Reading content aloud using browser TTS or external providers
|
|
22
|
-
* - Context-aware visibility (shows when readable text is available)
|
|
23
|
-
* - All levels except assessment and element
|
|
24
|
-
*/
|
|
25
|
-
export const ttsToolRegistration = {
|
|
26
|
-
toolId: "textToSpeech",
|
|
27
|
-
name: "Text to Speech",
|
|
28
|
-
description: "Read content aloud",
|
|
29
|
-
icon: "volume-up",
|
|
30
|
-
provider: {
|
|
31
|
-
getProviderId: () => "tts",
|
|
32
|
-
createProvider: (config) => {
|
|
33
|
-
const settings = resolveTTSRuntimeSettings(config);
|
|
34
|
-
return new TTSToolProvider(resolveTTSBackend(settings));
|
|
35
|
-
},
|
|
36
|
-
getInitConfig: (config) => {
|
|
37
|
-
const settings = resolveTTSRuntimeSettings(config);
|
|
38
|
-
const backend = resolveTTSBackend(settings);
|
|
39
|
-
const serverProvider = resolveRuntimeProvider(settings, backend);
|
|
40
|
-
const transportMode = resolveTransportMode(settings, serverProvider);
|
|
41
|
-
return {
|
|
42
|
-
backend,
|
|
43
|
-
serverProvider,
|
|
44
|
-
transportMode,
|
|
45
|
-
...buildRuntimeTTSConfig(settings),
|
|
46
|
-
};
|
|
47
|
-
},
|
|
48
|
-
getAuthFetcher: (config) => {
|
|
49
|
-
const runtimeAuthFetcher = config?.provider?.runtime?.authFetcher;
|
|
50
|
-
return typeof runtimeAuthFetcher === "function"
|
|
51
|
-
? runtimeAuthFetcher
|
|
52
|
-
: undefined;
|
|
53
|
-
},
|
|
54
|
-
sanitizeConfig: (config) => {
|
|
55
|
-
const settings = config.settings && typeof config.settings === "object"
|
|
56
|
-
? { ...config.settings }
|
|
57
|
-
: undefined;
|
|
58
|
-
if (settings && "layoutMode" in settings) {
|
|
59
|
-
settings.layoutMode = normalizeTTSLayoutMode(settings.layoutMode);
|
|
60
|
-
}
|
|
61
|
-
if (settings && "speedOptions" in settings) {
|
|
62
|
-
settings.speedOptions = normalizeTTSSpeedControlOptions(settings.speedOptions);
|
|
63
|
-
}
|
|
64
|
-
const normalizedConfig = {
|
|
65
|
-
...config,
|
|
66
|
-
};
|
|
67
|
-
if ("layoutMode" in normalizedConfig) {
|
|
68
|
-
normalizedConfig.layoutMode = normalizeTTSLayoutMode(normalizedConfig.layoutMode);
|
|
69
|
-
}
|
|
70
|
-
if ("speedOptions" in normalizedConfig) {
|
|
71
|
-
normalizedConfig.speedOptions = normalizeTTSSpeedControlOptions(normalizedConfig.speedOptions);
|
|
72
|
-
}
|
|
73
|
-
if (settings) {
|
|
74
|
-
normalizedConfig.settings = settings;
|
|
75
|
-
}
|
|
76
|
-
return normalizedConfig;
|
|
77
|
-
},
|
|
78
|
-
lazy: true,
|
|
79
|
-
},
|
|
80
|
-
// TTS is inline-only and scoped to item/passage contexts.
|
|
81
|
-
supportedLevels: ["item", "passage"],
|
|
82
|
-
// PNP support IDs that enable this tool
|
|
83
|
-
// Maps to QTI 3.0 standard features: textToSpeech, readAloud
|
|
84
|
-
pnpSupportIds: [
|
|
85
|
-
"textToSpeech", // QTI 3.0 standard (auditory.textToSpeech)
|
|
86
|
-
"readAloud", // QTI 3.0 standard (auditory.readAloud)
|
|
87
|
-
"tts", // Common abbreviation
|
|
88
|
-
"speechOutput", // Common variant
|
|
89
|
-
],
|
|
90
|
-
/**
|
|
91
|
-
* Pass 2: Determine if TTS is relevant in this context
|
|
92
|
-
*
|
|
93
|
-
* TTS is relevant when:
|
|
94
|
-
* - Context contains readable text (at least 10 characters)
|
|
95
|
-
*/
|
|
96
|
-
isVisibleInContext(context) {
|
|
97
|
-
return hasReadableText(context);
|
|
98
|
-
},
|
|
99
|
-
renderToolbar(_context, toolbarContext) {
|
|
100
|
-
const resolveRuntimeSettings = () => resolveTTSRuntimeSettings(toolbarContext.toolkitCoordinator?.getToolConfig(this.toolId) ||
|
|
101
|
-
undefined);
|
|
102
|
-
const resolveElementSpeedOptions = () => {
|
|
103
|
-
const runtimeSettings = resolveRuntimeSettings();
|
|
104
|
-
return normalizeTTSSpeedControlOptions(runtimeSettings.speedOptions);
|
|
105
|
-
};
|
|
106
|
-
const resolveLayoutMode = () => resolveTTSLayoutMode(resolveRuntimeSettings());
|
|
107
|
-
const resolveHostLayout = () => resolveTTSHostToolbarLayout(resolveRuntimeSettings());
|
|
108
|
-
const fullToolId = createScopedToolId(this.toolId, toolbarContext.scope.level, toolbarContext.scope.scopeId);
|
|
109
|
-
const resolveControlSize = () => {
|
|
110
|
-
const raw = toolbarContext.ui?.size;
|
|
111
|
-
return raw === "sm" || raw === "lg" ? raw : "md";
|
|
112
|
-
};
|
|
113
|
-
const ensureElement = () => {
|
|
114
|
-
let element = inlineTTSControls.get(fullToolId);
|
|
115
|
-
if (element &&
|
|
116
|
-
typeof element.isConnected ===
|
|
117
|
-
"boolean" &&
|
|
118
|
-
!element.isConnected) {
|
|
119
|
-
inlineTTSControls.delete(fullToolId);
|
|
120
|
-
element = undefined;
|
|
121
|
-
}
|
|
122
|
-
if (!element) {
|
|
123
|
-
element = document.createElement("pie-tool-tts-inline");
|
|
124
|
-
element[TOOL_ELEMENT_UNMOUNT_CALLBACK_PROP] = () => {
|
|
125
|
-
if (inlineTTSControls.get(fullToolId) === element) {
|
|
126
|
-
inlineTTSControls.delete(fullToolId);
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
inlineTTSControls.set(fullToolId, element);
|
|
130
|
-
}
|
|
131
|
-
element.setAttribute("tool-id", fullToolId);
|
|
132
|
-
element.setAttribute("catalog-id", toolbarContext.catalogId || toolbarContext.itemId);
|
|
133
|
-
element.setAttribute("language", toolbarContext.language || "en-US");
|
|
134
|
-
element.setAttribute("size", resolveControlSize());
|
|
135
|
-
element.setAttribute("layout-mode", resolveLayoutMode());
|
|
136
|
-
element.speedOptions = resolveElementSpeedOptions();
|
|
137
|
-
element.showSingleSpeedOption =
|
|
138
|
-
resolveRuntimeSettings().showSingleSpeedOption === true;
|
|
139
|
-
return element;
|
|
140
|
-
};
|
|
141
|
-
const hostLayout = resolveHostLayout();
|
|
142
|
-
return {
|
|
143
|
-
toolId: this.toolId,
|
|
144
|
-
button: null,
|
|
145
|
-
elements: [
|
|
146
|
-
{
|
|
147
|
-
element: ensureElement(),
|
|
148
|
-
mount: hostLayout.mount,
|
|
149
|
-
layoutHints: {
|
|
150
|
-
controlsRow: {
|
|
151
|
-
reserveSpace: hostLayout.controlsRow.reserveSpace,
|
|
152
|
-
showWhenToolActive: hostLayout.controlsRow.expandWhenToolActive,
|
|
153
|
-
},
|
|
154
|
-
headerOverlay: {
|
|
155
|
-
showWhenToolActive: hostLayout.headerOverlay.expandWhenToolActive,
|
|
156
|
-
},
|
|
157
|
-
},
|
|
158
|
-
},
|
|
159
|
-
],
|
|
160
|
-
subscribeActive: (callback) => {
|
|
161
|
-
const element = ensureElement();
|
|
162
|
-
const handler = (event) => {
|
|
163
|
-
const detail = event.detail;
|
|
164
|
-
callback(detail?.active === true);
|
|
165
|
-
};
|
|
166
|
-
element.addEventListener(TOOL_ACTIVE_CHANGE_EVENT, handler);
|
|
167
|
-
return () => {
|
|
168
|
-
element.removeEventListener(TOOL_ACTIVE_CHANGE_EVENT, handler);
|
|
169
|
-
};
|
|
170
|
-
},
|
|
171
|
-
sync: () => {
|
|
172
|
-
const element = ensureElement();
|
|
173
|
-
element.setAttribute("tool-id", fullToolId);
|
|
174
|
-
element.setAttribute("catalog-id", toolbarContext.catalogId || toolbarContext.itemId);
|
|
175
|
-
element.setAttribute("language", toolbarContext.language || "en-US");
|
|
176
|
-
element.setAttribute("size", resolveControlSize());
|
|
177
|
-
element.setAttribute("layout-mode", resolveLayoutMode());
|
|
178
|
-
element.speedOptions = resolveElementSpeedOptions();
|
|
179
|
-
element.showSingleSpeedOption =
|
|
180
|
-
resolveRuntimeSettings().showSingleSpeedOption === true;
|
|
181
|
-
},
|
|
182
|
-
};
|
|
183
|
-
},
|
|
184
|
-
};
|