@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.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 Patch-Adams
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 Patch-Adams
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('[Patch-Adams] CSS before failed to load from remote, using local fallback');
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('[Patch-Adams] CSS before loaded from remote:', REMOTE_URL);
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('[Patch-Adams] CSS after loaded from remote:', REMOTE_URL);
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('[Patch-Adams] CSS after timed out, using local fallback');
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('[Patch-Adams] CSS after loaded from local fallback:', LOCAL_PATH);
353
+ console.log('[PA-Patcher] CSS after loaded from local fallback:', LOCAL_PATH);
354
354
  },
355
355
  function() {
356
- console.error('[Patch-Adams] CSS after failed to load from both remote and local');
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
  });
@@ -2074,7 +2086,7 @@ function generateLrsBridgeCode(options) {
2074
2086
  tenantHomepage: null // https://{tenant}.bravais.com format
2075
2087
  };
2076
2088
 
2077
- // 0. Use baked-in GUIDs from Patch-Adams config (highest priority - set at wrap time)
2089
+ // 0. Use baked-in GUIDs from PA-Patcher config (highest priority - set at wrap time)
2078
2090
  if (DOCUMENT_GUID) {
2079
2091
  info.guid = DOCUMENT_GUID;
2080
2092
  info.id = 'http://xyleme.com/bravais/document/' + DOCUMENT_GUID;
@@ -2583,6 +2595,11 @@ function generateLrsBridgeCode(options) {
2583
2595
  // Publish index (default to 1)
2584
2596
  ctx.extensions['publishIndex'] = (LRS.courseInfo && LRS.courseInfo.publishIndex) ? LRS.courseInfo.publishIndex : 1;
2585
2597
 
2598
+ // Employee ID from employee lookup (if available)
2599
+ if (employeeLookupData && employeeLookupData.employeeId) {
2600
+ ctx.extensions['employeeId'] = employeeLookupData.employeeId;
2601
+ }
2602
+
2586
2603
  // Xyleme schema version and PII flag
2587
2604
  ctx.extensions['http://xyleme.com/bravais/extensions/statement-schema'] = 'xyleme_10';
2588
2605
  ctx.extensions['http://xyleme.com/bravais/extensions/protect_pii'] = false;
@@ -4251,7 +4268,7 @@ ${courseLines.join("\n")}
4251
4268
  },` : "";
4252
4269
  return `<!-- === PATCH-ADAMS: JS BEFORE (blocking) === -->
4253
4270
  <script data-pa="js-before-loader">
4254
- // Initialize Patch-Adams global namespace IMMEDIATELY (before IIFE)
4271
+ // Initialize PA-Patcher global namespace IMMEDIATELY (before IIFE)
4255
4272
  window.pa_patcher = window.pa_patcher || {
4256
4273
  version: '1.0.25',
4257
4274
  htmlClass: '${htmlClass}',
@@ -4296,7 +4313,7 @@ window.pa_patcher = window.pa_patcher || {
4296
4313
  if (isExtensionError(event.reason)) {
4297
4314
  event.preventDefault();
4298
4315
  event.stopImmediatePropagation();
4299
- console.debug('[Patch-Adams] Suppressed browser extension error:', event.reason);
4316
+ console.debug('[PA-Patcher] Suppressed browser extension error:', event.reason);
4300
4317
  return false;
4301
4318
  }
4302
4319
  }, true);
@@ -4306,7 +4323,7 @@ window.pa_patcher = window.pa_patcher || {
4306
4323
  if (isExtensionError(event.error || event.message)) {
4307
4324
  event.preventDefault();
4308
4325
  event.stopImmediatePropagation();
4309
- console.debug('[Patch-Adams] Suppressed browser extension error:', event.message);
4326
+ console.debug('[PA-Patcher] Suppressed browser extension error:', event.message);
4310
4327
  return false;
4311
4328
  }
4312
4329
  }, true);
