scorm-again 1.7.0 → 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 +73 -35
  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
package/.babelrc CHANGED
@@ -1,11 +1,22 @@
1
1
  {
2
2
  "presets": [
3
- "@babel/preset-env",
4
- "@babel/preset-flow"
5
- ],
6
- "plugins": [
7
- "@babel/plugin-proposal-class-properties",
8
- "@babel/plugin-proposal-private-methods",
9
- "@babel/plugin-proposal-optional-chaining"
3
+ [
4
+ "@babel/preset-env",
5
+ {
6
+ "corejs": "3",
7
+ "useBuiltIns": "entry",
8
+ "targets": {
9
+ "browsers": [
10
+ "edge >= 16",
11
+ "safari >= 9",
12
+ "firefox >= 57",
13
+ "ie >= 11",
14
+ "ios >= 9",
15
+ "chrome >= 49"
16
+ ]
17
+ }
18
+ }
19
+ ],
20
+ "@babel/preset-typescript"
10
21
  ]
11
22
  }
@@ -6,6 +6,11 @@
6
6
  version: 2
7
7
  updates:
8
8
  - package-ecosystem: "npm"
9
+ directory: "/"
10
+ schedule:
11
+ interval: "daily"
12
+ open-pull-requests-limit: 20
13
+ - package-ecosystem: "github-actions"
9
14
  directory: "/"
10
15
  schedule:
11
16
  interval: "daily"
@@ -0,0 +1,79 @@
1
+ name: Node.js CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request:
8
+ branches:
9
+ - master
10
+ workflow_dispatch:
11
+
12
+ jobs:
13
+ build:
14
+ runs-on: ubuntu-latest
15
+
16
+ steps:
17
+ # Checkout repository
18
+ - name: Checkout code
19
+ uses: actions/checkout@v4
20
+
21
+ # Set up Node.js
22
+ - name: Setup Node.js
23
+ uses: actions/setup-node@v4
24
+ with:
25
+ node-version: 20
26
+ cache: 'yarn'
27
+
28
+ # Install dependencies
29
+ - name: Install dependencies
30
+ run: yarn install
31
+
32
+ # Create required directories
33
+ - name: Create directories
34
+ run: mkdir -p reports dist docs test-results
35
+
36
+ # Run Mocha tests
37
+ - name: Run tests with Mocha
38
+ run: |
39
+ export TS_NODE_COMPILER_OPTIONS="{\"module\":\"commonjs\"}"
40
+ yarn run test:coverage
41
+
42
+ # Upload test results to GitHub
43
+ - uses: dorny/test-reporter@v1
44
+ with:
45
+ name: Test Reporter
46
+ path: test-results.json
47
+ reporter: mocha-json
48
+
49
+ # Run ESLint
50
+ - name: Run ESLint
51
+ run: |
52
+ ./node_modules/.bin/eslint ./src --format junit --output-file ./reports/eslint/eslint.xml
53
+
54
+ # Generate code coverage report and upload to Code Climate
55
+ - name: Upload Code Coverage Report
56
+ uses: paambaati/codeclimate-action@v9.0.0
57
+ env:
58
+ CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
59
+ with:
60
+ coverageCommand: yarn run test:coverage
61
+ coverageLocations: |
62
+ ${{github.workspace}}/coverage/lcov.info:lcov
63
+ debug: 'true'
64
+
65
+ # Format code with Prettier
66
+ - name: Format code with Prettier
67
+ run: yarn run prettier
68
+
69
+ # Build the project
70
+ - name: Build project
71
+ run: yarn run compile
72
+
73
+ - name: Commit and Push Dist Folder
74
+ if: github.event_name == 'push' && github.ref == 'refs/heads/master'
75
+ uses: stefanzweifel/git-auto-commit-action@v5
76
+ with:
77
+ commit_message: '[skip ci] Add dist folder'
78
+ file_pattern: 'dist/*.* src/**/*.* test/**/*.* src/*.* test/*.*'
79
+ skip_dirty_check: false
package/.jsdoc.json CHANGED
@@ -4,13 +4,12 @@
4
4
  ],
5
5
  "babel": {
6
6
  "presets": [
7
- "@babel/preset-env",
8
- "@babel/preset-flow"
7
+ "@babel/preset-env"
9
8
  ],
10
9
  "plugins": [
11
- "@babel/plugin-proposal-class-properties",
12
- "@babel/plugin-proposal-private-methods",
13
- "@babel/plugin-proposal-optional-chaining"
10
+ "@babel/plugin-transform-class-properties",
11
+ "@babel/plugin-transform-private-methods",
12
+ "@babel/plugin-transform-optional-chaining"
14
13
  ]
15
14
  }
16
15
  }
package/.mocharc.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "ui": "bdd",
3
+ "extension": [
4
+ "ts"
5
+ ],
6
+ "spec": "test/**/*.spec.ts",
7
+ "recursive": true
8
+ }
@@ -5,10 +5,13 @@
5
5
  <mocha-package>$PROJECT_DIR$/node_modules/mocha</mocha-package>
6
6
  <working-directory>$PROJECT_DIR$</working-directory>
7
7
  <pass-parent-env>true</pass-parent-env>
8
+ <envs>
9
+ <env name="TS_NODE_COMPILER_OPTIONS" value="&quot;{\&quot;module\&quot;:\&quot;commonjs\&quot;}&quot;" />
10
+ </envs>
8
11
  <ui>bdd</ui>
9
- <extra-mocha-options>--watch --require @babel/register</extra-mocha-options>
12
+ <extra-mocha-options>--watch --import=tsx</extra-mocha-options>
10
13
  <test-kind>PATTERN</test-kind>
