scorm-again 2.6.3 → 2.6.5

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.
Files changed (73) hide show
  1. package/.claude/.claude/settings.local.json +13 -0
  2. package/.claude/settings.local.json +33 -0
  3. package/dist/aicc.js +38 -22
  4. package/dist/aicc.js.map +1 -1
  5. package/dist/aicc.min.js +1 -1
  6. package/dist/aicc.min.js.map +1 -1
  7. package/dist/esm/aicc.js +38 -22
  8. package/dist/esm/aicc.js.map +1 -1
  9. package/dist/esm/aicc.min.js +1 -1
  10. package/dist/esm/aicc.min.js.map +1 -1
  11. package/dist/esm/scorm-again.js +79 -47
  12. package/dist/esm/scorm-again.js.map +1 -1
  13. package/dist/esm/scorm-again.min.js +1 -1
  14. package/dist/esm/scorm-again.min.js.map +1 -1
  15. package/dist/esm/scorm12.js +35 -20
  16. package/dist/esm/scorm12.js.map +1 -1
  17. package/dist/esm/scorm12.min.js +1 -1
  18. package/dist/esm/scorm12.min.js.map +1 -1
  19. package/dist/esm/scorm2004.js +69 -41
  20. package/dist/esm/scorm2004.js.map +1 -1
  21. package/dist/esm/scorm2004.min.js +1 -1
  22. package/dist/esm/scorm2004.min.js.map +1 -1
  23. package/dist/scorm-again.js +79 -47
  24. package/dist/scorm-again.js.map +1 -1
  25. package/dist/scorm-again.min.js +1 -1
  26. package/dist/scorm-again.min.js.map +1 -1
  27. package/dist/scorm12.js +35 -20
  28. package/dist/scorm12.js.map +1 -1
  29. package/dist/scorm12.min.js +1 -1
  30. package/dist/scorm12.min.js.map +1 -1
  31. package/dist/scorm2004.js +69 -41
  32. package/dist/scorm2004.js.map +1 -1
  33. package/dist/scorm2004.min.js +1 -1
  34. package/dist/scorm2004.min.js.map +1 -1
  35. package/dist/types/cmi/scorm2004/adl.d.ts +8 -2
  36. package/dist/types/cmi/scorm2004/cmi.d.ts +1 -1
  37. package/package.json +1 -1
  38. package/src/BaseAPI.ts +56 -33
  39. package/src/Scorm12API.ts +3 -2
  40. package/src/Scorm2004API.ts +31 -24
  41. package/src/cmi/aicc/attempts.ts +3 -3
  42. package/src/cmi/aicc/core.ts +30 -12
  43. package/src/cmi/aicc/evaluation.ts +1 -1
  44. package/src/cmi/aicc/student_data.ts +1 -1
  45. package/src/cmi/aicc/student_demographics.ts +13 -13
  46. package/src/cmi/aicc/student_preferences.ts +1 -1
  47. package/src/cmi/aicc/tries.ts +3 -3
  48. package/src/cmi/aicc/validation.ts +1 -1
  49. package/src/cmi/common/array.ts +1 -1
  50. package/src/cmi/common/score.ts +3 -3
  51. package/src/cmi/common/validation.ts +2 -2
  52. package/src/cmi/scorm12/cmi.ts +12 -4
  53. package/src/cmi/scorm12/interactions.ts +27 -11
  54. package/src/cmi/scorm12/objectives.ts +4 -4
  55. package/src/cmi/scorm12/student_data.ts +12 -4
  56. package/src/cmi/scorm12/student_preference.ts +3 -1
  57. package/src/cmi/scorm12/validation.ts +5 -3
  58. package/src/cmi/scorm2004/adl.ts +39 -22
  59. package/src/cmi/scorm2004/cmi.ts +47 -17
  60. package/src/cmi/scorm2004/comments.ts +11 -5
  61. package/src/cmi/scorm2004/interactions.ts +25 -23
  62. package/src/cmi/scorm2004/learner_preference.ts +3 -1
  63. package/src/cmi/scorm2004/objectives.ts +5 -5
  64. package/src/cmi/scorm2004/score.ts +3 -3
  65. package/src/cmi/scorm2004/validation.ts +2 -2
  66. package/src/exceptions/aicc_exceptions.ts +4 -4
  67. package/src/exceptions/scorm12_exceptions.ts +4 -4
  68. package/src/exceptions/scorm2004_exceptions.ts +4 -4
  69. package/src/utilities.ts +3 -3
  70. package/test/BaseAPI.requestHandler.spec.ts +126 -0
  71. package/test/Scorm12API.spec.ts +45 -0
  72. package/test/Scorm2004API.spec.ts +43 -0
  73. package/tsconfig.json +1 -0
