@pie-players/pie-default-tool-loaders 0.3.73 → 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 +56 -58
- package/dist/calculator-providers/CortexToolProvider.d.ts +12 -0
- package/dist/calculator-providers/CortexToolProvider.js +31 -0
- package/dist/calculator-providers/DesmosToolProvider.d.ts +13 -0
- package/dist/calculator-providers/DesmosToolProvider.js +31 -0
- package/dist/calculator-providers/GeoGebraToolProvider.d.ts +15 -0
- package/dist/calculator-providers/GeoGebraToolProvider.js +31 -0
- package/dist/calculator-providers/LazyCalculatorToolProvider.d.ts +34 -0
- package/dist/calculator-providers/LazyCalculatorToolProvider.js +95 -0
- 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 +61 -262
- package/dist/registrations/accessibility-tools.d.ts +1 -5
- package/dist/registrations/accessibility-tools.js +6 -41
- 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 +18 -73
- package/dist/registrations/dictionary-tools.d.ts +6 -5
- package/dist/registrations/dictionary-tools.js +23 -27
- package/dist/registrations/interaction-tools.d.ts +1 -7
- package/dist/registrations/interaction-tools.js +24 -28
- package/dist/registrations/measurement-tools.d.ts +1 -5
- package/dist/registrations/measurement-tools.js +1 -19
- package/dist/registrations/overlay-element-cache.d.ts +23 -0
- package/dist/registrations/overlay-element-cache.js +48 -0
- package/dist/registrations/overlay-toolbar-render.d.ts +3 -10
- package/dist/registrations/overlay-toolbar-render.js +5 -8
- 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 +3 -8
- package/dist/registrations/subject-specific-tools.js +10 -26
- package/dist/registrations/tts.d.ts +1 -6
- package/dist/registrations/tts.js +41 -90
- package/package.json +24 -21
- package/dist/packaged-tool-registry.d.ts +0 -2
- package/dist/packaged-tool-registry.js +0 -1
- package/dist/tool-placement.d.ts +0 -1
- package/dist/tool-placement.js +0 -1
- package/dist/tool-tag-map.d.ts +0 -1
- package/dist/tool-tag-map.js +0 -1
- package/dist/universal-supports.d.ts +0 -1
- package/dist/universal-supports.js +0 -1
package/README.md
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
Composition layer for the packaged PIE assessment tools: which capabilities exist
|
|
4
4
|
in a deployment, and how a program tiers them.
|
|
5
5
|
|
|
6
|
-
It owns the concrete `pie-tool-*` dependencies
|
|
6
|
+
It owns the concrete `pie-tool-*` dependencies and the calculator engines
|
|
7
|
+
(`pie-calculator-cortex`, `-desmos` and `-geogebra`) so toolkit core can stay
|
|
7
8
|
dependency-light and cycle-safe, and it is the layer above core — core knows
|
|
8
9
|
`featureId`, placement levels, activation kinds and precedence rules, and knows
|
|
9
10
|
no capability ids.
|
|
@@ -13,30 +14,29 @@ and how does the program tier them":
|
|
|
13
14
|
|
|
14
15
|
| Export | What it decides |
|
|
15
16
|
| --- | --- |
|
|
16
|
-
| `PACKAGED_TOOL_REGISTRATIONS`, `createPackagedToolRegistry
|
|
17
|
+
| `PACKAGED_TOOL_REGISTRATIONS`, `createPackagedToolRegistry` | Which capabilities exist, and their toolbar and surface contracts |
|
|
17
18
|
| `PACKAGED_TOOL_TAG_MAP` | Which custom element each one renders as |
|
|
18
|
-
| `
|
|
19
|
-
| `
|
|
20
|
-
| `DEFAULT_TOOL_MODULE_LOADERS
|
|
19
|
+
| `SECTION_PLAYER_PREFERRED_TOOL_PLACEMENT` | Where they appear and in what order |
|
|
20
|
+
| `createUniversalPersonalNeedsProfile`, `createEmptyPersonalNeedsProfile` | Which of them the program grants to everyone, or to no one |
|
|
21
|
+
| `DEFAULT_TOOL_MODULE_LOADERS` | When each one's bundle loads |
|
|
21
22
|
|
|
22
23
|
The individual registrations are exported too, so a host can compose its own set
|
|
23
24
|
rather than take the packaged one whole.
|
|
24
25
|
|
|
25
26
|
These exports are projections of one internal **Packaged Capability
|
|
26
27
|
Composition**. Each packaged capability is authored once with its registration,
|
|
27
|
-
element delivery, loader
|
|
28
|
+
element delivery, module loader, preferred placement and explicit
|
|
28
29
|
universal-support policy. The package build rejects contradictory PIE-owned data
|
|
29
|
-
— for example, a region capability with a toolbar tag, or a
|
|
30
|
-
|
|
30
|
+
— for example, a region capability with a toolbar tag, or a content-dependent
|
|
31
|
+
capability marked universal — so release tests find a missing facet
|
|
31
32
|
instead of a learner finding a dead affordance. The browser does not repeat that
|
|
32
33
|
strict gate at import time: a PIE authoring defect must block publication, not an
|
|
33
34
|
otherwise usable assessment.
|
|
34
35
|
|
|
35
|
-
That invariant boundary does not make host input stricter
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
known ids continue to register.
|
|
36
|
+
That invariant boundary does not make host input stricter: lazy module loading
|
|
37
|
+
is opt-in, registration/tag/factory overrides take precedence, an empty
|
|
38
|
+
`toolIds` array selects the full packaged set, and unknown selected ids are
|
|
39
|
+
ignored while known ids register.
|
|
40
40
|
|
|
41
41
|
## Usage
|
|
42
42
|
|
|
@@ -52,35 +52,27 @@ const registry = createPackagedToolRegistry({
|
|
|
52
52
|
});
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
module loader; hosts do not hand-maintain a second vendor map.
|
|
55
|
+
One loader set serves every host shape. `DEFAULT_TOOL_MODULE_LOADERS` holds a
|
|
56
|
+
loader per packaged capability, and a registry loads a module only when a tool
|
|
57
|
+
first renders, so an item player, a section player and an assessment player
|
|
58
|
+
pass the same set and load only the tools they place.
|
|
60
59
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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
|
-
});
|
|
60
|
+
The calculator is one element, `<pie-tool-calculator>`, for every provider.
|
|
61
|
+
Desmos is the provider when none is configured; the toolkit picks another from
|
|
62
|
+
`tools.providers.calculator` when the element mounts, and an open calculator
|
|
63
|
+
remounts on the new provider when a tool-config update replaces it.
|
|
81
64
|
|
|
65
|
+
```ts
|
|
82
66
|
const tools = {
|
|
83
|
-
providers: {
|
|
67
|
+
providers: {
|
|
68
|
+
calculator: {
|
|
69
|
+
provider: {
|
|
70
|
+
id: "calculator-geogebra",
|
|
71
|
+
init: { appletTimeoutMs: 20_000 },
|
|
72
|
+
},
|
|
73
|
+
settings: { showResetIcon: true },
|
|
74
|
+
},
|
|
75
|
+
},
|
|
84
76
|
};
|
|
85
77
|
```
|
|
86
78
|
|
|
@@ -89,32 +81,38 @@ For an offline-capable calculator with no API key or runtime CDN, use
|
|
|
89
81
|
history, evaluation limit, allowed functions, clipboard policy, and graph
|
|
90
82
|
viewport options documented by `@pie-players/pie-calculator-cortex`.
|
|
91
83
|
|
|
92
|
-
|
|
93
|
-
|
|
84
|
+
A host composing its own set starts from the toolkit's empty `ToolRegistry`,
|
|
85
|
+
registers into it, and installs the tag map its registrations create elements
|
|
86
|
+
from.
|
|
94
87
|
|
|
95
88
|
```ts
|
|
96
|
-
import {
|
|
89
|
+
import { ToolRegistry } from "@pie-players/pie-assessment-toolkit";
|
|
97
90
|
import {
|
|
98
91
|
calculatorToolRegistration,
|
|
99
|
-
|
|
92
|
+
DEFAULT_TOOL_MODULE_LOADERS,
|
|
93
|
+
PACKAGED_TOOL_TAG_MAP,
|
|
100
94
|
ttsToolRegistration,
|
|
101
95
|
} from "@pie-players/pie-default-tool-loaders";
|
|
102
96
|
|
|
103
|
-
const registry =
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
97
|
+
const registry = new ToolRegistry();
|
|
98
|
+
registry.register(calculatorToolRegistration);
|
|
99
|
+
registry.register(ttsToolRegistration);
|
|
100
|
+
registry.setComponentOverrides({ toolTagMap: PACKAGED_TOOL_TAG_MAP });
|
|
101
|
+
registry.setToolModuleLoaders(DEFAULT_TOOL_MODULE_LOADERS);
|
|
108
102
|
```
|
|
109
103
|
|
|
104
|
+
A later `setToolModuleLoaders` call adds or replaces entries. A replacement
|
|
105
|
+
registered after a tool's module has loaded is ignored with a warning, since the
|
|
106
|
+
elements it defines are already in place.
|
|
107
|
+
|
|
110
108
|
## Content-dependent capabilities require an explicit packaging decision
|
|
111
109
|
|
|
112
|
-
A content-dependent capability is never
|
|
113
|
-
`
|
|
110
|
+
A content-dependent capability is never granted by
|
|
111
|
+
`createUniversalPersonalNeedsProfile()`. It may ship in `PACKAGED_TOOL_REGISTRATIONS` only
|
|
114
112
|
when it has a useful presentation path without a grant and declares
|
|
115
113
|
`resolvesWithoutGrant`. Audio transcript is the shipped example: an authored
|
|
116
114
|
`visibility: "always"` transcript reaches every player, while its accommodation
|
|
117
|
-
path remains policy-gated and `transcript` stays out of the universal
|
|
115
|
+
path remains policy-gated and `transcript` stays out of the universal profile.
|
|
118
116
|
|
|
119
117
|
A content-dependent capability with no presentation path remains an explicit
|
|
120
118
|
deployment choice. Signing is the shipped example: install
|
|
@@ -127,11 +125,11 @@ import { signLanguageRegistration } from "@pie-players/pie-tool-sign-language";
|
|
|
127
125
|
registry.register(signLanguageRegistration);
|
|
128
126
|
```
|
|
129
127
|
|
|
130
|
-
## Universal
|
|
128
|
+
## Universal and empty profiles
|
|
131
129
|
|
|
132
|
-
`createUniversalPersonalNeedsProfile()` builds a `PersonalNeedsProfile`
|
|
133
|
-
|
|
134
|
-
|
|
130
|
+
`createUniversalPersonalNeedsProfile()` builds a fresh `PersonalNeedsProfile`
|
|
131
|
+
granting the tool ids of the capabilities the packaged set treats as universal
|
|
132
|
+
features. A support id is the tool id it grants.
|
|
135
133
|
|
|
136
134
|
```ts
|
|
137
135
|
import { createUniversalPersonalNeedsProfile } from "@pie-players/pie-default-tool-loaders";
|
|
@@ -142,11 +140,11 @@ const section = {
|
|
|
142
140
|
};
|
|
143
141
|
```
|
|
144
142
|
|
|
145
|
-
The
|
|
146
|
-
|
|
143
|
+
The toolkit ships no populated default, and `createEmptyPersonalNeedsProfile()`
|
|
144
|
+
builds a profile granting nothing. Which capabilities a
|
|
147
145
|
deployment grants by default is a property of the program, not of a capability:
|
|
148
146
|
TTS is a universal feature in one program and a documented accommodation in
|
|
149
|
-
another. So the
|
|
147
|
+
another. So the universal profile is data to adopt, extend or replace alongside the district
|
|
150
148
|
and test-administration configuration, and it deliberately excludes any
|
|
151
149
|
capability that declares a content dependency.
|
|
152
150
|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Fully bundled open-source calculator adapter for the tool-provider registry. */
|
|
2
|
+
import type { CalculatorToolProviderInitConfig, LazyCalculatorProviderDefinition } from "./LazyCalculatorToolProvider.js";
|
|
3
|
+
import { LazyCalculatorToolProvider } from "./LazyCalculatorToolProvider.js";
|
|
4
|
+
import type { ToolProviderCapabilities } from "@pie-players/pie-assessment-toolkit/tools/registration";
|
|
5
|
+
export type CortexToolProviderConfig = CalculatorToolProviderInitConfig;
|
|
6
|
+
export declare class CortexToolProvider extends LazyCalculatorToolProvider<CortexToolProviderConfig> {
|
|
7
|
+
readonly providerName = "PIE Open-Source Calculator";
|
|
8
|
+
readonly version = "1";
|
|
9
|
+
readonly requiresAuth = false;
|
|
10
|
+
protected getDefinition(): LazyCalculatorProviderDefinition<CortexToolProviderConfig>;
|
|
11
|
+
getCapabilities(): ToolProviderCapabilities;
|
|
12
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** Fully bundled open-source calculator adapter for the tool-provider registry. */
|
|
2
|
+
import { LazyCalculatorToolProvider } from "./LazyCalculatorToolProvider.js";
|
|
3
|
+
export class CortexToolProvider extends LazyCalculatorToolProvider {
|
|
4
|
+
providerName = "PIE Open-Source Calculator";
|
|
5
|
+
version = "1";
|
|
6
|
+
requiresAuth = false;
|
|
7
|
+
getDefinition() {
|
|
8
|
+
return {
|
|
9
|
+
backend: "cortex",
|
|
10
|
+
moduleImportOperation: "cortex-provider-module-import",
|
|
11
|
+
loadProvider: async () => {
|
|
12
|
+
const module = await import("@pie-players/pie-calculator-cortex");
|
|
13
|
+
return module.CortexCalculatorProvider;
|
|
14
|
+
},
|
|
15
|
+
initializationErrorMessage: "Failed to initialize the PIE open-source calculator provider. Confirm that this browser supports module workers and that the bundled worker assets are available.",
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
getCapabilities() {
|
|
19
|
+
return {
|
|
20
|
+
supportsOffline: true,
|
|
21
|
+
requiresAuth: false,
|
|
22
|
+
maxInstances: null,
|
|
23
|
+
features: {
|
|
24
|
+
basic: true,
|
|
25
|
+
scientific: true,
|
|
26
|
+
graphing: true,
|
|
27
|
+
fourFunction: true,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Desmos calculator adapter for the generic tool-provider registry. */
|
|
2
|
+
import type { CalculatorProviderInit } from "@pie-players/pie-calculator";
|
|
3
|
+
import { LazyCalculatorToolProvider, type LazyCalculatorProviderDefinition } from "./LazyCalculatorToolProvider.js";
|
|
4
|
+
import type { ToolProviderCapabilities } from "@pie-players/pie-assessment-toolkit/tools/registration";
|
|
5
|
+
/** Provider initialization is the provider-neutral calculator contract. */
|
|
6
|
+
export type DesmosToolProviderConfig = CalculatorProviderInit;
|
|
7
|
+
export declare class DesmosToolProvider extends LazyCalculatorToolProvider<DesmosToolProviderConfig> {
|
|
8
|
+
readonly providerName = "Desmos Calculator";
|
|
9
|
+
readonly version = "1.12";
|
|
10
|
+
readonly requiresAuth = true;
|
|
11
|
+
protected getDefinition(): LazyCalculatorProviderDefinition<DesmosToolProviderConfig>;
|
|
12
|
+
getCapabilities(): ToolProviderCapabilities;
|
|
13
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** Desmos calculator adapter for the generic tool-provider registry. */
|
|
2
|
+
import { LazyCalculatorToolProvider, } from "./LazyCalculatorToolProvider.js";
|
|
3
|
+
export class DesmosToolProvider extends LazyCalculatorToolProvider {
|
|
4
|
+
providerName = "Desmos Calculator";
|
|
5
|
+
version = "1.12";
|
|
6
|
+
requiresAuth = true;
|
|
7
|
+
getDefinition() {
|
|
8
|
+
return {
|
|
9
|
+
backend: "desmos",
|
|
10
|
+
moduleImportOperation: "desmos-provider-module-import",
|
|
11
|
+
loadProvider: async () => {
|
|
12
|
+
const module = await import("@pie-players/pie-calculator-desmos");
|
|
13
|
+
return module.DesmosCalculatorProvider;
|
|
14
|
+
},
|
|
15
|
+
initializationErrorMessage: "Failed to initialize Desmos calculator provider. Check the application key, preloaded API, runtime endpoint, or network access.",
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
getCapabilities() {
|
|
19
|
+
return {
|
|
20
|
+
supportsOffline: false,
|
|
21
|
+
requiresAuth: true,
|
|
22
|
+
maxInstances: null,
|
|
23
|
+
features: {
|
|
24
|
+
basic: true,
|
|
25
|
+
scientific: true,
|
|
26
|
+
graphing: true,
|
|
27
|
+
fourFunction: true,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** GeoGebra calculator adapter for the generic tool-provider registry. */
|
|
2
|
+
import type { CalculatorToolProviderInitConfig, LazyCalculatorProviderDefinition } from "./LazyCalculatorToolProvider.js";
|
|
3
|
+
import { LazyCalculatorToolProvider } from "./LazyCalculatorToolProvider.js";
|
|
4
|
+
import type { ToolProviderCapabilities } from "@pie-players/pie-assessment-toolkit/tools/registration";
|
|
5
|
+
export interface GeoGebraToolProviderConfig extends CalculatorToolProviderInitConfig {
|
|
6
|
+
scriptUrl?: string;
|
|
7
|
+
appletTimeoutMs?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare class GeoGebraToolProvider extends LazyCalculatorToolProvider<GeoGebraToolProviderConfig> {
|
|
10
|
+
readonly providerName = "GeoGebra Calculator";
|
|
11
|
+
readonly version = "6";
|
|
12
|
+
readonly requiresAuth = false;
|
|
13
|
+
protected getDefinition(): LazyCalculatorProviderDefinition<GeoGebraToolProviderConfig>;
|
|
14
|
+
getCapabilities(): ToolProviderCapabilities;
|
|
15
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** GeoGebra calculator adapter for the generic tool-provider registry. */
|
|
2
|
+
import { LazyCalculatorToolProvider } from "./LazyCalculatorToolProvider.js";
|
|
3
|
+
export class GeoGebraToolProvider extends LazyCalculatorToolProvider {
|
|
4
|
+
providerName = "GeoGebra Calculator";
|
|
5
|
+
version = "6";
|
|
6
|
+
requiresAuth = false;
|
|
7
|
+
getDefinition() {
|
|
8
|
+
return {
|
|
9
|
+
backend: "geogebra",
|
|
10
|
+
moduleImportOperation: "geogebra-provider-module-import",
|
|
11
|
+
loadProvider: async () => {
|
|
12
|
+
const module = await import("@pie-players/pie-calculator-geogebra");
|
|
13
|
+
return module.GeoGebraCalculatorProvider;
|
|
14
|
+
},
|
|
15
|
+
initializationErrorMessage: "Failed to initialize GeoGebra calculator provider. Confirm that the deployment may load GeoGebra and that its script URL is reachable.",
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
getCapabilities() {
|
|
19
|
+
return {
|
|
20
|
+
supportsOffline: false,
|
|
21
|
+
requiresAuth: false,
|
|
22
|
+
maxInstances: null,
|
|
23
|
+
features: {
|
|
24
|
+
basic: true,
|
|
25
|
+
scientific: true,
|
|
26
|
+
graphing: true,
|
|
27
|
+
fourFunction: false,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { CalculatorProvider, CalculatorProviderInit } from "@pie-players/pie-calculator";
|
|
2
|
+
import type { ToolProviderApi, ToolProviderCapabilities } from "@pie-players/pie-assessment-toolkit/tools/registration";
|
|
3
|
+
export type CalculatorToolProviderInitConfig = Pick<CalculatorProviderInit, "onTelemetry">;
|
|
4
|
+
type InitializableCalculatorProvider<TConfig> = CalculatorProvider & {
|
|
5
|
+
initialize(config: TConfig): Promise<void>;
|
|
6
|
+
};
|
|
7
|
+
export interface LazyCalculatorProviderDefinition<TConfig> {
|
|
8
|
+
backend: string;
|
|
9
|
+
moduleImportOperation: string;
|
|
10
|
+
loadProvider: () => Promise<new () => InitializableCalculatorProvider<TConfig>>;
|
|
11
|
+
initializationErrorMessage: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Shared lazy-module and lifecycle implementation for calculator tool adapters.
|
|
15
|
+
* Concrete adapters own only their metadata, capabilities and provider import.
|
|
16
|
+
*/
|
|
17
|
+
export declare abstract class LazyCalculatorToolProvider<TConfig extends CalculatorToolProviderInitConfig> implements ToolProviderApi<CalculatorProvider> {
|
|
18
|
+
abstract readonly providerName: string;
|
|
19
|
+
readonly category: "calculator";
|
|
20
|
+
abstract readonly version: string;
|
|
21
|
+
abstract readonly requiresAuth: boolean;
|
|
22
|
+
protected abstract getDefinition(): LazyCalculatorProviderDefinition<TConfig>;
|
|
23
|
+
abstract getCapabilities(): ToolProviderCapabilities;
|
|
24
|
+
private calculatorProvider;
|
|
25
|
+
private initializationPromise;
|
|
26
|
+
private lifecycleGeneration;
|
|
27
|
+
private emitTelemetry;
|
|
28
|
+
initialize(config?: TConfig): Promise<void>;
|
|
29
|
+
private initializeProvider;
|
|
30
|
+
createInstance(): Promise<CalculatorProvider>;
|
|
31
|
+
isReady(): boolean;
|
|
32
|
+
destroy(): void;
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared lazy-module and lifecycle implementation for calculator tool adapters.
|
|
3
|
+
* Concrete adapters own only their metadata, capabilities and provider import.
|
|
4
|
+
*/
|
|
5
|
+
export class LazyCalculatorToolProvider {
|
|
6
|
+
category = "calculator";
|
|
7
|
+
calculatorProvider = null;
|
|
8
|
+
initializationPromise = null;
|
|
9
|
+
lifecycleGeneration = 0;
|
|
10
|
+
async emitTelemetry(config, eventName, payload) {
|
|
11
|
+
try {
|
|
12
|
+
await config.onTelemetry?.(eventName, payload);
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
console.warn(`[${this.providerName}] telemetry callback failed:`, error);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
async initialize(config = {}) {
|
|
19
|
+
if (this.calculatorProvider)
|
|
20
|
+
return;
|
|
21
|
+
if (this.initializationPromise)
|
|
22
|
+
return this.initializationPromise;
|
|
23
|
+
const generation = ++this.lifecycleGeneration;
|
|
24
|
+
const initializationPromise = this.initializeProvider(config, generation);
|
|
25
|
+
this.initializationPromise = initializationPromise;
|
|
26
|
+
try {
|
|
27
|
+
await initializationPromise;
|
|
28
|
+
}
|
|
29
|
+
finally {
|
|
30
|
+
if (this.initializationPromise === initializationPromise) {
|
|
31
|
+
this.initializationPromise = null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async initializeProvider(config, generation) {
|
|
36
|
+
const definition = this.getDefinition();
|
|
37
|
+
const moduleLoadStartedAt = Date.now();
|
|
38
|
+
await this.emitTelemetry(config, "pie-tool-library-load-start", {
|
|
39
|
+
toolId: "calculator",
|
|
40
|
+
operation: definition.moduleImportOperation,
|
|
41
|
+
backend: definition.backend,
|
|
42
|
+
});
|
|
43
|
+
let ProviderConstructor;
|
|
44
|
+
try {
|
|
45
|
+
ProviderConstructor = await definition.loadProvider();
|
|
46
|
+
await this.emitTelemetry(config, "pie-tool-library-load-success", {
|
|
47
|
+
toolId: "calculator",
|
|
48
|
+
operation: definition.moduleImportOperation,
|
|
49
|
+
backend: definition.backend,
|
|
50
|
+
duration: Date.now() - moduleLoadStartedAt,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
await this.emitTelemetry(config, "pie-tool-library-load-error", {
|
|
55
|
+
toolId: "calculator",
|
|
56
|
+
operation: definition.moduleImportOperation,
|
|
57
|
+
backend: definition.backend,
|
|
58
|
+
duration: Date.now() - moduleLoadStartedAt,
|
|
59
|
+
errorType: "ToolLibraryLoadError",
|
|
60
|
+
message: error instanceof Error ? error.message : String(error),
|
|
61
|
+
});
|
|
62
|
+
throw new Error(definition.initializationErrorMessage, { cause: error });
|
|
63
|
+
}
|
|
64
|
+
if (generation !== this.lifecycleGeneration) {
|
|
65
|
+
throw new Error(`${this.providerName} initialization was cancelled`);
|
|
66
|
+
}
|
|
67
|
+
const candidate = new ProviderConstructor();
|
|
68
|
+
try {
|
|
69
|
+
await candidate.initialize(config);
|
|
70
|
+
if (generation !== this.lifecycleGeneration) {
|
|
71
|
+
throw new Error(`${this.providerName} initialization was cancelled`);
|
|
72
|
+
}
|
|
73
|
+
this.calculatorProvider = candidate;
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
candidate.destroy();
|
|
77
|
+
throw new Error(definition.initializationErrorMessage, { cause: error });
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
async createInstance() {
|
|
81
|
+
if (!this.calculatorProvider) {
|
|
82
|
+
throw new Error(`[${this.providerName}] Provider not initialized. Call initialize() first.`);
|
|
83
|
+
}
|
|
84
|
+
return this.calculatorProvider;
|
|
85
|
+
}
|
|
86
|
+
isReady() {
|
|
87
|
+
return this.calculatorProvider !== null;
|
|
88
|
+
}
|
|
89
|
+
destroy() {
|
|
90
|
+
this.lifecycleGeneration += 1;
|
|
91
|
+
this.initializationPromise = null;
|
|
92
|
+
this.calculatorProvider?.destroy();
|
|
93
|
+
this.calculatorProvider = null;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -16,5 +16,5 @@
|
|
|
16
16
|
* `tests/content-alternates.test.ts` pins this against the composition set in both
|
|
17
17
|
* directions, so a capability added there cannot quietly fail to reach print.
|
|
18
18
|
*/
|
|
19
|
-
import type { ToolRegistration } from "@pie-players/pie-assessment-toolkit/tools/
|
|
19
|
+
import type { ToolRegistration } from "@pie-players/pie-assessment-toolkit/tools/registration";
|
|
20
20
|
export declare const CONTENT_ALTERNATE_REGISTRATIONS: readonly ToolRegistration[];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export type {
|
|
2
|
-
export {
|
|
1
|
+
export type { PackagedToolRegistryOptions } from "./packaged-capability-composition.js";
|
|
2
|
+
export { createEmptyPersonalNeedsProfile, createPackagedToolRegistry, createUniversalPersonalNeedsProfile, DEFAULT_TOOL_MODULE_LOADERS, PACKAGED_TOOL_REGISTRATIONS, PACKAGED_TOOL_TAG_MAP, SECTION_PLAYER_PREFERRED_TOOL_PLACEMENT, } 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";
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { createEmptyPersonalNeedsProfile, createPackagedToolRegistry, createUniversalPersonalNeedsProfile, DEFAULT_TOOL_MODULE_LOADERS, PACKAGED_TOOL_REGISTRATIONS, PACKAGED_TOOL_TAG_MAP, SECTION_PLAYER_PREFERRED_TOOL_PLACEMENT, } 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";
|
|
@@ -2,45 +2,25 @@
|
|
|
2
2
|
* The one authored description of PIE's packaged capability composition.
|
|
3
3
|
*
|
|
4
4
|
* Registrations describe what a capability can do. This module owns the
|
|
5
|
-
* deployment decisions around them: element tags, lazy module
|
|
6
|
-
* placement
|
|
5
|
+
* deployment decisions around them: element tags, lazy module loaders, the
|
|
6
|
+
* section-player placement preset and the explicit universal-support policy.
|
|
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
|
|
10
|
+
import { ToolRegistry, type ToolComponentFactoryMap, type ToolModuleLoader, type ToolRegistration, type ToolTagMap } from "@pie-players/pie-assessment-toolkit/tools/registration";
|
|
11
11
|
import type { PersonalNeedsProfile } from "@pie-players/pie-players-shared/types";
|
|
12
|
-
export
|
|
13
|
-
export interface ToolRegistryLike {
|
|
14
|
-
setToolModuleLoaders(loaders: Partial<Record<string, ToolModuleLoader>>): void;
|
|
15
|
-
}
|
|
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 {
|
|
12
|
+
export interface PackagedToolRegistryOptions {
|
|
25
13
|
/** Override packaged registrations by toolId. */
|
|
26
14
|
overrides?: Partial<Record<string, ToolRegistration>>;
|
|
27
15
|
/** Override or extend the packaged element tag mapping. */
|
|
28
16
|
toolTagMap?: Partial<ToolTagMap>;
|
|
29
|
-
/** Override the component factory
|
|
30
|
-
toolComponentFactory?: ToolComponentFactory;
|
|
17
|
+
/** Override the component factory per tool. */
|
|
31
18
|
toolComponentFactories?: Partial<ToolComponentFactoryMap>;
|
|
32
19
|
/** Lazy module loaders keyed by toolId. */
|
|
33
20
|
toolModuleLoaders?: Partial<Record<string, ToolModuleLoader>>;
|
|
34
21
|
/** Restrict registration to specific packaged tool ids. */
|
|
35
22
|
toolIds?: string[];
|
|
36
23
|
}
|
|
37
|
-
export interface RegisterPackagedToolsOptions {
|
|
38
|
-
toolIds?: string[];
|
|
39
|
-
applyOverrides?: (registration: ToolRegistration) => ToolRegistration;
|
|
40
|
-
}
|
|
41
|
-
export interface RegisterDefaultToolModuleLoadersOptions extends PackagedCalculatorCompositionOptions {
|
|
42
|
-
loaders?: Partial<Record<string, ToolModuleLoader>>;
|
|
43
|
-
}
|
|
44
24
|
/**
|
|
45
25
|
* Release/build gate for PIE-authored composition data.
|
|
46
26
|
*
|
|
@@ -49,37 +29,25 @@ export interface RegisterDefaultToolModuleLoadersOptions extends PackagedCalcula
|
|
|
49
29
|
* that prevents an otherwise usable assessment from rendering.
|
|
50
30
|
*/
|
|
51
31
|
export declare function assertPackagedCapabilityComposition(): void;
|
|
52
|
-
export declare const PACKAGED_TOOL_REGISTRATIONS: readonly [
|
|
32
|
+
export declare const PACKAGED_TOOL_REGISTRATIONS: readonly ToolRegistration[];
|
|
53
33
|
export declare const PACKAGED_TOOL_TAG_MAP: ToolTagMap;
|
|
54
|
-
export declare const ITEM_TOOL_MODULE_LOADERS: Record<string, ToolModuleLoader>;
|
|
55
|
-
export declare const SECTION_TOOL_MODULE_LOADERS: Record<string, ToolModuleLoader>;
|
|
56
34
|
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>;
|
|
61
|
-
export declare const PACKAGED_TOOL_PLACEMENT: {
|
|
62
|
-
readonly assessment: readonly ["theme"];
|
|
63
|
-
readonly section: readonly ["theme"];
|
|
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"];
|
|
68
|
-
};
|
|
69
35
|
export declare const SECTION_PLAYER_PREFERRED_TOOL_PLACEMENT: {
|
|
70
36
|
section: string[];
|
|
71
37
|
item: string[];
|
|
72
38
|
passage: string[];
|
|
73
39
|
};
|
|
74
|
-
export declare const PACKAGED_TOOL_ORDER: readonly ["theme", "calculator", "textToSpeech", "lineReader", "annotationToolbar", "answerEliminator", "ruler", "protractor", "graph", "periodicTable", "dictionary", "pictureDictionary", "dictionarySpanish", "pictureDictionarySpanish"];
|
|
75
|
-
export declare const UNIVERSAL_SUPPORTS_PRESET: readonly string[];
|
|
76
|
-
/** Register packaged PIE capabilities onto an existing registry. */
|
|
77
|
-
export declare function registerPackagedTools(registry: ToolRegistry, options?: RegisterPackagedToolsOptions): void;
|
|
78
40
|
/** Create a registry holding the packaged PIE capabilities. */
|
|
79
41
|
export declare function createPackagedToolRegistry(options?: PackagedToolRegistryOptions): ToolRegistry;
|
|
80
|
-
/**
|
|
42
|
+
/**
|
|
43
|
+
* A fresh profile granting the packaged set's universal capabilities, sorted by
|
|
44
|
+
* tool id. Which capabilities are universal is program policy declared on each
|
|
45
|
+
* definition; registry membership never implies it.
|
|
46
|
+
*/
|
|
81
47
|
export declare function createUniversalPersonalNeedsProfile(): PersonalNeedsProfile;
|
|
82
|
-
/**
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
48
|
+
/**
|
|
49
|
+
* A fresh profile granting and prohibiting nothing. The toolkit ships no
|
|
50
|
+
* populated default: a deployment's universal set is program policy, which
|
|
51
|
+
* `createUniversalPersonalNeedsProfile` carries as data for hosts that adopt it.
|
|
52
|
+
*/
|
|
53
|
+
export declare function createEmptyPersonalNeedsProfile(): PersonalNeedsProfile;
|