@patch-adams/core 1.4.24 → 1.4.26
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 +70 -39
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +70 -39
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +70 -39
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +70 -39
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -613,13 +613,13 @@ html.${htmlClass}.${loadingClass} body {
|
|
|
613
613
|
var link = loadCSSSync(REMOTE_URL);
|
|
614
614
|
|
|
615
615
|
link.onerror = function() {
|
|
616
|
-
console.warn('[
|
|
616
|
+
console.warn('[PA-Patcher] CSS before failed to load from remote, using local fallback');
|
|
617
617
|
document.head.removeChild(link);
|
|
618
618
|
loadCSSSync(LOCAL_PATH);
|
|
619
619
|
};
|
|
620
620
|
|
|
621
621
|
link.onload = function() {
|
|
622
|
-
console.log('[
|
|
622
|
+
console.log('[PA-Patcher] CSS before loaded from remote:', REMOTE_URL);
|
|
623
623
|
};
|
|
624
624
|
})();
|
|
625
625
|
</script>`;
|
|
@@ -673,7 +673,7 @@ function generateCssAfterLoader(options) {
|
|
|
673
673
|
if (loaded) return;
|
|
674
674
|
loaded = true;
|
|
675
675
|
clearTimeout(timeoutId);
|
|
676
|
-
console.log('[
|
|
676
|
+
console.log('[PA-Patcher] CSS after loaded from remote:', REMOTE_URL);
|
|
677
677
|
},
|
|
678
678
|
function() {
|
|
679
679
|
if (loaded) return;
|
|
@@ -687,7 +687,7 @@ function generateCssAfterLoader(options) {
|
|
|
687
687
|
timeoutId = setTimeout(function() {
|
|
688
688
|
if (loaded) return;
|
|
689
689
|
loaded = true;
|
|
690
|
-
console.warn('[
|
|
690
|
+
console.warn('[PA-Patcher] CSS after timed out, using local fallback');
|
|
691
691
|
if (remoteLink.parentNode) {
|
|
692
692
|
document.head.removeChild(remoteLink);
|
|
693
693
|
}
|
|
@@ -699,10 +699,10 @@ function generateCssAfterLoader(options) {
|
|
|
699
699
|
loadCSS(
|
|
700
700
|
LOCAL_PATH,
|
|
701
701
|
function() {
|
|
702
|
-
console.log('[
|
|
702
|
+
console.log('[PA-Patcher] CSS after loaded from local fallback:', LOCAL_PATH);
|
|
703
703
|
},
|
|
704
704
|
function() {
|
|
705
|
-
console.error('[
|
|
705
|
+
console.error('[PA-Patcher] CSS after failed to load from both remote and local');
|
|
706
706
|
}
|
|
707
707
|
);
|
|
708
708
|
}
|
|
@@ -1667,7 +1667,9 @@ function generateLrsBridgeCode(options) {
|
|
|
1667
1667
|
((employee.fname || employee.firstName || '') + ' ' + (employee.lname || employee.lastName || '')).trim(),
|
|
1668
1668
|
firstName: employee.fname || employee.firstName || employee.first_name,
|
|
1669
1669
|
lastName: employee.lname || employee.lastName || employee.last_name,
|
|
1670
|
-
employeeId: employee.emp_id || employee.employeeId || employee.employee_id || employeeId
|
|
1670
|
+
employeeId: employee.emp_id || employee.employeeId || employee.employee_id || employeeId,
|
|
1671
|
+
bravaisUserId: employee.bravaisUserId || null,
|
|
1672
|
+
tenantUrl: employee.tenantUrl || null
|
|
1671
1673
|
};
|
|
1672
1674
|
log('Parsed employee data:', employeeLookupData);
|
|
1673
1675
|
// Persist to localStorage for cross-session caching
|
|
@@ -1741,6 +1743,16 @@ function generateLrsBridgeCode(options) {
|
|
|
1741
1743
|
if (employeeData.name && (!actor.name || actor.name === 'Unknown Learner')) {
|
|
1742
1744
|
actor.name = employeeData.name;
|
|
1743
1745
|
}
|
|
1746
|
+
|
|
1747
|
+
// Update account with Bravais user ID and tenant URL if available
|
|
1748
|
+
if (employeeData.bravaisUserId) {
|
|
1749
|
+
var originalAccountName = actor.account ? actor.account.name : null;
|
|
1750
|
+
actor.account = {
|
|
1751
|
+
name: employeeData.bravaisUserId,
|
|
1752
|
+
homePage: employeeData.tenantUrl || (actor.account && actor.account.homePage) || window.location.origin
|
|
1753
|
+
};
|
|
1754
|
+
log('Updated actor account: bravaisUserId=' + employeeData.bravaisUserId + ', homePage=' + actor.account.homePage + ' (was: ' + originalAccountName + ')');
|
|
1755
|
+
}
|
|
1744
1756
|
}
|
|
1745
1757
|
callback(actor);
|
|
1746
1758
|
});
|
|
@@ -1823,16 +1835,9 @@ function generateLrsBridgeCode(options) {
|
|
|
1823
1835
|
name: scormLearnerId
|
|
1824
1836
|
}
|
|
1825
1837
|
};
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
var parts = scormLearnerName.split(',');
|
|
1830
|
-
actor.name = (parts[1] || '').trim() + ' ' + (parts[0] || '').trim();
|
|
1831
|
-
} else {
|
|
1832
|
-
actor.name = scormLearnerName;
|
|
1833
|
-
}
|
|
1834
|
-
}
|
|
1835
|
-
log('Actor source: SCORM API');
|
|
1838
|
+
// Don't use SCORM student_name - it's unreliable ("Last, First" format varies by LMS).
|
|
1839
|
+
// The employee API lookup will provide the correct name and email.
|
|
1840
|
+
log('Actor source: SCORM API (id only, name from employee lookup)');
|
|
1836
1841
|
LRS.actor = actor;
|
|
1837
1842
|
return actor;
|
|
1838
1843
|
}
|
|
@@ -2412,7 +2417,7 @@ function generateLrsBridgeCode(options) {
|
|
|
2412
2417
|
tenantHomepage: null // https://{tenant}.bravais.com format
|
|
2413
2418
|
};
|
|
2414
2419
|
|
|
2415
|
-
// 0. Use baked-in GUIDs from
|
|
2420
|
+
// 0. Use baked-in GUIDs from PA-Patcher config (highest priority - set at wrap time)
|
|
2416
2421
|
if (DOCUMENT_GUID) {
|
|
2417
2422
|
info.guid = DOCUMENT_GUID;
|
|
2418
2423
|
info.id = 'http://xyleme.com/bravais/document/' + DOCUMENT_GUID;
|
|
@@ -2921,6 +2926,11 @@ function generateLrsBridgeCode(options) {
|
|
|
2921
2926
|
// Publish index (default to 1)
|
|
2922
2927
|
ctx.extensions['publishIndex'] = (LRS.courseInfo && LRS.courseInfo.publishIndex) ? LRS.courseInfo.publishIndex : 1;
|
|
2923
2928
|
|
|
2929
|
+
// Employee ID from employee lookup (if available)
|
|
2930
|
+
if (employeeLookupData && employeeLookupData.employeeId) {
|
|
2931
|
+
ctx.extensions['employeeId'] = employeeLookupData.employeeId;
|
|
2932
|
+
}
|
|
2933
|
+
|
|
2924
2934
|
// Xyleme schema version and PII flag
|
|
2925
2935
|
ctx.extensions['http://xyleme.com/bravais/extensions/statement-schema'] = 'xyleme_10';
|
|
2926
2936
|
ctx.extensions['http://xyleme.com/bravais/extensions/protect_pii'] = false;
|
|
@@ -3640,6 +3650,27 @@ function generateLrsBridgeCode(options) {
|
|
|
3640
3650
|
* because the bridge initializes in <head> before LMSInitialize runs.
|
|
3641
3651
|
*/
|
|
3642
3652
|
LRS.refreshActor = function(callback) {
|
|
3653
|
+
// If SCORM API wasn't found during <head> init, re-scan now
|
|
3654
|
+
// (some LMS inject window.API after page starts loading)
|
|
3655
|
+
if (!LRS.scormApi) {
|
|
3656
|
+
log('refreshActor: SCORM API missing, re-scanning...');
|
|
3657
|
+
var api2004 = findAPIInFrameHierarchy('API_1484_11', 10);
|
|
3658
|
+
if (api2004) {
|
|
3659
|
+
LRS.scormApi = api2004.api;
|
|
3660
|
+
LRS.scormApiFound = true;
|
|
3661
|
+
LRS.scormApiType = '2004';
|
|
3662
|
+
log('refreshActor: found SCORM 2004 API');
|
|
3663
|
+
} else {
|
|
3664
|
+
var api12 = findAPIInFrameHierarchy('API', 10);
|
|
3665
|
+
if (api12) {
|
|
3666
|
+
LRS.scormApi = api12.api;
|
|
3667
|
+
LRS.scormApiFound = true;
|
|
3668
|
+
LRS.scormApiType = '1.2';
|
|
3669
|
+
log('refreshActor: found SCORM 1.2 API');
|
|
3670
|
+
}
|
|
3671
|
+
}
|
|
3672
|
+
}
|
|
3673
|
+
|
|
3643
3674
|
// Always-visible diagnostic: confirm refreshActor is being called and show SCORM data (TEMPORARY)
|
|
3644
3675
|
if (window.console && window.console.info) {
|
|
3645
3676
|
var scormId = 'n/a', scormName = 'n/a';
|
|
@@ -4568,7 +4599,7 @@ ${courseLines.join("\n")}
|
|
|
4568
4599
|
},` : "";
|
|
4569
4600
|
return `<!-- === PATCH-ADAMS: JS BEFORE (blocking) === -->
|
|
4570
4601
|
<script data-pa="js-before-loader">
|
|
4571
|
-
// Initialize
|
|
4602
|
+
// Initialize PA-Patcher global namespace IMMEDIATELY (before IIFE)
|
|
4572
4603
|
window.pa_patcher = window.pa_patcher || {
|
|
4573
4604
|
version: '1.0.25',
|
|
4574
4605
|
htmlClass: '${htmlClass}',
|
|
@@ -4613,7 +4644,7 @@ window.pa_patcher = window.pa_patcher || {
|
|
|
4613
4644
|
if (isExtensionError(event.reason)) {
|
|
4614
4645
|
event.preventDefault();
|
|
4615
4646
|
event.stopImmediatePropagation();
|
|
4616
|
-
console.debug('[
|
|
4647
|
+
console.debug('[PA-Patcher] Suppressed browser extension error:', event.reason);
|
|
4617
4648
|
return false;
|
|
4618
4649
|
}
|
|
4619
4650
|
}, true);
|
|
@@ -4623,7 +4654,7 @@ window.pa_patcher = window.pa_patcher || {
|
|
|
4623
4654
|
if (isExtensionError(event.error || event.message)) {
|
|
4624
4655
|
event.preventDefault();
|
|
4625
4656
|
event.stopImmediatePropagation();
|
|
4626
|
-
console.debug('[
|
|
4657
|
+
console.debug('[PA-Patcher] Suppressed browser extension error:', event.message);
|
|
4627
4658
|
return false;
|
|
4628
4659
|
}
|
|
4629
4660
|
}, true);
|
|
@@ -4648,17 +4679,17 @@ window.pa_patcher = window.pa_patcher || {
|
|
|
4648
4679
|
var script = loadJSSync(REMOTE_URL);
|
|
4649
4680
|
|
|
4650
4681
|
script.onerror = function() {
|
|
4651
|
-
console.warn('[
|
|
4682
|
+
console.warn('[PA-Patcher] JS before failed to load from remote, using local fallback');
|
|
4652
4683
|
document.head.removeChild(script);
|
|
4653
4684
|
var fallback = loadJSSync(LOCAL_PATH);
|
|
4654
4685
|
fallback.onload = function() {
|
|
4655
4686
|
if (window.pa_patcher && window.pa_patcher.loaded) {
|
|
4656
4687
|
window.pa_patcher.loaded.jsBefore = true;
|
|
4657
4688
|
}
|
|
4658
|
-
console.log('[
|
|
4689
|
+
console.log('[PA-Patcher] JS before loaded from local fallback:', LOCAL_PATH);
|
|
4659
4690
|
};
|
|
4660
4691
|
fallback.onerror = function() {
|
|
4661
|
-
console.error('[
|
|
4692
|
+
console.error('[PA-Patcher] JS before failed to load from both remote and local');
|
|
4662
4693
|
};
|
|
4663
4694
|
};
|
|
4664
4695
|
|
|
@@ -4666,7 +4697,7 @@ window.pa_patcher = window.pa_patcher || {
|
|
|
4666
4697
|
if (window.pa_patcher && window.pa_patcher.loaded) {
|
|
4667
4698
|
window.pa_patcher.loaded.jsBefore = true;
|
|
4668
4699
|
}
|
|
4669
|
-
console.log('[
|
|
4700
|
+
console.log('[PA-Patcher] JS before loaded from remote:', REMOTE_URL);
|
|
4670
4701
|
};
|
|
4671
4702
|
})();
|
|
4672
4703
|
${lrsBridgeCode}
|
|
@@ -4737,14 +4768,14 @@ function generateJsAfterLoader(options) {
|
|
|
4737
4768
|
if (window.pa_patcher && window.pa_patcher.loaded) {
|
|
4738
4769
|
window.pa_patcher.loaded.jsAfter = true;
|
|
4739
4770
|
}
|
|
4740
|
-
console.log('[
|
|
4771
|
+
console.log('[PA-Patcher] Loading complete, content revealed');
|
|
4741
4772
|
|
|
4742
4773
|
// Add visual badge to indicate patching is active
|
|
4743
4774
|
var badge = document.createElement('div');
|
|
4744
4775
|
badge.setAttribute('data-pa', 'badge');
|
|
4745
4776
|
badge.style.cssText = 'position:fixed;bottom:10px;right:10px;background:#4CAF50;color:white;padding:4px 8px;border-radius:4px;font-size:11px;font-family:sans-serif;z-index:999999;opacity:0.8;cursor:pointer;';
|
|
4746
4777
|
badge.textContent = 'PA';
|
|
4747
|
-
badge.title = '
|
|
4778
|
+
badge.title = 'PA-Patcher Active';
|
|
4748
4779
|
badge.onclick = function() { badge.style.display = 'none'; };
|
|
4749
4780
|
document.body.appendChild(badge);
|
|
4750
4781
|
}
|
|
@@ -4760,7 +4791,7 @@ function generateJsAfterLoader(options) {
|
|
|
4760
4791
|
if (loaded) return;
|
|
4761
4792
|
loaded = true;
|
|
4762
4793
|
clearTimeout(timeoutId);
|
|
4763
|
-
console.log('[
|
|
4794
|
+
console.log('[PA-Patcher] JS after loaded from remote:', REMOTE_URL);
|
|
4764
4795
|
// Give the script a moment to execute, then remove loading class
|
|
4765
4796
|
setTimeout(removeLoadingClass, 50);
|
|
4766
4797
|
},
|
|
@@ -4776,7 +4807,7 @@ function generateJsAfterLoader(options) {
|
|
|
4776
4807
|
timeoutId = setTimeout(function() {
|
|
4777
4808
|
if (loaded) return;
|
|
4778
4809
|
loaded = true;
|
|
4779
|
-
console.warn('[
|
|
4810
|
+
console.warn('[PA-Patcher] JS after timed out, using local fallback');
|
|
4780
4811
|
if (remoteScript.parentNode) {
|
|
4781
4812
|
document.body.removeChild(remoteScript);
|
|
4782
4813
|
}
|
|
@@ -4788,11 +4819,11 @@ function generateJsAfterLoader(options) {
|
|
|
4788
4819
|
loadJS(
|
|
4789
4820
|
LOCAL_PATH,
|
|
4790
4821
|
function() {
|
|
4791
|
-
console.log('[
|
|
4822
|
+
console.log('[PA-Patcher] JS after loaded from local fallback:', LOCAL_PATH);
|
|
4792
4823
|
setTimeout(removeLoadingClass, 50);
|
|
4793
4824
|
},
|
|
4794
4825
|
function() {
|
|
4795
|
-
console.error('[
|
|
4826
|
+
console.error('[PA-Patcher] JS after failed to load from both remote and local');
|
|
4796
4827
|
// Still remove loading class so content is visible even if JS fails
|
|
4797
4828
|
removeLoadingClass();
|
|
4798
4829
|
}
|
|
@@ -5252,7 +5283,7 @@ var ManifestUpdater = class {
|
|
|
5252
5283
|
const resourceClosePattern = /(\s*)<\/resource>/i;
|
|
5253
5284
|
const match = xmlContent.match(resourceClosePattern);
|
|
5254
5285
|
if (!match) {
|
|
5255
|
-
console.warn("[
|
|
5286
|
+
console.warn("[PA-Patcher] Could not find </resource> tag in imsmanifest.xml");
|
|
5256
5287
|
return [];
|
|
5257
5288
|
}
|
|
5258
5289
|
const updatedXml = xmlContent.replace(
|
|
@@ -5264,7 +5295,7 @@ $1</resource>`
|
|
|
5264
5295
|
zip.updateFile("imsmanifest.xml", Buffer.from(updatedXml, "utf-8"));
|
|
5265
5296
|
return ["imsmanifest.xml"];
|
|
5266
5297
|
} catch (error) {
|
|
5267
|
-
console.error("[
|
|
5298
|
+
console.error("[PA-Patcher] Failed to update imsmanifest.xml:", error);
|
|
5268
5299
|
return [];
|
|
5269
5300
|
}
|
|
5270
5301
|
}
|
|
@@ -5586,7 +5617,7 @@ ${js.after}
|
|
|
5586
5617
|
var pluginRegistry = new PluginRegistry();
|
|
5587
5618
|
|
|
5588
5619
|
// src/patcher/index.ts
|
|
5589
|
-
var DEFAULT_CSS_BEFORE = `/*
|
|
5620
|
+
var DEFAULT_CSS_BEFORE = `/* PA-Patcher: CSS Before (blocking)
|
|
5590
5621
|
* This file loads at the start of <head> and blocks rendering.
|
|
5591
5622
|
* Use it to hide content and prevent flash of unstyled content.
|
|
5592
5623
|
*
|
|
@@ -5596,7 +5627,7 @@ var DEFAULT_CSS_BEFORE = `/* Patch-Adams: CSS Before (blocking)
|
|
|
5596
5627
|
* }
|
|
5597
5628
|
*/
|
|
5598
5629
|
`;
|
|
5599
|
-
var DEFAULT_CSS_AFTER = `/*
|
|
5630
|
+
var DEFAULT_CSS_AFTER = `/* PA-Patcher: CSS After (async)
|
|
5600
5631
|
* This file loads at the end of <head> with remote fallback.
|
|
5601
5632
|
* Use it for style overrides that take precedence over Rise styles.
|
|
5602
5633
|
*
|
|
@@ -5606,7 +5637,7 @@ var DEFAULT_CSS_AFTER = `/* Patch-Adams: CSS After (async)
|
|
|
5606
5637
|
* }
|
|
5607
5638
|
*/
|
|
5608
5639
|
`;
|
|
5609
|
-
var DEFAULT_JS_BEFORE = `//
|
|
5640
|
+
var DEFAULT_JS_BEFORE = `// PA-Patcher: JS Before (blocking)
|
|
5610
5641
|
// This file loads at the start of <head> and blocks rendering.
|
|
5611
5642
|
// Use it for setup, API interception, and preparing globals.
|
|
5612
5643
|
//
|
|
@@ -5616,9 +5647,9 @@ var DEFAULT_JS_BEFORE = `// Patch-Adams: JS Before (blocking)
|
|
|
5616
5647
|
// analytics: true
|
|
5617
5648
|
// };
|
|
5618
5649
|
|
|
5619
|
-
console.log('[
|
|
5650
|
+
console.log('[PA-Patcher] JS Before loaded');
|
|
5620
5651
|
`;
|
|
5621
|
-
var DEFAULT_JS_AFTER = `//
|
|
5652
|
+
var DEFAULT_JS_AFTER = `// PA-Patcher: JS After (async)
|
|
5622
5653
|
// This file loads at the end of <body> with remote fallback.
|
|
5623
5654
|
// Use it for DOM manipulation after Rise has initialized.
|
|
5624
5655
|
//
|
|
@@ -5630,7 +5661,7 @@ var DEFAULT_JS_AFTER = `// Patch-Adams: JS After (async)
|
|
|
5630
5661
|
// // Your modifications here
|
|
5631
5662
|
// });
|
|
5632
5663
|
|
|
5633
|
-
console.log('[
|
|
5664
|
+
console.log('[PA-Patcher] JS After loaded');
|
|
5634
5665
|
`;
|
|
5635
5666
|
var Patcher = class {
|
|
5636
5667
|
config;
|