@pie-players/pie-default-tool-loaders 0.3.65 → 0.3.67

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
@@ -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 four things, all answers to "which capabilities does this deployment have
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
- ## Accommodations are not in the packaged set
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 declaring `requiresAuthoredContent` is absent from
60
- `PACKAGED_TOOL_REGISTRATIONS` and its support ids from
61
- `UNIVERSAL_SUPPORTS_PRESET`. Signing is the shipped example: install
62
- `@pie-players/pie-tool-sign-language` and register it, which is the same two lines
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
-
@@ -0,0 +1,20 @@
1
+ /**
2
+ * The packaged capabilities that carry an authored alternate and render it as a
3
+ * region.
4
+ *
5
+ * A projection of the composition set below, kept in its own module for one
6
+ * reason: it must be importable without reaching the packaged composition table,
7
+ * whose lazy loaders name concrete `pie-tool-*` packages. A renderer that only
8
+ * ever shows text alternates — print — would otherwise carry a calculator and a
9
+ * TTS bundle it can never activate.
10
+ *
11
+ * Which slot an alternate fills is still the renderer's decision, not this list's:
12
+ * every entry declares its own `surfaces`, and a host resolves the slots it
13
+ * actually opens. Print opens the in-flow one and not the docked-media one,
14
+ * because a signed alternate on paper is a blank rectangle.
15
+ *
16
+ * `tests/content-alternates.test.ts` pins this against the composition set in both
17
+ * directions, so a capability added there cannot quietly fail to reach print.
18
+ */
19
+ import type { ToolRegistration } from "@pie-players/pie-assessment-toolkit/tools/internal";
20
+ export declare const CONTENT_ALTERNATE_REGISTRATIONS: readonly ToolRegistration[];
@@ -0,0 +1,22 @@
1
+ /**
2
+ * The packaged capabilities that carry an authored alternate and render it as a
3
+ * region.
4
+ *
5
+ * A projection of the composition set below, kept in its own module for one
6
+ * reason: it must be importable without reaching the packaged composition table,
7
+ * whose lazy loaders name concrete `pie-tool-*` packages. A renderer that only
8
+ * ever shows text alternates — print — would otherwise carry a calculator and a
9
+ * TTS bundle it can never activate.
10
+ *
11
+ * Which slot an alternate fills is still the renderer's decision, not this list's:
12
+ * every entry declares its own `surfaces`, and a host resolves the slots it
13
+ * actually opens. Print opens the in-flow one and not the docked-media one,
14
+ * because a signed alternate on paper is a blank rectangle.
15
+ *
16
+ * `tests/content-alternates.test.ts` pins this against the composition set in both
17
+ * directions, so a capability added there cannot quietly fail to reach print.
18
+ */
19
+ import { audioTranscriptRegistration } from "./registrations/audio-transcript.js";
20
+ export const CONTENT_ALTERNATE_REGISTRATIONS = [
21
+ audioTranscriptRegistration,
22
+ ];
package/dist/index.d.ts CHANGED
@@ -1,27 +1,10 @@
1
- export { UNIVERSAL_SUPPORTS_PRESET, createUniversalPersonalNeedsProfile, } from "./universal-supports.js";
2
- export type { PackagedToolRegistryOptions, RegisterPackagedToolsOptions, } from "./packaged-tool-registry.js";
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";
3
+ export { CONTENT_ALTERNATE_REGISTRATIONS } from "./content-alternates.js";
6
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, type ResolvedAudioTranscript, } from "./registrations/audio-transcript.js";
7
6
  export { calculatorToolRegistration } from "./registrations/calculator.js";
8
7
  export { answerEliminatorToolRegistration, highlighterToolRegistration, } from "./registrations/interaction-tools.js";
9
8
  export { protractorToolRegistration, rulerToolRegistration, } from "./registrations/measurement-tools.js";
10
9
  export { graphToolRegistration, periodicTableToolRegistration, } from "./registrations/subject-specific-tools.js";
11
10
  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,13 @@
1
- export { UNIVERSAL_SUPPORTS_PRESET, createUniversalPersonalNeedsProfile, } from "./universal-supports.js";
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";
2
+ // The authored-alternate subset, for a renderer that shows alternates and no
3
+ // toolbar — importable without the packaged composition's tool loaders.
4
+ export { CONTENT_ALTERNATE_REGISTRATIONS } from "./content-alternates.js";
5
5
  // Individual registrations, for a host composing a subset rather than the whole
6
6
  // packaged set.
7
7
  export { annotationToolbarRegistration, lineReaderToolRegistration, themeToolRegistration, } from "./registrations/accessibility-tools.js";
8
+ export { AUDIO_TRANSCRIPT_FEATURE_ID, AUDIO_TRANSCRIPT_REGION_CLASS, AUDIO_TRANSCRIPT_REGION_LABEL, audioTranscriptRegistration, resolveAudioTranscript, } from "./registrations/audio-transcript.js";
8
9
  export { calculatorToolRegistration } from "./registrations/calculator.js";
9
10
  export { answerEliminatorToolRegistration, highlighterToolRegistration, } from "./registrations/interaction-tools.js";
10
11
  export { protractorToolRegistration, rulerToolRegistration, } from "./registrations/measurement-tools.js";
11
12
  export { graphToolRegistration, periodicTableToolRegistration, } from "./registrations/subject-specific-tools.js";
12
13
  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;