@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.d.cts
CHANGED
|
@@ -969,7 +969,7 @@ declare function generateCssAfterLoader(options: CssAfterOptions): string;
|
|
|
969
969
|
declare function buildCssAfterOptions(config: PatchAdamsConfig): CssAfterOptions;
|
|
970
970
|
|
|
971
971
|
/**
|
|
972
|
-
* LRS Bridge Template for
|
|
972
|
+
* LRS Bridge Template for PA-Patcher
|
|
973
973
|
*
|
|
974
974
|
* Generates JavaScript code that bridges Rise courses to an LRS endpoint.
|
|
975
975
|
* Supports direct xAPI statement posting when PlayerIntegration is unavailable.
|
package/dist/index.d.ts
CHANGED
|
@@ -969,7 +969,7 @@ declare function generateCssAfterLoader(options: CssAfterOptions): string;
|
|
|
969
969
|
declare function buildCssAfterOptions(config: PatchAdamsConfig): CssAfterOptions;
|
|
970
970
|
|
|
971
971
|
/**
|
|
972
|
-
* LRS Bridge Template for
|
|
972
|
+
* LRS Bridge Template for PA-Patcher
|
|
973
973
|
*
|
|
974
974
|
* Generates JavaScript code that bridges Rise courses to an LRS endpoint.
|
|
975
975
|
* Supports direct xAPI statement posting when PlayerIntegration is unavailable.
|
package/dist/index.js
CHANGED
|
@@ -264,13 +264,13 @@ html.${htmlClass}.${loadingClass} body {
|
|
|
264
264
|
var link = loadCSSSync(REMOTE_URL);
|
|
265
265
|
|
|
266
266
|
link.onerror = function() {
|
|
267
|
-
console.warn('[
|
|
267
|
+
console.warn('[PA-Patcher] CSS before failed to load from remote, using local fallback');
|
|
268
268
|
document.head.removeChild(link);
|
|
269
269
|
loadCSSSync(LOCAL_PATH);
|
|
270
270
|
};
|
|
271
271
|
|
|
272
272
|
link.onload = function() {
|
|
273
|
-
console.log('[
|
|
273
|
+
console.log('[PA-Patcher] CSS before loaded from remote:', REMOTE_URL);
|
|
274
274
|
};
|
|
275
275
|
})();
|
|
276
276
|
</script>`;
|
|
@@ -324,7 +324,7 @@ function generateCssAfterLoader(options) {
|
|
|
324
324
|
if (loaded) return;
|
|
325
325
|
loaded = true;
|
|
326
326
|
clearTimeout(timeoutId);
|
|
327
|
-
console.log('[
|
|
327
|
+
console.log('[PA-Patcher] CSS after loaded from remote:', REMOTE_URL);
|
|
328
328
|
},
|
|
329
329
|
function() {
|
|
330
330
|
if (loaded) return;
|
|
@@ -338,7 +338,7 @@ function generateCssAfterLoader(options) {
|
|
|
338
338
|
timeoutId = setTimeout(function() {
|
|
339
339
|
if (loaded) return;
|
|
340
340
|
loaded = true;
|
|
341
|
-
console.warn('[
|
|
341
|
+
console.warn('[PA-Patcher] CSS after timed out, using local fallback');
|
|
342
342
|
if (remoteLink.parentNode) {
|
|
343
343
|
document.head.removeChild(remoteLink);
|
|
344
344
|
}
|
|
@@ -350,10 +350,10 @@ function generateCssAfterLoader(options) {
|
|
|
350
350
|
loadCSS(
|
|
351
351
|
LOCAL_PATH,
|
|
352
352
|
function() {
|
|
353
|
-
console.log('[
|
|
353
|
+
console.log('[PA-Patcher] CSS after loaded from local fallback:', LOCAL_PATH);
|
|
354
354
|
},
|
|
355
355
|
function() {
|
|
356
|
-
console.error('[
|
|
356
|
+
console.error('[PA-Patcher] CSS after failed to load from both remote and local');
|
|
357
357
|
}
|
|
358
358
|
);
|
|
359
359
|
}
|
|
@@ -1336,7 +1336,9 @@ function generateLrsBridgeCode(options) {
|
|
|
1336
1336
|
((employee.fname || employee.firstName || '') + ' ' + (employee.lname || employee.lastName || '')).trim(),
|
|
1337
1337
|
firstName: employee.fname || employee.firstName || employee.first_name,
|
|
1338
1338
|
lastName: employee.lname || employee.lastName || employee.last_name,
|
|
1339
|
-
employeeId: employee.emp_id || employee.employeeId || employee.employee_id || employeeId
|
|
1339
|
+
employeeId: employee.emp_id || employee.employeeId || employee.employee_id || employeeId,
|
|
1340
|
+
bravaisUserId: employee.bravaisUserId || null,
|
|
1341
|
+
tenantUrl: employee.tenantUrl || null
|
|
1340
1342
|
};
|
|
1341
1343
|
log('Parsed employee data:', employeeLookupData);
|
|
1342
1344
|
// Persist to localStorage for cross-session caching
|
|
@@ -1410,6 +1412,16 @@ function generateLrsBridgeCode(options) {
|
|
|
1410
1412
|
if (employeeData.name && (!actor.name || actor.name === 'Unknown Learner')) {
|
|
1411
1413
|
actor.name = employeeData.name;
|
|
1412
1414
|
}
|
|
1415
|
+
|
|
1416
|
+
// Update account with Bravais user ID and tenant URL if available
|
|
1417
|
+
if (employeeData.bravaisUserId) {
|
|
1418
|
+
var originalAccountName = actor.account ? actor.account.name : null;
|
|
1419
|
+
actor.account = {
|
|
1420
|
+
name: employeeData.bravaisUserId,
|
|
1421
|
+
homePage: employeeData.tenantUrl || (actor.account && actor.account.homePage) || window.location.origin
|
|
1422
|
+
};
|
|
1423
|
+
log('Updated actor account: bravaisUserId=' + employeeData.bravaisUserId + ', homePage=' + actor.account.homePage + ' (was: ' + originalAccountName + ')');
|
|
1424
|
+
}
|
|
1413
1425
|
}
|
|
1414
1426
|
callback(actor);
|
|
1415
1427
|
});
|
|
@@ -1492,16 +1504,9 @@ function generateLrsBridgeCode(options) {
|
|
|
1492
1504
|
name: scormLearnerId
|
|
1493
1505
|
}
|
|
1494
1506
|
};
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
var parts = scormLearnerName.split(',');
|
|
1499
|
-
actor.name = (parts[1] || '').trim() + ' ' + (parts[0] || '').trim();
|
|
1500
|
-
} else {
|
|
1501
|
-
actor.name = scormLearnerName;
|
|
1502
|
-
}
|
|
1503
|
-
}
|
|
1504
|
-
log('Actor source: SCORM API');
|
|
1507
|
+
// Don't use SCORM student_name - it's unreliable ("Last, First" format varies by LMS).
|
|
1508
|
+
// The employee API lookup will provide the correct name and email.
|
|
1509
|
+
log('Actor source: SCORM API (id only, name from employee lookup)');
|
|
1505
1510
|
LRS.actor = actor;
|
|
1506
1511
|
return actor;
|
|
1507
1512
|
}
|
|
@@ -2081,7 +2086,7 @@ function generateLrsBridgeCode(options) {
|
|
|
2081
2086
|
tenantHomepage: null // https://{tenant}.bravais.com format
|
|
2082
2087
|
};
|
|
2083
2088
|
|
|
2084
|
-
// 0. Use baked-in GUIDs from
|
|
2089
|
+
// 0. Use baked-in GUIDs from PA-Patcher config (highest priority - set at wrap time)
|
|
2085
2090
|
if (DOCUMENT_GUID) {
|
|
2086
2091
|
info.guid = DOCUMENT_GUID;
|
|
2087
2092
|
info.id = 'http://xyleme.com/bravais/document/' + DOCUMENT_GUID;
|
|
@@ -2590,6 +2595,11 @@ function generateLrsBridgeCode(options) {
|
|
|
2590
2595
|
// Publish index (default to 1)
|
|
2591
2596
|
ctx.extensions['publishIndex'] = (LRS.courseInfo && LRS.courseInfo.publishIndex) ? LRS.courseInfo.publishIndex : 1;
|
|
2592
2597
|
|
|
2598
|
+
// Employee ID from employee lookup (if available)
|
|
2599
|
+
if (employeeLookupData && employeeLookupData.employeeId) {
|
|
2600
|
+
ctx.extensions['employeeId'] = employeeLookupData.employeeId;
|
|
2601
|
+
}
|
|
2602
|
+
|
|
2593
2603
|
// Xyleme schema version and PII flag
|
|
2594
2604
|
ctx.extensions['http://xyleme.com/bravais/extensions/statement-schema'] = 'xyleme_10';
|
|
2595
2605
|
ctx.extensions['http://xyleme.com/bravais/extensions/protect_pii'] = false;
|
|
@@ -3309,6 +3319,27 @@ function generateLrsBridgeCode(options) {
|
|
|
3309
3319
|
* because the bridge initializes in <head> before LMSInitialize runs.
|
|
3310
3320
|
*/
|
|
3311
3321
|
LRS.refreshActor = function(callback) {
|
|
3322
|
+
// If SCORM API wasn't found during <head> init, re-scan now
|
|
3323
|
+
// (some LMS inject window.API after page starts loading)
|
|
3324
|
+
if (!LRS.scormApi) {
|
|
3325
|
+
log('refreshActor: SCORM API missing, re-scanning...');
|
|
3326
|
+
var api2004 = findAPIInFrameHierarchy('API_1484_11', 10);
|
|
3327
|
+
if (api2004) {
|
|
3328
|
+
LRS.scormApi = api2004.api;
|
|
3329
|
+
LRS.scormApiFound = true;
|
|
3330
|
+
LRS.scormApiType = '2004';
|
|
3331
|
+
log('refreshActor: found SCORM 2004 API');
|
|
3332
|
+
} else {
|
|
3333
|
+
var api12 = findAPIInFrameHierarchy('API', 10);
|
|
3334
|
+
if (api12) {
|
|
3335
|
+
LRS.scormApi = api12.api;
|
|
3336
|
+
LRS.scormApiFound = true;
|
|
3337
|
+
LRS.scormApiType = '1.2';
|
|
3338
|
+
log('refreshActor: found SCORM 1.2 API');
|
|
3339
|
+
}
|
|
3340
|
+
}
|
|
3341
|
+
}
|
|
3342
|
+
|
|
3312
3343
|
// Always-visible diagnostic: confirm refreshActor is being called and show SCORM data (TEMPORARY)
|
|
3313
3344
|
if (window.console && window.console.info) {
|
|
3314
3345
|
var scormId = 'n/a', scormName = 'n/a';
|
|
@@ -4237,7 +4268,7 @@ ${courseLines.join("\n")}
|
|
|
4237
4268
|
},` : "";
|
|
4238
4269
|
return `<!-- === PATCH-ADAMS: JS BEFORE (blocking) === -->
|
|
4239
4270
|
<script data-pa="js-before-loader">
|
|
4240
|
-
// Initialize
|
|
4271
|
+
// Initialize PA-Patcher global namespace IMMEDIATELY (before IIFE)
|
|
4241
4272
|
window.pa_patcher = window.pa_patcher || {
|
|
4242
4273
|
version: '1.0.25',
|
|
4243
4274
|
htmlClass: '${htmlClass}',
|
|
@@ -4282,7 +4313,7 @@ window.pa_patcher = window.pa_patcher || {
|
|
|
4282
4313
|
if (isExtensionError(event.reason)) {
|
|
4283
4314
|
event.preventDefault();
|
|
4284
4315
|
event.stopImmediatePropagation();
|
|
4285
|
-
console.debug('[
|
|
4316
|
+
console.debug('[PA-Patcher] Suppressed browser extension error:', event.reason);
|
|
4286
4317
|
return false;
|
|
4287
4318
|
}
|
|
4288
4319
|
}, true);
|
|
@@ -4292,7 +4323,7 @@ window.pa_patcher = window.pa_patcher || {
|
|
|
4292
4323
|
if (isExtensionError(event.error || event.message)) {
|
|
4293
4324
|
event.preventDefault();
|
|
4294
4325
|
event.stopImmediatePropagation();
|
|
4295
|
-
console.debug('[
|
|
4326
|
+
console.debug('[PA-Patcher] Suppressed browser extension error:', event.message);
|
|
4296
4327
|
return false;
|
|
4297
4328
|
}
|
|
4298
4329
|
}, true);
|
|
@@ -4317,17 +4348,17 @@ window.pa_patcher = window.pa_patcher || {
|
|
|
4317
4348
|
var script = loadJSSync(REMOTE_URL);
|
|
4318
4349
|
|
|
4319
4350
|
script.onerror = function() {
|
|
4320
|
-
console.warn('[
|
|
4351
|
+
console.warn('[PA-Patcher] JS before failed to load from remote, using local fallback');
|
|
4321
4352
|
document.head.removeChild(script);
|
|
4322
4353
|
var fallback = loadJSSync(LOCAL_PATH);
|
|
4323
4354
|
fallback.onload = function() {
|
|
4324
4355
|
if (window.pa_patcher && window.pa_patcher.loaded) {
|
|
4325
4356
|
window.pa_patcher.loaded.jsBefore = true;
|
|
4326
4357
|
}
|
|
4327
|
-
console.log('[
|
|
4358
|
+
console.log('[PA-Patcher] JS before loaded from local fallback:', LOCAL_PATH);
|
|
4328
4359
|
};
|
|
4329
4360
|
fallback.onerror = function() {
|
|
4330
|
-
console.error('[
|
|
4361
|
+
console.error('[PA-Patcher] JS before failed to load from both remote and local');
|
|
4331
4362
|
};
|
|
4332
4363
|
};
|
|
4333
4364
|
|
|
@@ -4335,7 +4366,7 @@ window.pa_patcher = window.pa_patcher || {
|
|
|
4335
4366
|
if (window.pa_patcher && window.pa_patcher.loaded) {
|
|
4336
4367
|
window.pa_patcher.loaded.jsBefore = true;
|
|
4337
4368
|
}
|
|
4338
|
-
console.log('[
|
|
4369
|
+
console.log('[PA-Patcher] JS before loaded from remote:', REMOTE_URL);
|
|
4339
4370
|
};
|
|
4340
4371
|
})();
|
|
4341
4372
|
${lrsBridgeCode}
|
|
@@ -4406,14 +4437,14 @@ function generateJsAfterLoader(options) {
|
|
|
4406
4437
|
if (window.pa_patcher && window.pa_patcher.loaded) {
|
|
4407
4438
|
window.pa_patcher.loaded.jsAfter = true;
|
|
4408
4439
|
}
|
|
4409
|
-
console.log('[
|
|
4440
|
+
console.log('[PA-Patcher] Loading complete, content revealed');
|
|
4410
4441
|
|
|
4411
4442
|
// Add visual badge to indicate patching is active
|
|
4412
4443
|
var badge = document.createElement('div');
|
|
4413
4444
|
badge.setAttribute('data-pa', 'badge');
|
|
4414
4445
|
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;';
|
|
4415
4446
|
badge.textContent = 'PA';
|
|
4416
|
-
badge.title = '
|
|
4447
|
+
badge.title = 'PA-Patcher Active';
|
|
4417
4448
|
badge.onclick = function() { badge.style.display = 'none'; };
|
|
4418
4449
|
document.body.appendChild(badge);
|
|
4419
4450
|
}
|
|
@@ -4429,7 +4460,7 @@ function generateJsAfterLoader(options) {
|
|
|
4429
4460
|
if (loaded) return;
|
|
4430
4461
|
loaded = true;
|
|
4431
4462
|
clearTimeout(timeoutId);
|
|
4432
|
-
console.log('[
|
|
4463
|
+
console.log('[PA-Patcher] JS after loaded from remote:', REMOTE_URL);
|
|
4433
4464
|
// Give the script a moment to execute, then remove loading class
|
|
4434
4465
|
setTimeout(removeLoadingClass, 50);
|
|
4435
4466
|
},
|
|
@@ -4445,7 +4476,7 @@ function generateJsAfterLoader(options) {
|
|
|
4445
4476
|
timeoutId = setTimeout(function() {
|
|
4446
4477
|
if (loaded) return;
|
|
4447
4478
|
loaded = true;
|
|
4448
|
-
console.warn('[
|
|
4479
|
+
console.warn('[PA-Patcher] JS after timed out, using local fallback');
|
|
4449
4480
|
if (remoteScript.parentNode) {
|
|
4450
4481
|
document.body.removeChild(remoteScript);
|
|
4451
4482
|
}
|
|
@@ -4457,11 +4488,11 @@ function generateJsAfterLoader(options) {
|
|
|
4457
4488
|
loadJS(
|
|
4458
4489
|
LOCAL_PATH,
|
|
4459
4490
|
function() {
|
|
4460
|
-
console.log('[
|
|
4491
|
+
console.log('[PA-Patcher] JS after loaded from local fallback:', LOCAL_PATH);
|
|
4461
4492
|
setTimeout(removeLoadingClass, 50);
|
|
4462
4493
|
},
|
|
4463
4494
|
function() {
|
|
4464
|
-
console.error('[
|
|
4495
|
+
console.error('[PA-Patcher] JS after failed to load from both remote and local');
|
|
4465
4496
|
// Still remove loading class so content is visible even if JS fails
|
|
4466
4497
|
removeLoadingClass();
|
|
4467
4498
|
}
|
|
@@ -4921,7 +4952,7 @@ var ManifestUpdater = class {
|
|
|
4921
4952
|
const resourceClosePattern = /(\s*)<\/resource>/i;
|
|
4922
4953
|
const match = xmlContent.match(resourceClosePattern);
|
|
4923
4954
|
if (!match) {
|
|
4924
|
-
console.warn("[
|
|
4955
|
+
console.warn("[PA-Patcher] Could not find </resource> tag in imsmanifest.xml");
|
|
4925
4956
|
return [];
|
|
4926
4957
|
}
|
|
4927
4958
|
const updatedXml = xmlContent.replace(
|
|
@@ -4933,7 +4964,7 @@ $1</resource>`
|
|
|
4933
4964
|
zip.updateFile("imsmanifest.xml", Buffer.from(updatedXml, "utf-8"));
|
|
4934
4965
|
return ["imsmanifest.xml"];
|
|
4935
4966
|
} catch (error) {
|
|
4936
|
-
console.error("[
|
|
4967
|
+
console.error("[PA-Patcher] Failed to update imsmanifest.xml:", error);
|
|
4937
4968
|
return [];
|
|
4938
4969
|
}
|
|
4939
4970
|
}
|
|
@@ -5565,7 +5596,7 @@ ${js.after}
|
|
|
5565
5596
|
var pluginRegistry = new PluginRegistry();
|
|
5566
5597
|
|
|
5567
5598
|
// src/patcher/index.ts
|
|
5568
|
-
var DEFAULT_CSS_BEFORE = `/*
|
|
5599
|
+
var DEFAULT_CSS_BEFORE = `/* PA-Patcher: CSS Before (blocking)
|
|
5569
5600
|
* This file loads at the start of <head> and blocks rendering.
|
|
5570
5601
|
* Use it to hide content and prevent flash of unstyled content.
|
|
5571
5602
|
*
|
|
@@ -5575,7 +5606,7 @@ var DEFAULT_CSS_BEFORE = `/* Patch-Adams: CSS Before (blocking)
|
|
|
5575
5606
|
* }
|
|
5576
5607
|
*/
|
|
5577
5608
|
`;
|
|
5578
|
-
var DEFAULT_CSS_AFTER = `/*
|
|
5609
|
+
var DEFAULT_CSS_AFTER = `/* PA-Patcher: CSS After (async)
|
|
5579
5610
|
* This file loads at the end of <head> with remote fallback.
|
|
5580
5611
|
* Use it for style overrides that take precedence over Rise styles.
|
|
5581
5612
|
*
|
|
@@ -5585,7 +5616,7 @@ var DEFAULT_CSS_AFTER = `/* Patch-Adams: CSS After (async)
|
|
|
5585
5616
|
* }
|
|
5586
5617
|
*/
|
|
5587
5618
|
`;
|
|
5588
|
-
var DEFAULT_JS_BEFORE = `//
|
|
5619
|
+
var DEFAULT_JS_BEFORE = `// PA-Patcher: JS Before (blocking)
|
|
5589
5620
|
// This file loads at the start of <head> and blocks rendering.
|
|
5590
5621
|
// Use it for setup, API interception, and preparing globals.
|
|
5591
5622
|
//
|
|
@@ -5595,9 +5626,9 @@ var DEFAULT_JS_BEFORE = `// Patch-Adams: JS Before (blocking)
|
|
|
5595
5626
|
// analytics: true
|
|
5596
5627
|
// };
|
|
5597
5628
|
|
|
5598
|
-
console.log('[
|
|
5629
|
+
console.log('[PA-Patcher] JS Before loaded');
|
|
5599
5630
|
`;
|
|
5600
|
-
var DEFAULT_JS_AFTER = `//
|
|
5631
|
+
var DEFAULT_JS_AFTER = `// PA-Patcher: JS After (async)
|
|
5601
5632
|
// This file loads at the end of <body> with remote fallback.
|
|
5602
5633
|
// Use it for DOM manipulation after Rise has initialized.
|
|
5603
5634
|
//
|
|
@@ -5609,7 +5640,7 @@ var DEFAULT_JS_AFTER = `// Patch-Adams: JS After (async)
|
|
|
5609
5640
|
// // Your modifications here
|
|
5610
5641
|
// });
|
|
5611
5642
|
|
|
5612
|
-
console.log('[
|
|
5643
|
+
console.log('[PA-Patcher] JS After loaded');
|
|
5613
5644
|
`;
|
|
5614
5645
|
var Patcher = class {
|
|
5615
5646
|
config;
|