@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/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('[Patch-Adams] CSS before failed to load from remote, using local fallback');
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('[Patch-Adams] CSS before loaded from remote:', REMOTE_URL);
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('[Patch-Adams] CSS after loaded from remote:', REMOTE_URL);
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('[Patch-Adams] CSS after timed out, using local fallback');
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('[Patch-Adams] CSS after loaded from local fallback:', LOCAL_PATH);
361
+ console.log('[PA-Patcher] CSS after loaded from local fallback:', LOCAL_PATH);
362
362
  },
363
363
  function() {
364
- console.error('[Patch-Adams] CSS after failed to load from both remote and local');
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
  });
@@ -2082,7 +2094,7 @@ function generateLrsBridgeCode(options) {
2082
2094
  tenantHomepage: null // https://{tenant}.bravais.com format
2083
2095
  };
2084
2096
 
2085
- // 0. Use baked-in GUIDs from Patch-Adams config (highest priority - set at wrap time)
2097
+ // 0. Use baked-in GUIDs from PA-Patcher config (highest priority - set at wrap time)
2086
2098
  if (DOCUMENT_GUID) {
2087
2099
  info.guid = DOCUMENT_GUID;
2088
2100
  info.id = 'http://xyleme.com/bravais/document/' + DOCUMENT_GUID;
@@ -2591,6 +2603,11 @@ function generateLrsBridgeCode(options) {
2591
2603
  // Publish index (default to 1)
2592
2604
  ctx.extensions['publishIndex'] = (LRS.courseInfo && LRS.courseInfo.publishIndex) ? LRS.courseInfo.publishIndex : 1;
2593
2605
 
2606
+ // Employee ID from employee lookup (if available)
2607
+ if (employeeLookupData && employeeLookupData.employeeId) {
2608
+ ctx.extensions['employeeId'] = employeeLookupData.employeeId;
2609
+ }
2610
+
2594
2611
  // Xyleme schema version and PII flag
2595
2612
  ctx.extensions['http://xyleme.com/bravais/extensions/statement-schema'] = 'xyleme_10';
2596
2613
  ctx.extensions['http://xyleme.com/bravais/extensions/protect_pii'] = false;
@@ -4259,7 +4276,7 @@ ${courseLines.join("\n")}
4259
4276
  },` : "";
4260
4277
  return `<!-- === PATCH-ADAMS: JS BEFORE (blocking) === -->
4261
4278
  <script data-pa="js-before-loader">
4262
- // Initialize Patch-Adams global namespace IMMEDIATELY (before IIFE)
4279
+ // Initialize PA-Patcher global namespace IMMEDIATELY (before IIFE)
4263
4280
  window.pa_patcher = window.pa_patcher || {
4264
4281
  version: '1.0.25',
4265
4282
  htmlClass: '${htmlClass}',
@@ -4304,7 +4321,7 @@ window.pa_patcher = window.pa_patcher || {
4304
4321
  if (isExtensionError(event.reason)) {
4305
4322
  event.preventDefault();
4306
4323
  event.stopImmediatePropagation();
4307
- console.debug('[Patch-Adams] Suppressed browser extension error:', event.reason);
4324
+ console.debug('[PA-Patcher] Suppressed browser extension error:', event.reason);
4308
4325
  return false;
4309
4326
  }
4310
4327
  }, true);
@@ -4314,7 +4331,7 @@ window.pa_patcher = window.pa_patcher || {
4314
4331
  if (isExtensionError(event.error || event.message)) {
4315
4332
  event.preventDefault();
4316
4333
  event.stopImmediatePropagation();
4317
- console.debug('[Patch-Adams] Suppressed browser extension error:', event.message);
4334
+ console.debug('[PA-Patcher] Suppressed browser extension error:', event.message);
4318
4335
  return false;
4319
4336
  }
4320
4337
  }, true);
