scorm-again 1.7.1 → 2.0.0

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 (85) hide show
  1. package/.babelrc +18 -7
  2. package/.github/dependabot.yml +5 -0
  3. package/.github/workflows/main.yml +79 -0
  4. package/.jsdoc.json +4 -5
  5. package/.mocharc.json +8 -0
  6. package/.run/Mocha Unit Tests.run.xml +5 -2
  7. package/CONTRIBUTING.md +1 -1
  8. package/README.md +14 -1
  9. package/dist/aicc.js +3661 -7170
  10. package/dist/aicc.js.map +1 -1
  11. package/dist/aicc.min.js +2 -40
  12. package/dist/aicc.min.js.map +1 -0
  13. package/dist/scorm-again.js +5671 -10695
  14. package/dist/scorm-again.js.map +1 -1
  15. package/dist/scorm-again.min.js +2 -52
  16. package/dist/scorm-again.min.js.map +1 -0
  17. package/dist/scorm12.js +2871 -5433
  18. package/dist/scorm12.js.map +1 -1
  19. package/dist/scorm12.min.js +2 -34
  20. package/dist/scorm12.min.js.map +1 -0
  21. package/dist/scorm2004.js +3868 -6797
  22. package/dist/scorm2004.js.map +1 -1
  23. package/dist/scorm2004.min.js +2 -40
  24. package/dist/scorm2004.min.js.map +1 -0
  25. package/eslint.config.js +21 -0
  26. package/package.json +72 -34
  27. package/results.json +34254 -0
  28. package/src/{AICC.js → AICC.ts} +27 -21
  29. package/src/BaseAPI.ts +1449 -0
  30. package/src/Scorm12API.ts +360 -0
  31. package/src/{Scorm2004API.js → Scorm2004API.ts} +245 -163
  32. package/src/cmi/aicc_cmi.ts +1248 -0
  33. package/src/cmi/common.ts +411 -0
  34. package/src/cmi/scorm12_cmi.ts +1426 -0
  35. package/src/cmi/scorm2004_cmi.ts +1874 -0
  36. package/src/constants/api_constants.ts +318 -0
  37. package/src/constants/error_codes.ts +88 -0
  38. package/src/constants/language_constants.ts +394 -0
  39. package/src/constants/regex.ts +97 -0
  40. package/src/constants/{response_constants.js → response_constants.ts} +67 -62
  41. package/src/exceptions.ts +133 -0
  42. package/src/exports/aicc.js +1 -1
  43. package/src/exports/scorm-again.js +3 -3
  44. package/src/exports/scorm12.js +1 -1
  45. package/src/exports/scorm2004.js +1 -1
  46. package/src/{utilities.js → utilities.ts} +114 -74
  47. package/tea.yaml +6 -0
  48. package/test/{AICC.spec.js → AICC.spec.ts} +70 -72
  49. package/test/Scorm12API.spec.ts +580 -0
  50. package/test/Scorm2004API.spec.ts +812 -0
  51. package/test/api_helpers.ts +176 -0
  52. package/test/cmi/{aicc_cmi.spec.js → aicc_cmi.spec.ts} +193 -209
  53. package/test/cmi/{scorm12_cmi.spec.js → scorm12_cmi.spec.ts} +251 -269
  54. package/test/cmi/scorm2004_cmi.spec.ts +1031 -0
  55. package/test/cmi_helpers.ts +207 -0
  56. package/test/exceptions.spec.ts +79 -0
  57. package/test/field_values.ts +202 -0
  58. package/test/utilities.spec.ts +322 -0
  59. package/tsconfig.json +18 -0
  60. package/webpack.config.js +65 -0
  61. package/.circleci/config.yml +0 -99
  62. package/.codeclimate.yml +0 -7
  63. package/.eslintrc.js +0 -36
  64. package/src/.flowconfig +0 -11
  65. package/src/BaseAPI.js +0 -1275
  66. package/src/Scorm12API.js +0 -308
  67. package/src/cmi/aicc_cmi.js +0 -1141
  68. package/src/cmi/common.js +0 -328
  69. package/src/cmi/scorm12_cmi.js +0 -1312
  70. package/src/cmi/scorm2004_cmi.js +0 -1692
  71. package/src/constants/api_constants.js +0 -218
  72. package/src/constants/error_codes.js +0 -87
  73. package/src/constants/language_constants.js +0 -76
  74. package/src/constants/regex.js +0 -84
  75. package/src/exceptions.js +0 -104
  76. package/test/Scorm12API.spec.js +0 -528
  77. package/test/Scorm2004API.spec.js +0 -775
  78. package/test/abstract_classes.spec.js +0 -17
  79. package/test/api_helpers.js +0 -128
  80. package/test/cmi/scorm2004_cmi.spec.js +0 -1066
  81. package/test/cmi_helpers.js +0 -161
  82. package/test/exceptions.spec.js +0 -71
  83. package/test/field_values.js +0 -353
  84. package/test/utilities.spec.js +0 -339
  85. package/webpack.js +0 -78
