@patch-adams/core 1.5.8 → 1.5.10

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.js CHANGED
@@ -616,12 +616,30 @@ function generateLrsBridgeCode(options) {
616
616
  });
617
617
  }
618
618
 
619
- // Decode HTML entities (e.g., " " & ') to clean text
619
+ // Clean HTML entities from text \u2014 handles both proper (") and broken (quot;) forms
620
+ // Rise strips the & from entities in SCORM interaction IDs, so we need both
620
621
  function decodeEntities(str) {
621
622
  if (!str || typeof str !== 'string') return str;
622
- var txt = document.createElement('textarea');
623
- txt.innerHTML = str;
624
- return txt.value;
623
+ // 1. Replace known broken entities (without &) that Rise leaves behind
624
+ str = str
625
+ .replace(/quot;/g, '"')
626
+ .replace(/apos;/g, "'")
627
+ .replace(/amp;/g, '&')
628
+ .replace(/lt;/g, '<')
629
+ .replace(/gt;/g, '>')
630
+ .replace(/nbsp;/g, ' ');
631
+ // 2. Replace numeric entities like &#34; &#39; &#x22; etc.
632
+ str = str.replace(/&#(x?[0-9a-fA-F]+);/g, function(match, code) {
633
+ var num = code.charAt(0) === 'x' ? parseInt(code.substring(1), 16) : parseInt(code, 10);
634
+ return isNaN(num) ? match : String.fromCharCode(num);
635
+ });
636
+ // 3. Catch any remaining standard &entities; via textarea decode
637
+ try {
638
+ var txt = document.createElement('textarea');
639
+ txt.innerHTML = str;
640
+ str = txt.value;
641
+ } catch (e) {}
642
+ return str;
625
643
  }
626
644
 
627
645
  LRS.sessionId = generateUUID();
@@ -3360,6 +3378,22 @@ function generateLrsBridgeCode(options) {
3360
3378
  sendStatement(statement);
3361
3379
  };
3362
3380
 
3381
+ // Send a "launched" statement \u2014 called by skin after email gate / actor setup
3382
+ LRS.sendLaunchStatement = function(data) {
3383
+ data = data || {};
3384
+ var activityDetails = {
3385
+ launchSource: data.source || 'email-gate',
3386
+ employeeEmail: data.email || (LRS.actor && LRS.actor.mbox ? LRS.actor.mbox.replace('mailto:', '') : undefined),
3387
+ employeeId: data.employeeId || LRS.employeeId || undefined
3388
+ };
3389
+
3390
+ if (data.employeeName) activityDetails.employeeName = data.employeeName;
3391
+
3392
+ var statement = buildStatement('launched', ACTIVITY_TYPES.course, activityDetails, null, null);
3393
+ log('Sending launch statement for:', activityDetails.employeeEmail || '(unknown)');
3394
+ sendStatement(statement);
3395
+ };
3396
+
3363
3397
  /**
3364
3398
  * Re-extract actor from SCORM after LMSInitialize has been called.
3365
3399
  * Call this from the SCORM wrapper after scormInit() succeeds,