@@ -4339,17 +4356,17 @@ window.pa_patcher = window.pa_patcher || {
4339
4356
  var script = loadJSSync(REMOTE_URL);
4340
4357
 
4341
4358
  script.onerror = function() {
4342
- console.warn('[Patch-Adams] JS before failed to load from remote, using local fallback');
4359
+ console.warn('[PA-Patcher] JS before failed to load from remote, using local fallback');
4343
4360
  document.head.removeChild(script);
4344
4361
  var fallback = loadJSSync(LOCAL_PATH);
4345
4362
  fallback.onload = function() {
4346
4363
  if (window.pa_patcher && window.pa_patcher.loaded) {
4347
4364
  window.pa_patcher.loaded.jsBefore = true;
4348
4365
  }
4349
- console.log('[Patch-Adams] JS before loaded from local fallback:', LOCAL_PATH);
4366
+ console.log('[PA-Patcher] JS before loaded from local fallback:', LOCAL_PATH);
4350
4367
  };
4351
4368
  fallback.onerror = function() {
4352
- console.error('[Patch-Adams] JS before failed to load from both remote and local');
4369
+ console.error('[PA-Patcher] JS before failed to load from both remote and local');
4353
4370
  };
4354
4371
  };
4355
4372
 
@@ -4357,7 +4374,7 @@ window.pa_patcher = window.pa_patcher || {
4357
4374
  if (window.pa_patcher && window.pa_patcher.loaded) {
4358
4375
  window.pa_patcher.loaded.jsBefore = true;
4359
4376
  }
4360
- console.log('[Patch-Adams] JS before loaded from remote:', REMOTE_URL);
4377
+ console.log('[PA-Patcher] JS before loaded from remote:', REMOTE_URL);
4361
4378
  };
4362
4379
  })();
4363
4380
  ${lrsBridgeCode}
@@ -4428,14 +4445,14 @@ function generateJsAfterLoader(options) {
4428
4445
  if (window.pa_patcher && window.pa_patcher.loaded) {
4429
4446
  window.pa_patcher.loaded.jsAfter = true;
4430
4447
  }
4431
- console.log('[Patch-Adams] Loading complete, content revealed');
4448
+ console.log('[PA-Patcher] Loading complete, content revealed');
4432
4449
 
4433
4450
  // Add visual badge to indicate patching is active
4434
4451
  var badge = document.createElement('div');
4435
4452
  badge.setAttribute('data-pa', 'badge');
4436
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;';
4437
4454
  badge.textContent = 'PA';
4438
- badge.title = 'Patch-Adams Active';
4455
+ badge.title = 'PA-Patcher Active';
4439
4456
  badge.onclick = function() { badge.style.display = 'none'; };
4440
4457
  document.body.appendChild(badge);
4441
4458
  }
@@ -4451,7 +4468,7 @@ function generateJsAfterLoader(options) {
4451
4468
  if (loaded) return;
4452
4469
  loaded = true;
4453
4470
  clearTimeout(timeoutId);
4454
- console.log('[Patch-Adams] JS after loaded from remote:', REMOTE_URL);
4471
+ console.log('[PA-Patcher] JS after loaded from remote:', REMOTE_URL);
4455
4472
  // Give the script a moment to execute, then remove loading class
4456
4473
  setTimeout(removeLoadingClass, 50);
4457
4474
  },
