@pie-players/pie-default-tool-loaders 0.3.65 → 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 +29 -8
- package/dist/index.d.ts +3 -21
- package/dist/index.js +2 -49
- 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 -52
- package/dist/packaged-tool-registry.js +1 -96
- package/dist/registrations/audio-transcript.d.ts +75 -0
- package/dist/registrations/audio-transcript.js +183 -0
- package/dist/tool-placement.d.ts +1 -29
- package/dist/tool-placement.js +1 -52
- package/dist/tool-tag-map.d.ts +1 -16
- package/dist/tool-tag-map.js +1 -27
- package/dist/universal-supports.d.ts +1 -33
- package/dist/universal-supports.js +1 -77
- package/package.json +15 -14
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ dependency-light and cycle-safe, and it is the layer above core — core knows
|
|
|
8
8
|
`featureId`, placement levels, activation kinds and precedence rules, and knows
|
|
9
9
|
no capability ids.
|
|
10
10
|
|
|
11
|
-
It owns
|
|
11
|
+
It owns five things, all answers to "which capabilities does this deployment have
|
|
12
12
|
and how does the program tier them":
|
|
13
13
|
|
|
14
14
|
| Export | What it decides |
|
|
@@ -22,6 +22,22 @@ and how does the program tier them":
|
|
|
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.
|
|
24
24
|
|
|
25
|
+
These exports are projections of one internal **Packaged Capability
|
|
26
|
+
Composition**. Each packaged capability is authored once with its registration,
|
|
27
|
+
element delivery, loader bootstrap sets, placement/order membership and explicit
|
|
28
|
+
universal-support policy. The package build rejects contradictory PIE-owned data
|
|
29
|
+
— for example, a region capability with a toolbar tag, or a universal support
|
|
30
|
+
id its registration does not declare — so release tests find a missing facet
|
|
31
|
+
instead of a learner finding a dead affordance. The browser does not repeat that
|
|
32
|
+
strict gate at import time: a PIE authoring defect must block publication, not an
|
|
33
|
+
otherwise usable assessment.
|
|
34
|
+
|
|
35
|
+
That invariant boundary does not make host input stricter. The existing public
|
|
36
|
+
factory and constants are unchanged: lazy module loading remains opt-in,
|
|
37
|
+
registration/tag/factory overrides retain precedence, an empty `toolIds` array
|
|
38
|
+
still selects the full packaged set, and unknown selected ids are ignored while
|
|
39
|
+
known ids continue to register.
|
|
40
|
+
|
|
25
41
|
## Usage
|
|
26
42
|
|
|
27
43
|
```ts
|
|
@@ -54,13 +70,19 @@ const registry = createDefaultToolRegistry({
|
|
|
54
70
|
registerSectionToolModuleLoaders(registry);
|
|
55
71
|
```
|
|
56
72
|
|
|
57
|
-
##
|
|
73
|
+
## Content-dependent capabilities require an explicit packaging decision
|
|
74
|
+
|
|
75
|
+
A content-dependent capability is never inferred into
|
|
76
|
+
`UNIVERSAL_SUPPORTS_PRESET`. It may ship in `PACKAGED_TOOL_REGISTRATIONS` only
|
|
77
|
+
when it has a useful presentation path without a grant and declares
|
|
78
|
+
`resolvesWithoutGrant`. Audio transcript is the shipped example: an authored
|
|
79
|
+
`visibility: "always"` transcript reaches every player, while its accommodation
|
|
80
|
+
path remains policy-gated and `transcript` stays out of the universal preset.
|
|
58
81
|
|
|
59
|
-
A capability
|
|
60
|
-
|
|
61
|
-
`
|
|
62
|
-
|
|
63
|
-
a host writes for a capability of its own.
|
|
82
|
+
A content-dependent capability with no presentation path remains an explicit
|
|
83
|
+
deployment choice. Signing is the shipped example: install
|
|
84
|
+
`@pie-players/pie-tool-sign-language` and register it, which is the same two
|
|
85
|
+
lines a host writes for a capability of its own.
|
|
64
86
|
|
|
65
87
|
```ts
|
|
66
88
|
import { signLanguageRegistration } from "@pie-players/pie-tool-sign-language";
|
|
@@ -94,4 +116,3 @@ capability that declares a content dependency.
|
|
|
94
116
|
A section carrying no profile is left alone. `pnpEnforcement` auto-detection
|
|
95
117
|
engages on real host policy material, so supplying no profile means placement
|
|
96
118
|
alone decides which tools appear.
|
|
97
|
-
|
package/dist/index.d.ts
CHANGED
|
@@ -1,27 +1,9 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export
|
|
3
|
-
export { createPackagedToolRegistry, PACKAGED_TOOL_ORDER, PACKAGED_TOOL_REGISTRATIONS, registerPackagedTools, } from "./packaged-tool-registry.js";
|
|
4
|
-
export { PACKAGED_TOOL_TAG_MAP } from "./tool-tag-map.js";
|
|
5
|
-
export { PACKAGED_TOOL_PLACEMENT, SECTION_PLAYER_PREFERRED_TOOL_PLACEMENT, } from "./tool-placement.js";
|
|
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";
|
|
6
3
|
export { annotationToolbarRegistration, lineReaderToolRegistration, themeToolRegistration, } from "./registrations/accessibility-tools.js";
|
|
4
|
+
export { AUDIO_TRANSCRIPT_FEATURE_ID, AUDIO_TRANSCRIPT_REGION_CLASS, AUDIO_TRANSCRIPT_REGION_LABEL, audioTranscriptRegistration, resolveAudioTranscript, type ResolvedAudioTranscript, } from "./registrations/audio-transcript.js";
|
|
7
5
|
export { calculatorToolRegistration } from "./registrations/calculator.js";
|
|
8
6
|
export { answerEliminatorToolRegistration, highlighterToolRegistration, } from "./registrations/interaction-tools.js";
|
|
9
7
|
export { protractorToolRegistration, rulerToolRegistration, } from "./registrations/measurement-tools.js";
|
|
10
8
|
export { graphToolRegistration, periodicTableToolRegistration, } from "./registrations/subject-specific-tools.js";
|
|
11
9
|
export { ttsToolRegistration } from "./registrations/tts.js";
|
|
12
|
-
export type ToolModuleLoader = () => Promise<unknown>;
|
|
13
|
-
export interface ToolRegistryLike {
|
|
14
|
-
setToolModuleLoaders(loaders: Partial<Record<string, ToolModuleLoader>>): void;
|
|
15
|
-
}
|
|
16
|
-
export declare const SECTION_TOOL_MODULE_LOADERS: Record<string, ToolModuleLoader>;
|
|
17
|
-
export declare const ITEM_TOOL_MODULE_LOADERS: Record<string, ToolModuleLoader>;
|
|
18
|
-
export declare const DEFAULT_TOOL_MODULE_LOADERS: Record<string, ToolModuleLoader>;
|
|
19
|
-
export type RegisterDefaultToolModuleLoadersOptions = {
|
|
20
|
-
loaders?: Partial<Record<string, ToolModuleLoader>>;
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* Register built-in lazy module loaders on a registry.
|
|
24
|
-
* Hosts can override or extend the defaults via options.loaders.
|
|
25
|
-
*/
|
|
26
|
-
export declare function registerDefaultToolModuleLoaders(registry: ToolRegistryLike, options?: RegisterDefaultToolModuleLoadersOptions): void;
|
|
27
|
-
export declare function registerSectionToolModuleLoaders(registry: ToolRegistryLike, options?: RegisterDefaultToolModuleLoadersOptions): void;
|
package/dist/index.js
CHANGED
|
@@ -1,57 +1,10 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { createPackagedToolRegistry, PACKAGED_TOOL_ORDER, PACKAGED_TOOL_REGISTRATIONS, registerPackagedTools, } from "./packaged-tool-registry.js";
|
|
3
|
-
export { PACKAGED_TOOL_TAG_MAP } from "./tool-tag-map.js";
|
|
4
|
-
export { PACKAGED_TOOL_PLACEMENT, SECTION_PLAYER_PREFERRED_TOOL_PLACEMENT, } from "./tool-placement.js";
|
|
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";
|
|
5
2
|
// Individual registrations, for a host composing a subset rather than the whole
|
|
6
3
|
// packaged set.
|
|
7
4
|
export { annotationToolbarRegistration, lineReaderToolRegistration, themeToolRegistration, } from "./registrations/accessibility-tools.js";
|
|
5
|
+
export { AUDIO_TRANSCRIPT_FEATURE_ID, AUDIO_TRANSCRIPT_REGION_CLASS, AUDIO_TRANSCRIPT_REGION_LABEL, audioTranscriptRegistration, resolveAudioTranscript, } from "./registrations/audio-transcript.js";
|
|
8
6
|
export { calculatorToolRegistration } from "./registrations/calculator.js";
|
|
9
7
|
export { answerEliminatorToolRegistration, highlighterToolRegistration, } from "./registrations/interaction-tools.js";
|
|
10
8
|
export { protractorToolRegistration, rulerToolRegistration, } from "./registrations/measurement-tools.js";
|
|
11
9
|
export { graphToolRegistration, periodicTableToolRegistration, } from "./registrations/subject-specific-tools.js";
|
|
12
10
|
export { ttsToolRegistration } from "./registrations/tts.js";
|
|
13
|
-
const loadSideEffectModule = (load) => load().then(() => undefined);
|
|
14
|
-
function loadCalculatorModule() {
|
|
15
|
-
if (typeof globalThis !== "undefined" &&
|
|
16
|
-
"customElements" in globalThis &&
|
|
17
|
-
globalThis.customElements?.get("pie-tool-calculator")) {
|
|
18
|
-
return Promise.resolve();
|
|
19
|
-
}
|
|
20
|
-
return loadSideEffectModule(() => import("@pie-players/pie-tool-calculator-desmos"));
|
|
21
|
-
}
|
|
22
|
-
export const SECTION_TOOL_MODULE_LOADERS = {
|
|
23
|
-
calculator: loadCalculatorModule,
|
|
24
|
-
graph: () => loadSideEffectModule(() => import("@pie-players/pie-tool-graph")),
|
|
25
|
-
periodicTable: () => loadSideEffectModule(() => import("@pie-players/pie-tool-periodic-table")),
|
|
26
|
-
ruler: () => loadSideEffectModule(() => import("@pie-players/pie-tool-ruler")),
|
|
27
|
-
protractor: () => loadSideEffectModule(() => import("@pie-players/pie-tool-protractor")),
|
|
28
|
-
lineReader: () => loadSideEffectModule(() => import("@pie-players/pie-tool-line-reader")),
|
|
29
|
-
};
|
|
30
|
-
export const ITEM_TOOL_MODULE_LOADERS = {
|
|
31
|
-
calculator: loadCalculatorModule,
|
|
32
|
-
textToSpeech: () => loadSideEffectModule(() => import("@pie-players/pie-tool-tts-inline")),
|
|
33
|
-
answerEliminator: () => loadSideEffectModule(() => import("@pie-players/pie-tool-answer-eliminator")),
|
|
34
|
-
highlighter: () => loadSideEffectModule(() => import("@pie-players/pie-tool-annotation-toolbar")),
|
|
35
|
-
annotationToolbar: () => loadSideEffectModule(() => import("@pie-players/pie-tool-annotation-toolbar")),
|
|
36
|
-
theme: () => loadSideEffectModule(() => import("@pie-players/pie-tool-theme")),
|
|
37
|
-
};
|
|
38
|
-
export const DEFAULT_TOOL_MODULE_LOADERS = {
|
|
39
|
-
...ITEM_TOOL_MODULE_LOADERS,
|
|
40
|
-
...SECTION_TOOL_MODULE_LOADERS,
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* Register built-in lazy module loaders on a registry.
|
|
44
|
-
* Hosts can override or extend the defaults via options.loaders.
|
|
45
|
-
*/
|
|
46
|
-
export function registerDefaultToolModuleLoaders(registry, options = {}) {
|
|
47
|
-
registry.setToolModuleLoaders({
|
|
48
|
-
...DEFAULT_TOOL_MODULE_LOADERS,
|
|
49
|
-
...(options.loaders || {}),
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
export function registerSectionToolModuleLoaders(registry, options = {}) {
|
|
53
|
-
registry.setToolModuleLoaders({
|
|
54
|
-
...SECTION_TOOL_MODULE_LOADERS,
|
|
55
|
-
...(options.loaders || {}),
|
|
56
|
-
});
|
|
57
|
-
}
|
|
@@ -0,0 +1,73 @@
|
|
|
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, type ToolComponentFactory, type ToolComponentFactoryMap, type ToolRegistration, type ToolTagMap } from "@pie-players/pie-assessment-toolkit/tools/internal";
|
|
11
|
+
import type { PersonalNeedsProfile } from "@pie-players/pie-players-shared/types";
|
|
12
|
+
export type ToolModuleLoader = () => Promise<unknown>;
|
|
13
|
+
export interface ToolRegistryLike {
|
|
14
|
+
setToolModuleLoaders(loaders: Partial<Record<string, ToolModuleLoader>>): void;
|
|
15
|
+
}
|
|
16
|
+
export interface PackagedToolRegistryOptions {
|
|
17
|
+
/** Override packaged registrations by toolId. */
|
|
18
|
+
overrides?: Partial<Record<string, ToolRegistration>>;
|
|
19
|
+
/** Override or extend the packaged element tag mapping. */
|
|
20
|
+
toolTagMap?: Partial<ToolTagMap>;
|
|
21
|
+
/** Override the component factory globally or per tool. */
|
|
22
|
+
toolComponentFactory?: ToolComponentFactory;
|
|
23
|
+
toolComponentFactories?: Partial<ToolComponentFactoryMap>;
|
|
24
|
+
/** Lazy module loaders keyed by toolId. */
|
|
25
|
+
toolModuleLoaders?: Partial<Record<string, ToolModuleLoader>>;
|
|
26
|
+
/** Restrict registration to specific packaged tool ids. */
|
|
27
|
+
toolIds?: string[];
|
|
28
|
+
}
|
|
29
|
+
export interface RegisterPackagedToolsOptions {
|
|
30
|
+
toolIds?: string[];
|
|
31
|
+
applyOverrides?: (registration: ToolRegistration) => ToolRegistration;
|
|
32
|
+
}
|
|
33
|
+
export type RegisterDefaultToolModuleLoadersOptions = {
|
|
34
|
+
loaders?: Partial<Record<string, ToolModuleLoader>>;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Release/build gate for PIE-authored composition data.
|
|
38
|
+
*
|
|
39
|
+
* Deliberately not called by the browser runtime: an invariant regression must
|
|
40
|
+
* stop the package before publication, not turn into an import-time exception
|
|
41
|
+
* that prevents an otherwise usable assessment from rendering.
|
|
42
|
+
*/
|
|
43
|
+
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];
|
|
45
|
+
export declare const PACKAGED_TOOL_TAG_MAP: ToolTagMap;
|
|
46
|
+
export declare const ITEM_TOOL_MODULE_LOADERS: Record<string, ToolModuleLoader>;
|
|
47
|
+
export declare const SECTION_TOOL_MODULE_LOADERS: Record<string, ToolModuleLoader>;
|
|
48
|
+
export declare const DEFAULT_TOOL_MODULE_LOADERS: Record<string, ToolModuleLoader>;
|
|
49
|
+
export declare const PACKAGED_TOOL_PLACEMENT: {
|
|
50
|
+
readonly assessment: readonly ["theme"];
|
|
51
|
+
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"];
|
|
56
|
+
};
|
|
57
|
+
export declare const SECTION_PLAYER_PREFERRED_TOOL_PLACEMENT: {
|
|
58
|
+
section: string[];
|
|
59
|
+
item: string[];
|
|
60
|
+
passage: string[];
|
|
61
|
+
};
|
|
62
|
+
export declare const PACKAGED_TOOL_ORDER: readonly ["theme", "calculator", "textToSpeech", "lineReader", "annotationToolbar", "highlighter", "answerEliminator", "ruler", "protractor", "graph", "periodicTable"];
|
|
63
|
+
export declare const UNIVERSAL_SUPPORTS_PRESET: readonly string[];
|
|
64
|
+
/** Register packaged PIE capabilities onto an existing registry. */
|
|
65
|
+
export declare function registerPackagedTools(registry: ToolRegistry, options?: RegisterPackagedToolsOptions): void;
|
|
66
|
+
/** Create a registry holding the packaged PIE capabilities. */
|
|
67
|
+
export declare function createPackagedToolRegistry(options?: PackagedToolRegistryOptions): ToolRegistry;
|
|
68
|
+
/** Build a fresh profile granting the explicit universal-support preset. */
|
|
69
|
+
export declare function createUniversalPersonalNeedsProfile(): PersonalNeedsProfile;
|
|
70
|
+
/** Register packaged lazy module loaders, followed by host overrides. */
|
|
71
|
+
export declare function registerDefaultToolModuleLoaders(registry: ToolRegistryLike, options?: RegisterDefaultToolModuleLoadersOptions): void;
|
|
72
|
+
/** Register only the section-bootstrap loader subset, then host overrides. */
|
|
73
|
+
export declare function registerSectionToolModuleLoaders(registry: ToolRegistryLike, options?: RegisterDefaultToolModuleLoadersOptions): void;
|