@pie-players/pie-assessment-toolkit 0.2.7 → 0.2.10
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 +200 -67
- package/dist/attempt/TestSession.d.ts +23 -21
- package/dist/attempt/TestSession.d.ts.map +1 -1
- package/dist/attempt/TestSession.js +17 -15
- package/dist/attempt/TestSession.js.map +1 -1
- package/dist/attempt/adapters/activity-to-test-attempt-session.d.ts +50 -0
- package/dist/attempt/adapters/activity-to-test-attempt-session.d.ts.map +1 -0
- package/dist/attempt/adapters/activity-to-test-attempt-session.js +135 -0
- package/dist/attempt/adapters/activity-to-test-attempt-session.js.map +1 -0
- package/dist/components/ItemToolBar.custom-element.js +953 -0
- package/dist/components/PieAssessmentToolkit.custom-element.js +757 -0
- package/dist/components/SectionToolBar.custom-element.js +162 -0
- package/dist/components/item-toolbar-element.d.ts +3 -0
- package/dist/components/item-toolbar-element.d.ts.map +1 -0
- package/dist/components/item-toolbar-element.js +2 -0
- package/dist/components/item-toolbar-element.js.map +1 -0
- package/dist/components/pie-assessment-toolkit-element.d.ts +3 -0
- package/dist/components/pie-assessment-toolkit-element.d.ts.map +1 -0
- package/dist/components/pie-assessment-toolkit-element.js +2 -0
- package/dist/components/pie-assessment-toolkit-element.js.map +1 -0
- package/dist/components/section-toolbar-element.d.ts +3 -0
- package/dist/components/section-toolbar-element.d.ts.map +1 -0
- package/dist/components/section-toolbar-element.js +2 -0
- package/dist/components/section-toolbar-element.js.map +1 -0
- package/dist/context/assessment-toolkit-context.d.ts +52 -0
- package/dist/context/assessment-toolkit-context.d.ts.map +1 -0
- package/dist/context/assessment-toolkit-context.js +6 -0
- package/dist/context/assessment-toolkit-context.js.map +1 -0
- package/dist/context/runtime-context-consumer.d.ts +14 -0
- package/dist/context/runtime-context-consumer.d.ts.map +1 -0
- package/dist/context/runtime-context-consumer.js +52 -0
- package/dist/context/runtime-context-consumer.js.map +1 -0
- package/dist/index.d.ts +19 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -11
- package/dist/index.js.map +1 -1
- package/dist/runtime/RuntimeRegistry.d.ts +13 -0
- package/dist/runtime/RuntimeRegistry.d.ts.map +1 -0
- package/dist/runtime/RuntimeRegistry.js +50 -0
- package/dist/runtime/RuntimeRegistry.js.map +1 -0
- package/dist/runtime/SectionRuntimeEngine.d.ts +45 -0
- package/dist/runtime/SectionRuntimeEngine.d.ts.map +1 -0
- package/dist/runtime/SectionRuntimeEngine.js +81 -0
- package/dist/runtime/SectionRuntimeEngine.js.map +1 -0
- package/dist/runtime/registration-events.d.ts +19 -0
- package/dist/runtime/registration-events.d.ts.map +1 -0
- package/dist/runtime/registration-events.js +4 -0
- package/dist/runtime/registration-events.js.map +1 -0
- package/dist/runtime/runtime-event-guards.d.ts +3 -0
- package/dist/runtime/runtime-event-guards.d.ts.map +1 -0
- package/dist/runtime/runtime-event-guards.js +9 -0
- package/dist/runtime/runtime-event-guards.js.map +1 -0
- package/dist/runtime/tool-host-contract.d.ts +30 -0
- package/dist/runtime/tool-host-contract.d.ts.map +1 -0
- package/dist/runtime/tool-host-contract.js +48 -0
- package/dist/runtime/tool-host-contract.js.map +1 -0
- package/dist/services/HighlightCoordinator.d.ts +9 -0
- package/dist/services/HighlightCoordinator.d.ts.map +1 -1
- package/dist/services/HighlightCoordinator.js +196 -55
- package/dist/services/HighlightCoordinator.js.map +1 -1
- package/dist/services/TTSService.d.ts +21 -1
- package/dist/services/TTSService.d.ts.map +1 -1
- package/dist/services/TTSService.js +356 -117
- package/dist/services/TTSService.js.map +1 -1
- package/dist/services/ThemeProvider.d.ts +1 -0
- package/dist/services/ThemeProvider.d.ts.map +1 -1
- package/dist/services/ThemeProvider.js +82 -46
- package/dist/services/ThemeProvider.js.map +1 -1
- package/dist/services/ToolConfigResolver.d.ts +1 -1
- package/dist/services/ToolConfigResolver.js +1 -1
- package/dist/services/ToolCoordinator.d.ts +1 -1
- package/dist/services/ToolCoordinator.d.ts.map +1 -1
- package/dist/services/ToolRegistry.d.ts +76 -67
- package/dist/services/ToolRegistry.d.ts.map +1 -1
- package/dist/services/ToolRegistry.js +73 -22
- package/dist/services/ToolRegistry.js.map +1 -1
- package/dist/services/ToolkitCoordinator.d.ts +126 -8
- package/dist/services/ToolkitCoordinator.d.ts.map +1 -1
- package/dist/services/ToolkitCoordinator.js +607 -72
- package/dist/services/ToolkitCoordinator.js.map +1 -1
- package/dist/services/createDefaultToolRegistry.d.ts +11 -12
- package/dist/services/createDefaultToolRegistry.d.ts.map +1 -1
- package/dist/services/createDefaultToolRegistry.js +9 -56
- package/dist/services/createDefaultToolRegistry.js.map +1 -1
- package/dist/services/defaultPersonalNeedsProfile.d.ts +4 -0
- package/dist/services/defaultPersonalNeedsProfile.d.ts.map +1 -0
- package/dist/services/defaultPersonalNeedsProfile.js +25 -0
- package/dist/services/defaultPersonalNeedsProfile.js.map +1 -0
- package/dist/services/interfaces.d.ts +62 -2
- package/dist/services/interfaces.d.ts.map +1 -1
- package/dist/services/interfaces.js.map +1 -1
- package/dist/services/pnp-standard-features.d.ts +3 -4
- package/dist/services/pnp-standard-features.d.ts.map +1 -1
- package/dist/services/pnp-standard-features.js +0 -3
- package/dist/services/pnp-standard-features.js.map +1 -1
- package/dist/services/section-controller-types.d.ts +37 -0
- package/dist/services/section-controller-types.d.ts.map +1 -0
- package/dist/services/section-controller-types.js +2 -0
- package/dist/services/section-controller-types.js.map +1 -0
- package/dist/services/tool-config-defaults.d.ts +14 -0
- package/dist/services/tool-config-defaults.d.ts.map +1 -0
- package/dist/services/tool-config-defaults.js +23 -0
- package/dist/services/tool-config-defaults.js.map +1 -0
- package/dist/services/tool-context.d.ts +4 -4
- package/dist/services/tool-context.d.ts.map +1 -1
- package/dist/services/tool-context.js +156 -20
- package/dist/services/tool-context.js.map +1 -1
- package/dist/services/tool-instance-id.d.ts +15 -0
- package/dist/services/tool-instance-id.d.ts.map +1 -0
- package/dist/services/tool-instance-id.js +55 -0
- package/dist/services/tool-instance-id.js.map +1 -0
- package/dist/services/tool-providers/IToolProvider.d.ts +2 -3
- package/dist/services/tool-providers/IToolProvider.d.ts.map +1 -1
- package/dist/services/tool-providers/IToolProvider.js +1 -2
- package/dist/services/tool-providers/IToolProvider.js.map +1 -1
- package/dist/services/tool-providers/MathJsToolProvider.d.ts +25 -0
- package/dist/services/tool-providers/MathJsToolProvider.d.ts.map +1 -0
- package/dist/services/tool-providers/MathJsToolProvider.js +53 -0
- package/dist/services/tool-providers/MathJsToolProvider.js.map +1 -0
- package/dist/services/tool-providers/index.d.ts +2 -0
- package/dist/services/tool-providers/index.d.ts.map +1 -1
- package/dist/services/tool-providers/index.js +1 -0
- package/dist/services/tool-providers/index.js.map +1 -1
- package/dist/services/toolbar-items.d.ts +26 -0
- package/dist/services/toolbar-items.d.ts.map +1 -0
- package/dist/services/toolbar-items.js +10 -0
- package/dist/services/toolbar-items.js.map +1 -0
- package/dist/services/tools-config-normalizer.d.ts +26 -0
- package/dist/services/tools-config-normalizer.d.ts.map +1 -0
- package/dist/services/tools-config-normalizer.js +62 -0
- package/dist/services/tools-config-normalizer.js.map +1 -0
- package/dist/services/tts/browser-provider.d.ts.map +1 -1
- package/dist/services/tts/browser-provider.js +201 -34
- package/dist/services/tts/browser-provider.js.map +1 -1
- package/dist/services/tts/text-processing.d.ts +17 -0
- package/dist/services/tts/text-processing.d.ts.map +1 -0
- package/dist/services/tts/text-processing.js +144 -0
- package/dist/services/tts/text-processing.js.map +1 -0
- package/dist/tools/calculators/ti-provider.d.ts.map +1 -1
- package/dist/tools/calculators/ti-provider.js +127 -4
- package/dist/tools/calculators/ti-provider.js.map +1 -1
- package/dist/tools/client.d.ts +2 -1
- package/dist/tools/client.d.ts.map +1 -1
- package/dist/tools/client.js +2 -1
- package/dist/tools/client.js.map +1 -1
- package/dist/tools/default-tool-module-loaders.d.ts +9 -0
- package/dist/tools/default-tool-module-loaders.d.ts.map +1 -0
- package/dist/tools/default-tool-module-loaders.js +11 -0
- package/dist/tools/default-tool-module-loaders.js.map +1 -0
- package/dist/tools/index.d.ts +2 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +2 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/library-loader.d.ts +1 -1
- package/dist/tools/library-loader.d.ts.map +1 -1
- package/dist/tools/library-loader.js +7 -2
- package/dist/tools/library-loader.js.map +1 -1
- package/dist/tools/registrations/accessibility-tools.d.ts +8 -11
- package/dist/tools/registrations/accessibility-tools.d.ts.map +1 -1
- package/dist/tools/registrations/accessibility-tools.js +108 -120
- package/dist/tools/registrations/accessibility-tools.js.map +1 -1
- package/dist/tools/registrations/calculator.d.ts +2 -2
- package/dist/tools/registrations/calculator.d.ts.map +1 -1
- package/dist/tools/registrations/calculator.js +42 -55
- package/dist/tools/registrations/calculator.js.map +1 -1
- package/dist/tools/registrations/interaction-tools.d.ts.map +1 -1
- package/dist/tools/registrations/interaction-tools.js +77 -52
- package/dist/tools/registrations/interaction-tools.js.map +1 -1
- package/dist/tools/registrations/measurement-tools.d.ts.map +1 -1
- package/dist/tools/registrations/measurement-tools.js +63 -38
- package/dist/tools/registrations/measurement-tools.js.map +1 -1
- package/dist/tools/registrations/subject-specific-tools.d.ts.map +1 -1
- package/dist/tools/registrations/subject-specific-tools.js +63 -38
- package/dist/tools/registrations/subject-specific-tools.js.map +1 -1
- package/dist/tools/registrations/tts.d.ts +1 -1
- package/dist/tools/registrations/tts.d.ts.map +1 -1
- package/dist/tools/registrations/tts.js +171 -41
- package/dist/tools/registrations/tts.js.map +1 -1
- package/dist/tools/response-discovery.d.ts +12 -14
- package/dist/tools/response-discovery.d.ts.map +1 -1
- package/dist/tools/response-discovery.js +23 -80
- package/dist/tools/response-discovery.js.map +1 -1
- package/dist/tools/tool-tag-map.d.ts +3 -3
- package/dist/tools/tool-tag-map.d.ts.map +1 -1
- package/dist/tools/tool-tag-map.js +4 -4
- package/dist/tools/tool-tag-map.js.map +1 -1
- package/dist/tools/types.d.ts +3 -1
- package/dist/tools/types.d.ts.map +1 -1
- package/package.json +28 -27
- package/src/README.md +16 -32
- package/src/components/ItemToolBar.svelte +701 -0
- package/src/components/PieAssessmentToolkit.svelte +610 -0
- package/src/components/SectionToolBar.svelte +58 -0
- package/src/components/ToolButton.svelte +11 -11
- package/src/components/ToolButtonGroup.svelte +27 -11
- package/src/tools/README.md +6 -5
- package/src/tools/calculators/README.md +4 -4
- package/dist/player/AssessmentPlayer.d.ts +0 -397
- package/dist/player/AssessmentPlayer.d.ts.map +0 -1
- package/dist/player/AssessmentPlayer.js +0 -974
- package/dist/player/AssessmentPlayer.js.map +0 -1
- package/dist/player/index.d.ts +0 -17
- package/dist/player/index.d.ts.map +0 -1
- package/dist/player/index.js +0 -15
- package/dist/player/index.js.map +0 -1
- package/dist/player/navigation-types.d.ts +0 -63
- package/dist/player/navigation-types.d.ts.map +0 -1
- package/dist/player/navigation-types.js +0 -7
- package/dist/player/navigation-types.js.map +0 -1
- package/dist/player/qti-navigation.d.ts +0 -29
- package/dist/player/qti-navigation.d.ts.map +0 -1
- package/dist/player/qti-navigation.js +0 -160
- package/dist/player/qti-navigation.js.map +0 -1
- package/dist/reference-layout/index.d.ts +0 -19
- package/dist/reference-layout/index.d.ts.map +0 -1
- package/dist/reference-layout/index.js +0 -20
- package/dist/reference-layout/index.js.map +0 -1
- package/dist/services/AnnotationToolbarConfig.d.ts +0 -134
- package/dist/services/AnnotationToolbarConfig.d.ts.map +0 -1
- package/dist/services/AnnotationToolbarConfig.js +0 -100
- package/dist/services/AnnotationToolbarConfig.js.map +0 -1
- package/dist/services/AssessmentAuthoringService.d.ts +0 -60
- package/dist/services/AssessmentAuthoringService.d.ts.map +0 -1
- package/dist/services/AssessmentAuthoringService.js +0 -183
- package/dist/services/AssessmentAuthoringService.js.map +0 -1
- package/dist/services/PNPMapper.d.ts +0 -81
- package/dist/services/PNPMapper.d.ts.map +0 -1
- package/dist/services/PNPMapper.js +0 -108
- package/dist/services/PNPMapper.js.map +0 -1
- package/dist/services/tts/provider-interface.d.ts +0 -131
- package/dist/services/tts/provider-interface.d.ts.map +0 -1
- package/dist/services/tts/provider-interface.js +0 -10
- package/dist/services/tts/provider-interface.js.map +0 -1
- package/src/components/PNPProfileTester.example.svelte +0 -188
- package/src/components/PNPProfileTester.svelte +0 -397
- package/src/components/PNPProvenanceViewer.svelte +0 -260
- package/src/components/QuestionToolBar.svelte +0 -483
- package/src/player/AssessmentLayout.svelte +0 -68
- package/src/player/README.md +0 -154
- package/src/reference-layout/README.md +0 -135
- package/src/reference-layout/ReferenceLayout.svelte +0 -201
- package/src/reference-layout/components/AssessmentContent.svelte +0 -259
- package/src/reference-layout/components/AssessmentFooter.svelte +0 -89
- package/src/reference-layout/components/AssessmentHeader.svelte +0 -250
- package/src/reference-layout/components/AssessmentNavigation.svelte +0 -134
- package/src/reference-layout/components/AssessmentToolsBar.svelte +0 -176
- package/src/reference-layout/components/ItemPanel.svelte +0 -200
- package/src/reference-layout/components/NotesPanel.svelte +0 -179
- package/src/reference-layout/components/PassagePanel.svelte +0 -76
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { ToolkitCoordinator } from "../services/ToolkitCoordinator.js";
|
|
2
|
+
import type { SectionControllerHandle } from "../services/section-controller-types.js";
|
|
3
|
+
import type { RuntimeRegistrationDetail } from "./registration-events.js";
|
|
4
|
+
import { RuntimeRegistry } from "./RuntimeRegistry.js";
|
|
5
|
+
interface RuntimeController extends SectionControllerHandle {
|
|
6
|
+
getCompositionModel?: () => unknown;
|
|
7
|
+
getCanonicalItemId?: (itemId: string) => string;
|
|
8
|
+
handleItemSessionChanged?: (itemId: string, session: unknown) => {
|
|
9
|
+
eventDetail?: unknown;
|
|
10
|
+
} | null;
|
|
11
|
+
subscribe?: (listener: (event: unknown) => void) => () => void;
|
|
12
|
+
navigateToItem?: (index: number) => unknown;
|
|
13
|
+
}
|
|
14
|
+
interface EngineInitArgs {
|
|
15
|
+
coordinator: ToolkitCoordinator;
|
|
16
|
+
section: unknown;
|
|
17
|
+
sectionId: string;
|
|
18
|
+
assessmentId: string;
|
|
19
|
+
view: string;
|
|
20
|
+
attemptId?: string;
|
|
21
|
+
createDefaultController: () => Promise<RuntimeController> | RuntimeController;
|
|
22
|
+
onCompositionChanged?: (composition: unknown) => void;
|
|
23
|
+
}
|
|
24
|
+
export declare class SectionRuntimeEngine {
|
|
25
|
+
private readonly registry;
|
|
26
|
+
private controller;
|
|
27
|
+
private coordinator;
|
|
28
|
+
private sectionId;
|
|
29
|
+
private attemptId;
|
|
30
|
+
private unsubscribeController;
|
|
31
|
+
private activeInitToken;
|
|
32
|
+
initialize(args: EngineInitArgs): Promise<void>;
|
|
33
|
+
register(detail: RuntimeRegistrationDetail): boolean;
|
|
34
|
+
unregister(element: HTMLElement): boolean;
|
|
35
|
+
getCompositionModel(): unknown;
|
|
36
|
+
getCanonicalItemId(itemId: string): string;
|
|
37
|
+
handleItemSessionChanged(itemId: string, session: unknown): unknown;
|
|
38
|
+
navigateToItem(index: number): unknown;
|
|
39
|
+
persist(): Promise<void>;
|
|
40
|
+
hydrate(): Promise<void>;
|
|
41
|
+
getRegistry(): RuntimeRegistry;
|
|
42
|
+
dispose(): Promise<void>;
|
|
43
|
+
}
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=SectionRuntimeEngine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SectionRuntimeEngine.d.ts","sourceRoot":"","sources":["../../src/runtime/SectionRuntimeEngine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAC5E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AACvF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,UAAU,iBAAkB,SAAQ,uBAAuB;IAC1D,mBAAm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B,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAK1C,wBAAwB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO;IAKnE,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAIhC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAIxB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAI9B,WAAW;IAIL,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAc9B"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { RuntimeRegistry } from "./RuntimeRegistry.js";
|
|
2
|
+
export class SectionRuntimeEngine {
|
|
3
|
+
registry = new RuntimeRegistry();
|
|
4
|
+
controller = null;
|
|
5
|
+
coordinator = null;
|
|
6
|
+
sectionId = "";
|
|
7
|
+
attemptId;
|
|
8
|
+
unsubscribeController = null;
|
|
9
|
+
activeInitToken = 0;
|
|
10
|
+
async initialize(args) {
|
|
11
|
+
this.activeInitToken += 1;
|
|
12
|
+
const token = this.activeInitToken;
|
|
13
|
+
this.coordinator = args.coordinator;
|
|
14
|
+
this.sectionId = args.sectionId;
|
|
15
|
+
this.attemptId = args.attemptId;
|
|
16
|
+
const resolved = (await args.coordinator.getOrCreateSectionController({
|
|
17
|
+
sectionId: args.sectionId,
|
|
18
|
+
attemptId: args.attemptId,
|
|
19
|
+
input: {
|
|
20
|
+
section: args.section,
|
|
21
|
+
sectionId: args.sectionId,
|
|
22
|
+
assessmentId: args.assessmentId,
|
|
23
|
+
view: args.view,
|
|
24
|
+
},
|
|
25
|
+
updateExisting: true,
|
|
26
|
+
createDefaultController: args.createDefaultController,
|
|
27
|
+
}));
|
|
28
|
+
if (token !== this.activeInitToken)
|
|
29
|
+
return;
|
|
30
|
+
this.unsubscribeController?.();
|
|
31
|
+
this.controller = resolved;
|
|
32
|
+
args.onCompositionChanged?.(resolved.getCompositionModel?.());
|
|
33
|
+
this.unsubscribeController = resolved.subscribe?.(() => {
|
|
34
|
+
args.onCompositionChanged?.(resolved.getCompositionModel?.());
|
|
35
|
+
}) || null;
|
|
36
|
+
}
|
|
37
|
+
register(detail) {
|
|
38
|
+
return this.registry.register(detail);
|
|
39
|
+
}
|
|
40
|
+
unregister(element) {
|
|
41
|
+
return this.registry.unregister(element);
|
|
42
|
+
}
|
|
43
|
+
getCompositionModel() {
|
|
44
|
+
return this.controller?.getCompositionModel?.() ?? null;
|
|
45
|
+
}
|
|
46
|
+
getCanonicalItemId(itemId) {
|
|
47
|
+
const map = this.registry.getCanonicalIdMap();
|
|
48
|
+
return map[itemId] || this.controller?.getCanonicalItemId?.(itemId) || itemId;
|
|
49
|
+
}
|
|
50
|
+
handleItemSessionChanged(itemId, session) {
|
|
51
|
+
const canonicalId = this.getCanonicalItemId(itemId);
|
|
52
|
+
return this.controller?.handleItemSessionChanged?.(canonicalId, session) ?? null;
|
|
53
|
+
}
|
|
54
|
+
navigateToItem(index) {
|
|
55
|
+
return this.controller?.navigateToItem?.(index) ?? null;
|
|
56
|
+
}
|
|
57
|
+
async persist() {
|
|
58
|
+
await this.controller?.persist?.();
|
|
59
|
+
}
|
|
60
|
+
async hydrate() {
|
|
61
|
+
await this.controller?.hydrate?.();
|
|
62
|
+
}
|
|
63
|
+
getRegistry() {
|
|
64
|
+
return this.registry;
|
|
65
|
+
}
|
|
66
|
+
async dispose() {
|
|
67
|
+
this.activeInitToken += 1;
|
|
68
|
+
this.unsubscribeController?.();
|
|
69
|
+
this.unsubscribeController = null;
|
|
70
|
+
if (this.coordinator && this.sectionId) {
|
|
71
|
+
await this.coordinator.disposeSectionController({
|
|
72
|
+
sectionId: this.sectionId,
|
|
73
|
+
attemptId: this.attemptId,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
this.registry.clear();
|
|
77
|
+
this.controller = null;
|
|
78
|
+
this.coordinator = null;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=SectionRuntimeEngine.js.map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AO;QACZ,MAAM,IAAI,CAAC,UAAU,EAAE,OAAO,EAAE,EAAE,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,OAAO;QACZ,MAAM,IAAI,CAAC,UAAU,EAAE,OAAO,EAAE,EAAE,CAAC;IACpC,CAAC;IAED,WAAW;QACV,OAAO,IAAI,CAAC,QAAQ,CAAC;IACtB,CAAC;IAED,KAAK,CAAC,OAAO;QACZ,IAAI,CAAC,eAAe,IAAI,CAAC,CAAC;QAC1B,IAAI,CAAC,qBAAqB,EAAE,EAAE,CAAC;QAC/B,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC;QAClC,IAAI,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACxC,MAAM,IAAI,CAAC,WAAW,CAAC,wBAAwB,CAAC;gBAC/C,SAAS,EAAE,IAAI,CAAC,SAAS;gBACzB,SAAS,EAAE,IAAI,CAAC,SAAS;aACzB,CAAC,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACtB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACvB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IACzB,CAAC;CACD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const PIE_REGISTER_EVENT = "pie-register";
|
|
2
|
+
export declare const PIE_UNREGISTER_EVENT = "pie-unregister";
|
|
3
|
+
export declare const PIE_ITEM_SESSION_CHANGED_EVENT = "item-session-changed";
|
|
4
|
+
export type RuntimeRegistrationKind = "item" | "passage";
|
|
5
|
+
export interface RuntimeRegistrationDetail {
|
|
6
|
+
kind: RuntimeRegistrationKind;
|
|
7
|
+
itemId: string;
|
|
8
|
+
canonicalItemId?: string;
|
|
9
|
+
contentKind?: string;
|
|
10
|
+
item?: unknown;
|
|
11
|
+
element: HTMLElement;
|
|
12
|
+
}
|
|
13
|
+
export interface ItemSessionChangedDetail {
|
|
14
|
+
itemId: string;
|
|
15
|
+
canonicalItemId?: string;
|
|
16
|
+
session: unknown;
|
|
17
|
+
sourceRuntimeId?: string;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=registration-events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registration-events.d.ts","sourceRoot":"","sources":["../../src/runtime/registration-events.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,iBAAiB,CAAC;AACjD,eAAO,MAAM,oBAAoB,mBAAmB,CAAC;AACrD,eAAO,MAAM,8BAA8B,yBAAyB,CAAC;AAErE,MAAM,MAAM,uBAAuB,GAAG,MAAM,GAAG,SAAS,CAAC;AAEzD,MAAM,WAAW,yBAAyB;IACzC,IAAI,EAAE,uBAAuB,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,WAAW,CAAC;CACrB;AAED,MAAM,WAAW,wBAAwB;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,CAAC,EAAE,MAAM,CAAC;CACzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registration-events.js","sourceRoot":"","sources":["../../src/runtime/registration-events.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,kBAAkB,GAAG,cAAc,CAAC;AACjD,MAAM,CAAC,MAAM,oBAAoB,GAAG,gBAAgB,CAAC;AACrD,MAAM,CAAC,MAAM,8BAA8B,GAAG,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-event-guards.d.ts","sourceRoot":"","sources":["../../src/runtime/runtime-event-guards.ts"],"names":[],"mappings":"AAAA,wBAAgB,eAAe,CAAC,MAAM,SAAY,GAAG,MAAM,CAE1D;AAED,wBAAgB,2BAA2B,CAC1C,eAAe,EAAE,MAAM,GAAG,SAAS,EACnC,gBAAgB,EAAE,MAAM,GACtB,OAAO,CAGT"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function createRuntimeId(prefix = "runtime") {
|
|
2
|
+
return `${prefix}-${Math.random().toString(16).slice(2)}-${Date.now()}`;
|
|
3
|
+
}
|
|
4
|
+
export function shouldHandleBySourceRuntime(sourceRuntimeId, currentRuntimeId) {
|
|
5
|
+
if (!sourceRuntimeId)
|
|
6
|
+
return true;
|
|
7
|
+
return sourceRuntimeId !== currentRuntimeId;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=runtime-event-guards.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-event-guards.js","sourceRoot":"","sources":["../../src/runtime/runtime-event-guards.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,eAAe,CAAC,MAAM,GAAG,SAAS;IACjD,OAAO,GAAG,MAAM,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;AACzE,CAAC;AAED,MAAM,UAAU,2BAA2B,CAC1C,eAAmC,EACnC,gBAAwB;IAExB,IAAI,CAAC,eAAe;QAAE,OAAO,IAAI,CAAC;IAClC,OAAO,eAAe,KAAK,gBAAgB,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { UnknownContext } from "@pie-players/pie-context";
|
|
2
|
+
import { type RegionScopeContextListener, type RuntimeContextListener, type ShellContextListener } from "../context/runtime-context-consumer.js";
|
|
3
|
+
type BaseEventInit = Pick<EventInit, "bubbles" | "composed" | "cancelable">;
|
|
4
|
+
/**
|
|
5
|
+
* Contract helper for all toolkit/tool events that must cross custom-element boundaries.
|
|
6
|
+
*/
|
|
7
|
+
export declare function createCrossBoundaryEvent<T>(name: string, detail: T, init?: Partial<BaseEventInit>): CustomEvent<T>;
|
|
8
|
+
/**
|
|
9
|
+
* Dispatches a cross-boundary event with toolkit defaults.
|
|
10
|
+
*/
|
|
11
|
+
export declare function dispatchCrossBoundaryEvent<T>(target: EventTarget, name: string, detail: T, init?: Partial<BaseEventInit>): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Shared runtime-context connection contract for tools and shells.
|
|
14
|
+
* Uses retry + provider announcements so late providers are tolerated.
|
|
15
|
+
*/
|
|
16
|
+
export declare function connectToolRuntimeContext(host: HTMLElement, onValue: RuntimeContextListener): () => void;
|
|
17
|
+
/**
|
|
18
|
+
* Shared shell-context connection contract for tools needing item/passage scope.
|
|
19
|
+
*/
|
|
20
|
+
export declare function connectToolShellContext(host: HTMLElement, onValue: ShellContextListener): () => void;
|
|
21
|
+
/**
|
|
22
|
+
* Shared region-scope context contract for tools targeting content subregions.
|
|
23
|
+
*/
|
|
24
|
+
export declare function connectToolRegionScopeContext(host: HTMLElement, onValue: RegionScopeContextListener): () => void;
|
|
25
|
+
/**
|
|
26
|
+
* Guard utility: narrows unknown context payloads when needed by callers.
|
|
27
|
+
*/
|
|
28
|
+
export declare function isContextValueDefined<T extends UnknownContext>(value: unknown): value is T["__context__"];
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=tool-host-contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-host-contract.d.ts","sourceRoot":"","sources":["../../src/runtime/tool-host-contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAIN,KAAK,0BAA0B,EAC/B,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,MAAM,wCAAwC,CAAC;AAEhD,KAAK,aAAa,GAAG,IAAI,CAAC,SAAS,EAAE,SAAS,GAAG,UAAU,GAAG,YAAY,CAAC,CAAC;AAQ5E;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,EACzC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,CAAC,EACT,IAAI,GAAE,OAAO,CAAC,aAAa,CAAM,GAC/B,WAAW,CAAC,CAAC,CAAC,CAMhB;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,EAC3C,MAAM,EAAE,WAAW,EACnB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,CAAC,EACT,IAAI,GAAE,OAAO,CAAC,aAAa,CAAM,GAC/B,OAAO,CAET;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACxC,IAAI,EAAE,WAAW,EACjB,OAAO,EAAE,sBAAsB,GAC7B,MAAM,IAAI,CAEZ;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACtC,IAAI,EAAE,WAAW,EACjB,OAAO,EAAE,oBAAoB,GAC3B,MAAM,IAAI,CAEZ;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAC5C,IAAI,EAAE,WAAW,EACjB,OAAO,EAAE,0BAA0B,GACjC,MAAM,IAAI,CAEZ;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,cAAc,EAC7D,KAAK,EAAE,OAAO,GACZ,KAAK,IAAI,CAAC,CAAC,aAAa,CAAC,CAE3B"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { connectAssessmentToolkitRegionScopeContext, connectAssessmentToolkitRuntimeContext, connectAssessmentToolkitShellContext, } from "../context/runtime-context-consumer.js";
|
|
2
|
+
const CROSS_BOUNDARY_EVENT_INIT = {
|
|
3
|
+
bubbles: true,
|
|
4
|
+
composed: true,
|
|
5
|
+
cancelable: false,
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Contract helper for all toolkit/tool events that must cross custom-element boundaries.
|
|
9
|
+
*/
|
|
10
|
+
export function createCrossBoundaryEvent(name, detail, init = {}) {
|
|
11
|
+
return new CustomEvent(name, {
|
|
12
|
+
detail,
|
|
13
|
+
...CROSS_BOUNDARY_EVENT_INIT,
|
|
14
|
+
...init,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Dispatches a cross-boundary event with toolkit defaults.
|
|
19
|
+
*/
|
|
20
|
+
export function dispatchCrossBoundaryEvent(target, name, detail, init = {}) {
|
|
21
|
+
return target.dispatchEvent(createCrossBoundaryEvent(name, detail, init));
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Shared runtime-context connection contract for tools and shells.
|
|
25
|
+
* Uses retry + provider announcements so late providers are tolerated.
|
|
26
|
+
*/
|
|
27
|
+
export function connectToolRuntimeContext(host, onValue) {
|
|
28
|
+
return connectAssessmentToolkitRuntimeContext(host, onValue);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Shared shell-context connection contract for tools needing item/passage scope.
|
|
32
|
+
*/
|
|
33
|
+
export function connectToolShellContext(host, onValue) {
|
|
34
|
+
return connectAssessmentToolkitShellContext(host, onValue);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Shared region-scope context contract for tools targeting content subregions.
|
|
38
|
+
*/
|
|
39
|
+
export function connectToolRegionScopeContext(host, onValue) {
|
|
40
|
+
return connectAssessmentToolkitRegionScopeContext(host, onValue);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Guard utility: narrows unknown context payloads when needed by callers.
|
|
44
|
+
*/
|
|
45
|
+
export function isContextValueDefined(value) {
|
|
46
|
+
return value !== null && value !== undefined;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=tool-host-contract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-host-contract.js","sourceRoot":"","sources":["../../src/runtime/tool-host-contract.ts"],"names":[],"mappings":"AACA,OAAO,EACN,0CAA0C,EAC1C,sCAAsC,EACtC,oCAAoC,GAIpC,MAAM,wCAAwC,CAAC;AAIhD,MAAM,yBAAyB,GAAkB;IAChD,OAAO,EAAE,IAAI;IACb,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE,KAAK;CACjB,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,wBAAwB,CACvC,IAAY,EACZ,MAAS,EACT,OAA+B,EAAE;IAEjC,OAAO,IAAI,WAAW,CAAI,IAAI,EAAE;QAC/B,MAAM;QACN,GAAG,yBAAyB;QAC5B,GAAG,IAAI;KACP,CAAC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,0BAA0B,CACzC,MAAmB,EACnB,IAAY,EACZ,MAAS,EACT,OAA+B,EAAE;IAEjC,OAAO,MAAM,CAAC,aAAa,CAAC,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;AAC3E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CACxC,IAAiB,EACjB,OAA+B;IAE/B,OAAO,sCAAsC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC9D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB,CACtC,IAAiB,EACjB,OAA6B;IAE7B,OAAO,oCAAoC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC5D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,6BAA6B,CAC5C,IAAiB,EACjB,OAAmC;IAEnC,OAAO,0CAA0C,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAClE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CACpC,KAAc;IAEd,OAAO,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAC;AAC9C,CAAC"}
|
|
@@ -65,7 +65,16 @@ export declare class HighlightCoordinator implements IHighlightCoordinator {
|
|
|
65
65
|
private nextAnnotationId;
|
|
66
66
|
private supported;
|
|
67
67
|
private rangeSerializer;
|
|
68
|
+
private themeObserver;
|
|
69
|
+
private explicitTTSColorOverride;
|
|
68
70
|
constructor(config?: HighlightCoordinatorConfig);
|
|
71
|
+
private setupThemeObservation;
|
|
72
|
+
private parseColor;
|
|
73
|
+
private relativeLuminance;
|
|
74
|
+
private contrastRatio;
|
|
75
|
+
private blend;
|
|
76
|
+
private resolveAdaptiveTTSStyle;
|
|
77
|
+
private applyAdaptiveTTSStyle;
|
|
69
78
|
/**
|
|
70
79
|
* Initialize CSS Custom Highlights
|
|
71
80
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HighlightCoordinator.d.ts","sourceRoot":"","sources":["../../src/services/HighlightCoordinator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAmB,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE7E;;GAEG;AACH,oBAAY,aAAa;IACxB,QAAQ,aAAa;IACrB,YAAY,iBAAiB;IAC7B,UAAU,eAAe;CACzB;AAED;;GAEG;AACH,oBAAY,cAAc;IACzB,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,SAAS,cAAc;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,KAAK,CAAC;IACb,IAAI,EAAE,aAAa,CAAC,UAAU,CAAC;IAC/B,KAAK,EAAE,cAAc,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,MAAM,0BAA0B,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAE/D,qBAAa,oBAAqB,YAAW,qBAAqB;IACjE,OAAO,CAAC,MAAM,CAA6B;IAC3C,OAAO,CAAC,gBAAgB,CAA0B;IAClD,OAAO,CAAC,oBAAoB,CAA0B;IACtD,OAAO,CAAC,WAAW,CAAiC;IAEpD,OAA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E;IASD;;;;;;;OAOG;IACH,iBAAiB,CAChB,IAAI,EAAE,KAAK,CACV,eAAe,GAAG;QACjB,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE,cAAc,CAAC;QACtB,SAAS,CAAC,EAAE,MAAM,CAAC;KACnB,CACD,EACD,IAAI,GAAE,OAAuB,GAC3B,MAAM;IAkBT;;;;;OAKG;IACH,cAAc,CACb,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,aAAa,EACnB,KAAK,GAAE,cAAsC,GAC3C,IAAI;IAwBP;;OAEG;IACH,eAAe,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI;IAgB1C;;OAEG;IACH,QAAQ,IAAI,IAAI;IAMhB;;OAEG;IACH,WAAW,IAAI,OAAO;IAItB;;;;;OAKG;IACH,uBAAuB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IA6B7D;;OAEG;IACH,OAAO,IAAI,IAAI;CAgBf"}
|
|
@@ -52,6 +52,8 @@ export class HighlightCoordinator {
|
|
|
52
52
|
nextAnnotationId = 1;
|
|
53
53
|
supported = false;
|
|
54
54
|
rangeSerializer;
|
|
55
|
+
themeObserver = null;
|
|
56
|
+
explicitTTSColorOverride = null;
|
|
55
57
|
constructor(config = {}) {
|
|
56
58
|
this.config = config;
|
|
57
59
|
this.rangeSerializer = new RangeSerializer();
|
|
@@ -63,6 +65,176 @@ export class HighlightCoordinator {
|
|
|
63
65
|
this.supported = true;
|
|
64
66
|
this.initializeHighlights();
|
|
65
67
|
this.registerStyles();
|
|
68
|
+
this.applyAdaptiveTTSStyle();
|
|
69
|
+
this.setupThemeObservation();
|
|
70
|
+
}
|
|
71
|
+
setupThemeObservation() {
|
|
72
|
+
if (typeof document === "undefined")
|
|
73
|
+
return;
|
|
74
|
+
if (typeof MutationObserver === "undefined")
|
|
75
|
+
return;
|
|
76
|
+
const refresh = () => this.applyAdaptiveTTSStyle();
|
|
77
|
+
this.themeObserver = new MutationObserver(refresh);
|
|
78
|
+
this.themeObserver.observe(document.documentElement, {
|
|
79
|
+
attributes: true,
|
|
80
|
+
attributeFilter: ["style", "data-theme", "data-color-scheme", "class"],
|
|
81
|
+
});
|
|
82
|
+
for (const host of document.querySelectorAll("pie-theme")) {
|
|
83
|
+
this.themeObserver.observe(host, {
|
|
84
|
+
attributes: true,
|
|
85
|
+
attributeFilter: [
|
|
86
|
+
"theme",
|
|
87
|
+
"scheme",
|
|
88
|
+
"provider",
|
|
89
|
+
"variables",
|
|
90
|
+
"style",
|
|
91
|
+
"data-theme",
|
|
92
|
+
"data-color-scheme",
|
|
93
|
+
],
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
parseColor(input) {
|
|
98
|
+
if (!input)
|
|
99
|
+
return null;
|
|
100
|
+
const value = input.trim();
|
|
101
|
+
if (!value)
|
|
102
|
+
return null;
|
|
103
|
+
const hexMatch = /^#([a-f\d]{3}|[a-f\d]{6})$/i.exec(value);
|
|
104
|
+
if (hexMatch) {
|
|
105
|
+
const hex = hexMatch[1];
|
|
106
|
+
if (hex.length === 3) {
|
|
107
|
+
return [
|
|
108
|
+
parseInt(hex[0] + hex[0], 16),
|
|
109
|
+
parseInt(hex[1] + hex[1], 16),
|
|
110
|
+
parseInt(hex[2] + hex[2], 16),
|
|
111
|
+
];
|
|
112
|
+
}
|
|
113
|
+
return [
|
|
114
|
+
parseInt(hex.slice(0, 2), 16),
|
|
115
|
+
parseInt(hex.slice(2, 4), 16),
|
|
116
|
+
parseInt(hex.slice(4, 6), 16),
|
|
117
|
+
];
|
|
118
|
+
}
|
|
119
|
+
const rgbMatch = /^rgba?\((.+)\)$/i.exec(value);
|
|
120
|
+
if (rgbMatch) {
|
|
121
|
+
const normalized = rgbMatch[1].replace(/\//g, ",");
|
|
122
|
+
const parts = normalized
|
|
123
|
+
.split(/[,\s]+/)
|
|
124
|
+
.map((part) => part.trim())
|
|
125
|
+
.filter(Boolean);
|
|
126
|
+
const r = Number(parts[0]);
|
|
127
|
+
const g = Number(parts[1]);
|
|
128
|
+
const b = Number(parts[2]);
|
|
129
|
+
if (Number.isFinite(r) && Number.isFinite(g) && Number.isFinite(b)) {
|
|
130
|
+
return [r, g, b];
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
// Browser parser fallback (covers formats like oklch()).
|
|
134
|
+
if (typeof document !== "undefined") {
|
|
135
|
+
const parserEl = document.createElement("span");
|
|
136
|
+
parserEl.style.color = value;
|
|
137
|
+
if (typeof parserEl.style.color === "string" && parserEl.style.color) {
|
|
138
|
+
document.body?.appendChild(parserEl);
|
|
139
|
+
const resolved = typeof getComputedStyle === "function"
|
|
140
|
+
? getComputedStyle(parserEl).color
|
|
141
|
+
: "";
|
|
142
|
+
parserEl.remove();
|
|
143
|
+
const normalizedResolved = resolved.trim();
|
|
144
|
+
// Guard against recursive loops when computed style returns the same
|
|
145
|
+
// unresolved function syntax (observed with certain color formats).
|
|
146
|
+
if (normalizedResolved && normalizedResolved !== value) {
|
|
147
|
+
return this.parseColor(resolved);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
relativeLuminance([r, g, b]) {
|
|
154
|
+
const toLinear = (channel) => {
|
|
155
|
+
const n = channel / 255;
|
|
156
|
+
return n <= 0.03928 ? n / 12.92 : ((n + 0.055) / 1.055) ** 2.4;
|
|
157
|
+
};
|
|
158
|
+
const lr = toLinear(r);
|
|
159
|
+
const lg = toLinear(g);
|
|
160
|
+
const lb = toLinear(b);
|
|
161
|
+
return 0.2126 * lr + 0.7152 * lg + 0.0722 * lb;
|
|
162
|
+
}
|
|
163
|
+
contrastRatio(a, b) {
|
|
164
|
+
const la = this.relativeLuminance(a);
|
|
165
|
+
const lb = this.relativeLuminance(b);
|
|
166
|
+
const lighter = Math.max(la, lb);
|
|
167
|
+
const darker = Math.min(la, lb);
|
|
168
|
+
return (lighter + 0.05) / (darker + 0.05);
|
|
169
|
+
}
|
|
170
|
+
blend(fg, bg, alpha) {
|
|
171
|
+
return [
|
|
172
|
+
Math.round(fg[0] * alpha + bg[0] * (1 - alpha)),
|
|
173
|
+
Math.round(fg[1] * alpha + bg[1] * (1 - alpha)),
|
|
174
|
+
Math.round(fg[2] * alpha + bg[2] * (1 - alpha)),
|
|
175
|
+
];
|
|
176
|
+
}
|
|
177
|
+
resolveAdaptiveTTSStyle(sourceEl) {
|
|
178
|
+
const fallbackMissing = [255, 235, 59];
|
|
179
|
+
const fallbackText = [17, 24, 39];
|
|
180
|
+
const fallbackBackground = [255, 255, 255];
|
|
181
|
+
const target = sourceEl ||
|
|
182
|
+
(typeof document !== "undefined" ? document.documentElement : null);
|
|
183
|
+
const computed = target && typeof getComputedStyle === "function"
|
|
184
|
+
? getComputedStyle(target)
|
|
185
|
+
: null;
|
|
186
|
+
const background = this.parseColor(computed?.getPropertyValue("--pie-background") || computed?.backgroundColor) || fallbackBackground;
|
|
187
|
+
const text = this.parseColor(computed?.getPropertyValue("--pie-text")) || fallbackText;
|
|
188
|
+
const accent = this.explicitTTSColorOverride
|
|
189
|
+
? this.parseColor(this.explicitTTSColorOverride.color) || fallbackMissing
|
|
190
|
+
: this.parseColor(computed?.getPropertyValue("--pie-missing")) ||
|
|
191
|
+
fallbackMissing;
|
|
192
|
+
const opacityCandidates = this.explicitTTSColorOverride
|
|
193
|
+
? [Math.max(0.3, Math.min(0.95, this.explicitTTSColorOverride.opacity))]
|
|
194
|
+
: [0.8, 0.72, 0.68, 0.62, 0.56, 0.5];
|
|
195
|
+
let selectedOpacity = opacityCandidates[opacityCandidates.length - 1];
|
|
196
|
+
let bestScore = -Infinity;
|
|
197
|
+
for (const opacity of opacityCandidates) {
|
|
198
|
+
const blended = this.blend(accent, background, opacity);
|
|
199
|
+
const backgroundDelta = this.contrastRatio(blended, background);
|
|
200
|
+
const textContrast = this.contrastRatio(blended, text);
|
|
201
|
+
const score = backgroundDelta * 1.2 + textContrast * 0.8;
|
|
202
|
+
if (backgroundDelta >= 1.25 && textContrast >= 2.4) {
|
|
203
|
+
selectedOpacity = opacity;
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
if (score > bestScore) {
|
|
207
|
+
bestScore = score;
|
|
208
|
+
selectedOpacity = opacity;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
const sentenceOpacity = Math.max(0.24, Math.min(0.85, selectedOpacity * 0.55));
|
|
212
|
+
const underlineOpacity = Math.max(0.55, Math.min(0.95, selectedOpacity + 0.2));
|
|
213
|
+
const shadowOpacity = Math.max(0.22, Math.min(0.6, selectedOpacity * 0.45));
|
|
214
|
+
const underlineColor = text;
|
|
215
|
+
const underlineBlend = this.blend(underlineColor, background, underlineOpacity);
|
|
216
|
+
const underlineDelta = this.contrastRatio(underlineBlend, background);
|
|
217
|
+
const fallbackUnderline = this.relativeLuminance(background) > 0.45 ? [0, 0, 0] : [255, 255, 255];
|
|
218
|
+
const finalUnderline = underlineDelta >= 1.35 ? underlineColor : fallbackUnderline;
|
|
219
|
+
const wordHighlight = `rgba(${accent[0]}, ${accent[1]}, ${accent[2]}, ${selectedOpacity})`;
|
|
220
|
+
const sentenceHighlight = `rgba(${accent[0]}, ${accent[1]}, ${accent[2]}, ${sentenceOpacity})`;
|
|
221
|
+
const wordUnderline = `rgba(${finalUnderline[0]}, ${finalUnderline[1]}, ${finalUnderline[2]}, ${underlineOpacity})`;
|
|
222
|
+
const wordShadow = `rgba(${finalUnderline[0]}, ${finalUnderline[1]}, ${finalUnderline[2]}, ${shadowOpacity})`;
|
|
223
|
+
return {
|
|
224
|
+
wordHighlight,
|
|
225
|
+
sentenceHighlight,
|
|
226
|
+
wordUnderline,
|
|
227
|
+
wordShadow,
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
applyAdaptiveTTSStyle(sourceEl) {
|
|
231
|
+
if (typeof document === "undefined")
|
|
232
|
+
return;
|
|
233
|
+
const vars = this.resolveAdaptiveTTSStyle(sourceEl);
|
|
234
|
+
document.documentElement.style.setProperty("--pie-tts-word-highlight", vars.wordHighlight);
|
|
235
|
+
document.documentElement.style.setProperty("--pie-tts-sentence-highlight", vars.sentenceHighlight);
|
|
236
|
+
document.documentElement.style.setProperty("--pie-tts-word-underline", vars.wordUnderline);
|
|
237
|
+
document.documentElement.style.setProperty("--pie-tts-word-shadow", vars.wordShadow);
|
|
66
238
|
}
|
|
67
239
|
/**
|
|
68
240
|
* Initialize CSS Custom Highlights
|
|
@@ -99,44 +271,47 @@ export class HighlightCoordinator {
|
|
|
99
271
|
style.textContent = `
|
|
100
272
|
/* TTS highlights - temporary */
|
|
101
273
|
::highlight(tts-word) {
|
|
102
|
-
background-color:
|
|
274
|
+
background-color: var(--pie-tts-word-highlight, color-mix(in srgb, var(--pie-missing, #ffeb3b) 68%, transparent));
|
|
275
|
+
text-decoration: underline 2px solid var(--pie-tts-word-underline, color-mix(in srgb, var(--pie-text, #111827) 70%, transparent));
|
|
276
|
+
text-underline-offset: 2px;
|
|
277
|
+
text-shadow: 0 0 1px var(--pie-tts-word-shadow, color-mix(in srgb, var(--pie-text, #111827) 35%, transparent));
|
|
103
278
|
color: inherit;
|
|
104
279
|
}
|
|
105
280
|
|
|
106
281
|
::highlight(tts-sentence) {
|
|
107
|
-
background-color:
|
|
282
|
+
background-color: var(--pie-tts-sentence-highlight, color-mix(in srgb, var(--pie-missing, #ffeb3b) 38%, transparent));
|
|
108
283
|
color: inherit;
|
|
109
284
|
}
|
|
110
285
|
|
|
111
286
|
/* Annotation highlights - persistent */
|
|
112
287
|
::highlight(annotation-yellow) {
|
|
113
|
-
background-color:
|
|
288
|
+
background-color: color-mix(in srgb, var(--pie-missing, #ffff00) 35%, transparent);
|
|
114
289
|
color: inherit;
|
|
115
290
|
}
|
|
116
291
|
|
|
117
292
|
::highlight(annotation-green) {
|
|
118
|
-
background-color:
|
|
293
|
+
background-color: color-mix(in srgb, var(--pie-correct, #90ee90) 35%, transparent);
|
|
119
294
|
color: inherit;
|
|
120
295
|
}
|
|
121
296
|
|
|
122
297
|
::highlight(annotation-blue) {
|
|
123
|
-
background-color:
|
|
298
|
+
background-color: color-mix(in srgb, var(--pie-tertiary, #add8e6) 35%, transparent);
|
|
124
299
|
color: inherit;
|
|
125
300
|
}
|
|
126
301
|
|
|
127
302
|
::highlight(annotation-pink) {
|
|
128
|
-
background-color:
|
|
303
|
+
background-color: color-mix(in srgb, var(--pie-secondary-light, #ffb6c1) 35%, transparent);
|
|
129
304
|
color: inherit;
|
|
130
305
|
}
|
|
131
306
|
|
|
132
307
|
::highlight(annotation-orange) {
|
|
133
|
-
background-color:
|
|
308
|
+
background-color: color-mix(in srgb, var(--pie-incorrect, #ffa500) 35%, transparent);
|
|
134
309
|
color: inherit;
|
|
135
310
|
}
|
|
136
311
|
|
|
137
312
|
::highlight(annotation-underline) {
|
|
138
313
|
background-color: transparent;
|
|
139
|
-
text-decoration: underline 2px solid #0066cc;
|
|
314
|
+
text-decoration: underline 2px solid var(--pie-primary, #0066cc);
|
|
140
315
|
text-underline-offset: 2px;
|
|
141
316
|
color: inherit;
|
|
142
317
|
}
|
|
@@ -153,6 +328,7 @@ export class HighlightCoordinator {
|
|
|
153
328
|
highlightTTSWord(textNode, startOffset, endOffset) {
|
|
154
329
|
if (!this.ttsWordHighlight)
|
|
155
330
|
return;
|
|
331
|
+
this.applyAdaptiveTTSStyle(textNode.parentElement);
|
|
156
332
|
// Clear previous word highlight
|
|
157
333
|
this.clearTTSWord();
|
|
158
334
|
// Create range for word
|
|
@@ -170,6 +346,11 @@ export class HighlightCoordinator {
|
|
|
170
346
|
highlightTTSSentence(ranges) {
|
|
171
347
|
if (!this.ttsSentenceHighlight)
|
|
172
348
|
return;
|
|
349
|
+
const source = ranges[0]?.startContainer;
|
|
350
|
+
const sourceElement = source?.nodeType === Node.ELEMENT_NODE
|
|
351
|
+
? source
|
|
352
|
+
: source?.parentElement;
|
|
353
|
+
this.applyAdaptiveTTSStyle(sourceElement);
|
|
173
354
|
// Clear previous sentence highlight
|
|
174
355
|
this.clearTTSSentence();
|
|
175
356
|
// Add all ranges
|
|
@@ -425,53 +606,11 @@ export class HighlightCoordinator {
|
|
|
425
606
|
const rgb = hexToRgb(color);
|
|
426
607
|
if (!rgb)
|
|
427
608
|
return;
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
background-color: ${rgbaColor};
|
|
434
|
-
color: inherit;
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
::highlight(tts-sentence) {
|
|
438
|
-
background-color: rgba(173, 216, 230, 0.3);
|
|
439
|
-
color: inherit;
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
/* Annotation highlights - persistent */
|
|
443
|
-
::highlight(annotation-yellow) {
|
|
444
|
-
background-color: rgba(255, 255, 0, 0.3);
|
|
445
|
-
color: inherit;
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
::highlight(annotation-green) {
|
|
449
|
-
background-color: rgba(144, 238, 144, 0.3);
|
|
450
|
-
color: inherit;
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
::highlight(annotation-blue) {
|
|
454
|
-
background-color: rgba(173, 216, 230, 0.3);
|
|
455
|
-
color: inherit;
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
::highlight(annotation-pink) {
|
|
459
|
-
background-color: rgba(255, 182, 193, 0.3);
|
|
460
|
-
color: inherit;
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
::highlight(annotation-orange) {
|
|
464
|
-
background-color: rgba(255, 165, 0, 0.3);
|
|
465
|
-
color: inherit;
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
::highlight(annotation-underline) {
|
|
469
|
-
background-color: transparent;
|
|
470
|
-
text-decoration: underline 2px solid #0066cc;
|
|
471
|
-
text-underline-offset: 2px;
|
|
472
|
-
color: inherit;
|
|
473
|
-
}
|
|
474
|
-
`;
|
|
609
|
+
this.explicitTTSColorOverride = {
|
|
610
|
+
color: `rgb(${rgb.r}, ${rgb.g}, ${rgb.b})`,
|
|
611
|
+
opacity: Math.max(0.2, Math.min(0.95, opacity)),
|
|
612
|
+
};
|
|
613
|
+
this.applyAdaptiveTTSStyle();
|
|
475
614
|
}
|
|
476
615
|
/**
|
|
477
616
|
* Cleanup - remove all highlights
|
|
@@ -488,6 +627,8 @@ export class HighlightCoordinator {
|
|
|
488
627
|
styleEl.remove();
|
|
489
628
|
}
|
|
490
629
|
}
|
|
630
|
+
this.themeObserver?.disconnect();
|
|
631
|
+
this.themeObserver = null;
|
|
491
632
|
}
|
|
492
633
|
}
|
|
493
634
|
//# sourceMappingURL=HighlightCoordinator.js.map
|