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