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
@@ -32,11 +32,12 @@ var AICCValidationError = (function (_super) {
32
32
  (0,tslib_es6.__extends)(AICCValidationError, _super);
33
33
  function AICCValidationError(errorCode) {
34
34
  var _this = this;
35
+ var _a, _b, _c, _d;
35
36
  if ({}.hasOwnProperty.call(aicc_errors, String(errorCode))) {
36
- _this = _super.call(this, errorCode, aicc_errors[String(errorCode)].basicMessage, aicc_errors[String(errorCode)].detailMessage) || this;
37
+ _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;
37
38
  }
38
39
  else {
39
- _this = _super.call(this, 101, aicc_errors["101"].basicMessage, aicc_errors["101"].detailMessage) || this;
40
+ _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;
40
41
  }
41
42
  return _this;
42
43
  }
@@ -1410,6 +1411,10 @@ var BaseAPI = (function () {
1410
1411
  : this._error_codes.GENERAL;
1411
1412
  for (var idx = 0; idx < structure.length; idx++) {
1412
1413
  var attribute = structure[idx];
1414
+ if (!attribute) {
1415
+ this.throwSCORMError(invalidErrorCode, invalidErrorMessage);
1416
+ return api_constants.global_constants.SCORM_FALSE;
1417
+ }
1413
1418
  if (idx === structure.length - 1) {
1414
1419
  if (scorm2004 && attribute.substring(0, 8) === "{target=") {
1415
1420
  if (this.isInitialized()) {
@@ -1440,7 +1445,7 @@ var BaseAPI = (function () {
1440
1445
  break;
1441
1446
  }
1442
1447
  if (refObject instanceof array.CMIArray) {
1443
- var index = parseInt(structure[idx + 1], 10);
1448
+ var index = parseInt(structure[idx + 1] || "0", 10);
1444
1449
  if (!isNaN(index)) {
1445
1450
  var item = refObject.childArray[index];
1446
1451
  if (item) {
@@ -1484,6 +1489,10 @@ var BaseAPI = (function () {
1484
1489
  : this._error_codes.GENERAL;
1485
1490
  for (var idx = 0; idx < structure.length; idx++) {
1486
1491
  attribute = structure[idx];
1492
+ if (!attribute) {
1493
+ this.throwSCORMError(invalidErrorCode, invalidErrorMessage);
1494
+ return;
1495
+ }
1487
1496
  if (!scorm2004) {
1488
1497
  if (idx === structure.length - 1) {
1489
1498
  if (!this._checkObjectHasProperty(refObject, attribute)) {
@@ -1509,7 +1518,7 @@ var BaseAPI = (function () {
1509
1518
  break;
1510
1519
  }
1511
1520
  if (refObject instanceof array.CMIArray) {
1512
- var index = parseInt(structure[idx + 1], 10);
1521
+ var index = parseInt(structure[idx + 1] || "", 10);
1513
1522
  if (!isNaN(index)) {
1514
1523
  var item = refObject.childArray[index];
1515
1524
  if (item) {
@@ -1547,17 +1556,18 @@ var BaseAPI = (function () {
1547
1556
  return this.currentState === api_constants.global_constants.STATE_TERMINATED;
1548
1557
  };
1549
1558
  BaseAPI.prototype.on = function (listenerName, callback) {
1559
+ var _a, _c;
1550
1560
  if (!callback)
1551
1561
  return;
1552
1562
  var listenerFunctions = listenerName.split(" ");
1553
1563
  for (var i = 0; i < listenerFunctions.length; i++) {
1554
- var listenerSplit = listenerFunctions[i].split(".");
1555
- if (listenerSplit.length === 0)
1564
+ var listenerSplit = (_a = listenerFunctions[i]) === null || _a === void 0 ? void 0 : _a.split(".");
1565
+ if (!listenerSplit || listenerSplit.length === 0)
1556
1566
  return;
1557
1567
  var functionName = listenerSplit[0];
1558
1568
  var CMIElement = null;
1559
1569
  if (listenerSplit.length > 1) {
1560
- CMIElement = listenerName.replace(functionName + ".", "");
1570
+ CMIElement = (_c = listenerFunctions[i]) === null || _c === void 0 ? void 0 : _c.replace(functionName + ".", "");
1561
1571
  }
1562
1572
  this.listenerArray.push({
1563
1573
  functionName: functionName,
@@ -1568,17 +1578,18 @@ var BaseAPI = (function () {
1568
1578
  }
1569
1579
  };
1570
1580
  BaseAPI.prototype.off = function (listenerName, callback) {
1581
+ var _a, _c;
1571
1582
  if (!callback)
1572
1583
  return;
1573
1584
  var listenerFunctions = listenerName.split(" ");
1574
1585
  var _loop_1 = function (i) {
1575
- var listenerSplit = listenerFunctions[i].split(".");
1576
- if (listenerSplit.length === 0)
1586
+ var listenerSplit = (_a = listenerFunctions[i]) === null || _a === void 0 ? void 0 : _a.split(".");
1587
+ if (!listenerSplit || listenerSplit.length === 0)
1577
1588
  return { value: void 0 };
1578
1589
  var functionName = listenerSplit[0];
1579
1590
  var CMIElement = null;
1580
1591
  if (listenerSplit.length > 1) {
1581
- CMIElement = listenerName.replace(functionName + ".", "");
1592
+ CMIElement = (_c = listenerFunctions[i]) === null || _c === void 0 ? void 0 : _c.replace(functionName + ".", "");
1582
1593
  }
1583
1594
  var removeIndex = this_1.listenerArray.findIndex(function (obj) {
1584
1595
  return obj.functionName === functionName &&
@@ -1598,15 +1609,16 @@ var BaseAPI = (function () {
1598
1609
  }
1599
1610
  };
1600
1611
  BaseAPI.prototype.clear = function (listenerName) {
1612
+ var _a, _c;
1601
1613
  var listenerFunctions = listenerName.split(" ");
1602
1614
  var _loop_2 = function (i) {
1603
- var listenerSplit = listenerFunctions[i].split(".");
1604
- if (listenerSplit.length === 0)
1615
+ var listenerSplit = (_a = listenerFunctions[i]) === null || _a === void 0 ? void 0 : _a.split(".");
1616
+ if (!listenerSplit || (listenerSplit === null || listenerSplit === void 0 ? void 0 : listenerSplit.length) === 0)
1605
1617
  return { value: void 0 };
1606
1618
  var functionName = listenerSplit[0];
1607
1619
  var CMIElement = null;
1608
1620
  if (listenerSplit.length > 1) {
1609
- CMIElement = listenerName.replace(functionName + ".", "");
1621
+ CMIElement = (_c = listenerFunctions[i]) === null || _c === void 0 ? void 0 : _c.replace(functionName + ".", "");
1610
1622
  }
1611
1623
  this_2.listenerArray = this_2.listenerArray.filter(function (obj) {
1612
1624
  return obj.functionName !== functionName && obj.CMIElement !== CMIElement;
@@ -1773,6 +1785,7 @@ var BaseAPI = (function () {
1773
1785
  errorCode: this.error_codes.GENERAL,
1774
1786
  };
1775
1787
  if (immediate) {
1788
+ params = this.settings.requestHandler(params);
1776
1789
  this.performFetch(url, params).then(function (response) { return (0,tslib_es6.__awaiter)(_this, void 0, void 0, function () {
1777
1790
  return (0,tslib_es6.__generator)(this, function (_a) {
1778
1791
  switch (_a.label) {
@@ -2088,14 +2101,16 @@ var Scorm12Impl = (function (_super) {
2088
2101
  Scorm12Impl.prototype.validateCorrectResponse = function (_CMIElement, _value) {
2089
2102
  };
2090
2103
  Scorm12Impl.prototype.getLmsErrorMessageDetails = function (errorNumber, detail) {
2104
+ var _a, _b;
2091
2105
  var basicMessage = "No Error";
2092
2106
  var detailMessage = "No Error";
2093
2107
  errorNumber = String(errorNumber);
2094
2108
  if (_constants_api_constants__WEBPACK_IMPORTED_MODULE_4__.scorm12_constants.error_descriptions[errorNumber]) {
2095
2109
  basicMessage =
2096
- _constants_api_constants__WEBPACK_IMPORTED_MODULE_4__.scorm12_constants.error_descriptions[errorNumber].basicMessage;
2110
+ ((_a = _constants_api_constants__WEBPACK_IMPORTED_MODULE_4__.scorm12_constants.error_descriptions[errorNumber]) === null || _a === void 0 ? void 0 : _a.basicMessage) ||
2111
+ "General Error";
2097
2112
  detailMessage =
2098
- _constants_api_constants__WEBPACK_IMPORTED_MODULE_4__.scorm12_constants.error_descriptions[errorNumber].detailMessage;
2113
+ ((_b = _constants_api_constants__WEBPACK_IMPORTED_MODULE_4__.scorm12_constants.error_descriptions[errorNumber]) === null || _b === void 0 ? void 0 : _b.detailMessage) || "";
2099
2114
  }
2100
2115
  return detail ? detailMessage : basicMessage;
2101
2116
  };
@@ -2252,11 +2267,12 @@ var Scorm2004ValidationError = (function (_super) {
2252
2267
  (0,tslib_es6.__extends)(Scorm2004ValidationError, _super);
2253
2268
  function Scorm2004ValidationError(errorCode) {
2254
2269
  var _this = this;
2270
+ var _a, _b, _c, _d;
2255
2271
  if ({}.hasOwnProperty.call(scorm2004_errors, String(errorCode))) {
2256
- _this = _super.call(this, errorCode, scorm2004_errors[String(errorCode)].basicMessage, scorm2004_errors[String(errorCode)].detailMessage) || this;
2272
+ _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;
2257
2273
  }
2258
2274
  else {
2259
- _this = _super.call(this, 101, scorm2004_errors["101"].basicMessage, scorm2004_errors["101"].detailMessage) || this;
2275
+ _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;
2260
2276
  }
2261
2277
  return _this;
2262
2278
  }
@@ -2672,6 +2688,7 @@ var CMIInteractionsObject = (function (_super) {
2672
2688
  return this._learner_response;
2673
2689
  },
2674
2690
  set: function (learner_response) {
2691
+ var _a, _b, _c, _d;
2675
2692
  if (this.initialized && (this._type === "" || this._id === "")) {
2676
2693
  throw new Scorm2004ValidationError(error_codes.scorm2004_errors.DEPENDENCY_NOT_ESTABLISHED);
2677
2694
  }
@@ -2689,14 +2706,14 @@ var CMIInteractionsObject = (function (_super) {
2689
2706
  var formatRegex = new RegExp(response_type.format);
2690
2707
  for (var i = 0; i < nodes.length; i++) {
2691
2708
  if (response_type === null || response_type === void 0 ? void 0 : response_type.delimiter2) {
2692
- var values = nodes[i].split(response_type.delimiter2);
2693
- if (values.length === 2) {
2694
- if (!values[0].match(formatRegex)) {
2709
+ var values = (_a = nodes[i]) === null || _a === void 0 ? void 0 : _a.split(response_type.delimiter2);
2710
+ if ((values === null || values === void 0 ? void 0 : values.length) === 2) {
2711
+ if (!((_b = values[0]) === null || _b === void 0 ? void 0 : _b.match(formatRegex))) {
2695
2712
  throw new Scorm2004ValidationError(error_codes.scorm2004_errors.TYPE_MISMATCH);
2696
2713
  }
2697
2714
  else {
2698
2715
  if (!response_type.format2 ||
2699
- !values[1].match(new RegExp(response_type.format2))) {
2716
+ !((_c = values[1]) === null || _c === void 0 ? void 0 : _c.match(new RegExp(response_type.format2)))) {
2700
2717
  throw new Scorm2004ValidationError(error_codes.scorm2004_errors.TYPE_MISMATCH);
2701
2718
  }
2702
2719
  }
@@ -2706,7 +2723,7 @@ var CMIInteractionsObject = (function (_super) {
2706
2723
  }
2707
2724
  }
2708
2725
  else {
2709
- if (!nodes[i].match(formatRegex)) {
2726
+ if (!((_d = nodes[i]) === null || _d === void 0 ? void 0 : _d.match(formatRegex))) {
2710
2727
  throw new Scorm2004ValidationError(error_codes.scorm2004_errors.TYPE_MISMATCH);
2711
2728
  }
2712
2729
  else {
@@ -4184,10 +4201,14 @@ var ADLNavRequestValid = (function (_super) {
4184
4201
  }
4185
4202
  for (var key in choice) {
4186
4203
  if ({}.hasOwnProperty.call(choice, key)) {
4187
- if (check2004ValidFormat(choice[key], regex.scorm2004_regex.NAVBoolean) &&
4188
- check2004ValidFormat(key, regex.scorm2004_regex.NAVTarget)) {
4189
- this._choice[key] =
4190
- enums.NAVBoolean[choice[key]];
4204
+ if (choice[key] !== undefined && check2004ValidFormat(key, regex.scorm2004_regex.NAVTarget)) {
4205
+ var value = choice[key];
4206
+ if (typeof value === 'string' && check2004ValidFormat(value, regex.scorm2004_regex.NAVBoolean)) {
4207
+ this._choice[key] = enums.NAVBoolean[value];
4208
+ }
4209
+ else if (Object.values(enums.NAVBoolean).includes(value)) {
4210
+ this._choice[key] = value;
4211
+ }
4191
4212
  }
4192
4213
  }
4193
4214
  }
@@ -4208,9 +4229,14 @@ var ADLNavRequestValid = (function (_super) {
4208
4229
  }
4209
4230
  for (var key in jump) {
4210
4231
  if ({}.hasOwnProperty.call(jump, key)) {
4211
- if (check2004ValidFormat(jump[key], regex.scorm2004_regex.NAVBoolean) &&
4212
- check2004ValidFormat(key, regex.scorm2004_regex.NAVTarget)) {
4213
- this._jump[key] = enums.NAVBoolean[jump[key]];
4232
+ if (jump[key] !== undefined && check2004ValidFormat(key, regex.scorm2004_regex.NAVTarget)) {
4233
+ var value = jump[key];
4234
+ if (typeof value === 'string' && check2004ValidFormat(value, regex.scorm2004_regex.NAVBoolean)) {
4235
+ this._jump[key] = enums.NAVBoolean[value];
4236
+ }
4237
+ else if (Object.values(enums.NAVBoolean).includes(value)) {
4238
+ this._jump[key] = value;
4239
+ }
4214
4240
  }
4215
4241
  }
4216
4242
  }
@@ -4361,19 +4387,19 @@ var Scorm2004Impl = (function (_super) {
4361
4387
  });
4362
4388
  };
4363
4389
  Scorm2004Impl.prototype.lmsGetValue = function (CMIElement) {
4364
- var _a;
4390
+ var _a, _b;
4365
4391
  var adlNavRequestRegex = "^adl\\.nav\\.request_valid\\.(choice|jump)\\.{target=\\S{0,}([a-zA-Z0-9-_]+)}$";
4366
4392
  if ((0,utilities.stringMatches)(CMIElement, adlNavRequestRegex)) {
4367
4393
  var matches = CMIElement.match(adlNavRequestRegex);
4368
4394
  if (matches) {
4369
4395
  var request = matches[1];
4370
- var target = matches[2].replace("{target=", "").replace("}", "");
4371
- if (request === "choice" || request === "jump") {
4396
+ var target = (_a = matches[2]) === null || _a === void 0 ? void 0 : _a.replace("{target=", "").replace("}", "");
4397
+ if (target && (request === "choice" || request === "jump")) {
4372
4398
  if (this.settings.scoItemIdValidator) {
4373
4399
  return String(this.settings.scoItemIdValidator(target));
4374
4400
  }
4375
4401
  if (this.settings.scoItemIds) {
4376
- return String((_a = this.settings.scoItemIds) === null || _a === void 0 ? void 0 : _a.includes(target));
4402
+ return String((_b = this.settings.scoItemIds) === null || _b === void 0 ? void 0 : _b.includes(target));
4377
4403
  }
4378
4404
  return String(request);
4379
4405
  }
@@ -4527,8 +4553,9 @@ var Scorm2004Impl = (function (_super) {
4527
4553
  var interaction_count = interaction.correct_responses._count;
4528
4554
  this.checkDuplicateChoiceResponse(interaction, value);
4529
4555
  var response_type = CorrectResponses[interaction.type];
4530
- if (typeof response_type.limit === "undefined" ||
4531
- interaction_count <= response_type.limit) {
4556
+ if (typeof response_type !== "undefined" &&
4557
+ (typeof response_type.limit === "undefined" ||
4558
+ interaction_count <= response_type.limit)) {
4532
4559
  this.checkValidResponseType(response_type, value, interaction.type);
4533
4560
  if ((this.lastErrorCode === "0" &&
4534
4561
  (!response_type.duplicate ||
@@ -4549,14 +4576,17 @@ var Scorm2004Impl = (function (_super) {
4549
4576
  return this._commonGetCMIValue("GetValue", true, CMIElement);
4550
4577
  };
4551
4578
  Scorm2004Impl.prototype.getLmsErrorMessageDetails = function (errorNumber, detail) {
4579
+ var _a, _b;
4552
4580
  var basicMessage = "";
4553
4581
  var detailMessage = "";
4554
4582
  errorNumber = String(errorNumber);
4555
4583
  if (api_constants.scorm2004_constants.error_descriptions[errorNumber]) {
4556
4584
  basicMessage =
4557
- api_constants.scorm2004_constants.error_descriptions[errorNumber].basicMessage;
4585
+ ((_a = api_constants.scorm2004_constants.error_descriptions[errorNumber]) === null || _a === void 0 ? void 0 : _a.basicMessage) ||
4586
+ "Unknown Error";
4558
4587
  detailMessage =
4559
- api_constants.scorm2004_constants.error_descriptions[errorNumber].detailMessage;
4588
+ ((_b = api_constants.scorm2004_constants.error_descriptions[errorNumber]) === null || _b === void 0 ? void 0 : _b.detailMessage) ||
4589
+ "";
4560
4590
  }
4561
4591
  return detail ? detailMessage : basicMessage;
4562
4592
  };
@@ -4572,7 +4602,7 @@ var Scorm2004Impl = (function (_super) {
4572
4602
  };
4573
4603
  Scorm2004Impl.prototype.checkCorrectResponseValue = function (interaction_type, nodes, value) {
4574
4604
  var response = CorrectResponses[interaction_type];
4575
- var formatRegex = new RegExp(response.format);
4605
+ var formatRegex = new RegExp((response === null || response === void 0 ? void 0 : response.format) || ".*");
4576
4606
  for (var i = 0; i < nodes.length && this.lastErrorCode === "0"; i++) {
4577
4607
  if (interaction_type.match("^(fill-in|long-fill-in|matching|performance|sequencing)$")) {
4578
4608
  nodes[i] = this.removeCorrectResponsePrefixes(nodes[i]);
@@ -4608,7 +4638,7 @@ var Scorm2004Impl = (function (_super) {
4608
4638
  }
4609
4639
  }
4610
4640
  else {
4611
- if (nodes[i] !== "" && response.unique) {
4641
+ if (nodes[i] !== "" && (response === null || response === void 0 ? void 0 : response.unique)) {
4612
4642
  for (var j = 0; j < i && this.lastErrorCode === "0"; j++) {
4613
4643
  if (nodes[i] === nodes[j]) {
4614
4644
  this.throwSCORMError(error_codes.scorm2004_errors.TYPE_MISMATCH);
@@ -4621,6 +4651,7 @@ var Scorm2004Impl = (function (_super) {
4621
4651
  }
4622
4652
  };
4623
4653
  Scorm2004Impl.prototype.removeCorrectResponsePrefixes = function (node) {
4654
+ var _a;
4624
4655
  var seenOrder = false;
4625
4656
  var seenCase = false;
4626
4657
  var seenLang = false;
@@ -4658,7 +4689,7 @@ var Scorm2004Impl = (function (_super) {
4658
4689
  seenOrder = true;
4659
4690
  break;
4660
4691
  }
4661
- node = node.substring(matches[1].length);
4692
+ node = node.substring(((_a = matches[1]) === null || _a === void 0 ? void 0 : _a.length) || 0);
4662
4693
  matches = node.match(prefixRegex);
4663
4694
  }
4664
4695
  return node;
@@ -5060,8 +5091,8 @@ function checkValidFormat(value, regexPattern, errorCode, errorClass, allowEmpty
5060
5091
  function checkValidRange(value, rangePattern, errorCode, errorClass) {
5061
5092
  var ranges = rangePattern.split("#");
5062
5093
  value = value * 1.0;
5063
- if (value >= ranges[0]) {
5064
- if (ranges[1] === "*" || value <= ranges[1]) {
5094
+ if (ranges[0] && value >= ranges[0]) {
5095
+ if (ranges[1] && (ranges[1] === "*" || value <= ranges[1])) {
5065
5096
  return true;
5066
5097
  }
5067
5098
  else {
@@ -6656,11 +6687,12 @@ var Scorm12ValidationError = (function (_super) {
6656
6687
  (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__extends)(Scorm12ValidationError, _super);
6657
6688
  function Scorm12ValidationError(errorCode) {
6658
6689
  var _this = this;
6690
+ var _a, _b, _c, _d, _e;
6659
6691
  if ({}.hasOwnProperty.call(scorm12_errors, String(errorCode))) {
6660
- _this = _super.call(this, errorCode, scorm12_errors[String(errorCode)].basicMessage, scorm12_errors[String(errorCode)].detailMessage) || this;
6692
+ _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;
6661
6693
  }
6662
6694
  else {
6663
- _this = _super.call(this, 101, scorm12_errors["101"].basicMessage, scorm12_errors["101"].detailMessage) || this;
6695
+ _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;
6664
6696
  }
6665
6697
  return _this;
6666
6698
  }
@@ -6730,7 +6762,7 @@ function getSecondsAsISODuration(seconds) {
6730
6762
  var duration = "P";
6731
6763
  var remainder = seconds;
6732
6764
  for (var designationsKey in designations) {
6733
- var current_seconds = designations[designationsKey];
6765
+ var current_seconds = designations[designationsKey] || 1;
6734
6766
  var value = Math.floor(remainder / current_seconds);
6735
6767
  remainder = remainder % current_seconds;
6736
6768
  if (countDecimals(remainder) > 2) {
@@ -6837,7 +6869,7 @@ function unflatten(data) {
6837
6869
  var m = regex.exec(p);
6838
6870
  while (m) {
6839
6871
  cur = cur[prop] || (cur[prop] = m[2] ? [] : {});
6840
- prop = m[2] || m[1];
6872
+ prop = m[2] || m[1] || "";
6841
6873
  m = regex.exec(p);
6842
6874
  }
6843
6875
  cur[prop] = data[p];
@@ -6849,7 +6881,7 @@ function countDecimals(num) {
6849
6881
  if (Math.floor(num) === num || String(num).indexOf(".") < 0)
6850
6882
  return 0;
6851
6883
  var parts = num.toString().split(".")[1];
6852
- return parts.length || 0;
6884
+ return (parts === null || parts === void 0 ? void 0 : parts.length) || 0;
6853
6885
  }
6854
6886
  function formatMessage(functionName, message, CMIElement) {
6855
6887
  var baseLength = 20;