@pie-players/pie-players-shared 0.3.44 → 0.3.45
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 +32 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/instrumentation/providers/NewRelicInstrumentationProvider.d.ts +1 -2
- package/dist/instrumentation/providers/NewRelicInstrumentationProvider.js +1 -2
- package/dist/instrumentation/providers/NewRelicInstrumentationProvider.js.map +1 -1
- package/dist/pie/index.d.ts +1 -1
- package/dist/pie/index.js +1 -1
- package/dist/pie/index.js.map +1 -1
- package/dist/pie/initialization.d.ts +2 -2
- package/dist/pie/initialization.js +4 -4
- package/dist/pie/initialization.js.map +1 -1
- package/dist/pie/instrumentation-event-map.js +3 -5
- package/dist/pie/instrumentation-event-map.js.map +1 -1
- package/dist/pie/logger.d.ts +1 -1
- package/dist/pie/logger.js.map +1 -1
- package/dist/pie/scoring.d.ts +1 -1
- package/dist/pie/scoring.js.map +1 -1
- package/dist/types/index.d.ts +26 -22
- package/dist/types/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# PIE Players Shared
|
|
2
|
+
|
|
3
|
+
Shared runtime utilities for the `@pie-players/*` player suite. This package is
|
|
4
|
+
for framework code and host integrations that need the same loader, PIE config,
|
|
5
|
+
security, object, i18n, or type helpers used by the player packages.
|
|
6
|
+
|
|
7
|
+
## Public Exports
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { safeLocalStorageGet } from "@pie-players/pie-players-shared";
|
|
11
|
+
import { makeUniqueTags } from "@pie-players/pie-players-shared/pie";
|
|
12
|
+
import { normalizeItemPlayerStrategy } from "@pie-players/pie-players-shared";
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Supported subpaths are declared in `package.json`:
|
|
16
|
+
|
|
17
|
+
- `@pie-players/pie-players-shared`
|
|
18
|
+
- `@pie-players/pie-players-shared/loader-config`
|
|
19
|
+
- `@pie-players/pie-players-shared/security`
|
|
20
|
+
- `@pie-players/pie-players-shared/object`
|
|
21
|
+
- `@pie-players/pie-players-shared/types`
|
|
22
|
+
- `@pie-players/pie-players-shared/pie`
|
|
23
|
+
- `@pie-players/pie-players-shared/pie/tag-names`
|
|
24
|
+
- `@pie-players/pie-players-shared/loaders`
|
|
25
|
+
- `@pie-players/pie-players-shared/server/npm-registry`
|
|
26
|
+
- `@pie-players/pie-players-shared/i18n`
|
|
27
|
+
|
|
28
|
+
## Related Documentation
|
|
29
|
+
|
|
30
|
+
- [PIE utilities README](src/pie/README.md)
|
|
31
|
+
- [i18n README](src/i18n/README.md)
|
|
32
|
+
- [PIE element tag/id contract](../../docs/architecture/types-and-utilities-contract.md)
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export * from "./security/index.js";
|
|
|
6
6
|
export * from "./loaders/index.js";
|
|
7
7
|
export * from "./object/index.js";
|
|
8
8
|
export * from "./pie/index.js";
|
|
9
|
-
export type { AssessmentEntity, AssessmentItemRef, AssessmentSection, ConfigEntity, Env, ItemConfig, ItemEntity,
|
|
9
|
+
export type { AssessmentEntity, AssessmentItemRef, AssessmentSection, ConfigEntity, Env, ItemConfig, ItemEntity, OutcomeResponse, PassageEntity, PieController, PieModel, QuestionEntity, RubricBlock, TestPart, } from "./types/index.js";
|
|
10
10
|
export { editorPostFix } from "./types/index.js";
|
|
11
11
|
export * from "./ui/focus-trap.js";
|
|
12
12
|
export * from "./ui/first-focusable.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,0CAA0C;AAC1C,cAAc,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,0CAA0C;AAC1C,cAAc,gBAAgB,CAAC;AAiB/B,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,iCAAiC,CAAC;AAChD,cAAc,sBAAsB,CAAC","sourcesContent":["export * from \"./config/profile.js\";\nexport * from \"./instrumentation/index.js\";\nexport * from \"./loader-config.js\";\nexport * from \"./player-strategy.js\";\nexport * from \"./security/index.js\";\nexport * from \"./loaders/index.js\";\nexport * from \"./object/index.js\";\n// Barrel export for PIE runtime utilities\nexport * from \"./pie/index.js\";\nexport type {\n\tAssessmentEntity,\n\tAssessmentItemRef,\n\tAssessmentSection,\n\tConfigEntity,\n\tEnv,\n\tItemConfig,\n\tItemEntity,\n\tOutcomeResponse,\n\tPassageEntity,\n\tPieController,\n\tPieModel,\n\tQuestionEntity,\n\tRubricBlock,\n\tTestPart,\n} from \"./types/index.js\";\nexport { editorPostFix } from \"./types/index.js\";\nexport * from \"./ui/focus-trap.js\";\nexport * from \"./ui/first-focusable.js\";\nexport * from \"./ui/debug-panel-persistence.js\";\nexport * from \"./ui/safe-storage.js\";\n"]}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* New Relic Instrumentation Provider
|
|
3
3
|
*
|
|
4
|
-
* Default provider
|
|
5
|
-
* New Relic instrumentation.
|
|
4
|
+
* Default provider for existing New Relic Browser Agent instrumentation.
|
|
6
5
|
*
|
|
7
6
|
* This provider wraps the global `window.newrelic` object provided by
|
|
8
7
|
* the New Relic Browser Agent.
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* New Relic Instrumentation Provider
|
|
3
3
|
*
|
|
4
|
-
* Default provider
|
|
5
|
-
* New Relic instrumentation.
|
|
4
|
+
* Default provider for existing New Relic Browser Agent instrumentation.
|
|
6
5
|
*
|
|
7
6
|
* This provider wraps the global `window.newrelic` object provided by
|
|
8
7
|
* the New Relic Browser Agent.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NewRelicInstrumentationProvider.js","sourceRoot":"","sources":["../../../src/instrumentation/providers/NewRelicInstrumentationProvider.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"NewRelicInstrumentationProvider.js","sourceRoot":"","sources":["../../../src/instrumentation/providers/NewRelicInstrumentationProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAE/E,MAAM,OAAO,+BAAgC,SAAQ,2BAA2B;IACtE,UAAU,GAAG,UAAU,CAAC;IACxB,YAAY,GAAG,WAAW,CAAC;IAEpC;;;;;;;OAOG;IACH,KAAK,CAAC,UAAU,CAAC,MAA8B;QAC9C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,kCAAkC;QAClC,IAAI,OAAO,MAAM,KAAK,WAAW,IAAK,MAAc,CAAC,QAAQ,EAAE,CAAC;YAC/D,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;YACxB,IAAI,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC;gBACxB,OAAO,CAAC,GAAG,CAAC,6CAA6C,CAAC,CAAC;YAC5D,CAAC;QACF,CAAC;aAAM,CAAC;YACP,IAAI,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC;gBACxB,OAAO,CAAC,I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AC;gBACvD,QAAQ,CAAC,kBAAkB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YACzC,CAAC;QACF,CAAC;IACF,CAAC;IAED;;;;;;OAMG;IACO,qBAAqB,CAAC,UAA+B;QAC9D,MAAM,QAAQ,GAAI,MAAc,CAAC,QAAQ,CAAC;QAE1C,IAAI,QAAQ,CAAC,kBAAkB,EAAE,CAAC;YACjC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;gBACvD,QAAQ,CAAC,kBAAkB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YACzC,CAAC;QACF,CAAC;IACF,CAAC;CACD","sourcesContent":["/**\n * New Relic Instrumentation Provider\n *\n * Default provider for existing New Relic Browser Agent instrumentation.\n *\n * This provider wraps the global `window.newrelic` object provided by\n * the New Relic Browser Agent.\n *\n * @example\n * ```typescript\n * const provider = new NewRelicInstrumentationProvider();\n * await provider.initialize();\n *\n * if (provider.isReady()) {\n * provider.trackError(new Error('Something went wrong'), {\n * component: 'my-component',\n * errorType: 'ValidationError'\n * });\n * }\n * ```\n */\n\nimport type { InstrumentationConfig } from \"../types.js\";\nimport { BaseInstrumentationProvider } from \"./BaseInstrumentationProvider.js\";\n\nexport class NewRelicInstrumentationProvider extends BaseInstrumentationProvider {\n\treadonly providerId = \"newrelic\";\n\treadonly providerName = \"New Relic\";\n\n\t/**\n\t * Initialize the New Relic provider\n\t *\n\t * Checks if the New Relic Browser Agent is available via `window.newrelic`.\n\t * If not available, initialization succeeds but `isReady()` will return false.\n\t *\n\t * @param config Optional configuration\n\t */\n\tasync initialize(config?: InstrumentationConfig): Promise<void> {\n\t\tthis.config = config;\n\n\t\t// Check if New Relic is available\n\t\tif (typeof window !== \"undefined\" && (window as any).newrelic) {\n\t\t\tthis.initialized = true;\n\t\t\tif (this.config?.debug) {\n\t\t\t\tconsole.log(\"[NewRelicProvider] Initialized successfully\");\n\t\t\t}\n\t\t} else {\n\t\t\tif (this.config?.debug) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t\"[NewRelicProvider] New Relic not available (window.newrelic not found)\",\n\t\t\t\t);\n\t\t\t}\n\t\t\t// Don't throw - allow graceful degradation\n\t\t\tthis.initialized = false;\n\t\t}\n\t}\n\n\t/**\n\t * Check if provider is ready\n\t *\n\t * @returns true if New Relic is available and initialized\n\t */\n\tisReady(): boolean {\n\t\treturn (\n\t\t\tthis.initialized &&\n\t\t\ttypeof window !== \"undefined\" &&\n\t\t\t!!(window as any).newrelic\n\t\t);\n\t}\n\n\t/**\n\t * Cleanup provider resources\n\t *\n\t * Marks provider as uninitialized. The global `window.newrelic` object\n\t * is not modified.\n\t */\n\tdestroy(): void {\n\t\tthis.initialized = false;\n\t\tif (this.config?.debug) {\n\t\t\tconsole.log(\"[NewRelicProvider] Destroyed\");\n\t\t}\n\t}\n\n\t/**\n\t * Track an error with New Relic\n\t *\n\t * Calls `newrelic.noticeError(error, attributes)`\n\t *\n\t * @param error The error to track\n\t * @param attributes Transformed attributes (already filtered and transformed by base class)\n\t */\n\tprotected doTrackError(error: Error, attributes: Record<string, any>): void {\n\t\tconst newrelic = (window as any).newrelic;\n\t\tnewrelic.noticeError(error, attributes);\n\t}\n\n\t/**\n\t * Track a custom event/page action with New Relic\n\t *\n\t * Calls `newrelic.addPageAction(eventName, attributes)`\n\t *\n\t * @param eventName Name of the event\n\t * @param attributes Transformed attributes (already filtered and transformed by base class)\n\t */\n\tprotected doTrackEvent(\n\t\teventName: string,\n\t\tattributes: Record<string, any>,\n\t): void {\n\t\tconst newrelic = (window as any).newrelic;\n\t\tnewrelic.addPageAction(eventName, attributes);\n\t}\n\n\t/**\n\t * Set user context for session tracking\n\t *\n\t * Calls `newrelic.setUserId()` and `newrelic.setCustomAttribute()` for user attributes.\n\t *\n\t * @param userId User identifier\n\t * @param attributes Optional user attributes\n\t */\n\tprotected doSetUserContext(\n\t\tuserId: string,\n\t\tattributes?: Record<string, any>,\n\t): void {\n\t\tconst newrelic = (window as any).newrelic;\n\n\t\t// Set user ID if method exists\n\t\tif (newrelic.setUserId) {\n\t\t\tnewrelic.setUserId(userId);\n\t\t}\n\n\t\t// Set custom attributes for user\n\t\tif (attributes && newrelic.setCustomAttribute) {\n\t\t\tfor (const [key, value] of Object.entries(attributes)) {\n\t\t\t\tnewrelic.setCustomAttribute(key, value);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Set global custom attributes\n\t *\n\t * Calls `newrelic.setCustomAttribute()` for each attribute.\n\t *\n\t * @param attributes Attributes to set globally\n\t */\n\tprotected doSetGlobalAttributes(attributes: Record<string, any>): void {\n\t\tconst newrelic = (window as any).newrelic;\n\n\t\tif (newrelic.setCustomAttribute) {\n\t\t\tfor (const [key, value] of Object.entries(attributes)) {\n\t\t\t\tnewrelic.setCustomAttribute(key, value);\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
|
package/dist/pie/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* PIE Utilities Index
|
|
3
3
|
*
|
|
4
|
-
* Barrel export for
|
|
4
|
+
* Barrel export for public PIE runtime utilities.
|
|
5
5
|
* Public consumers should import from this aggregate. The only supported
|
|
6
6
|
* deep `pie/*` subpath is `pie/tag-names` for tag helper reuse.
|
|
7
7
|
*
|
package/dist/pie/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* PIE Utilities Index
|
|
3
3
|
*
|
|
4
|
-
* Barrel export for
|
|
4
|
+
* Barrel export for public PIE runtime utilities.
|
|
5
5
|
* Public consumers should import from this aggregate. The only supported
|
|
6
6
|
* deep `pie/*` subpath is `pie/tag-names` for tag helper reuse.
|
|
7
7
|
*
|
package/dist/pie/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/pie/index.ts"],"names":[],"mappings":"AAAA;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O,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,UAAU;AACV,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAW/D,OAAO,EACN,UAAU,EACV,wBAAwB,EACxB,0BAA0B;AAC1B,0BAA0B;AAC1B,cAAc,EACd,sBAAsB,EACtB,MAAM,GACN,MAAM,YAAY,CAAC;AACpB,qBAAqB;AACrB,OAAO,EACN,yBAAyB,GAGzB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACN,gBAAgB,EAChB,SAAS,EACT,wBAAwB,EACxB,eAAe,GACf,MAAM,gBAAgB,CAAC;AAExB,UAAU;AACV,OAAO,EACN,gBAAgB,EAChB,iBAAiB,EACjB,uBAAuB,GACvB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACN,wBAAwB,EACxB,qBAAqB,EACrB,wCAAwC,EACxC,kBAAkB,EAClB,0BAA0B,EAC1B,mCAAmC,EACnC,4BAA4B,GAC5B,MAAM,gBAAgB,CAAC;AACxB,QAAQ;AACR,OAAO,EACN,gBAAgB,EAChB,wBAAwB,EACxB,uBAAuB,EACvB,gBAAgB,GAChB,MAAM,YAAY,CAAC","sourcesContent":["/**\n * PIE Utilities Index\n *\n * Barrel export for
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/pie/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,SAAS;AACT,OAAO,EACN,uBAAuB,EACvB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,yBAAyB,GACzB,MAAM,aAAa,CAAC;AACrB,2EAA2E;AAC3E,qEAAqE;AACrE,iBAAiB;AACjB,OAAO,EACN,8BAA8B,EAC9B,oBAAoB,EACpB,aAAa,EACb,uBAAuB,GACvB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,gCAAgC,EAChC,6BAA6B,EAC7B,6BAA6B,EAC7B,uBAAuB,GACvB,MAAM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AAM,gBAAgB,CAAC;AAExB,UAAU;AACV,OAAO,EACN,gBAAgB,EAChB,iBAAiB,EACjB,uBAAuB,GACvB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACN,wBAAwB,EACxB,qBAAqB,EACrB,wCAAwC,EACxC,kBAAkB,EAClB,0BAA0B,EAC1B,mCAAmC,EACnC,4BAA4B,GAC5B,MAAM,gBAAgB,CAAC;AACxB,QAAQ;AACR,OAAO,EACN,gBAAgB,EAChB,wBAAwB,EACxB,uBAAuB,EACvB,gBAAgB,GAChB,MAAM,YAAY,CAAC","sourcesContent":["/**\n * PIE Utilities Index\n *\n * Barrel export for public PIE runtime utilities.\n * Public consumers should import from this aggregate. The only supported\n * deep `pie/*` subpath is `pie/tag-names` for tag helper reuse.\n *\n * - `pie` - PIE runtime utilities, interfaces, and helpers\n * - `pie/tag-names` - Custom element tag naming helpers\n */\n\n// Config\nexport {\n\tassertPieConfigContract,\n\taddMarkupForPackage,\n\taddRubricIfNeeded,\n\telementForPackage,\n\tmakeUniqueTags,\n\tmodelsForPackage,\n\tvalidatePieConfigContract,\n} from \"./config.js\";\n// Loaders — the deep `ElementLoader` primitive (async `ensureRegistered` /\n// sync `assertRegistered`) lives under `pie-players-shared/loaders`.\n// Initialization\nexport {\n\tinitializePiesFromLoadedBundle,\n\tloadBundleFromString,\n\tloadPieModule,\n\tloadPieModuleFromString,\n} from \"./initialization.js\";\nexport {\n\tcreateAuthoringAssetEventManager,\n\tinitializeAuthoringConfigures,\n\tresolveConfigureConfiguration,\n\tvalidateAuthoringModels,\n} from \"./authoring.js\";\nexport type {\n\tAuthoringMediaHandlers,\n\tAuthoringValidationResult,\n\tInitializedConfigureModel,\n} from \"./authoring.js\";\nexport {\n\tinitializeMathRendering,\n\trenderMath,\n\tsetMathRenderer,\n} from \"./math-rendering.js\";\nexport { attachInstrumentationEventBridge } from \"./instrumentation-event-bridge.js\";\nexport type { AttachInstrumentationEventBridgeArgs } from \"./instrumentation-event-bridge.js\";\nexport { resolveInstrumentationProvider } from \"./instrumentation-provider-resolution.js\";\n// Canonical stage vocabulary (M6). Both `<pie-section-player-*>` and\n// `<pie-assessment-toolkit>` share this primitive so the\n// `pie-stage-change` event family stays coherent across CE shapes.\nexport {\n\tSTAGES,\n\tapplicableStages,\n\tstageOrdinal,\n} from \"./stages.js\";\nexport type {\n\tLoadingCompleteDetail,\n\tStage,\n\tStageChangeDetail,\n\tStageSourceCe,\n\tStageStatus,\n} from \"./stages.js\";\nexport { createStageTracker } from \"./stage-tracker.js\";\nexport type {\n\tCreateStageTrackerOptions,\n\tStageTracker,\n} from \"./stage-tracker.js\";\nexport {\n\tASSESSMENT_INSTRUMENTATION_EVENT_MAP,\n\tSECTION_INSTRUMENTATION_EVENT_MAP,\n\tTOOLKIT_INSTRUMENTATION_EVENT_MAP,\n} from \"./instrumentation-event-map.js\";\nexport type { InstrumentationEventMapping } from \"./instrumentation-event-map.js\";\n// Item controller\nexport type { ItemControllerOptions } from \"./item-controller.js\";\nexport { ItemController, normalizeItemSessionContainer } from \"./item-controller.js\";\nexport type {\n\tItemSessionContainer as CanonicalItemSessionContainer,\n\tItemSessionUpdateIntent,\n\tNormalizedItemSessionChange,\n} from \"./item-session-contract.js\";\nexport {\n\thasResponseValue,\n\tnormalizeItemSessionChange,\n} from \"./item-session-contract.js\";\nexport type {\n\tItemSessionContainer,\n\tItemSessionStorageStrategy,\n} from \"./item-controller-storage.js\";\nexport {\n\tMemoryItemSessionStorage,\n\tSessionStorageItemSessionStorage,\n} from \"./item-controller-storage.js\";\n// Logging\nexport type { PieLogger } from \"./logger.js\";\nexport { createPieLogger, isGlobalDebugEnabled } from \"./logger.js\";\n// Player bootstrap helpers (used by inline/preloaded players)\nexport type {\n\tItemData,\n\tPiePlayerConfig,\n\tPiePlayerElements,\n} from \"./player-initializer.js\";\nexport {\n\tbuildApiParams,\n\tbuildEventListenersMap,\n\tensurePiePlayerLoaded,\n\textractPassageMarkup,\n\tfetchItemData,\n\tinitializePiePlayer,\n} from \"./player-initializer.js\";\n// Registry\nexport { pieRegistry } from \"./registry.js\";\n// Scoring\nexport { findPieController, scorePieItem } from \"./scoring.js\";\n// Types and interfaces\nexport type {\n\tEntry,\n\tEventListeners,\n\tEventListenersMap,\n\tLoadPieElementsOptions,\n\tPieElement,\n\tPieRegistry,\n\tUpdatePieElementOptions,\n} from \"./types.js\";\nexport {\n\tBundleType,\n\tdefaultPieElementOptions,\n\tisCustomElementConstructor,\n\t// Type guards (functions)\n\tisPieAvailable,\n\tisPieRegistryAvailable,\n\tStatus,\n} from \"./types.js\";\n// Tag naming helpers\nexport {\n\tdefineCustomElementSafely,\n\ttype SafeDefineResult,\n\ttype SafeDefineStatus,\n} from \"./custom-element-define.js\";\nexport {\n\ttoPrintHashedTag,\n\ttoViewTag,\n\tvalidateCustomElementTag,\n\tVIEW_TAG_SUFFIX,\n} from \"./tag-names.js\";\nexport type { PieViewMode } from \"./tag-names.js\";\n// Updates\nexport {\n\tupdatePieElement,\n\tupdatePieElements,\n\tupdatePieElementWithRef,\n} from \"./updates.js\";\n// URL / element override helpers\nexport type { ElementOverrides } from \"./overrides.js\";\nexport {\n\taddOrUpdateOverrideInUrl,\n\tapplyElementOverrides,\n\tapplyElementVersionOverridesPreserveTags,\n\textractPackageInfo,\n\tformatElementOverrideParam,\n\tparseElementOverridesFromCurrentUrl,\n\tparseElementOverridesFromUrl,\n} from \"./overrides.js\";\n// Utils\nexport {\n\tfindOrAddSession,\n\tgetPackageWithoutVersion,\n\tgetPieElementBundlesUrl,\n\tparsePackageName,\n} from \"./utils.js\";\n"]}
|
|
@@ -20,7 +20,7 @@ declare global {
|
|
|
20
20
|
/**
|
|
21
21
|
* Initialize PIE elements from a bundle that may already be loaded.
|
|
22
22
|
*
|
|
23
|
-
* `window.pie` is the
|
|
23
|
+
* `window.pie` is the IIFE bundle-loading global populated by
|
|
24
24
|
* `loadPieModule` / `loadBundleFromString`. When the host loaded the
|
|
25
25
|
* bundle through the deep `ElementLoader` primitive instead — as
|
|
26
26
|
* `pie-section-player` does — the global is irrelevant: the loader
|
|
@@ -29,7 +29,7 @@ declare global {
|
|
|
29
29
|
*
|
|
30
30
|
* Behavior:
|
|
31
31
|
* - `window.pie` available → register any new tags from the bundle and
|
|
32
|
-
* update bindings for already-registered tags
|
|
32
|
+
* update bindings for already-registered tags.
|
|
33
33
|
* - `window.pie` missing → fall back to the update-only path. Tags that
|
|
34
34
|
* are already registered get their model/session updated; tags that
|
|
35
35
|
* are not yet registered are logged at `warn` and left alone — the
|
|
@@ -105,8 +105,8 @@ const updateRegisteredElement = (elementTagName, config, session, options, omitE
|
|
|
105
105
|
* already registered with `customElements`. This is the common case
|
|
106
106
|
* when `pie-item-player` mounts inside `pie-section-player`: the
|
|
107
107
|
* section player has already pre-warmed the bundle through the deep
|
|
108
|
-
* `ElementLoader` primitive, so the
|
|
109
|
-
*
|
|
108
|
+
* `ElementLoader` primitive, so the `window.pie.default` bundle-global
|
|
109
|
+
* path is not required for those tags.
|
|
110
110
|
*/
|
|
111
111
|
const registerPieElementsFromBundle = (elementModule, config, session, registry, options) => {
|
|
112
112
|
const promises = [];
|
|
@@ -302,7 +302,7 @@ const registerPieElementsFromBundle = (elementModule, config, session, registry,
|
|
|
302
302
|
/**
|
|
303
303
|
* Initialize PIE elements from a bundle that may already be loaded.
|
|
304
304
|
*
|
|
305
|
-
* `window.pie` is the
|
|
305
|
+
* `window.pie` is the IIFE bundle-loading global populated by
|
|
306
306
|
* `loadPieModule` / `loadBundleFromString`. When the host loaded the
|
|
307
307
|
* bundle through the deep `ElementLoader` primitive instead — as
|
|
308
308
|
* `pie-section-player` does — the global is irrelevant: the loader
|
|
@@ -311,7 +311,7 @@ const registerPieElementsFromBundle = (elementModule, config, session, registry,
|
|
|
311
311
|
*
|
|
312
312
|
* Behavior:
|
|
313
313
|
* - `window.pie` available → register any new tags from the bundle and
|
|
314
|
-
* update bindings for already-registered tags
|
|
314
|
+
* update bindings for already-registered tags.
|
|
315
315
|
* - `window.pie` missing → fall back to the update-only path. Tags that
|
|
316
316
|
* are already registered get their model/session updated; tags that
|
|
317
317
|
* are not yet registered are logged at `warn` and left alone — the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialization.js","sourceRoot":"","sources":["../../src/pie/initialization.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,iCAAiC,EAAE,MAAM,oBAAoB,CAAC;AAEvE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAO1D,OAAO,EACN,UAAU,EACV,0BAA0B,EAC1B,cAAc,EACd,MAAM,GACN,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EACN,gBAAgB,EAChB,wBAAwB,EACxB,uBAAuB,GACvB,MAAM,YAAY,CAAC;AAEpB,+FAA+F;AAC/F,MAAM,MAAM,GAAG,eAAe,CAAC,oBAAoB,EAAE,GAAG,EAAE,CACzD,oBAAoB,EAAE,CACtB,CAAC;AAEF,2CAA2C;AAC3C,MAAM,cAAc,GAA2B;IAC9C,gBAAgB,EAAE,kBAAkB;IACpC,UAAU,EAAE,UAAU,CAAC,MAAM,EAAE,iEAAiE;IAChG,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE;CACxC,CAAC;AAeF;;G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DAAsD,CAAC,CAAC;IACtE,CAAC,CACD,CAAC;AACH,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,EAC3C,QAAgB,EAChB,MAAoB,EACpB,OAAc,EACd,OAA+B,EAAE,EACjB,EAAE;IAClB,MAAM,iBAAiB,CAAC,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE;QACzD,+CAA+C;QAC/C,MAAM,aAAa,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,KAAK,EAC9B,QAAgB,EAChB,OAA4C,EAC5C,GAAsC,EACzB,EAAE;IACf,MAAM,MAAM,GAAG,OAAO,CAAC,qBAAqB;QAC3C,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,6BAA6B,EAAE,EAAE,CAAC;QACrD,CAAC,CAAC,QAAQ,CAAC;IACZ,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,wBAAwB,EAAE,CAAC,CAAC;IACpE,MAAM,SAAS,GAAG,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAC5C,IAAI,CAAC;QACJ,OAAO,MAAM,GAAG,CAAC,SAAS,CAAC,CAAC;IAC7B,CAAC;YAAS,CAAC;QACV,GAAG,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;IAChC,CAAC;AACF,CAAC,CAAC","sourcesContent":["/**\n * PIE Initialization Module\n *\n * Bundle loading and element initialization logic.\n * This is the core of the PIE player system.\n */\n\nimport { BUILDER_BUNDLE_URL } from \"../config/profile.js\";\nimport { mergeObjectsIgnoringNullUndefined } from \"../object/index.js\";\nimport type { ConfigEntity, Env, PieModel } from \"../types/index.js\";\nimport { editorPostFix } from \"../types/index.js\";\nimport { createPieLogger, isGlobalDebugEnabled } from \"./logger.js\";\nimport { initializeMathRendering } from \"./math-rendering.js\";\nimport { pieRegistry } from \"./registry.js\";\nimport { findPieController } from \"./scoring.js\";\nimport { defineCustomElementSafely } from \"./custom-element-define.js\";\nimport { validateCustomElementTag } from \"./tag-names.js\";\nimport type {\n\tEventListeners,\n\tLoadPieElementsOptions,\n\tPieElement,\n\tPieRegistry,\n} from \"./types.js\";\nimport {\n\tBundleType,\n\tisCustomElementConstructor,\n\tisPieAvailable,\n\tStatus,\n} from \"./types.js\";\nimport { updatePieElement } from \"./updates.js\";\nimport {\n\tfindOrAddSession,\n\tgetPackageWithoutVersion,\n\tgetPieElementBundlesUrl,\n} from \"./utils.js\";\n\n// Create module-level logger (respects global debug flag - pass function for dynamic checking)\nconst logger = createPieLogger(\"pie-initialization\", () =>\n\tisGlobalDebugEnabled(),\n);\n\n// Default options for loading PIE elements\nconst defaultOptions: LoadPieElementsOptions = {\n\tbuildServiceBase: BUILDER_BUNDLE_URL,\n\tbundleType: BundleType.player, // Default to player.js (no controllers, server-processed models)\n\tenv: { mode: \"gather\", role: \"student\" },\n};\n\n// Add this to your window types\ndeclare global {\n\tinterface Window {\n\t\t_pieElementObserver?: MutationObserver;\n\t\t_pieCurrentContext?: {\n\t\t\tconfig: ConfigEntity;\n\t\t\tsession: any[];\n\t\t\tenv?: Env;\n\t\t\tcontainer?: Element | Document;\n\t\t};\n\t}\n}\n\n/**\n * Helper function to initialize a PIE element\n */\nconst initializePieElement = (\n\telement: PieElement,\n\toptions: {\n\t\tconfig: ConfigEntity;\n\t\tsession: any[];\n\t\tenv?: Env;\n\t\teventListeners?: EventListeners;\n\t},\n): void => {\n\tconst { config, session, env, eventListeners } = options;\n\tif ((element as any).__pieInitialized) {\n\t\treturn;\n\t}\n\tconst tagName = element.tagName.toLowerCase();\n\n\tlogger.debug(`[initializePieElement] Initializing ${tagName}#${element.id}`);\n\n\t// Find model for this element\n\tlet model = config?.models?.find((m) => m.id === element.id) as PieModel;\n\tif (!model) {\n\t\t// Only warn if this element is from a client-player.js bundle (where models are expected)\n\t\t// player.js bundles use server-processed models, so missing models are expected there\n\t\tconst registry = pieRegistry();\n\t\tconst registryEntry = registry[tagName];\n\n\t\tif (registryEntry && registryEntry.bundleType === BundleType.clientPlayer) {\n\t\t\tlogger.warn(\n\t\t\t\t`[initializePieElement] Model not found for PIE element ${tagName}#${element.id} (client-player.js bundle)`,\n\t\t\t);\n\t\t}\n\t\treturn;\n\t}\n\n\t// Set session (with element property for updateSession callback)\n\tconst elementSession = findOrAddSession(session, model.id, model.element);\n\telement.session = elementSession;\n\t(element as any).__pieInitialized = true;\n\tlogger.debug(\n\t\t`[initializePieElement] Session set for ${tagName}#${element.id}:`,\n\t\telementSession,\n\t);\n\n\t// Set model - use controller if available (client-player.js), or use server-processed model (player.js)\n\tconst controller = findPieController(tagName);\n\n\tif (!env) {\n\t\tlogger.error(\n\t\t\t`[initializePieElement] ❌ FATAL: No env provided for ${tagName}`,\n\t\t);\n\t\tthrow new Error(\n\t\t\t`No env provided for ${tagName}. PIE elements require an env object with mode and role.`,\n\t\t);\n\t}\n\n\tif (!controller) {\n\t\t// No controller available - using server-processed model (player.js bundle)\n\t\tlogger.debug(\n\t\t\t`[initializePieElement] ℹ️ No controller for ${tagName}, using server-processed model`,\n\t\t);\n\t\tlogger.debug(`[initializePieElement] Model already processed by server:`, {\n\t\t\tid: model.id,\n\t\t\telement: model.element,\n\t\t\thasCorrectResponse: \"correctResponse\" in model,\n\t\t\tmode: env.mode,\n\t\t\trole: env.role,\n\t\t});\n\n\t\t// Set model directly - server already processed it\n\t\telement.model = model;\n\t} else {\n\t\t// Controller available - run client-side processing (client-player.js bundle)\n\t\t// Note: updatePieElementWithRef handles controller invocation\n\t\tlogger.debug(\n\t\t\t`[initializePieElement] Controller found for ${tagName}, will invoke model() function`,\n\t\t);\n\t}\n\n\t// Add event listeners\n\tif (eventListeners) {\n\t\tObject.entries(eventListeners).forEach(([evt, fn]) => {\n\t\t\telement.addEventListener(evt as any, fn);\n\t\t});\n\t}\n};\n\nconst getEditorElementTagName = (elementTagName: string, pkg: string): string =>\n\tvalidateCustomElementTag(\n\t\telementTagName + editorPostFix,\n\t\t`editor element tag for ${pkg}`,\n\t);\n\nconst updateRegisteredElement = (\n\telementTagName: string,\n\tconfig: ConfigEntity,\n\tsession: any[],\n\toptions: LoadPieElementsOptions,\n\tomitEnv = false,\n): void => {\n\tupdatePieElement(elementTagName, {\n\t\tconfig,\n\t\tsession,\n\t\t...(omitEnv ? {} : { env: options.env }),\n\t\tcontainer: options.container,\n\t\t...(options.eventListeners?.[elementTagName] && {\n\t\t\teventListeners: options.eventListeners[elementTagName],\n\t\t}),\n\t});\n};\n\n/**\n * Shared element registration logic\n * Extracted from initializePiesFromLoadedBundle and loadPieModule to eliminate ~200 lines of duplication\n * Also fixes MutationObserver memory leak by storing latest config/session in window context\n *\n * `elementModule` may be `null`. In that case we cannot register *new*\n * tags (no element constructor source), but we can still update tags\n * that another loader (e.g. the section-player's IIFE adapter) has\n * already registered with `customElements`. This is the common case\n * when `pie-item-player` mounts inside `pie-section-player`: the\n * section player has already pre-warmed the bundle through the deep\n * `ElementLoader` primitive, so the legacy `window.pie.default`\n * requirement no longer applies for those tags.\n */\nconst registerPieElementsFromBundle = (\n\telementModule: any | null,\n\tconfig: ConfigEntity,\n\tsession: any[],\n\tregistry: PieRegistry,\n\toptions: LoadPieElementsOptions,\n): Promise<void>[] => {\n\tconst promises: Promise<void>[] = [];\n\tconst isNodeWithinContainer = (\n\t\tnode: Node,\n\t\tcontainer?: Element | Document,\n\t): boolean => {\n\t\tif (!container || container === document) return true;\n\t\treturn node instanceof Node && container.contains(node);\n\t};\n\n\tif (elementModule) {\n\t\tlogger.debug(\n\t\t\t\"[registerPieElementsFromBundle] Available packages in bundle:\",\n\t\t\tObject.keys(elementModule),\n\t\t);\n\t} else {\n\t\tlogger.debug(\n\t\t\t\"[registerPieElementsFromBundle] No bundle module supplied; will only update tags already registered with customElements.\",\n\t\t);\n\t}\n\tlogger.debug(\n\t\t\"[registerPieElementsFromBundle] config.elements:\",\n\t\tconfig.elements,\n\t);\n\n\t// Store latest config/session in window so MutationObserver can access current values\n\tif (typeof window !== \"undefined\") {\n\t\twindow._pieCurrentContext = {\n\t\t\tconfig,\n\t\t\tsession,\n\t\t\tenv: options.env,\n\t\t\tcontainer: options.container,\n\t\t};\n\t}\n\n\tObject.entries(config.elements).forEach(([elName, pkg]) => {\n\t\tconst elementTagName = validateCustomElementTag(\n\t\t\telName,\n\t\t\t`element tag in config.elements for ${String(pkg)}`,\n\t\t);\n\t\tlogger.debug(\n\t\t\t`[registerPieElementsFromBundle] Processing element: ${elementTagName} -> ${pkg}`,\n\t\t);\n\n\t\t// Fast path — the tag is already registered with customElements\n\t\t// (typically by the host's pre-warm pipeline). We can update its\n\t\t// session/model bindings without needing the bundle module at all.\n\t\t// This branch is also the one that runs when `elementModule` is\n\t\t// `null` because `window.pie` was missing.\n\t\tif (customElements.get(elementTagName)) {\n\t\t\tupdateRegisteredElement(elementTagName, config, session, options);\n\n\t\t\tif (options.bundleType === BundleType.editor) {\n\t\t\t\tconst editorElName = getEditorElementTagName(\n\t\t\t\t\telementTagName,\n\t\t\t\t\tString(pkg),\n\t\t\t\t);\n\t\t\t\tupdateRegisteredElement(\n\t\t\t\t\teditorElName,\n\t\t\t\t\tconfig,\n\t\t\t\t\tsession,\n\t\t\t\t\toptions,\n\t\t\t\t\ttrue,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// From here on we are in the \"register a new tag\" branch, which\n\t\t// requires a bundle module to read the element constructor from.\n\t\tif (!elementModule) {\n\t\t\t// A missing bundle module + an unregistered tag is *not*\n\t\t\t// always an error: in the section-player composition the\n\t\t\t// host's own `ElementLoader` may register this tag\n\t\t\t// out-of-band moments later, in which case `updatePieElement`\n\t\t\t// will pick it up on the next reactive pass via the\n\t\t\t// MutationObserver / `whenDefined` paths. Log at warn so the\n\t\t\t// transient miss is still visible during diagnostics without\n\t\t\t// printing a red stack trace for a routine timing condition.\n\t\t\tlogger.warn(\n\t\t\t\t`[registerPieElementsFromBundle] Skipping \"${elementTagName}\" — no bundle module available and the tag is not yet registered. Will bind on next update if the host's loader registers it.`,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst pkgStripped = getPackageWithoutVersion(pkg as string);\n\t\tlogger.debug(\n\t\t\t`[registerPieElementsFromBundle] Package without version: \"${pkgStripped}\"`,\n\t\t);\n\n\t\tconst elementData = elementModule[pkgStripped];\n\t\tlogger.debug(\n\t\t\t`[registerPieElementsFromBundle] elementData result:`,\n\t\t\telementData ? \"FOUND\" : \"UNDEFINED\",\n\t\t);\n\n\t\tif (!elementData) {\n\t\t\tlogger.error(\n\t\t\t\t`[registerPieElementsFromBundle] ❌ Package \"${pkgStripped}\" not found in bundle!`,\n\t\t\t);\n\t\t\tlogger.error(\n\t\t\t\t`[registerPieElementsFromBundle] Lookup key: \"${pkgStripped}\"`,\n\t\t\t);\n\t\t\tlogger.error(\n\t\t\t\t`[registerPieElementsFromBundle] Available packages:`,\n\t\t\t\tObject.keys(elementModule),\n\t\t\t);\n\t\t\tthrow new Error(\n\t\t\t\t`pie ${pkgStripped} not found in ${Object.keys(elementModule)}`,\n\t\t\t);\n\t\t}\n\n\t\tlogger.debug(\n\t\t\t`[registerPieElementsFromBundle] elementData for ${pkgStripped}:`,\n\t\t\t{\n\t\t\t\thasController: !!elementData.controller,\n\t\t\t\thasElement: !!elementData.Element,\n\t\t\t\thasConfig: !!elementData.config,\n\t\t\t\tcontrollerKeys: elementData.controller\n\t\t\t\t\t? Object.keys(elementData.controller)\n\t\t\t\t\t: [],\n\t\t\t\tbundleType: options.bundleType,\n\t\t\t},\n\t\t);\n\n\t\t// Validate controller presence based on bundle type\n\t\tif (!elementData.controller) {\n\t\t\tif (options.bundleType === BundleType.clientPlayer) {\n\t\t\t\tlogger.error(\n\t\t\t\t\t`[registerPieElementsFromBundle] ❌ CRITICAL: No controller found for ${pkgStripped}!`,\n\t\t\t\t);\n\t\t\t\tlogger.error(\n\t\t\t\t\t`[registerPieElementsFromBundle] Bundle type: ${options.bundleType} (controllers required)`,\n\t\t\t\t);\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`No controller found for ${pkgStripped}. client-player.js bundles MUST include controllers!`,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tlogger.debug(\n\t\t\t\t\t`[registerPieElementsFromBundle] ℹ️ No controller found for ${pkgStripped} - using server-processed models (player.js bundle)`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t{\n\t\t\t// Register the element in our registry\n\t\t\tlogger.debug(\n\t\t\t\t`[registerPieElementsFromBundle] Registering ${elName} in registry${\n\t\t\t\t\telementData.controller\n\t\t\t\t\t\t? \" with controller\"\n\t\t\t\t\t\t: \" (no controller - server-processed models)\"\n\t\t\t\t}`,\n\t\t\t);\n\t\t\tregistry[elementTagName] = {\n\t\t\t\tpackage: pkg as string,\n\t\t\t\tstatus: Status.loading,\n\t\t\t\ttagName: elementTagName,\n\t\t\t\tcontroller: elementData.controller || null,\n\t\t\t\tconfig: elementData.config,\n\t\t\t\tbundleType: options.bundleType,\n\t\t\t};\n\n\t\t\tif (isCustomElementConstructor(elementData.Element)) {\n\t\t\t\tdefineCustomElementSafely(\n\t\t\t\t\telementTagName,\n\t\t\t\t\telementData.Element,\n\t\t\t\t\t`element tag in config.elements for ${String(pkg)}`,\n\t\t\t\t);\n\n\t\t\t\t// Initialize existing elements\n\t\t\t\tconst searchRoot = options.container || document;\n\t\t\t\tconst elements = searchRoot.querySelectorAll(elementTagName);\n\t\t\t\tlogger.debug(\n\t\t\t\t\t`[registerPieElementsFromBundle] Found ${elements.length} elements for tag '${elementTagName}'`,\n\t\t\t\t);\n\n\t\t\t\telements.forEach((el) => {\n\t\t\t\t\tinitializePieElement(el as PieElement, {\n\t\t\t\t\t\tconfig,\n\t\t\t\t\t\tsession,\n\t\t\t\t\t\tenv: options.env,\n\t\t\t\t\t\teventListeners: options.eventListeners?.[elementTagName],\n\t\t\t\t\t});\n\t\t\t\t});\n\n\t\t\t\t// Update registry status\n\t\t\t\tregistry[elementTagName] = {\n\t\t\t\t\t...registry[elementTagName],\n\t\t\t\t\tstatus: Status.loaded,\n\t\t\t\t};\n\n\t\t\t\tpromises.push(\n\t\t\t\t\tcustomElements.whenDefined(elementTagName).then(() => {\n\t\t\t\t\t\tlogger.debug(\n\t\t\t\t\t\t\t\"[registerPieElementsFromBundle] defined custom PIE element: %s\",\n\t\t\t\t\t\t\telementTagName,\n\t\t\t\t\t\t);\n\t\t\t\t\t}),\n\t\t\t\t);\n\n\t\t\t\t// Setup MutationObserver that uses current context (only once)\n\t\t\t\tif (!window._pieElementObserver) {\n\t\t\t\t\twindow._pieElementObserver = new MutationObserver((mutations) => {\n\t\t\t\t\t\t// Use current context from window instead of stale closure\n\t\t\t\t\t\tconst context = window._pieCurrentContext;\n\t\t\t\t\t\tif (!context) {\n\t\t\t\t\t\t\tlogger.warn(\"[MutationObserver] No current context available\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tmutations.forEach((mutation) => {\n\t\t\t\t\t\t\tif (mutation.type === \"childList\") {\n\t\t\t\t\t\t\t\tmutation.addedNodes.forEach((node) => {\n\t\t\t\t\t\t\t\t\tif (node.nodeType === Node.ELEMENT_NODE) {\n\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\t!isNodeWithinContainer(\n\t\t\t\t\t\t\t\t\t\t\t\tnode,\n\t\t\t\t\t\t\t\t\t\t\t\tcontext.container,\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tconst tagName = (node as Element).tagName.toLowerCase();\n\t\t\t\t\t\t\t\t\t\tif (registry[tagName]) {\n\t\t\t\t\t\t\t\t\t\t\tinitializePieElement(node as PieElement, {\n\t\t\t\t\t\t\t\t\t\t\t\tconfig: context.config,\n\t\t\t\t\t\t\t\t\t\t\t\tsession: context.session,\n\t\t\t\t\t\t\t\t\t\t\t\tenv: context.env,\n\t\t\t\t\t\t\t\t\t\t\t\teventListeners: options.eventListeners?.[tagName],\n\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t// Check children of added nodes\n\t\t\t\t\t\t\t\t\t\t(node as Element)\n\t\t\t\t\t\t\t\t\t\t\t.querySelectorAll(\"*\")\n\t\t\t\t\t\t\t\t\t\t\t.forEach((childNode) => {\n\t\t\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\t\t\t!isNodeWithinContainer(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tchildNode,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tcontext.container,\n\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\tconst childTagName = childNode.tagName.toLowerCase();\n\t\t\t\t\t\t\t\t\t\t\t\tif (registry[childTagName]) {\n\t\t\t\t\t\t\t\t\t\t\t\t\tinitializePieElement(childNode as PieElement, {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tconfig: context.config,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tsession: context.session,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tenv: context.env,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\teventListeners:\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\toptions.eventListeners?.[childTagName],\n\t\t\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\n\t\t\t\t\twindow._pieElementObserver.observe(document.body, {\n\t\t\t\t\t\tchildList: true,\n\t\t\t\t\t\tsubtree: true,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\t// Handle editor elements if needed\n\t\t\t\tif (options.bundleType === BundleType.editor) {\n\t\t\t\t\tif (isCustomElementConstructor(elementData.Configure)) {\n\t\t\t\t\t\tconst editorElName = getEditorElementTagName(\n\t\t\t\t\t\t\telementTagName,\n\t\t\t\t\t\t\tString(pkg),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tdefineCustomElementSafely(\n\t\t\t\t\t\t\teditorElName,\n\t\t\t\t\t\t\telementData.Configure,\n\t\t\t\t\t\t\t`editor element tag for ${String(pkg)}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tpromises.push(\n\t\t\t\t\t\t\tcustomElements.whenDefined(editorElName).then(() => {\n\t\t\t\t\t\t\t\tlogger.debug(\n\t\t\t\t\t\t\t\t\t`[registerPieElementsFromBundle] defined custom PIE editor element: ${editorElName}`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlogger.error(\n\t\t\t\t\t\t\t`[registerPieElementsFromBundle] pie.Configure for ${pkgStripped} is not a valid custom element constructor.`,\n\t\t\t\t\t\t\telementData.configure,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tlogger.error(\n\t\t\t\t\t`[registerPieElementsFromBundle] pie.Element for ${pkgStripped} is not a valid custom element constructor.`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t});\n\n\treturn promises;\n};\n\n/**\n * Initialize PIE elements from a bundle that may already be loaded.\n *\n * `window.pie` is the legacy bundle-loading global populated by\n * `loadPieModule` / `loadBundleFromString`. When the host loaded the\n * bundle through the deep `ElementLoader` primitive instead — as\n * `pie-section-player` does — the global is irrelevant: the loader\n * registers tags directly with `customElements`, so this function only\n * needs to bind models/sessions to whatever is already registered.\n *\n * Behavior:\n * - `window.pie` available → register any new tags from the bundle and\n * update bindings for already-registered tags (legacy fast path).\n * - `window.pie` missing → fall back to the update-only path. Tags that\n * are already registered get their model/session updated; tags that\n * are not yet registered are logged at `warn` and left alone — the\n * host's loader is expected to register them imminently, after which\n * the existing `MutationObserver` / `updatePieElements` flow binds\n * them on the next reactive pass.\n *\n * The original blanket `window.pie not found; was the bundle inlined\n * correctly?` error has been removed: in the section-player + item-player\n * composition it produced a confusing red stack trace for a routine\n * timing condition that the host already handles. Genuine failures\n * (bundle not loaded by *anyone*) still surface — every unregistered tag\n * gets its own warning, and `updatePieElements` later reports any tag\n * that never resolves.\n */\nexport const initializePiesFromLoadedBundle = (\n\tconfig: ConfigEntity,\n\tsession: any[],\n\topts: LoadPieElementsOptions = {},\n): void => {\n\tconst registry = pieRegistry();\n\tconst options = mergeObjectsIgnoringNullUndefined(defaultOptions, opts);\n\n\tif (isPieAvailable(window)) {\n\t\tlogger.debug(\"[initializePiesFromLoadedBundle] window.pie available\");\n\t\tconst elementModule = window.pie.default;\n\t\tregisterPieElementsFromBundle(\n\t\t\telementModule,\n\t\t\tconfig,\n\t\t\tsession,\n\t\t\tregistry,\n\t\t\toptions,\n\t\t);\n\t\treturn;\n\t}\n\n\tlogger.debug(\n\t\t\"[initializePiesFromLoadedBundle] window.pie not present; using update-only path. Already-registered tags will be bound now; missing tags are expected to be registered by the host's loader and will bind on the next update pass.\",\n\t);\n\tregisterPieElementsFromBundle(null, config, session, registry, options);\n};\n\n/**\n * Load a PIE bundle from a URL and initialize elements\n */\nexport const loadPieModule = async (\n\tconfig: ConfigEntity,\n\tsession: any[],\n\topts: LoadPieElementsOptions = {},\n): Promise<{\n\tsession: any[];\n}> => {\n\tif (!session) {\n\t\tthrow new Error(\"session is required\");\n\t}\n\n\t// Initialize math-rendering module (required by PIE elements)\n\tawait initializeMathRendering();\n\n\tconst registry = pieRegistry();\n\tconst options = mergeObjectsIgnoringNullUndefined(defaultOptions, opts);\n\tconst url = opts.bundleUrl || getPieElementBundlesUrl(config, options);\n\tconst script = document.createElement(\"script\");\n\tscript.src = url;\n\tscript.defer = true;\n\tscript.onerror = () => {\n\t\tthrow new Error(`failed to load script: ${url}`);\n\t};\n\n\tconst loadPromise = new Promise<void>((loadResolve) => {\n\t\tscript.addEventListener(\"load\", () => {\n\t\t\tlogger.debug(\"[loadPieModule] Script loaded from:\", url);\n\t\t\tif (isPieAvailable(window)) {\n\t\t\t\tlogger.debug(\"[loadPieModule] window.pie available\");\n\t\t\t\tconst elementModule = window.pie.default;\n\n\t\t\t\t// Use shared registration logic (returns array of promises)\n\t\t\t\tconst registrationPromises = registerPieElementsFromBundle(\n\t\t\t\t\telementModule,\n\t\t\t\t\tconfig,\n\t\t\t\t\tsession,\n\t\t\t\t\tregistry,\n\t\t\t\t\toptions,\n\t\t\t\t);\n\n\t\t\t\t// Wait for all element definitions to complete\n\t\t\t\tPromise.all(registrationPromises).then(() => loadResolve());\n\t\t\t} else {\n\t\t\t\tlogger.error(\n\t\t\t\t\t\"[loadPieModule] pie var not found; is %s a proper PIE IIFE module?\",\n\t\t\t\t\turl,\n\t\t\t\t);\n\t\t\t\tloadResolve();\n\t\t\t}\n\t\t});\n\t});\n\n\tdocument.head.appendChild(script);\n\tawait loadPromise;\n\treturn { session };\n};\n\n/**\n * Load a PIE bundle from a JavaScript string into window.pie (IIFE bundles only)\n * This only registers elements and controllers - does NOT initialize them.\n * For initialization, use initializePiesFromLoadedBundle after loading.\n */\nexport const loadBundleFromString = async (bundleJs: string): Promise<void> => {\n\tawait initializeMathRendering();\n\tawait withBlobBundleUrl(\n\t\tbundleJs,\n\t\t{ stripSourceMapComment: true },\n\t\tasync (bundleUrl) => {\n\t\t\t// Create a script tag to execute the bundle\n\t\t\tconst script = document.createElement(\"script\");\n\t\t\tscript.src = bundleUrl;\n\t\t\tscript.type = \"text/javascript\"; // IIFE bundles are standard JS\n\n\t\t\t// Wait for script to load\n\t\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\t\tscript.onload = () => resolve();\n\t\t\t\tscript.onerror = () => reject(new Error(\"Failed to load bundle\"));\n\t\t\t\tdocument.head.appendChild(script);\n\t\t\t});\n\n\t\t\tlogger.debug(\"[loadBundleFromString] Bundle loaded into window.pie\");\n\t\t},\n\t);\n};\n\n/**\n * Load a PIE bundle from a JavaScript string and initialize elements\n * Convenience wrapper around loadBundleFromString + loadPieModule\n */\nexport const loadPieModuleFromString = async (\n\tbundleJs: string,\n\tconfig: ConfigEntity,\n\tsession: any[],\n\topts: LoadPieElementsOptions = {},\n): Promise<void> => {\n\tawait withBlobBundleUrl(bundleJs, {}, async (bundleUrl) => {\n\t\t// Use existing loadPieModule with the blob URL\n\t\tawait loadPieModule(config, session, { ...opts, bundleUrl });\n\t});\n};\n\nconst withBlobBundleUrl = async <T>(\n\tbundleJs: string,\n\toptions: { stripSourceMapComment?: boolean },\n\trun: (bundleUrl: string) => Promise<T>,\n): Promise<T> => {\n\tconst source = options.stripSourceMapComment\n\t\t? bundleJs.replace(/\\/\\/# sourceMappingURL=.*$/m, \"\")\n\t\t: bundleJs;\n\tconst blob = new Blob([source], { type: \"application/javascript\" });\n\tconst bundleUrl = URL.createObjectURL(blob);\n\ttry {\n\t\treturn await run(bundleUrl);\n\t} finally {\n\t\tURL.revokeObjectURL(bundleUrl);\n\t}\n};\n"]}
|
|
1
|
+
{"version":3,"file":"initialization.js","sourceRoot":"","sources":["../../src/pie/initialization.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,iCAAiC,EAAE,MAAM,oBAAoB,CAAC;AAEvE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACl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,CAAC;IAC9D,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,KAAK,EAC9B,QAAgB,EAChB,OAA4C,EAC5C,GAAsC,EACzB,EAAE;IACf,MAAM,MAAM,GAAG,OAAO,CAAC,qBAAqB;QAC3C,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,6BAA6B,EAAE,EAAE,CAAC;QACrD,CAAC,CAAC,QAAQ,CAAC;IACZ,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,wBAAwB,EAAE,CAAC,CAAC;IACpE,MAAM,SAAS,GAAG,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAC5C,IAAI,CAAC;QACJ,OAAO,MAAM,GAAG,CAAC,SAAS,CAAC,CAAC;IAC7B,CAAC;YAAS,CAAC;QACV,GAAG,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;IAChC,CAAC;AACF,CAAC,CAAC","sourcesContent":["/**\n * PIE Initialization Module\n *\n * Bundle loading and element initialization logic.\n * This is the core of the PIE player system.\n */\n\nimport { BUILDER_BUNDLE_URL } from \"../config/profile.js\";\nimport { mergeObjectsIgnoringNullUndefined } from \"../object/index.js\";\nimport type { ConfigEntity, Env, PieModel } from \"../types/index.js\";\nimport { editorPostFix } from \"../types/index.js\";\nimport { createPieLogger, isGlobalDebugEnabled } from \"./logger.js\";\nimport { initializeMathRendering } from \"./math-rendering.js\";\nimport { pieRegistry } from \"./registry.js\";\nimport { findPieController } from \"./scoring.js\";\nimport { defineCustomElementSafely } from \"./custom-element-define.js\";\nimport { validateCustomElementTag } from \"./tag-names.js\";\nimport type {\n\tEventListeners,\n\tLoadPieElementsOptions,\n\tPieElement,\n\tPieRegistry,\n} from \"./types.js\";\nimport {\n\tBundleType,\n\tisCustomElementConstructor,\n\tisPieAvailable,\n\tStatus,\n} from \"./types.js\";\nimport { updatePieElement } from \"./updates.js\";\nimport {\n\tfindOrAddSession,\n\tgetPackageWithoutVersion,\n\tgetPieElementBundlesUrl,\n} from \"./utils.js\";\n\n// Create module-level logger (respects global debug flag - pass function for dynamic checking)\nconst logger = createPieLogger(\"pie-initialization\", () =>\n\tisGlobalDebugEnabled(),\n);\n\n// Default options for loading PIE elements\nconst defaultOptions: LoadPieElementsOptions = {\n\tbuildServiceBase: BUILDER_BUNDLE_URL,\n\tbundleType: BundleType.player, // Default to player.js (no controllers, server-processed models)\n\tenv: { mode: \"gather\", role: \"student\" },\n};\n\n// Add this to your window types\ndeclare global {\n\tinterface Window {\n\t\t_pieElementObserver?: MutationObserver;\n\t\t_pieCurrentContext?: {\n\t\t\tconfig: ConfigEntity;\n\t\t\tsession: any[];\n\t\t\tenv?: Env;\n\t\t\tcontainer?: Element | Document;\n\t\t};\n\t}\n}\n\n/**\n * Helper function to initialize a PIE element\n */\nconst initializePieElement = (\n\telement: PieElement,\n\toptions: {\n\t\tconfig: ConfigEntity;\n\t\tsession: any[];\n\t\tenv?: Env;\n\t\teventListeners?: EventListeners;\n\t},\n): void => {\n\tconst { config, session, env, eventListeners } = options;\n\tif ((element as any).__pieInitialized) {\n\t\treturn;\n\t}\n\tconst tagName = element.tagName.toLowerCase();\n\n\tlogger.debug(`[initializePieElement] Initializing ${tagName}#${element.id}`);\n\n\t// Find model for this element\n\tlet model = config?.models?.find((m) => m.id === element.id) as PieModel;\n\tif (!model) {\n\t\t// Only warn if this element is from a client-player.js bundle (where models are expected)\n\t\t// player.js bundles use server-processed models, so missing models are expected there\n\t\tconst registry = pieRegistry();\n\t\tconst registryEntry = registry[tagName];\n\n\t\tif (registryEntry && registryEntry.bundleType === BundleType.clientPlayer) {\n\t\t\tlogger.warn(\n\t\t\t\t`[initializePieElement] Model not found for PIE element ${tagName}#${element.id} (client-player.js bundle)`,\n\t\t\t);\n\t\t}\n\t\treturn;\n\t}\n\n\t// Set session (with element property for updateSession callback)\n\tconst elementSession = findOrAddSession(session, model.id, model.element);\n\telement.session = elementSession;\n\t(element as any).__pieInitialized = true;\n\tlogger.debug(\n\t\t`[initializePieElement] Session set for ${tagName}#${element.id}:`,\n\t\telementSession,\n\t);\n\n\t// Set model - use controller if available (client-player.js), or use server-processed model (player.js)\n\tconst controller = findPieController(tagName);\n\n\tif (!env) {\n\t\tlogger.error(\n\t\t\t`[initializePieElement] ❌ FATAL: No env provided for ${tagName}`,\n\t\t);\n\t\tthrow new Error(\n\t\t\t`No env provided for ${tagName}. PIE elements require an env object with mode and role.`,\n\t\t);\n\t}\n\n\tif (!controller) {\n\t\t// No controller available - using server-processed model (player.js bundle)\n\t\tlogger.debug(\n\t\t\t`[initializePieElement] ℹ️ No controller for ${tagName}, using server-processed model`,\n\t\t);\n\t\tlogger.debug(`[initializePieElement] Model already processed by server:`, {\n\t\t\tid: model.id,\n\t\t\telement: model.element,\n\t\t\thasCorrectResponse: \"correctResponse\" in model,\n\t\t\tmode: env.mode,\n\t\t\trole: env.role,\n\t\t});\n\n\t\t// Set model directly - server already processed it\n\t\telement.model = model;\n\t} else {\n\t\t// Controller available - run client-side processing (client-player.js bundle)\n\t\t// Note: updatePieElementWithRef handles controller invocation\n\t\tlogger.debug(\n\t\t\t`[initializePieElement] Controller found for ${tagName}, will invoke model() function`,\n\t\t);\n\t}\n\n\t// Add event listeners\n\tif (eventListeners) {\n\t\tObject.entries(eventListeners).forEach(([evt, fn]) => {\n\t\t\telement.addEventListener(evt as any, fn);\n\t\t});\n\t}\n};\n\nconst getEditorElementTagName = (elementTagName: string, pkg: string): string =>\n\tvalidateCustomElementTag(\n\t\telementTagName + editorPostFix,\n\t\t`editor element tag for ${pkg}`,\n\t);\n\nconst updateRegisteredElement = (\n\telementTagName: string,\n\tconfig: ConfigEntity,\n\tsession: any[],\n\toptions: LoadPieElementsOptions,\n\tomitEnv = false,\n): void => {\n\tupdatePieElement(elementTagName, {\n\t\tconfig,\n\t\tsession,\n\t\t...(omitEnv ? {} : { env: options.env }),\n\t\tcontainer: options.container,\n\t\t...(options.eventListeners?.[elementTagName] && {\n\t\t\teventListeners: options.eventListeners[elementTagName],\n\t\t}),\n\t});\n};\n\n/**\n * Shared element registration logic\n * Extracted from initializePiesFromLoadedBundle and loadPieModule to eliminate ~200 lines of duplication\n * Also fixes MutationObserver memory leak by storing latest config/session in window context\n *\n * `elementModule` may be `null`. In that case we cannot register *new*\n * tags (no element constructor source), but we can still update tags\n * that another loader (e.g. the section-player's IIFE adapter) has\n * already registered with `customElements`. This is the common case\n * when `pie-item-player` mounts inside `pie-section-player`: the\n * section player has already pre-warmed the bundle through the deep\n * `ElementLoader` primitive, so the `window.pie.default` bundle-global\n * path is not required for those tags.\n */\nconst registerPieElementsFromBundle = (\n\telementModule: any | null,\n\tconfig: ConfigEntity,\n\tsession: any[],\n\tregistry: PieRegistry,\n\toptions: LoadPieElementsOptions,\n): Promise<void>[] => {\n\tconst promises: Promise<void>[] = [];\n\tconst isNodeWithinContainer = (\n\t\tnode: Node,\n\t\tcontainer?: Element | Document,\n\t): boolean => {\n\t\tif (!container || container === document) return true;\n\t\treturn node instanceof Node && container.contains(node);\n\t};\n\n\tif (elementModule) {\n\t\tlogger.debug(\n\t\t\t\"[registerPieElementsFromBundle] Available packages in bundle:\",\n\t\t\tObject.keys(elementModule),\n\t\t);\n\t} else {\n\t\tlogger.debug(\n\t\t\t\"[registerPieElementsFromBundle] No bundle module supplied; will only update tags already registered with customElements.\",\n\t\t);\n\t}\n\tlogger.debug(\n\t\t\"[registerPieElementsFromBundle] config.elements:\",\n\t\tconfig.elements,\n\t);\n\n\t// Store latest config/session in window so MutationObserver can access current values\n\tif (typeof window !== \"undefined\") {\n\t\twindow._pieCurrentContext = {\n\t\t\tconfig,\n\t\t\tsession,\n\t\t\tenv: options.env,\n\t\t\tcontainer: options.container,\n\t\t};\n\t}\n\n\tObject.entries(config.elements).forEach(([elName, pkg]) => {\n\t\tconst elementTagName = validateCustomElementTag(\n\t\t\telName,\n\t\t\t`element tag in config.elements for ${String(pkg)}`,\n\t\t);\n\t\tlogger.debug(\n\t\t\t`[registerPieElementsFromBundle] Processing element: ${elementTagName} -> ${pkg}`,\n\t\t);\n\n\t\t// Fast path — the tag is already registered with customElements\n\t\t// (typically by the host's pre-warm pipeline). We can update its\n\t\t// session/model bindings without needing the bundle module at all.\n\t\t// This branch is also the one that runs when `elementModule` is\n\t\t// `null` because `window.pie` was missing.\n\t\tif (customElements.get(elementTagName)) {\n\t\t\tupdateRegisteredElement(elementTagName, config, session, options);\n\n\t\t\tif (options.bundleType === BundleType.editor) {\n\t\t\t\tconst editorElName = getEditorElementTagName(\n\t\t\t\t\telementTagName,\n\t\t\t\t\tString(pkg),\n\t\t\t\t);\n\t\t\t\tupdateRegisteredElement(\n\t\t\t\t\teditorElName,\n\t\t\t\t\tconfig,\n\t\t\t\t\tsession,\n\t\t\t\t\toptions,\n\t\t\t\t\ttrue,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// From here on we are in the \"register a new tag\" branch, which\n\t\t// requires a bundle module to read the element constructor from.\n\t\tif (!elementModule) {\n\t\t\t// A missing bundle module + an unregistered tag is *not*\n\t\t\t// always an error: in the section-player composition the\n\t\t\t// host's own `ElementLoader` may register this tag\n\t\t\t// out-of-band moments later, in which case `updatePieElement`\n\t\t\t// will pick it up on the next reactive pass via the\n\t\t\t// MutationObserver / `whenDefined` paths. Log at warn so the\n\t\t\t// transient miss is still visible during diagnostics without\n\t\t\t// printing a red stack trace for a routine timing condition.\n\t\t\tlogger.warn(\n\t\t\t\t`[registerPieElementsFromBundle] Skipping \"${elementTagName}\" — no bundle module available and the tag is not yet registered. Will bind on next update if the host's loader registers it.`,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst pkgStripped = getPackageWithoutVersion(pkg as string);\n\t\tlogger.debug(\n\t\t\t`[registerPieElementsFromBundle] Package without version: \"${pkgStripped}\"`,\n\t\t);\n\n\t\tconst elementData = elementModule[pkgStripped];\n\t\tlogger.debug(\n\t\t\t`[registerPieElementsFromBundle] elementData result:`,\n\t\t\telementData ? \"FOUND\" : \"UNDEFINED\",\n\t\t);\n\n\t\tif (!elementData) {\n\t\t\tlogger.error(\n\t\t\t\t`[registerPieElementsFromBundle] ❌ Package \"${pkgStripped}\" not found in bundle!`,\n\t\t\t);\n\t\t\tlogger.error(\n\t\t\t\t`[registerPieElementsFromBundle] Lookup key: \"${pkgStripped}\"`,\n\t\t\t);\n\t\t\tlogger.error(\n\t\t\t\t`[registerPieElementsFromBundle] Available packages:`,\n\t\t\t\tObject.keys(elementModule),\n\t\t\t);\n\t\t\tthrow new Error(\n\t\t\t\t`pie ${pkgStripped} not found in ${Object.keys(elementModule)}`,\n\t\t\t);\n\t\t}\n\n\t\tlogger.debug(\n\t\t\t`[registerPieElementsFromBundle] elementData for ${pkgStripped}:`,\n\t\t\t{\n\t\t\t\thasController: !!elementData.controller,\n\t\t\t\thasElement: !!elementData.Element,\n\t\t\t\thasConfig: !!elementData.config,\n\t\t\t\tcontrollerKeys: elementData.controller\n\t\t\t\t\t? Object.keys(elementData.controller)\n\t\t\t\t\t: [],\n\t\t\t\tbundleType: options.bundleType,\n\t\t\t},\n\t\t);\n\n\t\t// Validate controller presence based on bundle type\n\t\tif (!elementData.controller) {\n\t\t\tif (options.bundleType === BundleType.clientPlayer) {\n\t\t\t\tlogger.error(\n\t\t\t\t\t`[registerPieElementsFromBundle] ❌ CRITICAL: No controller found for ${pkgStripped}!`,\n\t\t\t\t);\n\t\t\t\tlogger.error(\n\t\t\t\t\t`[registerPieElementsFromBundle] Bundle type: ${options.bundleType} (controllers required)`,\n\t\t\t\t);\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`No controller found for ${pkgStripped}. client-player.js bundles MUST include controllers!`,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tlogger.debug(\n\t\t\t\t\t`[registerPieElementsFromBundle] ℹ️ No controller found for ${pkgStripped} - using server-processed models (player.js bundle)`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t{\n\t\t\t// Register the element in our registry\n\t\t\tlogger.debug(\n\t\t\t\t`[registerPieElementsFromBundle] Registering ${elName} in registry${\n\t\t\t\t\telementData.controller\n\t\t\t\t\t\t? \" with controller\"\n\t\t\t\t\t\t: \" (no controller - server-processed models)\"\n\t\t\t\t}`,\n\t\t\t);\n\t\t\tregistry[elementTagName] = {\n\t\t\t\tpackage: pkg as string,\n\t\t\t\tstatus: Status.loading,\n\t\t\t\ttagName: elementTagName,\n\t\t\t\tcontroller: elementData.controller || null,\n\t\t\t\tconfig: elementData.config,\n\t\t\t\tbundleType: options.bundleType,\n\t\t\t};\n\n\t\t\tif (isCustomElementConstructor(elementData.Element)) {\n\t\t\t\tdefineCustomElementSafely(\n\t\t\t\t\telementTagName,\n\t\t\t\t\telementData.Element,\n\t\t\t\t\t`element tag in config.elements for ${String(pkg)}`,\n\t\t\t\t);\n\n\t\t\t\t// Initialize existing elements\n\t\t\t\tconst searchRoot = options.container || document;\n\t\t\t\tconst elements = searchRoot.querySelectorAll(elementTagName);\n\t\t\t\tlogger.debug(\n\t\t\t\t\t`[registerPieElementsFromBundle] Found ${elements.length} elements for tag '${elementTagName}'`,\n\t\t\t\t);\n\n\t\t\t\telements.forEach((el) => {\n\t\t\t\t\tinitializePieElement(el as PieElement, {\n\t\t\t\t\t\tconfig,\n\t\t\t\t\t\tsession,\n\t\t\t\t\t\tenv: options.env,\n\t\t\t\t\t\teventListeners: options.eventListeners?.[elementTagName],\n\t\t\t\t\t});\n\t\t\t\t});\n\n\t\t\t\t// Update registry status\n\t\t\t\tregistry[elementTagName] = {\n\t\t\t\t\t...registry[elementTagName],\n\t\t\t\t\tstatus: Status.loaded,\n\t\t\t\t};\n\n\t\t\t\tpromises.push(\n\t\t\t\t\tcustomElements.whenDefined(elementTagName).then(() => {\n\t\t\t\t\t\tlogger.debug(\n\t\t\t\t\t\t\t\"[registerPieElementsFromBundle] defined custom PIE element: %s\",\n\t\t\t\t\t\t\telementTagName,\n\t\t\t\t\t\t);\n\t\t\t\t\t}),\n\t\t\t\t);\n\n\t\t\t\t// Setup MutationObserver that uses current context (only once)\n\t\t\t\tif (!window._pieElementObserver) {\n\t\t\t\t\twindow._pieElementObserver = new MutationObserver((mutations) => {\n\t\t\t\t\t\t// Use current context from window instead of stale closure\n\t\t\t\t\t\tconst context = window._pieCurrentContext;\n\t\t\t\t\t\tif (!context) {\n\t\t\t\t\t\t\tlogger.warn(\"[MutationObserver] No current context available\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tmutations.forEach((mutation) => {\n\t\t\t\t\t\t\tif (mutation.type === \"childList\") {\n\t\t\t\t\t\t\t\tmutation.addedNodes.forEach((node) => {\n\t\t\t\t\t\t\t\t\tif (node.nodeType === Node.ELEMENT_NODE) {\n\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\t!isNodeWithinContainer(\n\t\t\t\t\t\t\t\t\t\t\t\tnode,\n\t\t\t\t\t\t\t\t\t\t\t\tcontext.container,\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tconst tagName = (node as Element).tagName.toLowerCase();\n\t\t\t\t\t\t\t\t\t\tif (registry[tagName]) {\n\t\t\t\t\t\t\t\t\t\t\tinitializePieElement(node as PieElement, {\n\t\t\t\t\t\t\t\t\t\t\t\tconfig: context.config,\n\t\t\t\t\t\t\t\t\t\t\t\tsession: context.session,\n\t\t\t\t\t\t\t\t\t\t\t\tenv: context.env,\n\t\t\t\t\t\t\t\t\t\t\t\teventListeners: options.eventListeners?.[tagName],\n\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t// Check children of added nodes\n\t\t\t\t\t\t\t\t\t\t(node as Element)\n\t\t\t\t\t\t\t\t\t\t\t.querySelectorAll(\"*\")\n\t\t\t\t\t\t\t\t\t\t\t.forEach((childNode) => {\n\t\t\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\t\t\t!isNodeWithinContainer(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tchildNode,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tcontext.container,\n\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\tconst childTagName = childNode.tagName.toLowerCase();\n\t\t\t\t\t\t\t\t\t\t\t\tif (registry[childTagName]) {\n\t\t\t\t\t\t\t\t\t\t\t\t\tinitializePieElement(childNode as PieElement, {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tconfig: context.config,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tsession: context.session,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tenv: context.env,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\teventListeners:\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\toptions.eventListeners?.[childTagName],\n\t\t\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\n\t\t\t\t\twindow._pieElementObserver.observe(document.body, {\n\t\t\t\t\t\tchildList: true,\n\t\t\t\t\t\tsubtree: true,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\t// Handle editor elements if needed\n\t\t\t\tif (options.bundleType === BundleType.editor) {\n\t\t\t\t\tif (isCustomElementConstructor(elementData.Configure)) {\n\t\t\t\t\t\tconst editorElName = getEditorElementTagName(\n\t\t\t\t\t\t\telementTagName,\n\t\t\t\t\t\t\tString(pkg),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tdefineCustomElementSafely(\n\t\t\t\t\t\t\teditorElName,\n\t\t\t\t\t\t\telementData.Configure,\n\t\t\t\t\t\t\t`editor element tag for ${String(pkg)}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tpromises.push(\n\t\t\t\t\t\t\tcustomElements.whenDefined(editorElName).then(() => {\n\t\t\t\t\t\t\t\tlogger.debug(\n\t\t\t\t\t\t\t\t\t`[registerPieElementsFromBundle] defined custom PIE editor element: ${editorElName}`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlogger.error(\n\t\t\t\t\t\t\t`[registerPieElementsFromBundle] pie.Configure for ${pkgStripped} is not a valid custom element constructor.`,\n\t\t\t\t\t\t\telementData.configure,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tlogger.error(\n\t\t\t\t\t`[registerPieElementsFromBundle] pie.Element for ${pkgStripped} is not a valid custom element constructor.`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t});\n\n\treturn promises;\n};\n\n/**\n * Initialize PIE elements from a bundle that may already be loaded.\n *\n * `window.pie` is the IIFE bundle-loading global populated by\n * `loadPieModule` / `loadBundleFromString`. When the host loaded the\n * bundle through the deep `ElementLoader` primitive instead — as\n * `pie-section-player` does — the global is irrelevant: the loader\n * registers tags directly with `customElements`, so this function only\n * needs to bind models/sessions to whatever is already registered.\n *\n * Behavior:\n * - `window.pie` available → register any new tags from the bundle and\n * update bindings for already-registered tags.\n * - `window.pie` missing → fall back to the update-only path. Tags that\n * are already registered get their model/session updated; tags that\n * are not yet registered are logged at `warn` and left alone — the\n * host's loader is expected to register them imminently, after which\n * the existing `MutationObserver` / `updatePieElements` flow binds\n * them on the next reactive pass.\n *\n * The original blanket `window.pie not found; was the bundle inlined\n * correctly?` error has been removed: in the section-player + item-player\n * composition it produced a confusing red stack trace for a routine\n * timing condition that the host already handles. Genuine failures\n * (bundle not loaded by *anyone*) still surface — every unregistered tag\n * gets its own warning, and `updatePieElements` later reports any tag\n * that never resolves.\n */\nexport const initializePiesFromLoadedBundle = (\n\tconfig: ConfigEntity,\n\tsession: any[],\n\topts: LoadPieElementsOptions = {},\n): void => {\n\tconst registry = pieRegistry();\n\tconst options = mergeObjectsIgnoringNullUndefined(defaultOptions, opts);\n\n\tif (isPieAvailable(window)) {\n\t\tlogger.debug(\"[initializePiesFromLoadedBundle] window.pie available\");\n\t\tconst elementModule = window.pie.default;\n\t\tregisterPieElementsFromBundle(\n\t\t\telementModule,\n\t\t\tconfig,\n\t\t\tsession,\n\t\t\tregistry,\n\t\t\toptions,\n\t\t);\n\t\treturn;\n\t}\n\n\tlogger.debug(\n\t\t\"[initializePiesFromLoadedBundle] window.pie not present; using update-only path. Already-registered tags will be bound now; missing tags are expected to be registered by the host's loader and will bind on the next update pass.\",\n\t);\n\tregisterPieElementsFromBundle(null, config, session, registry, options);\n};\n\n/**\n * Load a PIE bundle from a URL and initialize elements\n */\nexport const loadPieModule = async (\n\tconfig: ConfigEntity,\n\tsession: any[],\n\topts: LoadPieElementsOptions = {},\n): Promise<{\n\tsession: any[];\n}> => {\n\tif (!session) {\n\t\tthrow new Error(\"session is required\");\n\t}\n\n\t// Initialize math-rendering module (required by PIE elements)\n\tawait initializeMathRendering();\n\n\tconst registry = pieRegistry();\n\tconst options = mergeObjectsIgnoringNullUndefined(defaultOptions, opts);\n\tconst url = opts.bundleUrl || getPieElementBundlesUrl(config, options);\n\tconst script = document.createElement(\"script\");\n\tscript.src = url;\n\tscript.defer = true;\n\tscript.onerror = () => {\n\t\tthrow new Error(`failed to load script: ${url}`);\n\t};\n\n\tconst loadPromise = new Promise<void>((loadResolve) => {\n\t\tscript.addEventListener(\"load\", () => {\n\t\t\tlogger.debug(\"[loadPieModule] Script loaded from:\", url);\n\t\t\tif (isPieAvailable(window)) {\n\t\t\t\tlogger.debug(\"[loadPieModule] window.pie available\");\n\t\t\t\tconst elementModule = window.pie.default;\n\n\t\t\t\t// Use shared registration logic (returns array of promises)\n\t\t\t\tconst registrationPromises = registerPieElementsFromBundle(\n\t\t\t\t\telementModule,\n\t\t\t\t\tconfig,\n\t\t\t\t\tsession,\n\t\t\t\t\tregistry,\n\t\t\t\t\toptions,\n\t\t\t\t);\n\n\t\t\t\t// Wait for all element definitions to complete\n\t\t\t\tPromise.all(registrationPromises).then(() => loadResolve());\n\t\t\t} else {\n\t\t\t\tlogger.error(\n\t\t\t\t\t\"[loadPieModule] pie var not found; is %s a proper PIE IIFE module?\",\n\t\t\t\t\turl,\n\t\t\t\t);\n\t\t\t\tloadResolve();\n\t\t\t}\n\t\t});\n\t});\n\n\tdocument.head.appendChild(script);\n\tawait loadPromise;\n\treturn { session };\n};\n\n/**\n * Load a PIE bundle from a JavaScript string into window.pie (IIFE bundles only)\n * This only registers elements and controllers - does NOT initialize them.\n * For initialization, use initializePiesFromLoadedBundle after loading.\n */\nexport const loadBundleFromString = async (bundleJs: string): Promise<void> => {\n\tawait initializeMathRendering();\n\tawait withBlobBundleUrl(\n\t\tbundleJs,\n\t\t{ stripSourceMapComment: true },\n\t\tasync (bundleUrl) => {\n\t\t\t// Create a script tag to execute the bundle\n\t\t\tconst script = document.createElement(\"script\");\n\t\t\tscript.src = bundleUrl;\n\t\t\tscript.type = \"text/javascript\"; // IIFE bundles are standard JS\n\n\t\t\t// Wait for script to load\n\t\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\t\tscript.onload = () => resolve();\n\t\t\t\tscript.onerror = () => reject(new Error(\"Failed to load bundle\"));\n\t\t\t\tdocument.head.appendChild(script);\n\t\t\t});\n\n\t\t\tlogger.debug(\"[loadBundleFromString] Bundle loaded into window.pie\");\n\t\t},\n\t);\n};\n\n/**\n * Load a PIE bundle from a JavaScript string and initialize elements\n * Convenience wrapper around loadBundleFromString + loadPieModule\n */\nexport const loadPieModuleFromString = async (\n\tbundleJs: string,\n\tconfig: ConfigEntity,\n\tsession: any[],\n\topts: LoadPieElementsOptions = {},\n): Promise<void> => {\n\tawait withBlobBundleUrl(bundleJs, {}, async (bundleUrl) => {\n\t\t// Use existing loadPieModule with the blob URL\n\t\tawait loadPieModule(config, session, { ...opts, bundleUrl });\n\t});\n};\n\nconst withBlobBundleUrl = async <T>(\n\tbundleJs: string,\n\toptions: { stripSourceMapComment?: boolean },\n\trun: (bundleUrl: string) => Promise<T>,\n): Promise<T> => {\n\tconst source = options.stripSourceMapComment\n\t\t? bundleJs.replace(/\\/\\/# sourceMappingURL=.*$/m, \"\")\n\t\t: bundleJs;\n\tconst blob = new Blob([source], { type: \"application/javascript\" });\n\tconst bundleUrl = URL.createObjectURL(blob);\n\ttry {\n\t\treturn await run(bundleUrl);\n\t} finally {\n\t\tURL.revokeObjectURL(bundleUrl);\n\t}\n};\n"]}
|
|
@@ -35,11 +35,9 @@ export const SECTION_INSTRUMENTATION_EVENT_MAP = [
|
|
|
35
35
|
// M6 canonical readiness vocabulary. Hosts listen for the DOM-prefixed
|
|
36
36
|
// names directly (`pie-stage-change`, `pie-loading-complete`); the
|
|
37
37
|
// instrumentation bridge forwards the same names to telemetry. The
|
|
38
|
-
//
|
|
39
|
-
// `
|
|
40
|
-
//
|
|
41
|
-
// architecture review compat sweep alongside their DOM-event
|
|
42
|
-
// surfaces.
|
|
38
|
+
// readiness alias mappings (`readiness-change`, `interaction-ready`,
|
|
39
|
+
// `ready`) and the `section-controller-ready` mapping were removed
|
|
40
|
+
// alongside their DOM-event surfaces.
|
|
43
41
|
{
|
|
44
42
|
sourceEventName: "pie-stage-change",
|
|
45
43
|
instrumentationEventName: "pie-section-stage-change",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentation-event-map.js","sourceRoot":"","sources":["../../src/pie/instrumentation-event-map.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,iCAAiC,GAAkC;IAC/E,mEAAmE;IACnE,uEAAuE;IACvE,sEAAsE;IACtE,qEAAqE;IACrE,gEAAgE;IAChE,uEAAuE;IACvE,8CAA8C;IAC9C;QACC,eAAe,EAAE,kBAAkB;QACnC,wBAAwB,EAAE,0BAA0B;KACpD;IACD;QACC,eAAe,EAAE,eAAe;QAChC,wBAAwB,EAAE,2BAA2B;KACrD;IACD;QACC,eAAe,EAAE,mBAAmB;QACpC,wBAAwB,EAAE,+BAA+B;KACzD;IACD;QACC,eAAe,EAAE,eAAe;QAChC,wBAAwB,EAAE,mBAAmB;KAC7C;IACD;QACC,eAAe,EAAE,eAAe;QAChC,wBAAwB,EAAE,2BAA2B;KACrD;IACD;QACC,eAAe,EAAE,iBAAiB;QAClC,wBAAwB,EAAE,6BAA6B;KACvD;CACD,CAAC;AAEF,MAAM,CAAC,MAAM,iCAAiC,GAAkC;IAC/E,uEAAuE;IACvE,mEAAmE;IACnE,mEAAmE;IACnE,
|
|
1
|
+
{"version":3,"file":"instrumentation-event-map.js","sourceRoot":"","sources":["../../src/pie/instrumentation-event-map.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,iCAAiC,GAAkC;IAC/E,mEAAmE;IACnE,uEAAuE;IACvE,sEAAsE;IACtE,qEAAqE;IACrE,gEAAgE;IAChE,uEAAuE;IACvE,8CAA8C;IAC9C;QACC,eAAe,EAAE,kBAAkB;QACnC,wBAAwB,EAAE,0BAA0B;KACpD;IACD;QACC,eAAe,EAAE,eAAe;QAChC,wBAAwB,EAAE,2BAA2B;KACrD;IACD;QACC,eAAe,EAAE,mBAAmB;QACpC,wBAAwB,EAAE,+BAA+B;KACzD;IACD;QACC,eAAe,EAAE,eAAe;QAChC,wBAAwB,EAAE,mBAAmB;KAC7C;IACD;QACC,eAAe,EAAE,eAAe;QAChC,wBAAwB,EAAE,2BAA2B;KACrD;IACD;QACC,eAAe,EAAE,iBAAiB;QAClC,wBAAwB,EAAE,6BAA6B;KACvD;CACD,CAAC;AAEF,MAAM,CAAC,MAAM,iCAAiC,GAAkC;IAC/E,uEAAuE;IACvE,mEAAmE;IACnE,mEAAmE;IACnE,qEAAqE;IACrE,mEAAmE;IACnE,sCAAsC;IACtC;QACC,eAAe,EAAE,kBAAkB;QACnC,wBAAwB,EAAE,0BAA0B;KACpD;IACD;QACC,eAAe,EAAE,sBAAsB;QACvC,wBAAwB,EAAE,8BAA8B;KACxD;IACD;QACC,eAAe,EAAE,iBAAiB;QAClC,wBAAwB,EAAE,6BAA6B;KACvD;IACD;QACC,eAAe,EAAE,qBAAqB;QACtC,wBAAwB,EAAE,iCAAiC;KAC3D;IACD;QACC,eAAe,EAAE,iBAAiB;QAClC,wBAAwB,EAAE,6BAA6B;KACvD;IACD;QACC,eAAe,EAAE,uBAAuB;QACxC,wBAAwB,EAAE,mCAAmC;KAC7D;IACD;QACC,eAAe,EAAE,uBAAuB;QACxC,wBAAwB,EAAE,mCAAmC;KAC7D;CACD,CAAC;AAEF,MAAM,CAAC,MAAM,oCAAoC,GAAkC;IAClF;QACC,eAAe,EAAE,6BAA6B;QAC9C,wBAAwB,EAAE,iCAAiC;KAC3D;IACD;QACC,eAAe,EAAE,iCAAiC;QAClD,wBAAwB,EAAE,qCAAqC;KAC/D;IACD;QACC,eAAe,EAAE,0BAA0B;QAC3C,wBAAwB,EAAE,8BAA8B;KACxD;IACD;QACC,eAAe,EAAE,4BAA4B;QAC7C,wBAAwB,EAAE,gCAAgC;KAC1D;IACD;QACC,eAAe,EAAE,4BAA4B;QAC7C,wBAAwB,EAAE,gCAAgC;KAC1D;IACD;QACC,eAAe,EAAE,6BAA6B;QAC9C,wBAAwB,EAAE,iCAAiC;KAC3D;IACD;QACC,eAAe,EAAE,qCAAqC;QACtD,wBAAwB,EAAE,yCAAyC;KACnE;IACD;QACC,eAAe,EAAE,kBAAkB;QACnC,wBAAwB,EAAE,sBAAsB;KAChD;CACD,CAAC","sourcesContent":["export type InstrumentationEventMapping = {\n\tsourceEventName: string;\n\tinstrumentationEventName: string;\n};\n\nexport const TOOLKIT_INSTRUMENTATION_EVENT_MAP: InstrumentationEventMapping[] = [\n\t// M6 canonical readiness vocabulary. The four-stage canonical list\n\t// (`composed`, `engine-ready`, `interactive`, `disposed`) is identical\n\t// across the toolkit CE and the layout CEs — the M6 retro removed the\n\t// `attached`, `runtime-bound`, and `ui-rendered` stages because they\n\t// had zero internal or external consumers. Hosts listen for the\n\t// DOM-prefixed name directly (`pie-stage-change`); the instrumentation\n\t// bridge forwards the same name to telemetry.\n\t{\n\t\tsourceEventName: \"pie-stage-change\",\n\t\tinstrumentationEventName: \"pie-toolkit-stage-change\",\n\t},\n\t{\n\t\tsourceEventName: \"runtime-owned\",\n\t\tinstrumentationEventName: \"pie-toolkit-runtime-owned\",\n\t},\n\t{\n\t\tsourceEventName: \"runtime-inherited\",\n\t\tinstrumentationEventName: \"pie-toolkit-runtime-inherited\",\n\t},\n\t{\n\t\tsourceEventName: \"toolkit-ready\",\n\t\tinstrumentationEventName: \"pie-toolkit-ready\",\n\t},\n\t{\n\t\tsourceEventName: \"section-ready\",\n\t\tinstrumentationEventName: \"pie-toolkit-section-ready\",\n\t},\n\t{\n\t\tsourceEventName: \"framework-error\",\n\t\tinstrumentationEventName: \"pie-toolkit-framework-error\",\n\t},\n];\n\nexport const SECTION_INSTRUMENTATION_EVENT_MAP: InstrumentationEventMapping[] = [\n\t// M6 canonical readiness vocabulary. Hosts listen for the DOM-prefixed\n\t// names directly (`pie-stage-change`, `pie-loading-complete`); the\n\t// instrumentation bridge forwards the same names to telemetry. The\n\t// readiness alias mappings (`readiness-change`, `interaction-ready`,\n\t// `ready`) and the `section-controller-ready` mapping were removed\n\t// alongside their DOM-event surfaces.\n\t{\n\t\tsourceEventName: \"pie-stage-change\",\n\t\tinstrumentationEventName: \"pie-section-stage-change\",\n\t},\n\t{\n\t\tsourceEventName: \"pie-loading-complete\",\n\t\tinstrumentationEventName: \"pie-section-loading-complete\",\n\t},\n\t{\n\t\tsourceEventName: \"session-changed\",\n\t\tinstrumentationEventName: \"pie-section-session-changed\",\n\t},\n\t{\n\t\tsourceEventName: \"composition-changed\",\n\t\tinstrumentationEventName: \"pie-section-composition-changed\",\n\t},\n\t{\n\t\tsourceEventName: \"framework-error\",\n\t\tinstrumentationEventName: \"pie-section-framework-error\",\n\t},\n\t{\n\t\tsourceEventName: \"element-preload-retry\",\n\t\tinstrumentationEventName: \"pie-section-element-preload-retry\",\n\t},\n\t{\n\t\tsourceEventName: \"element-preload-error\",\n\t\tinstrumentationEventName: \"pie-section-element-preload-error\",\n\t},\n];\n\nexport const ASSESSMENT_INSTRUMENTATION_EVENT_MAP: InstrumentationEventMapping[] = [\n\t{\n\t\tsourceEventName: \"assessment-controller-ready\",\n\t\tinstrumentationEventName: \"pie-assessment-controller-ready\",\n\t},\n\t{\n\t\tsourceEventName: \"assessment-navigation-requested\",\n\t\tinstrumentationEventName: \"pie-assessment-navigation-requested\",\n\t},\n\t{\n\t\tsourceEventName: \"assessment-route-changed\",\n\t\tinstrumentationEventName: \"pie-assessment-route-changed\",\n\t},\n\t{\n\t\tsourceEventName: \"assessment-session-applied\",\n\t\tinstrumentationEventName: \"pie-assessment-session-applied\",\n\t},\n\t{\n\t\tsourceEventName: \"assessment-session-changed\",\n\t\tinstrumentationEventName: \"pie-assessment-session-changed\",\n\t},\n\t{\n\t\tsourceEventName: \"assessment-progress-changed\",\n\t\tinstrumentationEventName: \"pie-assessment-progress-changed\",\n\t},\n\t{\n\t\tsourceEventName: \"assessment-submission-state-changed\",\n\t\tinstrumentationEventName: \"pie-assessment-submission-state-changed\",\n\t},\n\t{\n\t\tsourceEventName: \"assessment-error\",\n\t\tinstrumentationEventName: \"pie-assessment-error\",\n\t},\n];\n"]}
|
package/dist/pie/logger.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export interface PieLogger {
|
|
|
27
27
|
info: (message: string, ...args: any[]) => void;
|
|
28
28
|
/**
|
|
29
29
|
* Warning-level logging - always shown
|
|
30
|
-
* Use for: recoverable errors,
|
|
30
|
+
* Use for: recoverable errors, removed/unsupported features, potential issues
|
|
31
31
|
*/
|
|
32
32
|
warn: (message: string, ...args: any[]) => void;
|
|
33
33
|
/**
|
package/dist/pie/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/pie/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AA4BH;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAC9B,SAAiB,EACjB,cAA6B;IAE7B,MAAM,MAAM,GAAG,IAAI,SAAS,GAAG,CAAC;IAEhC,OAAO;QACN,mFAAmF;QACnF,KAAK,EAAE,CAAC,OAAe,EAAE,GAAG,IAAW,EAAE,EAAE;YAC1C,IAAI,cAAc,EAAE,EAAE,CAAC;gBACtB,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;YACzC,CAAC;QACF,CAAC;QAED,yDAAyD;QACzD,IAAI,EAAE,CAAC,OAAe,EAAE,GAAG,IAAW,EAAE,EAAE,CACzC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;QAEvC,IAAI,EAAE,CAAC,OAAe,EAAE,GAAG,IAAW,EAAE,EAAE,CACzC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;QAEvC,KAAK,EAAE,CAAC,OAAe,EAAE,GAAG,IAAW,EAAE,EAAE,CAC1C,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;KACxC,CAAC;AACH,CAAC;AAgBD;;GAEG;AACH,MAAM,UAAU,oBAAoB;IACnC,OAAO,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,SAAS,KAAK,IAAI,CAAC;AACnE,CAAC","sourcesContent":["/**\n * PIE Logger Utility\n *\n * Simple, efficient logging for PIE players with debug mode support.\n * Uses browser console methods (debug, info, warn, error) which can be\n * filtered natively in browser dev tools.\n *\n * Usage:\n * ```typescript\n * const logger = createPieLogger('pie-item-player', debug);\n * logger.debug('Detailed debug info', data); // Only shown if debug=true\n * logger.info('Important production info'); // Always shown\n * logger.warn('Warning message'); // Always shown\n * logger.error('Error occurred', error); // Always shown\n * ```\n */\n\nexport interface PieLogger {\n\t/**\n\t * Debug-level logging - only shown when debug mode is enabled\n\t * Use for: detailed initialization steps, data transformations, internal state\n\t */\n\tdebug: (message: string, ...args: any[]) => void;\n\n\t/**\n\t * Info-level logging - always shown\n\t * Use for: successful operations, lifecycle events, important milestones\n\t */\n\tinfo: (message: string, ...args: any[]) => void;\n\n\t/**\n\t * Warning-level logging - always shown\n\t * Use for: recoverable errors,
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/pie/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AA4BH;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAC9B,SAAiB,EACjB,cAA6B;IAE7B,MAAM,MAAM,GAAG,IAAI,SAAS,GAAG,CAAC;IAEhC,OAAO;QACN,mFAAmF;QACnF,KAAK,EAAE,CAAC,OAAe,EAAE,GAAG,IAAW,EAAE,EAAE;YAC1C,IAAI,cAAc,EAAE,EAAE,CAAC;gBACtB,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;YACzC,CAAC;QACF,CAAC;QAED,yDAAyD;QACzD,IAAI,EAAE,CAAC,OAAe,EAAE,GAAG,IAAW,EAAE,EAAE,CACzC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;QAEvC,IAAI,EAAE,CAAC,OAAe,EAAE,GAAG,IAAW,EAAE,EAAE,CACzC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;QAEvC,KAAK,EAAE,CAAC,OAAe,EAAE,GAAG,IAAW,EAAE,EAAE,CAC1C,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;KACxC,CAAC;AACH,CAAC;AAgBD;;GAEG;AACH,MAAM,UAAU,oBAAoB;IACnC,OAAO,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,SAAS,KAAK,IAAI,CAAC;AACnE,CAAC","sourcesContent":["/**\n * PIE Logger Utility\n *\n * Simple, efficient logging for PIE players with debug mode support.\n * Uses browser console methods (debug, info, warn, error) which can be\n * filtered natively in browser dev tools.\n *\n * Usage:\n * ```typescript\n * const logger = createPieLogger('pie-item-player', debug);\n * logger.debug('Detailed debug info', data); // Only shown if debug=true\n * logger.info('Important production info'); // Always shown\n * logger.warn('Warning message'); // Always shown\n * logger.error('Error occurred', error); // Always shown\n * ```\n */\n\nexport interface PieLogger {\n\t/**\n\t * Debug-level logging - only shown when debug mode is enabled\n\t * Use for: detailed initialization steps, data transformations, internal state\n\t */\n\tdebug: (message: string, ...args: any[]) => void;\n\n\t/**\n\t * Info-level logging - always shown\n\t * Use for: successful operations, lifecycle events, important milestones\n\t */\n\tinfo: (message: string, ...args: any[]) => void;\n\n\t/**\n\t * Warning-level logging - always shown\n\t * Use for: recoverable errors, removed/unsupported features, potential issues\n\t */\n\twarn: (message: string, ...args: any[]) => void;\n\n\t/**\n\t * Error-level logging - always shown\n\t * Use for: errors, exceptions, failures\n\t */\n\terror: (message: string, ...args: any[]) => void;\n}\n\n/**\n * Create a PIE logger instance\n *\n * @param namespace - Component name for log prefixing (e.g., 'pie-item-player')\n * @param debugEnabledFn - Function that returns whether debug logs should be shown (checked dynamically on each call)\n * @returns Logger instance with debug, info, warn, error methods\n */\nexport function createPieLogger(\n\tnamespace: string,\n\tdebugEnabledFn: () => boolean,\n): PieLogger {\n\tconst prefix = `[${namespace}]`;\n\n\treturn {\n\t\t// Only debug method checks debugEnabledFn - it's checked dynamically on every call\n\t\tdebug: (message: string, ...args: any[]) => {\n\t\t\tif (debugEnabledFn()) {\n\t\t\t\tconsole.debug(prefix, message, ...args);\n\t\t\t}\n\t\t},\n\n\t\t// info, warn, error always log (not gated by debug flag)\n\t\tinfo: (message: string, ...args: any[]) =>\n\t\t\tconsole.info(prefix, message, ...args),\n\n\t\twarn: (message: string, ...args: any[]) =>\n\t\t\tconsole.warn(prefix, message, ...args),\n\n\t\terror: (message: string, ...args: any[]) =>\n\t\t\tconsole.error(prefix, message, ...args),\n\t};\n}\n\n/**\n * Global debug flag - can be set via window for runtime debugging\n *\n * Usage in browser console:\n * ```javascript\n * window.PIE_DEBUG = true; // Enable debug logging\n * ```\n */\ndeclare global {\n\tinterface Window {\n\t\tPIE_DEBUG?: boolean;\n\t}\n}\n\n/**\n * Check if debug mode is enabled globally\n */\nexport function isGlobalDebugEnabled(): boolean {\n\treturn typeof window !== \"undefined\" && window.PIE_DEBUG === true;\n}\n"]}
|
package/dist/pie/scoring.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export type ScorePieItemOptions = {
|
|
|
15
15
|
models?: PieModel[];
|
|
16
16
|
/**
|
|
17
17
|
* Existing callers keep the historical scorePieItem controller call shape.
|
|
18
|
-
* provideScore() opts into the
|
|
18
|
+
* provideScore() opts into the item-player score result shape explicitly.
|
|
19
19
|
*/
|
|
20
20
|
outcomeArguments?: "session-env" | "model-session-env";
|
|
21
21
|
/**
|
package/dist/pie/scoring.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scoring.js","sourceRoot":"","sources":["../../src/pie/scoring.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAA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AK,CAAC,SAAS,CAAC,CAAC;YACtD,IAAI,UAAU,EAAE,OAAO,EAAE,CAAC;gBACzB,OAAO;oBACN,GAAG,OAAO;oBACV,GAAG,CAAC,MAAM,aAAa,CACtB,UAAU,EACV,KAAK,EACL,OAAO,EACP,UAAU,EACV,gBAAgB,CAChB,CAAC;iBACF,CAAC;YACH,CAAC;iBAAM,CAAC;gBACP,MAAM,CAAC,KAAK,CAAC,2BAA2B,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;YAC5D,CAAC;QACF,CAAC;aAAM,CAAC;YACP,MAAM,CAAC,KAAK,CAAC,qCAAqC,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC;QAC/D,CAAC;QACD,OAAO,SAAS,CAAC;IAClB,CAAC,CAAC,CACF,CAAC;IAEF,MAAM,CAAC,KAAK,CAAC,qBAAqB,EAAE,CAAC,CAAC,CAAC;IACvC,OAAO;QACN,OAAO,EAAE,OAAO,CAAC,qBAAqB;YACrC,CAAC,CAAC,CAAC;YACH,CAAC,CAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAuB;KAC3C,CAAC;AACH,CAAC","sourcesContent":["/**\n * PIE Scoring Module\n *\n * Scoring and outcome calculation for PIE elements.\n */\n\nimport type {\n\tConfigEntity,\n\tEnv,\n\tOutcomeResponse,\n\tPieController,\n\tPieModel,\n} from \"../types/index.js\";\nimport { createPieLogger, isGlobalDebugEnabled } from \"./logger.js\";\nimport { pieRegistry } from \"./registry.js\";\nimport type { PieElement } from \"./types.js\";\nimport { BundleType } from \"./types.js\";\nimport { findOrAddSession } from \"./utils.js\";\n\n// Create module-level logger (respects global debug flag - pass function for dynamic checking)\nconst logger = createPieLogger(\"pie-scoring\", () => isGlobalDebugEnabled());\n\n/**\n * Find the controller for a PIE element\n */\nexport const findPieController = (\n\telementName: string,\n): PieController | undefined => {\n\tconst registry = pieRegistry();\n\n\tlogger.debug(\n\t\t`[findPieController] Looking for controller for: ${elementName}`,\n\t);\n\tlogger.debug(\n\t\t`[findPieController] Registry has entries for:`,\n\t\tObject.keys(registry),\n\t);\n\n\tconst entry = registry[elementName];\n\tif (!entry) {\n\t\tlogger.error(\n\t\t\t`[findPieController] ❌ No registry entry found for element: ${elementName}`,\n\t\t);\n\t\tlogger.error(\n\t\t\t`[findPieController] Available element names:`,\n\t\t\tObject.keys(registry),\n\t\t);\n\t\tlogger.error(`[findPieController] Full registry:`, registry);\n\t\treturn undefined;\n\t}\n\n\tlogger.debug(`[findPieController] Found registry entry for ${elementName}:`, {\n\t\tpackage: entry.package,\n\t\ttagName: entry.tagName,\n\t\thasController: !!entry.controller,\n\t\tcontrollerKeys: entry.controller ? Object.keys(entry.controller) : [],\n\t\tbundleType: entry.bundleType,\n\t});\n\n\tconst controller = entry.controller;\n\tif (!controller) {\n\t\t// Check if missing controller is expected based on bundle type\n\t\tif (entry.bundleType === BundleType.clientPlayer) {\n\t\t\t// client-player.js MUST have controllers\n\t\t\tlogger.error(\n\t\t\t\t`[findPieController] ❌ CRITICAL: Registry entry exists for ${elementName} but controller is missing!`,\n\t\t\t);\n\t\t\tlogger.error(\n\t\t\t\t`[findPieController] Bundle type: ${entry.bundleType} (controllers required)`,\n\t\t\t);\n\t\t\tlogger.error(`[findPieController] Entry:`, entry);\n\t\t\tthrow new Error(\n\t\t\t\t`No controller found for ${elementName}. client-player.js bundles MUST include controllers. Check bundle loading and registration.`,\n\t\t\t);\n\t\t} else {\n\t\t\t// player.js doesn't have controllers - this is expected\n\t\t\tlogger.debug(\n\t\t\t\t`[findPieController] ℹ️ No controller for ${elementName} - using server-processed models (player.js bundle)`,\n\t\t\t);\n\t\t}\n\t} else {\n\t\tlogger.debug(\n\t\t\t`[findPieController] ✅ Controller found for ${elementName} with functions:`,\n\t\t\tObject.keys(controller),\n\t\t);\n\t}\n\n\treturn controller;\n};\n\nexport type ScorePieItemOptions = {\n\t/** Scope element lookup to a specific player/root. Defaults to document for existing callers. */\n\tcontainer?: Pick<ParentNode, \"querySelector\">;\n\tenv?: Partial<Env>;\n\tmodels?: PieModel[];\n\t/**\n\t * Existing callers keep the historical scorePieItem controller call shape.\n\t * provideScore() opts into the legacy <pie-player> shape explicitly.\n\t */\n\toutcomeArguments?: \"session-env\" | \"model-session-env\";\n\t/**\n\t * Preserve one result slot per model, including undefined for missing element/controller.\n\t * Existing scorePieItem callers keep the filtered result shape by default.\n\t */\n\tincludeMissingResults?: boolean;\n};\n\nconst escapeAttributeSelectorValue = (value: string): string =>\n\tvalue\n\t\t.replace(/\\\\/g, \"\\\\\\\\\")\n\t\t.replace(/\"/g, '\\\\\"')\n\t\t.replace(/\\n/g, \"\\\\a \")\n\t\t.replace(/\\r/g, \"\\\\d \");\n\nconst findRenderedPieElement = (\n\troot: Pick<ParentNode, \"querySelector\">,\n\tmodelId: string,\n): PieElement | null => {\n\tconst escapedId = escapeAttributeSelectorValue(modelId);\n\treturn (root.querySelector(`[id=\"${escapedId}\"]`) ||\n\t\troot.querySelector(`[pie-id=\"${escapedId}\"]`)) as PieElement | null;\n};\n\nconst invokeOutcome = async (\n\tcontroller: PieController,\n\tmodel: PieModel,\n\tsession: any,\n\tenv: Partial<Env>,\n\targumentShape: \"session-env\" | \"model-session-env\",\n): Promise<OutcomeResponse> => {\n\tif (argumentShape === \"model-session-env\") {\n\t\tconst outcome = controller.outcome as unknown as (\n\t\t\tmodel: PieModel,\n\t\t\tsession: any,\n\t\t\tenv: Partial<Env>,\n\t\t) => Promise<OutcomeResponse>;\n\t\treturn outcome.call(controller, model, session, env);\n\t}\n\tconst outcome = controller.outcome as unknown as (\n\t\tsession: any,\n\t\tenv: Partial<Env>,\n\t) => Promise<OutcomeResponse>;\n\treturn outcome.call(controller, session, env);\n};\n\nexport function scorePieItem(\n\tconfig: ConfigEntity,\n\tsessionData: any[],\n\toptions: ScorePieItemOptions & { includeMissingResults: true },\n): Promise<{ results: Array<OutcomeResponse | undefined> }>;\nexport function scorePieItem(\n\tconfig: ConfigEntity,\n\tsessionData: any[],\n\toptions?: ScorePieItemOptions,\n): Promise<{ results: OutcomeResponse[] }>;\n/**\n * Score a PIE item by calling outcome on all PIE elements\n */\nexport async function scorePieItem(\n\tconfig: ConfigEntity,\n\tsessionData: any[],\n\toptions: ScorePieItemOptions = {},\n): Promise<{ results: Array<OutcomeResponse | undefined> }> {\n\tconst root = options.container ?? document;\n\tconst models = options.models ?? config.models ?? [];\n\tconst outcomeArguments = options.outcomeArguments ?? \"session-env\";\n\tconst scoringEnv: Partial<Env> = {\n\t\t...options.env,\n\t\tmode: \"evaluate\",\n\t\tpartialScoring: options.env?.partialScoring,\n\t};\n\tconst r = await Promise.all(\n\t\tmodels.map(async (model) => {\n\t\t\tconst pieEl = findRenderedPieElement(root, model.id);\n\t\t\tlogger.debug(\"found pieEl %O for model id %s\", pieEl, model.id);\n\t\t\tconst session = findOrAddSession(sessionData, model.id, model.element);\n\t\t\tif (pieEl) {\n\t\t\t\tconst controller = findPieController(pieEl.localName);\n\t\t\t\tif (controller?.outcome) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...session,\n\t\t\t\t\t\t...(await invokeOutcome(\n\t\t\t\t\t\t\tcontroller,\n\t\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t\tsession,\n\t\t\t\t\t\t\tscoringEnv,\n\t\t\t\t\t\t\toutcomeArguments,\n\t\t\t\t\t\t)),\n\t\t\t\t\t};\n\t\t\t\t} else {\n\t\t\t\t\tlogger.debug(\"ignore %s (no controller)\", pieEl.localName);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tlogger.debug(\"ignore %s (no element found for %s)\", model.id);\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}),\n\t);\n\n\tlogger.debug(\"scorePieItem result\", r);\n\treturn {\n\t\tresults: options.includeMissingResults\n\t\t\t? r\n\t\t\t: (r.filter(Boolean) as OutcomeResponse[]),\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"scoring.js","sourceRoot":"","sources":["../../src/pie/scoring.ts"],"names":[],"mappings":"AAAA;;;;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E,KAAK,CAAC,EAAE,CAAC,CAAC;QAChE,MAAM,OAAO,GAAG,gBAAgB,CAAC,WAAW,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QACvE,IAAI,KAAK,EAAE,CAAC;YACX,MAAM,UAAU,GAAG,iBAAiB,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;YACtD,IAAI,UAAU,EAAE,OAAO,EAAE,CAAC;gBACzB,OAAO;oBACN,GAAG,OAAO;oBACV,GAAG,CAAC,MAAM,aAAa,CACtB,UAAU,EACV,KAAK,EACL,OAAO,EACP,UAAU,EACV,gBAAgB,CAChB,CAAC;iBACF,CAAC;YACH,CAAC;iBAAM,CAAC;gBACP,MAAM,CAAC,KAAK,CAAC,2BAA2B,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;YAC5D,CAAC;QACF,CAAC;aAAM,CAAC;YACP,MAAM,CAAC,KAAK,CAAC,qCAAqC,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC;QAC/D,CAAC;QACD,OAAO,SAAS,CAAC;IAClB,CAAC,CAAC,CACF,CAAC;IAEF,MAAM,CAAC,KAAK,CAAC,qBAAqB,EAAE,CAAC,CAAC,CAAC;IACvC,OAAO;QACN,OAAO,EAAE,OAAO,CAAC,qBAAqB;YACrC,CAAC,CAAC,CAAC;YACH,CAAC,CAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAuB;KAC3C,CAAC;AACH,CAAC","sourcesContent":["/**\n * PIE Scoring Module\n *\n * Scoring and outcome calculation for PIE elements.\n */\n\nimport type {\n\tConfigEntity,\n\tEnv,\n\tOutcomeResponse,\n\tPieController,\n\tPieModel,\n} from \"../types/index.js\";\nimport { createPieLogger, isGlobalDebugEnabled } from \"./logger.js\";\nimport { pieRegistry } from \"./registry.js\";\nimport type { PieElement } from \"./types.js\";\nimport { BundleType } from \"./types.js\";\nimport { findOrAddSession } from \"./utils.js\";\n\n// Create module-level logger (respects global debug flag - pass function for dynamic checking)\nconst logger = createPieLogger(\"pie-scoring\", () => isGlobalDebugEnabled());\n\n/**\n * Find the controller for a PIE element\n */\nexport const findPieController = (\n\telementName: string,\n): PieController | undefined => {\n\tconst registry = pieRegistry();\n\n\tlogger.debug(\n\t\t`[findPieController] Looking for controller for: ${elementName}`,\n\t);\n\tlogger.debug(\n\t\t`[findPieController] Registry has entries for:`,\n\t\tObject.keys(registry),\n\t);\n\n\tconst entry = registry[elementName];\n\tif (!entry) {\n\t\tlogger.error(\n\t\t\t`[findPieController] ❌ No registry entry found for element: ${elementName}`,\n\t\t);\n\t\tlogger.error(\n\t\t\t`[findPieController] Available element names:`,\n\t\t\tObject.keys(registry),\n\t\t);\n\t\tlogger.error(`[findPieController] Full registry:`, registry);\n\t\treturn undefined;\n\t}\n\n\tlogger.debug(`[findPieController] Found registry entry for ${elementName}:`, {\n\t\tpackage: entry.package,\n\t\ttagName: entry.tagName,\n\t\thasController: !!entry.controller,\n\t\tcontrollerKeys: entry.controller ? Object.keys(entry.controller) : [],\n\t\tbundleType: entry.bundleType,\n\t});\n\n\tconst controller = entry.controller;\n\tif (!controller) {\n\t\t// Check if missing controller is expected based on bundle type\n\t\tif (entry.bundleType === BundleType.clientPlayer) {\n\t\t\t// client-player.js MUST have controllers\n\t\t\tlogger.error(\n\t\t\t\t`[findPieController] ❌ CRITICAL: Registry entry exists for ${elementName} but controller is missing!`,\n\t\t\t);\n\t\t\tlogger.error(\n\t\t\t\t`[findPieController] Bundle type: ${entry.bundleType} (controllers required)`,\n\t\t\t);\n\t\t\tlogger.error(`[findPieController] Entry:`, entry);\n\t\t\tthrow new Error(\n\t\t\t\t`No controller found for ${elementName}. client-player.js bundles MUST include controllers. Check bundle loading and registration.`,\n\t\t\t);\n\t\t} else {\n\t\t\t// player.js doesn't have controllers - this is expected\n\t\t\tlogger.debug(\n\t\t\t\t`[findPieController] ℹ️ No controller for ${elementName} - using server-processed models (player.js bundle)`,\n\t\t\t);\n\t\t}\n\t} else {\n\t\tlogger.debug(\n\t\t\t`[findPieController] ✅ Controller found for ${elementName} with functions:`,\n\t\t\tObject.keys(controller),\n\t\t);\n\t}\n\n\treturn controller;\n};\n\nexport type ScorePieItemOptions = {\n\t/** Scope element lookup to a specific player/root. Defaults to document for existing callers. */\n\tcontainer?: Pick<ParentNode, \"querySelector\">;\n\tenv?: Partial<Env>;\n\tmodels?: PieModel[];\n\t/**\n\t * Existing callers keep the historical scorePieItem controller call shape.\n\t * provideScore() opts into the item-player score result shape explicitly.\n\t */\n\toutcomeArguments?: \"session-env\" | \"model-session-env\";\n\t/**\n\t * Preserve one result slot per model, including undefined for missing element/controller.\n\t * Existing scorePieItem callers keep the filtered result shape by default.\n\t */\n\tincludeMissingResults?: boolean;\n};\n\nconst escapeAttributeSelectorValue = (value: string): string =>\n\tvalue\n\t\t.replace(/\\\\/g, \"\\\\\\\\\")\n\t\t.replace(/\"/g, '\\\\\"')\n\t\t.replace(/\\n/g, \"\\\\a \")\n\t\t.replace(/\\r/g, \"\\\\d \");\n\nconst findRenderedPieElement = (\n\troot: Pick<ParentNode, \"querySelector\">,\n\tmodelId: string,\n): PieElement | null => {\n\tconst escapedId = escapeAttributeSelectorValue(modelId);\n\treturn (root.querySelector(`[id=\"${escapedId}\"]`) ||\n\t\troot.querySelector(`[pie-id=\"${escapedId}\"]`)) as PieElement | null;\n};\n\nconst invokeOutcome = async (\n\tcontroller: PieController,\n\tmodel: PieModel,\n\tsession: any,\n\tenv: Partial<Env>,\n\targumentShape: \"session-env\" | \"model-session-env\",\n): Promise<OutcomeResponse> => {\n\tif (argumentShape === \"model-session-env\") {\n\t\tconst outcome = controller.outcome as unknown as (\n\t\t\tmodel: PieModel,\n\t\t\tsession: any,\n\t\t\tenv: Partial<Env>,\n\t\t) => Promise<OutcomeResponse>;\n\t\treturn outcome.call(controller, model, session, env);\n\t}\n\tconst outcome = controller.outcome as unknown as (\n\t\tsession: any,\n\t\tenv: Partial<Env>,\n\t) => Promise<OutcomeResponse>;\n\treturn outcome.call(controller, session, env);\n};\n\nexport function scorePieItem(\n\tconfig: ConfigEntity,\n\tsessionData: any[],\n\toptions: ScorePieItemOptions & { includeMissingResults: true },\n): Promise<{ results: Array<OutcomeResponse | undefined> }>;\nexport function scorePieItem(\n\tconfig: ConfigEntity,\n\tsessionData: any[],\n\toptions?: ScorePieItemOptions,\n): Promise<{ results: OutcomeResponse[] }>;\n/**\n * Score a PIE item by calling outcome on all PIE elements\n */\nexport async function scorePieItem(\n\tconfig: ConfigEntity,\n\tsessionData: any[],\n\toptions: ScorePieItemOptions = {},\n): Promise<{ results: Array<OutcomeResponse | undefined> }> {\n\tconst root = options.container ?? document;\n\tconst models = options.models ?? config.models ?? [];\n\tconst outcomeArguments = options.outcomeArguments ?? \"session-env\";\n\tconst scoringEnv: Partial<Env> = {\n\t\t...options.env,\n\t\tmode: \"evaluate\",\n\t\tpartialScoring: options.env?.partialScoring,\n\t};\n\tconst r = await Promise.all(\n\t\tmodels.map(async (model) => {\n\t\t\tconst pieEl = findRenderedPieElement(root, model.id);\n\t\t\tlogger.debug(\"found pieEl %O for model id %s\", pieEl, model.id);\n\t\t\tconst session = findOrAddSession(sessionData, model.id, model.element);\n\t\t\tif (pieEl) {\n\t\t\t\tconst controller = findPieController(pieEl.localName);\n\t\t\t\tif (controller?.outcome) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...session,\n\t\t\t\t\t\t...(await invokeOutcome(\n\t\t\t\t\t\t\tcontroller,\n\t\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t\tsession,\n\t\t\t\t\t\t\tscoringEnv,\n\t\t\t\t\t\t\toutcomeArguments,\n\t\t\t\t\t\t)),\n\t\t\t\t\t};\n\t\t\t\t} else {\n\t\t\t\t\tlogger.debug(\"ignore %s (no controller)\", pieEl.localName);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tlogger.debug(\"ignore %s (no element found for %s)\", model.id);\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}),\n\t);\n\n\tlogger.debug(\"scorePieItem result\", r);\n\treturn {\n\t\tresults: options.includeMissingResults\n\t\t\t? r\n\t\t\t: (r.filter(Boolean) as OutcomeResponse[]),\n\t};\n}\n"]}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -112,6 +112,11 @@ export interface ConfigElements {
|
|
|
112
112
|
export interface PieModel {
|
|
113
113
|
id: string;
|
|
114
114
|
element: string;
|
|
115
|
+
/**
|
|
116
|
+
* QTI/APIP-style accessibility catalogs owned by this model's renderable fields
|
|
117
|
+
* (prompt, choices, feedback, rationale, etc.).
|
|
118
|
+
*/
|
|
119
|
+
accessibilityCatalogs?: AccessibilityCatalog[];
|
|
115
120
|
[key: string]: any;
|
|
116
121
|
}
|
|
117
122
|
export interface ConfigEntity {
|
|
@@ -132,6 +137,8 @@ export interface ConfigContainerEntity extends BaseEntity {
|
|
|
132
137
|
}
|
|
133
138
|
export interface PassageEntity extends VersionEntity, ConfigContainerEntity, SearchMetaDataEntity {
|
|
134
139
|
name: string;
|
|
140
|
+
/** QTI/APIP-style accessibility catalogs owned by this passage content. */
|
|
141
|
+
accessibilityCatalogs?: AccessibilityCatalog[];
|
|
135
142
|
retired?: boolean;
|
|
136
143
|
published?: boolean;
|
|
137
144
|
highlights?: Record<string, string[]>;
|
|
@@ -139,6 +146,8 @@ export interface PassageEntity extends VersionEntity, ConfigContainerEntity, Sea
|
|
|
139
146
|
export interface ItemEntity extends VersionEntity, ConfigContainerEntity, SearchMetaDataEntity {
|
|
140
147
|
name?: string;
|
|
141
148
|
passage?: string | PassageEntity;
|
|
149
|
+
/** QTI/APIP-style accessibility catalogs owned by the item root. */
|
|
150
|
+
accessibilityCatalogs?: AccessibilityCatalog[];
|
|
142
151
|
retired?: boolean;
|
|
143
152
|
published?: boolean;
|
|
144
153
|
configuration?: any;
|
|
@@ -277,22 +286,6 @@ export interface PersonalNeedsProfile {
|
|
|
277
286
|
* NOTE: Not currently used. We embed PassageEntity directly in RubricBlock instead.
|
|
278
287
|
* Kept for potential future use if we need to support external stimulus references.
|
|
279
288
|
*/
|
|
280
|
-
/**
|
|
281
|
-
* Reference to question and sorting info within a section.
|
|
282
|
-
*/
|
|
283
|
-
export interface SectionQuestionRef {
|
|
284
|
-
questionId: string;
|
|
285
|
-
sort?: string;
|
|
286
|
-
}
|
|
287
|
-
/**
|
|
288
|
-
* Questions can optionally be grouped in sections (legacy).
|
|
289
|
-
*/
|
|
290
|
-
export interface LegacyAssessmentSection extends SearchMetaDataEntity, SettingsMetaDataEntity {
|
|
291
|
-
id?: string;
|
|
292
|
-
title?: string;
|
|
293
|
-
sort?: string;
|
|
294
|
-
questions: SectionQuestionRef[];
|
|
295
|
-
}
|
|
296
289
|
export interface AssessmentEntity extends BaseEntity, SearchMetaDataEntity {
|
|
297
290
|
name?: string;
|
|
298
291
|
title?: string;
|
|
@@ -308,10 +301,6 @@ export interface AssessmentEntity extends BaseEntity, SearchMetaDataEntity {
|
|
|
308
301
|
accessibilityCatalogs?: AccessibilityCatalog[];
|
|
309
302
|
/** QTI 3.0: Personal Needs Profile (PNP 3.0) */
|
|
310
303
|
personalNeedsProfile?: PersonalNeedsProfile;
|
|
311
|
-
/** Legacy: Flat questions array */
|
|
312
|
-
questions?: QuestionEntity[];
|
|
313
|
-
/** Legacy: Simple sections */
|
|
314
|
-
sections?: LegacyAssessmentSection[];
|
|
315
304
|
/**
|
|
316
305
|
* QTI 3.0: testParts structure (authoritative for QTI format).
|
|
317
306
|
*/
|
|
@@ -382,6 +371,21 @@ export interface AssessmentSettings {
|
|
|
382
371
|
* @default 1.0
|
|
383
372
|
*/
|
|
384
373
|
pitch?: number;
|
|
374
|
+
/**
|
|
375
|
+
* Speech Rule Engine options for generated MathML speech.
|
|
376
|
+
*
|
|
377
|
+
* `style` is passed to SRE directly; ClearSpeak combines multiple
|
|
378
|
+
* preferences with ":" (for example,
|
|
379
|
+
* "ImpliedTimes_MoreImpliedTimes:Paren_Silent").
|
|
380
|
+
*
|
|
381
|
+
* Mirrors assessment-toolkit's SREMathSpeechOptions without importing
|
|
382
|
+
* toolkit service types into the shared content contract package.
|
|
383
|
+
*/
|
|
384
|
+
mathSpeech?: {
|
|
385
|
+
domain?: string;
|
|
386
|
+
style?: string;
|
|
387
|
+
engineOptions?: Record<string, unknown>;
|
|
388
|
+
};
|
|
385
389
|
/**
|
|
386
390
|
* Provider-specific options (extensions)
|
|
387
391
|
*
|
|
@@ -395,7 +399,7 @@ export interface AssessmentSettings {
|
|
|
395
399
|
};
|
|
396
400
|
/** Theme configuration (not in PNP) */
|
|
397
401
|
themeConfig?: {
|
|
398
|
-
|
|
402
|
+
scheme?: "default" | "high-contrast" | "dark";
|
|
399
403
|
fontSize?: number;
|
|
400
404
|
fontFamily?: string;
|
|
401
405
|
lineHeight?: number;
|
|
@@ -448,7 +452,7 @@ export interface SanctionedVersionChangeEntity extends BaseEntity {
|
|
|
448
452
|
summary?: string;
|
|
449
453
|
jobId: string;
|
|
450
454
|
}
|
|
451
|
-
export type PlayerMode = "gather" | "view" | "evaluate" | "
|
|
455
|
+
export type PlayerMode = "gather" | "view" | "evaluate" | "author";
|
|
452
456
|
export type PlayerRole = "student" | "instructor";
|
|
453
457
|
export interface Env {
|
|
454
458
|
mode: PlayerMode;
|
package/dist/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AA+CA,MAAM,CAAN,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC3B,iCAAa,CAAA;IACb,mCAAe,CAAA;IACf,mCAAe,CAAA;IACf,iDAA6B,CAAA;AAC9B,CAAC,EALW,gBAAgB,KAAhB,gBAAgB,QAK3B;AAED,MAAM,CAAN,IAAY,SAGX;AAHD,WAAY,SAAS;IACpB,0BAAa,CAAA;IACb,8BAAiB,CAAA;AAClB,CAAC,EAHW,SAAS,KAAT,SAAS,QAGpB;AAyBD,MAAM,CAAN,IAAY,QAIX;AAJD,WAAY,QAAQ;IACnB,6B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a,CAAC,MAAc;IAC3C,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IACvB,MAAM,IAAI,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAClE,IAAI,YAAY,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QAC/C,MAAM,UAAU,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,IAAI,CACzE,GAAG,CACH,CAAC;QACF,OAAO,GAAG,IAAI,IAAI,UAAU,EAAE,CAAC;IAChC,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC;AAaD,MAAM,OAAO,mBAAoB,SAAQ,WAAiC;IAI/D;IACA;IAJV,MAAM,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAEhC,YACU,SAAiB,EACjB,QAAiB;QAE1B,KAAK,CAAC,mBAAmB,CAAC,IAAI,EAAE;YAC/B,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,IAAI;YACd,MAAM,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE;SACxB,CAAC,CAAC;QAPD,cAAS,GAAT,SAAS,CAAQ;QACjB,aAAQ,GAAR,QAAQ,CAAS;IAO3B,CAAC;;AA2FF,wFAAwF;AACxF,MAAM,CAAN,IAAY,YAKX;AALD,WAAY,YAAY;IACvB,+CAAQ,CAAA;IACR,qDAAW,CAAA;IACX,iDAAS,CAAA;IACT,uDAAY,CAAA;AACb,CAAC,EALW,YAAY,KAAZ,YAAY,QAKvB","sourcesContent":["/**\n * This contains copies of the data types we use in PIEOneer. These types, unlike\n * the ones in the datastore package, should not have any dependencies, and might in some\n * cases be more shallow than their originals. The main reason for these is that they should\n * be able to be used in front-end code (as well as the PIEOneer backend code).\n *\n * INCLUDING REFERENCES TO THE DATASTORE PACKAGE INSTEAD WILL MAKE PIEONEER THROW 500\n * EVERYWHERE WITHOUT ANY FURTHER EXPLANATION\n */\nexport interface BaseEntity {\n\tid?: string;\n\tcreatedAt?: Date;\n\tupdatedAt?: Date;\n}\n\nexport interface CollectionEntity extends BaseEntity {\n\tname: string;\n\torganization: string | OrganizationEntity;\n}\n\nexport interface OrganizationEntity extends BaseEntity {\n\tname: string;\n\tdefaultCollection?: string | CollectionEntity;\n}\n\nexport interface UserEntity extends BaseEntity {\n\temail: string;\n\tname?: string;\n}\n\nexport interface ClientEntity extends BaseEntity {\n\tname: string;\n\tsecret: string;\n\tuser: string | UserEntity;\n\torganization: string | OrganizationEntity;\n}\n\nexport interface AssignmentEntity extends BaseEntity {\n\torganization: string | OrganizationEntity;\n}\n\nexport interface SessionEntity extends BaseEntity {\n\titem: ItemEntity;\n\tassignment?: string | AssignmentEntity; // TODO: Remove after data is migrated\n\torganization?: string | OrganizationEntity;\n}\n\nexport enum SessionEventType {\n\tSAVE = \"save\",\n\tMODEL = \"model\",\n\tSCORE = \"score\",\n\tMANUAL_SCORE = \"manual-score\",\n}\n\nexport enum ScoreType {\n\tAUTO = \"auto\",\n\tMANUAL = \"manual\",\n}\n\nexport interface SessionScore {\n\tpoints?: number;\n\tmax?: number;\n\ttype?: ScoreType;\n\tpartialScoring?: boolean;\n\tmessage?: string;\n\terrors?: string[];\n}\n\nexport interface SessionAutoScore extends SessionScore {\n\telements?: any[];\n\textraProps?: any;\n}\n\nexport interface SessionManualScore extends SessionScore {}\n\nexport interface SessionEventEntity extends BaseEntity {\n\tsession: string | SessionEntity;\n\ttype?: SessionEventType;\n\tsaveEventId?: string;\n\tscore?: number;\n}\n\nexport enum ModeType {\n\tGATHER = \"gather\",\n\tVIEW = \"view\",\n\tEVALUATE = \"evaluate\",\n}\n\nexport interface FlatSession {\n\tid: string;\n\tassignment: AssignmentEntity;\n\titem: string;\n\tdata: any[];\n\tcreatedAt: Date;\n\tupdatedAt: Date;\n\tmode: ModeType;\n\tautoScore: SessionAutoScore;\n\tmanualScore: SessionManualScore;\n\tevents: SessionEventEntity[]; // raw events;\n}\n\nexport interface SemVerPrerelease {\n\ttag: string;\n\tversion: number;\n}\n\nexport interface SemVer {\n\tmajor: number;\n\tminor: number;\n\tpatch: number;\n\tprerelease?: SemVerPrerelease;\n}\n\nexport interface VersionEntity extends BaseEntity {\n\tbaseId: string;\n\tsignature?: string;\n\tversion: SemVer;\n}\n\nexport interface SearchMetaData {\n\t[key: string]: any;\n}\n\nexport interface SearchMetaDataEntity extends BaseEntity {\n\tsearchMetaData?: SearchMetaData;\n}\n\nexport interface ConfigElements {\n\t[key: string]: string;\n}\n\nexport interface PieModel {\n\tid: string;\n\telement: string;\n\n\t[key: string]: any;\n}\n\nexport interface ConfigEntity {\n\tid?: string;\n\tmarkup: string;\n\telements: ConfigElements;\n\tmodels: PieModel[];\n\tconfiguration?: Record<string, any>; // NEW: Configure settings for authoring mode\n\n\t/**\n\t * QTI 3.0: Extracted accessibility catalogs from embedded SSML.\n\t * Automatically generated by SSMLExtractor when <speak> tags are found in content.\n\t */\n\textractedCatalogs?: AccessibilityCatalog[];\n\n\t[key: string]: any;\n}\n\nexport interface ConfigContainerEntity extends BaseEntity {\n\tconfig: ConfigEntity;\n}\n\nexport interface PassageEntity\n\textends VersionEntity,\n\t\tConfigContainerEntity,\n\t\tSearchMetaDataEntity {\n\tname: string;\n\tretired?: boolean;\n\tpublished?: boolean;\n\t// Search result highlights from OpenSearch (keyed by field name)\n\thighlights?: Record<string, string[]>;\n}\n\nexport interface ItemEntity\n\textends VersionEntity,\n\t\tConfigContainerEntity,\n\t\tSearchMetaDataEntity {\n\tname?: string;\n\tpassage?: string | PassageEntity;\n\tretired?: boolean;\n\tpublished?: boolean;\n\tconfiguration?: any;\n\t// Search result highlights from OpenSearch (keyed by field name)\n\thighlights?: Record<string, string[]>;\n}\n\nexport interface AssignmentSessionData {\n\tassignment: AssignmentEntity;\n\tsessions: FlatSession[];\n\titems: ItemEntity[];\n\terror?: string;\n}\n\n/**\n * Metadata specifically for interpretation by clients, typically containing\n * options that are relevant for the user interface. This is not indexed for search.\n */\nexport interface SettingsMetaData {\n\t[key: string]: any;\n}\n\n/**\n * Objects that contain metadata in the settings property, which is NOT indexed for search\n * but typically only relevant for particular client cases.\n */\nexport interface SettingsMetaDataEntity {\n\tsettings?: SettingsMetaData;\n}\n\n/**\n * A reference to an item with optionally a title, settings and metadata.\n */\nexport interface QuestionEntity\n\textends SearchMetaDataEntity,\n\t\tSettingsMetaDataEntity {\n\tid?: string;\n\ttitle?: string;\n\titemVId: string;\n\titem?: ItemEntity;\n}\n\n// ============================================================================\n// QTI-aligned assessment model (QTI 2.x compatible shape)\n// ============================================================================\n\nexport type RubricBlockView =\n\t| \"author\"\n\t| \"candidate\"\n\t| \"proctor\"\n\t| \"scorer\"\n\t| \"testConstructor\"\n\t| \"tutor\";\n\nexport interface RubricBlock {\n\tidentifier?: string;\n\t/** QTI spec: space-separated list of roles; stored as an array */\n\tview: RubricBlockView[];\n\tclass?: \"stimulus\" | \"instructions\" | \"rubric\";\n\n\t/**\n\t * Versioned ID reference to the passage (when class=\"stimulus\").\n\t */\n\tpassageVId?: string;\n\n\t/**\n\t * Embedded passage entity (PIE-native approach).\n\t * The passage is rendered using the same ItemPlayer infrastructure as items.\n\t * Contains a PIE config with markup, elements, and models.\n\t */\n\tpassage?: PassageEntity;\n\n\t/**\n\t * Simple HTML content string (for basic use cases).\n\t * Alternative to the passage entity approach.\n\t */\n\tcontent?: string;\n}\n\n/**\n * QTI-aligned assessment item reference (maps to qti-assessment-item-ref).\n * References an item within a section. The item property contains the resolved\n * ItemEntity with its PIE config.\n */\nexport interface AssessmentItemRef extends SearchMetaDataEntity {\n\tid?: string;\n\tidentifier: string;\n\ttitle?: string;\n\trequired?: boolean;\n\n\t/**\n\t * Item virtual ID - stable identifier for the item across versions\n\t */\n\titemVId?: string;\n\n\t/**\n\t * Resolved item entity with PIE config.\n\t * This is populated by the client before passing to the player.\n\t */\n\titem?: ItemEntity;\n\n\t/** Item-level settings for tool requirements and customization */\n\tsettings?: ItemSettings;\n}\n\nexport interface AssessmentSection\n\textends SearchMetaDataEntity,\n\t\tSettingsMetaDataEntity {\n\tid?: string;\n\tidentifier: string;\n\ttitle?: string;\n\tvisible?: boolean;\n\trequired?: boolean;\n\t/**\n\t * QTI 3 pagination hint (`qti-assessment-section@keep-together`).\n\t *\n\t * Indicates that the delivery system SHOULD render this section's items\n\t * together rather than splitting them across pages. This is strictly a\n\t * rendering/layout hint — it does NOT disable item-level navigation,\n\t * current-item tracking, or `item-selected` events in the section player.\n\t * Paginated and keep-together sections both support Next/Back,\n\t * `getCurrentItem()`, and `item-selected` events.\n\t */\n\tkeepTogether?: boolean;\n\n\tsections?: AssessmentSection[];\n\n\t/**\n\t * QTI 3.0: Assessment item references (items in this section).\n\t * Maps to qti-assessment-item-ref in QTI 3.0 XML.\n\t */\n\tassessmentItemRefs?: AssessmentItemRef[];\n\n\t// Shared context (passages/instructions/rubrics) for this section\n\trubricBlocks?: RubricBlock[];\n\n\tsort?: string;\n}\n\nexport interface TestPart {\n\tid?: string;\n\tidentifier: string;\n\tnavigationMode: \"linear\" | \"nonlinear\";\n\tsubmissionMode: \"individual\" | \"simultaneous\";\n\tsections: AssessmentSection[];\n}\n\n// ============================================================================\n// QTI 3.0 Types\n// ============================================================================\n\nexport interface ContextDeclaration {\n\tidentifier: string;\n\tbaseType:\n\t\t| \"boolean\"\n\t\t| \"integer\"\n\t\t| \"float\"\n\t\t| \"string\"\n\t\t| \"identifier\"\n\t\t| \"point\"\n\t\t| \"pair\"\n\t\t| \"directedPair\"\n\t\t| \"duration\"\n\t\t| \"file\"\n\t\t| \"uri\";\n\tcardinality: \"single\" | \"multiple\" | \"ordered\" | \"record\";\n\tdefaultValue?: any;\n}\n\nexport interface CatalogCard {\n\tcatalog: string; // 'spoken', 'sign-language', 'braille', etc.\n\tlanguage?: string;\n\tcontent: string;\n}\n\nexport interface AccessibilityCatalog {\n\tidentifier: string;\n\tcards: CatalogCard[];\n}\n\nexport interface PersonalNeedsProfile {\n\tsupports: string[];\n\tprohibitedSupports?: string[];\n\tactivateAtInit?: string[];\n}\n\n/**\n * QTI 3.0: Reference to a shared stimulus (passage).\n * Maps to qti-assessment-stimulus-ref element.\n *\n * NOTE: Not currently used. We embed PassageEntity directly in RubricBlock instead.\n * Kept for potential future use if we need to support external stimulus references.\n */\n/*\nexport interface StimulusRef {\n\tidentifier: string;\n\thref: string;\n}\n*/\n\n/**\n * Reference to question and sorting info within a section.\n */\nexport interface SectionQuestionRef {\n\tquestionId: string;\n\tsort?: string;\n}\n\n/**\n * Questions can optionally be grouped in sections (legacy).\n */\nexport interface LegacyAssessmentSection\n\textends SearchMetaDataEntity,\n\t\tSettingsMetaDataEntity {\n\tid?: string;\n\ttitle?: string;\n\tsort?: string;\n\tquestions: SectionQuestionRef[];\n}\n\nexport interface AssessmentEntity extends BaseEntity, SearchMetaDataEntity {\n\tname?: string;\n\ttitle?: string;\n\tidentifier?: string;\n\tdescription?: string;\n\n\t/** Enhanced structured settings for assessment configuration */\n\tsettings?: AssessmentSettings;\n\n\t/** QTI version - '3.0' for QTI 3.0 format */\n\tqtiVersion?: \"3.0\";\n\n\t/** QTI 3.0: Context declarations (global shared variables) */\n\tcontextDeclarations?: ContextDeclaration[];\n\n\t/** QTI 3.0: Integrated APIP accessibility catalogs */\n\taccessibilityCatalogs?: AccessibilityCatalog[];\n\n\t/** QTI 3.0: Personal Needs Profile (PNP 3.0) */\n\tpersonalNeedsProfile?: PersonalNeedsProfile;\n\n\t/** Legacy: Flat questions array */\n\tquestions?: QuestionEntity[];\n\n\t/** Legacy: Simple sections */\n\tsections?: LegacyAssessmentSection[];\n\n\t/**\n\t * QTI 3.0: testParts structure (authoritative for QTI format).\n\t */\n\ttestParts?: TestPart[];\n\n\t/** QTI 3.0: Stimulus material references (Phase 3 - placeholder) */\n\tstimulusRefs?: any[];\n}\n\n/**\n * Enhanced settings structure for assessment configuration.\n * Provides structured fields for district policies, test administration,\n * tool configurations, and theme settings while remaining extensible.\n */\nexport interface AssessmentSettings {\n\t/** District/organization policies */\n\tdistrictPolicy?: {\n\t\tblockedTools?: string[]; // PNP support IDs that are blocked\n\t\trequiredTools?: string[]; // PNP support IDs that are required\n\t\tpolicies?: Record<string, any>;\n\t};\n\n\t/** Test administration configuration */\n\ttestAdministration?: {\n\t\tmode?: \"practice\" | \"test\" | \"benchmark\";\n\t\ttoolOverrides?: Record<string, boolean>; // Override specific PNP supports\n\t\tstartDate?: string;\n\t\tendDate?: string;\n\t};\n\n\t/** Tool-specific provider configurations */\n\ttoolConfigs?: {\n\t\t// Calculator-specific options are owned by the calculator tool package.\n\t\tcalculator?: AssessmentCalculatorConfig;\n\t\t/**\n\t\t * Text-to-speech configuration.\n\t\t *\n\t\t * Standard parameters (voice, rate, pitch) are portable across providers\n\t\t * and follow W3C Web Speech API specifications.\n\t\t *\n\t\t * Provider-specific extensions should be placed in providerOptions.\n\t\t *\n\t\t * @see https://w3c.github.io/speech-api/\n\t\t */\n\t\ttextToSpeech?: {\n\t\t\t/**\n\t\t\t * TTS provider\n\t\t\t *\n\t\t\t * @standard \"browser\" uses W3C Web Speech API\n\t\t\t * @extension \"polly\" and \"custom\" are provider-specific\n\t\t\t */\n\t\t\tprovider?: \"browser\" | \"polly\" | \"custom\";\n\n\t\t\t/**\n\t\t\t * Voice identifier (provider-specific names)\n\t\t\t *\n\t\t\t * @standard W3C Web Speech API (concept)\n\t\t\t * @example \"Joanna\" (Polly), \"en-US-Standard-A\" (Google), browser voices\n\t\t\t */\n\t\t\tvoice?: string;\n\n\t\t\t/**\n\t\t\t * Speech rate (speed multiplier)\n\t\t\t *\n\t\t\t * @standard W3C Web Speech API\n\t\t\t * @range 0.25 to 4.0\n\t\t\t * @default 1.0\n\t\t\t */\n\t\t\trate?: number;\n\n\t\t\t/**\n\t\t\t * Pitch adjustment\n\t\t\t *\n\t\t\t * @standard W3C Web Speech API\n\t\t\t * @range 0 to 2 (as multiplier)\n\t\t\t * @default 1.0\n\t\t\t */\n\t\t\tpitch?: number;\n\n\t\t\t/**\n\t\t\t * Provider-specific options (extensions)\n\t\t\t *\n\t\t\t * @extension Not portable across providers\n\t\t\t * @example For AWS Polly: { engine: \"neural\", region: \"us-east-1\" }\n\t\t\t * @example For Google Cloud: { audioEncoding: \"MP3\", effectsProfileId: [\"headphone-class-device\"] }\n\t\t\t */\n\t\t\tproviderOptions?: Record<string, any>;\n\t\t};\n\t\t[toolId: string]: any; // Other tool configs\n\t};\n\n\t/** Theme configuration (not in PNP) */\n\tthemeConfig?: {\n\t\tcolorScheme?: \"default\" | \"high-contrast\" | \"dark\";\n\t\tfontSize?: number;\n\t\tfontFamily?: string;\n\t\tlineHeight?: number;\n\t\treducedMotion?: boolean;\n\t};\n\n\t/** Product-specific extensions */\n\t[key: string]: any;\n}\n\n/**\n * Calculator options exposed through assessment settings.\n * The engine is implicit (Desmos).\n */\nexport interface AssessmentCalculatorConfig {\n\ttype?: \"basic\" | \"scientific\" | \"graphing\";\n\t[key: string]: any;\n}\n\n/**\n * Item-level settings for tool requirements.\n * Used in AssessmentItemRef.settings to specify item-specific tool needs.\n */\nexport interface ItemSettings {\n\trequiredTools?: string[]; // PNP support IDs required for this item\n\trestrictedTools?: string[]; // PNP support IDs blocked for this item\n\ttoolParameters?: Record<string, any>; // Tool-specific config per item\n\n\t[key: string]: any; // Product extensions\n}\n\nexport interface SanctionedVersionEntity extends BaseEntity {\n\torganization?: string | OrganizationEntity; // if set, this is an organization specific matcher, otherwise, it's global\n\tmatch: string; // semver match expression, e.g. '1.*'\n\tpie: string; // e.g. @pie-element/calculator\n\tversion: string; // e.g. 2.14.24\n}\n\nexport enum SanctionedVersionChangeStatus {\n\tPENDING = \"pending\",\n\tIN_PROGRESS = \"in_progress\",\n\tCOMPLETED = \"completed\",\n\tFAILED = \"failed\",\n}\n\nexport interface SanctionedVersionChangeRequest {\n\tpie: string;\n\tmatch: string;\n\tversion: string;\n}\n\nexport interface SanctionedVersionChangeEntity extends BaseEntity {\n\torganization?: string | OrganizationEntity;\n\tcreatedBy: string | UserEntity;\n\tstatus: SanctionedVersionChangeStatus;\n\trequestedChanges: SanctionedVersionChangeRequest[];\n\tbeforeState: SanctionedVersionEntity[];\n\tsummary?: string;\n\tjobId: string;\n}\n\nexport type PlayerMode = \"gather\" | \"view\" | \"evaluate\" | \"browse\" | \"author\";\n\nexport type PlayerRole = \"student\" | \"instructor\";\n\nexport interface Env {\n\tmode: PlayerMode;\n\trole: PlayerRole;\n\tpartialScoring?: boolean;\n}\n\nexport interface OutcomeResponse {\n\tid: string;\n\telement: string;\n\tscore?: number;\n\tempty?: boolean;\n\tcompleted?: boolean;\n\n\t[key: string]: any;\n}\n\nexport interface PieController {\n\tmodel(model: PieModel, sessionData: any[], env?: any): Promise<PieModel>;\n\n\toutcome(\n\t\tmodelOrSessionData: PieModel | any[],\n\t\tsessionOrEnv?: any,\n\t\tenv?: any,\n\t): Promise<OutcomeResponse>;\n\n\tscore: (config: object, session: object, env: object) => Promise<object>;\n\tcreateCorrectResponseSession: (\n\t\tconfig: object,\n\t\tenv: object,\n\t) => Promise<object>;\n\tvalidate: (model: object, config: object) => any;\n}\n\nexport interface PieItemElement {\n\t[elementName: string]: string;\n}\n\nexport type BundleInfo = {\n\turl: string;\n\thash: string;\n};\n\ninterface PieDefaultModel {\n\t// supports 'excess' properties as may be defined in pie models\n\t// https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#strict-object-literal-assignment-checking\n\t[x: string]: any;\n}\n\ninterface PieContent {\n\tid: string;\n\t/**\n\t * Set of elements to include in the pie, provided in the format `{'element-name': 'mpm-package-name'}`\n\t */\n\telements: PieItemElement;\n\n\t/** Models for each PIE included in the item */\n\tmodels: PieModel[];\n\n\tmarkup: string;\n\n\tbundle?: BundleInfo;\n\n\tdefaultExtraModels?: {\n\t\t[key: string]: PieDefaultModel;\n\t};\n}\n\ninterface AdvancedItemConfig {\n\tid: string;\n\tpie: PieContent;\n\tpassage?: PieContent;\n\tinstructorResources?: [PieContent];\n\tdefaultExtraModels?: {\n\t\t[key: string]: PieDefaultModel;\n\t};\n}\n\nexport type ItemConfig = PieContent | AdvancedItemConfig;\n\n/**\n * During the loading of elements from PIE bundles, we do a trick where we make\n * editor components available as web components by appending this to the element name.\n */\nexport const editorPostFix = \"-pie-editor--\";\n\nexport type ModelUpdatedDetail = {\n\tupdate: any;\n\treset: boolean;\n};\n\nexport class ModelUpdatedEvent extends CustomEvent<ModelUpdatedDetail> {\n\tstatic TYPE = \"model.updated\";\n\n\tconstructor(\n\t\treadonly update: any,\n\t\treadonly reset: boolean = false,\n\t) {\n\t\tsuper(ModelUpdatedEvent.TYPE, { bubbles: true, detail: { update, reset } });\n\t}\n}\n\nexport type DeleteDone = (e?: Error) => void;\n\nexport type DeleteImageDetail = {\n\tsrc: string;\n\tdone: DeleteDone;\n};\n\nexport class DeleteImageEvent extends CustomEvent<DeleteImageDetail> {\n\tstatic TYPE = \"delete.image\";\n\n\tconstructor(\n\t\treadonly src: string,\n\t\treadonly done: DeleteDone,\n\t) {\n\t\tsuper(DeleteImageEvent.TYPE, { bubbles: true, detail: { src, done } });\n\t}\n}\n\nexport interface ImageHandler {\n\tisPasted?: boolean;\n\tcancel: () => void;\n\tdone: (err?: Error, src?: string) => void;\n\tfileChosen: (file: File) => void;\n\tprogress: (percent: number, bytes: number, total: number) => void;\n}\n\nexport class InsertImageEvent extends CustomEvent<ImageHandler> {\n\tstatic TYPE = \"insert.image\";\n\n\tconstructor(readonly handler: ImageHandler) {\n\t\tsuper(InsertImageEvent.TYPE, { bubbles: true, detail: handler });\n\t}\n}\n\nexport type DeleteSoundDetail = {\n\tsrc: string;\n\tdone: DeleteDone;\n};\n\nexport class DeleteSoundEvent extends CustomEvent<DeleteSoundDetail> {\n\tstatic TYPE = \"delete.sound\";\n\n\tconstructor(\n\t\treadonly src: string,\n\t\treadonly done: DeleteDone,\n\t) {\n\t\tsuper(DeleteSoundEvent.TYPE, { bubbles: true, detail: { src, done } });\n\t}\n}\n\nexport interface SoundHandler {\n\tcancel: () => void;\n\tdone: (err?: Error, src?: string) => void;\n\tfileChosen: File;\n\tprogress: (percent: number, bytes: number, total: number) => void;\n}\n\nexport class InsertSoundEvent extends CustomEvent<SoundHandler> {\n\tstatic TYPE = \"insert.sound\";\n\n\tconstructor(readonly handler: SoundHandler) {\n\t\tsuper(InsertSoundEvent.TYPE, { bubbles: true, detail: handler });\n\t}\n}\n\nexport const isPassageEntity = (\n\tpassage: string | PassageEntity | undefined,\n): passage is PassageEntity => typeof passage === \"object\" && passage !== null;\n\nexport function isPrerelease(version: any): version is SemVer {\n\treturn (\n\t\ttypeof version === \"object\" &&\n\t\tversion !== null &&\n\t\ttypeof version.major === \"number\" &&\n\t\ttypeof version.minor === \"number\" &&\n\t\ttypeof version.patch === \"number\" &&\n\t\t!!version.prerelease && // Check if prerelease exists\n\t\ttypeof version.prerelease.tag === \"string\" &&\n\t\ttypeof version.prerelease.version === \"number\"\n\t);\n}\n\nexport function formatVersion(semVer: SemVer): string {\n\tif (!semVer) return \"\";\n\tconst base = [semVer.major, semVer.minor, semVer.patch].join(\".\");\n\tif (isPrerelease(semVer) && semVer.prerelease) {\n\t\tconst prerelease = [semVer.prerelease.tag, semVer.prerelease.version].join(\n\t\t\t\".\",\n\t\t);\n\t\treturn `${base}-${prerelease}`;\n\t}\n\treturn base;\n}\n\nexport interface PieElement extends HTMLElement {\n\tmodel: PieModel;\n\tconfiguration: any;\n\tsession: any[];\n}\n\nexport type SessionChangedDetail = {\n\tcomplete: boolean;\n\tcomponent: any;\n};\n\nexport class SessionChangedEvent extends CustomEvent<SessionChangedDetail> {\n\tstatic TYPE = \"session-changed\";\n\n\tconstructor(\n\t\treadonly component: string,\n\t\treadonly complete: boolean,\n\t) {\n\t\tsuper(SessionChangedEvent.TYPE, {\n\t\t\tbubbles: true,\n\t\t\tcomposed: true,\n\t\t\tdetail: { complete, component },\n\t\t} as any);\n\t}\n}\n\ninterface ItemCfg extends ConfigEntity {}\n\ninterface ItemWPassageCfg {\n\tpie: ItemCfg;\n\tpassage: ConfigEntity;\n}\n\nexport interface LoadResponse {\n\tjs: {\n\t\tview: string[];\n\t};\n\titem: ItemCfg | ItemWPassageCfg;\n\tsession: {\n\t\tid: string;\n\t\tdata: any[];\n\t};\n}\n\nexport interface Tracker {\n\ttrack(message: string, ...args: any[]): void;\n\n\tstart(label: string): void;\n\n\tend(label: string, metadata?: { [key: string]: any }): void;\n}\n\n/**\n * Interface for storing tracker messages with timestamps\n */\n/**\n * Interface for storing tracker messages with timestamps\n */\nexport interface TrackerMessage {\n\ttimestamp: Date;\n\tmessage: string;\n\targs: any[];\n\tformattedMessage: string; // Added formatted message with interpolated args\n}\n\n/**\n * Enhanced tracker that stores messages with timestamps\n */\nexport interface EnhancedTracker extends Tracker {\n\t/**\n\t * Get all raw tracker messages ordered by timestamp (ascending)\n\t */\n\tgetMessages(): TrackerMessage[];\n\n\t/**\n\t * Get a formatted multi-line representation of all tracker messages\n\t */\n\tgetFormattedMessages(): string;\n}\n\nexport interface ScoreResponse {\n\tsession: FlatSession;\n\tscore: SessionScore;\n\tempty?: boolean;\n\n\t[key: string]: any;\n}\n\nexport interface VersionDiff {\n\tversion: SemVer;\n\tpreviousVersion: SemVer | null;\n\tcreatedAt: Date;\n\tchanges: {\n\t\tadded: Record<string, any>;\n\t\tremoved: Record<string, any>;\n\t\tmodified: Record<\n\t\t\tstring,\n\t\t\t{\n\t\t\t\tprevious: any;\n\t\t\t\tcurrent: any;\n\t\t\t}\n\t\t>;\n\t};\n\tchangeCount: number;\n}\n\nexport interface RoleToOrganizationsMapping {\n\tid?: string;\n\trole: string;\n\torganizations: OrganizationEntity[] | string[];\n\tcreatedAt?: Date;\n\tupdatedAt?: Date;\n}\n\n// CMS Types (copied from @pie-api-aws/datastore to avoid importing server-only package)\nexport enum StandardType {\n\tROOT = 0,\n\tSUBJECT = 1,\n\tLEVEL = 2,\n\tSTANDARD = 3,\n}\n\nexport interface HierarchyInfo {\n\troot?: {\n\t\tid: string;\n\t\tguid: string;\n\t\ttitle: string;\n\t};\n\tsubject?: {\n\t\tid: string;\n\t\tguid: string;\n\t\ttitle: string;\n\t};\n\tlevel?: {\n\t\tid: string;\n\t\tguid: string;\n\t\ttitle: string;\n\t\tgrades: number[];\n\t};\n}\n\nexport interface CmsLearningStandardEntity extends BaseEntity {\n\tguid: string;\n\tabbr?: string;\n\ttype: StandardType;\n\tparentId?: string;\n\tparentGuid?: string;\n\tpath?: string;\n\tdepth: number;\n\tancestors: string[];\n\thierarchy?: HierarchyInfo;\n\ttitle?: string;\n\tdescription?: string;\n\tsequence?: string;\n\torderIndex?: number;\n\tsubjectArea?: string;\n\tsubjectName?: string;\n\tcategory?: string;\n\tabType?: string;\n\tabLabel?: string;\n\tsetName?: string;\n\tpublication?: string;\n\tadopted?: string;\n\tgrades: number[];\n\tgradeNames?: string[];\n\tproperties: Record<string, string>;\n\tstatus?: \"active\" | \"retired\" | \"deprecated\";\n\tlastModifiedAt?: Date;\n\treplacesGuid?: string;\n\treplacedByGuid?: string;\n\tdescriptionHtml?: string;\n\tlastSyncedAt?: Date;\n}\n\nexport interface ItemBankConfig {\n\tcollectionId: string;\n\tsubject?: string;\n\tgradeLevels?: number[];\n\torderIndex: number;\n}\n\nexport interface DOKDistribution {\n\tdok1?: number;\n\tdok2?: number;\n\tdok3?: number;\n\tdok4?: number;\n}\n\nexport interface AssessmentGoal {\n\tdokDistribution?: DOKDistribution;\n\tconstructedResponseCount?: number;\n\tpassageGoals?: string;\n\ttotalItemCount?: {\n\t\ttarget?: number;\n\t\tmin?: number;\n\t\tmax?: number;\n\t};\n}\n\nexport interface StudioImportMetadata {\n\tstudioAssessmentProgramId?: string;\n\tstudioPublicId?: string;\n\timportedAt?: Date;\n}\n\nexport interface CmsBlueprintEntity extends BaseEntity {\n\tname: string;\n\tdescription?: string;\n\tsubject?: string;\n\tstandardSet?: string;\n\tgradeLevels: number[];\n\tstates?: string[];\n\titemBankConfigs: ItemBankConfig[];\n\tassessmentGoal?: AssessmentGoal;\n\tclaimFramework?: \"SBAC\" | \"PARCC\" | \"STATE\" | \"CUSTOM\";\n\tclaimTargets?: string[];\n\tuseSBACClusterTarget?: boolean;\n\tclusters?: string[];\n\tstudioImportMetadata?: StudioImportMetadata;\n\toriginalPrompt?: string;\n}\n\nexport interface CmsBlueprintItemEntity extends BaseEntity {\n\tblueprintId: string;\n\tstandardGuid: string;\n\tcount: number;\n\tdetails?: string;\n\tassessmentId?: string;\n}\n\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AA+CA,MAAM,CAAN,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC3B,iCAAa,CAAA;IACb,mCAAe,CAAA;IACf,mCAAe,CAAA;IACf,iDAA6B,CAAA;AAC9B,CAAC,EALW,gBAAgB,KAAhB,gBAAgB,QAK3B;AAED,MAAM,CAAN,IAAY,SAGX;AAHD,WAAY,SAAS;IACpB,0BAAa,CAAA;IACb,8BAAiB,CAAA;AAClB,CAAC,EAHW,SAAS,KAAT,SAAS,QAGpB;AAyBD,MAAM,CAAN,IAAY,QAIX;AAJD,WAAY,QAAQ;IACnB,6BAAiB,CAAA;IACjB,yBAAa,CAAA;IACb,iCAAqB,CAAA;AACtB,CAAC,EAJW,QAAQ,KAAR,QAAQ,QAInB;AAmdD,MAAM,CAAN,IAAY,6BAKX;AALD,WAAY,6BAA6B;IACxC,oDAAmB,CAAA;IACnB,4DAA2B,CAAA;IAC3B,wDAAuB,CAAA;IACvB,kDAAiB,CAAA;AAClB,CAAC,EALW,6BAA6B,KAA7B,6BAA6B,QAKxC;AAqGD;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,eAAe,CAAC;AAO7C,MAAM,OAAO,iBAAkB,SAAQ,WAA+B;IAI3D;IACA;IAJV,MAAM,CAAC,IAAI,GAAG,eAAe,CAAC;IAE9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,UAAU,EAAE,CAAC;IAChC,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC;AAaD,MAAM,OAAO,mBAAoB,SAAQ,WAAiC;IAI/D;IACA;IAJV,MAAM,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAEhC,YACU,SAAiB,EACjB,QAAiB;QAE1B,KAAK,CAAC,mBAAmB,CAAC,IAAI,EAAE;YAC/B,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,IAAI;YACd,MAAM,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE;SACxB,CAAC,CAAC;QAPD,cAAS,GAAT,SAAS,CAAQ;QACjB,aAAQ,GAAR,QAAQ,CAAS;IAO3B,CAAC;;AA2FF,wFAAwF;AACxF,MAAM,CAAN,IAAY,YAKX;AALD,WAAY,YAAY;IACvB,+CAAQ,CAAA;IACR,qDAAW,CAAA;IACX,iDAAS,CAAA;IACT,uDAAY,CAAA;AACb,CAAC,EALW,YAAY,KAAZ,YAAY,QAKvB","sourcesContent":["/**\n * This contains copies of the data types we use in PIEOneer. These types, unlike\n * the ones in the datastore package, should not have any dependencies, and might in some\n * cases be more shallow than their originals. The main reason for these is that they should\n * be able to be used in front-end code (as well as the PIEOneer backend code).\n *\n * INCLUDING REFERENCES TO THE DATASTORE PACKAGE INSTEAD WILL MAKE PIEONEER THROW 500\n * EVERYWHERE WITHOUT ANY FURTHER EXPLANATION\n */\nexport interface BaseEntity {\n\tid?: string;\n\tcreatedAt?: Date;\n\tupdatedAt?: Date;\n}\n\nexport interface CollectionEntity extends BaseEntity {\n\tname: string;\n\torganization: string | OrganizationEntity;\n}\n\nexport interface OrganizationEntity extends BaseEntity {\n\tname: string;\n\tdefaultCollection?: string | CollectionEntity;\n}\n\nexport interface UserEntity extends BaseEntity {\n\temail: string;\n\tname?: string;\n}\n\nexport interface ClientEntity extends BaseEntity {\n\tname: string;\n\tsecret: string;\n\tuser: string | UserEntity;\n\torganization: string | OrganizationEntity;\n}\n\nexport interface AssignmentEntity extends BaseEntity {\n\torganization: string | OrganizationEntity;\n}\n\nexport interface SessionEntity extends BaseEntity {\n\titem: ItemEntity;\n\tassignment?: string | AssignmentEntity; // TODO: Remove after data is migrated\n\torganization?: string | OrganizationEntity;\n}\n\nexport enum SessionEventType {\n\tSAVE = \"save\",\n\tMODEL = \"model\",\n\tSCORE = \"score\",\n\tMANUAL_SCORE = \"manual-score\",\n}\n\nexport enum ScoreType {\n\tAUTO = \"auto\",\n\tMANUAL = \"manual\",\n}\n\nexport interface SessionScore {\n\tpoints?: number;\n\tmax?: number;\n\ttype?: ScoreType;\n\tpartialScoring?: boolean;\n\tmessage?: string;\n\terrors?: string[];\n}\n\nexport interface SessionAutoScore extends SessionScore {\n\telements?: any[];\n\textraProps?: any;\n}\n\nexport interface SessionManualScore extends SessionScore {}\n\nexport interface SessionEventEntity extends BaseEntity {\n\tsession: string | SessionEntity;\n\ttype?: SessionEventType;\n\tsaveEventId?: string;\n\tscore?: number;\n}\n\nexport enum ModeType {\n\tGATHER = \"gather\",\n\tVIEW = \"view\",\n\tEVALUATE = \"evaluate\",\n}\n\nexport interface FlatSession {\n\tid: string;\n\tassignment: AssignmentEntity;\n\titem: string;\n\tdata: any[];\n\tcreatedAt: Date;\n\tupdatedAt: Date;\n\tmode: ModeType;\n\tautoScore: SessionAutoScore;\n\tmanualScore: SessionManualScore;\n\tevents: SessionEventEntity[]; // raw events;\n}\n\nexport interface SemVerPrerelease {\n\ttag: string;\n\tversion: number;\n}\n\nexport interface SemVer {\n\tmajor: number;\n\tminor: number;\n\tpatch: number;\n\tprerelease?: SemVerPrerelease;\n}\n\nexport interface VersionEntity extends BaseEntity {\n\tbaseId: string;\n\tsignature?: string;\n\tversion: SemVer;\n}\n\nexport interface SearchMetaData {\n\t[key: string]: any;\n}\n\nexport interface SearchMetaDataEntity extends BaseEntity {\n\tsearchMetaData?: SearchMetaData;\n}\n\nexport interface ConfigElements {\n\t[key: string]: string;\n}\n\nexport interface PieModel {\n\tid: string;\n\telement: string;\n\t/**\n\t * QTI/APIP-style accessibility catalogs owned by this model's renderable fields\n\t * (prompt, choices, feedback, rationale, etc.).\n\t */\n\taccessibilityCatalogs?: AccessibilityCatalog[];\n\n\t[key: string]: any;\n}\n\nexport interface ConfigEntity {\n\tid?: string;\n\tmarkup: string;\n\telements: ConfigElements;\n\tmodels: PieModel[];\n\tconfiguration?: Record<string, any>; // NEW: Configure settings for authoring mode\n\n\t/**\n\t * QTI 3.0: Extracted accessibility catalogs from embedded SSML.\n\t * Automatically generated by SSMLExtractor when <speak> tags are found in content.\n\t */\n\textractedCatalogs?: AccessibilityCatalog[];\n\n\t[key: string]: any;\n}\n\nexport interface ConfigContainerEntity extends BaseEntity {\n\tconfig: ConfigEntity;\n}\n\nexport interface PassageEntity\n\textends VersionEntity,\n\t\tConfigContainerEntity,\n\t\tSearchMetaDataEntity {\n\tname: string;\n\t/** QTI/APIP-style accessibility catalogs owned by this passage content. */\n\taccessibilityCatalogs?: AccessibilityCatalog[];\n\tretired?: boolean;\n\tpublished?: boolean;\n\t// Search result highlights from OpenSearch (keyed by field name)\n\thighlights?: Record<string, string[]>;\n}\n\nexport interface ItemEntity\n\textends VersionEntity,\n\t\tConfigContainerEntity,\n\t\tSearchMetaDataEntity {\n\tname?: string;\n\tpassage?: string | PassageEntity;\n\t/** QTI/APIP-style accessibility catalogs owned by the item root. */\n\taccessibilityCatalogs?: AccessibilityCatalog[];\n\tretired?: boolean;\n\tpublished?: boolean;\n\tconfiguration?: any;\n\t// Search result highlights from OpenSearch (keyed by field name)\n\thighlights?: Record<string, string[]>;\n}\n\nexport interface AssignmentSessionData {\n\tassignment: AssignmentEntity;\n\tsessions: FlatSession[];\n\titems: ItemEntity[];\n\terror?: string;\n}\n\n/**\n * Metadata specifically for interpretation by clients, typically containing\n * options that are relevant for the user interface. This is not indexed for search.\n */\nexport interface SettingsMetaData {\n\t[key: string]: any;\n}\n\n/**\n * Objects that contain metadata in the settings property, which is NOT indexed for search\n * but typically only relevant for particular client cases.\n */\nexport interface SettingsMetaDataEntity {\n\tsettings?: SettingsMetaData;\n}\n\n/**\n * A reference to an item with optionally a title, settings and metadata.\n */\nexport interface QuestionEntity\n\textends SearchMetaDataEntity,\n\t\tSettingsMetaDataEntity {\n\tid?: string;\n\ttitle?: string;\n\titemVId: string;\n\titem?: ItemEntity;\n}\n\n// ============================================================================\n// QTI-aligned assessment model (QTI 2.x compatible shape)\n// ============================================================================\n\nexport type RubricBlockView =\n\t| \"author\"\n\t| \"candidate\"\n\t| \"proctor\"\n\t| \"scorer\"\n\t| \"testConstructor\"\n\t| \"tutor\";\n\nexport interface RubricBlock {\n\tidentifier?: string;\n\t/** QTI spec: space-separated list of roles; stored as an array */\n\tview: RubricBlockView[];\n\tclass?: \"stimulus\" | \"instructions\" | \"rubric\";\n\n\t/**\n\t * Versioned ID reference to the passage (when class=\"stimulus\").\n\t */\n\tpassageVId?: string;\n\n\t/**\n\t * Embedded passage entity (PIE-native approach).\n\t * The passage is rendered using the same ItemPlayer infrastructure as items.\n\t * Contains a PIE config with markup, elements, and models.\n\t */\n\tpassage?: PassageEntity;\n\n\t/**\n\t * Simple HTML content string (for basic use cases).\n\t * Alternative to the passage entity approach.\n\t */\n\tcontent?: string;\n}\n\n/**\n * QTI-aligned assessment item reference (maps to qti-assessment-item-ref).\n * References an item within a section. The item property contains the resolved\n * ItemEntity with its PIE config.\n */\nexport interface AssessmentItemRef extends SearchMetaDataEntity {\n\tid?: string;\n\tidentifier: string;\n\ttitle?: string;\n\trequired?: boolean;\n\n\t/**\n\t * Item virtual ID - stable identifier for the item across versions\n\t */\n\titemVId?: string;\n\n\t/**\n\t * Resolved item entity with PIE config.\n\t * This is populated by the client before passing to the player.\n\t */\n\titem?: ItemEntity;\n\n\t/** Item-level settings for tool requirements and customization */\n\tsettings?: ItemSettings;\n}\n\nexport interface AssessmentSection\n\textends SearchMetaDataEntity,\n\t\tSettingsMetaDataEntity {\n\tid?: string;\n\tidentifier: string;\n\ttitle?: string;\n\tvisible?: boolean;\n\trequired?: boolean;\n\t/**\n\t * QTI 3 pagination hint (`qti-assessment-section@keep-together`).\n\t *\n\t * Indicates that the delivery system SHOULD render this section's items\n\t * together rather than splitting them across pages. This is strictly a\n\t * rendering/layout hint — it does NOT disable item-level navigation,\n\t * current-item tracking, or `item-selected` events in the section player.\n\t * Paginated and keep-together sections both support Next/Back,\n\t * `getCurrentItem()`, and `item-selected` events.\n\t */\n\tkeepTogether?: boolean;\n\n\tsections?: AssessmentSection[];\n\n\t/**\n\t * QTI 3.0: Assessment item references (items in this section).\n\t * Maps to qti-assessment-item-ref in QTI 3.0 XML.\n\t */\n\tassessmentItemRefs?: AssessmentItemRef[];\n\n\t// Shared context (passages/instructions/rubrics) for this section\n\trubricBlocks?: RubricBlock[];\n\n\tsort?: string;\n}\n\nexport interface TestPart {\n\tid?: string;\n\tidentifier: string;\n\tnavigationMode: \"linear\" | \"nonlinear\";\n\tsubmissionMode: \"individual\" | \"simultaneous\";\n\tsections: AssessmentSection[];\n}\n\n// ============================================================================\n// QTI 3.0 Types\n// ============================================================================\n\nexport interface ContextDeclaration {\n\tidentifier: string;\n\tbaseType:\n\t\t| \"boolean\"\n\t\t| \"integer\"\n\t\t| \"float\"\n\t\t| \"string\"\n\t\t| \"identifier\"\n\t\t| \"point\"\n\t\t| \"pair\"\n\t\t| \"directedPair\"\n\t\t| \"duration\"\n\t\t| \"file\"\n\t\t| \"uri\";\n\tcardinality: \"single\" | \"multiple\" | \"ordered\" | \"record\";\n\tdefaultValue?: any;\n}\n\nexport interface CatalogCard {\n\tcatalog: string; // 'spoken', 'sign-language', 'braille', etc.\n\tlanguage?: string;\n\tcontent: string;\n}\n\nexport interface AccessibilityCatalog {\n\tidentifier: string;\n\tcards: CatalogCard[];\n}\n\nexport interface PersonalNeedsProfile {\n\tsupports: string[];\n\tprohibitedSupports?: string[];\n\tactivateAtInit?: string[];\n}\n\n/**\n * QTI 3.0: Reference to a shared stimulus (passage).\n * Maps to qti-assessment-stimulus-ref element.\n *\n * NOTE: Not currently used. We embed PassageEntity directly in RubricBlock instead.\n * Kept for potential future use if we need to support external stimulus references.\n */\n/*\nexport interface StimulusRef {\n\tidentifier: string;\n\thref: string;\n}\n*/\n\nexport interface AssessmentEntity extends BaseEntity, SearchMetaDataEntity {\n\tname?: string;\n\ttitle?: string;\n\tidentifier?: string;\n\tdescription?: string;\n\n\t/** Enhanced structured settings for assessment configuration */\n\tsettings?: AssessmentSettings;\n\n\t/** QTI version - '3.0' for QTI 3.0 format */\n\tqtiVersion?: \"3.0\";\n\n\t/** QTI 3.0: Context declarations (global shared variables) */\n\tcontextDeclarations?: ContextDeclaration[];\n\n\t/** QTI 3.0: Integrated APIP accessibility catalogs */\n\taccessibilityCatalogs?: AccessibilityCatalog[];\n\n\t/** QTI 3.0: Personal Needs Profile (PNP 3.0) */\n\tpersonalNeedsProfile?: PersonalNeedsProfile;\n\n\t/**\n\t * QTI 3.0: testParts structure (authoritative for QTI format).\n\t */\n\ttestParts?: TestPart[];\n\n\t/** QTI 3.0: Stimulus material references (Phase 3 - placeholder) */\n\tstimulusRefs?: any[];\n}\n\n/**\n * Enhanced settings structure for assessment configuration.\n * Provides structured fields for district policies, test administration,\n * tool configurations, and theme settings while remaining extensible.\n */\nexport interface AssessmentSettings {\n\t/** District/organization policies */\n\tdistrictPolicy?: {\n\t\tblockedTools?: string[]; // PNP support IDs that are blocked\n\t\trequiredTools?: string[]; // PNP support IDs that are required\n\t\tpolicies?: Record<string, any>;\n\t};\n\n\t/** Test administration configuration */\n\ttestAdministration?: {\n\t\tmode?: \"practice\" | \"test\" | \"benchmark\";\n\t\ttoolOverrides?: Record<string, boolean>; // Override specific PNP supports\n\t\tstartDate?: string;\n\t\tendDate?: string;\n\t};\n\n\t/** Tool-specific provider configurations */\n\ttoolConfigs?: {\n\t\t// Calculator-specific options are owned by the calculator tool package.\n\t\tcalculator?: AssessmentCalculatorConfig;\n\t\t/**\n\t\t * Text-to-speech configuration.\n\t\t *\n\t\t * Standard parameters (voice, rate, pitch) are portable across providers\n\t\t * and follow W3C Web Speech API specifications.\n\t\t *\n\t\t * Provider-specific extensions should be placed in providerOptions.\n\t\t *\n\t\t * @see https://w3c.github.io/speech-api/\n\t\t */\n\t\ttextToSpeech?: {\n\t\t\t/**\n\t\t\t * TTS provider\n\t\t\t *\n\t\t\t * @standard \"browser\" uses W3C Web Speech API\n\t\t\t * @extension \"polly\" and \"custom\" are provider-specific\n\t\t\t */\n\t\t\tprovider?: \"browser\" | \"polly\" | \"custom\";\n\n\t\t\t/**\n\t\t\t * Voice identifier (provider-specific names)\n\t\t\t *\n\t\t\t * @standard W3C Web Speech API (concept)\n\t\t\t * @example \"Joanna\" (Polly), \"en-US-Standard-A\" (Google), browser voices\n\t\t\t */\n\t\t\tvoice?: string;\n\n\t\t\t/**\n\t\t\t * Speech rate (speed multiplier)\n\t\t\t *\n\t\t\t * @standard W3C Web Speech API\n\t\t\t * @range 0.25 to 4.0\n\t\t\t * @default 1.0\n\t\t\t */\n\t\t\trate?: number;\n\n\t\t\t/**\n\t\t\t * Pitch adjustment\n\t\t\t *\n\t\t\t * @standard W3C Web Speech API\n\t\t\t * @range 0 to 2 (as multiplier)\n\t\t\t * @default 1.0\n\t\t\t */\n\t\t\tpitch?: number;\n\n\t\t\t/**\n\t\t\t * Speech Rule Engine options for generated MathML speech.\n\t\t\t *\n\t\t\t * `style` is passed to SRE directly; ClearSpeak combines multiple\n\t\t\t * preferences with \":\" (for example,\n\t\t\t * \"ImpliedTimes_MoreImpliedTimes:Paren_Silent\").\n\t\t\t *\n\t\t\t * Mirrors assessment-toolkit's SREMathSpeechOptions without importing\n\t\t\t * toolkit service types into the shared content contract package.\n\t\t\t */\n\t\t\tmathSpeech?: {\n\t\t\t\tdomain?: string;\n\t\t\t\tstyle?: string;\n\t\t\t\tengineOptions?: Record<string, unknown>;\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * Provider-specific options (extensions)\n\t\t\t *\n\t\t\t * @extension Not portable across providers\n\t\t\t * @example For AWS Polly: { engine: \"neural\", region: \"us-east-1\" }\n\t\t\t * @example For Google Cloud: { audioEncoding: \"MP3\", effectsProfileId: [\"headphone-class-device\"] }\n\t\t\t */\n\t\t\tproviderOptions?: Record<string, any>;\n\t\t};\n\t\t[toolId: string]: any; // Other tool configs\n\t};\n\n\t/** Theme configuration (not in PNP) */\n\tthemeConfig?: {\n\t\tscheme?: \"default\" | \"high-contrast\" | \"dark\";\n\t\tfontSize?: number;\n\t\tfontFamily?: string;\n\t\tlineHeight?: number;\n\t\treducedMotion?: boolean;\n\t};\n\n\t/** Product-specific extensions */\n\t[key: string]: any;\n}\n\n/**\n * Calculator options exposed through assessment settings.\n * The engine is implicit (Desmos).\n */\nexport interface AssessmentCalculatorConfig {\n\ttype?: \"basic\" | \"scientific\" | \"graphing\";\n\t[key: string]: any;\n}\n\n/**\n * Item-level settings for tool requirements.\n * Used in AssessmentItemRef.settings to specify item-specific tool needs.\n */\nexport interface ItemSettings {\n\trequiredTools?: string[]; // PNP support IDs required for this item\n\trestrictedTools?: string[]; // PNP support IDs blocked for this item\n\ttoolParameters?: Record<string, any>; // Tool-specific config per item\n\n\t[key: string]: any; // Product extensions\n}\n\nexport interface SanctionedVersionEntity extends BaseEntity {\n\torganization?: string | OrganizationEntity; // if set, this is an organization specific matcher, otherwise, it's global\n\tmatch: string; // semver match expression, e.g. '1.*'\n\tpie: string; // e.g. @pie-element/calculator\n\tversion: string; // e.g. 2.14.24\n}\n\nexport enum SanctionedVersionChangeStatus {\n\tPENDING = \"pending\",\n\tIN_PROGRESS = \"in_progress\",\n\tCOMPLETED = \"completed\",\n\tFAILED = \"failed\",\n}\n\nexport interface SanctionedVersionChangeRequest {\n\tpie: string;\n\tmatch: string;\n\tversion: string;\n}\n\nexport interface SanctionedVersionChangeEntity extends BaseEntity {\n\torganization?: string | OrganizationEntity;\n\tcreatedBy: string | UserEntity;\n\tstatus: SanctionedVersionChangeStatus;\n\trequestedChanges: SanctionedVersionChangeRequest[];\n\tbeforeState: SanctionedVersionEntity[];\n\tsummary?: string;\n\tjobId: string;\n}\n\nexport type PlayerMode = \"gather\" | \"view\" | \"evaluate\" | \"author\";\n\nexport type PlayerRole = \"student\" | \"instructor\";\n\nexport interface Env {\n\tmode: PlayerMode;\n\trole: PlayerRole;\n\tpartialScoring?: boolean;\n}\n\nexport interface OutcomeResponse {\n\tid: string;\n\telement: string;\n\tscore?: number;\n\tempty?: boolean;\n\tcompleted?: boolean;\n\n\t[key: string]: any;\n}\n\nexport interface PieController {\n\tmodel(model: PieModel, sessionData: any[], env?: any): Promise<PieModel>;\n\n\toutcome(\n\t\tmodelOrSessionData: PieModel | any[],\n\t\tsessionOrEnv?: any,\n\t\tenv?: any,\n\t): Promise<OutcomeResponse>;\n\n\tscore: (config: object, session: object, env: object) => Promise<object>;\n\tcreateCorrectResponseSession: (\n\t\tconfig: object,\n\t\tenv: object,\n\t) => Promise<object>;\n\tvalidate: (model: object, config: object) => any;\n}\n\nexport interface PieItemElement {\n\t[elementName: string]: string;\n}\n\nexport type BundleInfo = {\n\turl: string;\n\thash: string;\n};\n\ninterface PieDefaultModel {\n\t// supports 'excess' properties as may be defined in pie models\n\t// https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#strict-object-literal-assignment-checking\n\t[x: string]: any;\n}\n\ninterface PieContent {\n\tid: string;\n\t/**\n\t * Set of elements to include in the pie, provided in the format `{'element-name': 'mpm-package-name'}`\n\t */\n\telements: PieItemElement;\n\n\t/** Models for each PIE included in the item */\n\tmodels: PieModel[];\n\n\tmarkup: string;\n\n\tbundle?: BundleInfo;\n\n\tdefaultExtraModels?: {\n\t\t[key: string]: PieDefaultModel;\n\t};\n}\n\ninterface AdvancedItemConfig {\n\tid: string;\n\tpie: PieContent;\n\tpassage?: PieContent;\n\tinstructorResources?: [PieContent];\n\tdefaultExtraModels?: {\n\t\t[key: string]: PieDefaultModel;\n\t};\n}\n\nexport type ItemConfig = PieContent | AdvancedItemConfig;\n\n/**\n * During the loading of elements from PIE bundles, we do a trick where we make\n * editor components available as web components by appending this to the element name.\n */\nexport const editorPostFix = \"-pie-editor--\";\n\nexport type ModelUpdatedDetail = {\n\tupdate: any;\n\treset: boolean;\n};\n\nexport class ModelUpdatedEvent extends CustomEvent<ModelUpdatedDetail> {\n\tstatic TYPE = \"model.updated\";\n\n\tconstructor(\n\t\treadonly update: any,\n\t\treadonly reset: boolean = false,\n\t) {\n\t\tsuper(ModelUpdatedEvent.TYPE, { bubbles: true, detail: { update, reset } });\n\t}\n}\n\nexport type DeleteDone = (e?: Error) => void;\n\nexport type DeleteImageDetail = {\n\tsrc: string;\n\tdone: DeleteDone;\n};\n\nexport class DeleteImageEvent extends CustomEvent<DeleteImageDetail> {\n\tstatic TYPE = \"delete.image\";\n\n\tconstructor(\n\t\treadonly src: string,\n\t\treadonly done: DeleteDone,\n\t) {\n\t\tsuper(DeleteImageEvent.TYPE, { bubbles: true, detail: { src, done } });\n\t}\n}\n\nexport interface ImageHandler {\n\tisPasted?: boolean;\n\tcancel: () => void;\n\tdone: (err?: Error, src?: string) => void;\n\tfileChosen: (file: File) => void;\n\tprogress: (percent: number, bytes: number, total: number) => void;\n}\n\nexport class InsertImageEvent extends CustomEvent<ImageHandler> {\n\tstatic TYPE = \"insert.image\";\n\n\tconstructor(readonly handler: ImageHandler) {\n\t\tsuper(InsertImageEvent.TYPE, { bubbles: true, detail: handler });\n\t}\n}\n\nexport type DeleteSoundDetail = {\n\tsrc: string;\n\tdone: DeleteDone;\n};\n\nexport class DeleteSoundEvent extends CustomEvent<DeleteSoundDetail> {\n\tstatic TYPE = \"delete.sound\";\n\n\tconstructor(\n\t\treadonly src: string,\n\t\treadonly done: DeleteDone,\n\t) {\n\t\tsuper(DeleteSoundEvent.TYPE, { bubbles: true, detail: { src, done } });\n\t}\n}\n\nexport interface SoundHandler {\n\tcancel: () => void;\n\tdone: (err?: Error, src?: string) => void;\n\tfileChosen: File;\n\tprogress: (percent: number, bytes: number, total: number) => void;\n}\n\nexport class InsertSoundEvent extends CustomEvent<SoundHandler> {\n\tstatic TYPE = \"insert.sound\";\n\n\tconstructor(readonly handler: SoundHandler) {\n\t\tsuper(InsertSoundEvent.TYPE, { bubbles: true, detail: handler });\n\t}\n}\n\nexport const isPassageEntity = (\n\tpassage: string | PassageEntity | undefined,\n): passage is PassageEntity => typeof passage === \"object\" && passage !== null;\n\nexport function isPrerelease(version: any): version is SemVer {\n\treturn (\n\t\ttypeof version === \"object\" &&\n\t\tversion !== null &&\n\t\ttypeof version.major === \"number\" &&\n\t\ttypeof version.minor === \"number\" &&\n\t\ttypeof version.patch === \"number\" &&\n\t\t!!version.prerelease && // Check if prerelease exists\n\t\ttypeof version.prerelease.tag === \"string\" &&\n\t\ttypeof version.prerelease.version === \"number\"\n\t);\n}\n\nexport function formatVersion(semVer: SemVer): string {\n\tif (!semVer) return \"\";\n\tconst base = [semVer.major, semVer.minor, semVer.patch].join(\".\");\n\tif (isPrerelease(semVer) && semVer.prerelease) {\n\t\tconst prerelease = [semVer.prerelease.tag, semVer.prerelease.version].join(\n\t\t\t\".\",\n\t\t);\n\t\treturn `${base}-${prerelease}`;\n\t}\n\treturn base;\n}\n\nexport interface PieElement extends HTMLElement {\n\tmodel: PieModel;\n\tconfiguration: any;\n\tsession: any[];\n}\n\nexport type SessionChangedDetail = {\n\tcomplete: boolean;\n\tcomponent: any;\n};\n\nexport class SessionChangedEvent extends CustomEvent<SessionChangedDetail> {\n\tstatic TYPE = \"session-changed\";\n\n\tconstructor(\n\t\treadonly component: string,\n\t\treadonly complete: boolean,\n\t) {\n\t\tsuper(SessionChangedEvent.TYPE, {\n\t\t\tbubbles: true,\n\t\t\tcomposed: true,\n\t\t\tdetail: { complete, component },\n\t\t} as any);\n\t}\n}\n\ninterface ItemCfg extends ConfigEntity {}\n\ninterface ItemWPassageCfg {\n\tpie: ItemCfg;\n\tpassage: ConfigEntity;\n}\n\nexport interface LoadResponse {\n\tjs: {\n\t\tview: string[];\n\t};\n\titem: ItemCfg | ItemWPassageCfg;\n\tsession: {\n\t\tid: string;\n\t\tdata: any[];\n\t};\n}\n\nexport interface Tracker {\n\ttrack(message: string, ...args: any[]): void;\n\n\tstart(label: string): void;\n\n\tend(label: string, metadata?: { [key: string]: any }): void;\n}\n\n/**\n * Interface for storing tracker messages with timestamps\n */\n/**\n * Interface for storing tracker messages with timestamps\n */\nexport interface TrackerMessage {\n\ttimestamp: Date;\n\tmessage: string;\n\targs: any[];\n\tformattedMessage: string; // Added formatted message with interpolated args\n}\n\n/**\n * Enhanced tracker that stores messages with timestamps\n */\nexport interface EnhancedTracker extends Tracker {\n\t/**\n\t * Get all raw tracker messages ordered by timestamp (ascending)\n\t */\n\tgetMessages(): TrackerMessage[];\n\n\t/**\n\t * Get a formatted multi-line representation of all tracker messages\n\t */\n\tgetFormattedMessages(): string;\n}\n\nexport interface ScoreResponse {\n\tsession: FlatSession;\n\tscore: SessionScore;\n\tempty?: boolean;\n\n\t[key: string]: any;\n}\n\nexport interface VersionDiff {\n\tversion: SemVer;\n\tpreviousVersion: SemVer | null;\n\tcreatedAt: Date;\n\tchanges: {\n\t\tadded: Record<string, any>;\n\t\tremoved: Record<string, any>;\n\t\tmodified: Record<\n\t\t\tstring,\n\t\t\t{\n\t\t\t\tprevious: any;\n\t\t\t\tcurrent: any;\n\t\t\t}\n\t\t>;\n\t};\n\tchangeCount: number;\n}\n\nexport interface RoleToOrganizationsMapping {\n\tid?: string;\n\trole: string;\n\torganizations: OrganizationEntity[] | string[];\n\tcreatedAt?: Date;\n\tupdatedAt?: Date;\n}\n\n// CMS Types (copied from @pie-api-aws/datastore to avoid importing server-only package)\nexport enum StandardType {\n\tROOT = 0,\n\tSUBJECT = 1,\n\tLEVEL = 2,\n\tSTANDARD = 3,\n}\n\nexport interface HierarchyInfo {\n\troot?: {\n\t\tid: string;\n\t\tguid: string;\n\t\ttitle: string;\n\t};\n\tsubject?: {\n\t\tid: string;\n\t\tguid: string;\n\t\ttitle: string;\n\t};\n\tlevel?: {\n\t\tid: string;\n\t\tguid: string;\n\t\ttitle: string;\n\t\tgrades: number[];\n\t};\n}\n\nexport interface CmsLearningStandardEntity extends BaseEntity {\n\tguid: string;\n\tabbr?: string;\n\ttype: StandardType;\n\tparentId?: string;\n\tparentGuid?: string;\n\tpath?: string;\n\tdepth: number;\n\tancestors: string[];\n\thierarchy?: HierarchyInfo;\n\ttitle?: string;\n\tdescription?: string;\n\tsequence?: string;\n\torderIndex?: number;\n\tsubjectArea?: string;\n\tsubjectName?: string;\n\tcategory?: string;\n\tabType?: string;\n\tabLabel?: string;\n\tsetName?: string;\n\tpublication?: string;\n\tadopted?: string;\n\tgrades: number[];\n\tgradeNames?: string[];\n\tproperties: Record<string, string>;\n\tstatus?: \"active\" | \"retired\" | \"deprecated\";\n\tlastModifiedAt?: Date;\n\treplacesGuid?: string;\n\treplacedByGuid?: string;\n\tdescriptionHtml?: string;\n\tlastSyncedAt?: Date;\n}\n\nexport interface ItemBankConfig {\n\tcollectionId: string;\n\tsubject?: string;\n\tgradeLevels?: number[];\n\torderIndex: number;\n}\n\nexport interface DOKDistribution {\n\tdok1?: number;\n\tdok2?: number;\n\tdok3?: number;\n\tdok4?: number;\n}\n\nexport interface AssessmentGoal {\n\tdokDistribution?: DOKDistribution;\n\tconstructedResponseCount?: number;\n\tpassageGoals?: string;\n\ttotalItemCount?: {\n\t\ttarget?: number;\n\t\tmin?: number;\n\t\tmax?: number;\n\t};\n}\n\nexport interface StudioImportMetadata {\n\tstudioAssessmentProgramId?: string;\n\tstudioPublicId?: string;\n\timportedAt?: Date;\n}\n\nexport interface CmsBlueprintEntity extends BaseEntity {\n\tname: string;\n\tdescription?: string;\n\tsubject?: string;\n\tstandardSet?: string;\n\tgradeLevels: number[];\n\tstates?: string[];\n\titemBankConfigs: ItemBankConfig[];\n\tassessmentGoal?: AssessmentGoal;\n\tclaimFramework?: \"SBAC\" | \"PARCC\" | \"STATE\" | \"CUSTOM\";\n\tclaimTargets?: string[];\n\tuseSBACClusterTarget?: boolean;\n\tclusters?: string[];\n\tstudioImportMetadata?: StudioImportMetadata;\n\toriginalPrompt?: string;\n}\n\nexport interface CmsBlueprintItemEntity extends BaseEntity {\n\tblueprintId: string;\n\tstandardGuid: string;\n\tcount: number;\n\tdetails?: string;\n\tassessmentId?: string;\n}\n"]}
|