@pie-players/pie-default-tool-loaders 0.3.64 → 0.3.66
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 +101 -7
- package/dist/index.d.ts +9 -16
- package/dist/index.js +10 -45
- package/dist/packaged-capability-composition.d.ts +73 -0
- package/dist/packaged-capability-composition.js +447 -0
- package/dist/packaged-tool-registry.d.ts +2 -0
- package/dist/packaged-tool-registry.js +1 -0
- package/dist/registrations/accessibility-tools.d.ts +34 -0
- package/dist/registrations/accessibility-tools.js +256 -0
- package/dist/registrations/audio-transcript.d.ts +75 -0
- package/dist/registrations/audio-transcript.js +183 -0
- package/dist/registrations/calculator.d.ts +20 -0
- package/dist/registrations/calculator.js +228 -0
- package/dist/registrations/interaction-tools.d.ts +27 -0
- package/dist/registrations/interaction-tools.js +143 -0
- package/dist/registrations/measurement-tools.d.ts +24 -0
- package/dist/registrations/measurement-tools.js +130 -0
- package/dist/registrations/subject-specific-tools.d.ts +27 -0
- package/dist/registrations/subject-specific-tools.js +158 -0
- package/dist/registrations/tts.d.ts +21 -0
- package/dist/registrations/tts.js +184 -0
- package/dist/tool-placement.d.ts +1 -0
- package/dist/tool-placement.js +1 -0
- package/dist/tool-tag-map.d.ts +1 -0
- package/dist/tool-tag-map.js +1 -0
- package/dist/universal-supports.d.ts +1 -0
- package/dist/universal-supports.js +1 -0
- package/package.json +17 -14
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one authored description of PIE's packaged capability composition.
|
|
3
|
+
*
|
|
4
|
+
* Registrations describe what a capability can do. This module owns the
|
|
5
|
+
* deployment decisions around them: element tags, lazy module bootstrap sets,
|
|
6
|
+
* placement presets, toolbar order and the explicit universal-support policy.
|
|
7
|
+
* Public constants are projections of this composition so adding a capability
|
|
8
|
+
* cannot leave a second hand-maintained catalogue silently behind.
|
|
9
|
+
*/
|
|
10
|
+
import { ToolRegistry, } from "@pie-players/pie-assessment-toolkit/tools/internal";
|
|
11
|
+
import { annotationToolbarRegistration, lineReaderToolRegistration, themeToolRegistration, } from "./registrations/accessibility-tools.js";
|
|
12
|
+
import { audioTranscriptRegistration } from "./registrations/audio-transcript.js";
|
|
13
|
+
import { calculatorToolRegistration } from "./registrations/calculator.js";
|
|
14
|
+
import { answerEliminatorToolRegistration, highlighterToolRegistration, } from "./registrations/interaction-tools.js";
|
|
15
|
+
import { protractorToolRegistration, rulerToolRegistration, } from "./registrations/measurement-tools.js";
|
|
16
|
+
import { graphToolRegistration, periodicTableToolRegistration, } from "./registrations/subject-specific-tools.js";
|
|
17
|
+
import { ttsToolRegistration } from "./registrations/tts.js";
|
|
18
|
+
const loadSideEffectModule = (load) => load().then(() => undefined);
|
|
19
|
+
function loadCalculatorModule() {
|
|
20
|
+
if (typeof globalThis !== "undefined" &&
|
|
21
|
+
"customElements" in globalThis &&
|
|
22
|
+
globalThis.customElements?.get("pie-tool-calculator")) {
|
|
23
|
+
return Promise.resolve();
|
|
24
|
+
}
|
|
25
|
+
return loadSideEffectModule(() => import("@pie-players/pie-tool-calculator-desmos"));
|
|
26
|
+
}
|
|
27
|
+
const loadTtsModule = () => loadSideEffectModule(() => import("@pie-players/pie-tool-tts-inline"));
|
|
28
|
+
const loadRulerModule = () => loadSideEffectModule(() => import("@pie-players/pie-tool-ruler"));
|
|
29
|
+
const loadProtractorModule = () => loadSideEffectModule(() => import("@pie-players/pie-tool-protractor"));
|
|
30
|
+
const loadAnswerEliminatorModule = () => loadSideEffectModule(() => import("@pie-players/pie-tool-answer-eliminator"));
|
|
31
|
+
const loadAnnotationToolbarModule = () => loadSideEffectModule(() => import("@pie-players/pie-tool-annotation-toolbar"));
|
|
32
|
+
const loadLineReaderModule = () => loadSideEffectModule(() => import("@pie-players/pie-tool-line-reader"));
|
|
33
|
+
const loadThemeModule = () => loadSideEffectModule(() => import("@pie-players/pie-tool-theme"));
|
|
34
|
+
const loadGraphModule = () => loadSideEffectModule(() => import("@pie-players/pie-tool-graph"));
|
|
35
|
+
const loadPeriodicTableModule = () => loadSideEffectModule(() => import("@pie-players/pie-tool-periodic-table"));
|
|
36
|
+
const PACKAGED_CAPABILITY_DEFINITIONS = [
|
|
37
|
+
{
|
|
38
|
+
registration: calculatorToolRegistration,
|
|
39
|
+
tagName: "pie-tool-calculator",
|
|
40
|
+
loadModule: loadCalculatorModule,
|
|
41
|
+
loaderTargets: ["item", "section"],
|
|
42
|
+
placementOrder: { element: 10 },
|
|
43
|
+
preferredPlacementOrder: { item: 10 },
|
|
44
|
+
toolbarOrder: 20,
|
|
45
|
+
universalSupportIds: [
|
|
46
|
+
"calculator",
|
|
47
|
+
"graphingCalculator",
|
|
48
|
+
"basicCalculator",
|
|
49
|
+
"scientificCalculator",
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
registration: ttsToolRegistration,
|
|
54
|
+
tagName: "pie-tool-text-to-speech",
|
|
55
|
+
loadModule: loadTtsModule,
|
|
56
|
+
loaderTargets: ["item"],
|
|
57
|
+
placementOrder: { item: 10, passage: 10, rubric: 10, element: 30 },
|
|
58
|
+
preferredPlacementOrder: { item: 20, passage: 10 },
|
|
59
|
+
toolbarOrder: 30,
|
|
60
|
+
universalSupportIds: ["textToSpeech", "readAloud", "tts", "speechOutput"],
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
registration: rulerToolRegistration,
|
|
64
|
+
tagName: "pie-tool-ruler",
|
|
65
|
+
loadModule: loadRulerModule,
|
|
66
|
+
loaderTargets: ["section"],
|
|
67
|
+
placementOrder: { element: 40 },
|
|
68
|
+
preferredPlacementOrder: { section: 50 },
|
|
69
|
+
toolbarOrder: 80,
|
|
70
|
+
universalSupportIds: ["ruler", "measurement"],
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
registration: protractorToolRegistration,
|
|
74
|
+
tagName: "pie-tool-protractor",
|
|
75
|
+
loadModule: loadProtractorModule,
|
|
76
|
+
loaderTargets: ["section"],
|
|
77
|
+
placementOrder: { element: 50 },
|
|
78
|
+
preferredPlacementOrder: { section: 60 },
|
|
79
|
+
toolbarOrder: 90,
|
|
80
|
+
universalSupportIds: ["protractor", "angleMeasurement"],
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
registration: answerEliminatorToolRegistration,
|
|
84
|
+
tagName: "pie-tool-answer-eliminator",
|
|
85
|
+
loadModule: loadAnswerEliminatorModule,
|
|
86
|
+
loaderTargets: ["item"],
|
|
87
|
+
placementOrder: { element: 20 },
|
|
88
|
+
preferredPlacementOrder: { item: 30 },
|
|
89
|
+
toolbarOrder: 70,
|
|
90
|
+
universalSupportIds: [
|
|
91
|
+
"answerMasking",
|
|
92
|
+
"answerEliminator",
|
|
93
|
+
"strikethrough",
|
|
94
|
+
"choiceMasking",
|
|
95
|
+
],
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
registration: highlighterToolRegistration,
|
|
99
|
+
tagName: "pie-tool-annotation-toolbar",
|
|
100
|
+
loadModule: loadAnnotationToolbarModule,
|
|
101
|
+
loaderTargets: ["item"],
|
|
102
|
+
placementOrder: { item: 20, passage: 20, rubric: 20, element: 60 },
|
|
103
|
+
toolbarOrder: 60,
|
|
104
|
+
universalSupportIds: ["highlighter", "textHighlight", "annotation"],
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
registration: lineReaderToolRegistration,
|
|
108
|
+
tagName: "pie-tool-line-reader",
|
|
109
|
+
loadModule: loadLineReaderModule,
|
|
110
|
+
loaderTargets: ["section"],
|
|
111
|
+
placementOrder: { passage: 40, rubric: 40 },
|
|
112
|
+
preferredPlacementOrder: { section: 40 },
|
|
113
|
+
toolbarOrder: 40,
|
|
114
|
+
universalSupportIds: [
|
|
115
|
+
"readingMask",
|
|
116
|
+
"readingGuide",
|
|
117
|
+
"readingRuler",
|
|
118
|
+
"lineReader",
|
|
119
|
+
"trackingGuide",
|
|
120
|
+
],
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
registration: themeToolRegistration,
|
|
124
|
+
tagName: "pie-tool-theme",
|
|
125
|
+
loadModule: loadThemeModule,
|
|
126
|
+
loaderTargets: ["item"],
|
|
127
|
+
placementOrder: { assessment: 10, section: 10 },
|
|
128
|
+
preferredPlacementOrder: { section: 10 },
|
|
129
|
+
toolbarOrder: 10,
|
|
130
|
+
universalSupportIds: [
|
|
131
|
+
"highContrastDisplay",
|
|
132
|
+
"colorContrast",
|
|
133
|
+
"invertColors",
|
|
134
|
+
"theme",
|
|
135
|
+
"highContrast",
|
|
136
|
+
"customColors",
|
|
137
|
+
],
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
registration: annotationToolbarRegistration,
|
|
141
|
+
tagName: "pie-tool-annotation-toolbar",
|
|
142
|
+
loadModule: loadAnnotationToolbarModule,
|
|
143
|
+
loaderTargets: ["item"],
|
|
144
|
+
placementOrder: { item: 30, passage: 30, rubric: 30, element: 70 },
|
|
145
|
+
preferredPlacementOrder: { item: 40, passage: 20 },
|
|
146
|
+
toolbarOrder: 50,
|
|
147
|
+
universalSupportIds: ["highlighting", "annotations"],
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
registration: graphToolRegistration,
|
|
151
|
+
tagName: "pie-tool-graph",
|
|
152
|
+
loadModule: loadGraphModule,
|
|
153
|
+
loaderTargets: ["section"],
|
|
154
|
+
placementOrder: { item: 40, element: 80 },
|
|
155
|
+
preferredPlacementOrder: { section: 20 },
|
|
156
|
+
toolbarOrder: 100,
|
|
157
|
+
universalSupportIds: ["graph", "coordinatePlane", "graphingTool"],
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
registration: periodicTableToolRegistration,
|
|
161
|
+
tagName: "pie-tool-periodic-table",
|
|
162
|
+
loadModule: loadPeriodicTableModule,
|
|
163
|
+
loaderTargets: ["section"],
|
|
164
|
+
placementOrder: { item: 50, element: 90 },
|
|
165
|
+
preferredPlacementOrder: { section: 30 },
|
|
166
|
+
toolbarOrder: 110,
|
|
167
|
+
universalSupportIds: [
|
|
168
|
+
"periodicTable",
|
|
169
|
+
"chemistryReference",
|
|
170
|
+
"elementReference",
|
|
171
|
+
],
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
registration: audioTranscriptRegistration,
|
|
175
|
+
universalSupportIds: [],
|
|
176
|
+
},
|
|
177
|
+
];
|
|
178
|
+
const PACKAGED_PLACEMENT_LEVELS = [
|
|
179
|
+
"assessment",
|
|
180
|
+
"section",
|
|
181
|
+
"item",
|
|
182
|
+
"passage",
|
|
183
|
+
"rubric",
|
|
184
|
+
"element",
|
|
185
|
+
];
|
|
186
|
+
const PREFERRED_PLACEMENT_LEVELS = ["section", "item", "passage"];
|
|
187
|
+
function assertUniqueWeights(definitions, levels, read, field) {
|
|
188
|
+
for (const level of levels) {
|
|
189
|
+
const seen = new Set();
|
|
190
|
+
for (const definition of definitions) {
|
|
191
|
+
const weight = read(definition)?.[level];
|
|
192
|
+
if (weight === undefined)
|
|
193
|
+
continue;
|
|
194
|
+
if (!Number.isSafeInteger(weight) || weight < 0) {
|
|
195
|
+
throw new Error(`Invalid packaged capability "${definition.registration.toolId}": ${field}.${level} must be a non-negative integer.`);
|
|
196
|
+
}
|
|
197
|
+
if (seen.has(weight)) {
|
|
198
|
+
throw new Error(`Invalid packaged capability composition: duplicate ${field}.${level} order ${weight}.`);
|
|
199
|
+
}
|
|
200
|
+
seen.add(weight);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
function assertComposition(definitions) {
|
|
205
|
+
const toolIds = new Set();
|
|
206
|
+
const universalSupportIds = new Set();
|
|
207
|
+
const toolbarOrders = new Set();
|
|
208
|
+
for (const definition of definitions) {
|
|
209
|
+
const { registration } = definition;
|
|
210
|
+
if (!registration.toolId.trim()) {
|
|
211
|
+
throw new Error("Invalid packaged capability composition: tool ids must be non-empty.");
|
|
212
|
+
}
|
|
213
|
+
if (toolIds.has(registration.toolId)) {
|
|
214
|
+
throw new Error(`Invalid packaged capability composition: duplicate tool id "${registration.toolId}".`);
|
|
215
|
+
}
|
|
216
|
+
toolIds.add(registration.toolId);
|
|
217
|
+
const isRegion = registration.activation === "region";
|
|
218
|
+
if (isRegion) {
|
|
219
|
+
if (definition.tagName !== undefined ||
|
|
220
|
+
definition.loadModule !== undefined ||
|
|
221
|
+
definition.loaderTargets !== undefined ||
|
|
222
|
+
definition.toolbarOrder !== undefined ||
|
|
223
|
+
Object.keys(definition.placementOrder ?? {}).length > 0 ||
|
|
224
|
+
Object.keys(definition.preferredPlacementOrder ?? {}).length > 0) {
|
|
225
|
+
throw new Error(`Invalid packaged capability "${registration.toolId}": a region capability is surface-hosted and cannot declare element delivery or toolbar placement.`);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
if (!definition.tagName?.includes("-")) {
|
|
230
|
+
throw new Error(`Invalid packaged capability "${registration.toolId}": element-backed capabilities need a custom-element tag.`);
|
|
231
|
+
}
|
|
232
|
+
if (typeof definition.loadModule !== "function" ||
|
|
233
|
+
!definition.loaderTargets?.length) {
|
|
234
|
+
throw new Error(`Invalid packaged capability "${registration.toolId}": element-backed capabilities need a lazy loader and at least one bootstrap target.`);
|
|
235
|
+
}
|
|
236
|
+
if (new Set(definition.loaderTargets).size !==
|
|
237
|
+
definition.loaderTargets.length) {
|
|
238
|
+
throw new Error(`Invalid packaged capability "${registration.toolId}": loader bootstrap targets must be unique.`);
|
|
239
|
+
}
|
|
240
|
+
if (definition.toolbarOrder === undefined) {
|
|
241
|
+
throw new Error(`Invalid packaged capability "${registration.toolId}": toolbar capabilities need an order.`);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
if (definition.toolbarOrder !== undefined) {
|
|
245
|
+
if (!Number.isSafeInteger(definition.toolbarOrder) ||
|
|
246
|
+
definition.toolbarOrder < 0) {
|
|
247
|
+
throw new Error(`Invalid packaged capability "${registration.toolId}": toolbar order must be a non-negative integer.`);
|
|
248
|
+
}
|
|
249
|
+
if (toolbarOrders.has(definition.toolbarOrder)) {
|
|
250
|
+
throw new Error(`Invalid packaged capability composition: duplicate toolbar order ${definition.toolbarOrder}.`);
|
|
251
|
+
}
|
|
252
|
+
toolbarOrders.add(definition.toolbarOrder);
|
|
253
|
+
}
|
|
254
|
+
const registrationSupportIds = new Set(registration.pnpSupportIds ?? [registration.toolId]);
|
|
255
|
+
if (registration.requiresAuthoredContent &&
|
|
256
|
+
definition.universalSupportIds.length > 0) {
|
|
257
|
+
throw new Error(`Invalid packaged capability "${registration.toolId}": content-dependent support ids cannot be universally granted.`);
|
|
258
|
+
}
|
|
259
|
+
for (const supportId of definition.universalSupportIds) {
|
|
260
|
+
if (!supportId.trim()) {
|
|
261
|
+
throw new Error(`Invalid packaged capability "${registration.toolId}": universal support ids must be non-empty.`);
|
|
262
|
+
}
|
|
263
|
+
if (!registrationSupportIds.has(supportId)) {
|
|
264
|
+
throw new Error(`Invalid packaged capability "${registration.toolId}": universal support id "${supportId}" is not declared by its registration.`);
|
|
265
|
+
}
|
|
266
|
+
if (universalSupportIds.has(supportId)) {
|
|
267
|
+
throw new Error(`Invalid packaged capability composition: universal support id "${supportId}" has more than one owner.`);
|
|
268
|
+
}
|
|
269
|
+
universalSupportIds.add(supportId);
|
|
270
|
+
}
|
|
271
|
+
for (const level of PREFERRED_PLACEMENT_LEVELS) {
|
|
272
|
+
if (definition.preferredPlacementOrder?.[level] !== undefined &&
|
|
273
|
+
!registration.supportedLevels.includes(level)) {
|
|
274
|
+
throw new Error(`Invalid packaged capability "${registration.toolId}": preferred placement "${level}" is not supported by its registration.`);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
assertUniqueWeights(definitions, PACKAGED_PLACEMENT_LEVELS, (definition) => definition.placementOrder, "placementOrder");
|
|
279
|
+
assertUniqueWeights(definitions, PREFERRED_PLACEMENT_LEVELS, (definition) => definition.preferredPlacementOrder, "preferredPlacementOrder");
|
|
280
|
+
}
|
|
281
|
+
function orderedToolIds(definitions, level, read) {
|
|
282
|
+
return definitions
|
|
283
|
+
.flatMap((definition) => {
|
|
284
|
+
const order = read(definition)?.[level];
|
|
285
|
+
return order === undefined ? [] : [{ definition, order }];
|
|
286
|
+
})
|
|
287
|
+
.sort((left, right) => left.order - right.order)
|
|
288
|
+
.map(({ definition }) => definition.registration.toolId);
|
|
289
|
+
}
|
|
290
|
+
class PackagedCapabilityComposition {
|
|
291
|
+
definitions;
|
|
292
|
+
registrations;
|
|
293
|
+
toolTagMap;
|
|
294
|
+
itemModuleLoaders;
|
|
295
|
+
sectionModuleLoaders;
|
|
296
|
+
defaultModuleLoaders;
|
|
297
|
+
placement;
|
|
298
|
+
preferredPlacement;
|
|
299
|
+
toolbarOrder;
|
|
300
|
+
universalSupportIds;
|
|
301
|
+
constructor(definitions) {
|
|
302
|
+
this.definitions = definitions;
|
|
303
|
+
this.registrations = Object.freeze(definitions.map(({ registration }) => registration));
|
|
304
|
+
this.toolTagMap = Object.freeze(Object.fromEntries(definitions.flatMap((definition) => definition.tagName
|
|
305
|
+
? [[definition.registration.toolId, definition.tagName]]
|
|
306
|
+
: [])));
|
|
307
|
+
this.itemModuleLoaders = this.projectModuleLoaders("item");
|
|
308
|
+
this.sectionModuleLoaders = this.projectModuleLoaders("section");
|
|
309
|
+
this.defaultModuleLoaders = Object.freeze({
|
|
310
|
+
...this.itemModuleLoaders,
|
|
311
|
+
...this.sectionModuleLoaders,
|
|
312
|
+
});
|
|
313
|
+
this.placement = Object.freeze(Object.fromEntries(PACKAGED_PLACEMENT_LEVELS.map((level) => [
|
|
314
|
+
level,
|
|
315
|
+
Object.freeze(orderedToolIds(definitions, level, (definition) => definition.placementOrder)),
|
|
316
|
+
])));
|
|
317
|
+
this.preferredPlacement = Object.freeze(Object.fromEntries(PREFERRED_PLACEMENT_LEVELS.map((level) => [
|
|
318
|
+
level,
|
|
319
|
+
Object.freeze(orderedToolIds(definitions, level, (definition) => definition.preferredPlacementOrder)),
|
|
320
|
+
])));
|
|
321
|
+
this.toolbarOrder = Object.freeze(definitions
|
|
322
|
+
.filter((definition) => definition.toolbarOrder !== undefined)
|
|
323
|
+
.slice()
|
|
324
|
+
.sort((left, right) => left.toolbarOrder - right.toolbarOrder)
|
|
325
|
+
.map(({ registration }) => registration.toolId));
|
|
326
|
+
this.universalSupportIds = Object.freeze(definitions
|
|
327
|
+
.flatMap(({ universalSupportIds }) => [...universalSupportIds])
|
|
328
|
+
.sort());
|
|
329
|
+
}
|
|
330
|
+
projectModuleLoaders(target) {
|
|
331
|
+
return Object.freeze(Object.fromEntries(this.definitions.flatMap((definition) => definition.loadModule && definition.loaderTargets?.includes(target)
|
|
332
|
+
? [[definition.registration.toolId, definition.loadModule]]
|
|
333
|
+
: [])));
|
|
334
|
+
}
|
|
335
|
+
selectRegistrations(toolIds) {
|
|
336
|
+
// Preserve the established fail-soft host behavior: no selection means all,
|
|
337
|
+
// and unknown ids are ignored rather than preventing known tools from loading.
|
|
338
|
+
if (!toolIds?.length)
|
|
339
|
+
return this.registrations;
|
|
340
|
+
const selected = new Set(toolIds);
|
|
341
|
+
return this.registrations.filter(({ toolId }) => selected.has(toolId));
|
|
342
|
+
}
|
|
343
|
+
registerTools(registry, options = {}) {
|
|
344
|
+
const applyOverrides = options.applyOverrides ??
|
|
345
|
+
((registration) => registration);
|
|
346
|
+
for (const registration of this.selectRegistrations(options.toolIds)) {
|
|
347
|
+
registry.register(applyOverrides(registration));
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
createRegistry(options = {}) {
|
|
351
|
+
const registry = new ToolRegistry();
|
|
352
|
+
this.registerTools(registry, {
|
|
353
|
+
toolIds: options.toolIds,
|
|
354
|
+
applyOverrides: (registration) => options.overrides?.[registration.toolId] ?? registration,
|
|
355
|
+
});
|
|
356
|
+
// Loader installation remains opt-in. Some hosts preload tool elements or
|
|
357
|
+
// provide their own tags; silently adding package loads here would change
|
|
358
|
+
// their bundle/runtime behavior.
|
|
359
|
+
if (options.toolModuleLoaders &&
|
|
360
|
+
Object.keys(options.toolModuleLoaders).length > 0) {
|
|
361
|
+
registry.setToolModuleLoaders(options.toolModuleLoaders);
|
|
362
|
+
}
|
|
363
|
+
registry.setComponentOverrides({
|
|
364
|
+
toolTagMap: { ...this.toolTagMap, ...(options.toolTagMap ?? {}) },
|
|
365
|
+
toolComponentFactory: options.toolComponentFactory,
|
|
366
|
+
toolComponentFactories: options.toolComponentFactories,
|
|
367
|
+
});
|
|
368
|
+
return registry;
|
|
369
|
+
}
|
|
370
|
+
createUniversalPersonalNeedsProfile() {
|
|
371
|
+
return {
|
|
372
|
+
supports: [...this.universalSupportIds],
|
|
373
|
+
prohibitedSupports: [],
|
|
374
|
+
activateAtInit: [],
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Release/build gate for PIE-authored composition data.
|
|
380
|
+
*
|
|
381
|
+
* Deliberately not called by the browser runtime: an invariant regression must
|
|
382
|
+
* stop the package before publication, not turn into an import-time exception
|
|
383
|
+
* that prevents an otherwise usable assessment from rendering.
|
|
384
|
+
*/
|
|
385
|
+
export function assertPackagedCapabilityComposition() {
|
|
386
|
+
assertComposition(PACKAGED_CAPABILITY_DEFINITIONS);
|
|
387
|
+
}
|
|
388
|
+
/** Internal deep-module instance. Root exports below are its stable facade. */
|
|
389
|
+
const packagedCapabilityComposition = new PackagedCapabilityComposition(PACKAGED_CAPABILITY_DEFINITIONS);
|
|
390
|
+
export const PACKAGED_TOOL_REGISTRATIONS = [
|
|
391
|
+
...packagedCapabilityComposition.registrations,
|
|
392
|
+
];
|
|
393
|
+
export const PACKAGED_TOOL_TAG_MAP = {
|
|
394
|
+
...packagedCapabilityComposition.toolTagMap,
|
|
395
|
+
};
|
|
396
|
+
export const ITEM_TOOL_MODULE_LOADERS = {
|
|
397
|
+
...packagedCapabilityComposition.itemModuleLoaders,
|
|
398
|
+
};
|
|
399
|
+
export const SECTION_TOOL_MODULE_LOADERS = {
|
|
400
|
+
...packagedCapabilityComposition.sectionModuleLoaders,
|
|
401
|
+
};
|
|
402
|
+
export const DEFAULT_TOOL_MODULE_LOADERS = {
|
|
403
|
+
...packagedCapabilityComposition.defaultModuleLoaders,
|
|
404
|
+
};
|
|
405
|
+
export const PACKAGED_TOOL_PLACEMENT = {
|
|
406
|
+
assessment: [...packagedCapabilityComposition.placement.assessment],
|
|
407
|
+
section: [...packagedCapabilityComposition.placement.section],
|
|
408
|
+
item: [...packagedCapabilityComposition.placement.item],
|
|
409
|
+
passage: [...packagedCapabilityComposition.placement.passage],
|
|
410
|
+
rubric: [...packagedCapabilityComposition.placement.rubric],
|
|
411
|
+
element: [...packagedCapabilityComposition.placement.element],
|
|
412
|
+
};
|
|
413
|
+
export const SECTION_PLAYER_PREFERRED_TOOL_PLACEMENT = {
|
|
414
|
+
section: [...packagedCapabilityComposition.preferredPlacement.section],
|
|
415
|
+
item: [...packagedCapabilityComposition.preferredPlacement.item],
|
|
416
|
+
passage: [...packagedCapabilityComposition.preferredPlacement.passage],
|
|
417
|
+
};
|
|
418
|
+
export const PACKAGED_TOOL_ORDER = [
|
|
419
|
+
...packagedCapabilityComposition.toolbarOrder,
|
|
420
|
+
];
|
|
421
|
+
export const UNIVERSAL_SUPPORTS_PRESET = packagedCapabilityComposition.universalSupportIds;
|
|
422
|
+
/** Register packaged PIE capabilities onto an existing registry. */
|
|
423
|
+
export function registerPackagedTools(registry, options = {}) {
|
|
424
|
+
packagedCapabilityComposition.registerTools(registry, options);
|
|
425
|
+
}
|
|
426
|
+
/** Create a registry holding the packaged PIE capabilities. */
|
|
427
|
+
export function createPackagedToolRegistry(options = {}) {
|
|
428
|
+
return packagedCapabilityComposition.createRegistry(options);
|
|
429
|
+
}
|
|
430
|
+
/** Build a fresh profile granting the explicit universal-support preset. */
|
|
431
|
+
export function createUniversalPersonalNeedsProfile() {
|
|
432
|
+
return packagedCapabilityComposition.createUniversalPersonalNeedsProfile();
|
|
433
|
+
}
|
|
434
|
+
/** Register packaged lazy module loaders, followed by host overrides. */
|
|
435
|
+
export function registerDefaultToolModuleLoaders(registry, options = {}) {
|
|
436
|
+
registry.setToolModuleLoaders({
|
|
437
|
+
...DEFAULT_TOOL_MODULE_LOADERS,
|
|
438
|
+
...(options.loaders ?? {}),
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
/** Register only the section-bootstrap loader subset, then host overrides. */
|
|
442
|
+
export function registerSectionToolModuleLoaders(registry, options = {}) {
|
|
443
|
+
registry.setToolModuleLoaders({
|
|
444
|
+
...SECTION_TOOL_MODULE_LOADERS,
|
|
445
|
+
...(options.loaders ?? {}),
|
|
446
|
+
});
|
|
447
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export type { PackagedToolRegistryOptions, RegisterPackagedToolsOptions, } from "./packaged-capability-composition.js";
|
|
2
|
+
export { createPackagedToolRegistry, PACKAGED_TOOL_ORDER, PACKAGED_TOOL_REGISTRATIONS, registerPackagedTools, } from "./packaged-capability-composition.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createPackagedToolRegistry, PACKAGED_TOOL_ORDER, PACKAGED_TOOL_REGISTRATIONS, registerPackagedTools, } from "./packaged-capability-composition.js";
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Accessibility Tools Registrations
|
|
3
|
+
*
|
|
4
|
+
* Registers tools for visual accessibility and reading support:
|
|
5
|
+
* - Line Reader (reading guide)
|
|
6
|
+
* - Color Scheme (theme/contrast)
|
|
7
|
+
* - Annotation Toolbar (text highlighting)
|
|
8
|
+
*
|
|
9
|
+
* Maps to QTI 3.0 standard access features from:
|
|
10
|
+
* - visual category: highContrastDisplay, colorContrast
|
|
11
|
+
* - reading category: readingMask, readingGuide, highlighting
|
|
12
|
+
*/
|
|
13
|
+
import type { ToolRegistration } from "@pie-players/pie-assessment-toolkit/tools/internal";
|
|
14
|
+
/**
|
|
15
|
+
* Line Reader tool registration
|
|
16
|
+
*
|
|
17
|
+
* Provides a reading guide overlay to help track reading position.
|
|
18
|
+
* Useful for text-heavy passages and questions.
|
|
19
|
+
*/
|
|
20
|
+
export declare const lineReaderToolRegistration: ToolRegistration;
|
|
21
|
+
/**
|
|
22
|
+
* Theme tool registration
|
|
23
|
+
*
|
|
24
|
+
* Provides accessible theme and contrast controls.
|
|
25
|
+
* Global tool that affects entire assessment.
|
|
26
|
+
*/
|
|
27
|
+
export declare const themeToolRegistration: ToolRegistration;
|
|
28
|
+
/**
|
|
29
|
+
* Annotation Toolbar registration
|
|
30
|
+
*
|
|
31
|
+
* Text highlighting with CSS Custom Highlight API.
|
|
32
|
+
* Zero DOM mutation, optimal performance.
|
|
33
|
+
*/
|
|
34
|
+
export declare const annotationToolbarRegistration: ToolRegistration;
|