@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 CHANGED
@@ -622,13 +622,13 @@ html.${htmlClass}.${loadingClass} body {
622
622
  var link = loadCSSSync(REMOTE_URL);
623
623
 
624
624
  link.onerror = function() {
625
- console.warn('[Patch-Adams] CSS before failed to load from remote, using local fallback');
625
+ console.warn('[PA-Patcher] CSS before failed to load from remote, using local fallback');
626
626
  document.head.removeChild(link);
627
627
  loadCSSSync(LOCAL_PATH);
628
628
  };
629
629
 
630
630
  link.onload = function() {
631
- console.log('[Patch-Adams] CSS before loaded from remote:', REMOTE_URL);
631
+ console.log('[PA-Patcher] CSS before loaded from remote:', REMOTE_URL);
632
632
  };
633
633
  })();
634
634
  </script>`;
@@ -682,7 +682,7 @@ function generateCssAfterLoader(options) {
682
682
  if (loaded) return;
683
683
  loaded = true;
684
684
  clearTimeout(timeoutId);
685
- console.log('[Patch-Adams] CSS after loaded from remote:', REMOTE_URL);
685
+ console.log('[PA-Patcher] CSS after loaded from remote:', REMOTE_URL);
686
686
  },
687
687
  function() {
688
688
  if (loaded) return;
@@ -696,7 +696,7 @@ function generateCssAfterLoader(options) {
696
696
  timeoutId = setTimeout(function() {
697
697
  if (loaded) return;
698
698
  loaded = true;
699
- console.warn('[Patch-Adams] CSS after timed out, using local fallback');
699
+ console.warn('[PA-Patcher] CSS after timed out, using local fallback');
700
700
  if (remoteLink.parentNode) {
701
701
  document.head.removeChild(remoteLink);
702
702
  }
@@ -708,10 +708,10 @@ function generateCssAfterLoader(options) {
708
708
  loadCSS(
709
709
  LOCAL_PATH,
710
710
  function() {
711
- console.log('[Patch-Adams] CSS after loaded from local fallback:', LOCAL_PATH);
711
+ console.log('[PA-Patcher] CSS after loaded from local fallback:', LOCAL_PATH);
712
712
  },
713
713
  function() {
714
- console.error('[Patch-Adams] CSS after failed to load from both remote and local');
714
+ console.error('[PA-Patcher] CSS after failed to load from both remote and local');
715
715
  }
716
716
  );
717
717
  }
@@ -1676,7 +1676,9 @@ function generateLrsBridgeCode(options) {
1676
1676
  ((employee.fname || employee.firstName || '') + ' ' + (employee.lname || employee.lastName || '')).trim(),
1677
1677
  firstName: employee.fname || employee.firstName || employee.first_name,
1678
1678
  lastName: employee.lname || employee.lastName || employee.last_name,
1679
- employeeId: employee.emp_id || employee.employeeId || employee.employee_id || employeeId
1679
+ employeeId: employee.emp_id || employee.employeeId || employee.employee_id || employeeId,
1680
+ bravaisUserId: employee.bravaisUserId || null,
1681
+ tenantUrl: employee.tenantUrl || null
1680
1682
  };
1681
1683
  log('Parsed employee data:', employeeLookupData);
1682
1684
  // Persist to localStorage for cross-session caching
@@ -1750,6 +1752,16 @@ function generateLrsBridgeCode(options) {
1750
1752
  if (employeeData.name && (!actor.name || actor.name === 'Unknown Learner')) {
1751
1753
  actor.name = employeeData.name;
1752
1754
  }
1755
+
1756
+ // Update account with Bravais user ID and tenant URL if available
1757
+ if (employeeData.bravaisUserId) {
1758
+ var originalAccountName = actor.account ? actor.account.name : null;
1759
+ actor.account = {
1760
+ name: employeeData.bravaisUserId,
1761
+ homePage: employeeData.tenantUrl || (actor.account && actor.account.homePage) || window.location.origin
1762
+ };
1763
+ log('Updated actor account: bravaisUserId=' + employeeData.bravaisUserId + ', homePage=' + actor.account.homePage + ' (was: ' + originalAccountName + ')');
1764
+ }
1753
1765
  }
1754
1766
  callback(actor);
1755
1767
  });
@@ -1832,16 +1844,9 @@ function generateLrsBridgeCode(options) {
1832
1844
  name: scormLearnerId
1833
1845
  }
1834
1846
  };
1835
- if (scormLearnerName) {
1836
- // Handle "LastName, FirstName" format
1837
- if (scormLearnerName.indexOf(',') > -1) {
1838
- var parts = scormLearnerName.split(',');
1839
- actor.name = (parts[1] || '').trim() + ' ' + (parts[0] || '').trim();
1840
- } else {
1841
- actor.name = scormLearnerName;
1842
- }
1843
- }
1844
- log('Actor source: SCORM API');
1847
+ // Don't use SCORM student_name - it's unreliable ("Last, First" format varies by LMS).
1848
+ // The employee API lookup will provide the correct name and email.
1849
+ log('Actor source: SCORM API (id only, name from employee lookup)');
1845
1850
  LRS.actor = actor;
1846
1851
  return actor;
1847
1852
  }
@@ -2421,7 +2426,7 @@ function generateLrsBridgeCode(options) {
2421
2426
  tenantHomepage: null // https://{tenant}.bravais.com format
2422
2427
  };
2423
2428
 
2424
- // 0. Use baked-in GUIDs from Patch-Adams config (highest priority - set at wrap time)
2429
+ // 0. Use baked-in GUIDs from PA-Patcher config (highest priority - set at wrap time)
2425
2430
  if (DOCUMENT_GUID) {
2426
2431
  info.guid = DOCUMENT_GUID;
2427
2432
  info.id = 'http://xyleme.com/bravais/document/' + DOCUMENT_GUID;
@@ -2930,6 +2935,11 @@ function generateLrsBridgeCode(options) {
2930
2935
  // Publish index (default to 1)
2931
2936
  ctx.extensions['publishIndex'] = (LRS.courseInfo && LRS.courseInfo.publishIndex) ? LRS.courseInfo.publishIndex : 1;
2932
2937
 
2938
+ // Employee ID from employee lookup (if available)
2939
+ if (employeeLookupData && employeeLookupData.employeeId) {
2940
+ ctx.extensions['employeeId'] = employeeLookupData.employeeId;
2941
+ }
2942
+
2933
2943
  // Xyleme schema version and PII flag
2934
2944
  ctx.extensions['http://xyleme.com/bravais/extensions/statement-schema'] = 'xyleme_10';
2935
2945
  ctx.extensions['http://xyleme.com/bravais/extensions/protect_pii'] = false;
@@ -3649,6 +3659,27 @@ function generateLrsBridgeCode(options) {
3649
3659
  * because the bridge initializes in <head> before LMSInitialize runs.
3650
3660
  */
3651
3661
  LRS.refreshActor = function(callback) {
3662
+ // If SCORM API wasn't found during <head> init, re-scan now
3663
+ // (some LMS inject window.API after page starts loading)
3664
+ if (!LRS.scormApi) {
3665
+ log('refreshActor: SCORM API missing, re-scanning...');
3666
+ var api2004 = findAPIInFrameHierarchy('API_1484_11', 10);
3667
+ if (api2004) {
3668
+ LRS.scormApi = api2004.api;
3669
+ LRS.scormApiFound = true;
3670
+ LRS.scormApiType = '2004';
3671
+ log('refreshActor: found SCORM 2004 API');
3672
+ } else {
3673
+ var api12 = findAPIInFrameHierarchy('API', 10);
3674
+ if (api12) {
3675
+ LRS.scormApi = api12.api;
3676
+ LRS.scormApiFound = true;
3677
+ LRS.scormApiType = '1.2';
3678
+ log('refreshActor: found SCORM 1.2 API');
3679
+ }
3680
+ }
3681
+ }
3682
+
3652
3683
  // Always-visible diagnostic: confirm refreshActor is being called and show SCORM data (TEMPORARY)
3653
3684
  if (window.console && window.console.info) {
3654
3685
  var scormId = 'n/a', scormName = 'n/a';
@@ -4577,7 +4608,7 @@ ${courseLines.join("\n")}
4577
4608
  },` : "";
