@patch-adams/core 1.5.20 → 1.5.21
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/dist/cli.cjs +37 -9
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +37 -9
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +37 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +37 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1971,22 +1971,28 @@ function generateLrsBridgeCode(options) {
|
|
|
1971
1971
|
|
|
1972
1972
|
/**
|
|
1973
1973
|
* Get the best available actor for statement building.
|
|
1974
|
-
*
|
|
1974
|
+
* ALWAYS checks localStorage because the skin overlay in another frame
|
|
1975
|
+
* may have updated the actor AFTER this bridge instance initialized.
|
|
1976
|
+
* (e.g., user enters email in skin overlay \u2192 actor persisted to localStorage,
|
|
1977
|
+
* but the bridge in scormcontent/index.html already loaded a stale actor at init)
|
|
1975
1978
|
*/
|
|
1976
1979
|
function getActor() {
|
|
1977
|
-
//
|
|
1978
|
-
|
|
1979
|
-
return LRS.actor;
|
|
1980
|
-
}
|
|
1981
|
-
// Check localStorage for actor set by another frame (e.g., skin overlay)
|
|
1980
|
+
// Always check localStorage for the freshest actor \u2014 it may have been
|
|
1981
|
+
// updated by the skin overlay in another frame since our init
|
|
1982
1982
|
var shared = loadSharedActor();
|
|
1983
1983
|
if (shared) {
|
|
1984
|
-
//
|
|
1984
|
+
// Only update if different from current (avoid unnecessary log spam)
|
|
1985
|
+
if (!LRS.actor || LRS.actor.name !== shared.name ||
|
|
1986
|
+
(LRS.actor.account && shared.account && LRS.actor.account.name !== shared.account.name)) {
|
|
1987
|
+
log('Actor updated from cross-frame storage:', shared.name);
|
|
1988
|
+
}
|
|
1985
1989
|
LRS.actor = shared;
|
|
1986
|
-
log('Actor loaded from cross-frame storage:', shared.name);
|
|
1987
1990
|
return shared;
|
|
1988
1991
|
}
|
|
1989
1992
|
// Fallback to current actor or re-extract
|
|
1993
|
+
if (LRS.actor && !isAnonymousActor(LRS.actor)) {
|
|
1994
|
+
return LRS.actor;
|
|
1995
|
+
}
|
|
1990
1996
|
return LRS.actor || extractActor();
|
|
1991
1997
|
}
|
|
1992
1998
|
|
|
@@ -1997,7 +2003,9 @@ function generateLrsBridgeCode(options) {
|
|
|
1997
2003
|
LRS.setActor = function(actor) {
|
|
1998
2004
|
LRS.actor = actor;
|
|
1999
2005
|
persistActor(actor);
|
|
2000
|
-
|
|
2006
|
+
|
|
2007
|
+
// Propagate to ALL frames: walk UP parent chain AND DOWN into child iframes
|
|
2008
|
+
// UP: parent frames (e.g., if skin is in a child iframe)
|
|
2001
2009
|
try {
|
|
2002
2010
|
var w = window;
|
|
2003
2011
|
for (var i = 0; i < 10; i++) {
|
|
@@ -2010,9 +2018,29 @@ function generateLrsBridgeCode(options) {
|
|
|
2010
2018
|
w = w.parent;
|
|
2011
2019
|
}
|
|
2012
2020
|
} catch (e) {}
|
|
2021
|
+
|
|
2022
|
+
// DOWN: child iframes (e.g., scormcontent/index.html has its own bridge)
|
|
2023
|
+
function setActorInChildren(win) {
|
|
2024
|
+
try {
|
|
2025
|
+
var frames = win.frames;
|
|
2026
|
+
for (var j = 0; j < frames.length; j++) {
|
|
2027
|
+
try {
|
|
2028
|
+
if (frames[j].pa_patcher && frames[j].pa_patcher.lrs) {
|
|
2029
|
+
frames[j].pa_patcher.lrs.actor = actor;
|
|
2030
|
+
log('Actor propagated to child frame', j);
|
|
2031
|
+
}
|
|
2032
|
+
// Recurse into nested iframes
|
|
2033
|
+
setActorInChildren(frames[j]);
|
|
2034
|
+
} catch (e) { /* cross-origin child */ }
|
|
2035
|
+
}
|
|
2036
|
+
} catch (e) {}
|
|
2037
|
+
}
|
|
2038
|
+
setActorInChildren(window);
|
|
2039
|
+
|
|
2013
2040
|
if (window.console && window.console.info) {
|
|
2014
2041
|
console.info('[PA-LRS] Actor set:', actor.name,
|
|
2015
2042
|
actor.mbox ? '(' + actor.mbox + ')' : '',
|
|
2043
|
+
actor.account ? '(account: ' + actor.account.name + ')' : '',
|
|
2016
2044
|
'\u2014 shared across frames');
|
|
2017
2045
|
}
|
|
2018
2046
|
};
|