@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,84 +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 { createPieI18n } from "@pie-players/pie-players-shared/i18n";
|
|
16
|
-
import { createLogger } from "../utils/logger.js";
|
|
17
|
-
const log = createLogger("I18nService");
|
|
18
|
-
/**
|
|
19
|
-
* Toolkit-scoped i18n service.
|
|
20
|
-
*
|
|
21
|
-
* Serves every locale this repository ships, English resident and the rest
|
|
22
|
-
* lazily loaded.
|
|
23
|
-
*/
|
|
24
|
-
export class I18nService {
|
|
25
|
-
i18n;
|
|
26
|
-
constructor(config = {}) {
|
|
27
|
-
this.i18n = createPieI18n(config);
|
|
28
|
-
log("I18nService created", {
|
|
29
|
-
locale: this.i18n.getLocale(),
|
|
30
|
-
fallbackLocale: config.fallbackLocale ?? "en-US",
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Set the locale, loading its catalog first.
|
|
35
|
-
*
|
|
36
|
-
* Never falls back to the browser locale: a rendered-string change reaches a
|
|
37
|
-
* host's live delivery on their next install with no build signal on their
|
|
38
|
-
* side, so the locale has to be something the host asked for.
|
|
39
|
-
*/
|
|
40
|
-
async initialize(config) {
|
|
41
|
-
log(`Initializing with locale: ${config.locale ?? this.i18n.getLocale()}`);
|
|
42
|
-
await this.i18n.initialize(config);
|
|
43
|
-
}
|
|
44
|
-
t(key, values) {
|
|
45
|
-
return this.i18n.t(key, values);
|
|
46
|
-
}
|
|
47
|
-
plural(key, options) {
|
|
48
|
-
return this.i18n.plural(key, options);
|
|
49
|
-
}
|
|
50
|
-
getLocale() {
|
|
51
|
-
return this.i18n.getLocale();
|
|
52
|
-
}
|
|
53
|
-
async setLocale(locale) {
|
|
54
|
-
log(`Setting locale to: ${locale}`);
|
|
55
|
-
await this.i18n.setLocale(locale);
|
|
56
|
-
}
|
|
57
|
-
getDirection() {
|
|
58
|
-
return this.i18n.getDirection();
|
|
59
|
-
}
|
|
60
|
-
getAvailableLocales() {
|
|
61
|
-
return this.i18n.getAvailableLocales();
|
|
62
|
-
}
|
|
63
|
-
isLocaleLoaded(locale) {
|
|
64
|
-
return this.i18n.isLocaleLoaded(locale);
|
|
65
|
-
}
|
|
66
|
-
subscribe(listener) {
|
|
67
|
-
return this.i18n.subscribe(listener);
|
|
68
|
-
}
|
|
69
|
-
hasKey(key) {
|
|
70
|
-
return this.i18n.hasKey(key);
|
|
71
|
-
}
|
|
72
|
-
addCustomMessages(locale, messages) {
|
|
73
|
-
this.i18n.addCustomMessages(locale, messages);
|
|
74
|
-
}
|
|
75
|
-
withLocale(locale) {
|
|
76
|
-
return this.i18n.withLocale(locale);
|
|
77
|
-
}
|
|
78
|
-
formatNumber(value, options) {
|
|
79
|
-
return this.i18n.formatNumber?.(value, options) ?? String(value);
|
|
80
|
-
}
|
|
81
|
-
formatDate(date, options) {
|
|
82
|
-
return this.i18n.formatDate?.(date, options) ?? date.toISOString();
|
|
83
|
-
}
|
|
84
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ThemeProvider
|
|
3
|
-
*
|
|
4
|
-
* Applies consistent accessibility theming across items and tools.
|
|
5
|
-
* Uses CSS custom properties and classes for framework-agnostic theming.
|
|
6
|
-
*
|
|
7
|
-
* Features:
|
|
8
|
-
* - High contrast mode
|
|
9
|
-
* - Font size scaling (small, normal, large, xlarge)
|
|
10
|
-
* - Color customization (background, foreground, accent)
|
|
11
|
-
* - Consistent theming across shadow DOM boundaries
|
|
12
|
-
* - No framework dependencies
|
|
13
|
-
*
|
|
14
|
-
* Part of PIE Assessment Toolkit.
|
|
15
|
-
*/
|
|
16
|
-
import type { ThemeProviderApi } from "./interfaces.js";
|
|
17
|
-
/**
|
|
18
|
-
* Font size options
|
|
19
|
-
*/
|
|
20
|
-
export type FontSize = "small" | "normal" | "large" | "xlarge";
|
|
21
|
-
/**
|
|
22
|
-
* Theme configuration
|
|
23
|
-
*/
|
|
24
|
-
export interface ThemeConfig {
|
|
25
|
-
highContrast?: boolean;
|
|
26
|
-
fontSize?: FontSize;
|
|
27
|
-
backgroundColor?: string;
|
|
28
|
-
foregroundColor?: string;
|
|
29
|
-
accentColor?: string;
|
|
30
|
-
linkColor?: string;
|
|
31
|
-
errorColor?: string;
|
|
32
|
-
successColor?: string;
|
|
33
|
-
warningColor?: string;
|
|
34
|
-
}
|
|
35
|
-
export declare class ThemeProvider implements ThemeProviderApi {
|
|
36
|
-
private currentTheme;
|
|
37
|
-
private styleElement;
|
|
38
|
-
private rootElement;
|
|
39
|
-
private styleContainer;
|
|
40
|
-
constructor(rootElement?: HTMLElement | null);
|
|
41
|
-
/**
|
|
42
|
-
* Initialize theme styles
|
|
43
|
-
*/
|
|
44
|
-
private initializeStyles;
|
|
45
|
-
/**
|
|
46
|
-
* Apply theme configuration
|
|
47
|
-
*
|
|
48
|
-
* @param config Partial theme configuration (merged with current theme)
|
|
49
|
-
*/
|
|
50
|
-
applyTheme(config: ThemeConfig): void;
|
|
51
|
-
/**
|
|
52
|
-
* Apply CSS custom properties to root element
|
|
53
|
-
*/
|
|
54
|
-
private applyCSSVariables;
|
|
55
|
-
/**
|
|
56
|
-
* Apply CSS classes to root element
|
|
57
|
-
*/
|
|
58
|
-
private applyCSSClasses;
|
|
59
|
-
/**
|
|
60
|
-
* Update global theme styles
|
|
61
|
-
*/
|
|
62
|
-
private updateGlobalStyles;
|
|
63
|
-
/**
|
|
64
|
-
* Set high contrast mode
|
|
65
|
-
*/
|
|
66
|
-
setHighContrast(enabled: boolean): void;
|
|
67
|
-
/**
|
|
68
|
-
* Set font size
|
|
69
|
-
*/
|
|
70
|
-
setFontSize(size: FontSize): void;
|
|
71
|
-
/**
|
|
72
|
-
* Set color scheme
|
|
73
|
-
*/
|
|
74
|
-
setColors(colors: {
|
|
75
|
-
backgroundColor?: string;
|
|
76
|
-
foregroundColor?: string;
|
|
77
|
-
accentColor?: string;
|
|
78
|
-
}): void;
|
|
79
|
-
/**
|
|
80
|
-
* Get current theme configuration
|
|
81
|
-
*/
|
|
82
|
-
getCurrentTheme(): Required<ThemeConfig>;
|
|
83
|
-
/**
|
|
84
|
-
* Reset to default theme
|
|
85
|
-
*/
|
|
86
|
-
reset(): void;
|
|
87
|
-
/**
|
|
88
|
-
* Adjust color opacity (helper)
|
|
89
|
-
*/
|
|
90
|
-
private adjustOpacity;
|
|
91
|
-
/**
|
|
92
|
-
* Cleanup - remove theme styles
|
|
93
|
-
*/
|
|
94
|
-
destroy(): void;
|
|
95
|
-
}
|
|
@@ -1,334 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ThemeProvider
|
|
3
|
-
*
|
|
4
|
-
* Applies consistent accessibility theming across items and tools.
|
|
5
|
-
* Uses CSS custom properties and classes for framework-agnostic theming.
|
|
6
|
-
*
|
|
7
|
-
* Features:
|
|
8
|
-
* - High contrast mode
|
|
9
|
-
* - Font size scaling (small, normal, large, xlarge)
|
|
10
|
-
* - Color customization (background, foreground, accent)
|
|
11
|
-
* - Consistent theming across shadow DOM boundaries
|
|
12
|
-
* - No framework dependencies
|
|
13
|
-
*
|
|
14
|
-
* Part of PIE Assessment Toolkit.
|
|
15
|
-
*/
|
|
16
|
-
/**
|
|
17
|
-
* Font size scale (in rem units)
|
|
18
|
-
*/
|
|
19
|
-
const FONT_SIZE_SCALE = {
|
|
20
|
-
small: 0.875, // 14px at 16px base
|
|
21
|
-
normal: 1.0, // 16px at 16px base
|
|
22
|
-
large: 1.25, // 20px at 16px base
|
|
23
|
-
xlarge: 1.5, // 24px at 16px base
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* Default theme values
|
|
27
|
-
*/
|
|
28
|
-
const DEFAULT_THEME = {
|
|
29
|
-
highContrast: false,
|
|
30
|
-
fontSize: "normal",
|
|
31
|
-
backgroundColor: "#ffffff",
|
|
32
|
-
foregroundColor: "#000000",
|
|
33
|
-
accentColor: "#3f51b5",
|
|
34
|
-
linkColor: "#146eb3",
|
|
35
|
-
errorColor: "#ff9800",
|
|
36
|
-
successColor: "#4caf50",
|
|
37
|
-
warningColor: "#d32f2f",
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* High contrast theme overrides
|
|
41
|
-
*/
|
|
42
|
-
const HIGH_CONTRAST_THEME = {
|
|
43
|
-
backgroundColor: "#000000",
|
|
44
|
-
foregroundColor: "#ffffff",
|
|
45
|
-
accentColor: "#ffff00",
|
|
46
|
-
linkColor: "#00ffff",
|
|
47
|
-
errorColor: "#ff0000",
|
|
48
|
-
successColor: "#00ff00",
|
|
49
|
-
warningColor: "#ffff00",
|
|
50
|
-
};
|
|
51
|
-
export class ThemeProvider {
|
|
52
|
-
currentTheme = { ...DEFAULT_THEME };
|
|
53
|
-
styleElement = null;
|
|
54
|
-
rootElement;
|
|
55
|
-
styleContainer = null;
|
|
56
|
-
constructor(rootElement = typeof document !== "undefined"
|
|
57
|
-
? document.documentElement
|
|
58
|
-
: null) {
|
|
59
|
-
this.rootElement = rootElement;
|
|
60
|
-
// SSR guard
|
|
61
|
-
if (typeof document === "undefined") {
|
|
62
|
-
console.warn("ThemeProvider: document not available (SSR context)");
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
this.initializeStyles();
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Initialize theme styles
|
|
69
|
-
*/
|
|
70
|
-
initializeStyles() {
|
|
71
|
-
if (!this.rootElement)
|
|
72
|
-
return;
|
|
73
|
-
const rootNode = this.rootElement.getRootNode();
|
|
74
|
-
if (rootNode instanceof ShadowRoot) {
|
|
75
|
-
this.styleContainer = rootNode;
|
|
76
|
-
this.styleElement = rootNode.querySelector('style[data-pie-theme-styles="true"]');
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
this.styleContainer = document.head;
|
|
80
|
-
this.styleElement = document.getElementById("pie-theme-styles");
|
|
81
|
-
}
|
|
82
|
-
if (!this.styleElement) {
|
|
83
|
-
this.styleElement = document.createElement("style");
|
|
84
|
-
if (this.styleContainer instanceof ShadowRoot) {
|
|
85
|
-
this.styleElement.setAttribute("data-pie-theme-styles", "true");
|
|
86
|
-
this.styleContainer.appendChild(this.styleElement);
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
this.styleElement.id = "pie-theme-styles";
|
|
90
|
-
document.head.appendChild(this.styleElement);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
// Apply default theme
|
|
94
|
-
this.applyTheme({});
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Apply theme configuration
|
|
98
|
-
*
|
|
99
|
-
* @param config Partial theme configuration (merged with current theme)
|
|
100
|
-
*/
|
|
101
|
-
applyTheme(config) {
|
|
102
|
-
if (!this.rootElement)
|
|
103
|
-
return;
|
|
104
|
-
// Merge with current theme
|
|
105
|
-
const newTheme = {
|
|
106
|
-
...this.currentTheme,
|
|
107
|
-
...config,
|
|
108
|
-
};
|
|
109
|
-
// Apply high contrast overrides if enabled
|
|
110
|
-
if (newTheme.highContrast) {
|
|
111
|
-
Object.assign(newTheme, HIGH_CONTRAST_THEME);
|
|
112
|
-
}
|
|
113
|
-
this.currentTheme = newTheme;
|
|
114
|
-
// Apply CSS custom properties
|
|
115
|
-
this.applyCSSVariables();
|
|
116
|
-
// Apply CSS classes
|
|
117
|
-
this.applyCSSClasses();
|
|
118
|
-
// Update global styles
|
|
119
|
-
this.updateGlobalStyles();
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Apply CSS custom properties to root element
|
|
123
|
-
*/
|
|
124
|
-
applyCSSVariables() {
|
|
125
|
-
if (!this.rootElement)
|
|
126
|
-
return;
|
|
127
|
-
const { fontSize, backgroundColor, foregroundColor, accentColor, linkColor, errorColor, successColor, warningColor, } = this.currentTheme;
|
|
128
|
-
// Font sizing
|
|
129
|
-
this.rootElement.style.setProperty("--pie-font-scale", String(FONT_SIZE_SCALE[fontSize]));
|
|
130
|
-
// Canonical PIE variables
|
|
131
|
-
this.rootElement.style.setProperty("--pie-background", backgroundColor);
|
|
132
|
-
this.rootElement.style.setProperty("--pie-text", foregroundColor);
|
|
133
|
-
this.rootElement.style.setProperty("--pie-primary", accentColor);
|
|
134
|
-
this.rootElement.style.setProperty("--pie-tertiary", linkColor);
|
|
135
|
-
this.rootElement.style.setProperty("--pie-incorrect", errorColor);
|
|
136
|
-
this.rootElement.style.setProperty("--pie-correct", successColor);
|
|
137
|
-
this.rootElement.style.setProperty("--pie-missing", warningColor);
|
|
138
|
-
// Derived surface tokens
|
|
139
|
-
this.rootElement.style.setProperty("--pie-background-dark", this.adjustOpacity(backgroundColor, 0.95));
|
|
140
|
-
this.rootElement.style.setProperty("--pie-secondary-background", this.adjustOpacity(backgroundColor, 0.92));
|
|
141
|
-
this.rootElement.style.setProperty("--pie-border", this.adjustOpacity(foregroundColor, 0.25));
|
|
142
|
-
this.rootElement.style.setProperty("--pie-border-light", this.adjustOpacity(foregroundColor, 0.16));
|
|
143
|
-
this.rootElement.style.setProperty("--pie-border-dark", this.adjustOpacity(foregroundColor, 0.4));
|
|
144
|
-
this.rootElement.style.setProperty("--pie-focus-checked", this.adjustOpacity(accentColor, 0.18));
|
|
145
|
-
this.rootElement.style.setProperty("--pie-focus-checked-border", accentColor);
|
|
146
|
-
// Button tokens used by toolkit controls
|
|
147
|
-
this.rootElement.style.setProperty("--pie-button-bg", backgroundColor);
|
|
148
|
-
this.rootElement.style.setProperty("--pie-button-border", this.adjustOpacity(foregroundColor, 0.2));
|
|
149
|
-
this.rootElement.style.setProperty("--pie-button-color", foregroundColor);
|
|
150
|
-
this.rootElement.style.setProperty("--pie-button-hover-bg", this.adjustOpacity(accentColor, 0.1));
|
|
151
|
-
this.rootElement.style.setProperty("--pie-button-hover-border", this.adjustOpacity(accentColor, 0.5));
|
|
152
|
-
this.rootElement.style.setProperty("--pie-button-hover-color", foregroundColor);
|
|
153
|
-
this.rootElement.style.setProperty("--pie-button-active-bg", this.adjustOpacity(accentColor, 0.16));
|
|
154
|
-
this.rootElement.style.setProperty("--pie-button-focus-outline", accentColor);
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Apply CSS classes to root element
|
|
158
|
-
*/
|
|
159
|
-
applyCSSClasses() {
|
|
160
|
-
if (!this.rootElement)
|
|
161
|
-
return;
|
|
162
|
-
const { highContrast, fontSize } = this.currentTheme;
|
|
163
|
-
// High contrast class
|
|
164
|
-
this.rootElement.classList.toggle("pie-high-contrast", highContrast);
|
|
165
|
-
// Font size classes
|
|
166
|
-
this.rootElement.classList.remove("pie-font-small", "pie-font-normal", "pie-font-large", "pie-font-xlarge");
|
|
167
|
-
this.rootElement.classList.add(`pie-font-${fontSize}`);
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Update global theme styles
|
|
171
|
-
*/
|
|
172
|
-
updateGlobalStyles() {
|
|
173
|
-
if (!this.styleElement)
|
|
174
|
-
return;
|
|
175
|
-
this.styleElement.textContent = `
|
|
176
|
-
/* PIE Assessment Toolkit - Theme Styles */
|
|
177
|
-
|
|
178
|
-
/* Font scaling */
|
|
179
|
-
.pie-themed,
|
|
180
|
-
.pie-themed * {
|
|
181
|
-
font-size: calc(1rem * var(--pie-font-scale, 1));
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/* Color theming */
|
|
185
|
-
.pie-themed {
|
|
186
|
-
background-color: var(--pie-background);
|
|
187
|
-
color: var(--pie-text);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
.pie-themed a {
|
|
191
|
-
color: var(--pie-tertiary);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
.pie-themed a:hover {
|
|
195
|
-
opacity: 0.8;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/* High contrast mode */
|
|
199
|
-
.pie-high-contrast .pie-themed {
|
|
200
|
-
border: 2px solid var(--pie-text);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
.pie-high-contrast .pie-themed a {
|
|
204
|
-
text-decoration: underline;
|
|
205
|
-
font-weight: bold;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
.pie-high-contrast .pie-themed button {
|
|
209
|
-
border: 2px solid var(--pie-text);
|
|
210
|
-
background-color: var(--pie-background);
|
|
211
|
-
color: var(--pie-text);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
.pie-high-contrast .pie-themed button:hover {
|
|
215
|
-
background-color: var(--pie-text);
|
|
216
|
-
color: var(--pie-background);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
/* Error/Success/Warning states */
|
|
220
|
-
.pie-themed .pie-error {
|
|
221
|
-
color: var(--pie-incorrect);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
.pie-themed .pie-success {
|
|
225
|
-
color: var(--pie-correct);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
.pie-themed .pie-warning {
|
|
229
|
-
color: var(--pie-missing);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
/* Focus indicators (accessibility) */
|
|
233
|
-
.pie-themed *:focus-visible {
|
|
234
|
-
outline: 3px solid var(--pie-focus-checked-border);
|
|
235
|
-
outline-offset: 2px;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
.pie-high-contrast *:focus-visible {
|
|
239
|
-
outline-width: 4px;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
/* Responsive font scaling */
|
|
243
|
-
@media (max-width: 768px) {
|
|
244
|
-
.pie-themed,
|
|
245
|
-
.pie-themed * {
|
|
246
|
-
font-size: calc(1rem * var(--pie-font-scale, 1) * 0.9);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
`;
|
|
250
|
-
}
|
|
251
|
-
/**
|
|
252
|
-
* Set high contrast mode
|
|
253
|
-
*/
|
|
254
|
-
setHighContrast(enabled) {
|
|
255
|
-
this.applyTheme({ highContrast: enabled });
|
|
256
|
-
}
|
|
257
|
-
/**
|
|
258
|
-
* Set font size
|
|
259
|
-
*/
|
|
260
|
-
setFontSize(size) {
|
|
261
|
-
this.applyTheme({ fontSize: size });
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* Set color scheme
|
|
265
|
-
*/
|
|
266
|
-
setColors(colors) {
|
|
267
|
-
this.applyTheme(colors);
|
|
268
|
-
}
|
|
269
|
-
/**
|
|
270
|
-
* Get current theme configuration
|
|
271
|
-
*/
|
|
272
|
-
getCurrentTheme() {
|
|
273
|
-
return { ...this.currentTheme };
|
|
274
|
-
}
|
|
275
|
-
/**
|
|
276
|
-
* Reset to default theme
|
|
277
|
-
*/
|
|
278
|
-
reset() {
|
|
279
|
-
this.currentTheme = { ...DEFAULT_THEME };
|
|
280
|
-
this.applyTheme({});
|
|
281
|
-
}
|
|
282
|
-
/**
|
|
283
|
-
* Adjust color opacity (helper)
|
|
284
|
-
*/
|
|
285
|
-
adjustOpacity(color, opacity) {
|
|
286
|
-
// Simple hex to rgba conversion
|
|
287
|
-
if (color.startsWith("#")) {
|
|
288
|
-
const r = parseInt(color.slice(1, 3), 16);
|
|
289
|
-
const g = parseInt(color.slice(3, 5), 16);
|
|
290
|
-
const b = parseInt(color.slice(5, 7), 16);
|
|
291
|
-
return `rgba(${r}, ${g}, ${b}, ${opacity})`;
|
|
292
|
-
}
|
|
293
|
-
// If already rgba/rgb, just return as-is (simplified)
|
|
294
|
-
return color;
|
|
295
|
-
}
|
|
296
|
-
/**
|
|
297
|
-
* Cleanup - remove theme styles
|
|
298
|
-
*/
|
|
299
|
-
destroy() {
|
|
300
|
-
if (this.styleElement) {
|
|
301
|
-
this.styleElement.remove();
|
|
302
|
-
this.styleElement = null;
|
|
303
|
-
}
|
|
304
|
-
this.styleContainer = null;
|
|
305
|
-
if (!this.rootElement)
|
|
306
|
-
return;
|
|
307
|
-
// Remove CSS classes
|
|
308
|
-
this.rootElement.classList.remove("pie-high-contrast", "pie-font-small", "pie-font-normal", "pie-font-large", "pie-font-xlarge");
|
|
309
|
-
// Remove CSS custom properties
|
|
310
|
-
this.rootElement.style.removeProperty("--pie-font-scale");
|
|
311
|
-
this.rootElement.style.removeProperty("--pie-background");
|
|
312
|
-
this.rootElement.style.removeProperty("--pie-text");
|
|
313
|
-
this.rootElement.style.removeProperty("--pie-primary");
|
|
314
|
-
this.rootElement.style.removeProperty("--pie-tertiary");
|
|
315
|
-
this.rootElement.style.removeProperty("--pie-incorrect");
|
|
316
|
-
this.rootElement.style.removeProperty("--pie-correct");
|
|
317
|
-
this.rootElement.style.removeProperty("--pie-missing");
|
|
318
|
-
this.rootElement.style.removeProperty("--pie-background-dark");
|
|
319
|
-
this.rootElement.style.removeProperty("--pie-secondary-background");
|
|
320
|
-
this.rootElement.style.removeProperty("--pie-border");
|
|
321
|
-
this.rootElement.style.removeProperty("--pie-border-light");
|
|
322
|
-
this.rootElement.style.removeProperty("--pie-border-dark");
|
|
323
|
-
this.rootElement.style.removeProperty("--pie-focus-checked");
|
|
324
|
-
this.rootElement.style.removeProperty("--pie-focus-checked-border");
|
|
325
|
-
this.rootElement.style.removeProperty("--pie-button-bg");
|
|
326
|
-
this.rootElement.style.removeProperty("--pie-button-border");
|
|
327
|
-
this.rootElement.style.removeProperty("--pie-button-color");
|
|
328
|
-
this.rootElement.style.removeProperty("--pie-button-hover-bg");
|
|
329
|
-
this.rootElement.style.removeProperty("--pie-button-hover-border");
|
|
330
|
-
this.rootElement.style.removeProperty("--pie-button-hover-color");
|
|
331
|
-
this.rootElement.style.removeProperty("--pie-button-active-bg");
|
|
332
|
-
this.rootElement.style.removeProperty("--pie-button-focus-outline");
|
|
333
|
-
}
|
|
334
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { PersonalNeedsProfile } from "@pie-players/pie-players-shared/types";
|
|
2
|
-
/**
|
|
3
|
-
* An empty personal-needs profile: nothing granted, nothing prohibited, nothing
|
|
4
|
-
* activated at init.
|
|
5
|
-
*
|
|
6
|
-
* The core ships no populated default on purpose. It once derived one from every
|
|
7
|
-
* registered tool's `pnpSupportIds`, which read *registry membership* as
|
|
8
|
-
* *eligibility tier* — registration means "policy-addressable", not "universal,
|
|
9
|
-
* on by default" — so an accommodation-tier capability was granted to every
|
|
10
|
-
* student of every host that supplied no profile. The remedy at the time was a
|
|
11
|
-
* compile-time list of ids to exclude, which a host could not extend for its own
|
|
12
|
-
* accommodation.
|
|
13
|
-
*
|
|
14
|
-
* Which capabilities a deployment grants by default is a property of the
|
|
15
|
-
* program, not of this package: TTS is a universal feature in one program and a
|
|
16
|
-
* documented accommodation in another. That belongs in policy configuration
|
|
17
|
-
* alongside the district and test-administration levels. A named preset of
|
|
18
|
-
* today's universal set ships as data from
|
|
19
|
-
* `@pie-players/pie-default-tool-loaders`, for hosts that want it.
|
|
20
|
-
*/
|
|
21
|
-
export declare function createEmptyPersonalNeedsProfile(): PersonalNeedsProfile;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* An empty personal-needs profile: nothing granted, nothing prohibited, nothing
|
|
3
|
-
* activated at init.
|
|
4
|
-
*
|
|
5
|
-
* The core ships no populated default on purpose. It once derived one from every
|
|
6
|
-
* registered tool's `pnpSupportIds`, which read *registry membership* as
|
|
7
|
-
* *eligibility tier* — registration means "policy-addressable", not "universal,
|
|
8
|
-
* on by default" — so an accommodation-tier capability was granted to every
|
|
9
|
-
* student of every host that supplied no profile. The remedy at the time was a
|
|
10
|
-
* compile-time list of ids to exclude, which a host could not extend for its own
|
|
11
|
-
* accommodation.
|
|
12
|
-
*
|
|
13
|
-
* Which capabilities a deployment grants by default is a property of the
|
|
14
|
-
* program, not of this package: TTS is a universal feature in one program and a
|
|
15
|
-
* documented accommodation in another. That belongs in policy configuration
|
|
16
|
-
* alongside the district and test-administration levels. A named preset of
|
|
17
|
-
* today's universal set ships as data from
|
|
18
|
-
* `@pie-players/pie-default-tool-loaders`, for hosts that want it.
|
|
19
|
-
*/
|
|
20
|
-
export function createEmptyPersonalNeedsProfile() {
|
|
21
|
-
return {
|
|
22
|
-
supports: [],
|
|
23
|
-
prohibitedSupports: [],
|
|
24
|
-
activateAtInit: [],
|
|
25
|
-
};
|
|
26
|
-
}
|