11
- <test-pattern>test/**/*.spec.js</test-pattern>
14
+ <test-pattern>test/**/*.spec.ts</test-pattern>
12
15
  <method v="2" />
13
16
  </configuration>
14
17
  </component>
package/CONTRIBUTING.md CHANGED
@@ -6,7 +6,7 @@ I'm really glad you're reading this, because this project could definitely benef
6
6
 
7
7
  I have written 1700+ test cases for the project, but testing is nowhere near what it should be. I try to add test cases as I have time or as an issue comes up. For pull requests, please create test cases for any new code that gets added.
8
8
 
9
- If you would like to contribute, but don't know where to get started, we could absolute use more test cases. The CMI test cases are pretty well covered, but there are always edge cases to think of, but the API test cases are definitely lacking. They are more difficult to create and setup, but obviously cover the bulk of the functionality as well.
9
+ If you would like to contribute, but don't know where to get started, we could absolutely use more test cases. The CMI test cases are pretty well covered, but there are always edge cases to think of, and the API test cases are definitely lacking. They are more difficult to create and setup, but obviously cover the bulk of the functionality as well.
10
10
 
11
11
  ## Submitting changes
12
12
 
package/README.md CHANGED
@@ -1,8 +1,21 @@
1
- [![CircleCI](https://img.shields.io/circleci/build/github/jcputney/scorm-again/master?style=for-the-badge "CircleCI Build Status")](https://circleci.com/gh/jcputney/scorm-again) [![Code Climate maintainability](https://img.shields.io/codeclimate/maintainability/jcputney/scorm-again?style=for-the-badge)](https://codeclimate.com/github/jcputney/scorm-again) [![Code Climate coverage](https://img.shields.io/codeclimate/coverage/jcputney/scorm-again?style=for-the-badge)](https://codeclimate.com/github/jcputney/scorm-again/trends/test_coverage_total) [![Code Climate technical debt](https://img.shields.io/codeclimate/tech-debt/jcputney/scorm-again?style=for-the-badge)](https://codeclimate.com/github/jcputney/scorm-again/trends/technical_debt) [![Snyk Vulnerabilities for GitHub Repo](https://img.shields.io/snyk/vulnerabilities/github/jcputney/scorm-again?style=for-the-badge) ](https://app.snyk.io/org/jcputney/projects?origin[]=github) ![Libraries.io dependency status for latest release](https://img.shields.io/librariesio/release/npm/scorm-again?style=for-the-badge) ![npm bundle size](https://img.shields.io/bundlephobia/min/scorm-again?style=for-the-badge) [![donate](https://img.shields.io/badge/paypal-donate-success?style=for-the-badge)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=NF5MPZJAV26LE) [![Gitter](https://img.shields.io/gitter/room/jcputney/scorm-again?style=for-the-badge)](https://gitter.im/jcputney/scorm-again) [![npm](https://img.shields.io/npm/v/scorm-again?color=%2344cc11&style=for-the-badge)](https://www.npmjs.com/package/scorm-again)
1
+ [![Github Actions](https://img.shields.io/github/actions/workflow/status/jcputney/scorm-again/main.yml?style=for-the-badge "Build Status")](https://github.com/jcputney/scorm-again/actions)
2
+ [![Code Climate maintainability](https://img.shields.io/codeclimate/maintainability/jcputney/scorm-again?style=for-the-badge)](https://codeclimate.com/github/jcputney/scorm-again)
3
+ [![Code Climate coverage](https://img.shields.io/codeclimate/coverage/jcputney/scorm-again?style=for-the-badge)](https://codeclimate.com/github/jcputney/scorm-again/trends/test_coverage_total)
4
+ [![Code Climate technical debt](https://img.shields.io/codeclimate/tech-debt/jcputney/scorm-again?style=for-the-badge)](https://codeclimate.com/github/jcputney/scorm-again/trends/technical_debt)
5
+ ![jsDelivr hits (npm)](https://img.shields.io/jsdelivr/npm/hy/scorm-again?style=for-the-badge&label=jsDeliver%20Downloads)
6
+ ![NPM Downloads](https://img.shields.io/npm/dy/scorm-again?style=for-the-badge&label=npm%20Downloads)
7
+ ![Libraries.io dependency status for GitHub repo](https://img.shields.io/librariesio/github/jcputney/scorm-again?style=for-the-badge) ![npm bundle size](https://img.shields.io/bundlephobia/min/scorm-again?style=for-the-badge)
8
+ [![npm](https://img.shields.io/npm/v/scorm-again?color=%2344cc11&style=for-the-badge)](https://www.npmjs.com/package/scorm-again)
9
+ ![GitHub License](https://img.shields.io/github/license/jcputney/scorm-again?style=for-the-badge)
10
+ [![donate](https://img.shields.io/badge/paypal-donate-success?style=for-the-badge)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=NF5MPZJAV26LE)
11
+
2
12
 
3
13
  # SCORM Again
4
14
  This project was created to modernize the SCORM JavaScript runtime, and to provide a stable, tested platform for running AICC, SCORM 1.2, and SCORM 2004 modules. This module is designed to be LMS agnostic, and is written to be able to be run without a backing LMS, logging all function calls and data instead of committing, if an LMS endpoint is not configured.
5
15
 
16
+ ## Potential Breaking Change!
17
+ Version 2.0.0 of scorm-again switches to using `fetch`, as well as async-only for reporting to the LMS. Since `fetch` is not supported by IE11, you will need to provide your own polyfill for this functionality if you need to support it.
18
+
6
19
  ### What is this not and what doesn't it do?
7
20
  1. This is not an LMS
8
21
  1. This does not handle the uploading and verification of SCORM/AICC modules