coursecode 0.1.41 → 0.1.42

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.
@@ -7,7 +7,7 @@
7
7
  <meta name="viewport" content="width=device-width, initial-scale=1" />
8
8
  <meta name="description" id="page-description" content="" />
9
9
  <link rel="stylesheet" href="css/framework.css" />
10
- <link rel="stylesheet" href="../course/theme.css" />
10
+ <link rel="stylesheet" href="../template/course/theme.css" />
11
11
  <!-- Skip link is styled via framework.css for accessibility -->
12
12
  </head>
13
13
 
@@ -172,4 +172,4 @@
172
172
  <script type="module" src="./js/main.js"></script>
173
173
  </body>
174
174
 
175
- </html>
175
+ </html>
@@ -120,7 +120,7 @@ class EventBus {
120
120
  // suppress to prevent infinite cascade
121
121
  if (isErrorEvent) {
122
122
  if (this._emittingError) {
123
- console.warn(`[EventBus] Suppressed recursive error event: ${event}`);
123
+ logger.warn(`[EventBus] Suppressed recursive error event: ${event}`);
124
124
  return false;
125
125
  }
126
126
  this._emittingError = true;
@@ -507,8 +507,7 @@ export class Scorm2004Driver extends ScormDriverBase {
507
507
  const value = this._scorm.get(key);
508
508
  const errorCode = this._scorm.debug.getCode();
509
509
 
510
- // Error 403 = "Data Model Element Value Not Initialized" - expected for optional fields
511
- if (errorCode === 403) {
510
+ if (this._isOptionalReadError(errorCode)) {
512
511
  return null;
513
512
  }
514
513
 
@@ -561,18 +560,12 @@ export class Scorm2004Driver extends ScormDriverBase {
561
560
  * Populates the CMI cache at init time. Single LMS read pass.
562
561
  */
563
562
  _populateCache() {
564
- // Helper: read a CMI value via strict _getValue, but tolerate error 403
565
- // ("Data Model Element Value Not Initialized") which strict LMSes like
566
- // SCORM Cloud return for unset elements on a fresh session.
567
- // Any other SCORM error still throws through _getValue's normal path.
563
+ // Startup cache hydration reads LMS state opportunistically. Some LMS
564
+ // adapters report supported-but-empty or unavailable optional fields as
565
+ // SCORM errors, so use the optional read path here and keep strict reads
566
+ // for required operations.
568
567
  const getOrDefault = (key, fallback) => {
569
- try {
570
- return this._getValue(key) || fallback;
571
- } catch (e) {
572
- const code = this._scorm.debug.getCode();
573
- if (code === 403) return fallback;
574
- throw e;
575
- }
568
+ return this._getValueOptional(key) || fallback;
576
569
  };
577
570
 
578
571
  // Read-only scalars (may be uninitialized on first launch)
@@ -712,6 +705,11 @@ export class Scorm2004Driver extends ScormDriverBase {
712
705
  throw new Error(msg);
713
706
  }
714
707
 
708
+ _isOptionalReadError(code) {
709
+ const numericCode = Number(code);
710
+ return numericCode === 401 || numericCode === 403;
711
+ }
712
+
715
713
  // --- Recovery Mode Helpers ---
716
714
 
717
715
  _getValueRecovered(key) {
@@ -739,7 +737,7 @@ export class Scorm2004Driver extends ScormDriverBase {
739
737
  const value = api.GetValue(key);
740
738
  const errCode = api.GetLastError ? parseInt(api.GetLastError(), 10) : 0;
741
739
 
742
- if (errCode === 403) {
740
+ if (this._isOptionalReadError(errCode)) {
743
741
  return null;
744
742
  }
745
743
 
@@ -31,13 +31,9 @@ further modified by Philip Hutchison
31
31
  if (typeof define === 'function' && define.amd) {
32
32
  // AMD. Register as an anonymous module.
33
33
  define([], factory);
34
- } else if (typeof module === 'object' && module.exports) {
35
- // Node. Does not work with strict CommonJS, but
36
- // only CommonJS-like environments that support module.exports,
37
- // like Node.
38
- module.exports = factory();
39
34
  } else {
40
- // Browser globals (root is window)
35
+ // Browser/global object. CourseCode imports this vendored copy as ESM,
36
+ // so avoid CommonJS export branches that modern bundlers warn about.
41
37
  root.pipwerks = factory();
42
38
  }
43
39
  }(typeof globalThis !== 'undefined' ? globalThis : typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : this, function () {
@@ -927,5 +923,5 @@ further modified by Philip Hutchison
927
923
  // ESM Export for Vite/modern bundlers
928
924
  // Added to enable ES module imports while keeping original UMD intact
929
925
  // =============================================================================
930
- export default (typeof window !== 'undefined' && window.pipwerks) || (typeof global !== 'undefined' && global.pipwerks);
931
- export const SCORM = (typeof window !== 'undefined' && window.pipwerks?.SCORM) || (typeof global !== 'undefined' && global.pipwerks?.SCORM);
926
+ export default globalThis.pipwerks;
927
+ export const SCORM = globalThis.pipwerks?.SCORM;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coursecode",
3
- "version": "0.1.41",
3
+ "version": "0.1.42",
4
4
  "description": "Multi-format course authoring framework with CLI tools (SCORM 2004, SCORM 1.2, cmi5, LTI 1.3)",
5
5
  "type": "module",
6
6
  "bin": {