@pie-players/pie-assessment-player 0.3.53 → 0.3.54

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.
@@ -37,6 +37,8 @@ export declare class AssessmentPlayerDefaultElement extends HTMLElement implemen
37
37
  private attachInstrumentationBridge;
38
38
  private renderEmptyState;
39
39
  private buildSectionPlayerTag;
40
+ private buildSectionRuntime;
41
+ private updateCurrentSectionRuntime;
40
42
  private cleanupTtsForSectionNavigation;
41
43
  private syncCurrentSectionSessionIntoAssessment;
42
44
  private attachSectionControllerReadyListener;
@@ -0,0 +1,10 @@
1
+ import { SectionPlayerRuntimeConfig } from '@pie-players/pie-section-player';
2
+ import { AssessmentPlayerRuntimeConfig } from '../types.js';
3
+ export type ResolveAssessmentSectionPlayerRuntimeArgs = {
4
+ sectionPlayerRuntime?: AssessmentPlayerRuntimeConfig["sectionPlayerRuntime"];
5
+ playerType: "iife" | "esm" | "preloaded";
6
+ attemptId?: string;
7
+ env?: Record<string, unknown> | null;
8
+ coordinator?: unknown;
9
+ };
10
+ export declare function resolveAssessmentSectionPlayerRuntime(args: ResolveAssessmentSectionPlayerRuntimeArgs): SectionPlayerRuntimeConfig;
@@ -1,8 +1,8 @@
1
1
  import "@pie-players/pie-section-player/components/section-player-splitpane-element";
2
2
  import "@pie-players/pie-section-player/components/section-player-vertical-element";