4578
4609
  return `<!-- === PATCH-ADAMS: JS BEFORE (blocking) === -->
4579
4610
  <script data-pa="js-before-loader">
4580
- // Initialize Patch-Adams global namespace IMMEDIATELY (before IIFE)
4611
+ // Initialize PA-Patcher global namespace IMMEDIATELY (before IIFE)
4581
4612
  window.pa_patcher = window.pa_patcher || {
4582
4613
  version: '1.0.25',
4583
4614
  htmlClass: '${htmlClass}',
@@ -4622,7 +4653,7 @@ window.pa_patcher = window.pa_patcher || {
4622
4653
  if (isExtensionError(event.reason)) {
4623
4654
  event.preventDefault();
4624
4655
  event.stopImmediatePropagation();
4625
- console.debug('[Patch-Adams] Suppressed browser extension error:', event.reason);
4656
+ console.debug('[PA-Patcher] Suppressed browser extension error:', event.reason);
4626
4657
  return false;
4627
4658
  }
4628
4659
  }, true);
@@ -4632,7 +4663,7 @@ window.pa_patcher = window.pa_patcher || {
4632
4663
  if (isExtensionError(event.error || event.message)) {
4633
4664
  event.preventDefault();
4634
4665
  event.stopImmediatePropagation();
4635
- console.debug('[Patch-Adams] Suppressed browser extension error:', event.message);
4666
+ console.debug('[PA-Patcher] Suppressed browser extension error:', event.message);
4636
4667
  return false;
4637
4668
  }
4638
4669
  }, true);
@@ -4657,17 +4688,17 @@ window.pa_patcher = window.pa_patcher || {
4657
4688
  var script = loadJSSync(REMOTE_URL);
4658
4689
 
4659
4690
  script.onerror = function() {
4660
- console.warn('[Patch-Adams] JS before failed to load from remote, using local fallback');
4691
+ console.warn('[PA-Patcher] JS before failed to load from remote, using local fallback');
4661
4692
  document.head.removeChild(script);
4662
4693
  var fallback = loadJSSync(LOCAL_PATH);
4663
4694
  fallback.onload = function() {
4664
4695
  if (window.pa_patcher && window.pa_patcher.loaded) {
4665
4696
  window.pa_patcher.loaded.jsBefore = true;
4666
4697
  }
4667
- console.log('[Patch-Adams] JS before loaded from local fallback:', LOCAL_PATH);
4698
+ console.log('[PA-Patcher] JS before loaded from local fallback:', LOCAL_PATH);
4668
4699
  };
4669
4700
  fallback.onerror = function() {
4670
- console.error('[Patch-Adams] JS before failed to load from both remote and local');
4701
+ console.error('[PA-Patcher] JS before failed to load from both remote and local');
4671
4702
  };
4672
4703
  };
4673
4704
 
@@ -4675,7 +4706,7 @@ window.pa_patcher = window.pa_patcher || {
4675
4706
  if (window.pa_patcher && window.pa_patcher.loaded) {
4676
4707
  window.pa_patcher.loaded.jsBefore = true;
4677
4708
  }
4678
- console.log('[Patch-Adams] JS before loaded from remote:', REMOTE_URL);
4709
+ console.log('[PA-Patcher] JS before loaded from remote:', REMOTE_URL);
4679
4710
  };
4680
4711
  })();
4681
4712
  ${lrsBridgeCode}
@@ -4746,14 +4777,14 @@ function generateJsAfterLoader(options) {
4746
4777
  if (window.pa_patcher && window.pa_patcher.loaded) {
4747
4778
  window.pa_patcher.loaded.jsAfter = true;
4748
4779
  }
4749
- console.log('[Patch-Adams] Loading complete, content revealed');
4780
+ console.log('[PA-Patcher] Loading complete, content revealed');
4750
4781
 
4751
4782
  // Add visual badge to indicate patching is active
4752
4783
  var badge = document.createElement('div');
4753
4784
  badge.setAttribute('data-pa', 'badge');
4754
4785
  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;';
4755
4786
  badge.textContent = 'PA';
4756
- badge.title = 'Patch-Adams Active';
4787
+ badge.title = 'PA-Patcher Active';
4757
4788
  badge.onclick = function() { badge.style.display = 'none'; };
4758
4789
  document.body.appendChild(badge);
4759
4790
  }
@@ -4769,7 +4800,7 @@ function generateJsAfterLoader(options) {
4769
4800
  if (loaded) return;
4770
4801
  loaded = true;
4771
4802
  clearTimeout(timeoutId);
4772
- console.log('[Patch-Adams] JS after loaded from remote:', REMOTE_URL);
4803
+ console.log('[PA-Patcher] JS after loaded from remote:', REMOTE_URL);
4773
4804
  // Give the script a moment to execute, then remove loading class
4774
4805
  setTimeout(removeLoadingClass, 50);
4775
4806
  },
@@ -4785,7 +4816,7 @@ function generateJsAfterLoader(options) {
4785
4816
  timeoutId = setTimeout(function() {
4786
4817
  if (loaded) return;
4787
4818
  loaded = true;
4788
- console.warn('[Patch-Adams] JS after timed out, using local fallback');
4819
+ console.warn('[PA-Patcher] JS after timed out, using local fallback');
4789
4820
  if (remoteScript.parentNode) {
4790
4821
  document.body.removeChild(remoteScript);
4791
4822
  }
@@ -4797,11 +4828,11 @@ function generateJsAfterLoader(options) {
4797
4828
  loadJS(
4798
4829
  LOCAL_PATH,
4799
4830
  function() {
4800
- console.log('[Patch-Adams] JS after loaded from local fallback:', LOCAL_PATH);
4831
+ console.log('[PA-Patcher] JS after loaded from local fallback:', LOCAL_PATH);
4801
4832
  setTimeout(removeLoadingClass, 50);
4802
4833
  },
4803
4834
  function() {
4804
- console.error('[Patch-Adams] JS after failed to load from both remote and local');
4835
+ console.error('[PA-Patcher] JS after failed to load from both remote and local');
4805
4836
  // Still remove loading class so content is visible even if JS fails
4806
4837
  removeLoadingClass();
4807
4838
  }
@@ -5261,7 +5292,7 @@ var ManifestUpdater = class {
5261
5292
  const resourceClosePattern = /(\s*)<\/resource>/i;
5262
5293
  const match = xmlContent.match(resourceClosePattern);
5263
5294
  if (!match) {
5264
- console.warn("[Patch-Adams] Could not find </resource> tag in imsmanifest.xml");
5295
+ console.warn("[PA-Patcher] Could not find </resource> tag in imsmanifest.xml");
5265
5296
  return [];
5266
5297
  }
5267
5298
  const updatedXml = xmlContent.replace(
@@ -5273,7 +5304,7 @@ $1</resource>`
5273
5304
  zip.updateFile("imsmanifest.xml", Buffer.from(updatedXml, "utf-8"));
