@pie-players/pie-assessment-toolkit 0.3.74 → 1.0.0-beta.0
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 +658 -714
- package/custom-elements.json +1315 -0
- package/dist/attempt/TestSession.d.ts +1 -21
- package/dist/attempt/TestSession.js +16 -102
- package/dist/components/ItemScope.custom-element.d.ts +1 -0
- package/dist/components/ItemScope.custom-element.js +1 -0
- package/dist/components/ItemToolBar.custom-element.js +1 -1
- package/dist/components/PieAssessmentToolkit.custom-element.js +14 -14
- package/dist/components/SectionToolBar.custom-element.js +1 -1
- package/dist/components/chunks/ItemToolBar-3zrc4p3d.js +4 -0
- package/dist/components/chunks/ItemToolBar-66hcwmfw.js +2 -0
- package/dist/components/chunks/ItemToolBar-9gqhfxtn.js +40 -0
- package/dist/components/chunks/ItemToolBar-hzc5wyjp.js +2 -0
- package/dist/components/chunks/{ItemToolBar-gmrryv2v.js → ItemToolBar-kkj69ptr.js} +1 -1
- package/dist/components/chunks/ItemToolBar-vdkyn9f3.js +2 -0
- package/dist/components/chunks/sre-engine-bj997w4b.js +1 -0
- package/dist/components/item-scope-element.d.ts +2 -0
- package/dist/components/item-scope-element.js +2 -0
- package/dist/context/assessment-toolkit-context.d.ts +33 -6
- package/dist/index.d.ts +25 -50
- package/dist/index.js +15 -45
- package/dist/policy/core/PolicySource.d.ts +2 -2
- package/dist/policy/core/ToolPolicyEngine.d.ts +118 -34
- package/dist/policy/core/ToolPolicyEngine.js +203 -56
- package/dist/policy/core/compose-decision.d.ts +28 -7
- package/dist/policy/core/compose-decision.js +95 -74
- package/dist/policy/core/decision-types.d.ts +98 -55
- package/dist/policy/core/feature-decision.d.ts +28 -19
- package/dist/policy/core/feature-decision.js +15 -11
- package/dist/policy/core/pnp-policy-inputs.d.ts +29 -35
- package/dist/policy/core/pnp-policy-inputs.js +40 -88
- package/dist/policy/core/provenance.d.ts +10 -5
- package/dist/policy/core/provenance.js +1 -1
- package/dist/policy/core/tool-parameters.d.ts +11 -0
- package/dist/policy/core/tool-parameters.js +15 -0
- package/dist/policy/engine.d.ts +7 -23
- package/dist/policy/engine.js +5 -20
- package/dist/policy/sources/PnpPolicySource.d.ts +43 -68
- package/dist/policy/sources/PnpPolicySource.js +133 -132
- package/dist/runtime/SectionControllerBinding.d.ts +283 -0
- package/dist/runtime/SectionControllerBinding.js +456 -0
- package/dist/runtime/SectionRuntimeEngine.d.ts +26 -289
- package/dist/runtime/SectionRuntimeEngine.js +30 -372
- package/dist/runtime/adapter/SectionEngineAdapter.d.ts +19 -80
- package/dist/runtime/adapter/SectionEngineAdapter.js +19 -92
- package/dist/runtime/adapter/dom-event-bridge.d.ts +15 -30
- package/dist/runtime/adapter/dom-event-bridge.js +17 -44
- package/dist/runtime/adapter/subscriber-fanout.d.ts +1 -3
- package/dist/runtime/adapter/subscriber-fanout.js +2 -6
- package/dist/runtime/catalog-context.d.ts +19 -0
- package/dist/runtime/catalog-context.js +28 -0
- package/dist/runtime/composition-emit-scheduler.d.ts +12 -18
- package/dist/runtime/composition-emit-scheduler.js +10 -16
- package/dist/runtime/content-language.d.ts +32 -0
- package/dist/runtime/content-language.js +46 -0
- package/dist/runtime/content-region.d.ts +13 -0
- package/dist/runtime/content-region.js +29 -0
- package/dist/runtime/content-registration.d.ts +13 -0
- package/dist/runtime/content-registration.js +25 -0
- package/dist/runtime/core/SectionEngineCore.d.ts +2 -4
- package/dist/runtime/core/SectionEngineCore.js +2 -6
- package/dist/runtime/core/cohort.d.ts +1 -6
- package/dist/runtime/core/cohort.js +1 -10
- package/dist/runtime/core/engine-input.d.ts +18 -30
- package/dist/runtime/core/engine-input.js +11 -12
- package/dist/runtime/core/engine-output.d.ts +17 -40
- package/dist/runtime/core/engine-output.js +9 -21
- package/dist/runtime/core/engine-readiness.d.ts +5 -37
- package/dist/runtime/core/engine-readiness.js +8 -41
- package/dist/runtime/core/engine-resolver.d.ts +46 -74
- package/dist/runtime/core/engine-resolver.js +18 -43
- package/dist/runtime/core/engine-state.d.ts +28 -36
- package/dist/runtime/core/engine-state.js +18 -21
- package/dist/runtime/core/engine-transition.d.ts +14 -19
- package/dist/runtime/core/engine-transition.js +74 -53
- package/dist/runtime/engine.d.ts +16 -19
- package/dist/runtime/engine.js +12 -19
- package/dist/runtime/page-warnings.d.ts +13 -0
- package/dist/runtime/page-warnings.js +22 -0
- package/dist/runtime/policy-input-forwarding.d.ts +25 -0
- package/dist/runtime/policy-input-forwarding.js +25 -0
- package/dist/runtime/registration-events.d.ts +22 -14
- package/dist/runtime/runtime-event-claim.d.ts +8 -0
- package/dist/runtime/runtime-event-claim.js +15 -0
- package/dist/runtime/runtime-id.d.ts +1 -1
- package/dist/runtime/runtime-id.js +1 -1
- package/dist/runtime/shell-event-bridge.d.ts +45 -0
- package/dist/runtime/shell-event-bridge.js +127 -0
- package/dist/runtime/shell-registration.d.ts +73 -0
- package/dist/runtime/shell-registration.js +95 -0
- package/dist/runtime/shell-scope.d.ts +68 -0
- package/dist/runtime/shell-scope.js +194 -0
- package/dist/runtime/tool-host-contract.d.ts +8 -14
- package/dist/runtime/tool-host-contract.js +12 -12
- package/dist/runtime/unclaimed-registration-watch.d.ts +7 -0
- package/dist/runtime/unclaimed-registration-watch.js +23 -0
- package/dist/services/AccessibilityCatalogResolver.d.ts +21 -31
- package/dist/services/AccessibilityCatalogResolver.js +29 -42
- package/dist/services/ElementToolStateStore.d.ts +42 -67
- package/dist/services/ElementToolStateStore.js +65 -71
- package/dist/services/HighlightCoordinator.d.ts +28 -40
- package/dist/services/HighlightCoordinator.js +459 -381
- package/dist/services/RangeSerializer.d.ts +11 -33
- package/dist/services/RangeSerializer.js +88 -59
- package/dist/services/SSMLExtractor.d.ts +8 -31
- package/dist/services/SSMLExtractor.js +18 -40
- package/dist/services/TTSService.d.ts +159 -119
- package/dist/services/TTSService.js +937 -822
- package/dist/services/ToolCoordinator.d.ts +42 -102
- package/dist/services/ToolCoordinator.js +178 -256
- package/dist/services/ToolRegistry.d.ts +152 -133
- package/dist/services/ToolRegistry.js +192 -178
- package/dist/services/ToolkitCoordinator.d.ts +233 -237
- package/dist/services/ToolkitCoordinator.js +615 -557
- package/dist/services/audio-handoff.d.ts +6 -7
- package/dist/services/audio-handoff.js +20 -14
- package/dist/services/catalog-owner.d.ts +0 -1
- package/dist/services/framework-error-bus.d.ts +3 -6
- package/dist/services/framework-error-bus.js +3 -6
- package/dist/services/framework-error.d.ts +51 -13
- package/dist/services/framework-error.js +19 -20
- package/dist/services/interfaces.d.ts +189 -184
- package/dist/services/section-controller-types.d.ts +7 -7
- package/dist/services/section-session-assignment.d.ts +21 -0
- package/dist/services/section-session-assignment.js +80 -0
- package/dist/services/spoken-audio-cards.d.ts +2 -6
- package/dist/services/spoken-audio-cards.js +2 -6
- package/dist/services/tool-config-defaults.d.ts +3 -3
- package/dist/services/tool-config-defaults.js +3 -3
- package/dist/services/tool-config-validation.d.ts +9 -12
- package/dist/services/tool-config-validation.js +47 -87
- package/dist/services/tool-context.d.ts +7 -31
- package/dist/services/tool-context.js +99 -65
- package/dist/services/tool-failure.d.ts +30 -0
- package/dist/services/tool-failure.js +11 -0
- package/dist/services/tool-icons.d.ts +5 -5
- package/dist/services/tool-icons.js +6 -5
- package/dist/services/tool-instance-id.d.ts +8 -7
- package/dist/services/tool-instance-id.js +12 -24
- package/dist/services/tool-providers/TTSToolProvider.d.ts +20 -58
- package/dist/services/tool-providers/TTSToolProvider.js +32 -85
- package/dist/services/tool-providers/ToolProviderApi.d.ts +10 -11
- package/dist/services/tool-providers/ToolProviderRegistry.d.ts +29 -60
- package/dist/services/tool-providers/ToolProviderRegistry.js +128 -144
- package/dist/services/tool-request.d.ts +31 -12
- package/dist/services/tool-request.js +31 -16
- package/dist/services/toolbar-decided-tools.d.ts +16 -0
- package/dist/services/toolbar-decided-tools.js +29 -0
- package/dist/services/toolbar-items.js +2 -5
- package/dist/services/tools-config-normalizer.d.ts +33 -29
- package/dist/services/tools-config-normalizer.js +26 -28
- package/dist/services/tts/browser-provider.d.ts +39 -6
- package/dist/services/tts/browser-provider.js +280 -160
- package/dist/services/tts/catalog-span-alignment.js +14 -7
- package/dist/services/tts/flat-tree.d.ts +64 -0
- package/dist/services/tts/flat-tree.js +269 -0
- package/dist/services/tts/generated-speech/assemble-plan.d.ts +3 -1
- package/dist/services/tts/generated-speech/assemble-plan.js +3 -1
- package/dist/services/tts/generated-speech/dom/build-dom-plan.d.ts +2 -0
- package/dist/services/tts/generated-speech/dom/build-dom-plan.js +1 -1
- package/dist/services/tts/generated-speech/dom/to-chunk-inputs.d.ts +2 -2
- package/dist/services/tts/generated-speech/index.d.ts +1 -1
- package/dist/services/tts/generated-speech/index.js +1 -1
- package/dist/services/tts/generated-speech/math-speech-cache.d.ts +3 -1
- package/dist/services/tts/generated-speech/math-speech-cache.js +5 -1
- package/dist/services/tts/generated-speech/types.d.ts +1 -1
- package/dist/services/tts/generated-speech/types.js +1 -1
- package/dist/services/tts/highlight-pipeline/create-highlight-plan.js +22 -16
- package/dist/services/tts/highlight-pipeline/prose-boundary-resolver.js +6 -4
- package/dist/services/tts/highlight-pipeline/readable-region.js +3 -2
- package/dist/services/tts/highlight-pipeline/types.d.ts +5 -0
- package/dist/services/tts/highlight-pipeline/visible-map-range.d.ts +12 -0
- package/dist/services/tts/highlight-pipeline/visible-map-range.js +73 -7
- package/dist/services/tts/highlight-target-resolver.d.ts +12 -0
- package/dist/services/tts/math-aware-text-processing.d.ts +5 -1
- package/dist/services/tts/math-aware-text-processing.js +42 -47
- package/dist/services/tts/math-control-names.d.ts +21 -0
- package/dist/services/tts/math-control-names.js +142 -0
- package/dist/services/tts/math-speech.d.ts +12 -1
- package/dist/services/tts/math-speech.js +54 -18
- package/dist/services/tts/mathml-sanitization.d.ts +7 -0
- package/dist/services/tts/mathml-sanitization.js +9 -1
- package/dist/services/tts/provider-options.d.ts +52 -0
- package/dist/services/tts/provider-options.js +1 -0
- package/dist/services/tts/ssml/spoken-text.d.ts +2 -26
- package/dist/services/tts/ssml/spoken-text.js +29 -0
- package/dist/services/tts/start-failure.d.ts +4 -0
- package/dist/services/tts/start-failure.js +19 -0
- package/dist/services/tts/text-processing.d.ts +9 -0
- package/dist/services/tts/text-processing.js +46 -33
- package/dist/services/tts/text-segmentation.d.ts +12 -0
- package/dist/services/tts/text-segmentation.js +60 -10
- package/dist/services/tts-runtime-config.d.ts +54 -26
- package/dist/services/tts-runtime-config.js +27 -112
- package/dist/tools/content-capability-resolution.d.ts +9 -11
- package/dist/tools/content-capability-resolution.js +8 -45
- package/dist/tools/registration.d.ts +59 -0
- package/dist/tools/registration.js +55 -0
- package/dist/tools/registrations/toolbar-registration-helpers.d.ts +6 -0
- package/dist/tools/registrations/toolbar-registration-helpers.js +8 -2
- package/dist/tools/tool-surface-host.d.ts +6 -10
- package/dist/tools/tool-surface-host.js +45 -50
- package/dist/tools/tool-tag-map.d.ts +5 -15
- package/dist/tools/tool-tag-map.js +6 -20
- package/dist/utils/structural-equality.d.ts +11 -0
- package/dist/utils/structural-equality.js +47 -0
- package/package.json +15 -29
- package/dist/attempt/adapters/activity-to-test-attempt-session.d.ts +0 -49
- package/dist/attempt/adapters/activity-to-test-attempt-session.js +0 -138
- package/dist/components/chunks/ItemToolBar-b9dz5jvd.js +0 -40
- package/dist/components/chunks/ItemToolBar-h4xap0t0.js +0 -4
- package/dist/components/chunks/ItemToolBar-wr2myaah.js +0 -2
- package/dist/components/chunks/sre-engine-wf9s43gg.js +0 -1
- package/dist/context/runtime-context-consumer.d.ts +0 -13
- package/dist/context/runtime-context-consumer.js +0 -18
- package/dist/item-loader.d.ts +0 -44
- package/dist/item-loader.js +0 -61
- package/dist/policy/core/engine-context.d.ts +0 -29
- package/dist/policy/core/engine-context.js +0 -27
- package/dist/policy/core/policy-source-tag.d.ts +0 -31
- package/dist/policy/core/policy-source-tag.js +0 -28
- package/dist/policy/internal.d.ts +0 -25
- package/dist/policy/internal.js +0 -25
- package/dist/runtime/adapter/coordinator-bridge.d.ts +0 -92
- package/dist/runtime/adapter/coordinator-bridge.js +0 -126
- package/dist/runtime/adapter/framework-error-bridge.d.ts +0 -36
- package/dist/runtime/adapter/framework-error-bridge.js +0 -46
- package/dist/runtime/adapter/instrumentation-bridge.d.ts +0 -31
- package/dist/runtime/adapter/instrumentation-bridge.js +0 -38
- package/dist/runtime/core/engine-stage-derivation.d.ts +0 -18
- package/dist/runtime/core/engine-stage-derivation.js +0 -29
- package/dist/runtime/engine-context.d.ts +0 -39
- package/dist/runtime/engine-context.js +0 -31
- package/dist/runtime/internal.d.ts +0 -43
- package/dist/runtime/internal.js +0 -45
- package/dist/runtime/section-runtime-engine-host-context.d.ts +0 -74
- package/dist/runtime/section-runtime-engine-host-context.js +0 -57
- package/dist/runtime/stage-emit-gate.d.ts +0 -92
- package/dist/runtime/stage-emit-gate.js +0 -82
- package/dist/services/ContextVariableStore.d.ts +0 -113
- package/dist/services/ContextVariableStore.js +0 -206
- package/dist/services/I18nService.d.ts +0 -47
- package/dist/services/I18nService.js +0 -84
- package/dist/services/ThemeProvider.d.ts +0 -95
- package/dist/services/ThemeProvider.js +0 -334
- package/dist/services/defaultPersonalNeedsProfile.d.ts +0 -21
- package/dist/services/defaultPersonalNeedsProfile.js +0 -26
- package/dist/services/pnp-standard-features.d.ts +0 -238
- package/dist/services/pnp-standard-features.js +0 -338
- package/dist/services/tts-control-events.d.ts +0 -13
- package/dist/services/tts-control-events.js +0 -7
- package/dist/tools/client.d.ts +0 -10
- package/dist/tools/client.js +0 -10
- package/dist/tools/internal.d.ts +0 -44
- package/dist/tools/internal.js +0 -39
- package/dist/utils/logger.d.ts +0 -6
- package/dist/utils/logger.js +0 -10
package/dist/index.js
CHANGED
|
@@ -6,58 +6,28 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @packageDocumentation
|
|
8
8
|
*/
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export {
|
|
15
|
-
|
|
16
|
-
export {
|
|
9
|
+
export { catalogOwnerContextFor, } from "./services/catalog-owner.js";
|
|
10
|
+
export { PIE_INTERNAL_FORMATIVE_ACTION_EVENT, PIE_INTERNAL_ITEM_SESSION_CHANGED_EVENT, PIE_INTERNAL_MEDIA_TIME_SOURCE_EVENT, PIE_ITEM_SESSION_CHANGED_EVENT, } from "./runtime/registration-events.js";
|
|
11
|
+
export { createShellScope, } from "./runtime/shell-scope.js";
|
|
12
|
+
// A shell's translation of its player's events into the runtime's, shared by the
|
|
13
|
+
// section player's passage shell and `<pie-item-scope>`.
|
|
14
|
+
export { createShellEventBridge, } from "./runtime/shell-event-bridge.js";
|
|
15
|
+
export { connectToolRuntimeContext, dispatchCrossBoundaryEvent, } from "./runtime/tool-host-contract.js";
|
|
16
|
+
export { AccessibilityCatalogResolver } from "./services/AccessibilityCatalogResolver.js";
|
|
17
17
|
// Element Tool State Store (Element-level ephemeral tool state)
|
|
18
|
-
export { ElementToolStateStore } from "./services/ElementToolStateStore.js";
|
|
18
|
+
export { ElementToolStateStore, } from "./services/ElementToolStateStore.js";
|
|
19
19
|
export { HighlightColor, HighlightCoordinator, HighlightType, } from "./services/HighlightCoordinator.js";
|
|
20
|
-
export { RangeSerializer } from "./services/RangeSerializer.js";
|
|
21
|
-
export { I18nService } from "./services/I18nService.js";
|
|
22
20
|
export { ToolRegistry } from "./services/ToolRegistry.js";
|
|
23
|
-
export {
|
|
24
|
-
export { extractTextContent, hasChoiceInteraction, hasMathContent, hasReadableText, isAssessmentContext, isElementContext, isItemContext, isPassageContext, isRubricContext, isSectionContext, } from "./services/tool-context.js";
|
|
25
|
-
export { DEFAULT_TOOL_PLACEMENT } from "./services/tool-config-defaults.js";
|
|
21
|
+
export { hasReadableText, hasSpokenContent, } from "./services/tool-context.js";
|
|
26
22
|
export { createToolsConfig } from "./services/create-tools-config.js";
|
|
27
|
-
export { createEmptyPersonalNeedsProfile } from "./services/defaultPersonalNeedsProfile.js";
|
|
28
|
-
export { createToolElement, resolveToolTag, toToolIdFromTag, } from "./tools/tool-tag-map.js";
|
|
29
|
-
// QTI 3.0 Standard Access Features
|
|
30
|
-
export { ALL_STANDARD_ACCESS_FEATURES, EXAMPLE_PNP_CONFIGURATIONS, getFeatureCategory, getFeaturesInCategory, isStandardAccessFeature, QTI_STANDARD_ACCESS_FEATURES, } from "./services/pnp-standard-features.js";
|
|
31
|
-
// Media-bearing catalog cards: the generic half, shared by every card form that
|
|
32
|
-
// references a recording rather than carrying text. Owned by
|
|
33
|
-
// `@pie-players/pie-players-shared/media`, which an element can import without
|
|
34
|
-
// this package; re-exported here for toolkit consumers.
|
|
35
|
-
export { applyMediaFragment, enforceMediaFragment, isSafeMediaSrc, isUnsupportedMediaAssetVersion, normalizeMediaFragment, normalizeMediaSources, SUPPORTED_MEDIA_ASSET_VERSION, trimmedOrUndefined, } from "@pie-players/pie-players-shared/media";
|
|
36
|
-
export { resolveSpokenAudioMedia, SPOKEN_CATALOG_TYPE, } from "./services/spoken-audio-cards.js";
|
|
37
23
|
export { SSMLExtractor } from "./services/SSMLExtractor.js";
|
|
38
|
-
export { ThemeProvider } from "./services/ThemeProvider.js";
|
|
39
24
|
// Tool Coordinator
|
|
40
|
-
export {
|
|
25
|
+
export { ZIndexLayer } from "./services/ToolCoordinator.js";
|
|
41
26
|
export { ToolkitCoordinator } from "./services/ToolkitCoordinator.js";
|
|
42
|
-
export {
|
|
43
|
-
export {
|
|
44
|
-
|
|
45
|
-
export { isHostDeniedFeature } from "./policy/core/feature-decision.js";
|
|
46
|
-
export { frameworkErrorFromToolConfigValidation, normalizeAndValidateToolsConfig, } from "./services/tool-config-validation.js";
|
|
47
|
-
export { createScopedToolId, parseScopedToolId, toOverlayToolId, } from "./services/tool-instance-id.js";
|
|
27
|
+
export { frameworkErrorFromUnknown, toFrameworkErrorModel, } from "./services/framework-error.js";
|
|
28
|
+
export { createScopedToolId } from "./services/tool-instance-id.js";
|
|
29
|
+
// Text-to-Speech Service
|
|
48
30
|
export { PlaybackState, TTSService } from "./services/TTSService.js";
|
|
49
|
-
export { PIE_TTS_CONTROL_HANDOFF_EVENT, } from "./services/tts-control-events.js";
|
|
50
|
-
export { bindTtsAudioHandoff, pauseTtsForMediaAudio, } from "./services/audio-handoff.js";
|
|
51
31
|
export { BrowserTTSProvider } from "./services/tts/browser-provider.js";
|
|
52
|
-
export {
|
|
53
|
-
export { createFetchItemLoader, createLoadItem, ItemLoadError, } from "./item-loader.js";
|
|
54
|
-
export { createMemoryStorage, createTestAttemptSessionIdentifier, createNewTestAttemptSession, getBrowserLocalStorage, getOrCreateAnonymousDeviceId, getTestAttemptSessionStorageKey, loadTestAttemptSession, saveTestAttemptSession, setCurrentPosition, upsertItemSessionFromPieSessionChange, upsertVisitedItem, } from "./attempt/TestSession.js";
|
|
32
|
+
export { createNewTestAttemptSession, setCurrentPosition, toItemSessionsRecord, upsertItemSessionFromPieSessionChange, upsertVisitedItem, } from "./attempt/TestSession.js";
|
|
55
33
|
export { createNewAssessmentSession, setCurrentSectionPosition, upsertSectionSession, } from "./attempt/AssessmentSession.js";
|
|
56
|
-
export { buildActivitySessionItemUpdate, buildActivitySessionPatchFromTestAttemptSession, mapActivityToTestAttemptSession, toItemSessionsRecord, } from "./attempt/adapters/activity-to-test-attempt-session.js";
|
|
57
|
-
// Section Player - Use @pie-players/pie-section-player web component
|
|
58
|
-
// ============================================================================
|
|
59
|
-
// Shared Components
|
|
60
|
-
// ============================================================================
|
|
61
|
-
// ItemToolBar custom element registration helper is exported via package.json exports field
|
|
62
|
-
// Import using: import '@pie-players/pie-assessment-toolkit/components/item-toolbar-element';
|
|
63
|
-
// PieAssessmentToolkit custom element registration helper is exported via package.json exports field
|
|
@@ -36,7 +36,7 @@ export interface PolicySourceProvenanceEntry {
|
|
|
36
36
|
* Custom precedence value used for the decision log. Defaults to
|
|
37
37
|
* `100 + sourceIndex` (engine-assigned) when `undefined`. Sources
|
|
38
38
|
* MAY override only if they know what they are doing — overriding
|
|
39
|
-
* to a value `<=
|
|
39
|
+
* to a value `<= 8` lets the source masquerade as a PNP/profile rule and
|
|
40
40
|
* is generally a bug.
|
|
41
41
|
*/
|
|
42
42
|
precedence?: number;
|
|
@@ -57,7 +57,7 @@ export interface PolicySourceResult {
|
|
|
57
57
|
decisions?: PolicySourceProvenanceEntry[];
|
|
58
58
|
}
|
|
59
59
|
export interface PolicySource {
|
|
60
|
-
/** Stable identifier
|
|
60
|
+
/** Stable identifier, recorded as `customSourceId` on the decisions and diagnostics it causes. */
|
|
61
61
|
readonly id: string;
|
|
62
62
|
refine(context: PolicySourceDecisionContext): PolicySourceResult;
|
|
63
63
|
}
|
|
@@ -3,43 +3,40 @@
|
|
|
3
3
|
* `docs/tools-and-accomodations/architecture.md`.
|
|
4
4
|
*
|
|
5
5
|
* Wraps `composeDecision(...)` with engine-instance state:
|
|
6
|
-
* - bound inputs (`tools`, `assessment`, `
|
|
6
|
+
* - bound inputs (`tools`, `assessment`, `pnpEnforcement`) and the
|
|
7
|
+
* settings of the mounted items
|
|
7
8
|
* - registered custom `PolicySource`s
|
|
8
9
|
* - `onPolicyChange` subscriber bus
|
|
9
10
|
* - `dispose()` clean-up
|
|
10
11
|
*
|
|
11
12
|
* The class has no DOM dependency and no Svelte runes. It is safe to
|
|
12
13
|
* instantiate inside a worker, in a Node test, or inside a CE
|
|
13
|
-
* connectedCallback.
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* PR 1 ships the engine *without callers*. PR 2 wires it into
|
|
17
|
-
* `ToolkitCoordinator`. PR 3 switches `<pie-item-toolbar>` over.
|
|
14
|
+
* connectedCallback. `ToolkitCoordinator` owns the instance, and
|
|
15
|
+
* `<pie-item-toolbar>` reads its decisions through the coordinator.
|
|
18
16
|
*/
|
|
19
|
-
import type { AssessmentEntity,
|
|
20
|
-
import type { CanonicalToolsConfig, ToolPlacementLevel } from "../../services/tools-config-normalizer.js";
|
|
17
|
+
import type { AssessmentEntity, ItemSettings, ToolParametersFor } from "@pie-players/pie-players-shared/types";
|
|
18
|
+
import type { CanonicalToolsConfig, PnpEnforcementMode, ToolPlacementLevel } from "../../services/tools-config-normalizer.js";
|
|
21
19
|
import type { ToolRegistry } from "../../services/ToolRegistry.js";
|
|
22
|
-
import type { ToolPolicyDecision, ToolPolicyDecisionRequest } from "./decision-types.js";
|
|
20
|
+
import type { ToolPolicyDecision, ToolPolicyDecisionRequest, ToolPolicyDiagnostic, ToolScope } from "./decision-types.js";
|
|
23
21
|
import type { PolicySource } from "./PolicySource.js";
|
|
24
22
|
import type { FeaturePolicyDecision } from "./feature-decision.js";
|
|
25
|
-
export type PnpEnforcementMode
|
|
23
|
+
export type { PnpEnforcementMode };
|
|
26
24
|
export interface ToolPolicyEngineInputs {
|
|
27
25
|
tools?: CanonicalToolsConfig | null;
|
|
28
26
|
assessment?: AssessmentEntity | null;
|
|
29
|
-
currentItemRef?: AssessmentItemRef | null;
|
|
30
27
|
/**
|
|
31
|
-
* Explicit PNP/profile override
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
28
|
+
* Explicit PNP/profile override; `null` or omitted is auto-mode. Auto-mode
|
|
29
|
+
* resolves per decision through {@link resolveDefaultPnpEnforcement}: `"on"`
|
|
30
|
+
* when the bound `assessment` carries PNP/profile policy material (PNP,
|
|
31
|
+
* district policy, test administration), and for a decision scoped to an item
|
|
32
|
+
* also when that item's settings require or restrict a tool;
|
|
36
33
|
* `"off"` otherwise. `tests/policy/pnp-default-on.test.ts` locks the rule.
|
|
37
34
|
*
|
|
38
35
|
* Hosts that want to force a mode pass `"on"` or `"off"`
|
|
39
36
|
* explicitly. Embedded under `<pie-section-player-*>` the preferred
|
|
40
37
|
* override flows through `runtime.tools.pnpEnforcement`.
|
|
41
38
|
*/
|
|
42
|
-
pnpEnforcement?: PnpEnforcementMode;
|
|
39
|
+
pnpEnforcement?: PnpEnforcementMode | null;
|
|
43
40
|
}
|
|
44
41
|
export interface ToolPolicyEngineArgs {
|
|
45
42
|
toolRegistry: ToolRegistry;
|
|
@@ -47,30 +44,65 @@ export interface ToolPolicyEngineArgs {
|
|
|
47
44
|
customSources?: readonly PolicySource[];
|
|
48
45
|
/** Stable context label used in provenance trails. Defaults to "tool-policy". */
|
|
49
46
|
contextId?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Whether the host may leave the assessment unbound without that being a
|
|
49
|
+
* misconfiguration; see {@link ResolvedEngineInputs.assessmentExpected}.
|
|
50
|
+
* Defaults to `false`.
|
|
51
|
+
*/
|
|
52
|
+
assessmentOptional?: boolean;
|
|
50
53
|
}
|
|
51
54
|
export interface ToolPolicyChangeEvent {
|
|
52
|
-
/**
|
|
53
|
-
|
|
55
|
+
/**
|
|
56
|
+
* What changed in this update. `"item-settings"` is a mounted item's
|
|
57
|
+
* settings changing: it can change which tools that item's own toolbar
|
|
58
|
+
* shows, and nothing else a toolbar renders.
|
|
59
|
+
*/
|
|
60
|
+
reason: "inputs" | "item-settings" | "policy-source-added" | "policy-source-removed" | "pnp-enforcement" | "disposed";
|
|
54
61
|
/** Snapshot of the engine's inputs after the change. */
|
|
55
62
|
inputs: Readonly<ResolvedEngineInputs>;
|
|
56
63
|
}
|
|
57
64
|
export interface ResolvedEngineInputs {
|
|
58
65
|
tools: CanonicalToolsConfig;
|
|
59
66
|
assessment: AssessmentEntity | null;
|
|
60
|
-
|
|
67
|
+
/**
|
|
68
|
+
* The mode a decision not scoped to an item applies. In auto-mode an
|
|
69
|
+
* item-scoped decision also turns on for its item's settings.
|
|
70
|
+
*/
|
|
61
71
|
pnpEnforcement: PnpEnforcementMode;
|
|
72
|
+
/** The host's override of auto-mode, or `null` in auto-mode. */
|
|
73
|
+
pnpEnforcementOverride: PnpEnforcementMode | null;
|
|
74
|
+
/**
|
|
75
|
+
* Whether an unbound assessment is a misconfiguration: always, unless the
|
|
76
|
+
* engine was built `assessmentOptional`, and then only while enforcement is
|
|
77
|
+
* overridden `"on"`.
|
|
78
|
+
*/
|
|
79
|
+
assessmentExpected: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Conflicts in the inputs themselves, independent of any decision: a
|
|
82
|
+
* `tool-policy.unknownSupportId` for each id the assessment or a mounted
|
|
83
|
+
* item's settings name that no registered tool carries. Recomputed when the
|
|
84
|
+
* assessment, an item's settings or the registry's tools change.
|
|
85
|
+
*/
|
|
86
|
+
diagnostics: readonly ToolPolicyDiagnostic[];
|
|
62
87
|
}
|
|
63
88
|
export type ToolPolicyChangeListener = (event: ToolPolicyChangeEvent) => void;
|
|
64
89
|
export declare class ToolPolicyEngine {
|
|
65
90
|
private toolRegistry;
|
|
91
|
+
private unsubscribeRegistry;
|
|
66
92
|
private readonly contextId;
|
|
93
|
+
private readonly assessmentOptional;
|
|
67
94
|
private pnpPolicySource;
|
|
68
95
|
private readonly customSources;
|
|
69
96
|
private readonly listeners;
|
|
70
97
|
private tools;
|
|
71
98
|
private assessment;
|
|
72
|
-
private
|
|
73
|
-
|
|
99
|
+
private pnpEnforcementOverride;
|
|
100
|
+
/**
|
|
101
|
+
* Mounted items' settings by canonical item id, newest registration last;
|
|
102
|
+
* see {@link registerItemSettings}.
|
|
103
|
+
*/
|
|
104
|
+
private readonly itemSettings;
|
|
105
|
+
private inputDiagnostics;
|
|
74
106
|
private disposed;
|
|
75
107
|
constructor(args: ToolPolicyEngineArgs);
|
|
76
108
|
/**
|
|
@@ -87,10 +119,38 @@ export declare class ToolPolicyEngine {
|
|
|
87
119
|
* values even though the policy decision itself is identical.
|
|
88
120
|
* Hosts that want timestamp-stable provenance should reuse a
|
|
89
121
|
* cached `ToolPolicyDecision` rather than re-call `decide(...)`.
|
|
122
|
+
*
|
|
123
|
+
* An item's registered settings apply to the item's own toolbar: a request
|
|
124
|
+
* at item level whose scope is the item. Every other request — a section,
|
|
125
|
+
* assessment or passage toolbar — is shared by the items it sits beside, so
|
|
126
|
+
* it leaves every item's settings out and reports each tool on its toolbar
|
|
127
|
+
* that one restricts or requires as `tool-policy.itemSettingNotApplied`.
|
|
90
128
|
*/
|
|
91
129
|
decide(request: ToolPolicyDecisionRequest): ToolPolicyDecision;
|
|
92
130
|
/**
|
|
93
|
-
*
|
|
131
|
+
* Whether some surface is granted `featureId`: a decision with no item scope,
|
|
132
|
+
* or one scoped to a registered item. A provider serves every surface, so its
|
|
133
|
+
* failure denies the accommodation wherever one surface is granted it.
|
|
134
|
+
*
|
|
135
|
+
* `enforced` counts only scopes whose `pnpEnforcement` is on, as a toolbar
|
|
136
|
+
* tool's decisions do; a feature with no placement leaves it unset.
|
|
137
|
+
*/
|
|
138
|
+
grantsFeatureAnywhere(featureId: string, options?: {
|
|
139
|
+
enforced?: boolean;
|
|
140
|
+
}): boolean;
|
|
141
|
+
/**
|
|
142
|
+
* File a mounted item's settings under its canonical id. They govern the
|
|
143
|
+
* decisions scoped to that item: its own toolbar, and a feature its content
|
|
144
|
+
* asks about with the item's scope. See {@link decide}.
|
|
145
|
+
*
|
|
146
|
+
* The same item mounted twice registers twice; the newest registration
|
|
147
|
+
* applies, and its cleanup hands the item back to the one before. Emits an
|
|
148
|
+
* `"item-settings"` change whenever the settings that apply to the item
|
|
149
|
+
* change.
|
|
150
|
+
*/
|
|
151
|
+
registerItemSettings(itemId: string, settings: ItemSettings): () => void;
|
|
152
|
+
/**
|
|
153
|
+
* Resolve eligibility for one PNP/AfA feature id through the eight-level
|
|
94
154
|
* precedence, independent of toolbar placement.
|
|
95
155
|
*
|
|
96
156
|
* For capabilities that render as their own surface rather than a toolbar
|
|
@@ -111,8 +171,11 @@ export declare class ToolPolicyEngine {
|
|
|
111
171
|
* The decision reports whether an assessment was bound, which is the engine's
|
|
112
172
|
* to answer rather than the policy source's — see
|
|
113
173
|
* {@link FeaturePolicyDecision.assessmentBound}.
|
|
174
|
+
*
|
|
175
|
+
* `scope` is the surface asking. An item's scope brings in the item's
|
|
176
|
+
* registered settings, as {@link decide} does for the item's toolbar.
|
|
114
177
|
*/
|
|
115
|
-
decideFeature(featureId:
|
|
178
|
+
decideFeature<K extends string>(featureId: K, scope?: ToolScope): FeaturePolicyDecision<ToolParametersFor<K>>;
|
|
116
179
|
/**
|
|
117
180
|
* The host gates that hold for a feature id, or `null` when none fires.
|
|
118
181
|
*
|
|
@@ -133,17 +196,14 @@ export declare class ToolPolicyEngine {
|
|
|
133
196
|
/**
|
|
134
197
|
* Apply a partial input update.
|
|
135
198
|
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
* `PieAssessmentToolkit.svelte`'s prop-forwarding effect and by the
|
|
141
|
-
* coordinator's `decideToolPolicy()` tests.
|
|
199
|
+
* A key that did not change does not fire `onPolicyChange` listeners.
|
|
200
|
+
* `tools` is diffed with `Object.is`. `assessment` is diffed structurally,
|
|
201
|
+
* because hosts rebuild it from their own state on every render; the latest
|
|
202
|
+
* reference is stored either way.
|
|
142
203
|
*
|
|
143
|
-
* `pnpEnforcement`
|
|
144
|
-
* a distinct `"pnp-enforcement"` reason when no
|
|
145
|
-
*
|
|
146
|
-
* event channel.
|
|
204
|
+
* `pnpEnforcement` sets the override, `null` or `undefined` returning to
|
|
205
|
+
* auto-mode, and emits with a distinct `"pnp-enforcement"` reason when no
|
|
206
|
+
* other key changed.
|
|
147
207
|
*/
|
|
148
208
|
updateInputs(patch: Partial<ToolPolicyEngineInputs>): void;
|
|
149
209
|
/**
|
|
@@ -157,6 +217,30 @@ export declare class ToolPolicyEngine {
|
|
|
157
217
|
getInputs(): Readonly<ResolvedEngineInputs>;
|
|
158
218
|
dispose(): void;
|
|
159
219
|
private snapshotInputs;
|
|
220
|
+
/** The override, else auto-mode over the assessment and `item`'s settings. */
|
|
221
|
+
private enforcementFor;
|
|
222
|
+
/** The settings that apply to `itemId`: its newest registration's. */
|
|
223
|
+
private itemSettingsFor;
|
|
224
|
+
private emitIfItemSettingsChanged;
|
|
225
|
+
/**
|
|
226
|
+
* Recompute {@link ResolvedEngineInputs.diagnostics} from the bound
|
|
227
|
+
* assessment, every mounted item's settings and the registry. Returns
|
|
228
|
+
* whether they changed.
|
|
229
|
+
*/
|
|
230
|
+
private refreshInputDiagnostics;
|
|
231
|
+
/**
|
|
232
|
+
* Registering a tool into the bound registry, or removing one, can make a
|
|
233
|
+
* named id known or unknown, so it emits an `"inputs"` change when the input
|
|
234
|
+
* diagnostics move.
|
|
235
|
+
*/
|
|
236
|
+
private watchRegistry;
|
|
237
|
+
/**
|
|
238
|
+
* The registered item an item scope names, by its canonical id. A scope
|
|
239
|
+
* of any other level names none.
|
|
240
|
+
*/
|
|
241
|
+
private itemForScope;
|
|
242
|
+
/** The registered items whose settings their own toolbar enforces. */
|
|
243
|
+
private enforcedItems;
|
|
160
244
|
private emit;
|
|
161
245
|
private assertNotDisposed;
|
|
162
246
|
}
|