@@ -4331,17 +4348,17 @@ window.pa_patcher = window.pa_patcher || {
4331
4348
  var script = loadJSSync(REMOTE_URL);
4332
4349
 
4333
4350
  script.onerror = function() {
4334
- console.warn('[Patch-Adams] JS before failed to load from remote, using local fallback');
4351
+ console.warn('[PA-Patcher] JS before failed to load from remote, using local fallback');
4335
4352
  document.head.removeChild(script);
4336
4353
  var fallback = loadJSSync(LOCAL_PATH);
4337
4354
  fallback.onload = function() {
4338
4355
  if (window.pa_patcher && window.pa_patcher.loaded) {
4339
4356
  window.pa_patcher.loaded.jsBefore = true;
4340
4357
  }
4341
- console.log('[Patch-Adams] JS before loaded from local fallback:', LOCAL_PATH);
4358
+ console.log('[PA-Patcher] JS before loaded from local fallback:', LOCAL_PATH);
4342
4359
  };
4343
4360
  fallback.onerror = function() {
4344
- console.error('[Patch-Adams] JS before failed to load from both remote and local');
4361
+ console.error('[PA-Patcher] JS before failed to load from both remote and local');
4345
4362
  };
4346
4363
  };
4347
4364
 
@@ -4349,7 +4366,7 @@ window.pa_patcher = window.pa_patcher || {
4349
4366
  if (window.pa_patcher && window.pa_patcher.loaded) {
4350
4367
  window.pa_patcher.loaded.jsBefore = true;
4351
4368
  }
4352
- console.log('[Patch-Adams] JS before loaded from remote:', REMOTE_URL);
4369
+ console.log('[PA-Patcher] JS before loaded from remote:', REMOTE_URL);
4353
4370
  };
4354
4371
  })();
4355
4372
  ${lrsBridgeCode}
@@ -4420,14 +4437,14 @@ function generateJsAfterLoader(options) {
4420
4437
  if (window.pa_patcher && window.pa_patcher.loaded) {
4421
4438
  window.pa_patcher.loaded.jsAfter = true;
4422
4439
  }
4423
- console.log('[Patch-Adams] Loading complete, content revealed');
4440
+ console.log('[PA-Patcher] Loading complete, content revealed');
4424
4441
 
4425
4442
  // Add visual badge to indicate patching is active
4426
4443
  var badge = document.createElement('div');
4427
4444
  badge.setAttribute('data-pa', 'badge');
4428
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;';
4429
4446
  badge.textContent = 'PA';
4430
- badge.title = 'Patch-Adams Active';
4447
+ badge.title = 'PA-Patcher Active';
4431
4448
  badge.onclick = function() { badge.style.display = 'none'; };
4432
4449
  document.body.appendChild(badge);
4433
4450
  }
@@ -4443,7 +4460,7 @@ function generateJsAfterLoader(options) {
4443
4460
  if (loaded) return;
4444
4461
  loaded = true;
4445
4462
  clearTimeout(timeoutId);
4446
- console.log('[Patch-Adams] JS after loaded from remote:', REMOTE_URL);
4463
+ console.log('[PA-Patcher] JS after loaded from remote:', REMOTE_URL);
4447
4464
  // Give the script a moment to execute, then remove loading class
4448
4465
  setTimeout(removeLoadingClass, 50);
4449
4466
  },
