@pie-players/pie-default-tool-loaders 0.3.74 → 0.3.75
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 +47 -57
- package/dist/calculator-providers/CortexToolProvider.d.ts +1 -2
- package/dist/calculator-providers/CortexToolProvider.js +0 -1
- package/dist/calculator-providers/DesmosToolProvider.d.ts +1 -2
- package/dist/calculator-providers/DesmosToolProvider.js +0 -1
- package/dist/calculator-providers/GeoGebraToolProvider.d.ts +1 -2
- package/dist/calculator-providers/GeoGebraToolProvider.js +0 -1
- package/dist/calculator-providers/LazyCalculatorToolProvider.d.ts +2 -3
- package/dist/content-alternates.d.ts +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/packaged-capability-composition.d.ts +17 -49
- package/dist/packaged-capability-composition.js +60 -261
- package/dist/registrations/accessibility-tools.d.ts +1 -5
- package/dist/registrations/accessibility-tools.js +6 -40
- package/dist/registrations/audio-transcript.d.ts +1 -1
- package/dist/registrations/audio-transcript.js +0 -1
- package/dist/registrations/calculator.d.ts +2 -6
- package/dist/registrations/calculator.js +9 -31
- package/dist/registrations/dictionary-tools.d.ts +6 -5
- package/dist/registrations/dictionary-tools.js +21 -26
- package/dist/registrations/interaction-tools.d.ts +1 -7
- package/dist/registrations/interaction-tools.js +22 -27
- package/dist/registrations/measurement-tools.d.ts +1 -5
- package/dist/registrations/measurement-tools.js +1 -17
- package/dist/registrations/overlay-element-cache.d.ts +3 -1
- package/dist/registrations/overlay-element-cache.js +2 -1
- package/dist/registrations/overlay-toolbar-render.d.ts +3 -10
- package/dist/registrations/overlay-toolbar-render.js +3 -7
- package/dist/registrations/selection-actions.d.ts +1 -1
- package/dist/registrations/selection-actions.js +1 -1
- package/dist/registrations/subject-specific-tools.d.ts +1 -5
- package/dist/registrations/subject-specific-tools.js +1 -15
- package/dist/registrations/tts.d.ts +1 -6
- package/dist/registrations/tts.js +36 -89
- package/package.json +22 -23
|
@@ -2,20 +2,15 @@
|
|
|
2
2
|
* Text-to-Speech (TTS) Tool Registration
|
|
3
3
|
*
|
|
4
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
5
|
*/
|
|
10
|
-
import { hasReadableText } from "@pie-players/pie-assessment-toolkit/tools/
|
|
11
|
-
import { createScopedToolId } from "@pie-players/pie-assessment-toolkit/tools/
|
|
12
|
-
import { buildRuntimeTTSConfig, normalizeTTSLayoutMode, normalizeTTSSpeedControlOptions, resolveTTSHostToolbarLayout, resolveTTSLayoutMode,
|
|
13
|
-
import { TTSToolProvider } from "@pie-players/pie-assessment-toolkit/tools/
|
|
6
|
+
import { hasReadableText } from "@pie-players/pie-assessment-toolkit/tools/registration";
|
|
7
|
+
import { createScopedToolId, createToolElement, } from "@pie-players/pie-assessment-toolkit/tools/registration";
|
|
8
|
+
import { buildRuntimeTTSConfig, normalizeTTSLayoutMode, normalizeTTSSpeedControlOptions, resolveTTSHostToolbarLayout, resolveTTSLayoutMode, resolveTTSRuntimeSettings, } from "@pie-players/pie-assessment-toolkit/tools/registration";
|
|
9
|
+
import { TTSToolProvider } from "@pie-players/pie-assessment-toolkit/tools/registration";
|
|
10
|
+
import { resolveOverlayElement } from "./overlay-element-cache.js";
|
|
14
11
|
// This package owns the server adapter's import, so the toolkit never names it
|
|
15
12
|
// and a bundler building the toolkit alone has nothing to resolve.
|
|
16
13
|
const loadServerTTSProvider = async () => (await import("@pie-players/tts-client-server")).ServerTTSProvider;
|
|
17
|
-
const inlineTTSControls = new Map();
|
|
18
|
-
export const TOOL_ELEMENT_UNMOUNT_CALLBACK_PROP = "__pieToolElementUnmount";
|
|
19
14
|
export const TOOL_ACTIVE_CHANGE_EVENT = "pie-tool-active-change";
|
|
20
15
|
/**
|
|
21
16
|
* Text-to-Speech tool registration
|
|
@@ -33,65 +28,34 @@ export const ttsToolRegistration = {
|
|
|
33
28
|
descriptionKey: "tools.textToSpeech.description",
|
|
34
29
|
icon: "volume-up",
|
|
35
30
|
provider: {
|
|
36
|
-
getProviderId: () => "tts",
|
|
37
31
|
createProvider: (config) => {
|
|
38
|
-
|
|
39
|
-
return new TTSToolProvider(resolveTTSBackend(settings), {
|
|
32
|
+
return new TTSToolProvider(resolveTTSRuntimeSettings(config).backend, {
|
|
40
33
|
loadServerProvider: loadServerTTSProvider,
|
|
41
34
|
});
|
|
42
35
|
},
|
|
43
|
-
getInitConfig: (config) =>
|
|
44
|
-
const settings = resolveTTSRuntimeSettings(config);
|
|
45
|
-
const backend = resolveTTSBackend(settings);
|
|
46
|
-
const serverProvider = resolveRuntimeProvider(settings, backend);
|
|
47
|
-
const transportMode = resolveTransportMode(settings, serverProvider);
|
|
48
|
-
return {
|
|
49
|
-
backend,
|
|
50
|
-
serverProvider,
|
|
51
|
-
transportMode,
|
|
52
|
-
...buildRuntimeTTSConfig(settings),
|
|
53
|
-
};
|
|
54
|
-
},
|
|
36
|
+
getInitConfig: (config) => buildRuntimeTTSConfig(resolveTTSRuntimeSettings(config)),
|
|
55
37
|
getAuthFetcher: (config) => {
|
|
56
38
|
const runtimeAuthFetcher = config?.provider?.runtime?.authFetcher;
|
|
57
39
|
return typeof runtimeAuthFetcher === "function"
|
|
58
40
|
? runtimeAuthFetcher
|
|
59
41
|
: undefined;
|
|
60
42
|
},
|
|
61
|
-
sanitizeConfig: (config) => {
|
|
62
|
-
const settings = config.settings && typeof config.settings === "object"
|
|
63
|
-
? { ...config.settings }
|
|
64
|
-
: undefined;
|
|
65
|
-
if (settings && "layoutMode" in settings) {
|
|
66
|
-
settings.layoutMode = normalizeTTSLayoutMode(settings.layoutMode);
|
|
67
|
-
}
|
|
68
|
-
if (settings && "speedOptions" in settings) {
|
|
69
|
-
settings.speedOptions = normalizeTTSSpeedControlOptions(settings.speedOptions);
|
|
70
|
-
}
|
|
71
|
-
const normalizedConfig = {
|
|
72
|
-
...config,
|
|
73
|
-
};
|
|
74
|
-
if ("layoutMode" in normalizedConfig) {
|
|
75
|
-
normalizedConfig.layoutMode = normalizeTTSLayoutMode(normalizedConfig.layoutMode);
|
|
76
|
-
}
|
|
77
|
-
if ("speedOptions" in normalizedConfig) {
|
|
78
|
-
normalizedConfig.speedOptions = normalizeTTSSpeedControlOptions(normalizedConfig.speedOptions);
|
|
79
|
-
}
|
|
80
|
-
if (settings) {
|
|
81
|
-
normalizedConfig.settings = settings;
|
|
82
|
-
}
|
|
83
|
-
return normalizedConfig;
|
|
84
|
-
},
|
|
85
43
|
lazy: true,
|
|
86
44
|
},
|
|
45
|
+
sanitizeConfig: (config) => {
|
|
46
|
+
const normalizedConfig = {
|
|
47
|
+
...config,
|
|
48
|
+
};
|
|
49
|
+
if ("layoutMode" in normalizedConfig) {
|
|
50
|
+
normalizedConfig.layoutMode = normalizeTTSLayoutMode(normalizedConfig.layoutMode);
|
|
51
|
+
}
|
|
52
|
+
if ("speedOptions" in normalizedConfig) {
|
|
53
|
+
normalizedConfig.speedOptions = normalizeTTSSpeedControlOptions(normalizedConfig.speedOptions);
|
|
54
|
+
}
|
|
55
|
+
return normalizedConfig;
|
|
56
|
+
},
|
|
87
57
|
// TTS is inline-only and scoped to item/passage contexts.
|
|
88
58
|
supportedLevels: ["item", "passage"],
|
|
89
|
-
// PNP support IDs that enable this tool
|
|
90
|
-
// Maps to QTI 3.0 standard features: textToSpeech, readAloud
|
|
91
|
-
pnpSupportIds: [
|
|
92
|
-
"textToSpeech", // QTI 3.0 standard (auditory.textToSpeech)
|
|
93
|
-
"readAloud", // QTI 3.0 standard (auditory.readAloud)
|
|
94
|
-
],
|
|
95
59
|
/**
|
|
96
60
|
* Pass 2: Determine if TTS is relevant in this context
|
|
97
61
|
*
|
|
@@ -101,7 +65,7 @@ export const ttsToolRegistration = {
|
|
|
101
65
|
isVisibleInContext(context) {
|
|
102
66
|
return hasReadableText(context);
|
|
103
67
|
},
|
|
104
|
-
renderToolbar(
|
|
68
|
+
renderToolbar(context, toolbarContext) {
|
|
105
69
|
const resolveRuntimeSettings = () => resolveTTSRuntimeSettings(toolbarContext.toolkitCoordinator?.getToolConfig(this.toolId) ||
|
|
106
70
|
undefined);
|
|
107
71
|
const resolveElementSpeedOptions = () => {
|
|
@@ -111,44 +75,38 @@ export const ttsToolRegistration = {
|
|
|
111
75
|
const resolveLayoutMode = () => resolveTTSLayoutMode(resolveRuntimeSettings());
|
|
112
76
|
const resolveHostLayout = () => resolveTTSHostToolbarLayout(resolveRuntimeSettings());
|
|
113
77
|
const fullToolId = createScopedToolId(this.toolId, toolbarContext.scope.level, toolbarContext.scope.scopeId);
|
|
78
|
+
// Only a language the toolbar or its host named: unnamed, the control resolves
|
|
79
|
+
// markup `lang`, and the browser voice follows the browser's language.
|
|
80
|
+
const applyContentLanguage = (element) => {
|
|
81
|
+
if (toolbarContext.language) {
|
|
82
|
+
element.setAttribute("language", toolbarContext.language);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
element.removeAttribute("language");
|
|
86
|
+
}
|
|
87
|
+
};
|
|
114
88
|
const resolveControlSize = () => {
|
|
115
89
|
const raw = toolbarContext.ui?.size;
|
|
116
90
|
return raw === "sm" || raw === "lg" ? raw : "md";
|
|
117
91
|
};
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
if (element &&
|
|
121
|
-
typeof element.isConnected ===
|
|
122
|
-
"boolean" &&
|
|
123
|
-
!element.isConnected) {
|
|
124
|
-
inlineTTSControls.delete(fullToolId);
|
|
125
|
-
element = undefined;
|
|
126
|
-
}
|
|
127
|
-
if (!element) {
|
|
128
|
-
element = document.createElement("pie-tool-tts-inline");
|
|
129
|
-
element[TOOL_ELEMENT_UNMOUNT_CALLBACK_PROP] = () => {
|
|
130
|
-
if (inlineTTSControls.get(fullToolId) === element) {
|
|
131
|
-
inlineTTSControls.delete(fullToolId);
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
inlineTTSControls.set(fullToolId, element);
|
|
135
|
-
}
|
|
92
|
+
const element = resolveOverlayElement(toolbarContext, fullToolId, () => createToolElement(this.toolId, context, toolbarContext, toolbarContext.componentOverrides));
|
|
93
|
+
const applyAttributes = () => {
|
|
136
94
|
element.setAttribute("catalog-id", toolbarContext.catalogId || toolbarContext.itemId);
|
|
137
|
-
element
|
|
95
|
+
applyContentLanguage(element);
|
|
138
96
|
element.setAttribute("size", resolveControlSize());
|
|
139
97
|
element.setAttribute("layout-mode", resolveLayoutMode());
|
|
140
98
|
element.speedOptions = resolveElementSpeedOptions();
|
|
141
99
|
element.showSingleSpeedOption =
|
|
142
100
|
resolveRuntimeSettings().showSingleSpeedOption === true;
|
|
143
|
-
return element;
|
|
144
101
|
};
|
|
102
|
+
applyAttributes();
|
|
145
103
|
const hostLayout = resolveHostLayout();
|
|
146
104
|
return {
|
|
147
105
|
toolId: this.toolId,
|
|
148
106
|
button: null,
|
|
149
107
|
elements: [
|
|
150
108
|
{
|
|
151
|
-
element
|
|
109
|
+
element,
|
|
152
110
|
mount: hostLayout.mount,
|
|
153
111
|
layoutHints: {
|
|
154
112
|
controlsRow: {
|
|
@@ -162,7 +120,6 @@ export const ttsToolRegistration = {
|
|
|
162
120
|
},
|
|
163
121
|
],
|
|
164
122
|
subscribeActive: (callback) => {
|
|
165
|
-
const element = ensureElement();
|
|
166
123
|
const handler = (event) => {
|
|
167
124
|
const detail = event.detail;
|
|
168
125
|
callback(detail?.active === true);
|
|
@@ -172,17 +129,7 @@ export const ttsToolRegistration = {
|
|
|
172
129
|
element.removeEventListener(TOOL_ACTIVE_CHANGE_EVENT, handler);
|
|
173
130
|
};
|
|
174
131
|
},
|
|
175
|
-
sync:
|
|
176
|
-
const element = ensureElement();
|
|
177
|
-
element.setAttribute("tool-id", fullToolId);
|
|
178
|
-
element.setAttribute("catalog-id", toolbarContext.catalogId || toolbarContext.itemId);
|
|
179
|
-
element.setAttribute("language", toolbarContext.language || "en-US");
|
|
180
|
-
element.setAttribute("size", resolveControlSize());
|
|
181
|
-
element.setAttribute("layout-mode", resolveLayoutMode());
|
|
182
|
-
element.speedOptions = resolveElementSpeedOptions();
|
|
183
|
-
element.showSingleSpeedOption =
|
|
184
|
-
resolveRuntimeSettings().showSingleSpeedOption === true;
|
|
185
|
-
},
|
|
132
|
+
sync: applyAttributes,
|
|
186
133
|
};
|
|
187
134
|
},
|
|
188
135
|
};
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-players/pie-default-tool-loaders",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.75",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "Composition layer for the packaged PIE assessment tools: registrations, tag map, placement
|
|
5
|
+
"description": "Composition layer for the packaged PIE assessment tools: registrations, tag map, placement preset, universal and empty profiles, and lazy module loaders",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "git+https://github.com/pie-framework/pie-players.git",
|
|
@@ -33,30 +33,29 @@
|
|
|
33
33
|
"test": "bun test"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@pie-players/pie-assessment-toolkit": "0.3.
|
|
37
|
-
"@pie-players/pie-calculator": "0.3.
|
|
38
|
-
"@pie-players/pie-calculator-cortex": "0.3.
|
|
39
|
-
"@pie-players/pie-calculator-desmos": "0.3.
|
|
40
|
-
"@pie-players/pie-calculator-geogebra": "0.3.
|
|
41
|
-
"@pie-players/pie-players-shared": "0.3.
|
|
42
|
-
"@pie-players/pie-tool-annotation-toolbar": "0.3.
|
|
43
|
-
"@pie-players/pie-tool-answer-eliminator": "0.3.
|
|
44
|
-
"@pie-players/pie-tool-calculator-
|
|
45
|
-
"@pie-players/pie-tool-
|
|
46
|
-
"@pie-players/pie-tool-
|
|
47
|
-
"@pie-players/pie-tool-
|
|
48
|
-
"@pie-players/pie-tool-
|
|
49
|
-
"@pie-players/pie-tool-
|
|
50
|
-
"@pie-players/pie-tool-
|
|
51
|
-
"@pie-players/pie-tool-
|
|
52
|
-
"@pie-players/pie-tool-
|
|
53
|
-
"@pie-players/pie-tool-
|
|
54
|
-
"@pie-players/
|
|
55
|
-
"@pie-players/pie-tool-tts-inline": "0.3.74",
|
|
56
|
-
"@pie-players/tts-client-server": "0.3.74"
|
|
36
|
+
"@pie-players/pie-assessment-toolkit": "0.3.75",
|
|
37
|
+
"@pie-players/pie-calculator": "0.3.75",
|
|
38
|
+
"@pie-players/pie-calculator-cortex": "0.3.75",
|
|
39
|
+
"@pie-players/pie-calculator-desmos": "0.3.75",
|
|
40
|
+
"@pie-players/pie-calculator-geogebra": "0.3.75",
|
|
41
|
+
"@pie-players/pie-players-shared": "0.3.75",
|
|
42
|
+
"@pie-players/pie-tool-annotation-toolbar": "0.3.75",
|
|
43
|
+
"@pie-players/pie-tool-answer-eliminator": "0.3.75",
|
|
44
|
+
"@pie-players/pie-tool-calculator-shared": "0.3.75",
|
|
45
|
+
"@pie-players/pie-tool-dictionary": "0.3.75",
|
|
46
|
+
"@pie-players/pie-tool-graph": "0.3.75",
|
|
47
|
+
"@pie-players/pie-tool-line-reader": "0.3.75",
|
|
48
|
+
"@pie-players/pie-tool-periodic-table": "0.3.75",
|
|
49
|
+
"@pie-players/pie-tool-picture-dictionary": "0.3.75",
|
|
50
|
+
"@pie-players/pie-tool-protractor": "0.3.75",
|
|
51
|
+
"@pie-players/pie-tool-ruler": "0.3.75",
|
|
52
|
+
"@pie-players/pie-tool-theme": "0.3.75",
|
|
53
|
+
"@pie-players/pie-tool-tts-inline": "0.3.75",
|
|
54
|
+
"@pie-players/tts-client-server": "0.3.75"
|
|
57
55
|
},
|
|
58
56
|
"devDependencies": {
|
|
59
57
|
"@biomejs/biome": "^2.5.15",
|
|
58
|
+
"@happy-dom/global-registrator": "^20.14.5",
|
|
60
59
|
"typescript": "^5.9.3"
|
|
61
60
|
},
|
|
62
61
|
"homepage": "https://github.com/pie-framework/pie-players/tree/master/packages/default-tool-loaders#readme",
|