@patch-adams/core 1.5.15 → 1.5.16

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.js CHANGED
@@ -2564,7 +2564,56 @@ function generateLrsBridgeCode(options) {
2564
2564
  info.versionId = paMeta.versionId || info.versionId;
2565
2565
  }
2566
2566
 
2567
- // 8. Build the course ID in Xyleme IRI format
2567
+ // 8. Extract Bravais document name from launch environment (runtime)
2568
+ // This is the name shown in Bravais Analytics and used for search.
2569
+ // Overrides packageName so the statement object name matches the Bravais document.
2570
+ if (!info.packageName) {
2571
+ var bravaisDocName = null;
2572
+
2573
+ // Strategy 1: Walk parent frames for PARAMS.documentName
2574
+ try {
2575
+ var win = window;
2576
+ for (var i = 0; i < 10; i++) {
2577
+ try {
2578
+ if (win.PARAMS && win.PARAMS.documentName) {
2579
+ bravaisDocName = win.PARAMS.documentName;
2580
+ log('Bravais document name from PARAMS:', bravaisDocName);
2581
+ break;
2582
+ }
2583
+ } catch (e) {}
2584
+ if (win === win.parent) break;
2585
+ win = win.parent;
2586
+ }
2587
+ } catch (e) {}
2588
+
2589
+ // Strategy 2: Walk parent frames checking window.name
2590
+ // Bravais sets the iframe name attribute to the document name
2591
+ if (!bravaisDocName) {
2592
+ try {
2593
+ var win = window;
2594
+ for (var i = 0; i < 10; i++) {
2595
+ try {
2596
+ var frameName = win.name;
2597
+ // Document names have hyphens and are long; skip generic frame names
2598
+ if (frameName && frameName.length > 20 && frameName.indexOf('-') > -1 &&
2599
+ frameName.indexOf('scorm') === -1 && frameName.indexOf('API') === -1) {
2600
+ bravaisDocName = frameName;
2601
+ log('Bravais document name from frame name:', bravaisDocName);
2602
+ break;
2603
+ }
2604
+ } catch (e) {}
2605
+ if (win === win.parent) break;
2606
+ win = win.parent;
2607
+ }
2608
+ } catch (e) {}
2609
+ }
2610
+
2611
+ if (bravaisDocName) {
2612
+ info.packageName = bravaisDocName;
2613
+ }
2614
+ }
2615
+
2616
+ // 9. Build the course ID in Xyleme IRI format
2568
2617
  // Native format: http://xyleme.com/bravais/document/{guid}
2569
2618
  if (info.guid) {
2570
2619
  info.id = 'http://xyleme.com/bravais/document/' + info.guid;