@patch-adams/core 1.4.27 → 1.4.28

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
@@ -4579,6 +4579,32 @@ function generateLrsBridgeCode(options) {
4579
4579
  }, 1000);
4580
4580
  }
4581
4581
 
4582
+ // If actor is still Unknown Learner, poll for SCORM API availability
4583
+ // The SCORM API may not be available during <head> init but appears later
4584
+ // (e.g., scorm-calls.js finds and initializes it after DOM ready)
4585
+ if (!LRS.actor || LRS.actor.name === 'Unknown Learner' || !LRS.actor.account || LRS.actor.account.name === 'unknown') {
4586
+ var actorRetryCount = 0;
4587
+ var actorMaxRetries = 15;
4588
+ var actorRetryInterval = setInterval(function() {
4589
+ actorRetryCount++;
4590
+ // Check if SCORM API has become available (injected by scorm-calls.js or LMS)
4591
+ var hasScormApi = LRS.scormApi ||
4592
+ (typeof window.API !== 'undefined' && window.API) ||
4593
+ (typeof window.API_1484_11 !== 'undefined' && window.API_1484_11);
4594
+
4595
+ if (hasScormApi) {
4596
+ log('SCORM API now available (attempt ' + actorRetryCount + '), refreshing actor...');
4597
+ clearInterval(actorRetryInterval);
4598
+ LRS.refreshActor(function(actor) {
4599
+ log('Actor refreshed after SCORM API detected:', actor ? actor.name : 'none');
4600
+ });
4601
+ } else if (actorRetryCount >= actorMaxRetries) {
4602
+ log('SCORM API not found after ' + actorMaxRetries + ' attempts, actor stays as-is');
4603
+ clearInterval(actorRetryInterval);
4604
+ }
4605
+ }, 1000);
4606
+ }
4607
+
4582
4608
  log('LRS bridge setup complete');
4583
4609
  }
4584
4610