@@ -4467,7 +4484,7 @@ function generateJsAfterLoader(options) {
4467
4484
  timeoutId = setTimeout(function() {
4468
4485
  if (loaded) return;
4469
4486
  loaded = true;
4470
- console.warn('[Patch-Adams] JS after timed out, using local fallback');
4487
+ console.warn('[PA-Patcher] JS after timed out, using local fallback');
4471
4488
  if (remoteScript.parentNode) {
4472
4489
  document.body.removeChild(remoteScript);
4473
4490
  }
@@ -4479,11 +4496,11 @@ function generateJsAfterLoader(options) {
4479
4496
  loadJS(
4480
4497
  LOCAL_PATH,
4481
4498
  function() {
4482
- console.log('[Patch-Adams] JS after loaded from local fallback:', LOCAL_PATH);
4499
+ console.log('[PA-Patcher] JS after loaded from local fallback:', LOCAL_PATH);
4483
4500
  setTimeout(removeLoadingClass, 50);
4484
4501
  },
4485
4502
  function() {
4486
- console.error('[Patch-Adams] JS after failed to load from both remote and local');
4503
+ console.error('[PA-Patcher] JS after failed to load from both remote and local');
4487
4504
  // Still remove loading class so content is visible even if JS fails
4488
4505
  removeLoadingClass();
4489
4506
  }
@@ -4943,7 +4960,7 @@ var ManifestUpdater = class {
4943
4960
  const resourceClosePattern = /(\s*)<\/resource>/i;
4944
4961
  const match = xmlContent.match(resourceClosePattern);
4945
4962
  if (!match) {
4946
- console.warn("[Patch-Adams] Could not find </resource> tag in imsmanifest.xml");
4963
+ console.warn("[PA-Patcher] Could not find </resource> tag in imsmanifest.xml");
4947
4964
  return [];
4948
4965
  }
4949
4966
  const updatedXml = xmlContent.replace(
@@ -4955,7 +4972,7 @@ $1</resource>`
4955
4972
  zip.updateFile("imsmanifest.xml", Buffer.from(updatedXml, "utf-8"));
4956
4973
  return ["imsmanifest.xml"];
4957
4974
  } catch (error) {
4958
- console.error("[Patch-Adams] Failed to update imsmanifest.xml:", error);
4975
+ console.error("[PA-Patcher] Failed to update imsmanifest.xml:", error);
4959
4976
  return [];
4960
4977
  }
4961
4978
  }
@@ -5587,7 +5604,7 @@ ${js.after}
5587
5604
  var pluginRegistry = new PluginRegistry();
5588
5605
 
5589
5606
  // src/patcher/index.ts
5590
- var DEFAULT_CSS_BEFORE = `/* Patch-Adams: CSS Before (blocking)
5607
+ var DEFAULT_CSS_BEFORE = `/* PA-Patcher: CSS Before (blocking)
5591
5608
  * This file loads at the start of <head> and blocks rendering.
5592
5609
  * Use it to hide content and prevent flash of unstyled content.
5593
5610
  *
@@ -5597,7 +5614,7 @@ var DEFAULT_CSS_BEFORE = `/* Patch-Adams: CSS Before (blocking)
5597
5614
  * }
5598
5615
  */
5599
5616
  `;
5600
- var DEFAULT_CSS_AFTER = `/* Patch-Adams: CSS After (async)
5617
+ var DEFAULT_CSS_AFTER = `/* PA-Patcher: CSS After (async)
5601
5618
  * This file loads at the end of <head> with remote fallback.
5602
5619
  * Use it for style overrides that take precedence over Rise styles.
5603
5620
  *
@@ -5607,7 +5624,7 @@ var DEFAULT_CSS_AFTER = `/* Patch-Adams: CSS After (async)
5607
5624
  * }
5608
5625
  */
5609
5626
  `;
5610
- var DEFAULT_JS_BEFORE = `// Patch-Adams: JS Before (blocking)
5627
+ var DEFAULT_JS_BEFORE = `// PA-Patcher: JS Before (blocking)
5611
5628
  // This file loads at the start of <head> and blocks rendering.
5612
5629
  // Use it for setup, API interception, and preparing globals.
5613
5630
  //
@@ -5617,9 +5634,9 @@ var DEFAULT_JS_BEFORE = `// Patch-Adams: JS Before (blocking)
5617
5634
  // analytics: true
5618
5635
  // };
5619
5636
 
5620
- console.log('[Patch-Adams] JS Before loaded');
5637
+ console.log('[PA-Patcher] JS Before loaded');
5621
5638
  `;
5622
- var DEFAULT_JS_AFTER = `// Patch-Adams: JS After (async)
5639
+ var DEFAULT_JS_AFTER = `// PA-Patcher: JS After (async)
5623
5640
  // This file loads at the end of <body> with remote fallback.
5624
5641
  // Use it for DOM manipulation after Rise has initialized.
5625
5642
  //
@@ -5631,7 +5648,7 @@ var DEFAULT_JS_AFTER = `// Patch-Adams: JS After (async)
5631
5648
  // // Your modifications here
5632
5649
  // });
5633
5650
 
5634
- console.log('[Patch-Adams] JS After loaded');
5651
+ console.log('[PA-Patcher] JS After loaded');
5635
5652
  `;
5636
5653
  var Patcher = class {
5637
5654
  config;