@pie-players/pie-players-shared 1.0.0-beta.0 → 1.0.0-beta.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/LICENSE +21 -0
- package/README.md +18 -17
- package/dist/THIRD-PARTY-LICENSES.txt +51 -0
- package/dist/components/vendor/nds/README.md +43 -5
- package/dist/components/vendor/nds/nds-icon-button.d.ts +2 -2
- package/dist/components/vendor/nds/nds-icon-button.js +2 -2
- package/dist/i18n/catalogs.d.ts +25 -13
- package/dist/i18n/catalogs.js +30 -22
- package/dist/i18n/content-language.d.ts +77 -0
- package/dist/i18n/content-language.js +129 -0
- package/dist/i18n/index.d.ts +7 -2
- package/dist/i18n/index.js +5 -2
- package/dist/i18n/language-tags.d.ts +3 -55
- package/dist/i18n/language-tags.js +3 -90
- package/dist/i18n/locale-load-error.d.ts +35 -0
- package/dist/i18n/locale-load-error.js +30 -0
- package/dist/i18n/messages/en-US.d.ts +151 -7
- package/dist/i18n/messages/en-US.js +168 -7
- package/dist/i18n/provider.d.ts +122 -18
- package/dist/i18n/provider.js +315 -133
- package/dist/i18n/pseudo.d.ts +34 -0
- package/dist/i18n/pseudo.js +106 -0
- package/dist/i18n/types.d.ts +19 -3
- package/dist/index.d.ts +16 -20
- package/dist/index.js +19 -19
- package/dist/instrumentation/providers/CompositeInstrumentationProvider.js +2 -1
- package/dist/item-session-control/index.d.ts +16 -0
- package/dist/item-session-control/index.js +5 -0
- package/dist/{formative → item-session-control}/mastery.d.ts +5 -5
- package/dist/{formative → item-session-control}/mastery.js +3 -3
- package/dist/{formative → item-session-control}/outcome.d.ts +3 -3
- package/dist/{formative → item-session-control}/outcome.js +2 -2
- package/dist/{formative → item-session-control}/policy.d.ts +11 -11
- package/dist/{formative → item-session-control}/policy.js +12 -12
- package/dist/item-session-control/session.d.ts +19 -0
- package/dist/{formative → item-session-control}/session.js +12 -12
- package/dist/{formative → item-session-control}/state.d.ts +26 -26
- package/dist/{formative → item-session-control}/state.js +13 -13
- package/dist/{formative → item-session-control}/types.d.ts +38 -40
- package/dist/{formative → item-session-control}/types.js +2 -2
- package/dist/loaders/ElementLoader.d.ts +1 -1
- package/dist/loaders/element-loader.d.ts +4 -1
- package/dist/loaders/element-loader.js +74 -21
- package/dist/loaders/element-package-spec.d.ts +16 -0
- package/dist/loaders/element-package-spec.js +30 -0
- package/dist/loaders/esm-adapter.d.ts +12 -1
- package/dist/loaders/esm-adapter.js +113 -19
- package/dist/loaders/iife-adapter.d.ts +7 -0
- package/dist/loaders/iife-adapter.js +1 -1
- package/dist/loaders/index.d.ts +2 -1
- package/dist/loaders/index.js +2 -1
- package/dist/loaders/preloaded-registration.d.ts +18 -6
- package/dist/loaders/preloaded-registration.js +44 -9
- package/dist/object/index.d.ts +4 -1
- package/dist/object/index.js +8 -1
- package/dist/pie/config.d.ts +8 -0
- package/dist/pie/config.js +32 -1
- package/dist/pie/index.d.ts +2 -0
- package/dist/pie/index.js +1 -0
- package/dist/pie/math-rendering.d.ts +13 -1
- package/dist/pie/math-rendering.js +54 -1
- package/dist/pie/updates.d.ts +4 -1
- package/dist/pie/updates.js +21 -5
- package/dist/pie/versioned-tag.d.ts +10 -0
- package/dist/pie/versioned-tag.js +27 -0
- package/dist/promise/index.d.ts +10 -0
- package/dist/promise/index.js +16 -0
- package/dist/security/overwide-regions.js +65 -0
- package/dist/security/private-hosts.d.ts +27 -0
- package/dist/security/private-hosts.js +85 -0
- package/dist/security/validate-style-url.js +2 -2
- package/dist/security/wrap-overwide-images.d.ts +6 -2
- package/dist/security/wrap-overwide-images.js +5 -2
- package/dist/security/wrap-overwide-tables.d.ts +6 -2
- package/dist/security/wrap-overwide-tables.js +5 -2
- package/dist/security/wrap-overwide.d.ts +13 -0
- package/dist/security/wrap-overwide.js +68 -3
- package/dist/timed-media/index.d.ts +1 -1
- package/dist/timed-media/index.js +1 -1
- package/dist/timed-media/policy.d.ts +2 -2
- package/dist/timed-media/policy.js +2 -2
- package/dist/timed-media/session.d.ts +1 -1
- package/dist/timed-media/session.js +1 -1
- package/dist/timed-media/types.d.ts +11 -11
- package/dist/tools/term-lookup.d.ts +15 -0
- package/dist/tools/term-lookup.js +16 -0
- package/dist/types/index.d.ts +127 -47
- package/dist/types/interchange.d.ts +116 -0
- package/dist/types/interchange.js +1 -0
- package/dist/ui/content-styles-entry.d.ts +1 -0
- package/dist/ui/content-styles-entry.js +2 -0
- package/dist/ui/content-styles.d.ts +24 -3
- package/dist/ui/content-styles.js +114 -3
- package/dist/ui/focus-trap.d.ts +12 -0
- package/dist/ui/focus-trap.js +41 -1
- package/dist/ui/fontawesome.d.ts +51 -0
- package/dist/ui/fontawesome.js +122 -0
- package/dist/ui/ime.d.ts +6 -0
- package/dist/ui/ime.js +10 -0
- package/dist/ui/overlay-containment.d.ts +13 -0
- package/dist/ui/overlay-containment.js +23 -0
- package/dist/ui/overlay-placement.d.ts +28 -0
- package/dist/ui/overlay-placement.js +17 -2
- package/package.json +72 -36
- package/dist/formative/index.d.ts +0 -16
- package/dist/formative/index.js +0 -5
- package/dist/formative/session.d.ts +0 -19
- package/dist/i18n/messages/nl-NL.d.ts +0 -529
- package/dist/i18n/messages/nl-NL.js +0 -529
- package/dist/instrumentation/new-relic-agent.d.ts +0 -20
- package/dist/loaders/module-shim.d.ts +0 -12
- package/dist/pie/authoring-tag.d.ts +0 -6
- package/dist/pie/configure-initialization.d.ts +0 -21
- package/dist/pie/correct-response-env.d.ts +0 -3
- package/dist/pie/element-announcements.d.ts +0 -39
- package/dist/pie/elements-rendered.d.ts +0 -23
- package/dist/pie/initialize-element.d.ts +0 -26
- package/dist/pie/markup-math.d.ts +0 -20
- package/dist/pie/resource-monitor.d.ts +0 -217
- package/dist/security/sanitize-forbidden-lists.d.ts +0 -8
- package/dist/ui/pointer-rotate.d.ts +0 -29
- package/dist/ui/safe-storage.d.ts +0 -2
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/** Expanded Latin pseudo-locale: text grows ~40% and carries accents and brackets. */
|
|
2
|
+
export const PSEUDO_LOCALE_EXPANDED = "en-XA";
|
|
3
|
+
/**
|
|
4
|
+
* Right-to-left pseudo-locale: the same transformed English under an `ar` primary
|
|
5
|
+
* subtag, so `localeDirection` resolves RTL and chrome lays out mirrored without a
|
|
6
|
+
* word of Arabic on screen.
|
|
7
|
+
*/
|
|
8
|
+
export const PSEUDO_LOCALE_RTL = "ar-XB";
|
|
9
|
+
const ACCENTS = {
|
|
10
|
+
a: "á",
|
|
11
|
+
A: "Á",
|
|
12
|
+
b: "ƀ",
|
|
13
|
+
B: "Ƀ",
|
|
14
|
+
c: "ç",
|
|
15
|
+
C: "Ç",
|
|
16
|
+
d: "ð",
|
|
17
|
+
D: "Ð",
|
|
18
|
+
e: "é",
|
|
19
|
+
E: "É",
|
|
20
|
+
f: "ƒ",
|
|
21
|
+
F: "Ƒ",
|
|
22
|
+
g: "ğ",
|
|
23
|
+
G: "Ğ",
|
|
24
|
+
h: "ĥ",
|
|
25
|
+
H: "Ĥ",
|
|
26
|
+
i: "í",
|
|
27
|
+
I: "Í",
|
|
28
|
+
j: "ĵ",
|
|
29
|
+
J: "Ĵ",
|
|
30
|
+
k: "ķ",
|
|
31
|
+
K: "Ķ",
|
|
32
|
+
l: "ĺ",
|
|
33
|
+
L: "Ĺ",
|
|
34
|
+
m: "ḿ",
|
|
35
|
+
M: "Ḿ",
|
|
36
|
+
n: "ñ",
|
|
37
|
+
N: "Ñ",
|
|
38
|
+
o: "ó",
|
|
39
|
+
O: "Ó",
|
|
40
|
+
p: "þ",
|
|
41
|
+
P: "Þ",
|
|
42
|
+
q: "ǫ",
|
|
43
|
+
Q: "Ǫ",
|
|
44
|
+
r: "ŕ",
|
|
45
|
+
R: "Ŕ",
|
|
46
|
+
s: "š",
|
|
47
|
+
S: "Š",
|
|
48
|
+
t: "ŧ",
|
|
49
|
+
T: "Ŧ",
|
|
50
|
+
u: "ú",
|
|
51
|
+
U: "Ú",
|
|
52
|
+
v: "ṽ",
|
|
53
|
+
V: "Ṽ",
|
|
54
|
+
w: "ŵ",
|
|
55
|
+
W: "Ŵ",
|
|
56
|
+
x: "ẋ",
|
|
57
|
+
X: "Ẋ",
|
|
58
|
+
y: "ý",
|
|
59
|
+
Y: "Ý",
|
|
60
|
+
z: "ž",
|
|
61
|
+
Z: "Ž",
|
|
62
|
+
};
|
|
63
|
+
const PLACEHOLDER = /(\{\w+\})/g;
|
|
64
|
+
function pseudoText(text, { expansion, accents, brackets }) {
|
|
65
|
+
const segments = text.split(PLACEHOLDER);
|
|
66
|
+
const transformed = segments.map((segment, index) => {
|
|
67
|
+
// A capturing split leaves each placeholder at an odd index, verbatim.
|
|
68
|
+
if (index % 2 === 1 || segment === "")
|
|
69
|
+
return segment;
|
|
70
|
+
let out = segment;
|
|
71
|
+
if (accents) {
|
|
72
|
+
out = out.replace(/[a-zA-Z]/g, (letter) => ACCENTS[letter] ?? letter);
|
|
73
|
+
}
|
|
74
|
+
if (expansion <= 0)
|
|
75
|
+
return out;
|
|
76
|
+
const padding = Math.max(1, Math.ceil(segment.length * expansion));
|
|
77
|
+
return `${out} ${"~".repeat(padding)}`;
|
|
78
|
+
});
|
|
79
|
+
const joined = transformed.join("");
|
|
80
|
+
return brackets ? `[${joined}]` : joined;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Produce the pseudo-localized twin of a catalog: same keys, same plural
|
|
84
|
+
* categories, same placeholder sets, longer accented bracketed strings.
|
|
85
|
+
*/
|
|
86
|
+
export function pseudoLocalize(catalog, options) {
|
|
87
|
+
const settings = {
|
|
88
|
+
expansion: options?.expansion ?? 0.4,
|
|
89
|
+
brackets: options?.brackets ?? true,
|
|
90
|
+
accents: options?.accents ?? true,
|
|
91
|
+
};
|
|
92
|
+
const result = {};
|
|
93
|
+
for (const [key, node] of Object.entries(catalog)) {
|
|
94
|
+
result[key] = pseudoNode(node, settings);
|
|
95
|
+
}
|
|
96
|
+
return result;
|
|
97
|
+
}
|
|
98
|
+
function pseudoNode(node, settings) {
|
|
99
|
+
if (typeof node === "string")
|
|
100
|
+
return pseudoText(node, settings);
|
|
101
|
+
const branch = {};
|
|
102
|
+
for (const [key, child] of Object.entries(node)) {
|
|
103
|
+
branch[key] = pseudoNode(child, settings);
|
|
104
|
+
}
|
|
105
|
+
return branch;
|
|
106
|
+
}
|
package/dist/i18n/types.d.ts
CHANGED
|
@@ -16,8 +16,13 @@ import type enUS from "./messages/en-US.js";
|
|
|
16
16
|
* syntax — the Learnosity transform emits POSIX `nl_NL`, QTI catalog cards carry
|
|
17
17
|
* `xml:lang` — and the resolver normalizes both onto these, so this list is the
|
|
18
18
|
* set of catalogs, not the set of accepted inputs.
|
|
19
|
+
*
|
|
20
|
+
* `en-US` is the only bundled catalog: the statically resident source of truth
|
|
21
|
+
* every other locale falls back through. Every other locale this repository
|
|
22
|
+
* ships lives in the optional generated tier
|
|
23
|
+
* (`@pie-players/pie-i18n-generated`), which a host composes into its loader.
|
|
19
24
|
*/
|
|
20
|
-
export type BundledLocaleCode = "en-US"
|
|
25
|
+
export type BundledLocaleCode = "en-US";
|
|
21
26
|
/**
|
|
22
27
|
* Any locale tag. A host may supply a locale we ship no catalog for and provide
|
|
23
28
|
* its own messages through {@link I18nConfig.customMessages}, so this is
|
|
@@ -52,7 +57,7 @@ type PluralCategoryKey = keyof PluralTranslation;
|
|
|
52
57
|
* Dot-notation keys of a catalog shape.
|
|
53
58
|
*
|
|
54
59
|
* A plural group terminates the path at the group itself: `plural()` is called
|
|
55
|
-
* with `player.
|
|
60
|
+
* with `player.check.triesLeft`, never with `…triesLeft.other`. A group is
|
|
56
61
|
* recognized by every one of its keys being a CLDR plural category — the
|
|
57
62
|
* containment has to run this way round, because a group carrying only
|
|
58
63
|
* `one`/`other` does not contain the whole category union.
|
|
@@ -142,8 +147,19 @@ export interface I18nConfig {
|
|
|
142
147
|
* i18next, ICU MessageFormat or its own catalog rather than take ours.
|
|
143
148
|
*/
|
|
144
149
|
export interface I18nProvider {
|
|
145
|
-
/**
|
|
150
|
+
/**
|
|
151
|
+
* The locale whose strings are served: the resolved catalog's tag once
|
|
152
|
+
* resident, else the most specific tag on the request's truncation chain
|
|
153
|
+
* the host supplied messages for, else the fallback locale.
|
|
154
|
+
*/
|
|
146
155
|
getLocale(): string;
|
|
156
|
+
/**
|
|
157
|
+
* The tag last requested through `setLocale` or the configured locale, as
|
|
158
|
+
* soon as it is requested. Players answer `interfaceLocaleContext` with it,
|
|
159
|
+
* since elements resolve the tag against their own catalogs. A provider
|
|
160
|
+
* that omits it is read through `getLocale`.
|
|
161
|
+
*/
|
|
162
|
+
getRequestedLocale?(): string;
|
|
147
163
|
/**
|
|
148
164
|
* Switch locale, loading its catalog if a loader is configured.
|
|
149
165
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export type { AssessmentEntity, AssessmentItemRef, AssessmentSection, AdvancedItemConfig, ConfigEntity, ConfigResource, Env, FormativeDeliveryPolicy, FormativeItemPolicy, TimedMediaSectionData, ItemConfig, ItemEntity, ItemSession, OutcomeResponse, PassageEntity, PieController, PieContent, PieDefaultModel, PieItemElement, PieModel, PieUpdateSession, ReferencedItemEntity, ReferencedPassageEntity, RubricBlock, TestPart, } from "./types/index.js";
|
|
1
|
+
export { BUILDER_BUNDLE_URL, } from "./config/profile.js";
|
|
2
|
+
export { BaseInstrumentationProvider, CompositeInstrumentationProvider, ConsoleInstrumentationProvider, type ConsoleProviderConfig, DebugPanelInstrumentationProvider, type ErrorAttributes, type EventAttributes, INSTRUMENTATION_DEBUG_EVENT_NAME, type InstrumentationConfig, type InstrumentationDebugRecord, type InstrumentationProvider, type MetricAttributes, NewRelicInstrumentationProvider, clearBufferedInstrumentationDebugRecords, getBufferedInstrumentationDebugRecords, isInstrumentationProvider, subscribeInstrumentationDebugRecords, } from "./instrumentation/index.js";
|
|
3
|
+
export { DEFAULT_IIFE_BUNDLE_RETRY_CONFIG, DEFAULT_LOADER_CONFIG, type IifeBundleRetryConfig, type LoaderConfig, } from "./loader-config.js";
|
|
4
|
+
export { type ItemPlayerStrategy, type ItemPlayerView, normalizeItemPlayerStrategy, resolveItemPlayerView, } from "./player-strategy.js";
|
|
5
|
+
export { type ItemMarkupSanitizer, type SanitizeItemMarkupOptions, type StyleUrlValidationError, type StyleUrlValidationOk, type StyleUrlValidationOptions, type StyleUrlValidationResult, buildAuthoringAllowList, createDefaultItemMarkupSanitizer, isOverwideImageWrapMutation, isOverwideTableWrapMutation, parseAllowedStyleOrigins, sanitizeItemMarkup, sanitizeStyleAttribute, sanitizeSvgIcon, validateExternalStyleUrl, wrapOverwideImages, wrapOverwideImagesInElement, wrapOverwideTables, wrapOverwideTablesInElement, } from "./security/index.js";
|
|
6
|
+
export { AdapterFailure, BUILT_IN_VIEWS, type BackendContext, type BackendOption, type BuiltInEsmCdnProviderName, DEFAULT_BUNDLE_HOST, DEFAULT_ESM_CDN_URL, ElementAssertionError, type ElementLoaderBackend, ElementLoaderError, type ElementMap, type ElementPackagePolicy, ElementPackagePolicyError, type ElementTag, type EnsureRegisteredOptions, type EsmBackend, type EsmBackendConfig, type EsmCdnProvider, type EsmCdnProviderName, type EsmCdnProviderOption, type IifeBackend, type IifeBackendConfig, type IifeBundleRetryStatus, MATHJAX_NO_ASSET_ROOT_EVENT, MATHJAX_VERSION_CONFLICT_EVENT, type MathAssetOptions, type PreloadedController, type PreloadedElement, type PreloadedElementSpecs, type PreloadedRegistrationOptions, type RegistrationFailureReason, type ViewConfig, aggregateElements, alignPreloadedElementVersions, assertElementPackagesAllowed, assertRegistered, createEsmBackend, createIifeBackend, defineAuthoredPreloadedTags, describeRegistrationFailures, ensureRegistered, forwardMathjaxEvents, isScopedPackageSpec, mapEsmViewElements, registerPreloadedElements, resolveEsmAssetRoot, resolveEsmPackageFileUrl, resolveEsmRuntimeSupportUrl, resolveLoadControllers, } from "./loaders/index.js";
|
|
7
|
+
export { ASSESSMENT_INSTRUMENTATION_EVENT_MAP, type AttachInstrumentationEventBridgeArgs, type AttemptCustomElementDefineOptions, type AuthoringMediaHandlers, type AuthoringValidationResult, type BindPageLifecycleCommitOptions, BundleType, type CanonicalItemSessionContainer, type CommitPendingSessionsOptions, type CommitPendingSessionsResult, type ElementOverrides, type Entry, type EventListeners, type EventListenersMap, ITEM_INSTRUMENTATION_EVENT_MAP, type InitializedConfigureModel, type InstrumentationEventMapping, ItemController, type ItemControllerOptions, type ItemSessionContainer, type ItemSessionStorageStrategy, type ItemSessionUpdateIntent, type LoadPieElementsOptions, type LoadingCompleteDetail, type MathRenderingOptions, MemoryItemSessionStorage, type NormalizedItemSessionChange, type PieElement, type PieElementContext, type PieElementContextSource, type PieLogger, type PieRegistry, type PieViewMode, SECTION_INSTRUMENTATION_EVENT_MAP, SESSION_COMMIT_METHOD, STAGES, type SafeDefineAttempt, type SafeDefineOutcome, type SafeDefineResult, type SafeDefineStatus, type SessionCommitReason, type SessionSnapshot, type SessionSnapshotConfig, type SessionSnapshotIdentity, type SessionSnapshotRecord, type SessionSnapshotStore, SessionStorageItemSessionStorage, type Stage, type StageChangeDetail, type StageStatus, Status, TOOLKIT_INSTRUMENTATION_EVENT_MAP, type UpdatePieElementOptions, VIEW_TAG_SUFFIX, addMarkupForPackage, addOrUpdateOverrideInUrl, addRubricIfNeeded, applyElementOverrides, applyElementVersionOverridesPreserveTags, assertPieConfigContract, attachInstrumentationEventBridge, attemptCustomElementDefine, bindPageLifecycleCommit, commitPendingSessions, createAuthoringAssetEventManager, createPieLogger, createSessionSnapshot, defaultPieElementOptions, defineCustomElementSafely, elementForPackage, encodeElementPackageSpecs, ensureHostSessionEntries, extractPackageInfo, findOrAddSession, findPieController, flushPendingSessionNotifications, formatElementOverrideParam, getPackageWithoutVersion, getPieElementBundlesUrl, hasLearnerResponse, hasResponseField, hasResponseValue, initializeAuthoringConfigures, initializeMathRendering, initializePiesFromLoadedBundle, isCustomElementConstructor, isGlobalDebugEnabled, isPieAvailable, isPieRegistryAvailable, isSessionSnapshotEnabled, isSnapshotIdentitySpecific, isTtsDebugEnabled, loadBundleFromString, loadPieModule, loadPieModuleFromString, makeUniqueTags, modelsForPackage, normalizeItemSessionChange, normalizeItemSessionContainer, noteSessionBaseline, noteSessionObserved, observePieElements, parseElementOverridesFromCurrentUrl, parseElementOverridesFromUrl, parsePackageName, pieElementContextsWithin, pieRegistry, projectSessionIntoHostContainer, resolveConfigureConfiguration, resolveInstrumentationProvider, runtimeElementTags, scorePieItem, sessionSnapshotKey, sessionStorageSnapshotStore, setMathRenderer, toPrintHashedTag, toViewTag, updatePieElement, updatePieElementWithRef, updatePieElements, validateAuthoringModels, validateCustomElementTag, validatePieConfigContract, } from "./pie/index.js";
|
|
8
|
+
export type { AssessmentEntity, AssessmentItemRef, AssessmentSection, AdvancedItemConfig, ConfigEntity, ConfigResource, Env, ItemSessionControlPolicy, TimedMediaSectionData, ItemConfig, ItemEntity, ItemSession, OutcomeResponse, PassageEntity, PieController, PieContent, PieDefaultModel, PieItemElement, PieModel, PieUpdateSession, ReferencedItemEntity, ReferencedPassageEntity, RubricBlock, TestPart, } from "./types/index.js";
|
|
10
9
|
export { editorPostFix } from "./types/index.js";
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
export
|
|
19
|
-
export * from "./ui/first-focusable.js";
|
|
20
|
-
export * from "./ui/safe-storage.js";
|
|
21
|
-
export * from "./ui/scope-css.js";
|
|
10
|
+
export { createFocusReturn, createFocusTrap, } from "./ui/focus-trap.js";
|
|
11
|
+
export { FOCUSABLE_SELECTOR, collectFocusable, isProgrammaticFocusTarget, } from "./ui/first-focusable.js";
|
|
12
|
+
export { isComposingKeyEvent, } from "./ui/ime.js";
|
|
13
|
+
export { DEFAULT_CONTAINMENT_GUTTER, clampPointWithinBlock, resolveContainingBlockRect, } from "./ui/overlay-containment.js";
|
|
14
|
+
export { OVERLAY_PLACEMENT_NUDGES, OVERLAY_PLACEMENT_ROTATIONS, type OverlayPlacementController, type OverlayPlacementNudge, type OverlaySizeControl, type OverlayTapTarget, createOverlayPlacement, dockUprightControls, } from "./ui/overlay-placement.js";
|
|
15
|
+
export { createPointerDragController, } from "./ui/pointer-drag.js";
|
|
16
|
+
export { createPointerGesture, } from "./ui/pointer-gesture.js";
|
|
17
|
+
export { scopeStylesheetCss, } from "./ui/scope-css.js";
|
package/dist/index.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
1
|
+
// The root names its exports one by one, so a module's new export reaches the
|
|
2
|
+
// root only by a deliberate edit here. Helpers with a subpath of their own
|
|
3
|
+
// (`./object`, `./ui/attribute-coercion`, `./ui/content-styles`) are exported
|
|
4
|
+
// only there.
|
|
5
|
+
export { BUILDER_BUNDLE_URL, } from "./config/profile.js";
|
|
6
|
+
export { BaseInstrumentationProvider, CompositeInstrumentationProvider, ConsoleInstrumentationProvider, DebugPanelInstrumentationProvider, INSTRUMENTATION_DEBUG_EVENT_NAME, NewRelicInstrumentationProvider, clearBufferedInstrumentationDebugRecords, getBufferedInstrumentationDebugRecords, isInstrumentationProvider, subscribeInstrumentationDebugRecords, } from "./instrumentation/index.js";
|
|
7
|
+
export { DEFAULT_IIFE_BUNDLE_RETRY_CONFIG, DEFAULT_LOADER_CONFIG, } from "./loader-config.js";
|
|
8
|
+
export { normalizeItemPlayerStrategy, resolveItemPlayerView, } from "./player-strategy.js";
|
|
9
|
+
export { buildAuthoringAllowList, createDefaultItemMarkupSanitizer, isOverwideImageWrapMutation, isOverwideTableWrapMutation, parseAllowedStyleOrigins, sanitizeItemMarkup, sanitizeStyleAttribute, sanitizeSvgIcon, validateExternalStyleUrl, wrapOverwideImages, wrapOverwideImagesInElement, wrapOverwideTables, wrapOverwideTablesInElement, } from "./security/index.js";
|
|
10
|
+
export { AdapterFailure, BUILT_IN_VIEWS, DEFAULT_BUNDLE_HOST, DEFAULT_ESM_CDN_URL, ElementAssertionError, ElementLoaderError, ElementPackagePolicyError, MATHJAX_NO_ASSET_ROOT_EVENT, MATHJAX_VERSION_CONFLICT_EVENT, aggregateElements, alignPreloadedElementVersions, assertElementPackagesAllowed, assertRegistered, createEsmBackend, createIifeBackend, defineAuthoredPreloadedTags, describeRegistrationFailures, ensureRegistered, forwardMathjaxEvents, isScopedPackageSpec, mapEsmViewElements, registerPreloadedElements, resolveEsmAssetRoot, resolveEsmPackageFileUrl, resolveEsmRuntimeSupportUrl, resolveLoadControllers, } from "./loaders/index.js";
|
|
11
|
+
export { ASSESSMENT_INSTRUMENTATION_EVENT_MAP, BundleType, ITEM_INSTRUMENTATION_EVENT_MAP, ItemController, MemoryItemSessionStorage, SECTION_INSTRUMENTATION_EVENT_MAP, SESSION_COMMIT_METHOD, STAGES, SessionStorageItemSessionStorage, Status, TOOLKIT_INSTRUMENTATION_EVENT_MAP, VIEW_TAG_SUFFIX, addMarkupForPackage, addOrUpdateOverrideInUrl, addRubricIfNeeded, applyElementOverrides, applyElementVersionOverridesPreserveTags, assertPieConfigContract, attachInstrumentationEventBridge, attemptCustomElementDefine, bindPageLifecycleCommit, commitPendingSessions, createAuthoringAssetEventManager, createPieLogger, createSessionSnapshot, defaultPieElementOptions, defineCustomElementSafely, elementForPackage, encodeElementPackageSpecs, ensureHostSessionEntries, extractPackageInfo, findOrAddSession, findPieController, flushPendingSessionNotifications, formatElementOverrideParam, getPackageWithoutVersion, getPieElementBundlesUrl, hasLearnerResponse, hasResponseField, hasResponseValue, initializeAuthoringConfigures, initializeMathRendering, initializePiesFromLoadedBundle, isCustomElementConstructor, isGlobalDebugEnabled, isPieAvailable, isPieRegistryAvailable, isSessionSnapshotEnabled, isSnapshotIdentitySpecific, isTtsDebugEnabled, loadBundleFromString, loadPieModule, loadPieModuleFromString, makeUniqueTags, modelsForPackage, normalizeItemSessionChange, normalizeItemSessionContainer, noteSessionBaseline, noteSessionObserved, observePieElements, parseElementOverridesFromCurrentUrl, parseElementOverridesFromUrl, parsePackageName, pieElementContextsWithin, pieRegistry, projectSessionIntoHostContainer, resolveConfigureConfiguration, resolveInstrumentationProvider, runtimeElementTags, scorePieItem, sessionSnapshotKey, sessionStorageSnapshotStore, setMathRenderer, toPrintHashedTag, toViewTag, updatePieElement, updatePieElementWithRef, updatePieElements, validateAuthoringModels, validateCustomElementTag, validatePieConfigContract, } from "./pie/index.js";
|
|
9
12
|
export { editorPostFix } from "./types/index.js";
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
export * from "./ui/first-focusable.js";
|
|
19
|
-
export * from "./ui/safe-storage.js";
|
|
20
|
-
export * from "./ui/scope-css.js";
|
|
13
|
+
export { createFocusReturn, createFocusTrap, } from "./ui/focus-trap.js";
|
|
14
|
+
export { FOCUSABLE_SELECTOR, collectFocusable, isProgrammaticFocusTarget, } from "./ui/first-focusable.js";
|
|
15
|
+
export { isComposingKeyEvent, } from "./ui/ime.js";
|
|
16
|
+
export { DEFAULT_CONTAINMENT_GUTTER, clampPointWithinBlock, resolveContainingBlockRect, } from "./ui/overlay-containment.js";
|
|
17
|
+
export { OVERLAY_PLACEMENT_NUDGES, OVERLAY_PLACEMENT_ROTATIONS, createOverlayPlacement, dockUprightControls, } from "./ui/overlay-placement.js";
|
|
18
|
+
export { createPointerDragController, } from "./ui/pointer-drag.js";
|
|
19
|
+
export { createPointerGesture, } from "./ui/pointer-gesture.js";
|
|
20
|
+
export { scopeStylesheetCss, } from "./ui/scope-css.js";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { settleAll } from "../../promise/index.js";
|
|
1
2
|
export class CompositeInstrumentationProvider {
|
|
2
3
|
providerId = "composite";
|
|
3
4
|
providerName = "Composite Provider";
|
|
@@ -7,7 +8,7 @@ export class CompositeInstrumentationProvider {
|
|
|
7
8
|
this.providers = providers.filter(Boolean);
|
|
8
9
|
}
|
|
9
10
|
async initialize(config) {
|
|
10
|
-
const results = await
|
|
11
|
+
const results = await settleAll(this.providers.map((provider) => provider.initialize(config)));
|
|
11
12
|
this.initialized = true;
|
|
12
13
|
if (config?.debug) {
|
|
13
14
|
for (const [index, result] of results.entries()) {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Item session control: Try state, feedback reveal, and section mastery.
|
|
3
|
+
*
|
|
4
|
+
* Pure and Node-safe by design — no DOM, no timers, no element registry — so
|
|
5
|
+
* the contract is testable without a browser and an adapter can import it
|
|
6
|
+
* without pulling in a player. Everything that touches the DOM stays in
|
|
7
|
+
* `@pie-players/pie-section-player`.
|
|
8
|
+
*
|
|
9
|
+
* Contract: `docs/prds/item-session-control-contract.md`.
|
|
10
|
+
*/
|
|
11
|
+
export type { TryAction, TryCorrectness, ItemSessionControlPolicy, FeedbackEnvOverride, FeedbackReveal, ItemTryState, ItemTryView, MasteryRollup, FeedbackRevealTiming, ScoredElementOutcome, TrySectionProjection, TrySectionSlice, TryLimit, TryOutcome, ResolvedItemSessionControlPolicy, } from "./types.js";
|
|
12
|
+
export { ITEM_SESSION_CONTROL_DEFAULTS, isItemSessionControlEnabledInSection, resolveItemSessionControls, resolveItemSessionControl, } from "./policy.js";
|
|
13
|
+
export { aggregateTryOutcome } from "./outcome.js";
|
|
14
|
+
export { ITEM_TRY_STATE_VERSION, createItemTryState, hideItemFeedback, recordTry, resolveItemTryView, retryItem, revealItemFeedback, } from "./state.js";
|
|
15
|
+
export { MASTERY_ROLLUP_VERSION, rollupMastery } from "./mastery.js";
|
|
16
|
+
export { TRY_SLICE_VERSION, normalizeTrySectionSlice, toTrySectionSlice, } from "./session.js";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { ITEM_SESSION_CONTROL_DEFAULTS, isItemSessionControlEnabledInSection, resolveItemSessionControls, resolveItemSessionControl, } from "./policy.js";
|
|
2
|
+
export { aggregateTryOutcome } from "./outcome.js";
|
|
3
|
+
export { ITEM_TRY_STATE_VERSION, createItemTryState, hideItemFeedback, recordTry, resolveItemTryView, retryItem, revealItemFeedback, } from "./state.js";
|
|
4
|
+
export { MASTERY_ROLLUP_VERSION, rollupMastery } from "./mastery.js";
|
|
5
|
+
export { TRY_SLICE_VERSION, normalizeTrySectionSlice, toTrySectionSlice, } from "./session.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const
|
|
1
|
+
import type { ItemTryState, MasteryRollup } from "./types.js";
|
|
2
|
+
export declare const MASTERY_ROLLUP_VERSION: 1;
|
|
3
3
|
/**
|
|
4
4
|
* Roll Try outcomes up to the section.
|
|
5
5
|
*
|
|
@@ -10,7 +10,7 @@ export declare const FORMATIVE_MASTERY_VERSION: 1;
|
|
|
10
10
|
* excluded: nothing yet says it cannot be scored, so it keeps the section from
|
|
11
11
|
* reading as complete after one correct answer.
|
|
12
12
|
*/
|
|
13
|
-
export declare function
|
|
13
|
+
export declare function rollupMastery(args: {
|
|
14
14
|
itemIdentifiers: readonly string[];
|
|
15
|
-
states: Record<string,
|
|
16
|
-
}):
|
|
15
|
+
states: Record<string, ItemTryState>;
|
|
16
|
+
}): MasteryRollup;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const
|
|
1
|
+
export const MASTERY_ROLLUP_VERSION = 1;
|
|
2
2
|
/**
|
|
3
3
|
* Roll Try outcomes up to the section.
|
|
4
4
|
*
|
|
@@ -9,7 +9,7 @@ export const FORMATIVE_MASTERY_VERSION = 1;
|
|
|
9
9
|
* excluded: nothing yet says it cannot be scored, so it keeps the section from
|
|
10
10
|
* reading as complete after one correct answer.
|
|
11
11
|
*/
|
|
12
|
-
export function
|
|
12
|
+
export function rollupMastery(args) {
|
|
13
13
|
const identifiers = args.itemIdentifiers ?? [];
|
|
14
14
|
const totalItems = identifiers.length;
|
|
15
15
|
let notScorableItems = 0;
|
|
@@ -31,7 +31,7 @@ export function rollupFormativeMastery(args) {
|
|
|
31
31
|
}
|
|
32
32
|
const scorableItems = Math.max(0, totalItems - notScorableItems);
|
|
33
33
|
return {
|
|
34
|
-
version:
|
|
34
|
+
version: MASTERY_ROLLUP_VERSION,
|
|
35
35
|
totalItems,
|
|
36
36
|
scorableItems,
|
|
37
37
|
masteredItems,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ScoredElementOutcome, TryOutcome } from "./types.js";
|
|
2
2
|
/**
|
|
3
3
|
* Reduce the array `pie-item-player.provideScore()` returns to one Try outcome.
|
|
4
4
|
*
|
|
5
5
|
* The aggregation mirrors the policy the persisted API scoring path already
|
|
6
6
|
* documents (`docs/item-player/scoring-and-rubrics.md`), so a browser-derived
|
|
7
|
-
*
|
|
7
|
+
* Try result and a server-derived score do not disagree about what a
|
|
8
8
|
* multi-element item is worth:
|
|
9
9
|
*
|
|
10
10
|
* - one scored outcome: `points = score`, `max = max ?? 1`;
|
|
@@ -16,4 +16,4 @@ import type { FormativeScoredOutcome, FormativeTryOutcome } from "./types.js";
|
|
|
16
16
|
* those slots count toward `totalElementCount` and not toward
|
|
17
17
|
* `scoredElementCount`.
|
|
18
18
|
*/
|
|
19
|
-
export declare function
|
|
19
|
+
export declare function aggregateTryOutcome(outcomes: ReadonlyArray<ScoredElementOutcome | null | undefined> | null): TryOutcome;
|
|
@@ -39,7 +39,7 @@ function classify(points, max) {
|
|
|
39
39
|
*
|
|
40
40
|
* The aggregation mirrors the policy the persisted API scoring path already
|
|
41
41
|
* documents (`docs/item-player/scoring-and-rubrics.md`), so a browser-derived
|
|
42
|
-
*
|
|
42
|
+
* Try result and a server-derived score do not disagree about what a
|
|
43
43
|
* multi-element item is worth:
|
|
44
44
|
*
|
|
45
45
|
* - one scored outcome: `points = score`, `max = max ?? 1`;
|
|
@@ -51,7 +51,7 @@ function classify(points, max) {
|
|
|
51
51
|
* those slots count toward `totalElementCount` and not toward
|
|
52
52
|
* `scoredElementCount`.
|
|
53
53
|
*/
|
|
54
|
-
export function
|
|
54
|
+
export function aggregateTryOutcome(outcomes) {
|
|
55
55
|
const all = Array.isArray(outcomes) ? outcomes : [];
|
|
56
56
|
const scored = all.filter(isScored);
|
|
57
57
|
const totalElementCount = all.length;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ItemSessionControlPolicy, ResolvedItemSessionControlPolicy } from "./types.js";
|
|
2
2
|
/**
|
|
3
3
|
* Built-in defaults. `enabled: false` is what makes this contract invisible to
|
|
4
|
-
* every section authored before it: an absent `
|
|
4
|
+
* every section authored before it: an absent `itemSessionControl` field resolves to a
|
|
5
5
|
* disabled policy, and a disabled policy produces no state, no projection and
|
|
6
6
|
* no control.
|
|
7
7
|
*
|
|
8
8
|
* `maxTries: 1` matches QTI 3's `qti-item-session-control@max-attempts` default.
|
|
9
9
|
*/
|
|
10
|
-
export declare const
|
|
10
|
+
export declare const ITEM_SESSION_CONTROL_DEFAULTS: ResolvedItemSessionControlPolicy;
|
|
11
11
|
/**
|
|
12
12
|
* Merge built-in defaults, the section policy, and one item ref's override, in
|
|
13
13
|
* that order. Each field overrides independently, which is the order QTI 3 uses
|
|
@@ -17,21 +17,21 @@ export declare const FORMATIVE_POLICY_DEFAULTS: ResolvedFormativePolicy;
|
|
|
17
17
|
* section: authored policy is host-supplied data, and a typo in one field should
|
|
18
18
|
* not cost the learner the whole item.
|
|
19
19
|
*/
|
|
20
|
-
export declare function
|
|
20
|
+
export declare function resolveItemSessionControl(sectionPolicy?: ItemSessionControlPolicy | null, itemPolicy?: ItemSessionControlPolicy | null): ResolvedItemSessionControlPolicy;
|
|
21
21
|
/**
|
|
22
22
|
* Resolve one policy per item in section order.
|
|
23
23
|
*
|
|
24
24
|
* Keyed by the identifier the caller supplies, which in the section runtime is
|
|
25
25
|
* the canonical item id — the same key `itemSessions` and the completion map
|
|
26
|
-
* use, so
|
|
26
|
+
* use, so Try state and an item session are always addressable by one
|
|
27
27
|
* id.
|
|
28
28
|
*/
|
|
29
|
-
export declare function
|
|
30
|
-
sectionPolicy?:
|
|
29
|
+
export declare function resolveItemSessionControls(args: {
|
|
30
|
+
sectionPolicy?: ItemSessionControlPolicy | null;
|
|
31
31
|
items: ReadonlyArray<{
|
|
32
32
|
identifier: string;
|
|
33
|
-
policy?:
|
|
33
|
+
policy?: ItemSessionControlPolicy | null;
|
|
34
34
|
}>;
|
|
35
|
-
}): Record<string,
|
|
36
|
-
/** True when at least one item in the section
|
|
37
|
-
export declare function
|
|
35
|
+
}): Record<string, ResolvedItemSessionControlPolicy>;
|
|
36
|
+
/** True when at least one item in the section enables item session control. */
|
|
37
|
+
export declare function isItemSessionControlEnabledInSection(policies: Record<string, ResolvedItemSessionControlPolicy>): boolean;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Built-in defaults. `enabled: false` is what makes this contract invisible to
|
|
3
|
-
* every section authored before it: an absent `
|
|
3
|
+
* every section authored before it: an absent `itemSessionControl` field resolves to a
|
|
4
4
|
* disabled policy, and a disabled policy produces no state, no projection and
|
|
5
5
|
* no control.
|
|
6
6
|
*
|
|
7
7
|
* `maxTries: 1` matches QTI 3's `qti-item-session-control@max-attempts` default.
|
|
8
8
|
*/
|
|
9
|
-
export const
|
|
9
|
+
export const ITEM_SESSION_CONTROL_DEFAULTS = {
|
|
10
10
|
enabled: false,
|
|
11
11
|
maxTries: 1,
|
|
12
12
|
feedback: "correctness",
|
|
@@ -40,21 +40,21 @@ function normalizeRevealTiming(value) {
|
|
|
40
40
|
* section: authored policy is host-supplied data, and a typo in one field should
|
|
41
41
|
* not cost the learner the whole item.
|
|
42
42
|
*/
|
|
43
|
-
export function
|
|
43
|
+
export function resolveItemSessionControl(sectionPolicy, itemPolicy) {
|
|
44
44
|
const enabled = typeof itemPolicy?.enabled === "boolean"
|
|
45
45
|
? itemPolicy.enabled
|
|
46
46
|
: typeof sectionPolicy?.enabled === "boolean"
|
|
47
47
|
? sectionPolicy.enabled
|
|
48
|
-
:
|
|
48
|
+
: ITEM_SESSION_CONTROL_DEFAULTS.enabled;
|
|
49
49
|
const maxTries = normalizeTryLimit(itemPolicy?.maxTries) ??
|
|
50
50
|
normalizeTryLimit(sectionPolicy?.maxTries) ??
|
|
51
|
-
|
|
51
|
+
ITEM_SESSION_CONTROL_DEFAULTS.maxTries;
|
|
52
52
|
const feedback = normalizeFeedback(itemPolicy?.feedback) ??
|
|
53
53
|
normalizeFeedback(sectionPolicy?.feedback) ??
|
|
54
|
-
|
|
54
|
+
ITEM_SESSION_CONTROL_DEFAULTS.feedback;
|
|
55
55
|
const requestedRevealOn = normalizeRevealTiming(itemPolicy?.revealOn) ??
|
|
56
56
|
normalizeRevealTiming(sectionPolicy?.revealOn) ??
|
|
57
|
-
|
|
57
|
+
ITEM_SESSION_CONTROL_DEFAULTS.revealOn;
|
|
58
58
|
// `"on-final-try"` has no referent under unlimited Tries — there is no final
|
|
59
59
|
// Try to reveal on — so it resolves to the only reading that keeps feedback
|
|
60
60
|
// reachable.
|
|
@@ -68,19 +68,19 @@ export function resolveFormativePolicy(sectionPolicy, itemPolicy) {
|
|
|
68
68
|
*
|
|
69
69
|
* Keyed by the identifier the caller supplies, which in the section runtime is
|
|
70
70
|
* the canonical item id — the same key `itemSessions` and the completion map
|
|
71
|
-
* use, so
|
|
71
|
+
* use, so Try state and an item session are always addressable by one
|
|
72
72
|
* id.
|
|
73
73
|
*/
|
|
74
|
-
export function
|
|
74
|
+
export function resolveItemSessionControls(args) {
|
|
75
75
|
const resolved = {};
|
|
76
76
|
for (const item of args.items) {
|
|
77
77
|
if (!item?.identifier)
|
|
78
78
|
continue;
|
|
79
|
-
resolved[item.identifier] =
|
|
79
|
+
resolved[item.identifier] = resolveItemSessionControl(args.sectionPolicy, item.policy);
|
|
80
80
|
}
|
|
81
81
|
return resolved;
|
|
82
82
|
}
|
|
83
|
-
/** True when at least one item in the section
|
|
84
|
-
export function
|
|
83
|
+
/** True when at least one item in the section enables item session control. */
|
|
84
|
+
export function isItemSessionControlEnabledInSection(policies) {
|
|
85
85
|
return Object.values(policies).some((policy) => policy.enabled);
|
|
86
86
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ItemTryState, TrySectionSlice } from "./types.js";
|
|
2
|
+
export declare const TRY_SLICE_VERSION: 1;
|
|
3
|
+
export declare function toTrySectionSlice(states: Record<string, ItemTryState>): TrySectionSlice;
|
|
4
|
+
/**
|
|
5
|
+
* Validate a persisted slice against the section it is being restored into.
|
|
6
|
+
*
|
|
7
|
+
* Returns `null` for a slice this build cannot read, which the caller treats as
|
|
8
|
+
* "start Try state clean". Rejection is deliberately narrow: it discards
|
|
9
|
+
* Try progress and nothing else, so a version bump here never costs a
|
|
10
|
+
* learner their responses — item sessions travel in the same snapshot and are
|
|
11
|
+
* normalized separately.
|
|
12
|
+
*
|
|
13
|
+
* An absent slice is `null` too, and indistinguishable from a save made
|
|
14
|
+
* without Try state, which is what keeps existing snapshots valid.
|
|
15
|
+
*/
|
|
16
|
+
export declare function normalizeTrySectionSlice(args: {
|
|
17
|
+
slice: unknown;
|
|
18
|
+
allowedItemIdentifiers: readonly string[];
|
|
19
|
+
}): Record<string, ItemTryState> | null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export const
|
|
1
|
+
import { ITEM_TRY_STATE_VERSION } from "./state.js";
|
|
2
|
+
export const TRY_SLICE_VERSION = 1;
|
|
3
3
|
const CORRECTNESS_VALUES = [
|
|
4
4
|
"correct",
|
|
5
5
|
"partial",
|
|
@@ -54,14 +54,14 @@ function normalizeItemState(itemIdentifier, value) {
|
|
|
54
54
|
if (!value || typeof value !== "object")
|
|
55
55
|
return null;
|
|
56
56
|
const raw = value;
|
|
57
|
-
if (raw.version !==
|
|
57
|
+
if (raw.version !== ITEM_TRY_STATE_VERSION)
|
|
58
58
|
return null;
|
|
59
59
|
const tryCount = readNonNegativeInteger(raw.tryCount);
|
|
60
60
|
if (tryCount === undefined)
|
|
61
61
|
return null;
|
|
62
62
|
const firstCorrectTry = readNonNegativeInteger(raw.firstCorrectTry);
|
|
63
63
|
return {
|
|
64
|
-
version:
|
|
64
|
+
version: ITEM_TRY_STATE_VERSION,
|
|
65
65
|
itemIdentifier,
|
|
66
66
|
tryCount,
|
|
67
67
|
revealed: raw.revealed === true,
|
|
@@ -72,9 +72,9 @@ function normalizeItemState(itemIdentifier, value) {
|
|
|
72
72
|
revealOverride: normalizeRevealOverride(raw.revealOverride),
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
|
-
export function
|
|
75
|
+
export function toTrySectionSlice(states) {
|
|
76
76
|
return {
|
|
77
|
-
version:
|
|
77
|
+
version: TRY_SLICE_VERSION,
|
|
78
78
|
items: { ...states },
|
|
79
79
|
};
|
|
80
80
|
}
|
|
@@ -82,20 +82,20 @@ export function toFormativeSectionSlice(states) {
|
|
|
82
82
|
* Validate a persisted slice against the section it is being restored into.
|
|
83
83
|
*
|
|
84
84
|
* Returns `null` for a slice this build cannot read, which the caller treats as
|
|
85
|
-
* "start
|
|
86
|
-
*
|
|
85
|
+
* "start Try state clean". Rejection is deliberately narrow: it discards
|
|
86
|
+
* Try progress and nothing else, so a version bump here never costs a
|
|
87
87
|
* learner their responses — item sessions travel in the same snapshot and are
|
|
88
88
|
* normalized separately.
|
|
89
89
|
*
|
|
90
|
-
* An absent slice is `null` too, and indistinguishable from a
|
|
91
|
-
*
|
|
90
|
+
* An absent slice is `null` too, and indistinguishable from a save made
|
|
91
|
+
* without Try state, which is what keeps existing snapshots valid.
|
|
92
92
|
*/
|
|
93
|
-
export function
|
|
93
|
+
export function normalizeTrySectionSlice(args) {
|
|
94
94
|
const { slice } = args;
|
|
95
95
|
if (!slice || typeof slice !== "object")
|
|
96
96
|
return null;
|
|
97
97
|
const raw = slice;
|
|
98
|
-
if (raw.version !==
|
|
98
|
+
if (raw.version !== TRY_SLICE_VERSION)
|
|
99
99
|
return null;
|
|
100
100
|
if (!raw.items || typeof raw.items !== "object")
|
|
101
101
|
return null;
|