@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
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cross-Custom-Element context for the section runtime engine (M7 PR 6).
|
|
3
|
-
*
|
|
4
|
-
* The toolkit CE renders inside its own Shadow DOM, so Svelte's native
|
|
5
|
-
* `setContext`/`getContext` (used by `engine-context.ts`) cannot bridge
|
|
6
|
-
* the kernel-provided engine reference to the toolkit's component tree.
|
|
7
|
-
* This module exposes a `@pie-players/pie-context` based context that
|
|
8
|
-
* does cross the CE boundary via DOM events:
|
|
9
|
-
*
|
|
10
|
-
* - The kernel (`SectionPlayerLayoutKernel.svelte`) installs a
|
|
11
|
-
* `ContextProvider` for `sectionRuntimeEngineHostContext` on its
|
|
12
|
-
* `host` (the layout CE). The provider value carries a narrow
|
|
13
|
-
* lifecycle handle for the engine owned by that kernel mount.
|
|
14
|
-
* - The toolkit CE installs a `ContextConsumer` on its own host. When
|
|
15
|
-
* wrapped by a section player layout, the consumer resolves to the
|
|
16
|
-
* kernel's lifecycle handle and suppresses its standalone lifecycle
|
|
17
|
-
* DOM emits in favor of the section-player host. Controller-side
|
|
18
|
-
* calls (`register`, `handleContent*`, `initialize`, etc.) remain
|
|
19
|
-
* owned by the toolkit's locally-constructed engine. When
|
|
20
|
-
* standalone, no host provider responds and the toolkit keeps using
|
|
21
|
-
* its standalone lifecycle path.
|
|
22
|
-
*
|
|
23
|
-
* The two engine-context surfaces (`SECTION_RUNTIME_ENGINE_KEY` and
|
|
24
|
-
* this one) are deliberately distinct:
|
|
25
|
-
* - `SECTION_RUNTIME_ENGINE_KEY` (Svelte context) stays scoped to a
|
|
26
|
-
* single component tree (kernel + descendants in the same shadow
|
|
27
|
-
* root) and is the right hook for in-tree consumers.
|
|
28
|
-
* - `sectionRuntimeEngineHostContext` (DOM-event context) is the
|
|
29
|
-
* bridge for cross-CE consumers and only carries data that is safe
|
|
30
|
-
* to share across CE boundaries (a stable lifecycle handle).
|
|
31
|
-
*
|
|
32
|
-
* **Stability.** This export is part of the stable runtime/engine
|
|
33
|
-
* surface; the symbol identity and value shape are part of the
|
|
34
|
-
* cross-CE contract. Renaming or replacing the symbol is a major
|
|
35
|
-
* breaking change. Adding optional fields to the value shape is
|
|
36
|
-
* allowed; required fields are not.
|
|
37
|
-
*/
|
|
38
|
-
/**
|
|
39
|
-
* Narrow cross-CE handle published by section-player. Deliberately omits
|
|
40
|
-
* controller-facing methods (`initialize`, `register`, `handleContent*`,
|
|
41
|
-
* etc.) so the package seam cannot grow an accidental controller contract.
|
|
42
|
-
*/
|
|
43
|
-
export interface SectionRuntimeLifecycleHandle {
|
|
44
|
-
getRuntimeId(): string;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Value shape published by the kernel and consumed by the wrapped
|
|
48
|
-
* toolkit CE. Carries only the lifecycle handle today; if more cross-CE
|
|
49
|
-
* shared runtime state is needed later, fields can be added here
|
|
50
|
-
* additively.
|
|
51
|
-
*/
|
|
52
|
-
export interface SectionRuntimeEngineHostContextValue {
|
|
53
|
-
engine: SectionRuntimeLifecycleHandle;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* `pie-context` context key for the cross-CE engine bridge. Uses a
|
|
57
|
-
* `Symbol.for(...)` registry key so providers and consumers in
|
|
58
|
-
* separately-bundled CEs see the same identity.
|
|
59
|
-
*/
|
|
60
|
-
export declare const sectionRuntimeEngineHostContext: {
|
|
61
|
-
__context__: SectionRuntimeEngineHostContextValue;
|
|
62
|
-
};
|
|
63
|
-
export type SectionRuntimeEngineHostContextListener = (value: SectionRuntimeEngineHostContextValue) => void;
|
|
64
|
-
/**
|
|
65
|
-
* Connect a DOM host to the cross-CE engine context through
|
|
66
|
-
* `connectContextWithRetry`, the provider-retry the toolkit's other
|
|
67
|
-
* contexts use.
|
|
68
|
-
*
|
|
69
|
-
* Returns a cleanup function that disconnects the consumer and clears
|
|
70
|
-
* the retry interval. Standalone toolkits naturally exhaust the retry
|
|
71
|
-
* window without ever resolving and continue using their local
|
|
72
|
-
* engine — that is by design and is not an error.
|
|
73
|
-
*/
|
|
74
|
-
export declare function connectSectionRuntimeEngineHostContext(host: HTMLElement, onValue: SectionRuntimeEngineHostContextListener): () => void;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cross-Custom-Element context for the section runtime engine (M7 PR 6).
|
|
3
|
-
*
|
|
4
|
-
* The toolkit CE renders inside its own Shadow DOM, so Svelte's native
|
|
5
|
-
* `setContext`/`getContext` (used by `engine-context.ts`) cannot bridge
|
|
6
|
-
* the kernel-provided engine reference to the toolkit's component tree.
|
|
7
|
-
* This module exposes a `@pie-players/pie-context` based context that
|
|
8
|
-
* does cross the CE boundary via DOM events:
|
|
9
|
-
*
|
|
10
|
-
* - The kernel (`SectionPlayerLayoutKernel.svelte`) installs a
|
|
11
|
-
* `ContextProvider` for `sectionRuntimeEngineHostContext` on its
|
|
12
|
-
* `host` (the layout CE). The provider value carries a narrow
|
|
13
|
-
* lifecycle handle for the engine owned by that kernel mount.
|
|
14
|
-
* - The toolkit CE installs a `ContextConsumer` on its own host. When
|
|
15
|
-
* wrapped by a section player layout, the consumer resolves to the
|
|
16
|
-
* kernel's lifecycle handle and suppresses its standalone lifecycle
|
|
17
|
-
* DOM emits in favor of the section-player host. Controller-side
|
|
18
|
-
* calls (`register`, `handleContent*`, `initialize`, etc.) remain
|
|
19
|
-
* owned by the toolkit's locally-constructed engine. When
|
|
20
|
-
* standalone, no host provider responds and the toolkit keeps using
|
|
21
|
-
* its standalone lifecycle path.
|
|
22
|
-
*
|
|
23
|
-
* The two engine-context surfaces (`SECTION_RUNTIME_ENGINE_KEY` and
|
|
24
|
-
* this one) are deliberately distinct:
|
|
25
|
-
* - `SECTION_RUNTIME_ENGINE_KEY` (Svelte context) stays scoped to a
|
|
26
|
-
* single component tree (kernel + descendants in the same shadow
|
|
27
|
-
* root) and is the right hook for in-tree consumers.
|
|
28
|
-
* - `sectionRuntimeEngineHostContext` (DOM-event context) is the
|
|
29
|
-
* bridge for cross-CE consumers and only carries data that is safe
|
|
30
|
-
* to share across CE boundaries (a stable lifecycle handle).
|
|
31
|
-
*
|
|
32
|
-
* **Stability.** This export is part of the stable runtime/engine
|
|
33
|
-
* surface; the symbol identity and value shape are part of the
|
|
34
|
-
* cross-CE contract. Renaming or replacing the symbol is a major
|
|
35
|
-
* breaking change. Adding optional fields to the value shape is
|
|
36
|
-
* allowed; required fields are not.
|
|
37
|
-
*/
|
|
38
|
-
import { connectContextWithRetry, createContext, } from "@pie-players/pie-context";
|
|
39
|
-
/**
|
|
40
|
-
* `pie-context` context key for the cross-CE engine bridge. Uses a
|
|
41
|
-
* `Symbol.for(...)` registry key so providers and consumers in
|
|
42
|
-
* separately-bundled CEs see the same identity.
|
|
43
|
-
*/
|
|
44
|
-
export const sectionRuntimeEngineHostContext = createContext(Symbol.for("pie.sectionRuntimeEngineHostContext"));
|
|
45
|
-
/**
|
|
46
|
-
* Connect a DOM host to the cross-CE engine context through
|
|
47
|
-
* `connectContextWithRetry`, the provider-retry the toolkit's other
|
|
48
|
-
* contexts use.
|
|
49
|
-
*
|
|
50
|
-
* Returns a cleanup function that disconnects the consumer and clears
|
|
51
|
-
* the retry interval. Standalone toolkits naturally exhaust the retry
|
|
52
|
-
* window without ever resolving and continue using their local
|
|
53
|
-
* engine — that is by design and is not an error.
|
|
54
|
-
*/
|
|
55
|
-
export function connectSectionRuntimeEngineHostContext(host, onValue) {
|
|
56
|
-
return connectContextWithRetry(host, sectionRuntimeEngineHostContext, onValue);
|
|
57
|
-
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Stage-emit suppression gate (M7 PR 6).
|
|
3
|
-
*
|
|
4
|
-
* `PieAssessmentToolkit.svelte` builds a `createStageTracker(...)` whose
|
|
5
|
-
* `emit` callback dispatches the toolkit CE's `pie-stage-change` DOM
|
|
6
|
-
* event and invokes the runtime-tier `onStageChange` callback. PR 6
|
|
7
|
-
* introduces the wrapped/standalone branch:
|
|
8
|
-
*
|
|
9
|
-
* - **Standalone** (no host lifecycle provider on
|
|
10
|
-
* the layout CE host): emit + `onStageChange` fire as before.
|
|
11
|
-
* - **Wrapped** (kernel publishes its lifecycle handle via
|
|
12
|
-
* `sectionRuntimeEngineHostContext` and the toolkit consumer
|
|
13
|
-
* resolves it): emit + `onStageChange` are suppressed on the
|
|
14
|
-
* toolkit CE, because the kernel's engine already emits the
|
|
15
|
-
* canonical `pie-stage-change` chain on the layout CE host and
|
|
16
|
-
* invokes the runtime-tier callback. Without suppression the
|
|
17
|
-
* toolkit CE would also dispatch its own event, which bubbles
|
|
18
|
-
* through `composed: true` to the layout CE host and produces a
|
|
19
|
-
* duplicate emission for outside listeners.
|
|
20
|
-
*
|
|
21
|
-
* The internal `stageTracker` latch state advances **before** this
|
|
22
|
-
* helper is reached (the latch is updated inside
|
|
23
|
-
* `createStageTracker.enter` prior to `opts.emit(...)`), so suppression
|
|
24
|
-
* here only short-circuits the externally-visible side effects. The
|
|
25
|
-
* toolkit's own readiness path (`waitUntilReady` / `engine-ready` /
|
|
26
|
-
* `interactive`) keeps working in standalone mode and degenerates into
|
|
27
|
-
* a series of suppressed emits in wrapped mode without losing any
|
|
28
|
-
* latch transitions.
|
|
29
|
-
*
|
|
30
|
-
* Splitting this helper out of the inline `emit:` closure in
|
|
31
|
-
* `PieAssessmentToolkit.svelte` lets us pin the suppression branch in a
|
|
32
|
-
* unit test without mounting the toolkit CE — see
|
|
33
|
-
* `tests/runtime/stage-emit-gate.test.ts`. The closure in the toolkit
|
|
34
|
-
* passes thunks for `isSuppressed` and `getOnStageChange` so the live
|
|
35
|
-
* Svelte reactive variables (`hostLifecycleEngine`, `onStageChange`) are
|
|
36
|
-
* read at emit time, not captured at construction time. This keeps the
|
|
37
|
-
* pre-PR-6 behavior of always reading the latest `onStageChange` prop
|
|
38
|
-
* value (cohort change, host swap, etc.) intact.
|
|
39
|
-
*
|
|
40
|
-
* NOT a public surface: this helper is internal to the toolkit and is
|
|
41
|
-
* not exported from `runtime/engine.ts`. It only exists to make the
|
|
42
|
-
* gate testable.
|
|
43
|
-
*/
|
|
44
|
-
import type { StageChangeDetail } from "@pie-players/pie-players-shared/pie";
|
|
45
|
-
export type StageOnChangeHandler = (detail: StageChangeDetail) => void;
|
|
46
|
-
export interface StageEmitGateContext {
|
|
47
|
-
/**
|
|
48
|
-
* Reads the current suppression flag. Implemented as a thunk so
|
|
49
|
-
* the reactive Svelte `$state(hostLifecycleEngine)` is read at emit
|
|
50
|
-
* time. Return `true` to suppress; `false` to fire.
|
|
51
|
-
*/
|
|
52
|
-
isSuppressed: () => boolean;
|
|
53
|
-
/**
|
|
54
|
-
* Dispatches the `pie-stage-change` DOM event on the toolkit's
|
|
55
|
-
* CE host. In `PieAssessmentToolkit.svelte` this is the
|
|
56
|
-
* Svelte-generated `emit("pie-stage-change", detail)` helper.
|
|
57
|
-
*/
|
|
58
|
-
dispatchDomEvent: (detail: StageChangeDetail) => void;
|
|
59
|
-
/**
|
|
60
|
-
* Reads the current `onStageChange` runtime-tier callback. Thunk
|
|
61
|
-
* so the latest reassigned handler is invoked, not whichever
|
|
62
|
-
* handler was current at construction time.
|
|
63
|
-
*/
|
|
64
|
-
getOnStageChange: () => StageOnChangeHandler | null | undefined;
|
|
65
|
-
/**
|
|
66
|
-
* Optional logger for handler errors. Defaults to `console.error`
|
|
67
|
-
* with the same prefix the toolkit used pre-PR-6 so test output
|
|
68
|
-
* matches production logs.
|
|
69
|
-
*/
|
|
70
|
-
logHandlerError?: (error: unknown) => void;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Run the toolkit's stage emit pipeline with the suppression gate
|
|
74
|
-
* applied.
|
|
75
|
-
*
|
|
76
|
-
* - When `isSuppressed()` returns `true`, the helper returns
|
|
77
|
-
* immediately with neither side effect.
|
|
78
|
-
* - Otherwise it dispatches the `pie-stage-change` DOM event first,
|
|
79
|
-
* then invokes `onStageChange(detail)` (preserving the
|
|
80
|
-
* "DOM-event-then-callback" ordering pre-PR-6 consumers depend
|
|
81
|
-
* on).
|
|
82
|
-
* - A throwing `onStageChange` handler does not interrupt the DOM
|
|
83
|
-
* event (already fired) and does not propagate up to
|
|
84
|
-
* `stageTracker.enter` (latch state already advanced); the error
|
|
85
|
-
* is logged and swallowed, matching pre-PR-6 behavior.
|
|
86
|
-
*
|
|
87
|
-
* Returns `true` if the emit pipeline ran (i.e. it was not
|
|
88
|
-
* suppressed); `false` if it was suppressed. Tests use the return
|
|
89
|
-
* value to assert the gate's decision in isolation from the side
|
|
90
|
-
* effects.
|
|
91
|
-
*/
|
|
92
|
-
export declare function runStageEmitWithSuppression(context: StageEmitGateContext, detail: StageChangeDetail): boolean;
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Stage-emit suppression gate (M7 PR 6).
|
|
3
|
-
*
|
|
4
|
-
* `PieAssessmentToolkit.svelte` builds a `createStageTracker(...)` whose
|
|
5
|
-
* `emit` callback dispatches the toolkit CE's `pie-stage-change` DOM
|
|
6
|
-
* event and invokes the runtime-tier `onStageChange` callback. PR 6
|
|
7
|
-
* introduces the wrapped/standalone branch:
|
|
8
|
-
*
|
|
9
|
-
* - **Standalone** (no host lifecycle provider on
|
|
10
|
-
* the layout CE host): emit + `onStageChange` fire as before.
|
|
11
|
-
* - **Wrapped** (kernel publishes its lifecycle handle via
|
|
12
|
-
* `sectionRuntimeEngineHostContext` and the toolkit consumer
|
|
13
|
-
* resolves it): emit + `onStageChange` are suppressed on the
|
|
14
|
-
* toolkit CE, because the kernel's engine already emits the
|
|
15
|
-
* canonical `pie-stage-change` chain on the layout CE host and
|
|
16
|
-
* invokes the runtime-tier callback. Without suppression the
|
|
17
|
-
* toolkit CE would also dispatch its own event, which bubbles
|
|
18
|
-
* through `composed: true` to the layout CE host and produces a
|
|
19
|
-
* duplicate emission for outside listeners.
|
|
20
|
-
*
|
|
21
|
-
* The internal `stageTracker` latch state advances **before** this
|
|
22
|
-
* helper is reached (the latch is updated inside
|
|
23
|
-
* `createStageTracker.enter` prior to `opts.emit(...)`), so suppression
|
|
24
|
-
* here only short-circuits the externally-visible side effects. The
|
|
25
|
-
* toolkit's own readiness path (`waitUntilReady` / `engine-ready` /
|
|
26
|
-
* `interactive`) keeps working in standalone mode and degenerates into
|
|
27
|
-
* a series of suppressed emits in wrapped mode without losing any
|
|
28
|
-
* latch transitions.
|
|
29
|
-
*
|
|
30
|
-
* Splitting this helper out of the inline `emit:` closure in
|
|
31
|
-
* `PieAssessmentToolkit.svelte` lets us pin the suppression branch in a
|
|
32
|
-
* unit test without mounting the toolkit CE — see
|
|
33
|
-
* `tests/runtime/stage-emit-gate.test.ts`. The closure in the toolkit
|
|
34
|
-
* passes thunks for `isSuppressed` and `getOnStageChange` so the live
|
|
35
|
-
* Svelte reactive variables (`hostLifecycleEngine`, `onStageChange`) are
|
|
36
|
-
* read at emit time, not captured at construction time. This keeps the
|
|
37
|
-
* pre-PR-6 behavior of always reading the latest `onStageChange` prop
|
|
38
|
-
* value (cohort change, host swap, etc.) intact.
|
|
39
|
-
*
|
|
40
|
-
* NOT a public surface: this helper is internal to the toolkit and is
|
|
41
|
-
* not exported from `runtime/engine.ts`. It only exists to make the
|
|
42
|
-
* gate testable.
|
|
43
|
-
*/
|
|
44
|
-
const defaultLogHandlerError = (error) => {
|
|
45
|
-
console.error("[pie-assessment-toolkit] onStageChange handler threw", error);
|
|
46
|
-
};
|
|
47
|
-
/**
|
|
48
|
-
* Run the toolkit's stage emit pipeline with the suppression gate
|
|
49
|
-
* applied.
|
|
50
|
-
*
|
|
51
|
-
* - When `isSuppressed()` returns `true`, the helper returns
|
|
52
|
-
* immediately with neither side effect.
|
|
53
|
-
* - Otherwise it dispatches the `pie-stage-change` DOM event first,
|
|
54
|
-
* then invokes `onStageChange(detail)` (preserving the
|
|
55
|
-
* "DOM-event-then-callback" ordering pre-PR-6 consumers depend
|
|
56
|
-
* on).
|
|
57
|
-
* - A throwing `onStageChange` handler does not interrupt the DOM
|
|
58
|
-
* event (already fired) and does not propagate up to
|
|
59
|
-
* `stageTracker.enter` (latch state already advanced); the error
|
|
60
|
-
* is logged and swallowed, matching pre-PR-6 behavior.
|
|
61
|
-
*
|
|
62
|
-
* Returns `true` if the emit pipeline ran (i.e. it was not
|
|
63
|
-
* suppressed); `false` if it was suppressed. Tests use the return
|
|
64
|
-
* value to assert the gate's decision in isolation from the side
|
|
65
|
-
* effects.
|
|
66
|
-
*/
|
|
67
|
-
export function runStageEmitWithSuppression(context, detail) {
|
|
68
|
-
if (context.isSuppressed()) {
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
context.dispatchDomEvent(detail);
|
|
72
|
-
const handler = context.getOnStageChange();
|
|
73
|
-
if (handler) {
|
|
74
|
-
try {
|
|
75
|
-
handler(detail);
|
|
76
|
-
}
|
|
77
|
-
catch (error) {
|
|
78
|
-
(context.logHandlerError ?? defaultLogHandlerError)(error);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return true;
|
|
82
|
-
}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Context Variable Store
|
|
3
|
-
*
|
|
4
|
-
* Standalone service for managing QTI 3.0 context variables.
|
|
5
|
-
* Context variables are global assessment-level variables that can be
|
|
6
|
-
* shared across items.
|
|
7
|
-
*
|
|
8
|
-
* Can be used independently by any assessment player without requiring
|
|
9
|
-
* the full AssessmentPlayer.
|
|
10
|
-
*
|
|
11
|
-
* Part of PIE Assessment Toolkit.
|
|
12
|
-
*/
|
|
13
|
-
import type { ContextDeclaration } from "@pie-players/pie-players-shared/types";
|
|
14
|
-
/**
|
|
15
|
-
* Standalone service for managing QTI 3.0 context variables.
|
|
16
|
-
*
|
|
17
|
-
* Context variables are global assessment-level variables that can be
|
|
18
|
-
* shared across items. Can be used independently by any assessment player.
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```typescript
|
|
22
|
-
* // Initialize with declarations
|
|
23
|
-
* const store = new ContextVariableStore(declarations);
|
|
24
|
-
*
|
|
25
|
-
* // Get/set variables
|
|
26
|
-
* const seed = store.get('RANDOM_SEED');
|
|
27
|
-
* store.set('DIFFICULTY_LEVEL', 'hard');
|
|
28
|
-
*
|
|
29
|
-
* // Pass to items
|
|
30
|
-
* const context = store.toObject();
|
|
31
|
-
* await renderItem(item, session, context);
|
|
32
|
-
*
|
|
33
|
-
* // Persist in session
|
|
34
|
-
* session.contextVariables = store.toObject();
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
export declare class ContextVariableStore {
|
|
38
|
-
private variables;
|
|
39
|
-
private declarations;
|
|
40
|
-
/**
|
|
41
|
-
* Initialize store with context declarations from assessment
|
|
42
|
-
*
|
|
43
|
-
* @param declarations QTI 3.0 context declarations
|
|
44
|
-
*/
|
|
45
|
-
constructor(declarations?: ContextDeclaration[]);
|
|
46
|
-
/**
|
|
47
|
-
* Initialize context variables from declarations
|
|
48
|
-
*
|
|
49
|
-
* Sets each variable to its defaultValue or type-appropriate default.
|
|
50
|
-
*/
|
|
51
|
-
initialize(declarations: ContextDeclaration[]): void;
|
|
52
|
-
/**
|
|
53
|
-
* Get context variable value
|
|
54
|
-
*
|
|
55
|
-
* @param identifier Variable identifier
|
|
56
|
-
* @returns Variable value or undefined if not found
|
|
57
|
-
*/
|
|
58
|
-
get(identifier: string): any;
|
|
59
|
-
/**
|
|
60
|
-
* Set context variable value
|
|
61
|
-
*
|
|
62
|
-
* @param identifier Variable identifier
|
|
63
|
-
* @param value New value
|
|
64
|
-
*/
|
|
65
|
-
set(identifier: string, value: any): void;
|
|
66
|
-
/**
|
|
67
|
-
* Check if variable exists
|
|
68
|
-
*/
|
|
69
|
-
has(identifier: string): boolean;
|
|
70
|
-
/**
|
|
71
|
-
* Get all variable names
|
|
72
|
-
*/
|
|
73
|
-
getIdentifiers(): string[];
|
|
74
|
-
/**
|
|
75
|
-
* Get all variables as object (for passing to PIE elements)
|
|
76
|
-
*
|
|
77
|
-
* @returns Plain object with all context variables
|
|
78
|
-
*/
|
|
79
|
-
toObject(): Record<string, any>;
|
|
80
|
-
/**
|
|
81
|
-
* Load state from serialized object (for session restore)
|
|
82
|
-
*
|
|
83
|
-
* @param state Object containing context variable values
|
|
84
|
-
*/
|
|
85
|
-
fromObject(state: Record<string, any>): void;
|
|
86
|
-
/**
|
|
87
|
-
* Clear all variables (reset to defaults)
|
|
88
|
-
*/
|
|
89
|
-
reset(): void;
|
|
90
|
-
/**
|
|
91
|
-
* Get declaration for variable
|
|
92
|
-
*
|
|
93
|
-
* @param identifier Variable identifier
|
|
94
|
-
* @returns Declaration or undefined if not found
|
|
95
|
-
*/
|
|
96
|
-
getDeclaration(identifier: string): ContextDeclaration | undefined;
|
|
97
|
-
/**
|
|
98
|
-
* Get all declarations
|
|
99
|
-
*/
|
|
100
|
-
getDeclarations(): ContextDeclaration[];
|
|
101
|
-
/**
|
|
102
|
-
* Get default value for QTI base type
|
|
103
|
-
*
|
|
104
|
-
* @private
|
|
105
|
-
*/
|
|
106
|
-
private getDefaultValueForType;
|
|
107
|
-
/**
|
|
108
|
-
* Validate value matches declared type (basic validation)
|
|
109
|
-
*
|
|
110
|
-
* @private
|
|
111
|
-
*/
|
|
112
|
-
private validateValue;
|
|
113
|
-
}
|
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Context Variable Store
|
|
3
|
-
*
|
|
4
|
-
* Standalone service for managing QTI 3.0 context variables.
|
|
5
|
-
* Context variables are global assessment-level variables that can be
|
|
6
|
-
* shared across items.
|
|
7
|
-
*
|
|
8
|
-
* Can be used independently by any assessment player without requiring
|
|
9
|
-
* the full AssessmentPlayer.
|
|
10
|
-
*
|
|
11
|
-
* Part of PIE Assessment Toolkit.
|
|
12
|
-
*/
|
|
13
|
-
/**
|
|
14
|
-
* Standalone service for managing QTI 3.0 context variables.
|
|
15
|
-
*
|
|
16
|
-
* Context variables are global assessment-level variables that can be
|
|
17
|
-
* shared across items. Can be used independently by any assessment player.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```typescript
|
|
21
|
-
* // Initialize with declarations
|
|
22
|
-
* const store = new ContextVariableStore(declarations);
|
|
23
|
-
*
|
|
24
|
-
* // Get/set variables
|
|
25
|
-
* const seed = store.get('RANDOM_SEED');
|
|
26
|
-
* store.set('DIFFICULTY_LEVEL', 'hard');
|
|
27
|
-
*
|
|
28
|
-
* // Pass to items
|
|
29
|
-
* const context = store.toObject();
|
|
30
|
-
* await renderItem(item, session, context);
|
|
31
|
-
*
|
|
32
|
-
* // Persist in session
|
|
33
|
-
* session.contextVariables = store.toObject();
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
|
-
export class ContextVariableStore {
|
|
37
|
-
variables = new Map();
|
|
38
|
-
declarations = new Map();
|
|
39
|
-
/**
|
|
40
|
-
* Initialize store with context declarations from assessment
|
|
41
|
-
*
|
|
42
|
-
* @param declarations QTI 3.0 context declarations
|
|
43
|
-
*/
|
|
44
|
-
constructor(declarations) {
|
|
45
|
-
if (declarations) {
|
|
46
|
-
this.initialize(declarations);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Initialize context variables from declarations
|
|
51
|
-
*
|
|
52
|
-
* Sets each variable to its defaultValue or type-appropriate default.
|
|
53
|
-
*/
|
|
54
|
-
initialize(declarations) {
|
|
55
|
-
this.declarations.clear();
|
|
56
|
-
this.variables.clear();
|
|
57
|
-
for (const decl of declarations) {
|
|
58
|
-
this.declarations.set(decl.identifier, decl);
|
|
59
|
-
const value = decl.defaultValue ??
|
|
60
|
-
this.getDefaultValueForType(decl.baseType, decl.cardinality);
|
|
61
|
-
this.variables.set(decl.identifier, value);
|
|
62
|
-
}
|
|
63
|
-
console.debug(`ContextVariableStore: Initialized ${declarations.length} context variables:`, Array.from(this.variables.keys()));
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Get context variable value
|
|
67
|
-
*
|
|
68
|
-
* @param identifier Variable identifier
|
|
69
|
-
* @returns Variable value or undefined if not found
|
|
70
|
-
*/
|
|
71
|
-
get(identifier) {
|
|
72
|
-
return this.variables.get(identifier);
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Set context variable value
|
|
76
|
-
*
|
|
77
|
-
* @param identifier Variable identifier
|
|
78
|
-
* @param value New value
|
|
79
|
-
*/
|
|
80
|
-
set(identifier, value) {
|
|
81
|
-
if (!this.declarations.has(identifier)) {
|
|
82
|
-
console.warn(`ContextVariableStore: Setting undeclared context variable: ${identifier}`, "Consider declaring it in contextDeclarations");
|
|
83
|
-
}
|
|
84
|
-
// Type validation (optional but recommended)
|
|
85
|
-
const decl = this.declarations.get(identifier);
|
|
86
|
-
if (decl) {
|
|
87
|
-
this.validateValue(decl, value);
|
|
88
|
-
}
|
|
89
|
-
this.variables.set(identifier, value);
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Check if variable exists
|
|
93
|
-
*/
|
|
94
|
-
has(identifier) {
|
|
95
|
-
return this.variables.has(identifier);
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Get all variable names
|
|
99
|
-
*/
|
|
100
|
-
getIdentifiers() {
|
|
101
|
-
return Array.from(this.variables.keys());
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Get all variables as object (for passing to PIE elements)
|
|
105
|
-
*
|
|
106
|
-
* @returns Plain object with all context variables
|
|
107
|
-
*/
|
|
108
|
-
toObject() {
|
|
109
|
-
return Object.fromEntries(this.variables);
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Load state from serialized object (for session restore)
|
|
113
|
-
*
|
|
114
|
-
* @param state Object containing context variable values
|
|
115
|
-
*/
|
|
116
|
-
fromObject(state) {
|
|
117
|
-
for (const [key, value] of Object.entries(state)) {
|
|
118
|
-
this.variables.set(key, value);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Clear all variables (reset to defaults)
|
|
123
|
-
*/
|
|
124
|
-
reset() {
|
|
125
|
-
for (const [identifier, decl] of this.declarations) {
|
|
126
|
-
const value = decl.defaultValue ??
|
|
127
|
-
this.getDefaultValueForType(decl.baseType, decl.cardinality);
|
|
128
|
-
this.variables.set(identifier, value);
|
|
129
|
-
}
|
|
130
|
-
console.debug("ContextVariableStore: Reset to default values");
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Get declaration for variable
|
|
134
|
-
*
|
|
135
|
-
* @param identifier Variable identifier
|
|
136
|
-
* @returns Declaration or undefined if not found
|
|
137
|
-
*/
|
|
138
|
-
getDeclaration(identifier) {
|
|
139
|
-
return this.declarations.get(identifier);
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Get all declarations
|
|
143
|
-
*/
|
|
144
|
-
getDeclarations() {
|
|
145
|
-
return Array.from(this.declarations.values());
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Get default value for QTI base type
|
|
149
|
-
*
|
|
150
|
-
* @private
|
|
151
|
-
*/
|
|
152
|
-
getDefaultValueForType(baseType, cardinality) {
|
|
153
|
-
if (cardinality === "multiple" || cardinality === "ordered") {
|
|
154
|
-
return [];
|
|
155
|
-
}
|
|
156
|
-
if (cardinality === "record") {
|
|
157
|
-
return {};
|
|
158
|
-
}
|
|
159
|
-
// Single cardinality defaults
|
|
160
|
-
switch (baseType) {
|
|
161
|
-
case "boolean":
|
|
162
|
-
return false;
|
|
163
|
-
case "integer":
|
|
164
|
-
return 0;
|
|
165
|
-
case "float":
|
|
166
|
-
return 0.0;
|
|
167
|
-
case "string":
|
|
168
|
-
case "identifier":
|
|
169
|
-
case "uri":
|
|
170
|
-
return "";
|
|
171
|
-
case "point":
|
|
172
|
-
return [0, 0];
|
|
173
|
-
case "pair":
|
|
174
|
-
return ["", ""];
|
|
175
|
-
case "directedPair":
|
|
176
|
-
return ["", ""];
|
|
177
|
-
case "duration":
|
|
178
|
-
return 0;
|
|
179
|
-
case "file":
|
|
180
|
-
return null;
|
|
181
|
-
default:
|
|
182
|
-
return null;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* Validate value matches declared type (basic validation)
|
|
187
|
-
*
|
|
188
|
-
* @private
|
|
189
|
-
*/
|
|
190
|
-
validateValue(decl, value) {
|
|
191
|
-
// Basic type checking - can be extended
|
|
192
|
-
if (decl.baseType === "integer" && !Number.isInteger(value)) {
|
|
193
|
-
console.warn(`ContextVariableStore: Variable ${decl.identifier} expects integer, got:`, typeof value);
|
|
194
|
-
}
|
|
195
|
-
if (decl.baseType === "float" && typeof value !== "number") {
|
|
196
|
-
console.warn(`ContextVariableStore: Variable ${decl.identifier} expects float, got:`, typeof value);
|
|
197
|
-
}
|
|
198
|
-
if (decl.baseType === "boolean" && typeof value !== "boolean") {
|
|
199
|
-
console.warn(`ContextVariableStore: Variable ${decl.identifier} expects boolean, got:`, typeof value);
|
|
200
|
-
}
|
|
201
|
-
if ((decl.cardinality === "multiple" || decl.cardinality === "ordered") &&
|
|
202
|
-
!Array.isArray(value)) {
|
|
203
|
-
console.warn(`ContextVariableStore: Variable ${decl.identifier} expects array (cardinality: ${decl.cardinality}), got:`, typeof value);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* I18nService
|
|
3
|
-
*
|
|
4
|
-
* The toolkit's view of the shared i18n provider: a delegating wrapper over
|
|
5
|
-
* `SimpleI18n` from `players-shared` that adds toolkit-scoped logging and wires
|
|
6
|
-
* the lazy catalog loaders.
|
|
7
|
-
*
|
|
8
|
-
* It was once a near-verbatim second copy of that class — same fields, same
|
|
9
|
-
* lookup, same plural selection. Duplicate implementations of one contract drift
|
|
10
|
-
* silently, because nothing fails when only one of them is fixed. Keep this a
|
|
11
|
-
* wrapper.
|
|
12
|
-
*
|
|
13
|
-
* Part of PIE Assessment Toolkit.
|
|
14
|
-
*/
|
|
15
|
-
import type { I18nConfig, I18nProvider, I18nServiceApi, InterpolationValues, LocaleCode, MessageCatalog, MessageKeyInput, PluralOptions, TextDirection } from "@pie-players/pie-players-shared/i18n";
|
|
16
|
-
export type { I18nConfig, I18nProvider, I18nServiceApi, InterpolationValues, LocaleCode, MessageCatalog, MessageKeyInput, PluralOptions, TextDirection, };
|
|
17
|
-
/**
|
|
18
|
-
* Toolkit-scoped i18n service.
|
|
19
|
-
*
|
|
20
|
-
* Serves every locale this repository ships, English resident and the rest
|
|
21
|
-
* lazily loaded.
|
|
22
|
-
*/
|
|
23
|
-
export declare class I18nService implements I18nServiceApi {
|
|
24
|
-
private readonly i18n;
|
|
25
|
-
constructor(config?: I18nConfig);
|
|
26
|
-
/**
|
|
27
|
-
* Set the locale, loading its catalog first.
|
|
28
|
-
*
|
|
29
|
-
* Never falls back to the browser locale: a rendered-string change reaches a
|
|
30
|
-
* host's live delivery on their next install with no build signal on their
|
|
31
|
-
* side, so the locale has to be something the host asked for.
|
|
32
|
-
*/
|
|
33
|
-
initialize(config: I18nConfig): Promise<void>;
|
|
34
|
-
t(key: MessageKeyInput, values?: InterpolationValues): string;
|
|
35
|
-
plural(key: MessageKeyInput, options: PluralOptions): string;
|
|
36
|
-
getLocale(): string;
|
|
37
|
-
setLocale(locale: LocaleCode): Promise<void>;
|
|
38
|
-
getDirection(): TextDirection;
|
|
39
|
-
getAvailableLocales(): string[];
|
|
40
|
-
isLocaleLoaded(locale: LocaleCode): boolean;
|
|
41
|
-
subscribe(listener: () => void): () => void;
|
|
42
|
-
hasKey(key: MessageKeyInput): boolean;
|
|
43
|
-
addCustomMessages(locale: string, messages: MessageCatalog): void;
|
|
44
|
-
withLocale(locale: LocaleCode): I18nProvider;
|
|
45
|
-
formatNumber(value: number, options?: Intl.NumberFormatOptions): string;
|
|
46
|
-
formatDate(date: Date, options?: Intl.DateTimeFormatOptions): string;
|
|
47
|
-
}
|