@patch-adams/core 1.4.25 → 1.4.27
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 +82 -39
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +82 -39
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +82 -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 +82 -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
|
});
|
|
@@ -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;
|
|
@@ -4396,6 +4413,19 @@ function generateLrsBridgeCode(options) {
|
|
|
4396
4413
|
// Setup connection
|
|
4397
4414
|
var bridgeReady = setupBridge();
|
|
4398
4415
|
|
|
4416
|
+
// Track async readiness: both actor and doc metadata must resolve before sending statements
|
|
4417
|
+
var actorReady = false;
|
|
4418
|
+
var docReady = false;
|
|
4419
|
+
var launchEventsSent = false;
|
|
4420
|
+
|
|
4421
|
+
function tryLaunchEvents() {
|
|
4422
|
+
if (launchEventsSent) return;
|
|
4423
|
+
if (!actorReady || !docReady) return;
|
|
4424
|
+
launchEventsSent = true;
|
|
4425
|
+
log('Both actor and doc metadata ready, sending launch events');
|
|
4426
|
+
setTimeout(sendLaunchEvents, 50);
|
|
4427
|
+
}
|
|
4428
|
+
|
|
4399
4429
|
if (bridgeReady) {
|
|
4400
4430
|
LRS.initialized = true;
|
|
4401
4431
|
|
|
@@ -4406,14 +4436,23 @@ function generateLrsBridgeCode(options) {
|
|
|
4406
4436
|
log('Actor:', LRS.actor);
|
|
4407
4437
|
log('Course:', LRS.courseInfo);
|
|
4408
4438
|
|
|
4409
|
-
// Then try async actor extraction
|
|
4410
|
-
//
|
|
4439
|
+
// Then try async actor extraction (employee lookup, Bravais session)
|
|
4440
|
+
// Launch events will NOT be sent until this completes
|
|
4411
4441
|
extractActorAsync(function(actor) {
|
|
4412
4442
|
log('Actor updated after async fetch:', actor);
|
|
4443
|
+
actorReady = true;
|
|
4444
|
+
// Log final actor state for diagnostics
|
|
4445
|
+
if (window.console && window.console.info) {
|
|
4446
|
+
console.info('[PA-LRS] Actor resolved: name=' + (actor ? actor.name : 'none') +
|
|
4447
|
+
', mbox=' + (actor ? actor.mbox : 'none') +
|
|
4448
|
+
', account=' + (actor && actor.account ? actor.account.name : 'none'));
|
|
4449
|
+
}
|
|
4450
|
+
tryLaunchEvents();
|
|
4413
4451
|
});
|
|
4414
4452
|
} else {
|
|
4415
4453
|
warn('Bridge setup failed - operating in offline mode');
|
|
4416
4454
|
LRS.mode = 'offline';
|
|
4455
|
+
actorReady = true; // No actor to wait for in offline mode
|
|
4417
4456
|
}
|
|
4418
4457
|
|
|
4419
4458
|
// Always-visible bridge summary (not gated by DEBUG)
|
|
@@ -4458,13 +4497,17 @@ function generateLrsBridgeCode(options) {
|
|
|
4458
4497
|
}
|
|
4459
4498
|
}
|
|
4460
4499
|
|
|
4461
|
-
function
|
|
4500
|
+
function onDocReady() {
|
|
4501
|
+
docReady = true;
|
|
4502
|
+
tryLaunchEvents();
|
|
4503
|
+
}
|
|
4504
|
+
|
|
4505
|
+
function fetchDocDataAndReady(docId) {
|
|
4462
4506
|
fetchDocumentMetadata(docId, function(docData) {
|
|
4463
4507
|
if (docData) {
|
|
4464
4508
|
updateCourseInfoFromApi(docData);
|
|
4465
4509
|
}
|
|
4466
|
-
|
|
4467
|
-
setTimeout(sendLaunchEvents, 100);
|
|
4510
|
+
onDocReady();
|
|
4468
4511
|
});
|
|
4469
4512
|
}
|
|
4470
4513
|
|
|
@@ -4484,20 +4527,20 @@ function generateLrsBridgeCode(options) {
|
|
|
4484
4527
|
} else {
|
|
4485
4528
|
warn('Could not fetch document data from shared API - statements may fail aggregation');
|
|
4486
4529
|
}
|
|
4487
|
-
|
|
4530
|
+
onDocReady();
|
|
4488
4531
|
});
|
|
4489
4532
|
} else if (documentId) {
|
|
4490
4533
|
// No shared link token, try with extracted document ID (requires auth)
|
|
4491
4534
|
log('No shared link token, fetching document data with ID:', documentId);
|
|
4492
|
-
|
|
4535
|
+
fetchDocDataAndReady(documentId);
|
|
4493
4536
|
} else {
|
|
4494
4537
|
// No identifiers available
|
|
4495
4538
|
warn('No shared link token or document ID - statements may fail aggregation');
|
|
4496
|
-
|
|
4539
|
+
onDocReady();
|
|
4497
4540
|
}
|
|
4498
4541
|
} else {
|
|
4499
|
-
// Already have GUID
|
|
4500
|
-
|
|
4542
|
+
// Already have GUID
|
|
4543
|
+
onDocReady();
|
|
4501
4544
|
}
|
|
4502
4545
|
|
|
4503
4546
|
// Setup beforeunload to send terminated
|
|
@@ -4582,7 +4625,7 @@ ${courseLines.join("\n")}
|
|
|
4582
4625
|
},` : "";
|
|
4583
4626
|
return `<!-- === PATCH-ADAMS: JS BEFORE (blocking) === -->
|
|
4584
4627
|
<script data-pa="js-before-loader">
|
|
4585
|
-
// Initialize
|
|
4628
|
+
// Initialize PA-Patcher global namespace IMMEDIATELY (before IIFE)
|
|
4586
4629
|
window.pa_patcher = window.pa_patcher || {
|
|
4587
4630
|
version: '1.0.25',
|
|
4588
4631
|
htmlClass: '${htmlClass}',
|
|
@@ -4627,7 +4670,7 @@ window.pa_patcher = window.pa_patcher || {
|
|
|
4627
4670
|
if (isExtensionError(event.reason)) {
|
|
4628
4671
|
event.preventDefault();
|
|
4629
4672
|
event.stopImmediatePropagation();
|
|
4630
|
-
console.debug('[
|
|
4673
|
+
console.debug('[PA-Patcher] Suppressed browser extension error:', event.reason);
|
|
4631
4674
|
return false;
|
|
4632
4675
|
}
|
|
4633
4676
|
}, true);
|
|
@@ -4637,7 +4680,7 @@ window.pa_patcher = window.pa_patcher || {
|
|
|
4637
4680
|
if (isExtensionError(event.error || event.message)) {
|
|
4638
4681
|
event.preventDefault();
|
|
4639
4682
|
event.stopImmediatePropagation();
|
|
4640
|
-
console.debug('[
|
|
4683
|
+
console.debug('[PA-Patcher] Suppressed browser extension error:', event.message);
|
|
4641
4684
|
return false;
|
|
4642
4685
|
}
|
|
4643
4686
|
}, true);
|
|
@@ -4662,17 +4705,17 @@ window.pa_patcher = window.pa_patcher || {
|
|
|
4662
4705
|
var script = loadJSSync(REMOTE_URL);
|
|
4663
4706
|
|
|
4664
4707
|
script.onerror = function() {
|
|
4665
|
-
console.warn('[
|
|
4708
|
+
console.warn('[PA-Patcher] JS before failed to load from remote, using local fallback');
|
|
4666
4709
|
document.head.removeChild(script);
|
|
4667
4710
|
var fallback = loadJSSync(LOCAL_PATH);
|
|
4668
4711
|
fallback.onload = function() {
|
|
4669
4712
|
if (window.pa_patcher && window.pa_patcher.loaded) {
|
|
4670
4713
|
window.pa_patcher.loaded.jsBefore = true;
|
|
4671
4714
|
}
|
|
4672
|
-
console.log('[
|
|
4715
|
+
console.log('[PA-Patcher] JS before loaded from local fallback:', LOCAL_PATH);
|
|
4673
4716
|
};
|
|
4674
4717
|
fallback.onerror = function() {
|
|
4675
|
-
console.error('[
|
|
4718
|
+
console.error('[PA-Patcher] JS before failed to load from both remote and local');
|
|
4676
4719
|
};
|
|
4677
4720
|
};
|
|
4678
4721
|
|
|
@@ -4680,7 +4723,7 @@ window.pa_patcher = window.pa_patcher || {
|
|
|
4680
4723
|
if (window.pa_patcher && window.pa_patcher.loaded) {
|
|
4681
4724
|
window.pa_patcher.loaded.jsBefore = true;
|
|
4682
4725
|
}
|
|
4683
|
-
console.log('[
|
|
4726
|
+
console.log('[PA-Patcher] JS before loaded from remote:', REMOTE_URL);
|
|
4684
4727
|
};
|
|
4685
4728
|
})();
|
|
4686
4729
|
${lrsBridgeCode}
|
|
@@ -4751,14 +4794,14 @@ function generateJsAfterLoader(options) {
|
|
|
4751
4794
|
if (window.pa_patcher && window.pa_patcher.loaded) {
|
|
4752
4795
|
window.pa_patcher.loaded.jsAfter = true;
|
|
4753
4796
|
}
|
|
4754
|
-
console.log('[
|
|
4797
|
+
console.log('[PA-Patcher] Loading complete, content revealed');
|
|
4755
4798
|
|
|
4756
4799
|
// Add visual badge to indicate patching is active
|
|
4757
4800
|
var badge = document.createElement('div');
|
|
4758
4801
|
badge.setAttribute('data-pa', 'badge');
|
|
4759
4802
|
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
4803
|
badge.textContent = 'PA';
|
|
4761
|
-
badge.title = '
|
|
4804
|
+
badge.title = 'PA-Patcher Active';
|
|
4762
4805
|
badge.onclick = function() { badge.style.display = 'none'; };
|
|
4763
4806
|
document.body.appendChild(badge);
|
|
4764
4807
|
}
|
|
@@ -4774,7 +4817,7 @@ function generateJsAfterLoader(options) {
|
|
|
4774
4817
|
if (loaded) return;
|
|
4775
4818
|
loaded = true;
|
|
4776
4819
|
clearTimeout(timeoutId);
|
|
4777
|
-
console.log('[
|
|
4820
|
+
console.log('[PA-Patcher] JS after loaded from remote:', REMOTE_URL);
|
|
4778
4821
|
// Give the script a moment to execute, then remove loading class
|
|
4779
4822
|
setTimeout(removeLoadingClass, 50);
|
|
4780
4823
|
},
|
|
@@ -4790,7 +4833,7 @@ function generateJsAfterLoader(options) {
|
|
|
4790
4833
|
timeoutId = setTimeout(function() {
|
|
4791
4834
|
if (loaded) return;
|
|
4792
4835
|
loaded = true;
|
|
4793
|
-
console.warn('[
|
|
4836
|
+
console.warn('[PA-Patcher] JS after timed out, using local fallback');
|
|
4794
4837
|
if (remoteScript.parentNode) {
|
|
4795
4838
|
document.body.removeChild(remoteScript);
|
|
4796
4839
|
}
|
|
@@ -4802,11 +4845,11 @@ function generateJsAfterLoader(options) {
|
|
|
4802
4845
|
loadJS(
|
|
4803
4846
|
LOCAL_PATH,
|
|
4804
4847
|
function() {
|
|
4805
|
-
console.log('[
|
|
4848
|
+
console.log('[PA-Patcher] JS after loaded from local fallback:', LOCAL_PATH);
|
|
4806
4849
|
setTimeout(removeLoadingClass, 50);
|
|
4807
4850
|
},
|
|
4808
4851
|
function() {
|
|
4809
|
-
console.error('[
|
|
4852
|
+
console.error('[PA-Patcher] JS after failed to load from both remote and local');
|
|
4810
4853
|
// Still remove loading class so content is visible even if JS fails
|
|
4811
4854
|
removeLoadingClass();
|
|
4812
4855
|
}
|
|
@@ -5266,7 +5309,7 @@ var ManifestUpdater = class {
|
|
|
5266
5309
|
const resourceClosePattern = /(\s*)<\/resource>/i;
|
|
5267
5310
|
const match = xmlContent.match(resourceClosePattern);
|
|
5268
5311
|
if (!match) {
|
|
5269
|
-
console.warn("[
|
|
5312
|
+
console.warn("[PA-Patcher] Could not find </resource> tag in imsmanifest.xml");
|
|
5270
5313
|
return [];
|
|
5271
5314
|
}
|
|
5272
5315
|
const updatedXml = xmlContent.replace(
|
|
@@ -5278,7 +5321,7 @@ $1</resource>`
|
|
|
5278
5321
|
zip.updateFile("imsmanifest.xml", Buffer.from(updatedXml, "utf-8"));
|
|
5279
5322
|
return ["imsmanifest.xml"];
|
|
5280
5323
|
} catch (error) {
|
|
5281
|
-
console.error("[
|
|
5324
|
+
console.error("[PA-Patcher] Failed to update imsmanifest.xml:", error);
|
|
5282
5325
|
return [];
|
|
5283
5326
|
}
|
|
5284
5327
|
}
|
|
@@ -5600,7 +5643,7 @@ ${js.after}
|
|
|
5600
5643
|
var pluginRegistry = new PluginRegistry();
|
|
5601
5644
|
|
|
5602
5645
|
// src/patcher/index.ts
|
|
5603
|
-
var DEFAULT_CSS_BEFORE = `/*
|
|
5646
|
+
var DEFAULT_CSS_BEFORE = `/* PA-Patcher: CSS Before (blocking)
|
|
5604
5647
|
* This file loads at the start of <head> and blocks rendering.
|
|
5605
5648
|
* Use it to hide content and prevent flash of unstyled content.
|
|
5606
5649
|
*
|
|
@@ -5610,7 +5653,7 @@ var DEFAULT_CSS_BEFORE = `/* Patch-Adams: CSS Before (blocking)
|
|
|
5610
5653
|
* }
|
|
5611
5654
|
*/
|
|
5612
5655
|
`;
|
|
5613
|
-
var DEFAULT_CSS_AFTER = `/*
|
|
5656
|
+
var DEFAULT_CSS_AFTER = `/* PA-Patcher: CSS After (async)
|
|
5614
5657
|
* This file loads at the end of <head> with remote fallback.
|
|
5615
5658
|
* Use it for style overrides that take precedence over Rise styles.
|
|
5616
5659
|
*
|
|
@@ -5620,7 +5663,7 @@ var DEFAULT_CSS_AFTER = `/* Patch-Adams: CSS After (async)
|
|
|
5620
5663
|
* }
|
|
5621
5664
|
*/
|
|
5622
5665
|
`;
|
|
5623
|
-
var DEFAULT_JS_BEFORE = `//
|
|
5666
|
+
var DEFAULT_JS_BEFORE = `// PA-Patcher: JS Before (blocking)
|
|
5624
5667
|
// This file loads at the start of <head> and blocks rendering.
|
|
5625
5668
|
// Use it for setup, API interception, and preparing globals.
|
|
5626
5669
|
//
|
|
@@ -5630,9 +5673,9 @@ var DEFAULT_JS_BEFORE = `// Patch-Adams: JS Before (blocking)
|
|
|
5630
5673
|
// analytics: true
|
|
5631
5674
|
// };
|
|
5632
5675
|
|
|
5633
|
-
console.log('[
|
|
5676
|
+
console.log('[PA-Patcher] JS Before loaded');
|
|
5634
5677
|
`;
|
|
5635
|
-
var DEFAULT_JS_AFTER = `//
|
|
5678
|
+
var DEFAULT_JS_AFTER = `// PA-Patcher: JS After (async)
|
|
5636
5679
|
// This file loads at the end of <body> with remote fallback.
|
|
5637
5680
|
// Use it for DOM manipulation after Rise has initialized.
|
|
5638
5681
|
//
|
|
@@ -5644,7 +5687,7 @@ var DEFAULT_JS_AFTER = `// Patch-Adams: JS After (async)
|
|
|
5644
5687
|
// // Your modifications here
|
|
5645
5688
|
// });
|
|
5646
5689
|
|
|
5647
|
-
console.log('[
|
|
5690
|
+
console.log('[PA-Patcher] JS After loaded');
|
|
5648
5691
|
`;
|
|
5649
5692
|
var Patcher = class {
|
|
5650
5693
|
config;
|