@@ -1,12 +1,13 @@
1
- // @flow
2
- import Scorm12API from './Scorm12API';
1
+ import Scorm12API from "./Scorm12API";
3
2
  import {
4
3
  CMI,
5
4
  CMIAttemptRecordsObject,
6
5
  CMIEvaluationCommentsObject,
7
6
  CMITriesObject,
8
- } from './cmi/aicc_cmi';
9
- import {NAV} from './cmi/scorm12_cmi';
7
+ } from "./cmi/aicc_cmi";
8
+ import { NAV } from "./cmi/scorm12_cmi";
9
+ import { Settings } from "./BaseAPI";
10
+ import { BaseCMI } from "./cmi/common";
10
11
 
11
12
  /**
12
13
  * The AICC API class
@@ -14,16 +15,10 @@ import {NAV} from './cmi/scorm12_cmi';
14
15
  export default class AICC extends Scorm12API {
15
16
  /**
16
17
  * Constructor to create AICC API object
17
- * @param {object} settings
18
+ * @param {Settings} settings
18
19
  */
19
- constructor(settings: {}) {
20
- const finalSettings = {
21
- ...{
22
- mastery_override: false,
23
- }, ...settings,
24
- };
25
-
26
- super(finalSettings);
20
+ constructor(settings?: Settings) {
21
+ super(settings);
27
22
 
28
23
  this.cmi = new CMI();
29
24
  this.nav = new NAV();
@@ -35,19 +30,30 @@ export default class AICC extends Scorm12API {
35
30
  * @param {string} CMIElement
36
31
  * @param {any} value
37
32
  * @param {boolean} foundFirstIndex
38
- * @return {object}
33
+ * @return {BaseCMI | null}
39
34
  */
40
- getChildElement(CMIElement, value, foundFirstIndex) {
35
+ getChildElement(
36
+ CMIElement: string,
37
+ value: any,
38
+ foundFirstIndex: boolean,
39
+ ): BaseCMI | null {
41
40
  let newChild = super.getChildElement(CMIElement, value, foundFirstIndex);
42
41
 
43
42
  if (!newChild) {
44
- if (this.stringMatches(CMIElement, 'cmi\\.evaluation\\.comments\\.\\d+')) {
43
+ if (
44
+ this.stringMatches(CMIElement, "cmi\\.evaluation\\.comments\\.\\d+")
45
+ ) {
45
46
  newChild = new CMIEvaluationCommentsObject();
46
- } else if (this.stringMatches(CMIElement,
47
- 'cmi\\.student_data\\.tries\\.\\d+')) {
47
+ } else if (
48
+ this.stringMatches(CMIElement, "cmi\\.student_data\\.tries\\.\\d+")
49
+ ) {
48
50
  newChild = new CMITriesObject();
49
- } else if (this.stringMatches(CMIElement,
50
- 'cmi\\.student_data\\.attempt_records\\.\\d+')) {
51
+ } else if (
52
+ this.stringMatches(
53
+ CMIElement,
54
+ "cmi\\.student_data\\.attempt_records\\.\\d+",
55
+ )
56
+ ) {
51
57
  newChild = new CMIAttemptRecordsObject();
52
58
  }
53
59
  }
@@ -60,7 +66,7 @@ export default class AICC extends Scorm12API {
60
66
  *
61
67
  * @param {AICC} newAPI
62
68
  */
63
- replaceWithAnotherScormAPI(newAPI) {
69
+ replaceWithAnotherScormAPI(newAPI: AICC) {
64
70
  // Data Model
65
71
  this.cmi = newAPI.cmi;
66
72
  this.nav = newAPI.nav;