5274
5305
  return ["imsmanifest.xml"];
5275
5306
  } catch (error) {
5276
- console.error("[Patch-Adams] Failed to update imsmanifest.xml:", error);
5307
+ console.error("[PA-Patcher] Failed to update imsmanifest.xml:", error);
5277
5308
  return [];
5278
5309
  }
5279
5310
  }
@@ -5595,7 +5626,7 @@ ${js.after}
5595
5626
  var pluginRegistry = new PluginRegistry();
5596
5627
 
5597
5628
  // src/patcher/index.ts
5598
- var DEFAULT_CSS_BEFORE = `/* Patch-Adams: CSS Before (blocking)
5629
+ var DEFAULT_CSS_BEFORE = `/* PA-Patcher: CSS Before (blocking)
5599
5630
  * This file loads at the start of <head> and blocks rendering.
5600
5631
  * Use it to hide content and prevent flash of unstyled content.
5601
5632
  *
@@ -5605,7 +5636,7 @@ var DEFAULT_CSS_BEFORE = `/* Patch-Adams: CSS Before (blocking)
5605
5636
  * }
5606
5637
  */
5607
5638
  `;
5608
- var DEFAULT_CSS_AFTER = `/* Patch-Adams: CSS After (async)
5639
+ var DEFAULT_CSS_AFTER = `/* PA-Patcher: CSS After (async)
5609
5640
  * This file loads at the end of <head> with remote fallback.
5610
5641
  * Use it for style overrides that take precedence over Rise styles.
5611
5642
  *
@@ -5615,7 +5646,7 @@ var DEFAULT_CSS_AFTER = `/* Patch-Adams: CSS After (async)
5615
5646
  * }
5616
5647
  */