@@ -4459,7 +4476,7 @@ function generateJsAfterLoader(options) {
4459
4476
  timeoutId = setTimeout(function() {
4460
4477
  if (loaded) return;
4461
4478
  loaded = true;
4462
- console.warn('[Patch-Adams] JS after timed out, using local fallback');
4479
+ console.warn('[PA-Patcher] JS after timed out, using local fallback');
4463
4480
  if (remoteScript.parentNode) {
4464
4481
  document.body.removeChild(remoteScript);
4465
4482
  }
@@ -4471,11 +4488,11 @@ function generateJsAfterLoader(options) {
4471
4488
  loadJS(
4472
4489
  LOCAL_PATH,
4473
4490
  function() {
4474
- console.log('[Patch-Adams] JS after loaded from local fallback:', LOCAL_PATH);
4491
+ console.log('[PA-Patcher] JS after loaded from local fallback:', LOCAL_PATH);
4475
4492
  setTimeout(removeLoadingClass, 50);
4476
4493
  },
4477
4494
  function() {
4478
- console.error('[Patch-Adams] JS after failed to load from both remote and local');
4495
+ console.error('[PA-Patcher] JS after failed to load from both remote and local');
4479
4496
  // Still remove loading class so content is visible even if JS fails
4480
4497
  removeLoadingClass();
4481
4498
  }
@@ -4935,7 +4952,7 @@ var ManifestUpdater = class {
4935
4952
  const resourceClosePattern = /(\s*)<\/resource>/i;
4936
4953
  const match = xmlContent.match(resourceClosePattern);
4937
4954
  if (!match) {
4938
- console.warn("[Patch-Adams] Could not find </resource> tag in imsmanifest.xml");
4955
+ console.warn("[PA-Patcher] Could not find </resource> tag in imsmanifest.xml");
4939
4956
  return [];
4940
4957
  }
4941
4958
  const updatedXml = xmlContent.replace(
@@ -4947,7 +4964,7 @@ $1</resource>`
4947
4964
  zip.updateFile("imsmanifest.xml", Buffer.from(updatedXml, "utf-8"));
4948
4965
  return ["imsmanifest.xml"];
4949
4966
  } catch (error) {
4950
- console.error("[Patch-Adams] Failed to update imsmanifest.xml:", error);
4967
+ console.error("[PA-Patcher] Failed to update imsmanifest.xml:", error);
4951
4968
  return [];
4952
4969
  }
4953
4970
  }
@@ -5579,7 +5596,7 @@ ${js.after}
5579
5596
  var pluginRegistry = new PluginRegistry();
5580
5597
 
5581
5598
  // src/patcher/index.ts
5582
- var DEFAULT_CSS_BEFORE = `/* Patch-Adams: CSS Before (blocking)
5599
+ var DEFAULT_CSS_BEFORE = `/* PA-Patcher: CSS Before (blocking)
5583
5600
  * This file loads at the start of <head> and blocks rendering.
5584
5601
  * Use it to hide content and prevent flash of unstyled content.
5585
5602
  *
@@ -5589,7 +5606,7 @@ var DEFAULT_CSS_BEFORE = `/* Patch-Adams: CSS Before (blocking)
5589
5606
  * }
5590
5607
  */
5591
5608
  `;
5592
- var DEFAULT_CSS_AFTER = `/* Patch-Adams: CSS After (async)
5609
+ var DEFAULT_CSS_AFTER = `/* PA-Patcher: CSS After (async)
5593
5610
  * This file loads at the end of <head> with remote fallback.
5594
5611
  * Use it for style overrides that take precedence over Rise styles.
5595
5612
  *
@@ -5599,7 +5616,7 @@ var DEFAULT_CSS_AFTER = `/* Patch-Adams: CSS After (async)
5599
5616
  * }
5600
5617
  */
5601
5618
  `;
5602
- var DEFAULT_JS_BEFORE = `// Patch-Adams: JS Before (blocking)
5619
+ var DEFAULT_JS_BEFORE = `// PA-Patcher: JS Before (blocking)
5603
5620
  // This file loads at the start of <head> and blocks rendering.
5604
5621
  // Use it for setup, API interception, and preparing globals.
5605
5622
  //
@@ -5609,9 +5626,9 @@ var DEFAULT_JS_BEFORE = `// Patch-Adams: JS Before (blocking)
5609
5626
  // analytics: true
5610
5627
  // };
5611
5628
 
5612
- console.log('[Patch-Adams] JS Before loaded');
5629
+ console.log('[PA-Patcher] JS Before loaded');
5613
5630
  `;
5614
- var DEFAULT_JS_AFTER = `// Patch-Adams: JS After (async)
5631
+ var DEFAULT_JS_AFTER = `// PA-Patcher: JS After (async)
5615
5632
  // This file loads at the end of <body> with remote fallback.
5616
5633
  // Use it for DOM manipulation after Rise has initialized.
5617
5634
  //
@@ -5623,7 +5640,7 @@ var DEFAULT_JS_AFTER = `// Patch-Adams: JS After (async)
5623
5640
  // // Your modifications here
5624
5641
  // });
5625
5642
 
5626
- console.log('[Patch-Adams] JS After loaded');
5643
+ console.log('[PA-Patcher] JS After loaded');
5627
5644
  `;
5628
5645
  var Patcher = class {
5629
5646
  config;