@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/index.js CHANGED
@@ -2233,7 +2233,56 @@ function generateLrsBridgeCode(options) {
2233
2233
  info.versionId = paMeta.versionId || info.versionId;
2234
2234
  }
2235
2235
 
2236
- // 8. Build the course ID in Xyleme IRI format
2236
+ // 8. Extract Bravais document name from launch environment (runtime)
2237
+ // This is the name shown in Bravais Analytics and used for search.
2238
+ // Overrides packageName so the statement object name matches the Bravais document.
2239
+ if (!info.packageName) {
2240
+ var bravaisDocName = null;
2241
+
2242
+ // Strategy 1: Walk parent frames for PARAMS.documentName
2243
+ try {
2244
+ var win = window;
2245
+ for (var i = 0; i < 10; i++) {
2246
+ try {
2247
+ if (win.PARAMS && win.PARAMS.documentName) {
2248
+ bravaisDocName = win.PARAMS.documentName;
2249
+ log('Bravais document name from PARAMS:', bravaisDocName);
2250
+ break;
2251
+ }
2252
+ } catch (e) {}
2253
+ if (win === win.parent) break;
2254
+ win = win.parent;
2255
+ }
2256
+ } catch (e) {}
2257
+
2258
+ // Strategy 2: Walk parent frames checking window.name
2259
+ // Bravais sets the iframe name attribute to the document name
2260
+ if (!bravaisDocName) {
2261
+ try {
2262
+ var win = window;
2263
+ for (var i = 0; i < 10; i++) {
2264
+ try {
2265
+ var frameName = win.name;
2266
+ // Document names have hyphens and are long; skip generic frame names
2267
+ if (frameName && frameName.length > 20 && frameName.indexOf('-') > -1 &&
2268
+ frameName.indexOf('scorm') === -1 && frameName.indexOf('API') === -1) {
2269
+ bravaisDocName = frameName;
2270
+ log('Bravais document name from frame name:', bravaisDocName);
2271
+ break;
2272
+ }
2273
+ } catch (e) {}
2274
+ if (win === win.parent) break;
2275
+ win = win.parent;
2276
+ }
2277
+ } catch (e) {}
2278
+ }
2279
+
2280
+ if (bravaisDocName) {
2281
+ info.packageName = bravaisDocName;
2282
+ }
2283
+ }
2284
+
2285
+ // 9. Build the course ID in Xyleme IRI format
2237
2286
  // Native format: http://xyleme.com/bravais/document/{guid}
2238
2287
  if (info.guid) {
2239
2288
  info.id = 'http://xyleme.com/bravais/document/' + info.guid;