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