@patch-adams/core 1.4.25 → 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 +46 -29
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +46 -29
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +46 -29
- 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 +46 -29
- 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
|
});
|
|
@@ -2405,7 +2417,7 @@ function generateLrsBridgeCode(options) {
|
|
|
2405
2417
|
tenantHomepage: null // https://{tenant}.bravais.com format
|
|
2406
2418
|
};
|
|
2407
2419
|
|
|
2408
|
-
// 0. Use baked-in GUIDs from
|
|
2420
|
+
// 0. Use baked-in GUIDs from PA-Patcher config (highest priority - set at wrap time)
|
|
2409
2421
|
if (DOCUMENT_GUID) {
|
|
2410
2422
|
info.guid = DOCUMENT_GUID;
|
|
2411
2423
|
info.id = 'http://xyleme.com/bravais/document/' + DOCUMENT_GUID;
|
|
@@ -2914,6 +2926,11 @@ function generateLrsBridgeCode(options) {
|
|
|
2914
2926
|
// Publish index (default to 1)
|
|
2915
2927
|
ctx.extensions['publishIndex'] = (LRS.courseInfo && LRS.courseInfo.publishIndex) ? LRS.courseInfo.publishIndex : 1;
|
|
2916
2928
|
|
|
2929
|
+
// Employee ID from employee lookup (if available)
|
|
2930
|
+
if (employeeLookupData && employeeLookupData.employeeId) {
|
|
2931
|
+
ctx.extensions['employeeId'] = employeeLookupData.employeeId;
|
|
2932
|
+
}
|
|
2933
|
+
|
|
2917
2934
|
// Xyleme schema version and PII flag
|
|
2918
2935
|
ctx.extensions['http://xyleme.com/bravais/extensions/statement-schema'] = 'xyleme_10';
|
|
2919
2936
|
ctx.extensions['http://xyleme.com/bravais/extensions/protect_pii'] = false;
|
|
@@ -4582,7 +4599,7 @@ ${courseLines.join("\n")}
|
|
|
4582
4599
|
},` : "";
|
|
4583
4600
|
return `<!-- === PATCH-ADAMS: JS BEFORE (blocking) === -->
|
|
4584
4601
|
<script data-pa="js-before-loader">
|
|
4585
|
-
// Initialize
|
|
4602
|
+
// Initialize PA-Patcher global namespace IMMEDIATELY (before IIFE)
|
|
4586
4603
|
window.pa_patcher = window.pa_patcher || {
|
|
4587
4604
|
version: '1.0.25',
|
|
4588
4605
|
htmlClass: '${htmlClass}',
|
|
@@ -4627,7 +4644,7 @@ window.pa_patcher = window.pa_patcher || {
|
|
|
4627
4644
|
if (isExtensionError(event.reason)) {
|
|
4628
4645
|
event.preventDefault();
|
|
4629
4646
|
event.stopImmediatePropagation();
|
|
4630
|
-
console.debug('[
|
|
4647
|
+
console.debug('[PA-Patcher] Suppressed browser extension error:', event.reason);
|
|
4631
4648
|
return false;
|
|
4632
4649
|
}
|
|
4633
4650
|
}, true);
|
|
@@ -4637,7 +4654,7 @@ window.pa_patcher = window.pa_patcher || {
|
|
|
4637
4654
|
if (isExtensionError(event.error || event.message)) {
|
|
4638
4655
|
event.preventDefault();
|
|
4639
4656
|
event.stopImmediatePropagation();
|
|
4640
|
-
console.debug('[
|
|
4657
|
+
console.debug('[PA-Patcher] Suppressed browser extension error:', event.message);
|
|
4641
4658
|
return false;
|
|
4642
4659
|
}
|
|
4643
4660
|
}, true);
|
|
@@ -4662,17 +4679,17 @@ window.pa_patcher = window.pa_patcher || {
|
|
|
4662
4679
|
var script = loadJSSync(REMOTE_URL);
|
|
4663
4680
|
|
|
4664
4681
|
script.onerror = function() {
|
|
4665
|
-
console.warn('[
|
|
4682
|
+
console.warn('[PA-Patcher] JS before failed to load from remote, using local fallback');
|
|
4666
4683
|
document.head.removeChild(script);
|
|
4667
4684
|
var fallback = loadJSSync(LOCAL_PATH);
|
|
4668
4685
|
fallback.onload = function() {
|
|
4669
4686
|
if (window.pa_patcher && window.pa_patcher.loaded) {
|
|
4670
4687
|
window.pa_patcher.loaded.jsBefore = true;
|
|
4671
4688
|
}
|
|
4672
|
-
console.log('[
|
|
4689
|
+
console.log('[PA-Patcher] JS before loaded from local fallback:', LOCAL_PATH);
|
|
4673
4690
|
};
|
|
4674
4691
|
fallback.onerror = function() {
|
|
4675
|
-
console.error('[
|
|
4692
|
+
console.error('[PA-Patcher] JS before failed to load from both remote and local');
|
|
4676
4693
|
};
|
|
4677
4694
|
};
|
|
4678
4695
|
|
|
@@ -4680,7 +4697,7 @@ window.pa_patcher = window.pa_patcher || {
|
|
|
4680
4697
|
if (window.pa_patcher && window.pa_patcher.loaded) {
|
|
4681
4698
|
window.pa_patcher.loaded.jsBefore = true;
|
|
4682
4699
|
}
|
|
4683
|
-
console.log('[
|
|
4700
|
+
console.log('[PA-Patcher] JS before loaded from remote:', REMOTE_URL);
|
|
4684
4701
|
};
|
|
4685
4702
|
})();
|
|
4686
4703
|
${lrsBridgeCode}
|
|
@@ -4751,14 +4768,14 @@ function generateJsAfterLoader(options) {
|
|
|
4751
4768
|
if (window.pa_patcher && window.pa_patcher.loaded) {
|
|
4752
4769
|
window.pa_patcher.loaded.jsAfter = true;
|
|
4753
4770
|
}
|
|
4754
|
-
console.log('[
|
|
4771
|
+
console.log('[PA-Patcher] Loading complete, content revealed');
|
|
4755
4772
|
|
|
4756
4773
|
// Add visual badge to indicate patching is active
|
|
4757
4774
|
var badge = document.createElement('div');
|
|
4758
4775
|
badge.setAttribute('data-pa', 'badge');
|
|
4759
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;';
|
|
4760
4777
|
badge.textContent = 'PA';
|
|
4761
|
-
badge.title = '
|
|
4778
|
+
badge.title = 'PA-Patcher Active';
|
|
4762
4779
|
badge.onclick = function() { badge.style.display = 'none'; };
|
|
4763
4780
|
document.body.appendChild(badge);
|
|
4764
4781
|
}
|
|
@@ -4774,7 +4791,7 @@ function generateJsAfterLoader(options) {
|
|
|
4774
4791
|
if (loaded) return;
|
|
4775
4792
|
loaded = true;
|
|
4776
4793
|
clearTimeout(timeoutId);
|
|
4777
|
-
console.log('[
|
|
4794
|
+
console.log('[PA-Patcher] JS after loaded from remote:', REMOTE_URL);
|
|
4778
4795
|
// Give the script a moment to execute, then remove loading class
|
|
4779
4796
|
setTimeout(removeLoadingClass, 50);
|
|
4780
4797
|
},
|
|
@@ -4790,7 +4807,7 @@ function generateJsAfterLoader(options) {
|
|
|
4790
4807
|
timeoutId = setTimeout(function() {
|
|
4791
4808
|
if (loaded) return;
|
|
4792
4809
|
loaded = true;
|
|
4793
|
-
console.warn('[
|
|
4810
|
+
console.warn('[PA-Patcher] JS after timed out, using local fallback');
|
|
4794
4811
|
if (remoteScript.parentNode) {
|
|
4795
4812
|
document.body.removeChild(remoteScript);
|
|
4796
4813
|
}
|
|
@@ -4802,11 +4819,11 @@ function generateJsAfterLoader(options) {
|
|
|
4802
4819
|
loadJS(
|
|
4803
4820
|
LOCAL_PATH,
|
|
4804
4821
|
function() {
|
|
4805
|
-
console.log('[
|
|
4822
|
+
console.log('[PA-Patcher] JS after loaded from local fallback:', LOCAL_PATH);
|
|
4806
4823
|
setTimeout(removeLoadingClass, 50);
|
|
4807
4824
|
},
|
|
4808
4825
|
function() {
|
|
4809
|
-
console.error('[
|
|
4826
|
+
console.error('[PA-Patcher] JS after failed to load from both remote and local');
|
|
4810
4827
|
// Still remove loading class so content is visible even if JS fails
|
|
4811
4828
|
removeLoadingClass();
|
|
4812
4829
|
}
|
|
@@ -5266,7 +5283,7 @@ var ManifestUpdater = class {
|
|
|
5266
5283
|
const resourceClosePattern = /(\s*)<\/resource>/i;
|
|
5267
5284
|
const match = xmlContent.match(resourceClosePattern);
|
|
5268
5285
|
if (!match) {
|
|
5269
|
-
console.warn("[
|
|
5286
|
+
console.warn("[PA-Patcher] Could not find </resource> tag in imsmanifest.xml");
|
|
5270
5287
|
return [];
|
|
5271
5288
|
}
|
|
5272
5289
|
const updatedXml = xmlContent.replace(
|
|
@@ -5278,7 +5295,7 @@ $1</resource>`
|
|
|
5278
5295
|
zip.updateFile("imsmanifest.xml", Buffer.from(updatedXml, "utf-8"));
|
|
5279
5296
|
return ["imsmanifest.xml"];
|
|
5280
5297
|
} catch (error) {
|
|
5281
|
-
console.error("[
|
|
5298
|
+
console.error("[PA-Patcher] Failed to update imsmanifest.xml:", error);
|
|
5282
5299
|
return [];
|
|
5283
5300
|
}
|
|
5284
5301
|
}
|
|
@@ -5600,7 +5617,7 @@ ${js.after}
|
|
|
5600
5617
|
var pluginRegistry = new PluginRegistry();
|
|
5601
5618
|
|
|
5602
5619
|
// src/patcher/index.ts
|
|
5603
|
-
var DEFAULT_CSS_BEFORE = `/*
|
|
5620
|
+
var DEFAULT_CSS_BEFORE = `/* PA-Patcher: CSS Before (blocking)
|
|
5604
5621
|
* This file loads at the start of <head> and blocks rendering.
|
|
5605
5622
|
* Use it to hide content and prevent flash of unstyled content.
|
|
5606
5623
|
*
|
|
@@ -5610,7 +5627,7 @@ var DEFAULT_CSS_BEFORE = `/* Patch-Adams: CSS Before (blocking)
|
|
|
5610
5627
|
* }
|
|
5611
5628
|
*/
|
|
5612
5629
|
`;
|
|
5613
|
-
var DEFAULT_CSS_AFTER = `/*
|
|
5630
|
+
var DEFAULT_CSS_AFTER = `/* PA-Patcher: CSS After (async)
|
|
5614
5631
|
* This file loads at the end of <head> with remote fallback.
|
|
5615
5632
|
* Use it for style overrides that take precedence over Rise styles.
|
|
5616
5633
|
*
|
|
@@ -5620,7 +5637,7 @@ var DEFAULT_CSS_AFTER = `/* Patch-Adams: CSS After (async)
|
|
|
5620
5637
|
* }
|
|
5621
5638
|
*/
|
|
5622
5639
|
`;
|
|
5623
|
-
var DEFAULT_JS_BEFORE = `//
|
|
5640
|
+
var DEFAULT_JS_BEFORE = `// PA-Patcher: JS Before (blocking)
|
|
5624
5641
|
// This file loads at the start of <head> and blocks rendering.
|
|
5625
5642
|
// Use it for setup, API interception, and preparing globals.
|
|
5626
5643
|
//
|
|
@@ -5630,9 +5647,9 @@ var DEFAULT_JS_BEFORE = `// Patch-Adams: JS Before (blocking)
|
|
|
5630
5647
|
// analytics: true
|
|
5631
5648
|
// };
|
|
5632
5649
|
|
|
5633
|
-
console.log('[
|
|
5650
|
+
console.log('[PA-Patcher] JS Before loaded');
|
|
5634
5651
|
`;
|
|
5635
|
-
var DEFAULT_JS_AFTER = `//
|
|
5652
|
+
var DEFAULT_JS_AFTER = `// PA-Patcher: JS After (async)
|
|
5636
5653
|
// This file loads at the end of <body> with remote fallback.
|
|
5637
5654
|
// Use it for DOM manipulation after Rise has initialized.
|
|
5638
5655
|
//
|
|
@@ -5644,7 +5661,7 @@ var DEFAULT_JS_AFTER = `// Patch-Adams: JS After (async)
|
|
|
5644
5661
|
// // Your modifications here
|
|
5645
5662
|
// });
|
|
5646
5663
|
|
|
5647
|
-
console.log('[
|
|
5664
|
+
console.log('[PA-Patcher] JS After loaded');
|
|
5648
5665
|
`;
|
|
5649
5666
|
var Patcher = class {
|
|
5650
5667
|
config;
|