5617
5648
  `;
5618
- var DEFAULT_JS_BEFORE = `// Patch-Adams: JS Before (blocking)
5649
+ var DEFAULT_JS_BEFORE = `// PA-Patcher: JS Before (blocking)
5619
5650
  // This file loads at the start of <head> and blocks rendering.
5620
5651
  // Use it for setup, API interception, and preparing globals.
5621
5652
  //
@@ -5625,9 +5656,9 @@ var DEFAULT_JS_BEFORE = `// Patch-Adams: JS Before (blocking)
5625
5656
  // analytics: true
5626
5657
  // };
5627
5658
 
5628
- console.log('[Patch-Adams] JS Before loaded');
5659
+ console.log('[PA-Patcher] JS Before loaded');
5629
5660
  `;
5630
- var DEFAULT_JS_AFTER = `// Patch-Adams: JS After (async)
5661
+ var DEFAULT_JS_AFTER = `// PA-Patcher: JS After (async)
5631
5662
  // This file loads at the end of <body> with remote fallback.
5632
5663
  // Use it for DOM manipulation after Rise has initialized.
5633
5664
  //
@@ -5639,7 +5670,7 @@ var DEFAULT_JS_AFTER = `// Patch-Adams: JS After (async)
5639
5670
  // // Your modifications here
5640
5671
  // });
5641
5672
 
5642
- console.log('[Patch-Adams] JS After loaded');
5673
+ console.log('[PA-Patcher] JS After loaded');
5643
5674
  `;
5644
5675
  var Patcher = class {
5645
5676
  config;