@pie-players/pie-assessment-toolkit 0.3.50 → 0.3.52
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 +25 -0
- package/dist/components/ItemToolBar.custom-element.js +98 -14
- package/dist/components/PieAssessmentToolkit.custom-element.js +293 -48
- package/dist/components/SectionToolBar.custom-element.js +98 -14
- package/dist/context/assessment-toolkit-context.d.ts +2 -0
- package/dist/context/assessment-toolkit-context.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/services/HighlightCoordinator.d.ts +6 -0
- package/dist/services/HighlightCoordinator.js +20 -5
- package/dist/services/HighlightCoordinator.js.map +1 -1
- package/dist/services/TTSService.d.ts +19 -0
- package/dist/services/TTSService.js +238 -35
- package/dist/services/TTSService.js.map +1 -1
- package/dist/services/ToolkitCoordinator.d.ts +3 -2
- package/dist/services/ToolkitCoordinator.js.map +1 -1
- package/dist/services/createDefaultToolRegistry.d.ts +2 -1
- package/dist/services/createDefaultToolRegistry.js +2 -1
- package/dist/services/createDefaultToolRegistry.js.map +1 -1
- package/dist/services/interfaces.d.ts +15 -0
- package/dist/services/interfaces.js.map +1 -1
- package/dist/services/tool-config-defaults.d.ts +11 -0
- package/dist/services/tool-config-defaults.js +18 -0
- package/dist/services/tool-config-defaults.js.map +1 -1
- package/dist/services/tts/highlight-target-resolver.d.ts +17 -0
- package/dist/services/tts/highlight-target-resolver.js +2 -0
- package/dist/services/tts/highlight-target-resolver.js.map +1 -0
- package/dist/services/tts-runtime-config.d.ts +15 -1
- package/dist/services/tts-runtime-config.js +76 -10
- package/dist/services/tts-runtime-config.js.map +1 -1
- package/dist/tools/registrations/tts.js +6 -8
- package/dist/tools/registrations/tts.js.map +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -616,12 +616,37 @@ tools: {
|
|
|
616
616
|
}
|
|
617
617
|
```
|
|
618
618
|
|
|
619
|
+
Hosts that need semantic UI copy can use object-form options. The `rate` still
|
|
620
|
+
drives playback and provider mapping; `label` / `ariaLabel` only change visible
|
|
621
|
+
and accessible button text.
|
|
622
|
+
|
|
623
|
+
```typescript
|
|
624
|
+
tools: {
|
|
625
|
+
providers: {
|
|
626
|
+
textToSpeech: {
|
|
627
|
+
enabled: true,
|
|
628
|
+
backend: "server",
|
|
629
|
+
serverProvider: "custom",
|
|
630
|
+
settings: {
|
|
631
|
+
speedOptions: [
|
|
632
|
+
{ rate: 0.8, label: "Slow", ariaLabel: "Slow speed" },
|
|
633
|
+
{ rate: 1.5, label: "Fast", ariaLabel: "Fast speed" }
|
|
634
|
+
]
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
```
|
|
640
|
+
|
|
619
641
|
`speedOptions` semantics:
|
|
620
642
|
|
|
621
643
|
- Omitted or non-array: default speed buttons are shown (`0.8x`, `1.25x`).
|
|
622
644
|
- Explicit empty array (`[]`): hide all speed buttons.
|
|
623
645
|
- Invalid-only arrays (for example `["fast", -1, 1]`): fall back to defaults.
|
|
624
646
|
- Valid numeric values are deduplicated and keep first-seen order.
|
|
647
|
+
- Object-form entries use the same numeric validation/deduping by `rate`.
|
|
648
|
+
- Missing labels fall back to numeric text like `1.5x`; missing `ariaLabel`
|
|
649
|
+
falls back to a matching accessible name like `Fast speed`.
|
|
625
650
|
- `1` is excluded (normal speed is already available by toggling active speed off).
|
|
626
651
|
|
|
627
652
|
### Runtime Fallback: Server TTS -> Browser TTS
|
|
@@ -6871,22 +6871,81 @@ var isServerBackend = (backend) => backend === "polly" || backend === "google" |
|
|
|
6871
6871
|
var withDefault = (value, fallback2) => value === undefined ? fallback2 : value;
|
|
6872
6872
|
var normalizeTTSLayoutMode = (value, fallback2 = "left-aligned") => typeof value === "string" && VALID_TTS_LAYOUT_MODES.has(value) ? value : fallback2;
|
|
6873
6873
|
var DEFAULT_TTS_SPEED_OPTIONS = Object.freeze([0.8, 1.25]);
|
|
6874
|
-
var
|
|
6874
|
+
var normalizeSpeedRate = (entry) => {
|
|
6875
|
+
if (typeof entry !== "number" || !Number.isFinite(entry) || entry <= 0) {
|
|
6876
|
+
return;
|
|
6877
|
+
}
|
|
6878
|
+
const rounded = Math.round(entry * 100) / 100;
|
|
6879
|
+
return rounded === 1 ? undefined : rounded;
|
|
6880
|
+
};
|
|
6881
|
+
var trimOptionalText = (value) => {
|
|
6882
|
+
if (typeof value !== "string")
|
|
6883
|
+
return;
|
|
6884
|
+
const trimmed = value.trim();
|
|
6885
|
+
return trimmed.length ? trimmed : undefined;
|
|
6886
|
+
};
|
|
6887
|
+
var formatSpeedLabel = (rate) => `${rate}x`;
|
|
6888
|
+
var formatSpeedAriaLabel = (label, usedDefaultLabel) => usedDefaultLabel ? `Speed ${label}` : `${label} speed`;
|
|
6889
|
+
var normalizeSpeedAriaLabel = (label, ariaLabel, usedDefaultLabel) => {
|
|
6890
|
+
if (!ariaLabel)
|
|
6891
|
+
return formatSpeedAriaLabel(label, usedDefaultLabel);
|
|
6892
|
+
if (ariaLabel.toLowerCase().includes(label.toLowerCase()))
|
|
6893
|
+
return ariaLabel;
|
|
6894
|
+
return `${label} ${ariaLabel}`;
|
|
6895
|
+
};
|
|
6896
|
+
var normalizeTTSSpeedOptionConfig = (entry) => {
|
|
6897
|
+
if (typeof entry === "number")
|
|
6898
|
+
return normalizeSpeedRate(entry);
|
|
6899
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry))
|
|
6900
|
+
return;
|
|
6901
|
+
const record = entry;
|
|
6902
|
+
const rate = normalizeSpeedRate(record.rate);
|
|
6903
|
+
if (rate === undefined)
|
|
6904
|
+
return;
|
|
6905
|
+
const label = trimOptionalText(record.label);
|
|
6906
|
+
const ariaLabel = trimOptionalText(record.ariaLabel);
|
|
6907
|
+
return {
|
|
6908
|
+
rate,
|
|
6909
|
+
...label ? { label } : {},
|
|
6910
|
+
...ariaLabel ? { ariaLabel } : {}
|
|
6911
|
+
};
|
|
6912
|
+
};
|
|
6913
|
+
var normalizeTTSSpeedOptionConfigs = (value) => {
|
|
6875
6914
|
if (!Array.isArray(value))
|
|
6876
6915
|
return [...DEFAULT_TTS_SPEED_OPTIONS];
|
|
6877
6916
|
if (value.length === 0)
|
|
6878
6917
|
return [];
|
|
6879
|
-
const
|
|
6918
|
+
const dedupedRates = new Set;
|
|
6919
|
+
const normalized = [];
|
|
6880
6920
|
for (const entry of value) {
|
|
6881
|
-
|
|
6921
|
+
const option = normalizeTTSSpeedOptionConfig(entry);
|
|
6922
|
+
if (option === undefined)
|
|
6882
6923
|
continue;
|
|
6883
|
-
const
|
|
6884
|
-
if (
|
|
6924
|
+
const rate = typeof option === "number" ? option : option.rate;
|
|
6925
|
+
if (dedupedRates.has(rate))
|
|
6885
6926
|
continue;
|
|
6886
|
-
|
|
6927
|
+
dedupedRates.add(rate);
|
|
6928
|
+
normalized.push(option);
|
|
6887
6929
|
}
|
|
6888
|
-
return
|
|
6930
|
+
return normalized.length ? normalized : [...DEFAULT_TTS_SPEED_OPTIONS];
|
|
6889
6931
|
};
|
|
6932
|
+
var normalizeTTSSpeedControlOptions = (value) => normalizeTTSSpeedOptionConfigs(value).map((option) => {
|
|
6933
|
+
if (typeof option === "number") {
|
|
6934
|
+
const label2 = formatSpeedLabel(option);
|
|
6935
|
+
return {
|
|
6936
|
+
rate: option,
|
|
6937
|
+
label: label2,
|
|
6938
|
+
ariaLabel: formatSpeedAriaLabel(label2, true)
|
|
6939
|
+
};
|
|
6940
|
+
}
|
|
6941
|
+
const defaultLabel = formatSpeedLabel(option.rate);
|
|
6942
|
+
const label = option.label || defaultLabel;
|
|
6943
|
+
return {
|
|
6944
|
+
rate: option.rate,
|
|
6945
|
+
label,
|
|
6946
|
+
ariaLabel: normalizeSpeedAriaLabel(label, option.ariaLabel, label === defaultLabel)
|
|
6947
|
+
};
|
|
6948
|
+
});
|
|
6890
6949
|
var applyRuntimeDefaults = (config) => {
|
|
6891
6950
|
const withLayoutDefaults = {
|
|
6892
6951
|
...config,
|
|
@@ -7043,7 +7102,7 @@ var ttsToolRegistration = {
|
|
|
7043
7102
|
settings.layoutMode = normalizeTTSLayoutMode(settings.layoutMode);
|
|
7044
7103
|
}
|
|
7045
7104
|
if (settings && "speedOptions" in settings) {
|
|
7046
|
-
settings.speedOptions =
|
|
7105
|
+
settings.speedOptions = normalizeTTSSpeedOptionConfigs(settings.speedOptions);
|
|
7047
7106
|
}
|
|
7048
7107
|
const normalizedConfig = {
|
|
7049
7108
|
...config
|
|
@@ -7052,7 +7111,7 @@ var ttsToolRegistration = {
|
|
|
7052
7111
|
normalizedConfig.layoutMode = normalizeTTSLayoutMode(normalizedConfig.layoutMode);
|
|
7053
7112
|
}
|
|
7054
7113
|
if ("speedOptions" in normalizedConfig) {
|
|
7055
|
-
normalizedConfig.speedOptions =
|
|
7114
|
+
normalizedConfig.speedOptions = normalizeTTSSpeedOptionConfigs(normalizedConfig.speedOptions);
|
|
7056
7115
|
}
|
|
7057
7116
|
if (settings) {
|
|
7058
7117
|
normalizedConfig.settings = settings;
|
|
@@ -7075,7 +7134,7 @@ var ttsToolRegistration = {
|
|
|
7075
7134
|
const resolveRuntimeSettings = () => resolveTTSRuntimeSettings(toolbarContext.toolkitCoordinator?.getToolConfig(this.toolId) || undefined);
|
|
7076
7135
|
const resolveElementSpeedOptions = () => {
|
|
7077
7136
|
const runtimeSettings = resolveRuntimeSettings();
|
|
7078
|
-
return
|
|
7137
|
+
return normalizeTTSSpeedControlOptions(runtimeSettings.speedOptions);
|
|
7079
7138
|
};
|
|
7080
7139
|
const resolveLayoutMode = () => resolveTTSLayoutMode(resolveRuntimeSettings());
|
|
7081
7140
|
const resolveHostLayout = () => resolveTTSHostToolbarLayout(resolveRuntimeSettings());
|
|
@@ -9334,13 +9393,34 @@ function ItemToolBar($$anchor, $$props) {
|
|
|
9334
9393
|
const maxHeight = shellConfig?.maxHeight ?? window.innerHeight;
|
|
9335
9394
|
return { minWidth, minHeight, maxWidth, maxHeight };
|
|
9336
9395
|
};
|
|
9396
|
+
const applyContentMinWidth = () => {
|
|
9397
|
+
const configuredMinWidth = currentArgs.mounted.entry.shell?.minWidth;
|
|
9398
|
+
const shouldScroll = typeof configuredMinWidth === "number" && configuredMinWidth > 0 && width < configuredMinWidth;
|
|
9399
|
+
const minWidthValue = shouldScroll ? `${configuredMinWidth}px` : "";
|
|
9400
|
+
if (mountedContentElement) {
|
|
9401
|
+
mountedContentElement.style.minWidth = minWidthValue;
|
|
9402
|
+
}
|
|
9403
|
+
if (headerEl) {
|
|
9404
|
+
headerEl.style.minWidth = minWidthValue;
|
|
9405
|
+
}
|
|
9406
|
+
if (contentEl) {
|
|
9407
|
+
contentEl.style.minWidth = minWidthValue;
|
|
9408
|
+
}
|
|
9409
|
+
if (shellEl) {
|
|
9410
|
+
shellEl.style.overflowX = shouldScroll ? "auto" : "visible";
|
|
9411
|
+
shellEl.style.overflowY = "visible";
|
|
9412
|
+
}
|
|
9413
|
+
};
|
|
9337
9414
|
const applyPositionAndSize = () => {
|
|
9338
9415
|
const { minWidth, minHeight, maxWidth, maxHeight } = getShellBounds();
|
|
9339
|
-
|
|
9340
|
-
|
|
9416
|
+
const effectiveMinWidth = Math.min(minWidth, window.innerWidth);
|
|
9417
|
+
const effectiveMinHeight = Math.min(minHeight, window.innerHeight);
|
|
9418
|
+
width = clamp(width, effectiveMinWidth, Math.max(effectiveMinWidth, Math.min(maxWidth, window.innerWidth)));
|
|
9419
|
+
height = clamp(height, effectiveMinHeight, Math.max(effectiveMinHeight, Math.min(maxHeight, window.innerHeight)));
|
|
9341
9420
|
x2 = clamp(x2, 0, Math.max(0, window.innerWidth - width));
|
|
9342
9421
|
y2 = clamp(y2, 0, Math.max(0, window.innerHeight - height));
|
|
9343
9422
|
applyShellStyle();
|
|
9423
|
+
applyContentMinWidth();
|
|
9344
9424
|
notifyHostedResize();
|
|
9345
9425
|
};
|
|
9346
9426
|
const moveBy = (dx, dy) => {
|
|
@@ -9441,6 +9521,7 @@ function ItemToolBar($$anchor, $$props) {
|
|
|
9441
9521
|
element2.style.height = "100%";
|
|
9442
9522
|
element2.style.flex = "1 1 auto";
|
|
9443
9523
|
element2.style.minHeight = "0";
|
|
9524
|
+
applyContentMinWidth();
|
|
9444
9525
|
if (mountedContentElement && mountedContentElement !== element2) {
|
|
9445
9526
|
if (mountedContentElement.parentNode === contentEl) {
|
|
9446
9527
|
invokeElementUnmount(mountedContentElement);
|
|
@@ -9689,8 +9770,10 @@ function ItemToolBar($$anchor, $$props) {
|
|
|
9689
9770
|
if (resizePointerId === event2.pointerId) {
|
|
9690
9771
|
event2.preventDefault();
|
|
9691
9772
|
const shellConfig = currentArgs.mounted.entry.shell;
|
|
9692
|
-
const
|
|
9693
|
-
const
|
|
9773
|
+
const configuredMinWidth = shellConfig?.minWidth ?? 320;
|
|
9774
|
+
const configuredMinHeight = shellConfig?.minHeight ?? 240;
|
|
9775
|
+
const minWidth = Math.min(configuredMinWidth, window.innerWidth);
|
|
9776
|
+
const minHeight = Math.min(configuredMinHeight, window.innerHeight);
|
|
9694
9777
|
const maxWidth = shellConfig?.maxWidth ?? window.innerWidth;
|
|
9695
9778
|
const maxHeight = shellConfig?.maxHeight ?? window.innerHeight;
|
|
9696
9779
|
const dx = event2.clientX - resizeStartX;
|
|
@@ -9721,6 +9804,7 @@ function ItemToolBar($$anchor, $$props) {
|
|
|
9721
9804
|
height = newHeight;
|
|
9722
9805
|
}
|
|
9723
9806
|
applyShellStyle();
|
|
9807
|
+
applyContentMinWidth();
|
|
9724
9808
|
notifyHostedResize();
|
|
9725
9809
|
}
|
|
9726
9810
|
};
|