3
- import { defineCustomElementSafely as _ } from "@pie-players/pie-players-shared";
4
- var U = "https://proxy.pie-api.com", H = `${U}/bundles/`;
5
- function $(e) {
3
+ import { defineCustomElementSafely as U } from "@pie-players/pie-players-shared";
4
+ var $ = "https://proxy.pie-api.com", J = `${$}/bundles/`;
5
+ function B(e) {
6
6
  try {
7
7
  const t = {
8
8
  BASE_URL: "/",
@@ -15,7 +15,7 @@ function $(e) {
15
15
  } catch {
16
16
  }
17
17
  }
18
- var Le = typeof window < "u" && window.PIE_BUILDER_ORIGIN_URL || $("PUBLIC_BUILDER_ORIGIN_URL") || U, V = typeof window < "u" && window.PIE_BUILDER_BUNDLE_URL || $("PUBLIC_BUILDER_BUNDLE_URL") || H;
18
+ var Be = typeof window < "u" && window.PIE_BUILDER_ORIGIN_URL || B("PUBLIC_BUILDER_ORIGIN_URL") || $, K = typeof window < "u" && window.PIE_BUILDER_BUNDLE_URL || B("PUBLIC_BUILDER_BUNDLE_URL") || J;
19
19
  function g(e) {
20
20
  "@babel/helpers - typeof";
21
21
  return g = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(t) {
@@ -24,7 +24,7 @@ function g(e) {
24
24
  return t && typeof Symbol == "function" && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
25
25
  }, g(e);
26
26
  }
27
- function J(e, t) {
27
+ function W(e, t) {
28
28
  if (g(e) != "object" || !e) return e;
29
29
  var s = e[Symbol.toPrimitive];
30
30
  if (s !== void 0) {
@@ -34,105 +34,105 @@ function J(e, t) {
34
34
  }
35
35
  return (t === "string" ? String : Number)(e);
36
36
  }
37
- function K(e) {
38
- var t = J(e, "string");
37
+ function Z(e) {
38
+ var t = W(e, "string");
39
39
  return g(t) == "symbol" ? t : t + "";
40
40
  }
41
- function a(e, t, s) {
42
- return (t = K(t)) in e ? Object.defineProperty(e, t, {
41
+ function c(e, t, s) {
42
+ return (t = Z(t)) in e ? Object.defineProperty(e, t, {
43
43
  value: s,
44
44
  enumerable: !0,
45
45
  configurable: !0,
46
46
  writable: !0
47
47
  }) : e[t] = s, e;
48
48
  }
49
- var P;
50
- (function(e) {
51
- e.SAVE = "save", e.MODEL = "model", e.SCORE = "score", e.MANUAL_SCORE = "manual-score";
52
- })(P || (P = {}));
53
49
  var N;
54
50
  (function(e) {
55
- e.AUTO = "auto", e.MANUAL = "manual";
51
+ e.SAVE = "save", e.MODEL = "model", e.SCORE = "score", e.MANUAL_SCORE = "manual-score";
56
52
  })(N || (N = {}));
57
53
  var C;
58
54
  (function(e) {
59
- e.GATHER = "gather", e.VIEW = "view", e.EVALUATE = "evaluate";
55
+ e.AUTO = "auto", e.MANUAL = "manual";
60
56
  })(C || (C = {}));
61
57
  var A;
62
58
  (function(e) {
63
- e.PENDING = "pending", e.IN_PROGRESS = "in_progress", e.COMPLETED = "completed", e.FAILED = "failed";
59
+ e.GATHER = "gather", e.VIEW = "view", e.EVALUATE = "evaluate";
64
60
  })(A || (A = {}));
65
- var W = class B extends CustomEvent {
61
+ var x;
62
+ (function(e) {
63
+ e.PENDING = "pending", e.IN_PROGRESS = "in_progress", e.COMPLETED = "completed", e.FAILED = "failed";
64
+ })(x || (x = {}));
65
+ var Q = class O extends CustomEvent {
66
66
  constructor(t, s = !1) {
67
- super(B.TYPE, {
67
+ super(O.TYPE, {
68
68
  bubbles: !0,
69
69
  detail: {
70
70
  update: t,
71
71
  reset: s
72
72
  }
73
- }), a(this, "update", void 0), a(this, "reset", void 0), this.update = t, this.reset = s;
73
+ }), c(this, "update", void 0), c(this, "reset", void 0), this.update = t, this.reset = s;
74
74
  }
75
75
  };
76
- a(W, "TYPE", "model.updated");
77
- var Z = class O extends CustomEvent {
76
+ c(Q, "TYPE", "model.updated");
77
+ var X = class M extends CustomEvent {
78
78
  constructor(t, s) {
79
- super(O.TYPE, {
79
+ super(M.TYPE, {
80
80
  bubbles: !0,
81
81
  detail: {
82
82
  src: t,
83
83
  done: s
84
84
  }
85
- }), a(this, "src", void 0), a(this, "done", void 0), this.src = t, this.done = s;
85
+ }), c(this, "src", void 0), c(this, "done", void 0), this.src = t, this.done = s;
86
86
  }
87
87
  };
88
- a(Z, "TYPE", "delete.image");
89
- var Q = class M extends CustomEvent {
88
+ c(X, "TYPE", "delete.image");
89
+ var ee = class F extends CustomEvent {
90
90
  constructor(t) {
91
- super(M.TYPE, {
91
+ super(F.TYPE, {
92
92
  bubbles: !0,
93
93
  detail: t
94
- }), a(this, "handler", void 0), this.handler = t;
94
+ }), c(this, "handler", void 0), this.handler = t;
95
95
  }
96
96
  };
97
- a(Q, "TYPE", "insert.image");
98
- var X = class F extends CustomEvent {
97
+ c(ee, "TYPE", "insert.image");
98
+ var te = class q extends CustomEvent {
99
99
  constructor(t, s) {
100
- super(F.TYPE, {
100
+ super(q.TYPE, {
101
101
  bubbles: !0,
102
102
  detail: {
103
103
  src: t,
104
104
  done: s
105
105
  }
106
- }), a(this, "src", void 0), a(this, "done", void 0), this.src = t, this.done = s;
106
+ }), c(this, "src", void 0), c(this, "done", void 0), this.src = t, this.done = s;
107
107
  }
108
108
  };
109
- a(X, "TYPE", "delete.sound");
110
- var ee = class z extends CustomEvent {
109
+ c(te, "TYPE", "delete.sound");
110
+ var se = class j extends CustomEvent {
111
111
  constructor(t) {
112
- super(z.TYPE, {
112
+ super(j.TYPE, {
113
113
  bubbles: !0,
114
114
  detail: t
115
- }), a(this, "handler", void 0), this.handler = t;
115
+ }), c(this, "handler", void 0), this.handler = t;
116
116
  }
117
117
  };
118
- a(ee, "TYPE", "insert.sound");
119
- var te = class G extends CustomEvent {
118
+ c(se, "TYPE", "insert.sound");
119
+ var ne = class z extends CustomEvent {
120
120
  constructor(t, s) {
121
- super(G.TYPE, {
121
+ super(z.TYPE, {
122
122
  bubbles: !0,
123
123
  composed: !0,
124
124
  detail: {
125
125
  complete: s,
126
126
  component: t
127
127
  }
128
- }), a(this, "component", void 0), a(this, "complete", void 0), this.component = t, this.complete = s;
128
+ }), c(this, "component", void 0), c(this, "complete", void 0), this.component = t, this.complete = s;
129
129
  }
130
130
  };
131
- a(te, "TYPE", "session-changed");
132
- var x;
131
+ c(ne, "TYPE", "session-changed");
132
+ var R;
133
133
  (function(e) {
134
134
  e[e.ROOT = 0] = "ROOT", e[e.SUBJECT = 1] = "SUBJECT", e[e.LEVEL = 2] = "LEVEL", e[e.STANDARD = 3] = "STANDARD";
135
- })(x || (x = {}));
135
+ })(R || (R = {}));
136
136
  function h(e, t) {
137
137
  const s = `[${e}]`;
138
138
  return {
@@ -147,35 +147,35 @@ function h(e, t) {
147
147
  function m() {
148
148
  return typeof window < "u" && window.PIE_DEBUG === !0;
149
149
  }
150
- var ke = h("math-rendering", () => m()), S;
150
+ var Oe = h("math-rendering", () => m()), S;
151
151
  (function(e) {
152
152
  e.player = "player.js", e.clientPlayer = "client-player.js", e.editor = "editor.js";
153
153
  })(S || (S = {}));
154
- var R;
154
+ var L;
155
155
  (function(e) {
156
156
  e.loading = "loading", e.loaded = "loaded";
157
- })(R || (R = {}));
158
- var Te = h("pie-scoring", () => m()), De = h("pie-updates", () => m()), _e = h("pie-initialization", () => m()), Ue = {
159
- buildServiceBase: V,
157
+ })(L || (L = {}));
158
+ var Me = h("pie-scoring", () => m()), Fe = h("pie-updates", () => m()), qe = h("pie-initialization", () => m()), je = {
159
+ buildServiceBase: K,
160
160
  bundleType: S.player,
161
161
  env: {
162
162
  mode: "gather",
163
163
  role: "student"
164
164
  }
165
- }, $e = h("asset-handler", () => m()), Be = h("authoring", () => m());
166
- function j(e) {
165
+ }, ze = h("asset-handler", () => m()), Ge = h("authoring", () => m());
166
+ function G(e) {
167
167
  if (!e || typeof e != "object") return !1;
168
168
  const t = e;
169
169
  return typeof t.providerId == "string" && typeof t.providerName == "string" && typeof t.initialize == "function" && typeof t.trackError == "function" && typeof t.trackEvent == "function" && typeof t.destroy == "function" && typeof t.isReady == "function";
170
170
  }
171
- var se = h("instrumentation-event-bridge", () => m());
172
- function ne(e) {
171
+ var ie = h("instrumentation-event-bridge", () => m());
172
+ function re(e) {
173
173
  return e && typeof e == "object" ? e : typeof e > "u" ? {} : { value: e };
174
174
  }
175
- function ie(e) {
176
- se.warn(`[InstrumentationEventBridge:${e}] Ignoring invalid instrumentation provider; expected InstrumentationProvider contract`);
175
+ function oe(e) {
176
+ ie.warn(`[InstrumentationEventBridge:${e}] Ignoring invalid instrumentation provider; expected InstrumentationProvider contract`);
177
177
  }
178
- function re(e) {
178
+ function ae(e) {
179
179
  try {
180
180
  e.provider.trackError(e.error instanceof Error ? e.error : new Error(String(e.error ?? "Unknown instrumentation bridge error")), {
181
181
  component: e.component,
@@ -185,15 +185,15 @@ function re(e) {
185
185
  } catch {
186
186
  }
187
187
  }
188
- function oe(e) {
188
+ function ce(e) {
189
189
  if (!e.host || !e.eventMap.length) return () => {
190
190
  };
191
191
  if (!e.instrumentationProvider) return () => {
192
192
  };
193
- if (!j(e.instrumentationProvider))
194
- return e.debug && ie(e.component), () => {
193
+ if (!G(e.instrumentationProvider))
194
+ return e.debug && oe(e.component), () => {
195
195
  };
196
- const t = e.instrumentationProvider, s = [], n = Math.max(0, e.dedupeWindowMs ?? 0), i = /* @__PURE__ */ new Map(), c = (r, o) => {
196
+ const t = e.instrumentationProvider, s = [], n = Math.max(0, e.dedupeWindowMs ?? 0), i = /* @__PURE__ */ new Map(), a = (r, o) => {
197
197
  const d = [
198
198
  o.assessmentId,
199
199
  o.sectionId,
@@ -201,31 +201,31 @@ function oe(e) {
201
201
  o.itemId,
202
202
  o.canonicalItemId,
203
203
  o.sourceRuntimeId
204
- ].map((l) => String(l ?? "")).join("|");
204
+ ].map((u) => String(u ?? "")).join("|");
205
205
  return `${r.instrumentationEventName}|${d}`;
206
206
  };
207
207
  for (const r of e.eventMap) {
208
208
  const o = (d) => {
209
209
  try {
210
210
  if (!t.isReady() || e.shouldTrackEvent && !e.shouldTrackEvent(d)) return;
211
- const l = ne(d.detail), p = (/* @__PURE__ */ new Date()).toISOString(), I = {
212
- ...l,
211
+ const u = re(d.detail), p = (/* @__PURE__ */ new Date()).toISOString(), E = {
212
+ ...u,
213
213
  ...e.staticAttributes,
214
214
  component: e.component,
215
215
  sourceEventName: r.sourceEventName,
216
216
  timestamp: p
217
217
  };
218
218
  if (n > 0) {
219
- const b = Date.now(), E = c(r, I), w = i.get(E);
220
- if (typeof w == "number" && b - w < n) return;
221
- i.set(E, b);
219
+ const b = Date.now(), w = a(r, E), P = i.get(w);
220
+ if (typeof P == "number" && b - P < n) return;
221
+ i.set(w, b);
222
222
  }
223
- t.trackEvent(r.instrumentationEventName, { ...I });
224
- } catch (l) {
225
- re({
223
+ t.trackEvent(r.instrumentationEventName, { ...E });
224
+ } catch (u) {
225
+ ae({
226
226
  provider: t,
227
227
  component: e.component,
228
- error: l,
228
+ error: u,
229
229
  sourceEventName: r.sourceEventName
230
230
  });
231
231
  }
@@ -238,9 +238,9 @@ function oe(e) {
238
238
  for (const r of s) r();
239
239
  };
240
240
  }
241
- var ae = class {
241
+ var de = class {
242
242
  constructor() {
243
- a(this, "initialized", !1), a(this, "config", void 0);
243
+ c(this, "initialized", !1), c(this, "config", void 0);
244
244
  }
245
245
  trackError(e, t) {
246
246
  if (!this.guardedOperation("trackError", e, t) || !this.applyErrorFilter(e, t)) return;
@@ -302,9 +302,9 @@ var ae = class {
302
302
  transformAttributes(e) {
303
303
  return this.config?.attributeTransformer ? this.config.attributeTransformer(e) : e;
304
304
  }
305
- }, ce = class extends ae {
305
+ }, ue = class extends de {
306
306
  constructor(...e) {
307
- super(...e), a(this, "providerId", "newrelic"), a(this, "providerName", "New Relic");
307
+ super(...e), c(this, "providerId", "newrelic"), c(this, "providerName", "New Relic");
308
308
  }
309
309
  async initialize(e) {
310
310
  this.config = e, typeof window < "u" && window.newrelic ? (this.initialized = !0, this.config?.debug && console.log("[NewRelicProvider] Initialized successfully")) : (this.config?.debug && console.warn("[NewRelicProvider] New Relic not available (window.newrelic not found)"), this.initialized = !1);
@@ -330,14 +330,14 @@ var ae = class {
330
330
  if (t.setCustomAttribute) for (const [s, n] of Object.entries(e)) t.setCustomAttribute(s, n);
331
331
  }
332
332
  };
333
- function L(e) {
333
+ function T(e) {
334
334
  return e && typeof e == "object" ? e : {};
335
335
  }
336
- function k(e) {
337
- const t = L(L(e).loaderConfig);
336
+ function D(e) {
337
+ const t = T(T(e).loaderConfig);
338
338
  return Object.keys(t).length > 0 ? t : null;
339
339
  }
340
- function T(e) {
340
+ function _(e) {
341
341
  if (!e || !("instrumentationProvider" in e)) return { kind: "unset" };
342
342
  const t = e.instrumentationProvider;
343
343
  return t === null ? { kind: "null" } : typeof t > "u" ? { kind: "unset" } : {
@@ -345,35 +345,35 @@ function T(e) {
345
345
  value: t
346
346
  };
347
347
  }
348
- function D(e) {
348
+ function k(e) {
349
349
  if (!e || !("trackPageActions" in e)) return;
350
350
  const t = e.trackPageActions;
351
351
  return typeof t == "boolean" ? t : void 0;
352
352
  }
353
- function de(e, t) {
353
+ function le(e, t) {
354
354
  return e.kind === "value" || e.kind === "null" ? e : t;
355
355
  }
356
- var v, le = h("instrumentation-provider-resolution", () => m());
357
- function ue() {
358
- return v || (v = new ce(), v.initialize()), v;
356
+ var v, he = h("instrumentation-provider-resolution", () => m());
357
+ function me() {
358
+ return v || (v = new ue(), v.initialize()), v;
359
359
  }
360
- function he(e) {
361
- const t = k(e.runtimePlayer), s = k(e.player), n = D(t), i = D(s), c = n ?? i ?? !1, r = de(T(t), T(s));
360
+ function pe(e) {
361
+ const t = D(e.runtimePlayer), s = D(e.player), n = k(t), i = k(s), a = n ?? i ?? !1, r = le(_(t), _(s));
362
362
  if (r.kind !== "null") {
363
- if (r.kind === "unset") return c ? ue() : void 0;
364
- if (j(r.value)) return r.value;
363
+ if (r.kind === "unset") return a ? me() : void 0;
364
+ if (G(r.value)) return r.value;
365
365
  if (e.debug) {
366
366
  const o = e.component ? `[${e.component}] ` : "";
367
- le.warn(`${o}Ignoring invalid instrumentation provider; expected InstrumentationProvider contract`);
367
+ he.warn(`${o}Ignoring invalid instrumentation provider; expected InstrumentationProvider contract`);
368
368
  }
369
369
  }
370
370
  }
371
- var Oe = Object.freeze([
371
+ var Ye = Object.freeze([
372
372
  "composed",
373
373
  "engine-ready",
374
374
  "interactive",
375
375
  "disposed"
376
- ]), me = [
376
+ ]), fe = [
377
377
  {
378
378
  sourceEventName: "assessment-controller-ready",
379
379
  instrumentationEventName: "pie-assessment-controller-ready"
@@ -406,7 +406,7 @@ var Oe = Object.freeze([
406
406
  sourceEventName: "assessment-error",
407
407
  instrumentationEventName: "pie-assessment-error"
408
408
  }
409
- ], Me = /* @__PURE__ */ new Set([
409
+ ], He = /* @__PURE__ */ new Set([
410
410
  "id",
411
411
  "element",
412
412
  .../* @__PURE__ */ new Set([
@@ -415,16 +415,16 @@ var Oe = Object.freeze([
415
415
  "timestamp",
416
416
  "sourceRuntimeId"
417
417
  ])
418
- ]), Fe = h("pie-overrides", () => m());
418
+ ]), Ve = h("pie-overrides", () => m());
419
419
  function f() {
420
420
  return Date.now();
421
421
  }
422
422
  function y(e) {
423
423
  return e.replace(/[^a-zA-Z0-9_-]/g, "-");
424
424
  }
425
- function pe(e) {
425
+ function ge(e) {
426
426
  if (e.attemptId) return `aas_v1_${y(e.assessmentId)}_${y(e.attemptId)}`;
427
- const t = Y(), s = t ? fe(t) : "anon";
427
+ const t = Y(), s = t ? ve(t) : "anon";
428
428
  return `aas_v1_${y(e.assessmentId)}_${y(s)}`;
429
429
  }
430
430
  function Y() {
@@ -434,17 +434,17 @@ function Y() {
434
434
  return null;
435
435
  }
436
436
  }
437
- function fe(e) {
437
+ function ve(e) {
438
438
  const t = "pie:assessment-player:anonymous-device-id", s = e.getItem(t);
439
439
  if (s) return s;
440
440
  const n = `anon-${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`;
441
441
  return e.setItem(t, n), n;
442
442
  }
443
- function q() {
443
+ function H() {
444
444
  return (/* @__PURE__ */ new Date()).toISOString();
445
445
  }
446
- function ge(e) {
447
- const t = q(), s = e.sectionIdentifiers[0];
446
+ function ye(e) {
447
+ const t = H(), s = e.sectionIdentifiers[0];
448
448
  return {
449
449
  version: 1,
450
450
  assessmentAttemptSessionIdentifier: e.assessmentAttemptSessionIdentifier,
@@ -463,8 +463,8 @@ function ge(e) {
463
463
  sectionSessions: {}
464
464
  };
465
465
  }
466
- function ve(e, t) {
467
- const s = q();
466
+ function Se(e, t) {
467
+ const s = H();
468
468
  return {
469
469
  ...e,
470
470
  updatedAt: s,
@@ -478,7 +478,7 @@ function ve(e, t) {
478
478
  }
479
479
  };
480
480
  }
481
- function ye(e, t) {
481
+ function Ie(e, t) {
482
482
  const s = new Set(e.navigationState.visitedSectionIdentifiers || []);
483
483
  return t.currentSectionIdentifier && s.add(t.currentSectionIdentifier), {
484
484
  ...e,
@@ -490,17 +490,17 @@ function ye(e, t) {
490
490
  }
491
491
  };
492
492
  }
493
- function Se(e) {
493
+ function Ee(e) {
494
494
  if (!e) return [];
495
495
  const t = [], s = e.testParts || [];
496
496
  return s.length > 0 ? (s.forEach((n, i) => {
497
- (n.sections || []).forEach((c, r) => {
497
+ (n.sections || []).forEach((a, r) => {
498
498
  t.push({
499
499
  stageIdentifier: n.identifier,
500
500
  stageIndex: i,
501
501
  sectionIndex: t.length,
502
- sectionIdentifier: c.identifier || `section-${i}-${r}`,
503
- section: c
502
+ sectionIdentifier: a.identifier || `section-${i}-${r}`,
503
+ section: a
504
504
  });
505
505
  });
506
506
  }), t) : ((e.sections || []).forEach((n, i) => {
@@ -513,7 +513,7 @@ function Se(e) {
513
513
  });
514
514
  }), t);
515
515
  }
516
- var Ie = class {
516
+ var be = class {
517
517
  constructor(e) {
518
518
  this.args = e, this.listeners = /* @__PURE__ */ new Set(), this.deliveryPlan = { sections: [] }, this.session = null, this.readiness = "bootstrapping", this.submitted = !1, this.storageContext = {
519
519
  assessmentId: e.assessmentId,
@@ -556,7 +556,7 @@ var Ie = class {
556
556
  return this.persistenceStrategy = await this.args.hooks?.createAssessmentSessionPersistence?.(this.storageContext, e) ?? await e.createDefaultPersistence(), this.persistenceStrategy;
557
557
  }
558
558
  async createDeliveryPlan() {
559
- const e = { createDefaultDeliveryPlan: () => ({ sections: Se(this.args.assessment) }) }, t = {
559
+ const e = { createDefaultDeliveryPlan: () => ({ sections: Ee(this.args.assessment) }) }, t = {
560
560
  assessmentId: this.args.assessmentId,
561
561
  attemptId: this.args.attemptId,
562
562
  assessment: this.args.assessment
@@ -566,8 +566,8 @@ var Ie = class {
566
566
  ensureSession() {
567
567
  if (this.session) return this.session;
568
568
  const e = this.deliveryPlan.sections.map((t) => t.sectionIdentifier);
569
- return this.session = ge({
570
- assessmentAttemptSessionIdentifier: pe({
569
+ return this.session = ye({
570
+ assessmentAttemptSessionIdentifier: ge({
571
571
  assessmentId: this.args.assessmentId,
572
572
  attemptId: this.args.attemptId
573
573
  }),
@@ -634,7 +634,7 @@ var Ie = class {
634
634
  const t = this.buildNavigationSnapshot();
635
635
  if (e < 0 || e >= t.totalSections) return !1;
636
636
  const s = t.currentSectionId, n = this.deliveryPlan.sections[e];
637
- this.session = ye(this.ensureSession(), {
637
+ this.session = Ie(this.ensureSession(), {
638
638
  currentSectionIndex: e,
639
639
  currentSectionIdentifier: n?.sectionIdentifier
640
640
  });
@@ -692,7 +692,7 @@ var Ie = class {
692
692
  return this.ensureSession().sectionSessions[e]?.session || null;
693
693
  }
694
694
  updateSectionSession(e, t) {
695
- this.session = ve(this.ensureSession(), {
695
+ this.session = Se(this.ensureSession(), {
696
696
  sectionIdentifier: e,
697
697
  sectionSession: t
698
698
  }), this.emit({
@@ -700,7 +700,7 @@ var Ie = class {
700
700
  timestamp: f()
701
701
  });
702
702
  }
703
- }, u = {
703
+ }, l = {
704
704
  controllerReady: "assessment-controller-ready",
705
705
  navigationRequested: "assessment-navigation-requested",
706
706
  submitRequested: "assessment-submit-requested",
@@ -710,14 +710,83 @@ var Ie = class {
710
710
  progressChanged: "assessment-progress-changed",
711
711
  submissionStateChanged: "assessment-submission-state-changed",
712
712
  error: "assessment-error"
713
- }, be = "pie-section-player-splitpane", Ee = "pie-section-player-vertical";
714
- function we(e, t = !1) {
713
+ };
714
+ function I(e) {
715
+ return e && { ...e };
716
+ }
717
+ function we(e) {
718
+ return e && typeof e == "object" && !Array.isArray(e) ? { ...e } : e;
719
+ }
720
+ function V(e) {
721
+ return e && Object.fromEntries(Object.entries(e).map(([t, s]) => [t, we(s)]));
722
+ }
723
+ function Pe(e) {
724
+ if (e)
725
+ return {
726
+ ...e,
727
+ auth: I(e.auth),
728
+ endpoints: V(e.endpoints),
729
+ request: e.request ? {
730
+ ...e.request,
731
+ headers: e.request.headers ? { ...e.request.headers } : void 0
732
+ } : void 0,
733
+ options: e.options ? {
734
+ ...e.options,
735
+ overrides: e.options.overrides ? { ...e.options.overrides } : void 0
736
+ } : void 0,
737
+ autosave: e.autosave && typeof e.autosave == "object" ? { ...e.autosave } : e.autosave,
738
+ client: e.client ? { ...e.client } : void 0
739
+ };
740
+ }
741
+ function Ne(e) {
742
+ if (e)
743
+ return {
744
+ ...e,
745
+ auth: I(e.auth),
746
+ delivery: Pe(e.delivery),
747
+ authoring: e.authoring ? {
748
+ ...e.authoring,
749
+ auth: I(e.authoring.auth),
750
+ endpoints: V(e.authoring.endpoints),
751
+ request: e.authoring.request ? {
752
+ ...e.authoring.request,
753
+ headers: e.authoring.request.headers ? { ...e.authoring.request.headers } : void 0
754
+ } : void 0,
755
+ media: e.authoring.media ? { ...e.authoring.media } : void 0,
756
+ client: e.authoring.client ? { ...e.authoring.client } : void 0
757
+ } : void 0
758
+ };
759
+ }
760
+ function Ce(e, t) {
761
+ return !e?.delivery || e.delivery.enabled === !1 || !t || e.delivery.assignmentId !== void 0 ? e : {
762
+ ...e,
763
+ delivery: {
764
+ ...e.delivery,
765
+ assignmentId: t
766
+ }
767
+ };
768
+ }
769
+ function Ae(e) {
770
+ const { sectionPlayerRuntime: t, playerType: s, attemptId: n, env: i, coordinator: a } = e, r = t?.player && typeof t.player == "object" ? {
771
+ ...t.player,
772
+ backend: Ce(Ne(t.player.backend), n)
773
+ } : t?.player;
774
+ return {
775
+ playerType: s,
776
+ ...i ? { env: i } : {},
777
+ ...a ? { coordinator: a } : {},
778
+ ...t || {},
779
+ ...r !== void 0 ? { player: r } : {}
780
+ };
781
+ }
782
+ var xe = "pie-section-player-splitpane", Re = "pie-section-player-vertical";
783
+ function Le(e, t = !1) {
715
784
  if (e == null) return t;
716
785
  if (typeof e == "boolean") return e;
717
786
  const s = e.trim().toLowerCase();
718
787
  return s === "" || s === "true" || s === "1" || s === "yes";
719
788
  }
720
- var Pe = class extends HTMLElement {
789
+ var Te = class extends HTMLElement {
721
790
  static get observedAttributes() {
722
791
  return [
723
792
  "assessment-id",
@@ -746,7 +815,7 @@ var Pe = class extends HTMLElement {
746
815
  return this._sectionPlayerRuntime;
747
816
  }
748
817
  set sectionPlayerRuntime(e) {
749
- this._sectionPlayerRuntime = e, this.isConnected && this.attachInstrumentationBridge();
818
+ this._sectionPlayerRuntime = e, this.isConnected && (this.attachInstrumentationBridge(), this.updateCurrentSectionRuntime());
750
819
  }
751
820
  connectedCallback() {
752
821
  this.assessmentId || (this.assessmentId = this.getAttribute("assessment-id") || ""), this.attemptId || (this.attemptId = this.getAttribute("attempt-id") || ""), this.showNavigation = this.getAttribute("show-navigation") ?? this.showNavigation;
@@ -772,33 +841,33 @@ var Pe = class extends HTMLElement {
772
841
  return;
773
842
  }
774
843
  this.readiness = { phase: "bootstrapping" }, this.render();
775
- const e = new Ie({
844
+ const e = new be({
776
845
  assessmentId: this.assessmentId,
777
846
  attemptId: this.attemptId || void 0,
778
847
  assessment: this.assessment,
779
848
  hooks: this.hooks || void 0
780
849
  });
781
850
  this.unsubscribeController?.(), this.controller = e, this.unsubscribeController = e.subscribe((t) => {
782
- t.type === "assessment-route-changed" && (this.cleanupTtsForSectionNavigation(t), this.dispatch(u.routeChanged, t), this.render()), t.type === "assessment-session-applied" && this.dispatch(u.sessionApplied, t), t.type === "assessment-session-changed" && this.dispatch(u.sessionChanged, t), t.type === "assessment-progress-changed" && this.dispatch(u.progressChanged, t), t.type === "assessment-submission-state-changed" && this.dispatch(u.submissionStateChanged, t);
851
+ t.type === "assessment-route-changed" && (this.cleanupTtsForSectionNavigation(t), this.dispatch(l.routeChanged, t), this.render()), t.type === "assessment-session-applied" && this.dispatch(l.sessionApplied, t), t.type === "assessment-session-changed" && this.dispatch(l.sessionChanged, t), t.type === "assessment-progress-changed" && this.dispatch(l.progressChanged, t), t.type === "assessment-submission-state-changed" && this.dispatch(l.submissionStateChanged, t);
783
852
  });
784
853
  try {
785
- await e.initialize(), this.readiness = { phase: "ready" }, this.controllerReadyResolve?.(e), this.dispatch(u.controllerReady, { controller: e }), this.hooks?.onAssessmentControllerReady?.(e), this.render();
854
+ await e.initialize(), this.readiness = { phase: "ready" }, this.controllerReadyResolve?.(e), this.dispatch(l.controllerReady, { controller: e }), this.hooks?.onAssessmentControllerReady?.(e), this.render();
786
855
  } catch (t) {
787
- this.readiness = { phase: "error" }, this.dispatch(u.error, { error: t }), this.renderEmptyState("Failed to initialize assessment player");
856
+ this.readiness = { phase: "error" }, this.dispatch(l.error, { error: t }), this.renderEmptyState("Failed to initialize assessment player");
788
857
  }
789
858
  }
790
859
  resolveInstrumentationProvider() {
791
- return he({
860
+ return pe({
792
861
  runtimePlayer: this.sectionPlayerRuntime?.player,
793
862
  component: "pie-assessment-player-default"
794
863
  });
795
864
  }
796
865
  attachInstrumentationBridge() {
797
- this.detachInstrumentationBridge?.(), this.detachInstrumentationBridge = oe({
866
+ this.detachInstrumentationBridge?.(), this.detachInstrumentationBridge = ce({
798
867
  host: this,
799
868
  instrumentationProvider: this.resolveInstrumentationProvider(),
800
869
  component: "pie-assessment-player-default",
801
- eventMap: me,
870
+ eventMap: fe,
802
871
  staticAttributes: {
803
872
  instrumentationLayer: "assessment",
804
873
  assessmentId: this.assessmentId,
@@ -812,7 +881,20 @@ var Pe = class extends HTMLElement {
812
881
  t.className = "pie-assessment-player-empty", t.textContent = e, this.appendChild(t);
813
882
  }
814
883
  buildSectionPlayerTag() {
815
- return this.sectionPlayerLayout === "vertical" ? Ee : be;
884
+ return this.sectionPlayerLayout === "vertical" ? Re : xe;
885
+ }
886
+ buildSectionRuntime() {
887
+ return Ae({
888
+ sectionPlayerRuntime: this.sectionPlayerRuntime,
889
+ playerType: this.playerType,
890
+ attemptId: this.attemptId || void 0,
891
+ env: this.env,
892
+ coordinator: this.coordinator
893
+ });
894
+ }
895
+ updateCurrentSectionRuntime() {
896
+ const e = this.sectionHost?.firstElementChild;
897
+ e && (e.runtime = this.buildSectionRuntime());
816
898
  }
817
899
  cleanupTtsForSectionNavigation(e) {
818
900
  if (e.currentSectionId && e.previousSectionId && e.currentSectionId === e.previousSectionId) return;
@@ -902,37 +984,32 @@ var Pe = class extends HTMLElement {
902
984
  }
903
985
  `, t.appendChild(s);
904
986
  const n = this.getSnapshot();
905
- if (we(this.showNavigation, !0)) {
987
+ if (Le(this.showNavigation, !0)) {
906
988
  const r = document.createElement("div");
907
989
  r.className = "pie-assessment-player-navigation";
908
990
  const o = document.createElement("div");
909
991
  o.className = "pie-assessment-player-current-position", o.textContent = n.navigation.totalSections > 0 ? `Section ${n.navigation.currentIndex + 1} of ${n.navigation.totalSections}` : "No sections";
910
992
  const d = document.createElement("div");
911
993
  d.className = "pie-assessment-player-nav-controls";
912
- const l = document.createElement("button");
913
- l.className = "pie-assessment-player-nav-btn", l.textContent = "Back", l.disabled = !n.navigation.canPrevious, l.addEventListener("click", () => {
994
+ const u = document.createElement("button");
995
+ u.className = "pie-assessment-player-nav-btn", u.textContent = "Back", u.disabled = !n.navigation.canPrevious, u.addEventListener("click", () => {
914
996
  this.navigatePrevious();
915
997
  });
916
998
  const p = document.createElement("button");
917
999
  p.className = "pie-assessment-player-nav-btn", p.textContent = "Next", p.disabled = !n.navigation.canNext, p.addEventListener("click", () => {
918
1000
  this.navigateNext();
919
- }), d.appendChild(l), d.appendChild(p), r.appendChild(o), r.appendChild(d), t.appendChild(r);
1001
+ }), d.appendChild(u), d.appendChild(p), r.appendChild(o), r.appendChild(d), t.appendChild(r);
920
1002
  }
921
1003
  const i = document.createElement("div");
922
1004
  i.className = "pie-assessment-player-section-host", this.sectionHost = i;
923
- const c = e?.getCurrentSection() || null;
924
- if (c) {
1005
+ const a = e?.getCurrentSection() || null;
1006
+ if (a) {
925
1007
  const r = this.buildSectionPlayerTag(), o = document.createElement(r);
926
- if (o.setAttribute("assessment-id", this.assessmentId), o.setAttribute("section-id", c.sectionIdentifier), this.attemptId && o.setAttribute("attempt-id", this.attemptId), this.debug !== void 0 && this.debug !== null) {
1008
+ if (o.setAttribute("assessment-id", this.assessmentId), o.setAttribute("section-id", a.sectionIdentifier), this.attemptId && o.setAttribute("attempt-id", this.attemptId), this.debug !== void 0 && this.debug !== null) {
927
1009
  const d = typeof this.debug == "boolean" ? String(this.debug) : this.debug;
928
1010
  o.setAttribute("debug", d);
929
1011
  }
930
- o.section = c.section, o.runtime = {
931
- playerType: this.playerType,
932
- ...this.env ? { env: this.env } : {},
933
- ...this.coordinator ? { coordinator: this.coordinator } : {},
934
- ...this.sectionPlayerRuntime || {}
935
- }, o.hooks = { cardTitleFormatter: this.hooks?.cardTitleFormatter }, i.appendChild(o), this.attachSectionControllerReadyListener(o, c.sectionIdentifier);
1012
+ o.section = a.section, o.runtime = this.buildSectionRuntime(), o.hooks = { cardTitleFormatter: this.hooks?.cardTitleFormatter }, i.appendChild(o), this.attachSectionControllerReadyListener(o, a.sectionIdentifier);
936
1013
  }
937
1014
  t.appendChild(i), this.appendChild(t);
938
1015
  }
@@ -981,15 +1058,15 @@ var Pe = class extends HTMLElement {
981
1058
  }
982
1059
  navigateTo(e) {
983
1060
  const t = this.selectNavigation(), s = t.currentIndex, n = t.currentSectionId;
984
- let i = s, c;
1061
+ let i = s, a;
985
1062
  if (typeof e == "number")
986
- i = e, c = this.controller?.getSectionAt(i)?.sectionIdentifier;
987
- else if (c = e, this.controller?.getCurrentSection()?.sectionIdentifier === c) return !0;
988
- if (!this.dispatch(u.navigationRequested, {
1063
+ i = e, a = this.controller?.getSectionAt(i)?.sectionIdentifier;
1064
+ else if (a = e, this.controller?.getCurrentSection()?.sectionIdentifier === a) return !0;
1065
+ if (!this.dispatch(l.navigationRequested, {
989
1066
  fromIndex: s,
990
1067
  toIndex: i,
991
1068
  fromSectionId: n,
992
- toSectionId: c,
1069
+ toSectionId: a,
993
1070
  reason: "navigate-to"
994
1071
  }, !0)) return !1;
995
1072
  this.syncCurrentSectionSessionIntoAssessment();
@@ -998,7 +1075,7 @@ var Pe = class extends HTMLElement {
998
1075
  }
999
1076
  navigateNext() {
1000
1077
  const e = this.selectNavigation(), t = this.controller?.getSectionAt(e.currentIndex + 1);
1001
- if (!this.dispatch(u.navigationRequested, {
1078
+ if (!this.dispatch(l.navigationRequested, {
1002
1079
  fromIndex: e.currentIndex,
1003
1080
  toIndex: e.currentIndex + 1,
1004
1081
  fromSectionId: e.currentSectionId,
@@ -1011,7 +1088,7 @@ var Pe = class extends HTMLElement {
1011
1088
  }
1012
1089
  navigatePrevious() {
1013
1090
  const e = this.selectNavigation(), t = this.controller?.getSectionAt(e.currentIndex - 1);
1014
- if (!this.dispatch(u.navigationRequested, {
1091
+ if (!this.dispatch(l.navigationRequested, {
1015
1092
  fromIndex: e.currentIndex,
1016
1093
  toIndex: e.currentIndex - 1,
1017
1094
  fromSectionId: e.currentSectionId,
@@ -1033,14 +1110,14 @@ var Pe = class extends HTMLElement {
1033
1110
  return Promise.race([t, s]);
1034
1111
  }
1035
1112
  };
1036
- _("pie-assessment-player-default", Pe, "assessment player default tag");
1037
- function Ne(e, t = !1) {
1113
+ U("pie-assessment-player-default", Te, "assessment player default tag");
1114
+ function De(e, t = !1) {
1038
1115
  if (e == null) return t;
1039
1116
  if (typeof e == "boolean") return e;
1040
1117
  const s = e.trim().toLowerCase();
1041
1118
  return s === "" || s === "true" || s === "1" || s === "yes";
1042
1119
  }
1043
- var Ce = class extends HTMLElement {
1120
+ var _e = class extends HTMLElement {
1044
1121
  constructor(...e) {
1045
1122
  super(...e), this.showNavigation = !0;
1046
1123
  }
@@ -1054,7 +1131,7 @@ var Ce = class extends HTMLElement {
1054
1131
  e === "show-navigation" && (this.showNavigation = s), this.render();
1055
1132
  }
1056
1133
  render() {
1057
- const e = Ne(this.showNavigation, !0);
1134
+ const e = De(this.showNavigation, !0);
1058
1135
  this.innerHTML = "";
1059
1136
  const t = document.createElement("style");
1060
1137
  t.textContent = `
@@ -1077,8 +1154,8 @@ var Ce = class extends HTMLElement {
1077
1154
  `;
1078
1155
  const s = document.createElement("div");
1079
1156
  if (s.className = "pie-assessment-player-shell", e) {
1080
- const c = document.createElement("slot");
1081
- c.name = "navigation", s.appendChild(c);
1157
+ const a = document.createElement("slot");
1158
+ a.name = "navigation", s.appendChild(a);
1082
1159
  }
1083
1160
  const n = document.createElement("div");
1084
1161
  n.className = "pie-assessment-player-shell__body";
@@ -1086,7 +1163,7 @@ var Ce = class extends HTMLElement {
1086
1163
  n.appendChild(i), s.appendChild(n), this.appendChild(t), this.appendChild(s);
1087
1164
  }
1088
1165
  };
1089
- _("pie-assessment-player-shell", Ce, "assessment player shell tag");
1166
+ U("pie-assessment-player-shell", _e, "assessment player shell tag");
1090
1167
  export {
1091
- u as ASSESSMENT_PLAYER_PUBLIC_EVENTS
1168
+ l as ASSESSMENT_PLAYER_PUBLIC_EVENTS
1092
1169
  };
package/dist/types.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { AssessmentSection, Env, TestPart } from '@pie-players/pie-players-shared/types';
2
2
  import { LoaderConfig } from '@pie-players/pie-players-shared/loader-config';
3
+ import { SectionPlayerRuntimeConfig } from '@pie-players/pie-section-player';
3
4
  export interface SectionSessionSnapshot {
4
5
  currentItemIndex?: number;
5
6
  visitedItemIdentifiers?: string[];
@@ -87,10 +88,10 @@ export interface SectionPlayerLoaderOverrides {
87
88
  loaderOptions?: Record<string, unknown>;
88
89
  [key: string]: unknown;
89
90
  }
90
- export interface SectionPlayerRuntimeOverrides {
91
- player?: SectionPlayerLoaderOverrides | null;
91
+ export type SectionPlayerRuntimeOverrides = SectionPlayerRuntimeConfig & {
92
+ player?: (SectionPlayerRuntimeConfig["player"] & SectionPlayerLoaderOverrides) | null;
92
93
  [key: string]: unknown;
93
- }
94
+ };
94
95
  export interface AssessmentPlayerRuntimeConfig {
95
96
  assessmentId?: string;
96
97
  attemptId?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-players/pie-assessment-player",
3
- "version": "0.3.53",
3
+ "version": "0.3.54",
4
4
  "type": "module",
5
5
  "description": "Assessment-level coordinator custom elements for orchestrating section-player instances",
6
6
  "license": "MIT",
@@ -49,9 +49,9 @@
49
49
  "lint": "biome check ."
50
50
  },
51
51
  "dependencies": {
52
- "@pie-players/pie-assessment-toolkit": "0.3.53",
53
- "@pie-players/pie-players-shared": "0.3.53",
54
- "@pie-players/pie-section-player": "0.3.53"
52
+ "@pie-players/pie-assessment-toolkit": "0.3.54",
53
+ "@pie-players/pie-players-shared": "0.3.54",
54
+ "@pie-players/pie-section-player": "0.3.54"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@axe-core/playwright": "^4.11.1",