@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/index.cjs
CHANGED
|
@@ -272,13 +272,13 @@ html.${htmlClass}.${loadingClass} body {
|
|
|
272
272
|
var link = loadCSSSync(REMOTE_URL);
|
|
273
273
|
|
|
274
274
|
link.onerror = function() {
|
|
275
|
-
console.warn('[
|
|
275
|
+
console.warn('[PA-Patcher] CSS before failed to load from remote, using local fallback');
|
|
276
276
|
document.head.removeChild(link);
|
|
277
277
|
loadCSSSync(LOCAL_PATH);
|
|
278
278
|
};
|
|
279
279
|
|
|
280
280
|
link.onload = function() {
|
|
281
|
-
console.log('[
|
|
281
|
+
console.log('[PA-Patcher] CSS before loaded from remote:', REMOTE_URL);
|
|
282
282
|
};
|
|
283
283
|
})();
|
|
284
284
|
</script>`;
|
|
@@ -332,7 +332,7 @@ function generateCssAfterLoader(options) {
|
|
|
332
332
|
if (loaded) return;
|
|
333
333
|
loaded = true;
|
|
334
334
|
clearTimeout(timeoutId);
|
|
335
|
-
console.log('[
|
|
335
|
+
console.log('[PA-Patcher] CSS after loaded from remote:', REMOTE_URL);
|
|
336
336
|
},
|
|
337
337
|
function() {
|
|
338
338
|
if (loaded) return;
|
|
@@ -346,7 +346,7 @@ function generateCssAfterLoader(options) {
|
|
|
346
346
|
timeoutId = setTimeout(function() {
|
|
347
347
|
if (loaded) return;
|
|
348
348
|
loaded = true;
|
|
349
|
-
console.warn('[
|
|
349
|
+
console.warn('[PA-Patcher] CSS after timed out, using local fallback');
|
|
350
350
|
if (remoteLink.parentNode) {
|
|
351
351
|
document.head.removeChild(remoteLink);
|
|
352
352
|
}
|
|
@@ -358,10 +358,10 @@ function generateCssAfterLoader(options) {
|
|
|
358
358
|
loadCSS(
|
|
359
359
|
LOCAL_PATH,
|
|
360
360
|
function() {
|
|
361
|
-
console.log('[
|
|
361
|
+
console.log('[PA-Patcher] CSS after loaded from local fallback:', LOCAL_PATH);
|
|
362
362
|
},
|
|
363
363
|
function() {
|
|
364
|
-
console.error('[
|
|
364
|
+
console.error('[PA-Patcher] CSS after failed to load from both remote and local');
|
|
365
365
|
}
|
|
366
366
|
);
|
|
367
367
|
}
|
|
@@ -1344,7 +1344,9 @@ function generateLrsBridgeCode(options) {
|
|
|
1344
1344
|
((employee.fname || employee.firstName || '') + ' ' + (employee.lname || employee.lastName || '')).trim(),
|
|
1345
1345
|
firstName: employee.fname || employee.firstName || employee.first_name,
|
|
1346
1346
|
lastName: employee.lname || employee.lastName || employee.last_name,
|
|
1347
|
-
employeeId: employee.emp_id || employee.employeeId || employee.employee_id || employeeId
|
|
1347
|
+
employeeId: employee.emp_id || employee.employeeId || employee.employee_id || employeeId,
|
|
1348
|
+
bravaisUserId: employee.bravaisUserId || null,
|
|
1349
|
+
tenantUrl: employee.tenantUrl || null
|
|
1348
1350
|
};
|
|
1349
1351
|
log('Parsed employee data:', employeeLookupData);
|
|
1350
1352
|
// Persist to localStorage for cross-session caching
|
|
@@ -1418,6 +1420,16 @@ function generateLrsBridgeCode(options) {
|
|
|
1418
1420
|
if (employeeData.name && (!actor.name || actor.name === 'Unknown Learner')) {
|
|
1419
1421
|
actor.name = employeeData.name;
|
|
1420
1422
|
}
|
|
1423
|
+
|
|
1424
|
+
// Update account with Bravais user ID and tenant URL if available
|
|
1425
|
+
if (employeeData.bravaisUserId) {
|
|
1426
|
+
var originalAccountName = actor.account ? actor.account.name : null;
|
|
1427
|
+
actor.account = {
|
|
1428
|
+
name: employeeData.bravaisUserId,
|
|
1429
|
+
homePage: employeeData.tenantUrl || (actor.account && actor.account.homePage) || window.location.origin
|
|
1430
|
+
};
|
|
1431
|
+
log('Updated actor account: bravaisUserId=' + employeeData.bravaisUserId + ', homePage=' + actor.account.homePage + ' (was: ' + originalAccountName + ')');
|
|
1432
|
+
}
|
|
1421
1433
|
}
|
|
1422
1434
|
callback(actor);
|
|
1423
1435
|
});
|
|
@@ -1500,16 +1512,9 @@ function generateLrsBridgeCode(options) {
|
|
|
1500
1512
|
name: scormLearnerId
|
|
1501
1513
|
}
|
|
1502
1514
|
};
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
var parts = scormLearnerName.split(',');
|
|
1507
|
-
actor.name = (parts[1] || '').trim() + ' ' + (parts[0] || '').trim();
|
|
1508
|
-
} else {
|
|
1509
|
-
actor.name = scormLearnerName;
|
|
1510
|
-
}
|
|
1511
|
-
}
|
|
1512
|
-
log('Actor source: SCORM API');
|
|
1515
|
+
// Don't use SCORM student_name - it's unreliable ("Last, First" format varies by LMS).
|
|
1516
|
+
// The employee API lookup will provide the correct name and email.
|
|
1517
|
+
log('Actor source: SCORM API (id only, name from employee lookup)');
|
|
1513
1518
|
LRS.actor = actor;
|
|
1514
1519
|
return actor;
|
|
1515
1520
|
}
|
|
@@ -2089,7 +2094,7 @@ function generateLrsBridgeCode(options) {
|
|
|
2089
2094
|
tenantHomepage: null // https://{tenant}.bravais.com format
|
|
2090
2095
|
};
|
|
2091
2096
|
|
|
2092
|
-
// 0. Use baked-in GUIDs from
|
|
2097
|
+
// 0. Use baked-in GUIDs from PA-Patcher config (highest priority - set at wrap time)
|
|
2093
2098
|
if (DOCUMENT_GUID) {
|
|
2094
2099
|
info.guid = DOCUMENT_GUID;
|
|
2095
2100
|
info.id = 'http://xyleme.com/bravais/document/' + DOCUMENT_GUID;
|
|
@@ -2598,6 +2603,11 @@ function generateLrsBridgeCode(options) {
|
|
|
2598
2603
|
// Publish index (default to 1)
|
|
2599
2604
|
ctx.extensions['publishIndex'] = (LRS.courseInfo && LRS.courseInfo.publishIndex) ? LRS.courseInfo.publishIndex : 1;
|
|
2600
2605
|
|
|
2606
|
+
// Employee ID from employee lookup (if available)
|
|
2607
|
+
if (employeeLookupData && employeeLookupData.employeeId) {
|
|
2608
|
+
ctx.extensions['employeeId'] = employeeLookupData.employeeId;
|
|
2609
|
+
}
|
|
2610
|
+
|
|
2601
2611
|
// Xyleme schema version and PII flag
|
|
2602
2612
|
ctx.extensions['http://xyleme.com/bravais/extensions/statement-schema'] = 'xyleme_10';
|
|
2603
2613
|
ctx.extensions['http://xyleme.com/bravais/extensions/protect_pii'] = false;
|
|
@@ -3317,6 +3327,27 @@ function generateLrsBridgeCode(options) {
|
|
|
3317
3327
|
* because the bridge initializes in <head> before LMSInitialize runs.
|
|
3318
3328
|
*/
|
|
3319
3329
|
LRS.refreshActor = function(callback) {
|
|
3330
|
+
// If SCORM API wasn't found during <head> init, re-scan now
|
|
3331
|
+
// (some LMS inject window.API after page starts loading)
|
|
3332
|
+
if (!LRS.scormApi) {
|
|
3333
|
+
log('refreshActor: SCORM API missing, re-scanning...');
|
|
3334
|
+
var api2004 = findAPIInFrameHierarchy('API_1484_11', 10);
|
|
3335
|
+
if (api2004) {
|
|
3336
|
+
LRS.scormApi = api2004.api;
|
|
3337
|
+
LRS.scormApiFound = true;
|
|
3338
|
+
LRS.scormApiType = '2004';
|
|
3339
|
+
log('refreshActor: found SCORM 2004 API');
|
|
3340
|
+
} else {
|
|
3341
|
+
var api12 = findAPIInFrameHierarchy('API', 10);
|
|
3342
|
+
if (api12) {
|
|
3343
|
+
LRS.scormApi = api12.api;
|
|
3344
|
+
LRS.scormApiFound = true;
|
|
3345
|
+
LRS.scormApiType = '1.2';
|
|
3346
|
+
log('refreshActor: found SCORM 1.2 API');
|
|
3347
|
+
}
|
|
3348
|
+
}
|
|
3349
|
+
}
|
|
3350
|
+
|
|
3320
3351
|
// Always-visible diagnostic: confirm refreshActor is being called and show SCORM data (TEMPORARY)
|
|
3321
3352
|
if (window.console && window.console.info) {
|
|
3322
3353
|
var scormId = 'n/a', scormName = 'n/a';
|
|
@@ -4245,7 +4276,7 @@ ${courseLines.join("\n")}
|
|
|
4245
4276
|
},` : "";
|
|
4246
4277
|
return `<!-- === PATCH-ADAMS: JS BEFORE (blocking) === -->
|
|
4247
4278
|
<script data-pa="js-before-loader">
|
|
4248
|
-
// Initialize
|
|
4279
|
+
// Initialize PA-Patcher global namespace IMMEDIATELY (before IIFE)
|
|
4249
4280
|
window.pa_patcher = window.pa_patcher || {
|
|
4250
4281
|
version: '1.0.25',
|
|
4251
4282
|
htmlClass: '${htmlClass}',
|
|
@@ -4290,7 +4321,7 @@ window.pa_patcher = window.pa_patcher || {
|
|
|
4290
4321
|
if (isExtensionError(event.reason)) {
|
|
4291
4322
|
event.preventDefault();
|
|
4292
4323
|
event.stopImmediatePropagation();
|
|
4293
|
-
console.debug('[
|
|
4324
|
+
console.debug('[PA-Patcher] Suppressed browser extension error:', event.reason);
|
|
4294
4325
|
return false;
|
|
4295
4326
|
}
|
|
4296
4327
|
}, true);
|
|
@@ -4300,7 +4331,7 @@ window.pa_patcher = window.pa_patcher || {
|
|
|
4300
4331
|
if (isExtensionError(event.error || event.message)) {
|
|
4301
4332
|
event.preventDefault();
|
|
4302
4333
|
event.stopImmediatePropagation();
|
|
4303
|
-
console.debug('[
|
|
4334
|
+
console.debug('[PA-Patcher] Suppressed browser extension error:', event.message);
|
|
4304
4335
|
return false;
|
|
4305
4336
|
}
|
|
4306
4337
|
}, true);
|
|
@@ -4325,17 +4356,17 @@ window.pa_patcher = window.pa_patcher || {
|
|
|
4325
4356
|
var script = loadJSSync(REMOTE_URL);
|
|
4326
4357
|
|
|
4327
4358
|
script.onerror = function() {
|
|
4328
|
-
console.warn('[
|
|
4359
|
+
console.warn('[PA-Patcher] JS before failed to load from remote, using local fallback');
|
|
4329
4360
|
document.head.removeChild(script);
|
|
4330
4361
|
var fallback = loadJSSync(LOCAL_PATH);
|
|
4331
4362
|
fallback.onload = function() {
|
|
4332
4363
|
if (window.pa_patcher && window.pa_patcher.loaded) {
|
|
4333
4364
|
window.pa_patcher.loaded.jsBefore = true;
|
|
4334
4365
|
}
|
|
4335
|
-
console.log('[
|
|
4366
|
+
console.log('[PA-Patcher] JS before loaded from local fallback:', LOCAL_PATH);
|
|
4336
4367
|
};
|
|
4337
4368
|
fallback.onerror = function() {
|
|
4338
|
-
console.error('[
|
|
4369
|
+
console.error('[PA-Patcher] JS before failed to load from both remote and local');
|
|
4339
4370
|
};
|
|
4340
4371
|
};
|
|
4341
4372
|
|
|
@@ -4343,7 +4374,7 @@ window.pa_patcher = window.pa_patcher || {
|
|
|
4343
4374
|
if (window.pa_patcher && window.pa_patcher.loaded) {
|
|
4344
4375
|
window.pa_patcher.loaded.jsBefore = true;
|
|
4345
4376
|
}
|
|
4346
|
-
console.log('[
|
|
4377
|
+
console.log('[PA-Patcher] JS before loaded from remote:', REMOTE_URL);
|
|
4347
4378
|
};
|
|
4348
4379
|
})();
|
|
4349
4380
|
${lrsBridgeCode}
|
|
@@ -4414,14 +4445,14 @@ function generateJsAfterLoader(options) {
|
|
|
4414
4445
|
if (window.pa_patcher && window.pa_patcher.loaded) {
|
|
4415
4446
|
window.pa_patcher.loaded.jsAfter = true;
|
|
4416
4447
|
}
|
|
4417
|
-
console.log('[
|
|
4448
|
+
console.log('[PA-Patcher] Loading complete, content revealed');
|
|
4418
4449
|
|
|
4419
4450
|
// Add visual badge to indicate patching is active
|
|
4420
4451
|
var badge = document.createElement('div');
|
|
4421
4452
|
badge.setAttribute('data-pa', 'badge');
|
|
4422
4453
|
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;';
|
|
4423
4454
|
badge.textContent = 'PA';
|
|
4424
|
-
badge.title = '
|
|
4455
|
+
badge.title = 'PA-Patcher Active';
|
|
4425
4456
|
badge.onclick = function() { badge.style.display = 'none'; };
|
|
4426
4457
|
document.body.appendChild(badge);
|
|
4427
4458
|
}
|
|
@@ -4437,7 +4468,7 @@ function generateJsAfterLoader(options) {
|
|
|
4437
4468
|
if (loaded) return;
|
|
4438
4469
|
loaded = true;
|
|
4439
4470
|
clearTimeout(timeoutId);
|
|
4440
|
-
console.log('[
|
|
4471
|
+
console.log('[PA-Patcher] JS after loaded from remote:', REMOTE_URL);
|
|
4441
4472
|
// Give the script a moment to execute, then remove loading class
|
|
4442
4473
|
setTimeout(removeLoadingClass, 50);
|
|
4443
4474
|
},
|
|
@@ -4453,7 +4484,7 @@ function generateJsAfterLoader(options) {
|
|
|
4453
4484
|
timeoutId = setTimeout(function() {
|
|
4454
4485
|
if (loaded) return;
|
|
4455
4486
|
loaded = true;
|
|
4456
|
-
console.warn('[
|
|
4487
|
+
console.warn('[PA-Patcher] JS after timed out, using local fallback');
|
|
4457
4488
|
if (remoteScript.parentNode) {
|
|
4458
4489
|
document.body.removeChild(remoteScript);
|
|
4459
4490
|
}
|
|
@@ -4465,11 +4496,11 @@ function generateJsAfterLoader(options) {
|
|
|
4465
4496
|
loadJS(
|
|
4466
4497
|
LOCAL_PATH,
|
|
4467
4498
|
function() {
|
|
4468
|
-
console.log('[
|
|
4499
|
+
console.log('[PA-Patcher] JS after loaded from local fallback:', LOCAL_PATH);
|
|
4469
4500
|
setTimeout(removeLoadingClass, 50);
|
|
4470
4501
|
},
|
|
4471
4502
|
function() {
|
|
4472
|
-
console.error('[
|
|
4503
|
+
console.error('[PA-Patcher] JS after failed to load from both remote and local');
|
|
4473
4504
|
// Still remove loading class so content is visible even if JS fails
|
|
4474
4505
|
removeLoadingClass();
|
|
4475
4506
|
}
|
|
@@ -4929,7 +4960,7 @@ var ManifestUpdater = class {
|
|
|
4929
4960
|
const resourceClosePattern = /(\s*)<\/resource>/i;
|
|
4930
4961
|
const match = xmlContent.match(resourceClosePattern);
|
|
4931
4962
|
if (!match) {
|
|
4932
|
-
console.warn("[
|
|
4963
|
+
console.warn("[PA-Patcher] Could not find </resource> tag in imsmanifest.xml");
|
|
4933
4964
|
return [];
|
|
4934
4965
|
}
|
|
4935
4966
|
const updatedXml = xmlContent.replace(
|
|
@@ -4941,7 +4972,7 @@ $1</resource>`
|
|
|
4941
4972
|
zip.updateFile("imsmanifest.xml", Buffer.from(updatedXml, "utf-8"));
|
|
4942
4973
|
return ["imsmanifest.xml"];
|
|
4943
4974
|
} catch (error) {
|
|
4944
|
-
console.error("[
|
|
4975
|
+
console.error("[PA-Patcher] Failed to update imsmanifest.xml:", error);
|
|
4945
4976
|
return [];
|
|
4946
4977
|
}
|
|
4947
4978
|
}
|
|
@@ -5573,7 +5604,7 @@ ${js.after}
|
|
|
5573
5604
|
var pluginRegistry = new PluginRegistry();
|
|
5574
5605
|
|
|
5575
5606
|
// src/patcher/index.ts
|
|
5576
|
-
var DEFAULT_CSS_BEFORE = `/*
|
|
5607
|
+
var DEFAULT_CSS_BEFORE = `/* PA-Patcher: CSS Before (blocking)
|
|
5577
5608
|
* This file loads at the start of <head> and blocks rendering.
|
|
5578
5609
|
* Use it to hide content and prevent flash of unstyled content.
|
|
5579
5610
|
*
|
|
@@ -5583,7 +5614,7 @@ var DEFAULT_CSS_BEFORE = `/* Patch-Adams: CSS Before (blocking)
|
|
|
5583
5614
|
* }
|
|
5584
5615
|
*/
|
|
5585
5616
|
`;
|
|
5586
|
-
var DEFAULT_CSS_AFTER = `/*
|
|
5617
|
+
var DEFAULT_CSS_AFTER = `/* PA-Patcher: CSS After (async)
|
|
5587
5618
|
* This file loads at the end of <head> with remote fallback.
|
|
5588
5619
|
* Use it for style overrides that take precedence over Rise styles.
|
|
5589
5620
|
*
|
|
@@ -5593,7 +5624,7 @@ var DEFAULT_CSS_AFTER = `/* Patch-Adams: CSS After (async)
|
|
|
5593
5624
|
* }
|
|
5594
5625
|
*/
|
|
5595
5626
|
`;
|
|
5596
|
-
var DEFAULT_JS_BEFORE = `//
|
|
5627
|
+
var DEFAULT_JS_BEFORE = `// PA-Patcher: JS Before (blocking)
|
|
5597
5628
|
// This file loads at the start of <head> and blocks rendering.
|
|
5598
5629
|
// Use it for setup, API interception, and preparing globals.
|
|
5599
5630
|
//
|
|
@@ -5603,9 +5634,9 @@ var DEFAULT_JS_BEFORE = `// Patch-Adams: JS Before (blocking)
|
|
|
5603
5634
|
// analytics: true
|
|
5604
5635
|
// };
|
|
5605
5636
|
|
|
5606
|
-
console.log('[
|
|
5637
|
+
console.log('[PA-Patcher] JS Before loaded');
|
|
5607
5638
|
`;
|
|
5608
|
-
var DEFAULT_JS_AFTER = `//
|
|
5639
|
+
var DEFAULT_JS_AFTER = `// PA-Patcher: JS After (async)
|
|
5609
5640
|
// This file loads at the end of <body> with remote fallback.
|
|
5610
5641
|
// Use it for DOM manipulation after Rise has initialized.
|
|
5611
5642
|
//
|
|
@@ -5617,7 +5648,7 @@ var DEFAULT_JS_AFTER = `// Patch-Adams: JS After (async)
|
|
|
5617
5648
|
// // Your modifications here
|
|
5618
5649
|
// });
|
|
5619
5650
|
|
|
5620
|
-
console.log('[
|
|
5651
|
+
console.log('[PA-Patcher] JS After loaded');
|
|
5621
5652
|
`;
|
|
5622
5653
|
var Patcher = class {
|
|
5623
5654
|
config;
|