@pie-players/pie-default-tool-loaders 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.
package/README.md CHANGED
@@ -17,7 +17,7 @@ and how does the program tier them":
17
17
  | `PACKAGED_TOOL_TAG_MAP` | Which custom element each one renders as |
18
18
  | `PACKAGED_TOOL_PLACEMENT`, `SECTION_PLAYER_PREFERRED_TOOL_PLACEMENT`, `PACKAGED_TOOL_ORDER` | Where they appear and in what order |
19
19
  | `UNIVERSAL_SUPPORTS_PRESET`, `createUniversalPersonalNeedsProfile` | Which of their support ids the program grants to everyone |
20
- | `DEFAULT_TOOL_MODULE_LOADERS`, `registerSectionToolModuleLoaders` | When each one's bundle loads |
20
+ | `DEFAULT_TOOL_MODULE_LOADERS`, `createDefaultToolModuleLoaders`, `registerSectionToolModuleLoaders` | When each one's bundle loads |
21
21
 
22
22
  The individual registrations are exported too, so a host can compose its own set
23
23
  rather than take the packaged one whole.
@@ -52,6 +52,43 @@ const registry = createPackagedToolRegistry({
52
52
  });
53
53
  ```
54
54
 
55
+ Desmos remains the calculator delivery when no provider is configured. To use
56
+ GeoGebra or the fully bundled open-source Cortex implementation, pass the same
57
+ calculator configuration to both the toolkit and the
58
+ packaged composition. The composition then owns the matching element tag and
59
+ module loader; hosts do not hand-maintain a second vendor map.
60
+
61
+ ```ts
62
+ import {
63
+ createDefaultToolModuleLoaders,
64
+ createPackagedToolRegistry,
65
+ } from "@pie-players/pie-default-tool-loaders";
66
+
67
+ const calculatorProviderConfig = {
68
+ provider: {
69
+ id: "calculator-geogebra",
70
+ init: { appletTimeoutMs: 20_000 },
71
+ },
72
+ settings: { showResetIcon: true },
73
+ };
74
+
75
+ const registry = createPackagedToolRegistry({
76
+ calculatorProviderConfig,
77
+ toolModuleLoaders: createDefaultToolModuleLoaders({
78
+ calculatorProviderConfig,
79
+ }),
80
+ });
81
+
82
+ const tools = {
83
+ providers: { calculator: calculatorProviderConfig },
84
+ };
85
+ ```
86
+
87
+ For an offline-capable calculator with no API key or runtime CDN, use
88
+ `provider.id: "calculator-cortex"`. Its `settings` accept angle mode, precision,
89
+ history, evaluation limit, allowed functions, clipboard policy, and graph
90
+ viewport options documented by `@pie-players/pie-calculator-cortex`.
91
+
55
92
  `createDefaultToolRegistry()` in the toolkit is the other end of that choice: it
56
93
  builds an empty registry, and a host composing its own set registers into it.
57
94
 
package/dist/index.d.ts CHANGED
@@ -1,10 +1,11 @@
1
- export type { PackagedToolRegistryOptions, RegisterDefaultToolModuleLoadersOptions, RegisterPackagedToolsOptions, ToolModuleLoader, ToolRegistryLike, } from "./packaged-capability-composition.js";
2
- export { createPackagedToolRegistry, createUniversalPersonalNeedsProfile, DEFAULT_TOOL_MODULE_LOADERS, ITEM_TOOL_MODULE_LOADERS, PACKAGED_TOOL_ORDER, PACKAGED_TOOL_PLACEMENT, PACKAGED_TOOL_REGISTRATIONS, PACKAGED_TOOL_TAG_MAP, registerDefaultToolModuleLoaders, registerPackagedTools, registerSectionToolModuleLoaders, SECTION_PLAYER_PREFERRED_TOOL_PLACEMENT, SECTION_TOOL_MODULE_LOADERS, UNIVERSAL_SUPPORTS_PRESET, } from "./packaged-capability-composition.js";
1
+ export type { PackagedCalculatorCompositionOptions, PackagedToolRegistryOptions, RegisterDefaultToolModuleLoadersOptions, RegisterPackagedToolsOptions, ToolModuleLoader, ToolRegistryLike, } from "./packaged-capability-composition.js";
2
+ export { createPackagedToolRegistry, createDefaultToolModuleLoaders, createSectionToolModuleLoaders, createUniversalPersonalNeedsProfile, DEFAULT_TOOL_MODULE_LOADERS, ITEM_TOOL_MODULE_LOADERS, PACKAGED_TOOL_ORDER, PACKAGED_TOOL_PLACEMENT, PACKAGED_TOOL_REGISTRATIONS, PACKAGED_TOOL_TAG_MAP, registerDefaultToolModuleLoaders, registerPackagedTools, registerSectionToolModuleLoaders, SECTION_PLAYER_PREFERRED_TOOL_PLACEMENT, SECTION_TOOL_MODULE_LOADERS, UNIVERSAL_SUPPORTS_PRESET, } from "./packaged-capability-composition.js";
3
3
  export { CONTENT_ALTERNATE_REGISTRATIONS } from "./content-alternates.js";
4
4
  export { annotationToolbarRegistration, lineReaderToolRegistration, themeToolRegistration, } from "./registrations/accessibility-tools.js";
5
5
  export { AUDIO_TRANSCRIPT_FEATURE_ID, AUDIO_TRANSCRIPT_REGION_CLASS, AUDIO_TRANSCRIPT_REGION_LABEL, audioTranscriptRegistration, resolveAudioTranscript, type ResolvedAudioTranscript, } from "./registrations/audio-transcript.js";
6
6
  export { calculatorToolRegistration } from "./registrations/calculator.js";
7
- export { answerEliminatorToolRegistration, highlighterToolRegistration, } from "./registrations/interaction-tools.js";
7
+ export { createDictionaryToolRegistration, createPictureDictionaryToolRegistration, dictionaryToolRegistration, type DictionaryVariantOptions, pictureDictionaryToolRegistration, spanishDictionaryToolRegistration, spanishPictureDictionaryToolRegistration, } from "./registrations/dictionary-tools.js";
8
+ export { answerEliminatorToolRegistration } from "./registrations/interaction-tools.js";
8
9
  export { protractorToolRegistration, rulerToolRegistration, } from "./registrations/measurement-tools.js";
9
10
  export { graphToolRegistration, periodicTableToolRegistration, } from "./registrations/subject-specific-tools.js";
10
11
  export { ttsToolRegistration } from "./registrations/tts.js";
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { createPackagedToolRegistry, createUniversalPersonalNeedsProfile, DEFAULT_TOOL_MODULE_LOADERS, ITEM_TOOL_MODULE_LOADERS, PACKAGED_TOOL_ORDER, PACKAGED_TOOL_PLACEMENT, PACKAGED_TOOL_REGISTRATIONS, PACKAGED_TOOL_TAG_MAP, registerDefaultToolModuleLoaders, registerPackagedTools, registerSectionToolModuleLoaders, SECTION_PLAYER_PREFERRED_TOOL_PLACEMENT, SECTION_TOOL_MODULE_LOADERS, UNIVERSAL_SUPPORTS_PRESET, } from "./packaged-capability-composition.js";
1
+ export { createPackagedToolRegistry, createDefaultToolModuleLoaders, createSectionToolModuleLoaders, createUniversalPersonalNeedsProfile, DEFAULT_TOOL_MODULE_LOADERS, ITEM_TOOL_MODULE_LOADERS, PACKAGED_TOOL_ORDER, PACKAGED_TOOL_PLACEMENT, PACKAGED_TOOL_REGISTRATIONS, PACKAGED_TOOL_TAG_MAP, registerDefaultToolModuleLoaders, registerPackagedTools, registerSectionToolModuleLoaders, SECTION_PLAYER_PREFERRED_TOOL_PLACEMENT, SECTION_TOOL_MODULE_LOADERS, UNIVERSAL_SUPPORTS_PRESET, } from "./packaged-capability-composition.js";
2
2
  // The authored-alternate subset, for a renderer that shows alternates and no
3
3
  // toolbar — importable without the packaged composition's tool loaders.
4
4
  export { CONTENT_ALTERNATE_REGISTRATIONS } from "./content-alternates.js";
@@ -7,7 +7,8 @@ export { CONTENT_ALTERNATE_REGISTRATIONS } from "./content-alternates.js";
7
7
  export { annotationToolbarRegistration, lineReaderToolRegistration, themeToolRegistration, } from "./registrations/accessibility-tools.js";
8
8
  export { AUDIO_TRANSCRIPT_FEATURE_ID, AUDIO_TRANSCRIPT_REGION_CLASS, AUDIO_TRANSCRIPT_REGION_LABEL, audioTranscriptRegistration, resolveAudioTranscript, } from "./registrations/audio-transcript.js";
9
9
  export { calculatorToolRegistration } from "./registrations/calculator.js";
10
- export { answerEliminatorToolRegistration, highlighterToolRegistration, } from "./registrations/interaction-tools.js";
10
+ export { createDictionaryToolRegistration, createPictureDictionaryToolRegistration, dictionaryToolRegistration, pictureDictionaryToolRegistration, spanishDictionaryToolRegistration, spanishPictureDictionaryToolRegistration, } from "./registrations/dictionary-tools.js";
11
+ export { answerEliminatorToolRegistration } from "./registrations/interaction-tools.js";
11
12
  export { protractorToolRegistration, rulerToolRegistration, } from "./registrations/measurement-tools.js";
12
13
  export { graphToolRegistration, periodicTableToolRegistration, } from "./registrations/subject-specific-tools.js";
13
14
  export { ttsToolRegistration } from "./registrations/tts.js";
@@ -7,13 +7,21 @@
7
7
  * Public constants are projections of this composition so adding a capability
8
8
  * cannot leave a second hand-maintained catalogue silently behind.
9
9
  */
10
- import { ToolRegistry, type ToolComponentFactory, type ToolComponentFactoryMap, type ToolRegistration, type ToolTagMap } from "@pie-players/pie-assessment-toolkit/tools/internal";
10
+ import { ToolRegistry, type ToolComponentFactory, type ToolComponentFactoryMap, type ToolRegistration, type ToolTagMap, type ToolProviderConfig } from "@pie-players/pie-assessment-toolkit/tools/internal";
11
11
  import type { PersonalNeedsProfile } from "@pie-players/pie-players-shared/types";
12
12
  export type ToolModuleLoader = () => Promise<unknown>;
13
13
  export interface ToolRegistryLike {
14
14
  setToolModuleLoaders(loaders: Partial<Record<string, ToolModuleLoader>>): void;
15
15
  }
16
- export interface PackagedToolRegistryOptions {
16
+ export interface PackagedCalculatorCompositionOptions {
17
+ /**
18
+ * The same calculator config supplied at `tools.providers.calculator`.
19
+ * Selects the matching packaged element and default loader. Omit it to retain
20
+ * the existing Desmos delivery.
21
+ */
22
+ calculatorProviderConfig?: ToolProviderConfig;
23
+ }
24
+ export interface PackagedToolRegistryOptions extends PackagedCalculatorCompositionOptions {
17
25
  /** Override packaged registrations by toolId. */
18
26
  overrides?: Partial<Record<string, ToolRegistration>>;
19
27
  /** Override or extend the packaged element tag mapping. */
@@ -30,9 +38,9 @@ export interface RegisterPackagedToolsOptions {
30
38
  toolIds?: string[];
31
39
  applyOverrides?: (registration: ToolRegistration) => ToolRegistration;
32
40
  }
33
- export type RegisterDefaultToolModuleLoadersOptions = {
41
+ export interface RegisterDefaultToolModuleLoadersOptions extends PackagedCalculatorCompositionOptions {
34
42
  loaders?: Partial<Record<string, ToolModuleLoader>>;
35
- };
43
+ }
36
44
  /**
37
45
  * Release/build gate for PIE-authored composition data.
38
46
  *
@@ -41,25 +49,29 @@ export type RegisterDefaultToolModuleLoadersOptions = {
41
49
  * that prevents an otherwise usable assessment from rendering.
42
50
  */
43
51
  export declare function assertPackagedCapabilityComposition(): void;
44
- export declare const PACKAGED_TOOL_REGISTRATIONS: readonly [ToolRegistration, ToolRegistration, ToolRegistration, ToolRegistration, ToolRegistration, ToolRegistration, ToolRegistration, ToolRegistration, ToolRegistration, ToolRegistration, ToolRegistration, ToolRegistration];
52
+ export declare const PACKAGED_TOOL_REGISTRATIONS: readonly [ToolRegistration, ToolRegistration, ToolRegistration, ToolRegistration, ToolRegistration, ToolRegistration, ToolRegistration, ToolRegistration, ToolRegistration, ToolRegistration, ToolRegistration, ToolRegistration, ToolRegistration, ToolRegistration];
45
53
  export declare const PACKAGED_TOOL_TAG_MAP: ToolTagMap;
46
54
  export declare const ITEM_TOOL_MODULE_LOADERS: Record<string, ToolModuleLoader>;
47
55
  export declare const SECTION_TOOL_MODULE_LOADERS: Record<string, ToolModuleLoader>;
48
56
  export declare const DEFAULT_TOOL_MODULE_LOADERS: Record<string, ToolModuleLoader>;
57
+ /** Build the packaged loader map for a selected calculator provider. */
58
+ export declare function createDefaultToolModuleLoaders(options?: PackagedCalculatorCompositionOptions): Record<string, ToolModuleLoader>;
59
+ /** Build the section-bootstrap loader subset for a selected calculator provider. */
60
+ export declare function createSectionToolModuleLoaders(options?: PackagedCalculatorCompositionOptions): Record<string, ToolModuleLoader>;
49
61
  export declare const PACKAGED_TOOL_PLACEMENT: {
50
62
  readonly assessment: readonly ["theme"];
51
63
  readonly section: readonly ["theme"];
52
- readonly item: readonly ["textToSpeech", "highlighter", "annotationToolbar", "graph", "periodicTable"];
53
- readonly passage: readonly ["textToSpeech", "highlighter", "annotationToolbar", "lineReader"];
54
- readonly rubric: readonly ["textToSpeech", "highlighter", "annotationToolbar", "lineReader"];
55
- readonly element: readonly ["calculator", "answerEliminator", "textToSpeech", "ruler", "protractor", "highlighter", "annotationToolbar", "graph", "periodicTable"];
64
+ readonly item: readonly ["textToSpeech", "annotationToolbar", "graph", "periodicTable", "dictionary", "pictureDictionary", "dictionarySpanish", "pictureDictionarySpanish"];
65
+ readonly passage: readonly ["textToSpeech", "annotationToolbar", "lineReader"];
66
+ readonly rubric: readonly ["textToSpeech", "annotationToolbar", "lineReader"];
67
+ readonly element: readonly ["calculator", "answerEliminator", "textToSpeech", "ruler", "protractor", "annotationToolbar", "graph", "periodicTable", "dictionary", "pictureDictionary", "dictionarySpanish", "pictureDictionarySpanish"];
56
68
  };
57
69
  export declare const SECTION_PLAYER_PREFERRED_TOOL_PLACEMENT: {
58
70
  section: string[];
59
71
  item: string[];
60
72
  passage: string[];
61
73
  };
62
- export declare const PACKAGED_TOOL_ORDER: readonly ["theme", "calculator", "textToSpeech", "lineReader", "annotationToolbar", "highlighter", "answerEliminator", "ruler", "protractor", "graph", "periodicTable"];
74
+ export declare const PACKAGED_TOOL_ORDER: readonly ["theme", "calculator", "textToSpeech", "lineReader", "annotationToolbar", "answerEliminator", "ruler", "protractor", "graph", "periodicTable", "dictionary", "pictureDictionary", "dictionarySpanish", "pictureDictionarySpanish"];
63
75
  export declare const UNIVERSAL_SUPPORTS_PRESET: readonly string[];
64
76
  /** Register packaged PIE capabilities onto an existing registry. */
65
77
  export declare function registerPackagedTools(registry: ToolRegistry, options?: RegisterPackagedToolsOptions): void;
@@ -10,19 +10,40 @@
10
10
  import { ToolRegistry, } from "@pie-players/pie-assessment-toolkit/tools/internal";
11
11
  import { annotationToolbarRegistration, lineReaderToolRegistration, themeToolRegistration, } from "./registrations/accessibility-tools.js";
12
12
  import { audioTranscriptRegistration } from "./registrations/audio-transcript.js";
13
- import { calculatorToolRegistration } from "./registrations/calculator.js";
14
- import { answerEliminatorToolRegistration, highlighterToolRegistration, } from "./registrations/interaction-tools.js";
13
+ import { calculatorToolRegistration, resolveCalculatorProviderId, } from "./registrations/calculator.js";
14
+ import { dictionaryToolRegistration, pictureDictionaryToolRegistration, spanishDictionaryToolRegistration, spanishPictureDictionaryToolRegistration, } from "./registrations/dictionary-tools.js";
15
+ import { answerEliminatorToolRegistration } from "./registrations/interaction-tools.js";
15
16
  import { protractorToolRegistration, rulerToolRegistration, } from "./registrations/measurement-tools.js";
16
17
  import { graphToolRegistration, periodicTableToolRegistration, } from "./registrations/subject-specific-tools.js";
17
18
  import { ttsToolRegistration } from "./registrations/tts.js";
18
19
  const loadSideEffectModule = (load) => load().then(() => undefined);
19
- function loadCalculatorModule() {
20
+ function loadCalculatorElement(tagName, load) {
20
21
  if (typeof globalThis !== "undefined" &&
21
22
  "customElements" in globalThis &&
22
- globalThis.customElements?.get("pie-tool-calculator")) {
23
+ globalThis.customElements?.get(tagName)) {
23
24
  return Promise.resolve();
24
25
  }
25
- return loadSideEffectModule(() => import("@pie-players/pie-tool-calculator-desmos"));
26
+ return loadSideEffectModule(load);
27
+ }
28
+ const loadDesmosCalculatorModule = () => loadCalculatorElement("pie-tool-calculator", () => import("@pie-players/pie-tool-calculator-shared/calculator-element"));
29
+ const loadGeoGebraCalculatorModule = () => loadCalculatorElement("pie-tool-calculator-geogebra", () => import("@pie-players/pie-tool-calculator-geogebra"));
30
+ const loadCortexCalculatorModule = () => loadCalculatorElement("pie-tool-calculator-cortex", () => import("@pie-players/pie-tool-calculator-cortex"));
31
+ const CALCULATOR_DELIVERY = {
32
+ "calculator-desmos": {
33
+ tagName: "pie-tool-calculator",
34
+ loadModule: loadDesmosCalculatorModule,
35
+ },
36
+ "calculator-geogebra": {
37
+ tagName: "pie-tool-calculator-geogebra",
38
+ loadModule: loadGeoGebraCalculatorModule,
39
+ },
40
+ "calculator-cortex": {
41
+ tagName: "pie-tool-calculator-cortex",
42
+ loadModule: loadCortexCalculatorModule,
43
+ },
44
+ };
45
+ function resolveCalculatorDelivery(config) {
46
+ return CALCULATOR_DELIVERY[resolveCalculatorProviderId(config)];
26
47
  }
27
48
  const loadTtsModule = () => loadSideEffectModule(() => import("@pie-players/pie-tool-tts-inline"));
28
49
  const loadRulerModule = () => loadSideEffectModule(() => import("@pie-players/pie-tool-ruler"));
@@ -33,21 +54,18 @@ const loadLineReaderModule = () => loadSideEffectModule(() => import("@pie-playe
33
54
  const loadThemeModule = () => loadSideEffectModule(() => import("@pie-players/pie-tool-theme"));
34
55
  const loadGraphModule = () => loadSideEffectModule(() => import("@pie-players/pie-tool-graph"));
35
56
  const loadPeriodicTableModule = () => loadSideEffectModule(() => import("@pie-players/pie-tool-periodic-table"));
57
+ const loadDictionaryModule = () => loadSideEffectModule(() => import("@pie-players/pie-tool-dictionary"));
58
+ const loadPictureDictionaryModule = () => loadSideEffectModule(() => import("@pie-players/pie-tool-picture-dictionary"));
36
59
  const PACKAGED_CAPABILITY_DEFINITIONS = [
37
60
  {
38
61
  registration: calculatorToolRegistration,
39
- tagName: "pie-tool-calculator",
40
- loadModule: loadCalculatorModule,
62
+ tagName: CALCULATOR_DELIVERY["calculator-desmos"].tagName,
63
+ loadModule: CALCULATOR_DELIVERY["calculator-desmos"].loadModule,
41
64
  loaderTargets: ["item", "section"],
42
65
  placementOrder: { element: 10 },
43
66
  preferredPlacementOrder: { item: 10 },
44
67
  toolbarOrder: 20,
45
- universalSupportIds: [
46
- "calculator",
47
- "graphingCalculator",
48
- "basicCalculator",
49
- "scientificCalculator",
50
- ],
68
+ universalSupportIds: ["calculator", "graphingCalculator"],
51
69
  },
52
70
  {
53
71
  registration: ttsToolRegistration,
@@ -57,7 +75,7 @@ const PACKAGED_CAPABILITY_DEFINITIONS = [
57
75
  placementOrder: { item: 10, passage: 10, rubric: 10, element: 30 },
58
76
  preferredPlacementOrder: { item: 20, passage: 10 },
59
77
  toolbarOrder: 30,
60
- universalSupportIds: ["textToSpeech", "readAloud", "tts", "speechOutput"],
78
+ universalSupportIds: ["textToSpeech", "readAloud"],
61
79
  },
62
80
  {
63
81
  registration: rulerToolRegistration,
@@ -67,7 +85,7 @@ const PACKAGED_CAPABILITY_DEFINITIONS = [
67
85
  placementOrder: { element: 40 },
68
86
  preferredPlacementOrder: { section: 50 },
69
87
  toolbarOrder: 80,
70
- universalSupportIds: ["ruler", "measurement"],
88
+ universalSupportIds: ["ruler"],
71
89
  },
72
90
  {
73
91
  registration: protractorToolRegistration,
@@ -77,7 +95,7 @@ const PACKAGED_CAPABILITY_DEFINITIONS = [
77
95
  placementOrder: { element: 50 },
78
96
  preferredPlacementOrder: { section: 60 },
79
97
  toolbarOrder: 90,
80
- universalSupportIds: ["protractor", "angleMeasurement"],
98
+ universalSupportIds: ["protractor"],
81
99
  },
82
100
  {
83
101
  registration: answerEliminatorToolRegistration,
@@ -87,21 +105,7 @@ const PACKAGED_CAPABILITY_DEFINITIONS = [
87
105
  placementOrder: { element: 20 },
88
106
  preferredPlacementOrder: { item: 30 },
89
107
  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"],
108
+ universalSupportIds: ["answerMasking", "answerEliminator", "strikethrough"],
105
109
  },
106
110
  {
107
111
  registration: lineReaderToolRegistration,
@@ -111,13 +115,7 @@ const PACKAGED_CAPABILITY_DEFINITIONS = [
111
115
  placementOrder: { passage: 40, rubric: 40 },
112
116
  preferredPlacementOrder: { section: 40 },
113
117
  toolbarOrder: 40,
114
- universalSupportIds: [
115
- "readingMask",
116
- "readingGuide",
117
- "readingRuler",
118
- "lineReader",
119
- "trackingGuide",
120
- ],
118
+ universalSupportIds: ["readingMask", "readingGuide", "readingRuler"],
121
119
  },
122
120
  {
123
121
  registration: themeToolRegistration,
@@ -132,8 +130,6 @@ const PACKAGED_CAPABILITY_DEFINITIONS = [
132
130
  "colorContrast",
133
131
  "invertColors",
134
132
  "theme",
135
- "highContrast",
136
- "customColors",
137
133
  ],
138
134
  },
139
135
  {
@@ -144,6 +140,9 @@ const PACKAGED_CAPABILITY_DEFINITIONS = [
144
140
  placementOrder: { item: 30, passage: 30, rubric: 30, element: 70 },
145
141
  preferredPlacementOrder: { item: 40, passage: 20 },
146
142
  toolbarOrder: 50,
143
+ // The last three came from the `highlighter` capability, which mounted this
144
+ // same element behind a second identically-labelled button. Kept here so a
145
+ // profile granted one of the older ids still gets highlighting.
147
146
  universalSupportIds: ["highlighting", "annotations"],
148
147
  },
149
148
  {
@@ -154,7 +153,7 @@ const PACKAGED_CAPABILITY_DEFINITIONS = [
154
153
  placementOrder: { item: 40, element: 80 },
155
154
  preferredPlacementOrder: { section: 20 },
156
155
  toolbarOrder: 100,
157
- universalSupportIds: ["graph", "coordinatePlane", "graphingTool"],
156
+ universalSupportIds: ["graph"],
158
157
  },
159
158
  {
160
159
  registration: periodicTableToolRegistration,
@@ -164,11 +163,52 @@ const PACKAGED_CAPABILITY_DEFINITIONS = [
164
163
  placementOrder: { item: 50, element: 90 },
165
164
  preferredPlacementOrder: { section: 30 },
166
165
  toolbarOrder: 110,
167
- universalSupportIds: [
168
- "periodicTable",
169
- "chemistryReference",
170
- "elementReference",
171
- ],
166
+ universalSupportIds: ["periodicTable"],
167
+ },
168
+ {
169
+ registration: dictionaryToolRegistration,
170
+ tagName: "pie-tool-dictionary",
171
+ loadModule: loadDictionaryModule,
172
+ loaderTargets: ["section"],
173
+ placementOrder: { item: 60, element: 100 },
174
+ preferredPlacementOrder: { section: 70 },
175
+ toolbarOrder: 120,
176
+ // Deliberately empty: a dictionary is a granted accommodation, and on a
177
+ // vocabulary item it is construct-relevant, so it is never universal.
178
+ universalSupportIds: [],
179
+ },
180
+ {
181
+ registration: pictureDictionaryToolRegistration,
182
+ tagName: "pie-tool-picture-dictionary",
183
+ loadModule: loadPictureDictionaryModule,
184
+ loaderTargets: ["section"],
185
+ placementOrder: { item: 70, element: 110 },
186
+ preferredPlacementOrder: { section: 80 },
187
+ toolbarOrder: 130,
188
+ universalSupportIds: [],
189
+ },
190
+ // The Spanish variants render the same elements under their own capability ids, so a
191
+ // programme can grant a Spanish gloss beside the content-following dictionary or
192
+ // instead of it. Ordered after both, since English-content delivery is the common case.
193
+ {
194
+ registration: spanishDictionaryToolRegistration,
195
+ tagName: "pie-tool-dictionary",
196
+ loadModule: loadDictionaryModule,
197
+ loaderTargets: ["section"],
198
+ placementOrder: { item: 80, element: 120 },
199
+ preferredPlacementOrder: { section: 90 },
200
+ toolbarOrder: 140,
201
+ universalSupportIds: [],
202
+ },
203
+ {
204
+ registration: spanishPictureDictionaryToolRegistration,
205
+ tagName: "pie-tool-picture-dictionary",
206
+ loadModule: loadPictureDictionaryModule,
207
+ loaderTargets: ["section"],
208
+ placementOrder: { item: 90, element: 130 },
209
+ preferredPlacementOrder: { section: 100 },
210
+ toolbarOrder: 150,
211
+ universalSupportIds: [],
172
212
  },
173
213
  {
174
214
  registration: audioTranscriptRegistration,
@@ -358,10 +398,27 @@ class PackagedCapabilityComposition {
358
398
  // their bundle/runtime behavior.
359
399
  if (options.toolModuleLoaders &&
360
400
  Object.keys(options.toolModuleLoaders).length > 0) {
361
- registry.setToolModuleLoaders(options.toolModuleLoaders);
401
+ const toolModuleLoaders = { ...options.toolModuleLoaders };
402
+ const calculatorDelivery = resolveCalculatorDelivery(options.calculatorProviderConfig);
403
+ // A host using the packaged default map gets a coherent provider-specific
404
+ // loader. A genuinely custom calculator loader remains the host's override.
405
+ if (options.calculatorProviderConfig &&
406
+ toolModuleLoaders.calculator === this.defaultModuleLoaders.calculator) {
407
+ toolModuleLoaders.calculator = calculatorDelivery.loadModule;
408
+ }
409
+ registry.setToolModuleLoaders(toolModuleLoaders);
362
410
  }
411
+ const calculatorTagMap = options.calculatorProviderConfig
412
+ ? {
413
+ calculator: resolveCalculatorDelivery(options.calculatorProviderConfig).tagName,
414
+ }
415
+ : {};
363
416
  registry.setComponentOverrides({
364
- toolTagMap: { ...this.toolTagMap, ...(options.toolTagMap ?? {}) },
417
+ toolTagMap: {
418
+ ...this.toolTagMap,
419
+ ...calculatorTagMap,
420
+ ...(options.toolTagMap ?? {}),
421
+ },
365
422
  toolComponentFactory: options.toolComponentFactory,
366
423
  toolComponentFactories: options.toolComponentFactories,
367
424
  });
@@ -402,6 +459,22 @@ export const SECTION_TOOL_MODULE_LOADERS = {
402
459
  export const DEFAULT_TOOL_MODULE_LOADERS = {
403
460
  ...packagedCapabilityComposition.defaultModuleLoaders,
404
461
  };
462
+ /** Build the packaged loader map for a selected calculator provider. */
463
+ export function createDefaultToolModuleLoaders(options = {}) {
464
+ return {
465
+ ...DEFAULT_TOOL_MODULE_LOADERS,
466
+ calculator: resolveCalculatorDelivery(options.calculatorProviderConfig)
467
+ .loadModule,
468
+ };
469
+ }
470
+ /** Build the section-bootstrap loader subset for a selected calculator provider. */
471
+ export function createSectionToolModuleLoaders(options = {}) {
472
+ return {
473
+ ...SECTION_TOOL_MODULE_LOADERS,
474
+ calculator: resolveCalculatorDelivery(options.calculatorProviderConfig)
475
+ .loadModule,
476
+ };
477
+ }
405
478
  export const PACKAGED_TOOL_PLACEMENT = {
406
479
  assessment: [...packagedCapabilityComposition.placement.assessment],
407
480
  section: [...packagedCapabilityComposition.placement.section],
@@ -434,14 +507,14 @@ export function createUniversalPersonalNeedsProfile() {
434
507
  /** Register packaged lazy module loaders, followed by host overrides. */
435
508
  export function registerDefaultToolModuleLoaders(registry, options = {}) {
436
509
  registry.setToolModuleLoaders({
437
- ...DEFAULT_TOOL_MODULE_LOADERS,
510
+ ...createDefaultToolModuleLoaders(options),
438
511
  ...(options.loaders ?? {}),
439
512
  });
440
513
  }
441
514
  /** Register only the section-bootstrap loader subset, then host overrides. */
442
515
  export function registerSectionToolModuleLoaders(registry, options = {}) {
443
516
  registry.setToolModuleLoaders({
444
- ...SECTION_TOOL_MODULE_LOADERS,
517
+ ...createSectionToolModuleLoaders(options),
445
518
  ...(options.loaders ?? {}),
446
519
  });
447
520
  }