@pie-players/pie-players-shared 0.3.29 → 0.3.31
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/{src → dist}/components/PieItemPlayer.svelte +156 -88
- package/dist/i18n/translations/en/tools.json +1 -1
- package/{src → dist}/i18n/use-i18n-standalone.svelte.ts +1 -0
- package/{src → dist}/i18n/use-i18n.svelte.ts +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/loader-config.d.ts +25 -0
- package/dist/loader-config.d.ts.map +1 -1
- package/dist/loader-config.js +5 -0
- package/dist/loader-config.js.map +1 -1
- package/dist/loaders/ElementLoader.d.ts +6 -34
- package/dist/loaders/ElementLoader.d.ts.map +1 -1
- package/dist/loaders/ElementLoader.js +21 -9
- package/dist/loaders/ElementLoader.js.map +1 -1
- package/dist/loaders/element-loader-types.d.ts +91 -0
- package/dist/loaders/element-loader-types.d.ts.map +1 -0
- package/dist/loaders/element-loader-types.js +26 -0
- package/dist/loaders/element-loader-types.js.map +1 -0
- package/dist/loaders/element-loader.d.ts +92 -0
- package/dist/loaders/element-loader.d.ts.map +1 -0
- package/dist/loaders/element-loader.js +391 -0
- package/dist/loaders/element-loader.js.map +1 -0
- package/dist/loaders/esm-adapter.d.ts +40 -0
- package/dist/loaders/esm-adapter.d.ts.map +1 -0
- package/dist/loaders/esm-adapter.js +274 -0
- package/dist/loaders/esm-adapter.js.map +1 -0
- package/dist/loaders/iife-adapter.d.ts +86 -0
- package/dist/loaders/iife-adapter.d.ts.map +1 -0
- package/dist/loaders/iife-adapter.js +365 -0
- package/dist/loaders/iife-adapter.js.map +1 -0
- package/dist/loaders/index.d.ts +30 -17
- package/dist/loaders/index.d.ts.map +1 -1
- package/dist/loaders/index.js +26 -14
- package/dist/loaders/index.js.map +1 -1
- package/dist/pie/config.d.ts.map +1 -1
- package/dist/pie/config.js +12 -5
- package/dist/pie/config.js.map +1 -1
- package/dist/pie/index.d.ts +6 -4
- package/dist/pie/index.d.ts.map +1 -1
- package/dist/pie/index.js +8 -2
- package/dist/pie/index.js.map +1 -1
- package/dist/pie/initialization.d.ts +26 -1
- package/dist/pie/initialization.d.ts.map +1 -1
- package/dist/pie/initialization.js +72 -15
- package/dist/pie/initialization.js.map +1 -1
- package/dist/pie/instrumentation-event-map.d.ts.map +1 -1
- package/dist/pie/instrumentation-event-map.js +27 -16
- package/dist/pie/instrumentation-event-map.js.map +1 -1
- package/dist/pie/overrides.d.ts +9 -0
- package/dist/pie/overrides.d.ts.map +1 -1
- package/dist/pie/overrides.js +36 -0
- package/dist/pie/overrides.js.map +1 -1
- package/dist/pie/resource-monitor.d.ts +17 -0
- package/dist/pie/resource-monitor.d.ts.map +1 -1
- package/dist/pie/resource-monitor.js +284 -81
- package/dist/pie/resource-monitor.js.map +1 -1
- package/dist/pie/stage-tracker.d.ts +51 -0
- package/dist/pie/stage-tracker.d.ts.map +1 -0
- package/dist/pie/stage-tracker.js +106 -0
- package/dist/pie/stage-tracker.js.map +1 -0
- package/dist/pie/stages.d.ts +75 -0
- package/dist/pie/stages.d.ts.map +1 -0
- package/dist/pie/stages.js +58 -0
- package/dist/pie/stages.js.map +1 -0
- package/dist/pie/updates.d.ts.map +1 -1
- package/dist/pie/updates.js +65 -2
- package/dist/pie/updates.js.map +1 -1
- package/dist/pie/use-resource-monitor.svelte.d.ts.map +1 -1
- package/dist/pie/use-resource-monitor.svelte.js +88 -75
- package/dist/pie/use-resource-monitor.svelte.js.map +1 -1
- package/dist/security/index.d.ts +5 -0
- package/dist/security/index.d.ts.map +1 -0
- package/dist/security/index.js +5 -0
- package/dist/security/index.js.map +1 -0
- package/dist/security/sanitize-item-markup.d.ts +46 -0
- package/dist/security/sanitize-item-markup.d.ts.map +1 -0
- package/dist/security/sanitize-item-markup.js +174 -0
- package/dist/security/sanitize-item-markup.js.map +1 -0
- package/dist/security/sanitize-svg-icon.d.ts +15 -0
- package/dist/security/sanitize-svg-icon.d.ts.map +1 -0
- package/dist/security/sanitize-svg-icon.js +89 -0
- package/dist/security/sanitize-svg-icon.js.map +1 -0
- package/dist/security/validate-style-url.d.ts +28 -0
- package/dist/security/validate-style-url.d.ts.map +1 -0
- package/dist/security/validate-style-url.js +58 -0
- package/dist/security/validate-style-url.js.map +1 -0
- package/dist/security/wrap-overwide-images.d.ts +31 -0
- package/dist/security/wrap-overwide-images.d.ts.map +1 -0
- package/dist/security/wrap-overwide-images.js +92 -0
- package/dist/security/wrap-overwide-images.js.map +1 -0
- package/dist/server/npm-registry.d.ts +8 -0
- package/dist/server/npm-registry.d.ts.map +1 -0
- package/dist/server/npm-registry.js +60 -0
- package/dist/server/npm-registry.js.map +1 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/ui/first-focusable.d.ts +21 -0
- package/dist/ui/first-focusable.d.ts.map +1 -0
- package/dist/ui/first-focusable.js +73 -0
- package/dist/ui/first-focusable.js.map +1 -0
- package/dist/ui/focus-trap.d.ts.map +1 -1
- package/dist/ui/focus-trap.js +2 -13
- package/dist/ui/focus-trap.js.map +1 -1
- package/dist/ui/use-promise.svelte.ts +109 -0
- package/package.json +49 -34
- package/dist/i18n/scripts/check-coverage.d.ts +0 -16
- package/dist/i18n/scripts/check-coverage.d.ts.map +0 -1
- package/dist/i18n/scripts/check-coverage.js +0 -262
- package/dist/i18n/scripts/check-coverage.js.map +0 -1
- package/dist/i18n/scripts/scan-hardcoded.d.ts +0 -16
- package/dist/i18n/scripts/scan-hardcoded.d.ts.map +0 -1
- package/dist/i18n/scripts/scan-hardcoded.js +0 -266
- package/dist/i18n/scripts/scan-hardcoded.js.map +0 -1
- package/dist/i18n/use-i18n-standalone.svelte.d.ts +0 -87
- package/dist/i18n/use-i18n-standalone.svelte.d.ts.map +0 -1
- package/dist/i18n/use-i18n-standalone.svelte.js +0 -151
- package/dist/i18n/use-i18n-standalone.svelte.js.map +0 -1
- package/dist/i18n/use-i18n.svelte.d.ts +0 -67
- package/dist/i18n/use-i18n.svelte.d.ts.map +0 -1
- package/dist/i18n/use-i18n.svelte.js +0 -144
- package/dist/i18n/use-i18n.svelte.js.map +0 -1
- package/dist/instrumentation/providers/DataDogInstrumentationProvider.d.ts +0 -170
- package/dist/instrumentation/providers/DataDogInstrumentationProvider.d.ts.map +0 -1
- package/dist/instrumentation/providers/DataDogInstrumentationProvider.js +0 -183
- package/dist/instrumentation/providers/DataDogInstrumentationProvider.js.map +0 -1
- package/dist/loaders/EsmElementLoader.d.ts +0 -69
- package/dist/loaders/EsmElementLoader.d.ts.map +0 -1
- package/dist/loaders/EsmElementLoader.js +0 -72
- package/dist/loaders/EsmElementLoader.js.map +0 -1
- package/dist/loaders/IifeElementLoader.d.ts +0 -61
- package/dist/loaders/IifeElementLoader.d.ts.map +0 -1
- package/dist/loaders/IifeElementLoader.js +0 -63
- package/dist/loaders/IifeElementLoader.js.map +0 -1
- package/dist/pie/esm-loader.d.ts +0 -104
- package/dist/pie/esm-loader.d.ts.map +0 -1
- package/dist/pie/esm-loader.js +0 -358
- package/dist/pie/esm-loader.js.map +0 -1
- package/dist/pie/iife-loader.d.ts +0 -81
- package/dist/pie/iife-loader.d.ts.map +0 -1
- package/dist/pie/iife-loader.js +0 -425
- package/dist/pie/iife-loader.js.map +0 -1
- package/dist/theming/css-variables.d.ts +0 -7
- package/dist/theming/css-variables.d.ts.map +0 -1
- package/dist/theming/css-variables.js +0 -43
- package/dist/theming/css-variables.js.map +0 -1
- package/dist/theming/index.d.ts +0 -4
- package/dist/theming/index.d.ts.map +0 -1
- package/dist/theming/index.js +0 -3
- package/dist/theming/index.js.map +0 -1
- package/dist/theming/presets.d.ts +0 -7
- package/dist/theming/presets.d.ts.map +0 -1
- package/dist/theming/presets.js +0 -146
- package/dist/theming/presets.js.map +0 -1
- package/dist/theming/types.d.ts +0 -5
- package/dist/theming/types.d.ts.map +0 -1
- package/dist/theming/types.js +0 -2
- package/dist/theming/types.js.map +0 -1
- package/dist/types/custom-elements.d.ts +0 -158
- package/dist/types/custom-elements.d.ts.map +0 -1
- package/dist/types/custom-elements.js +0 -8
- package/dist/types/custom-elements.js.map +0 -1
- package/dist/types/search.d.ts +0 -105
- package/dist/types/search.d.ts.map +0 -1
- package/dist/types/search.js +0 -12
- package/dist/types/search.js.map +0 -1
- package/dist/types/transform.d.ts +0 -48
- package/dist/types/transform.d.ts.map +0 -1
- package/dist/types/transform.js +0 -21
- package/dist/types/transform.js.map +0 -1
- package/src/i18n/README.md +0 -223
- package/src/i18n/index.ts +0 -26
- package/src/i18n/loader.ts +0 -156
- package/src/i18n/scripts/check-coverage.ts +0 -345
- package/src/i18n/scripts/scan-hardcoded.ts +0 -342
- package/src/i18n/simple-i18n.ts +0 -236
- package/src/i18n/translations/ar/common.json +0 -36
- package/src/i18n/translations/ar/toolkit.json +0 -48
- package/src/i18n/translations/ar/tools.json +0 -103
- package/src/i18n/translations/en/common.json +0 -36
- package/src/i18n/translations/en/toolkit.json +0 -48
- package/src/i18n/translations/en/tools.json +0 -103
- package/src/i18n/translations/es/common.json +0 -36
- package/src/i18n/translations/es/toolkit.json +0 -48
- package/src/i18n/translations/es/tools.json +0 -103
- package/src/i18n/translations/zh/common.json +0 -36
- package/src/i18n/translations/zh/toolkit.json +0 -48
- package/src/i18n/translations/zh/tools.json +0 -103
- package/src/i18n/types.ts +0 -66
- /package/{src → dist}/components/PiePreviewLayout.svelte +0 -0
- /package/{src → dist}/components/PiePreviewToggle.svelte +0 -0
- /package/{src → dist}/components/PieSpinner.svelte +0 -0
- /package/{src → dist}/components/ToolSettingsButton.svelte +0 -0
- /package/{src → dist}/components/ToolSettingsPanel.svelte +0 -0
- /package/{src → dist}/components/index.ts +0 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type Stage, type StageChangeDetail, type StageSourceCe, type StageStatus } from "./stages.js";
|
|
2
|
+
/**
|
|
3
|
+
* Stage tracker primitive (M6).
|
|
4
|
+
*
|
|
5
|
+
* One tracker per CE instance per cohort. `enter(stage, status?)` is the
|
|
6
|
+
* only mutation; `reset()` rolls the cohort over (e.g. when
|
|
7
|
+
* `(sectionId, attemptId)` changes).
|
|
8
|
+
*
|
|
9
|
+
* The tracker enforces the locked invariants from
|
|
10
|
+
* `m6_ready_vocab_canonical_followup.plan.md` §3.1–§3.6:
|
|
11
|
+
* - Monotonic ordering across `STAGES`. Backward transitions inside one
|
|
12
|
+
* cohort are rejected (dev) / warned-once (prod) so subscribers never
|
|
13
|
+
* see a stage regress without an intervening `reset()`.
|
|
14
|
+
* - Per-CE applicability. The post-retro canonical list applies to
|
|
15
|
+
* every CE shape; the `applicableStages` indirection is kept so a
|
|
16
|
+
* future shape-specific stage can opt out without rewriting callers.
|
|
17
|
+
* Non-applicable stages auto-emit `status: "skipped"` when an
|
|
18
|
+
* applicable later stage is entered, so iteration order stays stable
|
|
19
|
+
* across CE shapes.
|
|
20
|
+
* - One source for every emit. The injected `emit(detail)` function
|
|
21
|
+
* drives DOM events, engine subscribers, and coordinator subscribers
|
|
22
|
+
* from the same call site so no surface drifts.
|
|
23
|
+
*
|
|
24
|
+
* Failure semantics intentionally piggyback on the M3 framework-error
|
|
25
|
+
* contract: `enter(stage, "failed")` records the position; the
|
|
26
|
+
* framework error records the cause.
|
|
27
|
+
*/
|
|
28
|
+
export type CreateStageTrackerOptions = {
|
|
29
|
+
sourceCe: string;
|
|
30
|
+
sourceCeShape: StageSourceCe;
|
|
31
|
+
runtimeId: string;
|
|
32
|
+
sectionId?: string;
|
|
33
|
+
attemptId?: string;
|
|
34
|
+
emit: (detail: StageChangeDetail) => void;
|
|
35
|
+
now?: () => string;
|
|
36
|
+
onUnexpectedTransition?: (info: {
|
|
37
|
+
from: Stage | null;
|
|
38
|
+
to: Stage;
|
|
39
|
+
reason: "backward" | "duplicate";
|
|
40
|
+
}) => void;
|
|
41
|
+
};
|
|
42
|
+
export type StageTracker = {
|
|
43
|
+
enter: (stage: Stage, status?: StageStatus) => void;
|
|
44
|
+
reset: (next?: {
|
|
45
|
+
sectionId?: string;
|
|
46
|
+
attemptId?: string;
|
|
47
|
+
}) => void;
|
|
48
|
+
getCurrent: () => Stage | null;
|
|
49
|
+
};
|
|
50
|
+
export declare function createStageTracker(opts: CreateStageTrackerOptions): StageTracker;
|
|
51
|
+
//# sourceMappingURL=stage-tracker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stage-tracker.d.ts","sourceRoot":"","sources":["../../src/pie/stage-tracker.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,KAAK,KAAK,EACV,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,MAAM,aAAa,CAAC;AAErB;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,MAAM,MAAM,yBAAyB,GAAG;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,aAAa,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC1C,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,sBAAsB,CAAC,EAAE,CAAC,IAAI,EAAE;QAC/B,IAAI,EAAE,KAAK,GAAG,IAAI,CAAC;QACnB,EAAE,EAAE,KAAK,CAAC;QACV,MAAM,EAAE,UAAU,GAAG,WAAW,CAAC;KACjC,KAAK,IAAI,CAAC;CACX,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IAC1B,KAAK,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,WAAW,KAAK,IAAI,CAAC;IACpD,KAAK,EAAE,CAAC,IAAI,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACnE,UAAU,EAAE,MAAM,KAAK,GAAG,IAAI,CAAC;CAC/B,CAAC;AAqBF,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,yBAAyB,GAAG,YAAY,CAkGhF"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { STAGES, applicableStages, stageOrdinal, } from "./stages.js";
|
|
2
|
+
let unexpectedTransitionWarned = false;
|
|
3
|
+
function defaultUnexpectedTransitionLogger(info) {
|
|
4
|
+
if (unexpectedTransitionWarned)
|
|
5
|
+
return;
|
|
6
|
+
unexpectedTransitionWarned = true;
|
|
7
|
+
if (typeof console !== "undefined" && console.warn) {
|
|
8
|
+
console.warn(`[pie-stage-tracker] Unexpected ${info.reason} stage transition ` +
|
|
9
|
+
`from \`${info.from ?? "<none>"}\` to \`${info.to}\`. ` +
|
|
10
|
+
`Stage transitions are expected to be monotonic within a cohort; ` +
|
|
11
|
+
`call \`reset()\` when \`(sectionId, attemptId)\` changes.`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export function createStageTracker(opts) {
|
|
15
|
+
const applicable = applicableStages(opts.sourceCeShape);
|
|
16
|
+
const applicableSet = new Set(applicable);
|
|
17
|
+
const now = opts.now ?? (() => new Date().toISOString());
|
|
18
|
+
const onUnexpected = opts.onUnexpectedTransition ?? defaultUnexpectedTransitionLogger;
|
|
19
|
+
let current = null;
|
|
20
|
+
let sectionId = opts.sectionId;
|
|
21
|
+
let attemptId = opts.attemptId;
|
|
22
|
+
const emitted = new Set();
|
|
23
|
+
function emitDetail(stage, status) {
|
|
24
|
+
opts.emit({
|
|
25
|
+
stage,
|
|
26
|
+
status,
|
|
27
|
+
runtimeId: opts.runtimeId,
|
|
28
|
+
sectionId,
|
|
29
|
+
attemptId,
|
|
30
|
+
timestamp: now(),
|
|
31
|
+
sourceCe: opts.sourceCe,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function fillSkippedBefore(stage) {
|
|
35
|
+
const targetIdx = stageOrdinal(stage);
|
|
36
|
+
const startIdx = current === null ? 0 : stageOrdinal(current) + 1;
|
|
37
|
+
for (let idx = startIdx; idx < targetIdx; idx += 1) {
|
|
38
|
+
const skipCandidate = STAGES[idx];
|
|
39
|
+
if (applicableSet.has(skipCandidate))
|
|
40
|
+
continue;
|
|
41
|
+
if (emitted.has(skipCandidate))
|
|
42
|
+
continue;
|
|
43
|
+
emitted.add(skipCandidate);
|
|
44
|
+
emitDetail(skipCandidate, "skipped");
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function enter(stage, status = "entered") {
|
|
48
|
+
const nextOrdinal = stageOrdinal(stage);
|
|
49
|
+
const currentOrdinal = current === null ? -1 : stageOrdinal(current);
|
|
50
|
+
if (status === "entered") {
|
|
51
|
+
if (emitted.has(stage)) {
|
|
52
|
+
onUnexpected({ from: current, to: stage, reason: "duplicate" });
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (nextOrdinal < currentOrdinal) {
|
|
56
|
+
onUnexpected({ from: current, to: stage, reason: "backward" });
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (!applicableSet.has(stage)) {
|
|
60
|
+
// A non-applicable stage entered with `entered` is a programming
|
|
61
|
+
// error: the tracker auto-skips it when a later stage enters.
|
|
62
|
+
// Treat it as a `skipped` emission and continue.
|
|
63
|
+
if (emitted.has(stage))
|
|
64
|
+
return;
|
|
65
|
+
emitted.add(stage);
|
|
66
|
+
emitDetail(stage, "skipped");
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
fillSkippedBefore(stage);
|
|
70
|
+
emitted.add(stage);
|
|
71
|
+
current = stage;
|
|
72
|
+
emitDetail(stage, "entered");
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
// `status === "failed"` records position; do not gate on monotonic
|
|
76
|
+
// ordering — failure can happen during any transition. Mark the stage
|
|
77
|
+
// as emitted so a subsequent `entered` for the same stage warns as a
|
|
78
|
+
// duplicate; downstream recovery should call `reset()` first.
|
|
79
|
+
if (status === "failed") {
|
|
80
|
+
fillSkippedBefore(stage);
|
|
81
|
+
emitted.add(stage);
|
|
82
|
+
current = stage;
|
|
83
|
+
emitDetail(stage, "failed");
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
// `status === "skipped"` is reserved for the auto-fill path; explicit
|
|
87
|
+
// callers shouldn't pass it. Accept it idempotently for robustness.
|
|
88
|
+
if (emitted.has(stage))
|
|
89
|
+
return;
|
|
90
|
+
emitted.add(stage);
|
|
91
|
+
emitDetail(stage, "skipped");
|
|
92
|
+
}
|
|
93
|
+
function reset(next) {
|
|
94
|
+
current = null;
|
|
95
|
+
emitted.clear();
|
|
96
|
+
if (next) {
|
|
97
|
+
sectionId = next.sectionId;
|
|
98
|
+
attemptId = next.attemptId;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function getCurrent() {
|
|
102
|
+
return current;
|
|
103
|
+
}
|
|
104
|
+
return { enter, reset, getCurrent };
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=stage-tracker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stage-tracker.js","sourceRoot":"","sources":["../../src/pie/stage-tracker.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,MAAM,EACN,gBAAgB,EAChB,YAAY,GAKZ,MAAM,aAAa,CAAC;AAkDrB,IAAI,0BAA0B,GAAG,KAAK,CAAC;AAEvC,SAAS,iCAAiC,CAAC,IAI1C;IACA,IAAI,0BAA0B;QAAE,OAAO;IACvC,0BAA0B,GAAG,IAAI,CAAC;IAClC,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACpD,OAAO,CAAC,IAAI,CACX,kCAAkC,IAAI,CAAC,MAAM,oBAAoB;YAChE,UAAU,IAAI,CAAC,IAAI,IAAI,QAAQ,WAAW,IAAI,CAAC,EAAE,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AG,CAAC,KAAK,CAAC,CAAC;YACnB,OAAO,GAAG,KAAK,CAAC;YAChB,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;YAC7B,OAAO;QACR,CAAC;QAED,mEAAmE;QACnE,sEAAsE;QACtE,qEAAqE;QACrE,8DAA8D;QAC9D,IAAI,MAAM,KAAK,QAAQ,EAAE,CAAC;YACzB,iBAAiB,CAAC,KAAK,CAAC,CAAC;YACzB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACnB,OAAO,GAAG,KAAK,CAAC;YAChB,UAAU,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;YAC5B,OAAO;QACR,CAAC;QAED,sEAAsE;QACtE,oEAAoE;QACpE,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC;YAAE,OAAO;QAC/B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACnB,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IAC9B,CAAC;IAED,SAAS,KAAK,CAAC,IAAiD;QAC/D,OAAO,GAAG,IAAI,CAAC;QACf,OAAO,CAAC,KAAK,EAAE,CAAC;QAChB,IAAI,IAAI,EAAE,CAAC;YACV,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;YAC3B,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAC5B,CAAC;IACF,CAAC;IAED,SAAS,UAAU;QAClB,OAAO,OAAO,CAAC;IAChB,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical stage vocabulary (M6 of the Coherent Options Surface track).
|
|
3
|
+
*
|
|
4
|
+
* One monotonic stage list is the unified replacement for the previous
|
|
5
|
+
* drift of `toolkit-ready`, `section-ready`, `section-controller-ready`,
|
|
6
|
+
* `interaction-ready`, `readiness-change`, and `ready` — all of which
|
|
7
|
+
* have been removed. Hosts ask the same question — "is this CE at
|
|
8
|
+
* stage ≥ X?" — across every `<pie-section-player-*>` and
|
|
9
|
+
* `<pie-assessment-toolkit>` element.
|
|
10
|
+
*
|
|
11
|
+
* The four-stage canonical list (`composed`, `engine-ready`, `interactive`,
|
|
12
|
+
* `disposed`) was finalized after the M5/M6 cumulative review confirmed
|
|
13
|
+
* zero internal or external consumers for the original `attached`,
|
|
14
|
+
* `runtime-bound`, and `ui-rendered` stages. The retro keeps the same
|
|
15
|
+
* shape for both the toolkit CE and the layout CEs — every CE iterates
|
|
16
|
+
* through the same list so subscribers don't need to special-case shape.
|
|
17
|
+
*
|
|
18
|
+
* Locked decisions (see `m6_ready_vocab_canonical_followup.plan.md`):
|
|
19
|
+
* - **A1** Stage machine model with one canonical event family.
|
|
20
|
+
* - **B1** "All items loaded" is reclassified as `pie-loading-complete`,
|
|
21
|
+
* not a stage. (The previous `ready` DOM event alias was removed in
|
|
22
|
+
* the broad architecture review compat sweep.)
|
|
23
|
+
* - **C1** `readiness.mode = "strict"` only delays the `interactive`
|
|
24
|
+
* transition; every earlier stage fires identically across modes.
|
|
25
|
+
* - **D1** One DOM event family `pie-stage-change` with the stage in the
|
|
26
|
+
* payload, mirroring the M3 `framework-error` idiom.
|
|
27
|
+
*
|
|
28
|
+
* Failure semantics deliberately stay in the M3 framework-error contract —
|
|
29
|
+
* `status: "failed"` records the position; the framework error records the
|
|
30
|
+
* cause.
|
|
31
|
+
*/
|
|
32
|
+
export declare const STAGES: readonly ["composed", "engine-ready", "interactive", "disposed"];
|
|
33
|
+
export type Stage = (typeof STAGES)[number];
|
|
34
|
+
export type StageStatus = "entered" | "skipped" | "failed";
|
|
35
|
+
/**
|
|
36
|
+
* Subset of the source CE shape used by stage subscribers. Both shapes
|
|
37
|
+
* apply every canonical stage post-retro — the distinction stays in the
|
|
38
|
+
* type so future shape-specific stages (e.g. layout-only `paginated`) can
|
|
39
|
+
* be added without churn at the call sites.
|
|
40
|
+
*/
|
|
41
|
+
export type StageSourceCe = "toolkit" | "layout";
|
|
42
|
+
/**
|
|
43
|
+
* Stages that apply to a given CE shape. Post-retro the toolkit and the
|
|
44
|
+
* layout CEs share the same canonical list; `applicableStages` is kept as
|
|
45
|
+
* an indirection so the tracker, telemetry, and tests don't have to be
|
|
46
|
+
* rewritten when a future stage diverges between shapes.
|
|
47
|
+
*/
|
|
48
|
+
export declare function applicableStages(_sourceCe: StageSourceCe): readonly Stage[];
|
|
49
|
+
/**
|
|
50
|
+
* Strict ordering index used by the tracker to detect monotonic
|
|
51
|
+
* violations. `disposed` is last; `composed` is first.
|
|
52
|
+
*/
|
|
53
|
+
export declare function stageOrdinal(stage: Stage): number;
|
|
54
|
+
export type StageChangeDetail = {
|
|
55
|
+
stage: Stage;
|
|
56
|
+
status: StageStatus;
|
|
57
|
+
/** Matches the existing `runtimeId` carried by toolkit telemetry. */
|
|
58
|
+
runtimeId: string;
|
|
59
|
+
sectionId?: string;
|
|
60
|
+
attemptId?: string;
|
|
61
|
+
/** ISO-8601, monotonic across one cohort. */
|
|
62
|
+
timestamp: string;
|
|
63
|
+
/** Tag name minus the `--version-<encoded>` suffix. */
|
|
64
|
+
sourceCe: string;
|
|
65
|
+
};
|
|
66
|
+
export type LoadingCompleteDetail = {
|
|
67
|
+
runtimeId: string;
|
|
68
|
+
sectionId: string;
|
|
69
|
+
attemptId?: string;
|
|
70
|
+
itemCount: number;
|
|
71
|
+
loadedCount: number;
|
|
72
|
+
timestamp: string;
|
|
73
|
+
sourceCe: string;
|
|
74
|
+
};
|
|
75
|
+
//# sourceMappingURL=stages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stages.d.ts","sourceRoot":"","sources":["../../src/pie/stages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,eAAO,MAAM,MAAM,kEAKR,CAAC;AAEZ,MAAM,MAAM,KAAK,GAAG,CAAC,OAAO,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;AAE5C,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE3D;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEjD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,aAAa,GAAG,SAAS,KAAK,EAAE,CAE3E;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAMjD;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC/B,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,EAAE,WAAW,CAAC;IACpB,qEAAqE;IACrE,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6CAA6C;IAC7C,SAAS,EAAE,MAAM,CAAC;IAClB,uDAAuD;IACvD,QAAQ,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CACjB,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical stage vocabulary (M6 of the Coherent Options Surface track).
|
|
3
|
+
*
|
|
4
|
+
* One monotonic stage list is the unified replacement for the previous
|
|
5
|
+
* drift of `toolkit-ready`, `section-ready`, `section-controller-ready`,
|
|
6
|
+
* `interaction-ready`, `readiness-change`, and `ready` — all of which
|
|
7
|
+
* have been removed. Hosts ask the same question — "is this CE at
|
|
8
|
+
* stage ≥ X?" — across every `<pie-section-player-*>` and
|
|
9
|
+
* `<pie-assessment-toolkit>` element.
|
|
10
|
+
*
|
|
11
|
+
* The four-stage canonical list (`composed`, `engine-ready`, `interactive`,
|
|
12
|
+
* `disposed`) was finalized after the M5/M6 cumulative review confirmed
|
|
13
|
+
* zero internal or external consumers for the original `attached`,
|
|
14
|
+
* `runtime-bound`, and `ui-rendered` stages. The retro keeps the same
|
|
15
|
+
* shape for both the toolkit CE and the layout CEs — every CE iterates
|
|
16
|
+
* through the same list so subscribers don't need to special-case shape.
|
|
17
|
+
*
|
|
18
|
+
* Locked decisions (see `m6_ready_vocab_canonical_followup.plan.md`):
|
|
19
|
+
* - **A1** Stage machine model with one canonical event family.
|
|
20
|
+
* - **B1** "All items loaded" is reclassified as `pie-loading-complete`,
|
|
21
|
+
* not a stage. (The previous `ready` DOM event alias was removed in
|
|
22
|
+
* the broad architecture review compat sweep.)
|
|
23
|
+
* - **C1** `readiness.mode = "strict"` only delays the `interactive`
|
|
24
|
+
* transition; every earlier stage fires identically across modes.
|
|
25
|
+
* - **D1** One DOM event family `pie-stage-change` with the stage in the
|
|
26
|
+
* payload, mirroring the M3 `framework-error` idiom.
|
|
27
|
+
*
|
|
28
|
+
* Failure semantics deliberately stay in the M3 framework-error contract —
|
|
29
|
+
* `status: "failed"` records the position; the framework error records the
|
|
30
|
+
* cause.
|
|
31
|
+
*/
|
|
32
|
+
export const STAGES = Object.freeze([
|
|
33
|
+
"composed",
|
|
34
|
+
"engine-ready",
|
|
35
|
+
"interactive",
|
|
36
|
+
"disposed",
|
|
37
|
+
]);
|
|
38
|
+
/**
|
|
39
|
+
* Stages that apply to a given CE shape. Post-retro the toolkit and the
|
|
40
|
+
* layout CEs share the same canonical list; `applicableStages` is kept as
|
|
41
|
+
* an indirection so the tracker, telemetry, and tests don't have to be
|
|
42
|
+
* rewritten when a future stage diverges between shapes.
|
|
43
|
+
*/
|
|
44
|
+
export function applicableStages(_sourceCe) {
|
|
45
|
+
return STAGES;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Strict ordering index used by the tracker to detect monotonic
|
|
49
|
+
* violations. `disposed` is last; `composed` is first.
|
|
50
|
+
*/
|
|
51
|
+
export function stageOrdinal(stage) {
|
|
52
|
+
const idx = STAGES.indexOf(stage);
|
|
53
|
+
if (idx === -1) {
|
|
54
|
+
throw new Error(`Unknown stage \`${stage}\``);
|
|
55
|
+
}
|
|
56
|
+
return idx;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=stages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stages.js","sourceRoot":"","sources":["../../src/pie/stages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IACnC,UAAU;IACV,cAAc;IACd,aAAa;IACb,UAAU;CACD,CAAC,CAAC;AAcZ;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,SAAwB;IACxD,OAAO,MAAM,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,KAAY;IACxC,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAClC,IAAI,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,mBAAmB,KAAK,IAAI,CAAC,CAAC;IAC/C,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updates.d.ts","sourceRoot":"","sources":["../../src/pie/updates.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"updates.d.ts","sourceRoot":"","sources":["../../src/pie/updates.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,GAAG,EAAY,MAAM,mBAAmB,CAAC;AAGrE,OAAO,KAAK,EAAc,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAiPtE;;GAEG;AACH,eAAO,MAAM,uBAAuB,GACnC,IAAI,OAAO,EACX,MAAM,uBAAuB,KAC3B,IAUF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAC5B,QAAQ,MAAM,EACd,MAAM,uBAAuB,KAC3B,IAiBF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAC7B,QAAQ,YAAY,EACpB,SAAS,GAAG,EAAE,EACd,KAAK,GAAG,EACR,YAAY,OAAO,GAAG,QAAQ,KAC5B,IAKF,CAAC"}
|
package/dist/pie/updates.js
CHANGED
|
@@ -10,6 +10,50 @@ import { defaultPieElementOptions } from "./types.js";
|
|
|
10
10
|
import { findOrAddSession } from "./utils.js";
|
|
11
11
|
// Create module-level logger (respects global debug flag - pass function for dynamic checking)
|
|
12
12
|
const logger = createPieLogger("pie-updates", () => isGlobalDebugEnabled());
|
|
13
|
+
const describeControllerShape = (controller) => {
|
|
14
|
+
if (!controller)
|
|
15
|
+
return "missing";
|
|
16
|
+
if (typeof controller === "function")
|
|
17
|
+
return "function";
|
|
18
|
+
if (typeof controller !== "object")
|
|
19
|
+
return typeof controller;
|
|
20
|
+
const keys = Object.keys(controller);
|
|
21
|
+
const defaultValue = controller.default;
|
|
22
|
+
const defaultKeys = defaultValue && typeof defaultValue === "object"
|
|
23
|
+
? Object.keys(defaultValue)
|
|
24
|
+
: [];
|
|
25
|
+
return defaultKeys.length > 0
|
|
26
|
+
? `object(keys=[${keys.join(",")}],defaultKeys=[${defaultKeys.join(",")}])`
|
|
27
|
+
: `object(keys=[${keys.join(",")}])`;
|
|
28
|
+
};
|
|
29
|
+
const resolveControllerModelFunction = (controller) => {
|
|
30
|
+
if (!controller)
|
|
31
|
+
return null;
|
|
32
|
+
if (typeof controller === "function") {
|
|
33
|
+
return controller;
|
|
34
|
+
}
|
|
35
|
+
if (typeof controller !== "object")
|
|
36
|
+
return null;
|
|
37
|
+
const direct = controller.model;
|
|
38
|
+
if (typeof direct === "function") {
|
|
39
|
+
return (model, sessionData, env, updateSession) => direct.call(controller, model, sessionData, env, updateSession);
|
|
40
|
+
}
|
|
41
|
+
const fromDefault = controller.default;
|
|
42
|
+
if (fromDefault && typeof fromDefault === "object") {
|
|
43
|
+
const nested = fromDefault.model;
|
|
44
|
+
if (typeof nested === "function") {
|
|
45
|
+
return (model, sessionData, env, updateSession) => nested.call(fromDefault, model, sessionData, env, updateSession);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return null;
|
|
49
|
+
};
|
|
50
|
+
const emitControllerError = (pieElement, detail) => {
|
|
51
|
+
pieElement.dispatchEvent(new CustomEvent("pie-controller-error", {
|
|
52
|
+
detail,
|
|
53
|
+
bubbles: true,
|
|
54
|
+
composed: true,
|
|
55
|
+
}));
|
|
56
|
+
};
|
|
13
57
|
/**
|
|
14
58
|
* Helper function to apply controller to element
|
|
15
59
|
* Extracted to eliminate duplication and ensure consistent controller invocation
|
|
@@ -28,12 +72,19 @@ const applyControllerToElement = async (element, model, elementSession, controll
|
|
|
28
72
|
return Promise.resolve();
|
|
29
73
|
};
|
|
30
74
|
try {
|
|
31
|
-
const
|
|
75
|
+
const modelFunction = resolveControllerModelFunction(controller);
|
|
76
|
+
if (!modelFunction) {
|
|
77
|
+
throw new Error(`Controller contract mismatch: expected a model() function but received ${describeControllerShape(controller)}`);
|
|
78
|
+
}
|
|
79
|
+
const controllerResult = await modelFunction(model, elementSession, env, updateSession);
|
|
32
80
|
// Merge controller result with id and element (like server-side PieControllerExecutor does)
|
|
81
|
+
const controllerResultObject = controllerResult && typeof controllerResult === "object"
|
|
82
|
+
? controllerResult
|
|
83
|
+
: {};
|
|
33
84
|
const filteredModel = {
|
|
34
85
|
id: model.id,
|
|
35
86
|
element: model.element,
|
|
36
|
-
...
|
|
87
|
+
...controllerResultObject,
|
|
37
88
|
};
|
|
38
89
|
logger.debug(`${logPrefix} ✅ Controller filtered model:`, {
|
|
39
90
|
id: filteredModel.id,
|
|
@@ -91,7 +142,19 @@ const updateSinglePieElement = (pieElement, controllerLookupTag, options, logCon
|
|
|
91
142
|
hasCorrectResponse: "correctResponse" in model,
|
|
92
143
|
});
|
|
93
144
|
applyControllerToElement(pieElement, model, elementSession, controller, env, `${logContext}(${controllerLookupTag}#${pieElement.id})`).catch((err) => {
|
|
145
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
146
|
+
const isContractError = errorMessage.includes("Controller contract mismatch");
|
|
94
147
|
logger.error(`${logContext} Controller failed for ${controllerLookupTag}#${pieElement.id}:`, err);
|
|
148
|
+
emitControllerError(pieElement, {
|
|
149
|
+
code: isContractError
|
|
150
|
+
? "PIE_CONTROLLER_CONTRACT_ERROR"
|
|
151
|
+
: "PIE_CONTROLLER_RUNTIME_ERROR",
|
|
152
|
+
message: `${controllerLookupTag} controller failed while applying model for ${pieElement.id}. ${errorMessage}`,
|
|
153
|
+
elementName: controllerLookupTag,
|
|
154
|
+
elementId: pieElement.id,
|
|
155
|
+
controllerShape: describeControllerShape(controller),
|
|
156
|
+
cause: errorMessage,
|
|
157
|
+
});
|
|
95
158
|
// Fall back to raw model on controller error
|
|
96
159
|
pieElement.model = model;
|
|
97
160
|
pieElement.session = elementSession;
|
package/dist/pie/updates.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updates.js","sourceRoot":"","sources":["../../src/pie/updates.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,iCAAiC,EAAE,MAAM,oBAAoB,CAAC;AAEvE,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAA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C,MAAM,iBAAiB,GAAG,CAChC,MAAoB,EACpB,OAAc,EACd,GAAQ,EACR,SAA8B,EACvB,EAAE;IACT,MAAM,CAAC,KAAK,CAAC,qDAAqD,EAAE,GAAG,CAAC,CAAC;IACzE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE;QAC1D,gBAAgB,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC;IAC/D,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-resource-monitor.svelte.d.ts","sourceRoot":"","sources":["../../src/pie/use-resource-monitor.svelte.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAIxD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAKxD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CACjC,cAAc,EAAE,MAAM,WAAW,GAAG,IAAI,EACxC,eAAe,EAAE,MAAM,YAAY,EACnC,eAAe,EAAE,MAAM,OAAO,EAC9B,aAAa,GAAE,MAAqB;
|
|
1
|
+
{"version":3,"file":"use-resource-monitor.svelte.d.ts","sourceRoot":"","sources":["../../src/pie/use-resource-monitor.svelte.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAIxD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAKxD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CACjC,cAAc,EAAE,MAAM,WAAW,GAAG,IAAI,EACxC,eAAe,EAAE,MAAM,YAAY,EACnC,eAAe,EAAE,MAAM,OAAO,EAC9B,aAAa,GAAE,MAAqB;IA+InC;;OAEG;;IAKH;;OAEG;;;;;;;;IAKH;;OAEG;;EAKJ"}
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* </script>
|
|
23
23
|
* ```
|
|
24
24
|
*/
|
|
25
|
-
import { onDestroy } from "svelte";
|
|
25
|
+
import { onDestroy, untrack } from "svelte";
|
|
26
26
|
import { isInstrumentationProvider } from "../instrumentation/provider-guards.js";
|
|
27
27
|
import { DEFAULT_LOADER_CONFIG } from "../loader-config.js";
|
|
28
28
|
import { createPieLogger } from "./logger.js";
|
|
@@ -45,85 +45,98 @@ export function useResourceMonitor(getHostElement, getLoaderConfig, getDebugEnab
|
|
|
45
45
|
let activeHostElement = $state(null);
|
|
46
46
|
let monitorConfigKey = $state("");
|
|
47
47
|
let activeProvider = $state(undefined);
|
|
48
|
-
// Initialize resource monitor when conditions are met
|
|
48
|
+
// Initialize resource monitor when conditions are met.
|
|
49
|
+
//
|
|
50
|
+
// The body of this effect both reads and writes the local `$state`
|
|
51
|
+
// latches (`monitor`, `isInitialized`, `activeHostElement`,
|
|
52
|
+
// `monitorConfigKey`, `activeProvider`) — those latches exist so the
|
|
53
|
+
// public `instance`/`isActive` getters stay reactive for downstream
|
|
54
|
+
// consumers, but the same-effect read+write would otherwise trip
|
|
55
|
+
// `effect_update_depth_exceeded` on every host/config/provider change
|
|
56
|
+
// (observed in the assessment-player smoke flow during instrumentation
|
|
57
|
+
// provider rebinding). Per `.cursor/rules/svelte-subscription-safety.mdc`,
|
|
58
|
+
// we explicitly track only the input getters and run the body inside
|
|
59
|
+
// `untrack(...)` so the self-mutations don't re-trigger the effect.
|
|
49
60
|
$effect(() => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
loaderConfig?.instrumentationProvider
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
});
|
|
72
|
-
const providerChanged = activeProvider !== resolvedInstrumentationProvider;
|
|
73
|
-
const hostChanged = activeHostElement !== hostElement;
|
|
74
|
-
const configChanged = monitorConfigKey !== nextConfigKey;
|
|
75
|
-
const shouldReinitialize = hostElement && isInitialized && (hostChanged || configChanged || providerChanged);
|
|
76
|
-
// Clean up existing monitor if host element becomes null
|
|
77
|
-
if (!hostElement && monitor) {
|
|
78
|
-
logger.debug(`Host element removed, stopping resource monitor for ${componentName}`);
|
|
79
|
-
monitor.stop();
|
|
80
|
-
monitor = null;
|
|
81
|
-
isInitialized = false;
|
|
82
|
-
activeHostElement = null;
|
|
83
|
-
activeProvider = undefined;
|
|
84
|
-
monitorConfigKey = "";
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
if (shouldReinitialize && monitor) {
|
|
88
|
-
logger.debug(`Reinitializing resource monitor for ${componentName}`, {
|
|
89
|
-
hostChanged,
|
|
90
|
-
configChanged,
|
|
91
|
-
providerChanged,
|
|
92
|
-
});
|
|
93
|
-
monitor.stop();
|
|
94
|
-
monitor = null;
|
|
95
|
-
isInitialized = false;
|
|
96
|
-
}
|
|
97
|
-
// Initialize if we have a host element (retry logic works independently of trackPageActions)
|
|
98
|
-
if (hostElement && !isInitialized) {
|
|
99
|
-
logger.debug(`Initializing resource monitor for ${componentName}`, {
|
|
61
|
+
void getHostElement();
|
|
62
|
+
void getLoaderConfig();
|
|
63
|
+
void getDebugEnabled();
|
|
64
|
+
untrack(() => {
|
|
65
|
+
const hostElement = getHostElement();
|
|
66
|
+
const loaderConfig = getLoaderConfig();
|
|
67
|
+
const debugEnabled = getDebugEnabled();
|
|
68
|
+
const resolvedTrackPageActions = loaderConfig?.trackPageActions ?? false;
|
|
69
|
+
const resolvedMaxRetries = loaderConfig?.maxResourceRetries ??
|
|
70
|
+
DEFAULT_LOADER_CONFIG.maxResourceRetries;
|
|
71
|
+
const resolvedRetryDelay = loaderConfig?.resourceRetryDelay ??
|
|
72
|
+
DEFAULT_LOADER_CONFIG.resourceRetryDelay;
|
|
73
|
+
const resolvedInstrumentationProvider = isInstrumentationProvider(loaderConfig?.instrumentationProvider)
|
|
74
|
+
? loaderConfig?.instrumentationProvider
|
|
75
|
+
: undefined;
|
|
76
|
+
if (debugEnabled &&
|
|
77
|
+
loaderConfig?.instrumentationProvider &&
|
|
78
|
+
!resolvedInstrumentationProvider) {
|
|
79
|
+
logger.warn(`Ignoring invalid instrumentation provider for ${componentName}; expected InstrumentationProvider contract`);
|
|
80
|
+
}
|
|
81
|
+
const nextConfigKey = JSON.stringify({
|
|
100
82
|
trackPageActions: resolvedTrackPageActions,
|
|
101
83
|
maxRetries: resolvedMaxRetries,
|
|
102
84
|
retryDelay: resolvedRetryDelay,
|
|
103
|
-
|
|
104
|
-
hasContainer: !!hostElement,
|
|
85
|
+
debugEnabled,
|
|
105
86
|
});
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
(
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
87
|
+
const providerChanged = activeProvider !== resolvedInstrumentationProvider;
|
|
88
|
+
const hostChanged = activeHostElement !== hostElement;
|
|
89
|
+
const configChanged = monitorConfigKey !== nextConfigKey;
|
|
90
|
+
const shouldReinitialize = hostElement && isInitialized && (hostChanged || configChanged || providerChanged);
|
|
91
|
+
if (!hostElement && monitor) {
|
|
92
|
+
logger.debug(`Host element removed, stopping resource monitor for ${componentName}`);
|
|
93
|
+
monitor.stop();
|
|
94
|
+
monitor = null;
|
|
95
|
+
isInitialized = false;
|
|
96
|
+
activeHostElement = null;
|
|
97
|
+
activeProvider = undefined;
|
|
98
|
+
monitorConfigKey = "";
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (shouldReinitialize && monitor) {
|
|
102
|
+
logger.debug(`Reinitializing resource monitor for ${componentName}`, {
|
|
103
|
+
hostChanged,
|
|
104
|
+
configChanged,
|
|
105
|
+
providerChanged,
|
|
106
|
+
});
|
|
107
|
+
monitor.stop();
|
|
108
|
+
monitor = null;
|
|
109
|
+
isInitialized = false;
|
|
110
|
+
}
|
|
111
|
+
if (hostElement && !isInitialized) {
|
|
112
|
+
logger.debug(`Initializing resource monitor for ${componentName}`, {
|
|
113
|
+
trackPageActions: resolvedTrackPageActions,
|
|
114
|
+
maxRetries: resolvedMaxRetries,
|
|
115
|
+
retryDelay: resolvedRetryDelay,
|
|
116
|
+
hasCustomProvider: !!resolvedInstrumentationProvider,
|
|
117
|
+
hasContainer: !!hostElement,
|
|
118
|
+
});
|
|
119
|
+
monitor = new ResourceMonitor({
|
|
120
|
+
trackPageActions: resolvedTrackPageActions,
|
|
121
|
+
instrumentationProvider: resolvedInstrumentationProvider,
|
|
122
|
+
maxRetries: resolvedMaxRetries,
|
|
123
|
+
initialRetryDelay: resolvedRetryDelay,
|
|
124
|
+
maxRetryDelay: DEFAULT_MAX_RETRY_DELAY,
|
|
125
|
+
debug: debugEnabled,
|
|
126
|
+
});
|
|
127
|
+
monitor.start(hostElement);
|
|
128
|
+
isInitialized = true;
|
|
129
|
+
activeHostElement = hostElement;
|
|
130
|
+
activeProvider = resolvedInstrumentationProvider;
|
|
131
|
+
monitorConfigKey = nextConfigKey;
|
|
132
|
+
logger.info(`✅ Resource monitoring enabled for ${componentName}` +
|
|
133
|
+
(resolvedTrackPageActions
|
|
134
|
+
? resolvedInstrumentationProvider
|
|
135
|
+
? " (with custom instrumentation provider)"
|
|
136
|
+
: " (with New Relic tracking)"
|
|
137
|
+
: " (retry only)"));
|
|
138
|
+
}
|
|
139
|
+
});
|
|
127
140
|
});
|
|
128
141
|
// Cleanup on component destroy
|
|
129
142
|
onDestroy(() => {
|