@@ -34,11 +34,12 @@ var AICCValidationError = (function (_super) {
34
34
  (0,tslib_es6.__extends)(AICCValidationError, _super);
35
35
  function AICCValidationError(errorCode) {
36
36
  var _this = this;
37
+ var _a, _b, _c, _d;
37
38
  if ({}.hasOwnProperty.call(aicc_errors, String(errorCode))) {
38
- _this = _super.call(this, errorCode, aicc_errors[String(errorCode)].basicMessage, aicc_errors[String(errorCode)].detailMessage) || this;
39
+ _this = _super.call(this, errorCode, ((_a = aicc_errors[String(errorCode)]) === null || _a === void 0 ? void 0 : _a.basicMessage) || "Unknown rror", (_b = aicc_errors[String(errorCode)]) === null || _b === void 0 ? void 0 : _b.detailMessage) || this;
39
40
  }
40
41
  else {
41
- _this = _super.call(this, 101, aicc_errors["101"].basicMessage, aicc_errors["101"].detailMessage) || this;
42
+ _this = _super.call(this, 101, ((_c = aicc_errors["101"]) === null || _c === void 0 ? void 0 : _c.basicMessage) || "General error", (_d = aicc_errors["101"]) === null || _d === void 0 ? void 0 : _d.detailMessage) || this;
42
43
  }
43
44
  return _this;
44
45
  }
@@ -1412,6 +1413,10 @@ var BaseAPI = (function () {
1412
1413
  : this._error_codes.GENERAL;
1413
1414
  for (var idx = 0; idx < structure.length; idx++) {
1414
1415
  var attribute = structure[idx];
1416
+ if (!attribute) {
1417
+ this.throwSCORMError(invalidErrorCode, invalidErrorMessage);
1418
+ return api_constants.global_constants.SCORM_FALSE;
1419
+ }
1415
1420
  if (idx === structure.length - 1) {
1416
1421
  if (scorm2004 && attribute.substring(0, 8) === "{target=") {
1417
1422
  if (this.isInitialized()) {
@@ -1442,7 +1447,7 @@ var BaseAPI = (function () {
1442
1447
  break;
1443
1448
  }
1444
1449
  if (refObject instanceof array.CMIArray) {
1445
- var index = parseInt(structure[idx + 1], 10);
1450
+ var index = parseInt(structure[idx + 1] || "0", 10);
1446
1451
  if (!isNaN(index)) {
1447
1452
  var item = refObject.childArray[index];
1448
1453
  if (item) {
@@ -1486,6 +1491,10 @@ var BaseAPI = (function () {
1486
1491
  : this._error_codes.GENERAL;
1487
1492
  for (var idx = 0; idx < structure.length; idx++) {
1488
1493
  attribute = structure[idx];
1494
+ if (!attribute) {
1495
+ this.throwSCORMError(invalidErrorCode, invalidErrorMessage);
1496
+ return;
1497
+ }
1489
1498
  if (!scorm2004) {
1490
1499
  if (idx === structure.length - 1) {
1491
1500
  if (!this._checkObjectHasProperty(refObject, attribute)) {
@@ -1511,7 +1520,7 @@ var BaseAPI = (function () {
1511
1520
  break;
1512
1521
  }
1513
1522
  if (refObject instanceof array.CMIArray) {
1514
- var index = parseInt(structure[idx + 1], 10);
1523
+ var index = parseInt(structure[idx + 1] || "", 10);
1515
1524
  if (!isNaN(index)) {
1516
1525
  var item = refObject.childArray[index];
1517
1526
  if (item) {
@@ -1549,17 +1558,18 @@ var BaseAPI = (function () {
1549
1558
  return this.currentState === api_constants.global_constants.STATE_TERMINATED;
1550
1559
  };
1551
1560
  BaseAPI.prototype.on = function (listenerName, callback) {
1561
+ var _a, _c;
1552
1562
  if (!callback)
1553
1563
  return;
1554
1564
  var listenerFunctions = listenerName.split(" ");
1555
1565
  for (var i = 0; i < listenerFunctions.length; i++) {
1556
- var listenerSplit = listenerFunctions[i].split(".");
1557
- if (listenerSplit.length === 0)
1566
+ var listenerSplit = (_a = listenerFunctions[i]) === null || _a === void 0 ? void 0 : _a.split(".");
1567
+ if (!listenerSplit || listenerSplit.length === 0)
1558
1568
  return;
1559
1569
  var functionName = listenerSplit[0];
1560
1570
  var CMIElement = null;
1561
1571
  if (listenerSplit.length > 1) {
1562
- CMIElement = listenerName.replace(functionName + ".", "");
1572
+ CMIElement = (_c = listenerFunctions[i]) === null || _c === void 0 ? void 0 : _c.replace(functionName + ".", "");
1563
1573
  }
1564
1574
  this.listenerArray.push({
1565
1575
  functionName: functionName,
@@ -1570,17 +1580,18 @@ var BaseAPI = (function () {
1570
1580
  }
1571
1581
  };
1572
1582
  BaseAPI.prototype.off = function (listenerName, callback) {
1583
+ var _a, _c;
1573
1584
  if (!callback)
1574
1585
  return;
1575
1586
  var listenerFunctions = listenerName.split(" ");
1576
1587
  var _loop_1 = function (i) {
1577
- var listenerSplit = listenerFunctions[i].split(".");
1578
- if (listenerSplit.length === 0)
1588
+ var listenerSplit = (_a = listenerFunctions[i]) === null || _a === void 0 ? void 0 : _a.split(".");
1589
+ if (!listenerSplit || listenerSplit.length === 0)
1579
1590
  return { value: void 0 };
1580
1591
  var functionName = listenerSplit[0];
1581
1592
  var CMIElement = null;
1582
1593
  if (listenerSplit.length > 1) {
1583
- CMIElement = listenerName.replace(functionName + ".", "");
1594
+ CMIElement = (_c = listenerFunctions[i]) === null || _c === void 0 ? void 0 : _c.replace(functionName + ".", "");
1584
1595
  }
1585
1596
  var removeIndex = this_1.listenerArray.findIndex(function (obj) {
1586
1597
  return obj.functionName === functionName &&
@@ -1600,15 +1611,16 @@ var BaseAPI = (function () {
1600
1611
  }
1601
1612
  };
1602
1613
  BaseAPI.prototype.clear = function (listenerName) {
1614
+ var _a, _c;
1603
1615
  var listenerFunctions = listenerName.split(" ");
1604
1616
  var _loop_2 = function (i) {
1605
- var listenerSplit = listenerFunctions[i].split(".");
1606
- if (listenerSplit.length === 0)
1617
+ var listenerSplit = (_a = listenerFunctions[i]) === null || _a === void 0 ? void 0 : _a.split(".");
1618
+ if (!listenerSplit || (listenerSplit === null || listenerSplit === void 0 ? void 0 : listenerSplit.length) === 0)
1607
1619
  return { value: void 0 };
1608
1620
  var functionName = listenerSplit[0];
1609
1621
  var CMIElement = null;
1610
1622
  if (listenerSplit.length > 1) {
1611
- CMIElement = listenerName.replace(functionName + ".", "");
1623
+ CMIElement = (_c = listenerFunctions[i]) === null || _c === void 0 ? void 0 : _c.replace(functionName + ".", "");
1612
1624
  }
1613
1625
  this_2.listenerArray = this_2.listenerArray.filter(function (obj) {
1614
1626
  return obj.functionName !== functionName && obj.CMIElement !== CMIElement;
@@ -1775,6 +1787,7 @@ var BaseAPI = (function () {
1775
1787
  errorCode: this.error_codes.GENERAL,
1776
1788
  };
1777
1789
  if (immediate) {
1790
+ params = this.settings.requestHandler(params);
1778
1791
  this.performFetch(url, params).then(function (response) { return (0,tslib_es6.__awaiter)(_this, void 0, void 0, function () {
1779
1792
  return (0,tslib_es6.__generator)(this, function (_a) {
1780
1793
  switch (_a.label) {
@@ -2090,14 +2103,16 @@ var Scorm12Impl = (function (_super) {
2090
2103
  Scorm12Impl.prototype.validateCorrectResponse = function (_CMIElement, _value) {
2091
2104
  };
2092
2105
  Scorm12Impl.prototype.getLmsErrorMessageDetails = function (errorNumber, detail) {
2106
+ var _a, _b;
2093
2107
  var basicMessage = "No Error";
2094
2108
  var detailMessage = "No Error";
2095
2109
  errorNumber = String(errorNumber);
2096
2110
  if (_constants_api_constants__WEBPACK_IMPORTED_MODULE_4__.scorm12_constants.error_descriptions[errorNumber]) {
2097
2111
  basicMessage =
2098
- _constants_api_constants__WEBPACK_IMPORTED_MODULE_4__.scorm12_constants.error_descriptions[errorNumber].basicMessage;
2112
+ ((_a = _constants_api_constants__WEBPACK_IMPORTED_MODULE_4__.scorm12_constants.error_descriptions[errorNumber]) === null || _a === void 0 ? void 0 : _a.basicMessage) ||
2113
+ "General Error";
2099
2114
  detailMessage =
2100
- _constants_api_constants__WEBPACK_IMPORTED_MODULE_4__.scorm12_constants.error_descriptions[errorNumber].detailMessage;
2115
+ ((_b = _constants_api_constants__WEBPACK_IMPORTED_MODULE_4__.scorm12_constants.error_descriptions[errorNumber]) === null || _b === void 0 ? void 0 : _b.detailMessage) || "";
2101
2116
  }
2102
2117
  return detail ? detailMessage : basicMessage;
2103
2118
  };
@@ -2254,11 +2269,12 @@ var Scorm2004ValidationError = (function (_super) {
2254
2269
  (0,tslib_es6.__extends)(Scorm2004ValidationError, _super);
2255
2270
  function Scorm2004ValidationError(errorCode) {
2256
2271
  var _this = this;
2272
+ var _a, _b, _c, _d;
2257
2273
  if ({}.hasOwnProperty.call(scorm2004_errors, String(errorCode))) {
2258
- _this = _super.call(this, errorCode, scorm2004_errors[String(errorCode)].basicMessage, scorm2004_errors[String(errorCode)].detailMessage) || this;
2274
+ _this = _super.call(this, errorCode, ((_a = scorm2004_errors[String(errorCode)]) === null || _a === void 0 ? void 0 : _a.basicMessage) || "Unknown error", (_b = scorm2004_errors[String(errorCode)]) === null || _b === void 0 ? void 0 : _b.detailMessage) || this;
2259
2275
  }
2260
2276
  else {
2261
- _this = _super.call(this, 101, scorm2004_errors["101"].basicMessage, scorm2004_errors["101"].detailMessage) || this;
2277
+ _this = _super.call(this, 101, ((_c = scorm2004_errors["101"]) === null || _c === void 0 ? void 0 : _c.basicMessage) || "General error", (_d = scorm2004_errors["101"]) === null || _d === void 0 ? void 0 : _d.detailMessage) || this;
2262
2278
  }
2263
2279
  return _this;
2264
2280
  }
@@ -2674,6 +2690,7 @@ var CMIInteractionsObject = (function (_super) {
2674
2690
  return this._learner_response;
2675
2691
  },
2676
2692
  set: function (learner_response) {
2693
+ var _a, _b, _c, _d;
2677
2694
  if (this.initialized && (this._type === "" || this._id === "")) {
2678
2695
  throw new Scorm2004ValidationError(error_codes.scorm2004_errors.DEPENDENCY_NOT_ESTABLISHED);
2679
2696
  }
@@ -2691,14 +2708,14 @@ var CMIInteractionsObject = (function (_super) {
2691
2708
  var formatRegex = new RegExp(response_type.format);
2692
2709
  for (var i = 0; i < nodes.length; i++) {
2693
2710
  if (response_type === null || response_type === void 0 ? void 0 : response_type.delimiter2) {
2694
- var values = nodes[i].split(response_type.delimiter2);
2695
- if (values.length === 2) {
2696
- if (!values[0].match(formatRegex)) {
2711
+ var values = (_a = nodes[i]) === null || _a === void 0 ? void 0 : _a.split(response_type.delimiter2);
2712
+ if ((values === null || values === void 0 ? void 0 : values.length) === 2) {
2713
+ if (!((_b = values[0]) === null || _b === void 0 ? void 0 : _b.match(formatRegex))) {
2697
2714
  throw new Scorm2004ValidationError(error_codes.scorm2004_errors.TYPE_MISMATCH);
2698
2715
  }
2699
2716
  else {
2700
2717
  if (!response_type.format2 ||
2701
- !values[1].match(new RegExp(response_type.format2))) {
2718
+ !((_c = values[1]) === null || _c === void 0 ? void 0 : _c.match(new RegExp(response_type.format2)))) {
2702
2719
  throw new Scorm2004ValidationError(error_codes.scorm2004_errors.TYPE_MISMATCH);
2703
2720
  }
2704
2721
  }
@@ -2708,7 +2725,7 @@ var CMIInteractionsObject = (function (_super) {
2708
2725
  }
2709
2726
  }
2710
2727
  else {
2711
- if (!nodes[i].match(formatRegex)) {
2728
+ if (!((_d = nodes[i]) === null || _d === void 0 ? void 0 : _d.match(formatRegex))) {
2712
2729
  throw new Scorm2004ValidationError(error_codes.scorm2004_errors.TYPE_MISMATCH);
2713
2730
  }
2714
2731
  else {
@@ -4186,10 +4203,14 @@ var ADLNavRequestValid = (function (_super) {
4186
4203
  }
4187
4204
  for (var key in choice) {
4188
4205
  if ({}.hasOwnProperty.call(choice, key)) {
4189
- if (check2004ValidFormat(choice[key], regex.scorm2004_regex.NAVBoolean) &&
4190
- check2004ValidFormat(key, regex.scorm2004_regex.NAVTarget)) {
4191
- this._choice[key] =
4192
- enums.NAVBoolean[choice[key]];
4206
+ if (choice[key] !== undefined && check2004ValidFormat(key, regex.scorm2004_regex.NAVTarget)) {
4207
+ var value = choice[key];
4208
+ if (typeof value === 'string' && check2004ValidFormat(value, regex.scorm2004_regex.NAVBoolean)) {
4209
+ this._choice[key] = enums.NAVBoolean[value];
4210
+ }
4211
+ else if (Object.values(enums.NAVBoolean).includes(value)) {
4212
+ this._choice[key] = value;
4213
+ }
4193
4214
  }
4194
4215
  }
4195
4216
  }
@@ -4210,9 +4231,14 @@ var ADLNavRequestValid = (function (_super) {
4210
4231
  }
4211
4232
  for (var key in jump) {
4212
4233
  if ({}.hasOwnProperty.call(jump, key)) {
4213
- if (check2004ValidFormat(jump[key], regex.scorm2004_regex.NAVBoolean) &&
4214
- check2004ValidFormat(key, regex.scorm2004_regex.NAVTarget)) {
4215
- this._jump[key] = enums.NAVBoolean[jump[key]];
4234
+ if (jump[key] !== undefined && check2004ValidFormat(key, regex.scorm2004_regex.NAVTarget)) {
4235
+ var value = jump[key];
4236
+ if (typeof value === 'string' && check2004ValidFormat(value, regex.scorm2004_regex.NAVBoolean)) {
4237
+ this._jump[key] = enums.NAVBoolean[value];
4238
+ }
4239
+ else if (Object.values(enums.NAVBoolean).includes(value)) {
4240
+ this._jump[key] = value;
4241
+ }
4216
4242
  }
4217
4243
  }
4218
4244
  }
@@ -4363,19 +4389,19 @@ var Scorm2004Impl = (function (_super) {
4363
4389
  });
4364
4390
  };
4365
4391
  Scorm2004Impl.prototype.lmsGetValue = function (CMIElement) {
4366
- var _a;
4392
+ var _a, _b;
4367
4393
  var adlNavRequestRegex = "^adl\\.nav\\.request_valid\\.(choice|jump)\\.{target=\\S{0,}([a-zA-Z0-9-_]+)}$";
4368
4394
  if ((0,utilities.stringMatches)(CMIElement, adlNavRequestRegex)) {
4369
4395
  var matches = CMIElement.match(adlNavRequestRegex);
4370
4396
  if (matches) {
4371
4397
  var request = matches[1];
4372
- var target = matches[2].replace("{target=", "").replace("}", "");
4373
- if (request === "choice" || request === "jump") {
4398
+ var target = (_a = matches[2]) === null || _a === void 0 ? void 0 : _a.replace("{target=", "").replace("}", "");
4399
+ if (target && (request === "choice" || request === "jump")) {
4374
4400
  if (this.settings.scoItemIdValidator) {
4375
4401
  return String(this.settings.scoItemIdValidator(target));
4376
4402
  }
4377
4403
  if (this.settings.scoItemIds) {
4378
- return String((_a = this.settings.scoItemIds) === null || _a === void 0 ? void 0 : _a.includes(target));
4404
+ return String((_b = this.settings.scoItemIds) === null || _b === void 0 ? void 0 : _b.includes(target));
4379
4405
  }
4380
4406
  return String(request);
4381
4407
  }
@@ -4529,8 +4555,9 @@ var Scorm2004Impl = (function (_super) {
4529
4555
  var interaction_count = interaction.correct_responses._count;
4530
4556
  this.checkDuplicateChoiceResponse(interaction, value);
4531
4557
  var response_type = CorrectResponses[interaction.type];
4532
- if (typeof response_type.limit === "undefined" ||
4533
- interaction_count <= response_type.limit) {
4558
+ if (typeof response_type !== "undefined" &&
4559
+ (typeof response_type.limit === "undefined" ||
4560
+ interaction_count <= response_type.limit)) {
4534
4561
  this.checkValidResponseType(response_type, value, interaction.type);
4535
4562
  if ((this.lastErrorCode === "0" &&
4536
4563
  (!response_type.duplicate ||
@@ -4551,14 +4578,17 @@ var Scorm2004Impl = (function (_super) {
4551
4578
  return this._commonGetCMIValue("GetValue", true, CMIElement);
4552
4579
  };
4553
4580
  Scorm2004Impl.prototype.getLmsErrorMessageDetails = function (errorNumber, detail) {
4581
+ var _a, _b;
4554
4582
  var basicMessage = "";
4555
4583
  var detailMessage = "";
4556
4584
  errorNumber = String(errorNumber);
4557
4585
  if (api_constants.scorm2004_constants.error_descriptions[errorNumber]) {
4558
4586
  basicMessage =
4559
- api_constants.scorm2004_constants.error_descriptions[errorNumber].basicMessage;
4587
+ ((_a = api_constants.scorm2004_constants.error_descriptions[errorNumber]) === null || _a === void 0 ? void 0 : _a.basicMessage) ||
4588
+ "Unknown Error";
4560
4589
  detailMessage =
4561
- api_constants.scorm2004_constants.error_descriptions[errorNumber].detailMessage;
4590
+ ((_b = api_constants.scorm2004_constants.error_descriptions[errorNumber]) === null || _b === void 0 ? void 0 : _b.detailMessage) ||
4591
+ "";
4562
4592
  }
4563
4593
  return detail ? detailMessage : basicMessage;
4564
4594
  };
@@ -4574,7 +4604,7 @@ var Scorm2004Impl = (function (_super) {
4574
4604
  };
4575
4605
  Scorm2004Impl.prototype.checkCorrectResponseValue = function (interaction_type, nodes, value) {
4576
4606
  var response = CorrectResponses[interaction_type];
4577
- var formatRegex = new RegExp(response.format);
4607
+ var formatRegex = new RegExp((response === null || response === void 0 ? void 0 : response.format) || ".*");
4578
4608
  for (var i = 0; i < nodes.length && this.lastErrorCode === "0"; i++) {
4579
4609
  if (interaction_type.match("^(fill-in|long-fill-in|matching|performance|sequencing)$")) {
4580
4610
  nodes[i] = this.removeCorrectResponsePrefixes(nodes[i]);
@@ -4610,7 +4640,7 @@ var Scorm2004Impl = (function (_super) {
4610
4640
  }
4611
4641
  }
4612
4642
  else {
4613
- if (nodes[i] !== "" && response.unique) {
4643
+ if (nodes[i] !== "" && (response === null || response === void 0 ? void 0 : response.unique)) {
4614
4644
  for (var j = 0; j < i && this.lastErrorCode === "0"; j++) {
4615
4645
  if (nodes[i] === nodes[j]) {
4616
4646
  this.throwSCORMError(error_codes.scorm2004_errors.TYPE_MISMATCH);
@@ -4623,6 +4653,7 @@ var Scorm2004Impl = (function (_super) {
4623
4653
  }
4624
4654
  };
4625
4655
  Scorm2004Impl.prototype.removeCorrectResponsePrefixes = function (node) {
4656
+ var _a;
4626
4657
  var seenOrder = false;
4627
4658
  var seenCase = false;
4628
4659
  var seenLang = false;
@@ -4660,7 +4691,7 @@ var Scorm2004Impl = (function (_super) {
4660
4691
  seenOrder = true;
4661
4692
  break;
4662
4693
  }
4663
- node = node.substring(matches[1].length);
4694
+ node = node.substring(((_a = matches[1]) === null || _a === void 0 ? void 0 : _a.length) || 0);
4664
4695
  matches = node.match(prefixRegex);
4665
4696
  }
4666
4697
  return node;
@@ -5062,8 +5093,8 @@ function checkValidFormat(value, regexPattern, errorCode, errorClass, allowEmpty
5062
5093
  function checkValidRange(value, rangePattern, errorCode, errorClass) {
5063
5094
  var ranges = rangePattern.split("#");
5064
5095
  value = value * 1.0;
5065
- if (value >= ranges[0]) {
5066
- if (ranges[1] === "*" || value <= ranges[1]) {
5096
+ if (ranges[0] && value >= ranges[0]) {
5097
+ if (ranges[1] && (ranges[1] === "*" || value <= ranges[1])) {
5067
5098
  return true;
5068
5099
  }
5069
5100
  else {
@@ -6658,11 +6689,12 @@ var Scorm12ValidationError = (function (_super) {
6658
6689
  (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__extends)(Scorm12ValidationError, _super);
6659
6690
  function Scorm12ValidationError(errorCode) {
6660
6691
  var _this = this;
6692
+ var _a, _b, _c, _d, _e;
6661
6693
  if ({}.hasOwnProperty.call(scorm12_errors, String(errorCode))) {
6662
- _this = _super.call(this, errorCode, scorm12_errors[String(errorCode)].basicMessage, scorm12_errors[String(errorCode)].detailMessage) || this;
6694
+ _this = _super.call(this, errorCode, ((_a = scorm12_errors[String(errorCode)]) === null || _a === void 0 ? void 0 : _a.basicMessage) || "Unknown error", (_b = scorm12_errors[String(errorCode)]) === null || _b === void 0 ? void 0 : _b.detailMessage) || this;
6663
6695
  }
6664
6696
  else {
6665
- _this = _super.call(this, 101, scorm12_errors["101"].basicMessage, scorm12_errors["101"].detailMessage) || this;
6697
+ _this = _super.call(this, 101, (_d = (_c = scorm12_errors["101"]) === null || _c === void 0 ? void 0 : _c.basicMessage) !== null && _d !== void 0 ? _d : "General error", (_e = scorm12_errors["101"]) === null || _e === void 0 ? void 0 : _e.detailMessage) || this;
6666
6698
  }
6667
6699
  return _this;
6668
6700
  }
@@ -6732,7 +6764,7 @@ function getSecondsAsISODuration(seconds) {
6732
6764
  var duration = "P";
6733
6765
  var remainder = seconds;
6734
6766
  for (var designationsKey in designations) {
6735
- var current_seconds = designations[designationsKey];
6767
+ var current_seconds = designations[designationsKey] || 1;
6736
6768
  var value = Math.floor(remainder / current_seconds);
6737
6769
  remainder = remainder % current_seconds;
6738
6770
  if (countDecimals(remainder) > 2) {
@@ -6839,7 +6871,7 @@ function unflatten(data) {
6839
6871
  var m = regex.exec(p);
6840
6872
  while (m) {
6841
6873
  cur = cur[prop] || (cur[prop] = m[2] ? [] : {});
6842
- prop = m[2] || m[1];
6874
+ prop = m[2] || m[1] || "";
6843
6875
  m = regex.exec(p);
6844
6876
  }
6845
6877
  cur[prop] = data[p];
@@ -6851,7 +6883,7 @@ function countDecimals(num) {
6851
6883
  if (Math.floor(num) === num || String(num).indexOf(".") < 0)
6852
6884
  return 0;
6853
6885
  var parts = num.toString().split(".")[1];
6854
- return parts.length || 0;
6886
+ return (parts === null || parts === void 0 ? void 0 : parts.length) || 0;
6855
6887
  }
6856
6888
  function formatMessage(functionName, message, CMIElement) {
6857
6889
  var baseLength = 20;