scorm-again 2.6.7 → 2.6.8
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.
- package/.claude/settings.local.json +93 -2
- package/dist/aicc.js +3083 -3058
- package/dist/aicc.js.map +1 -1
- package/dist/aicc.min.js +1 -1
- package/dist/aicc.min.js.map +1 -1
- package/dist/esm/aicc.js +3102 -3083
- package/dist/esm/aicc.js.map +1 -1
- package/dist/esm/aicc.min.js +1 -1
- package/dist/esm/aicc.min.js.map +1 -1
- package/dist/esm/scorm-again.js +5605 -5580
- package/dist/esm/scorm-again.js.map +1 -1
- package/dist/esm/scorm-again.min.js +1 -1
- package/dist/esm/scorm-again.min.js.map +1 -1
- package/dist/esm/scorm12.js +2822 -2797
- package/dist/esm/scorm12.js.map +1 -1
- package/dist/esm/scorm12.min.js +1 -1
- package/dist/esm/scorm12.min.js.map +1 -1
- package/dist/esm/scorm2004.js +1955 -1936
- package/dist/esm/scorm2004.js.map +1 -1
- package/dist/esm/scorm2004.min.js +1 -1
- package/dist/esm/scorm2004.min.js.map +1 -1
- package/dist/scorm-again.js +5605 -5580
- package/dist/scorm-again.js.map +1 -1
- package/dist/scorm-again.min.js +1 -1
- package/dist/scorm-again.min.js.map +1 -1
- package/dist/scorm12.js +2821 -2796
- package/dist/scorm12.js.map +1 -1
- package/dist/scorm12.min.js +1 -1
- package/dist/scorm12.min.js.map +1 -1
- package/dist/scorm2004.js +1798 -1773
- package/dist/scorm2004.js.map +1 -1
- package/dist/scorm2004.min.js +1 -1
- package/dist/scorm2004.min.js.map +1 -1
- package/examples/react-native-offline/.claude/settings.local.json +31 -0
- package/package.json +2 -1
- package/src/Scorm2004API.ts +2 -2
- package/src/constants/default_settings.ts +2 -2
- package/.claude/.claude/settings.local.json +0 -13
package/dist/scorm2004.js
CHANGED
|
@@ -2,1255 +2,138 @@
|
|
|
2
2
|
/******/ "use strict";
|
|
3
3
|
/******/ var __webpack_modules__ = ({
|
|
4
4
|
|
|
5
|
-
/***/
|
|
5
|
+
/***/ 56:
|
|
6
6
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
7
7
|
|
|
8
|
-
// ESM COMPAT FLAG
|
|
9
8
|
__webpack_require__.r(__webpack_exports__);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
9
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
10
|
+
/* harmony export */ CompletionStatus: function() { return /* binding */ CompletionStatus; },
|
|
11
|
+
/* harmony export */ LogLevelEnum: function() { return /* binding */ LogLevelEnum; },
|
|
12
|
+
/* harmony export */ NAVBoolean: function() { return /* binding */ NAVBoolean; },
|
|
13
|
+
/* harmony export */ SuccessStatus: function() { return /* binding */ SuccessStatus; }
|
|
14
|
+
/* harmony export */ });
|
|
15
|
+
var NAVBoolean;
|
|
16
|
+
(function (NAVBoolean) {
|
|
17
|
+
NAVBoolean["unknown"] = "unknown";
|
|
18
|
+
NAVBoolean["true"] = "true";
|
|
19
|
+
NAVBoolean["false"] = "false";
|
|
20
|
+
})(NAVBoolean || (NAVBoolean = {}));
|
|
21
|
+
var SuccessStatus;
|
|
22
|
+
(function (SuccessStatus) {
|
|
23
|
+
SuccessStatus["passed"] = "passed";
|
|
24
|
+
SuccessStatus["failed"] = "failed";
|
|
25
|
+
SuccessStatus["unknown"] = "unknown";
|
|
26
|
+
})(SuccessStatus || (SuccessStatus = {}));
|
|
27
|
+
var CompletionStatus;
|
|
28
|
+
(function (CompletionStatus) {
|
|
29
|
+
CompletionStatus["completed"] = "completed";
|
|
30
|
+
CompletionStatus["incomplete"] = "incomplete";
|
|
31
|
+
CompletionStatus["unknown"] = "unknown";
|
|
32
|
+
})(CompletionStatus || (CompletionStatus = {}));
|
|
33
|
+
var LogLevelEnum;
|
|
34
|
+
(function (LogLevelEnum) {
|
|
35
|
+
LogLevelEnum[LogLevelEnum["_"] = 0] = "_";
|
|
36
|
+
LogLevelEnum[LogLevelEnum["DEBUG"] = 1] = "DEBUG";
|
|
37
|
+
LogLevelEnum[LogLevelEnum["INFO"] = 2] = "INFO";
|
|
38
|
+
LogLevelEnum[LogLevelEnum["WARN"] = 3] = "WARN";
|
|
39
|
+
LogLevelEnum[LogLevelEnum["ERROR"] = 4] = "ERROR";
|
|
40
|
+
LogLevelEnum[LogLevelEnum["NONE"] = 5] = "NONE";
|
|
41
|
+
})(LogLevelEnum || (LogLevelEnum = {}));
|
|
29
42
|
|
|
30
43
|
|
|
44
|
+
/***/ }),
|
|
31
45
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
autocommitSeconds: 10,
|
|
35
|
-
asyncCommit: false,
|
|
36
|
-
sendFullCommit: true,
|
|
37
|
-
lmsCommitUrl: false,
|
|
38
|
-
dataCommitFormat: "json",
|
|
39
|
-
commitRequestDataType: "application/json;charset=UTF-8",
|
|
40
|
-
autoProgress: false,
|
|
41
|
-
logLevel: enums.LogLevelEnum.ERROR,
|
|
42
|
-
selfReportSessionTime: false,
|
|
43
|
-
alwaysSendTotalTime: false,
|
|
44
|
-
renderCommonCommitFields: false,
|
|
45
|
-
strict_errors: true,
|
|
46
|
-
xhrHeaders: {},
|
|
47
|
-
xhrWithCredentials: false,
|
|
48
|
-
fetchMode: "cors",
|
|
49
|
-
responseHandler: function (response) {
|
|
50
|
-
return (0,tslib_es6.__awaiter)(this, void 0, void 0, function () {
|
|
51
|
-
var responseText, httpResult;
|
|
52
|
-
return (0,tslib_es6.__generator)(this, function (_a) {
|
|
53
|
-
switch (_a.label) {
|
|
54
|
-
case 0:
|
|
55
|
-
if (!(typeof response !== "undefined")) return [3, 2];
|
|
56
|
-
return [4, response.text()];
|
|
57
|
-
case 1:
|
|
58
|
-
responseText = _a.sent();
|
|
59
|
-
httpResult = null;
|
|
60
|
-
if (responseText) {
|
|
61
|
-
httpResult = JSON.parse(responseText);
|
|
62
|
-
}
|
|
63
|
-
if (httpResult === null ||
|
|
64
|
-
!{}.hasOwnProperty.call(httpResult, "result")) {
|
|
65
|
-
if (response.status === 200) {
|
|
66
|
-
return [2, {
|
|
67
|
-
result: api_constants.global_constants.SCORM_TRUE,
|
|
68
|
-
errorCode: 0
|
|
69
|
-
}];
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
return [2, {
|
|
73
|
-
result: api_constants.global_constants.SCORM_FALSE,
|
|
74
|
-
errorCode: 101
|
|
75
|
-
}];
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
return [2, {
|
|
80
|
-
result: httpResult.result,
|
|
81
|
-
errorCode: httpResult.errorCode
|
|
82
|
-
? httpResult.errorCode
|
|
83
|
-
: httpResult.result === api_constants.global_constants.SCORM_TRUE
|
|
84
|
-
? 0
|
|
85
|
-
: 101
|
|
86
|
-
}];
|
|
87
|
-
}
|
|
88
|
-
_a.label = 2;
|
|
89
|
-
case 2: return [2, {
|
|
90
|
-
result: api_constants.global_constants.SCORM_FALSE,
|
|
91
|
-
errorCode: 101
|
|
92
|
-
}];
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
},
|
|
97
|
-
requestHandler: function (commitObject) {
|
|
98
|
-
return commitObject;
|
|
99
|
-
},
|
|
100
|
-
onLogMessage: function (messageLevel, logMessage) {
|
|
101
|
-
switch (messageLevel) {
|
|
102
|
-
case "4":
|
|
103
|
-
case 4:
|
|
104
|
-
case "ERROR":
|
|
105
|
-
case enums.LogLevelEnum.ERROR:
|
|
106
|
-
console.error(logMessage);
|
|
107
|
-
break;
|
|
108
|
-
case "3":
|
|
109
|
-
case 3:
|
|
110
|
-
case "WARN":
|
|
111
|
-
case enums.LogLevelEnum.WARN:
|
|
112
|
-
console.warn(logMessage);
|
|
113
|
-
break;
|
|
114
|
-
case "2":
|
|
115
|
-
case 2:
|
|
116
|
-
case "INFO":
|
|
117
|
-
case enums.LogLevelEnum.INFO:
|
|
118
|
-
console.info(logMessage);
|
|
119
|
-
break;
|
|
120
|
-
case "1":
|
|
121
|
-
case 1:
|
|
122
|
-
case "DEBUG":
|
|
123
|
-
case enums.LogLevelEnum.DEBUG:
|
|
124
|
-
if (console.debug) {
|
|
125
|
-
console.debug(logMessage);
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
console.log(logMessage);
|
|
129
|
-
}
|
|
130
|
-
break;
|
|
131
|
-
}
|
|
132
|
-
},
|
|
133
|
-
scoItemIds: [],
|
|
134
|
-
scoItemIdValidator: false,
|
|
135
|
-
globalObjectiveIds: []
|
|
136
|
-
};
|
|
46
|
+
/***/ 319:
|
|
47
|
+
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
137
48
|
|
|
138
|
-
|
|
49
|
+
__webpack_require__.r(__webpack_exports__);
|
|
50
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
51
|
+
/* harmony export */ BaseCMI: function() { return /* binding */ BaseCMI; },
|
|
52
|
+
/* harmony export */ BaseRootCMI: function() { return /* binding */ BaseRootCMI; }
|
|
53
|
+
/* harmony export */ });
|
|
54
|
+
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(635);
|
|
139
55
|
|
|
140
|
-
var
|
|
141
|
-
function
|
|
142
|
-
this.
|
|
143
|
-
this.
|
|
144
|
-
this._timeout = setTimeout(this.wrapper.bind(this), when);
|
|
145
|
-
this._callback = callback;
|
|
56
|
+
var BaseCMI = (function () {
|
|
57
|
+
function BaseCMI() {
|
|
58
|
+
this.jsonString = false;
|
|
59
|
+
this._initialized = false;
|
|
146
60
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
61
|
+
Object.defineProperty(BaseCMI.prototype, "initialized", {
|
|
62
|
+
get: function () {
|
|
63
|
+
return this._initialized;
|
|
64
|
+
},
|
|
65
|
+
enumerable: false,
|
|
66
|
+
configurable: true
|
|
67
|
+
});
|
|
68
|
+
Object.defineProperty(BaseCMI.prototype, "start_time", {
|
|
69
|
+
get: function () {
|
|
70
|
+
return this._start_time;
|
|
71
|
+
},
|
|
72
|
+
enumerable: false,
|
|
73
|
+
configurable: true
|
|
74
|
+
});
|
|
75
|
+
BaseCMI.prototype.initialize = function () {
|
|
76
|
+
this._initialized = true;
|
|
152
77
|
};
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
if (!this._cancelled) {
|
|
156
|
-
(function () { return (0,tslib_es6.__awaiter)(_this, void 0, void 0, function () { return (0,tslib_es6.__generator)(this, function (_a) {
|
|
157
|
-
switch (_a.label) {
|
|
158
|
-
case 0: return [4, this._API.commit(this._callback)];
|
|
159
|
-
case 1: return [2, _a.sent()];
|
|
160
|
-
}
|
|
161
|
-
}); }); })();
|
|
162
|
-
}
|
|
78
|
+
BaseCMI.prototype.setStartTime = function () {
|
|
79
|
+
this._start_time = new Date().getTime();
|
|
163
80
|
};
|
|
164
|
-
return
|
|
81
|
+
return BaseCMI;
|
|
165
82
|
}());
|
|
166
83
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
84
|
+
var BaseRootCMI = (function (_super) {
|
|
85
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_0__.__extends)(BaseRootCMI, _super);
|
|
86
|
+
function BaseRootCMI() {
|
|
87
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
88
|
+
}
|
|
89
|
+
return BaseRootCMI;
|
|
90
|
+
}(BaseCMI));
|
|
171
91
|
|
|
172
92
|
|
|
173
93
|
|
|
94
|
+
/***/ }),
|
|
174
95
|
|
|
96
|
+
/***/ 340:
|
|
97
|
+
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
175
98
|
|
|
99
|
+
__webpack_require__.r(__webpack_exports__);
|
|
100
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
101
|
+
/* harmony export */ aicc_constants: function() { return /* binding */ aicc_constants; },
|
|
102
|
+
/* harmony export */ global_constants: function() { return /* binding */ global_constants; },
|
|
103
|
+
/* harmony export */ scorm12_constants: function() { return /* binding */ scorm12_constants; },
|
|
104
|
+
/* harmony export */ scorm2004_constants: function() { return /* binding */ scorm2004_constants; }
|
|
105
|
+
/* harmony export */ });
|
|
106
|
+
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(635);
|
|
176
107
|
|
|
177
|
-
var
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
this.clearScheduledCommit();
|
|
199
|
-
this.currentState = api_constants.global_constants.STATE_NOT_INITIALIZED;
|
|
200
|
-
this.lastErrorCode = "0";
|
|
201
|
-
this.listenerArray = [];
|
|
202
|
-
this.startingData = {};
|
|
203
|
-
};
|
|
204
|
-
BaseAPI.prototype.initialize = function (callbackName, initializeMessage, terminationMessage) {
|
|
205
|
-
var returnValue = api_constants.global_constants.SCORM_FALSE;
|
|
206
|
-
if (this.isInitialized()) {
|
|
207
|
-
this.throwSCORMError(this._error_codes.INITIALIZED, initializeMessage);
|
|
208
|
-
}
|
|
209
|
-
else if (this.isTerminated()) {
|
|
210
|
-
this.throwSCORMError(this._error_codes.TERMINATED, terminationMessage);
|
|
211
|
-
}
|
|
212
|
-
else {
|
|
213
|
-
if (this.selfReportSessionTime) {
|
|
214
|
-
this.cmi.setStartTime();
|
|
215
|
-
}
|
|
216
|
-
this.currentState = api_constants.global_constants.STATE_INITIALIZED;
|
|
217
|
-
this.lastErrorCode = "0";
|
|
218
|
-
returnValue = api_constants.global_constants.SCORM_TRUE;
|
|
219
|
-
this.processListeners(callbackName);
|
|
220
|
-
}
|
|
221
|
-
this.apiLog(callbackName, "returned: " + returnValue, enums.LogLevelEnum.INFO);
|
|
222
|
-
this.clearSCORMError(returnValue);
|
|
223
|
-
return returnValue;
|
|
224
|
-
};
|
|
225
|
-
BaseAPI.prototype.apiLog = function (functionName, logMessage, messageLevel, CMIElement) {
|
|
226
|
-
logMessage = (0,utilities.formatMessage)(functionName, logMessage, CMIElement);
|
|
227
|
-
if (messageLevel >= this.apiLogLevel) {
|
|
228
|
-
this.settings.onLogMessage(messageLevel, logMessage);
|
|
229
|
-
}
|
|
230
|
-
};
|
|
231
|
-
Object.defineProperty(BaseAPI.prototype, "error_codes", {
|
|
232
|
-
get: function () {
|
|
233
|
-
return this._error_codes;
|
|
108
|
+
var global_constants = {
|
|
109
|
+
SCORM_TRUE: "true",
|
|
110
|
+
SCORM_FALSE: "false",
|
|
111
|
+
STATE_NOT_INITIALIZED: 0,
|
|
112
|
+
STATE_INITIALIZED: 1,
|
|
113
|
+
STATE_TERMINATED: 2,
|
|
114
|
+
};
|
|
115
|
+
var scorm12_constants = {
|
|
116
|
+
cmi_children: "core,suspend_data,launch_data,comments,objectives,student_data,student_preference,interactions",
|
|
117
|
+
core_children: "student_id,student_name,lesson_location,credit,lesson_status,entry,score,total_time,lesson_mode,exit,session_time",
|
|
118
|
+
score_children: "raw,min,max",
|
|
119
|
+
comments_children: "content,location,time",
|
|
120
|
+
objectives_children: "id,score,status",
|
|
121
|
+
correct_responses_children: "pattern",
|
|
122
|
+
student_data_children: "mastery_score,max_time_allowed,time_limit_action",
|
|
123
|
+
student_preference_children: "audio,language,speed,text",
|
|
124
|
+
interactions_children: "id,objectives,time,type,correct_responses,weighting,student_response,result,latency",
|
|
125
|
+
error_descriptions: {
|
|
126
|
+
"101": {
|
|
127
|
+
basicMessage: "General Exception",
|
|
128
|
+
detailMessage: "No specific error code exists to describe the error. Use LMSGetDiagnostic for more information",
|
|
234
129
|
},
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
Object.defineProperty(BaseAPI.prototype, "settings", {
|
|
239
|
-
get: function () {
|
|
240
|
-
return this._settings;
|
|
130
|
+
"201": {
|
|
131
|
+
basicMessage: "Invalid argument error",
|
|
132
|
+
detailMessage: "Indicates that an argument represents an invalid data model element or is otherwise incorrect.",
|
|
241
133
|
},
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
enumerable: false,
|
|
246
|
-
configurable: true
|
|
247
|
-
});
|
|
248
|
-
BaseAPI.prototype.terminate = function (callbackName, checkTerminated) {
|
|
249
|
-
return (0,tslib_es6.__awaiter)(this, void 0, void 0, function () {
|
|
250
|
-
var returnValue, result;
|
|
251
|
-
return (0,tslib_es6.__generator)(this, function (_a) {
|
|
252
|
-
switch (_a.label) {
|
|
253
|
-
case 0:
|
|
254
|
-
returnValue = api_constants.global_constants.SCORM_FALSE;
|
|
255
|
-
if (!this.checkState(checkTerminated, this._error_codes.TERMINATION_BEFORE_INIT, this._error_codes.MULTIPLE_TERMINATION)) return [3, 2];
|
|
256
|
-
this.currentState = api_constants.global_constants.STATE_TERMINATED;
|
|
257
|
-
return [4, this.storeData(true)];
|
|
258
|
-
case 1:
|
|
259
|
-
result = _a.sent();
|
|
260
|
-
if (typeof result.errorCode !== "undefined" && result.errorCode > 0) {
|
|
261
|
-
this.throwSCORMError(result.errorCode);
|
|
262
|
-
}
|
|
263
|
-
returnValue =
|
|
264
|
-
typeof result !== "undefined" && (result.result === true || result.result === api_constants.global_constants.SCORM_TRUE)
|
|
265
|
-
? api_constants.global_constants.SCORM_TRUE
|
|
266
|
-
: api_constants.global_constants.SCORM_FALSE;
|
|
267
|
-
if (checkTerminated)
|
|
268
|
-
this.lastErrorCode = "0";
|
|
269
|
-
returnValue = api_constants.global_constants.SCORM_TRUE;
|
|
270
|
-
this.processListeners(callbackName);
|
|
271
|
-
_a.label = 2;
|
|
272
|
-
case 2:
|
|
273
|
-
this.apiLog(callbackName, "returned: " + returnValue, enums.LogLevelEnum.INFO);
|
|
274
|
-
this.clearSCORMError(returnValue);
|
|
275
|
-
return [2, returnValue];
|
|
276
|
-
}
|
|
277
|
-
});
|
|
278
|
-
});
|
|
279
|
-
};
|
|
280
|
-
BaseAPI.prototype.getValue = function (callbackName, checkTerminated, CMIElement) {
|
|
281
|
-
var returnValue = "";
|
|
282
|
-
if (this.checkState(checkTerminated, this._error_codes.RETRIEVE_BEFORE_INIT, this._error_codes.RETRIEVE_AFTER_TERM)) {
|
|
283
|
-
if (checkTerminated)
|
|
284
|
-
this.lastErrorCode = "0";
|
|
285
|
-
try {
|
|
286
|
-
returnValue = this.getCMIValue(CMIElement);
|
|
287
|
-
}
|
|
288
|
-
catch (e) {
|
|
289
|
-
returnValue = this.handleValueAccessException(e, returnValue);
|
|
290
|
-
}
|
|
291
|
-
this.processListeners(callbackName, CMIElement);
|
|
292
|
-
}
|
|
293
|
-
this.apiLog(callbackName, ": returned: " + returnValue, enums.LogLevelEnum.INFO, CMIElement);
|
|
294
|
-
if (returnValue === undefined) {
|
|
295
|
-
return "";
|
|
296
|
-
}
|
|
297
|
-
this.clearSCORMError(returnValue);
|
|
298
|
-
return returnValue;
|
|
299
|
-
};
|
|
300
|
-
BaseAPI.prototype.setValue = function (callbackName, commitCallback, checkTerminated, CMIElement, value) {
|
|
301
|
-
if (value !== undefined) {
|
|
302
|
-
value = String(value);
|
|
303
|
-
}
|
|
304
|
-
var returnValue = api_constants.global_constants.SCORM_FALSE;
|
|
305
|
-
if (this.checkState(checkTerminated, this._error_codes.STORE_BEFORE_INIT, this._error_codes.STORE_AFTER_TERM)) {
|
|
306
|
-
if (checkTerminated)
|
|
307
|
-
this.lastErrorCode = "0";
|
|
308
|
-
try {
|
|
309
|
-
returnValue = this.setCMIValue(CMIElement, value);
|
|
310
|
-
}
|
|
311
|
-
catch (e) {
|
|
312
|
-
this.handleValueAccessException(e, returnValue);
|
|
313
|
-
}
|
|
314
|
-
this.processListeners(callbackName, CMIElement, value);
|
|
315
|
-
}
|
|
316
|
-
if (returnValue === undefined) {
|
|
317
|
-
returnValue = api_constants.global_constants.SCORM_FALSE;
|
|
318
|
-
}
|
|
319
|
-
if (String(this.lastErrorCode) === "0") {
|
|
320
|
-
if (this.settings.autocommit) {
|
|
321
|
-
this.scheduleCommit(this.settings.autocommitSeconds * 1000, commitCallback);
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
this.apiLog(callbackName, ": " + value + ": result: " + returnValue, enums.LogLevelEnum.INFO, CMIElement);
|
|
325
|
-
this.clearSCORMError(returnValue);
|
|
326
|
-
return returnValue;
|
|
327
|
-
};
|
|
328
|
-
BaseAPI.prototype.commit = function (callbackName_1) {
|
|
329
|
-
return (0,tslib_es6.__awaiter)(this, arguments, void 0, function (callbackName, checkTerminated) {
|
|
330
|
-
var returnValue, result;
|
|
331
|
-
if (checkTerminated === void 0) { checkTerminated = false; }
|
|
332
|
-
return (0,tslib_es6.__generator)(this, function (_a) {
|
|
333
|
-
switch (_a.label) {
|
|
334
|
-
case 0:
|
|
335
|
-
this.clearScheduledCommit();
|
|
336
|
-
returnValue = api_constants.global_constants.SCORM_FALSE;
|
|
337
|
-
if (!this.checkState(checkTerminated, this._error_codes.COMMIT_BEFORE_INIT, this._error_codes.COMMIT_AFTER_TERM)) return [3, 2];
|
|
338
|
-
return [4, this.storeData(false)];
|
|
339
|
-
case 1:
|
|
340
|
-
result = _a.sent();
|
|
341
|
-
if (result.errorCode && result.errorCode > 0) {
|
|
342
|
-
this.throwSCORMError(result.errorCode);
|
|
343
|
-
}
|
|
344
|
-
returnValue =
|
|
345
|
-
typeof result !== "undefined" && (result.result === true || result.result === api_constants.global_constants.SCORM_TRUE)
|
|
346
|
-
? api_constants.global_constants.SCORM_TRUE
|
|
347
|
-
: api_constants.global_constants.SCORM_FALSE;
|
|
348
|
-
this.apiLog(callbackName, " Result: " + returnValue, enums.LogLevelEnum.DEBUG, "HttpRequest");
|
|
349
|
-
if (checkTerminated)
|
|
350
|
-
this.lastErrorCode = "0";
|
|
351
|
-
this.processListeners(callbackName);
|
|
352
|
-
_a.label = 2;
|
|
353
|
-
case 2:
|
|
354
|
-
this.apiLog(callbackName, "returned: " + returnValue, enums.LogLevelEnum.INFO);
|
|
355
|
-
this.clearSCORMError(returnValue);
|
|
356
|
-
return [2, returnValue];
|
|
357
|
-
}
|
|
358
|
-
});
|
|
359
|
-
});
|
|
360
|
-
};
|
|
361
|
-
BaseAPI.prototype.getLastError = function (callbackName) {
|
|
362
|
-
var returnValue = String(this.lastErrorCode);
|
|
363
|
-
this.processListeners(callbackName);
|
|
364
|
-
this.apiLog(callbackName, "returned: " + returnValue, enums.LogLevelEnum.INFO);
|
|
365
|
-
return returnValue;
|
|
366
|
-
};
|
|
367
|
-
BaseAPI.prototype.getErrorString = function (callbackName, CMIErrorCode) {
|
|
368
|
-
var returnValue = "";
|
|
369
|
-
if (CMIErrorCode !== null && CMIErrorCode !== "") {
|
|
370
|
-
returnValue = this.getLmsErrorMessageDetails(CMIErrorCode);
|
|
371
|
-
this.processListeners(callbackName);
|
|
372
|
-
}
|
|
373
|
-
this.apiLog(callbackName, "returned: " + returnValue, enums.LogLevelEnum.INFO);
|
|
374
|
-
return returnValue;
|
|
375
|
-
};
|
|
376
|
-
BaseAPI.prototype.getDiagnostic = function (callbackName, CMIErrorCode) {
|
|
377
|
-
var returnValue = "";
|
|
378
|
-
if (CMIErrorCode !== null && CMIErrorCode !== "") {
|
|
379
|
-
returnValue = this.getLmsErrorMessageDetails(CMIErrorCode, true);
|
|
380
|
-
this.processListeners(callbackName);
|
|
381
|
-
}
|
|
382
|
-
this.apiLog(callbackName, "returned: " + returnValue, enums.LogLevelEnum.INFO);
|
|
383
|
-
return returnValue;
|
|
384
|
-
};
|
|
385
|
-
BaseAPI.prototype.checkState = function (checkTerminated, beforeInitError, afterTermError) {
|
|
386
|
-
if (this.isNotInitialized()) {
|
|
387
|
-
this.throwSCORMError(beforeInitError);
|
|
388
|
-
return false;
|
|
389
|
-
}
|
|
390
|
-
else if (checkTerminated && this.isTerminated()) {
|
|
391
|
-
this.throwSCORMError(afterTermError);
|
|
392
|
-
return false;
|
|
393
|
-
}
|
|
394
|
-
return true;
|
|
395
|
-
};
|
|
396
|
-
BaseAPI.prototype.getLmsErrorMessageDetails = function (_errorNumber, _detail) {
|
|
397
|
-
if (_detail === void 0) { _detail = false; }
|
|
398
|
-
throw new Error("The getLmsErrorMessageDetails method has not been implemented");
|
|
399
|
-
};
|
|
400
|
-
BaseAPI.prototype.getCMIValue = function (_CMIElement) {
|
|
401
|
-
throw new Error("The getCMIValue method has not been implemented");
|
|
402
|
-
};
|
|
403
|
-
BaseAPI.prototype.setCMIValue = function (_CMIElement, _value) {
|
|
404
|
-
throw new Error("The setCMIValue method has not been implemented");
|
|
405
|
-
};
|
|
406
|
-
BaseAPI.prototype._commonSetCMIValue = function (methodName, scorm2004, CMIElement, value) {
|
|
407
|
-
if (!CMIElement || CMIElement === "") {
|
|
408
|
-
return api_constants.global_constants.SCORM_FALSE;
|
|
409
|
-
}
|
|
410
|
-
var structure = CMIElement.split(".");
|
|
411
|
-
var refObject = this;
|
|
412
|
-
var returnValue = api_constants.global_constants.SCORM_FALSE;
|
|
413
|
-
var foundFirstIndex = false;
|
|
414
|
-
var invalidErrorMessage = "The data model element passed to ".concat(methodName, " (").concat(CMIElement, ") is not a valid SCORM data model element.");
|
|
415
|
-
var invalidErrorCode = scorm2004
|
|
416
|
-
? this._error_codes.UNDEFINED_DATA_MODEL
|
|
417
|
-
: this._error_codes.GENERAL;
|
|
418
|
-
for (var idx = 0; idx < structure.length; idx++) {
|
|
419
|
-
var attribute = structure[idx];
|
|
420
|
-
if (!attribute) {
|
|
421
|
-
this.throwSCORMError(invalidErrorCode, invalidErrorMessage);
|
|
422
|
-
return api_constants.global_constants.SCORM_FALSE;
|
|
423
|
-
}
|
|
424
|
-
if (idx === structure.length - 1) {
|
|
425
|
-
if (scorm2004 && attribute.substring(0, 8) === "{target=") {
|
|
426
|
-
if (this.isInitialized()) {
|
|
427
|
-
this.throwSCORMError(this._error_codes.READ_ONLY_ELEMENT);
|
|
428
|
-
}
|
|
429
|
-
else {
|
|
430
|
-
refObject = (0,tslib_es6.__assign)((0,tslib_es6.__assign)({}, refObject), { attribute: value });
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
else if (!this._checkObjectHasProperty(refObject, attribute)) {
|
|
434
|
-
this.throwSCORMError(invalidErrorCode, invalidErrorMessage);
|
|
435
|
-
}
|
|
436
|
-
else {
|
|
437
|
-
if ((0,utilities.stringMatches)(CMIElement, "\\.correct_responses\\.\\d+") &&
|
|
438
|
-
this.isInitialized()) {
|
|
439
|
-
this.validateCorrectResponse(CMIElement, value);
|
|
440
|
-
}
|
|
441
|
-
if (!scorm2004 || this.lastErrorCode === "0") {
|
|
442
|
-
refObject[attribute] = value;
|
|
443
|
-
returnValue = api_constants.global_constants.SCORM_TRUE;
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
else {
|
|
448
|
-
refObject = refObject[attribute];
|
|
449
|
-
if (!refObject) {
|
|
450
|
-
this.throwSCORMError(invalidErrorCode, invalidErrorMessage);
|
|
451
|
-
break;
|
|
452
|
-
}
|
|
453
|
-
if (refObject instanceof array.CMIArray) {
|
|
454
|
-
var index = parseInt(structure[idx + 1] || "0", 10);
|
|
455
|
-
if (!isNaN(index)) {
|
|
456
|
-
var item = refObject.childArray[index];
|
|
457
|
-
if (item) {
|
|
458
|
-
refObject = item;
|
|
459
|
-
foundFirstIndex = true;
|
|
460
|
-
}
|
|
461
|
-
else {
|
|
462
|
-
var newChild = this.getChildElement(CMIElement, value, foundFirstIndex);
|
|
463
|
-
foundFirstIndex = true;
|
|
464
|
-
if (!newChild) {
|
|
465
|
-
this.throwSCORMError(invalidErrorCode, invalidErrorMessage);
|
|
466
|
-
}
|
|
467
|
-
else {
|
|
468
|
-
if (refObject.initialized)
|
|
469
|
-
newChild.initialize();
|
|
470
|
-
refObject.childArray.push(newChild);
|
|
471
|
-
refObject = newChild;
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
idx++;
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
if (returnValue === api_constants.global_constants.SCORM_FALSE) {
|
|
480
|
-
this.apiLog(methodName, "There was an error setting the value for: ".concat(CMIElement, ", value of: ").concat(value), enums.LogLevelEnum.WARN);
|
|
481
|
-
}
|
|
482
|
-
return returnValue;
|
|
483
|
-
};
|
|
484
|
-
BaseAPI.prototype._commonGetCMIValue = function (methodName, scorm2004, CMIElement) {
|
|
485
|
-
if (!CMIElement || CMIElement === "") {
|
|
486
|
-
return "";
|
|
487
|
-
}
|
|
488
|
-
var structure = CMIElement.split(".");
|
|
489
|
-
var refObject = this;
|
|
490
|
-
var attribute = null;
|
|
491
|
-
var uninitializedErrorMessage = "The data model element passed to ".concat(methodName, " (").concat(CMIElement, ") has not been initialized.");
|
|
492
|
-
var invalidErrorMessage = "The data model element passed to ".concat(methodName, " (").concat(CMIElement, ") is not a valid SCORM data model element.");
|
|
493
|
-
var invalidErrorCode = scorm2004
|
|
494
|
-
? this._error_codes.UNDEFINED_DATA_MODEL
|
|
495
|
-
: this._error_codes.GENERAL;
|
|
496
|
-
for (var idx = 0; idx < structure.length; idx++) {
|
|
497
|
-
attribute = structure[idx];
|
|
498
|
-
if (!attribute) {
|
|
499
|
-
this.throwSCORMError(invalidErrorCode, invalidErrorMessage);
|
|
500
|
-
return;
|
|
501
|
-
}
|
|
502
|
-
if (!scorm2004) {
|
|
503
|
-
if (idx === structure.length - 1) {
|
|
504
|
-
if (!this._checkObjectHasProperty(refObject, attribute)) {
|
|
505
|
-
this.throwSCORMError(invalidErrorCode, invalidErrorMessage);
|
|
506
|
-
return;
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
else {
|
|
511
|
-
if (String(attribute).substring(0, 8) === "{target=" &&
|
|
512
|
-
typeof refObject._isTargetValid == "function") {
|
|
513
|
-
var target = String(attribute).substring(8, String(attribute).length - 9);
|
|
514
|
-
return refObject._isTargetValid(target);
|
|
515
|
-
}
|
|
516
|
-
else if (!this._checkObjectHasProperty(refObject, attribute)) {
|
|
517
|
-
this.throwSCORMError(invalidErrorCode, invalidErrorMessage);
|
|
518
|
-
return;
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
refObject = refObject[attribute];
|
|
522
|
-
if (refObject === undefined) {
|
|
523
|
-
this.throwSCORMError(invalidErrorCode, invalidErrorMessage);
|
|
524
|
-
break;
|
|
525
|
-
}
|
|
526
|
-
if (refObject instanceof array.CMIArray) {
|
|
527
|
-
var index = parseInt(structure[idx + 1] || "", 10);
|
|
528
|
-
if (!isNaN(index)) {
|
|
529
|
-
var item = refObject.childArray[index];
|
|
530
|
-
if (item) {
|
|
531
|
-
refObject = item;
|
|
532
|
-
}
|
|
533
|
-
else {
|
|
534
|
-
this.throwSCORMError(this._error_codes.VALUE_NOT_INITIALIZED, uninitializedErrorMessage);
|
|
535
|
-
break;
|
|
536
|
-
}
|
|
537
|
-
idx++;
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
if (refObject === null || refObject === undefined) {
|
|
542
|
-
if (!scorm2004) {
|
|
543
|
-
if (attribute === "_children") {
|
|
544
|
-
this.throwSCORMError(this._error_codes.CHILDREN_ERROR);
|
|
545
|
-
}
|
|
546
|
-
else if (attribute === "_count") {
|
|
547
|
-
this.throwSCORMError(this._error_codes.COUNT_ERROR);
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
else {
|
|
552
|
-
return refObject;
|
|
553
|
-
}
|
|
554
|
-
};
|
|
555
|
-
BaseAPI.prototype.isInitialized = function () {
|
|
556
|
-
return this.currentState === api_constants.global_constants.STATE_INITIALIZED;
|
|
557
|
-
};
|
|
558
|
-
BaseAPI.prototype.isNotInitialized = function () {
|
|
559
|
-
return this.currentState === api_constants.global_constants.STATE_NOT_INITIALIZED;
|
|
560
|
-
};
|
|
561
|
-
BaseAPI.prototype.isTerminated = function () {
|
|
562
|
-
return this.currentState === api_constants.global_constants.STATE_TERMINATED;
|
|
563
|
-
};
|
|
564
|
-
BaseAPI.prototype.on = function (listenerName, callback) {
|
|
565
|
-
var _a, _c;
|
|
566
|
-
if (!callback)
|
|
567
|
-
return;
|
|
568
|
-
var listenerFunctions = listenerName.split(" ");
|
|
569
|
-
for (var i = 0; i < listenerFunctions.length; i++) {
|
|
570
|
-
var listenerSplit = (_a = listenerFunctions[i]) === null || _a === void 0 ? void 0 : _a.split(".");
|
|
571
|
-
if (!listenerSplit || listenerSplit.length === 0)
|
|
572
|
-
return;
|
|
573
|
-
var functionName = listenerSplit[0];
|
|
574
|
-
var CMIElement = null;
|
|
575
|
-
if (listenerSplit.length > 1) {
|
|
576
|
-
CMIElement = (_c = listenerFunctions[i]) === null || _c === void 0 ? void 0 : _c.replace(functionName + ".", "");
|
|
577
|
-
}
|
|
578
|
-
this.listenerArray.push({
|
|
579
|
-
functionName: functionName,
|
|
580
|
-
CMIElement: CMIElement,
|
|
581
|
-
callback: callback
|
|
582
|
-
});
|
|
583
|
-
this.apiLog("on", "Added event listener: ".concat(this.listenerArray.length), enums.LogLevelEnum.INFO, functionName);
|
|
584
|
-
}
|
|
585
|
-
};
|
|
586
|
-
BaseAPI.prototype.off = function (listenerName, callback) {
|
|
587
|
-
var _a, _c;
|
|
588
|
-
if (!callback)
|
|
589
|
-
return;
|
|
590
|
-
var listenerFunctions = listenerName.split(" ");
|
|
591
|
-
var _loop_1 = function (i) {
|
|
592
|
-
var listenerSplit = (_a = listenerFunctions[i]) === null || _a === void 0 ? void 0 : _a.split(".");
|
|
593
|
-
if (!listenerSplit || listenerSplit.length === 0)
|
|
594
|
-
return { value: void 0 };
|
|
595
|
-
var functionName = listenerSplit[0];
|
|
596
|
-
var CMIElement = null;
|
|
597
|
-
if (listenerSplit.length > 1) {
|
|
598
|
-
CMIElement = (_c = listenerFunctions[i]) === null || _c === void 0 ? void 0 : _c.replace(functionName + ".", "");
|
|
599
|
-
}
|
|
600
|
-
var removeIndex = this_1.listenerArray.findIndex(function (obj) {
|
|
601
|
-
return obj.functionName === functionName &&
|
|
602
|
-
obj.CMIElement === CMIElement &&
|
|
603
|
-
obj.callback === callback;
|
|
604
|
-
});
|
|
605
|
-
if (removeIndex !== -1) {
|
|
606
|
-
this_1.listenerArray.splice(removeIndex, 1);
|
|
607
|
-
this_1.apiLog("off", "Removed event listener: ".concat(this_1.listenerArray.length), enums.LogLevelEnum.INFO, functionName);
|
|
608
|
-
}
|
|
609
|
-
};
|
|
610
|
-
var this_1 = this;
|
|
611
|
-
for (var i = 0; i < listenerFunctions.length; i++) {
|
|
612
|
-
var state_1 = _loop_1(i);
|
|
613
|
-
if (typeof state_1 === "object")
|
|
614
|
-
return state_1.value;
|
|
615
|
-
}
|
|
616
|
-
};
|
|
617
|
-
BaseAPI.prototype.clear = function (listenerName) {
|
|
618
|
-
var _a, _c;
|
|
619
|
-
var listenerFunctions = listenerName.split(" ");
|
|
620
|
-
var _loop_2 = function (i) {
|
|
621
|
-
var listenerSplit = (_a = listenerFunctions[i]) === null || _a === void 0 ? void 0 : _a.split(".");
|
|
622
|
-
if (!listenerSplit || (listenerSplit === null || listenerSplit === void 0 ? void 0 : listenerSplit.length) === 0)
|
|
623
|
-
return { value: void 0 };
|
|
624
|
-
var functionName = listenerSplit[0];
|
|
625
|
-
var CMIElement = null;
|
|
626
|
-
if (listenerSplit.length > 1) {
|
|
627
|
-
CMIElement = (_c = listenerFunctions[i]) === null || _c === void 0 ? void 0 : _c.replace(functionName + ".", "");
|
|
628
|
-
}
|
|
629
|
-
this_2.listenerArray = this_2.listenerArray.filter(function (obj) {
|
|
630
|
-
return obj.functionName !== functionName && obj.CMIElement !== CMIElement;
|
|
631
|
-
});
|
|
632
|
-
};
|
|
633
|
-
var this_2 = this;
|
|
634
|
-
for (var i = 0; i < listenerFunctions.length; i++) {
|
|
635
|
-
var state_2 = _loop_2(i);
|
|
636
|
-
if (typeof state_2 === "object")
|
|
637
|
-
return state_2.value;
|
|
638
|
-
}
|
|
639
|
-
};
|
|
640
|
-
BaseAPI.prototype.processListeners = function (functionName, CMIElement, value) {
|
|
641
|
-
this.apiLog(functionName, value, enums.LogLevelEnum.INFO, CMIElement);
|
|
642
|
-
for (var i = 0; i < this.listenerArray.length; i++) {
|
|
643
|
-
var listener = this.listenerArray[i];
|
|
644
|
-
var functionsMatch = listener.functionName === functionName;
|
|
645
|
-
var listenerHasCMIElement = !!listener.CMIElement;
|
|
646
|
-
var CMIElementsMatch = false;
|
|
647
|
-
if (CMIElement &&
|
|
648
|
-
listener.CMIElement &&
|
|
649
|
-
listener.CMIElement.substring(listener.CMIElement.length - 1) === "*") {
|
|
650
|
-
CMIElementsMatch =
|
|
651
|
-
CMIElement.indexOf(listener.CMIElement.substring(0, listener.CMIElement.length - 1)) === 0;
|
|
652
|
-
}
|
|
653
|
-
else {
|
|
654
|
-
CMIElementsMatch = listener.CMIElement === CMIElement;
|
|
655
|
-
}
|
|
656
|
-
if (functionsMatch && (!listenerHasCMIElement || CMIElementsMatch)) {
|
|
657
|
-
this.apiLog("processListeners", "Processing listener: ".concat(listener.functionName), enums.LogLevelEnum.INFO, CMIElement);
|
|
658
|
-
listener.callback(CMIElement, value);
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
};
|
|
662
|
-
BaseAPI.prototype.throwSCORMError = function (errorNumber, message) {
|
|
663
|
-
if (!message) {
|
|
664
|
-
message = this.getLmsErrorMessageDetails(errorNumber);
|
|
665
|
-
}
|
|
666
|
-
this.apiLog("throwSCORMError", errorNumber + ": " + message, enums.LogLevelEnum.ERROR);
|
|
667
|
-
this.lastErrorCode = String(errorNumber);
|
|
668
|
-
};
|
|
669
|
-
BaseAPI.prototype.clearSCORMError = function (success) {
|
|
670
|
-
if (success !== undefined && success !== api_constants.global_constants.SCORM_FALSE) {
|
|
671
|
-
this.lastErrorCode = "0";
|
|
672
|
-
}
|
|
673
|
-
};
|
|
674
|
-
BaseAPI.prototype.loadFromFlattenedJSON = function (json, CMIElement) {
|
|
675
|
-
var _this = this;
|
|
676
|
-
if (!CMIElement) {
|
|
677
|
-
CMIElement = "";
|
|
678
|
-
}
|
|
679
|
-
if (!this.isNotInitialized()) {
|
|
680
|
-
console.error("loadFromFlattenedJSON can only be called before the call to lmsInitialize.");
|
|
681
|
-
return;
|
|
682
|
-
}
|
|
683
|
-
function testPattern(a, c, a_pattern) {
|
|
684
|
-
var a_match = a.match(a_pattern);
|
|
685
|
-
var c_match;
|
|
686
|
-
if (a_match !== null && (c_match = c.match(a_pattern)) !== null) {
|
|
687
|
-
var a_num = Number(a_match[2]);
|
|
688
|
-
var c_num = Number(c_match[2]);
|
|
689
|
-
if (a_num === c_num) {
|
|
690
|
-
if (a_match[3] === "id") {
|
|
691
|
-
return -1;
|
|
692
|
-
}
|
|
693
|
-
else if (a_match[3] === "type") {
|
|
694
|
-
if (c_match[3] === "id") {
|
|
695
|
-
return 1;
|
|
696
|
-
}
|
|
697
|
-
else {
|
|
698
|
-
return -1;
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
else {
|
|
702
|
-
return 1;
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
return a_num - c_num;
|
|
706
|
-
}
|
|
707
|
-
return null;
|
|
708
|
-
}
|
|
709
|
-
var int_pattern = /^(cmi\.interactions\.)(\d+)\.(.*)$/;
|
|
710
|
-
var obj_pattern = /^(cmi\.objectives\.)(\d+)\.(.*)$/;
|
|
711
|
-
var result = Object.keys(json).map(function (key) {
|
|
712
|
-
return [String(key), json[key]];
|
|
713
|
-
});
|
|
714
|
-
result.sort(function (_a, _c) {
|
|
715
|
-
var a = _a[0], _b = _a[1];
|
|
716
|
-
var c = _c[0], _d = _c[1];
|
|
717
|
-
var test;
|
|
718
|
-
if ((test = testPattern(a, c, int_pattern)) !== null) {
|
|
719
|
-
return test;
|
|
720
|
-
}
|
|
721
|
-
if ((test = testPattern(a, c, obj_pattern)) !== null) {
|
|
722
|
-
return test;
|
|
723
|
-
}
|
|
724
|
-
if (a < c) {
|
|
725
|
-
return -1;
|
|
726
|
-
}
|
|
727
|
-
if (a > c) {
|
|
728
|
-
return 1;
|
|
729
|
-
}
|
|
730
|
-
return 0;
|
|
731
|
-
});
|
|
732
|
-
var obj;
|
|
733
|
-
result.forEach(function (element) {
|
|
734
|
-
obj = {};
|
|
735
|
-
obj[element[0]] = element[1];
|
|
736
|
-
_this.loadFromJSON((0,utilities.unflatten)(obj), CMIElement);
|
|
737
|
-
});
|
|
738
|
-
};
|
|
739
|
-
BaseAPI.prototype.loadFromJSON = function (json, CMIElement) {
|
|
740
|
-
if (CMIElement === void 0) { CMIElement = ""; }
|
|
741
|
-
if ((!CMIElement || CMIElement === "") &&
|
|
742
|
-
!Object.hasOwnProperty.call(json, "cmi") &&
|
|
743
|
-
!Object.hasOwnProperty.call(json, "adl")) {
|
|
744
|
-
CMIElement = "cmi";
|
|
745
|
-
}
|
|
746
|
-
if (!this.isNotInitialized()) {
|
|
747
|
-
console.error("loadFromJSON can only be called before the call to lmsInitialize.");
|
|
748
|
-
return;
|
|
749
|
-
}
|
|
750
|
-
CMIElement = CMIElement !== undefined ? CMIElement : "cmi";
|
|
751
|
-
this.startingData = json;
|
|
752
|
-
for (var key in json) {
|
|
753
|
-
if ({}.hasOwnProperty.call(json, key) && json[key]) {
|
|
754
|
-
var currentCMIElement = (CMIElement ? CMIElement + "." : "") + key;
|
|
755
|
-
var value = json[key];
|
|
756
|
-
if (value["childArray"]) {
|
|
757
|
-
for (var i = 0; i < value["childArray"].length; i++) {
|
|
758
|
-
this.loadFromJSON(value["childArray"][i], currentCMIElement + "." + i);
|
|
759
|
-
}
|
|
760
|
-
}
|
|
761
|
-
else if (value.constructor === Object) {
|
|
762
|
-
this.loadFromJSON(value, currentCMIElement);
|
|
763
|
-
}
|
|
764
|
-
else {
|
|
765
|
-
this.setCMIValue(currentCMIElement, value);
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
};
|
|
770
|
-
BaseAPI.prototype.renderCMIToJSONString = function () {
|
|
771
|
-
var cmi = this.cmi;
|
|
772
|
-
if (this.settings.sendFullCommit) {
|
|
773
|
-
return JSON.stringify({ cmi: cmi });
|
|
774
|
-
}
|
|
775
|
-
return JSON.stringify({ cmi: cmi }, function (k, v) { return (v === undefined ? null : v); }, 2);
|
|
776
|
-
};
|
|
777
|
-
BaseAPI.prototype.renderCMIToJSONObject = function () {
|
|
778
|
-
return JSON.parse(this.renderCMIToJSONString());
|
|
779
|
-
};
|
|
780
|
-
BaseAPI.prototype.processHttpRequest = function (url_1, params_1) {
|
|
781
|
-
return (0,tslib_es6.__awaiter)(this, arguments, void 0, function (url, params, immediate) {
|
|
782
|
-
var api, genericError, process;
|
|
783
|
-
var _this = this;
|
|
784
|
-
if (immediate === void 0) { immediate = false; }
|
|
785
|
-
return (0,tslib_es6.__generator)(this, function (_a) {
|
|
786
|
-
switch (_a.label) {
|
|
787
|
-
case 0:
|
|
788
|
-
api = this;
|
|
789
|
-
genericError = {
|
|
790
|
-
result: api_constants.global_constants.SCORM_FALSE,
|
|
791
|
-
errorCode: this.error_codes.GENERAL
|
|
792
|
-
};
|
|
793
|
-
if (immediate) {
|
|
794
|
-
params = this.settings.requestHandler(params);
|
|
795
|
-
this.performFetch(url, params).then(function (response) { return (0,tslib_es6.__awaiter)(_this, void 0, void 0, function () {
|
|
796
|
-
return (0,tslib_es6.__generator)(this, function (_a) {
|
|
797
|
-
switch (_a.label) {
|
|
798
|
-
case 0: return [4, this.transformResponse(response)];
|
|
799
|
-
case 1:
|
|
800
|
-
_a.sent();
|
|
801
|
-
return [2];
|
|
802
|
-
}
|
|
803
|
-
});
|
|
804
|
-
}); });
|
|
805
|
-
return [2, {
|
|
806
|
-
result: api_constants.global_constants.SCORM_TRUE,
|
|
807
|
-
errorCode: 0
|
|
808
|
-
}];
|
|
809
|
-
}
|
|
810
|
-
process = function (url, params, settings) { return (0,tslib_es6.__awaiter)(_this, void 0, void 0, function () {
|
|
811
|
-
var response, e_1, message;
|
|
812
|
-
return (0,tslib_es6.__generator)(this, function (_a) {
|
|
813
|
-
switch (_a.label) {
|
|
814
|
-
case 0:
|
|
815
|
-
_a.trys.push([0, 2, , 3]);
|
|
816
|
-
params = settings.requestHandler(params);
|
|
817
|
-
return [4, this.performFetch(url, params)];
|
|
818
|
-
case 1:
|
|
819
|
-
response = _a.sent();
|
|
820
|
-
return [2, this.transformResponse(response)];
|
|
821
|
-
case 2:
|
|
822
|
-
e_1 = _a.sent();
|
|
823
|
-
message = e_1 instanceof Error ? e_1.message : String(e_1);
|
|
824
|
-
this.apiLog("processHttpRequest", message, enums.LogLevelEnum.ERROR);
|
|
825
|
-
api.processListeners("CommitError");
|
|
826
|
-
return [2, genericError];
|
|
827
|
-
case 3: return [2];
|
|
828
|
-
}
|
|
829
|
-
});
|
|
830
|
-
}); };
|
|
831
|
-
return [4, process(url, params, this.settings)];
|
|
832
|
-
case 1: return [2, _a.sent()];
|
|
833
|
-
}
|
|
834
|
-
});
|
|
835
|
-
});
|
|
836
|
-
};
|
|
837
|
-
BaseAPI.prototype.scheduleCommit = function (when, callback) {
|
|
838
|
-
if (!this._timeout) {
|
|
839
|
-
this._timeout = new ScheduledCommit(this, when, callback);
|
|
840
|
-
this.apiLog("scheduleCommit", "scheduled", enums.LogLevelEnum.DEBUG, "");
|
|
841
|
-
}
|
|
842
|
-
};
|
|
843
|
-
BaseAPI.prototype.clearScheduledCommit = function () {
|
|
844
|
-
if (this._timeout) {
|
|
845
|
-
this._timeout.cancel();
|
|
846
|
-
this._timeout = undefined;
|
|
847
|
-
this.apiLog("clearScheduledCommit", "cleared", enums.LogLevelEnum.DEBUG, "");
|
|
848
|
-
}
|
|
849
|
-
};
|
|
850
|
-
BaseAPI.prototype._checkObjectHasProperty = function (refObject, attribute) {
|
|
851
|
-
return (Object.hasOwnProperty.call(refObject, attribute) ||
|
|
852
|
-
Object.getOwnPropertyDescriptor(Object.getPrototypeOf(refObject), attribute) != null ||
|
|
853
|
-
attribute in refObject);
|
|
854
|
-
};
|
|
855
|
-
BaseAPI.prototype.handleValueAccessException = function (e, returnValue) {
|
|
856
|
-
if (e instanceof exceptions.ValidationError) {
|
|
857
|
-
this.lastErrorCode = String(e.errorCode);
|
|
858
|
-
returnValue = api_constants.global_constants.SCORM_FALSE;
|
|
859
|
-
}
|
|
860
|
-
else {
|
|
861
|
-
if (e instanceof Error && e.message) {
|
|
862
|
-
console.error(e.message);
|
|
863
|
-
}
|
|
864
|
-
else {
|
|
865
|
-
console.error(e);
|
|
866
|
-
}
|
|
867
|
-
this.throwSCORMError(this._error_codes.GENERAL);
|
|
868
|
-
}
|
|
869
|
-
return returnValue;
|
|
870
|
-
};
|
|
871
|
-
BaseAPI.prototype.getCommitObject = function (terminateCommit) {
|
|
872
|
-
var shouldTerminateCommit = terminateCommit || this.settings.alwaysSendTotalTime;
|
|
873
|
-
var commitObject = this.settings.renderCommonCommitFields
|
|
874
|
-
? this.renderCommitObject(shouldTerminateCommit)
|
|
875
|
-
: this.renderCommitCMI(shouldTerminateCommit);
|
|
876
|
-
if ([enums.LogLevelEnum.DEBUG, "1", 1, "DEBUG"].includes(this.apiLogLevel)) {
|
|
877
|
-
console.debug("Commit (terminated: " + (terminateCommit ? "yes" : "no") + "): ");
|
|
878
|
-
console.debug(commitObject);
|
|
879
|
-
}
|
|
880
|
-
return commitObject;
|
|
881
|
-
};
|
|
882
|
-
BaseAPI.prototype.performFetch = function (url, params) {
|
|
883
|
-
return (0,tslib_es6.__awaiter)(this, void 0, void 0, function () {
|
|
884
|
-
var init;
|
|
885
|
-
return (0,tslib_es6.__generator)(this, function (_a) {
|
|
886
|
-
init = {
|
|
887
|
-
method: "POST",
|
|
888
|
-
mode: this.settings.fetchMode,
|
|
889
|
-
body: params instanceof Array ? params.join("&") : JSON.stringify(params),
|
|
890
|
-
headers: (0,tslib_es6.__assign)((0,tslib_es6.__assign)({}, this.settings.xhrHeaders), { "Content-Type": this.settings.commitRequestDataType }),
|
|
891
|
-
keepalive: true
|
|
892
|
-
};
|
|
893
|
-
if (this.settings.xhrWithCredentials) {
|
|
894
|
-
init = (0,tslib_es6.__assign)((0,tslib_es6.__assign)({}, init), { credentials: "include" });
|
|
895
|
-
}
|
|
896
|
-
return [2, fetch(url, init)];
|
|
897
|
-
});
|
|
898
|
-
});
|
|
899
|
-
};
|
|
900
|
-
BaseAPI.prototype.transformResponse = function (response) {
|
|
901
|
-
return (0,tslib_es6.__awaiter)(this, void 0, void 0, function () {
|
|
902
|
-
var result, _a;
|
|
903
|
-
return (0,tslib_es6.__generator)(this, function (_c) {
|
|
904
|
-
switch (_c.label) {
|
|
905
|
-
case 0:
|
|
906
|
-
if (!(typeof this.settings.responseHandler === "function")) return [3, 2];
|
|
907
|
-
return [4, this.settings.responseHandler(response)];
|
|
908
|
-
case 1:
|
|
909
|
-
_a = _c.sent();
|
|
910
|
-
return [3, 4];
|
|
911
|
-
case 2: return [4, response.json()];
|
|
912
|
-
case 3:
|
|
913
|
-
_a = _c.sent();
|
|
914
|
-
_c.label = 4;
|
|
915
|
-
case 4:
|
|
916
|
-
result = _a;
|
|
917
|
-
if (response.status >= 200 &&
|
|
918
|
-
response.status <= 299 &&
|
|
919
|
-
(result.result === true || result.result === api_constants.global_constants.SCORM_TRUE)) {
|
|
920
|
-
this.processListeners("CommitSuccess");
|
|
921
|
-
}
|
|
922
|
-
else {
|
|
923
|
-
this.processListeners("CommitError");
|
|
924
|
-
}
|
|
925
|
-
return [2, result];
|
|
926
|
-
}
|
|
927
|
-
});
|
|
928
|
-
});
|
|
929
|
-
};
|
|
930
|
-
return BaseAPI;
|
|
931
|
-
}());
|
|
932
|
-
/* harmony default export */ var src_BaseAPI = (BaseAPI);
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
/***/ }),
|
|
936
|
-
|
|
937
|
-
/***/ 589:
|
|
938
|
-
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
939
|
-
|
|
940
|
-
__webpack_require__.r(__webpack_exports__);
|
|
941
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
942
|
-
/* harmony export */ CMIArray: function() { return /* binding */ CMIArray; }
|
|
943
|
-
/* harmony export */ });
|
|
944
|
-
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(635);
|
|
945
|
-
/* harmony import */ var _base_cmi__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(319);
|
|
946
|
-
/* harmony import */ var _exceptions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(784);
|
|
947
|
-
/* harmony import */ var _constants_error_codes__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(797);
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
var CMIArray = (function (_super) {
|
|
953
|
-
(0,tslib__WEBPACK_IMPORTED_MODULE_0__.__extends)(CMIArray, _super);
|
|
954
|
-
function CMIArray(params) {
|
|
955
|
-
var _this = _super.call(this) || this;
|
|
956
|
-
_this.__children = params.children;
|
|
957
|
-
_this._errorCode = params.errorCode || _constants_error_codes__WEBPACK_IMPORTED_MODULE_1__.scorm12_errors.GENERAL;
|
|
958
|
-
_this._errorClass = params.errorClass || _exceptions__WEBPACK_IMPORTED_MODULE_2__.BaseScormValidationError;
|
|
959
|
-
_this.childArray = [];
|
|
960
|
-
return _this;
|
|
961
|
-
}
|
|
962
|
-
CMIArray.prototype.reset = function (wipe) {
|
|
963
|
-
if (wipe === void 0) { wipe = false; }
|
|
964
|
-
this._initialized = false;
|
|
965
|
-
if (wipe) {
|
|
966
|
-
this.childArray = [];
|
|
967
|
-
}
|
|
968
|
-
else {
|
|
969
|
-
for (var i = 0; i < this.childArray.length; i++) {
|
|
970
|
-
this.childArray[i].reset();
|
|
971
|
-
}
|
|
972
|
-
}
|
|
973
|
-
};
|
|
974
|
-
Object.defineProperty(CMIArray.prototype, "_children", {
|
|
975
|
-
get: function () {
|
|
976
|
-
return this.__children;
|
|
977
|
-
},
|
|
978
|
-
set: function (_children) {
|
|
979
|
-
throw new this._errorClass(this._errorCode);
|
|
980
|
-
},
|
|
981
|
-
enumerable: false,
|
|
982
|
-
configurable: true
|
|
983
|
-
});
|
|
984
|
-
Object.defineProperty(CMIArray.prototype, "_count", {
|
|
985
|
-
get: function () {
|
|
986
|
-
return this.childArray.length;
|
|
987
|
-
},
|
|
988
|
-
set: function (_count) {
|
|
989
|
-
throw new this._errorClass(this._errorCode);
|
|
990
|
-
},
|
|
991
|
-
enumerable: false,
|
|
992
|
-
configurable: true
|
|
993
|
-
});
|
|
994
|
-
CMIArray.prototype.toJSON = function () {
|
|
995
|
-
this.jsonString = true;
|
|
996
|
-
var result = {};
|
|
997
|
-
for (var i = 0; i < this.childArray.length; i++) {
|
|
998
|
-
result[i + ""] = this.childArray[i];
|
|
999
|
-
}
|
|
1000
|
-
delete this.jsonString;
|
|
1001
|
-
return result;
|
|
1002
|
-
};
|
|
1003
|
-
return CMIArray;
|
|
1004
|
-
}(_base_cmi__WEBPACK_IMPORTED_MODULE_3__.BaseCMI));
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
/***/ }),
|
|
1009
|
-
|
|
1010
|
-
/***/ 319:
|
|
1011
|
-
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
1012
|
-
|
|
1013
|
-
__webpack_require__.r(__webpack_exports__);
|
|
1014
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1015
|
-
/* harmony export */ BaseCMI: function() { return /* binding */ BaseCMI; },
|
|
1016
|
-
/* harmony export */ BaseRootCMI: function() { return /* binding */ BaseRootCMI; }
|
|
1017
|
-
/* harmony export */ });
|
|
1018
|
-
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(635);
|
|
1019
|
-
|
|
1020
|
-
var BaseCMI = (function () {
|
|
1021
|
-
function BaseCMI() {
|
|
1022
|
-
this.jsonString = false;
|
|
1023
|
-
this._initialized = false;
|
|
1024
|
-
}
|
|
1025
|
-
Object.defineProperty(BaseCMI.prototype, "initialized", {
|
|
1026
|
-
get: function () {
|
|
1027
|
-
return this._initialized;
|
|
1028
|
-
},
|
|
1029
|
-
enumerable: false,
|
|
1030
|
-
configurable: true
|
|
1031
|
-
});
|
|
1032
|
-
Object.defineProperty(BaseCMI.prototype, "start_time", {
|
|
1033
|
-
get: function () {
|
|
1034
|
-
return this._start_time;
|
|
1035
|
-
},
|
|
1036
|
-
enumerable: false,
|
|
1037
|
-
configurable: true
|
|
1038
|
-
});
|
|
1039
|
-
BaseCMI.prototype.initialize = function () {
|
|
1040
|
-
this._initialized = true;
|
|
1041
|
-
};
|
|
1042
|
-
BaseCMI.prototype.setStartTime = function () {
|
|
1043
|
-
this._start_time = new Date().getTime();
|
|
1044
|
-
};
|
|
1045
|
-
return BaseCMI;
|
|
1046
|
-
}());
|
|
1047
|
-
|
|
1048
|
-
var BaseRootCMI = (function (_super) {
|
|
1049
|
-
(0,tslib__WEBPACK_IMPORTED_MODULE_0__.__extends)(BaseRootCMI, _super);
|
|
1050
|
-
function BaseRootCMI() {
|
|
1051
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
1052
|
-
}
|
|
1053
|
-
return BaseRootCMI;
|
|
1054
|
-
}(BaseCMI));
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
/***/ }),
|
|
1059
|
-
|
|
1060
|
-
/***/ 434:
|
|
1061
|
-
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
1062
|
-
|
|
1063
|
-
__webpack_require__.r(__webpack_exports__);
|
|
1064
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1065
|
-
/* harmony export */ CMIScore: function() { return /* binding */ CMIScore; }
|
|
1066
|
-
/* harmony export */ });
|
|
1067
|
-
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(635);
|
|
1068
|
-
/* harmony import */ var _constants_api_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(340);
|
|
1069
|
-
/* harmony import */ var _constants_regex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(417);
|
|
1070
|
-
/* harmony import */ var _base_cmi__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(319);
|
|
1071
|
-
/* harmony import */ var _validation__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(449);
|
|
1072
|
-
/* harmony import */ var _constants_error_codes__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(797);
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
var CMIScore = (function (_super) {
|
|
1080
|
-
(0,tslib__WEBPACK_IMPORTED_MODULE_0__.__extends)(CMIScore, _super);
|
|
1081
|
-
function CMIScore(params) {
|
|
1082
|
-
var _this = _super.call(this) || this;
|
|
1083
|
-
_this._raw = "";
|
|
1084
|
-
_this._min = "";
|
|
1085
|
-
_this.__children = params.score_children || _constants_api_constants__WEBPACK_IMPORTED_MODULE_1__.scorm12_constants.score_children;
|
|
1086
|
-
_this.__score_range = !params.score_range
|
|
1087
|
-
? false
|
|
1088
|
-
: _constants_regex__WEBPACK_IMPORTED_MODULE_2__.scorm12_regex.score_range;
|
|
1089
|
-
_this._max = params.max || params.max === "" ? params.max : "100";
|
|
1090
|
-
_this.__invalid_error_code =
|
|
1091
|
-
params.invalidErrorCode || _constants_error_codes__WEBPACK_IMPORTED_MODULE_3__.scorm12_errors.INVALID_SET_VALUE;
|
|
1092
|
-
_this.__invalid_type_code =
|
|
1093
|
-
params.invalidTypeCode || _constants_error_codes__WEBPACK_IMPORTED_MODULE_3__.scorm12_errors.TYPE_MISMATCH;
|
|
1094
|
-
_this.__invalid_range_code =
|
|
1095
|
-
params.invalidRangeCode || _constants_error_codes__WEBPACK_IMPORTED_MODULE_3__.scorm12_errors.VALUE_OUT_OF_RANGE;
|
|
1096
|
-
_this.__decimal_regex = params.decimalRegex || _constants_regex__WEBPACK_IMPORTED_MODULE_2__.scorm12_regex.CMIDecimal;
|
|
1097
|
-
_this.__error_class = params.errorClass;
|
|
1098
|
-
return _this;
|
|
1099
|
-
}
|
|
1100
|
-
CMIScore.prototype.reset = function () {
|
|
1101
|
-
this._initialized = false;
|
|
1102
|
-
};
|
|
1103
|
-
Object.defineProperty(CMIScore.prototype, "_children", {
|
|
1104
|
-
get: function () {
|
|
1105
|
-
return this.__children;
|
|
1106
|
-
},
|
|
1107
|
-
set: function (_children) {
|
|
1108
|
-
throw new this.__error_class(this.__invalid_error_code);
|
|
1109
|
-
},
|
|
1110
|
-
enumerable: false,
|
|
1111
|
-
configurable: true
|
|
1112
|
-
});
|
|
1113
|
-
Object.defineProperty(CMIScore.prototype, "raw", {
|
|
1114
|
-
get: function () {
|
|
1115
|
-
return this._raw;
|
|
1116
|
-
},
|
|
1117
|
-
set: function (raw) {
|
|
1118
|
-
if ((0,_validation__WEBPACK_IMPORTED_MODULE_4__.checkValidFormat)(raw, this.__decimal_regex, this.__invalid_type_code, this.__error_class) &&
|
|
1119
|
-
(!this.__score_range ||
|
|
1120
|
-
(0,_validation__WEBPACK_IMPORTED_MODULE_4__.checkValidRange)(raw, this.__score_range, this.__invalid_range_code, this.__error_class))) {
|
|
1121
|
-
this._raw = raw;
|
|
1122
|
-
}
|
|
1123
|
-
},
|
|
1124
|
-
enumerable: false,
|
|
1125
|
-
configurable: true
|
|
1126
|
-
});
|
|
1127
|
-
Object.defineProperty(CMIScore.prototype, "min", {
|
|
1128
|
-
get: function () {
|
|
1129
|
-
return this._min;
|
|
1130
|
-
},
|
|
1131
|
-
set: function (min) {
|
|
1132
|
-
if ((0,_validation__WEBPACK_IMPORTED_MODULE_4__.checkValidFormat)(min, this.__decimal_regex, this.__invalid_type_code, this.__error_class) &&
|
|
1133
|
-
(!this.__score_range ||
|
|
1134
|
-
(0,_validation__WEBPACK_IMPORTED_MODULE_4__.checkValidRange)(min, this.__score_range, this.__invalid_range_code, this.__error_class))) {
|
|
1135
|
-
this._min = min;
|
|
1136
|
-
}
|
|
1137
|
-
},
|
|
1138
|
-
enumerable: false,
|
|
1139
|
-
configurable: true
|
|
1140
|
-
});
|
|
1141
|
-
Object.defineProperty(CMIScore.prototype, "max", {
|
|
1142
|
-
get: function () {
|
|
1143
|
-
return this._max;
|
|
1144
|
-
},
|
|
1145
|
-
set: function (max) {
|
|
1146
|
-
if ((0,_validation__WEBPACK_IMPORTED_MODULE_4__.checkValidFormat)(max, this.__decimal_regex, this.__invalid_type_code, this.__error_class) &&
|
|
1147
|
-
(!this.__score_range ||
|
|
1148
|
-
(0,_validation__WEBPACK_IMPORTED_MODULE_4__.checkValidRange)(max, this.__score_range, this.__invalid_range_code, this.__error_class))) {
|
|
1149
|
-
this._max = max;
|
|
1150
|
-
}
|
|
1151
|
-
},
|
|
1152
|
-
enumerable: false,
|
|
1153
|
-
configurable: true
|
|
1154
|
-
});
|
|
1155
|
-
CMIScore.prototype.toJSON = function () {
|
|
1156
|
-
this.jsonString = true;
|
|
1157
|
-
var result = {
|
|
1158
|
-
raw: this.raw,
|
|
1159
|
-
min: this.min,
|
|
1160
|
-
max: this.max,
|
|
1161
|
-
};
|
|
1162
|
-
delete this.jsonString;
|
|
1163
|
-
return result;
|
|
1164
|
-
};
|
|
1165
|
-
return CMIScore;
|
|
1166
|
-
}(_base_cmi__WEBPACK_IMPORTED_MODULE_5__.BaseCMI));
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
/***/ }),
|
|
1171
|
-
|
|
1172
|
-
/***/ 449:
|
|
1173
|
-
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
1174
|
-
|
|
1175
|
-
__webpack_require__.r(__webpack_exports__);
|
|
1176
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1177
|
-
/* harmony export */ checkValidFormat: function() { return /* binding */ checkValidFormat; },
|
|
1178
|
-
/* harmony export */ checkValidRange: function() { return /* binding */ checkValidRange; }
|
|
1179
|
-
/* harmony export */ });
|
|
1180
|
-
function checkValidFormat(value, regexPattern, errorCode, errorClass, allowEmptyString) {
|
|
1181
|
-
if (typeof value !== "string") {
|
|
1182
|
-
return false;
|
|
1183
|
-
}
|
|
1184
|
-
var formatRegex = new RegExp(regexPattern);
|
|
1185
|
-
var matches = value.match(formatRegex);
|
|
1186
|
-
if (allowEmptyString && value === "") {
|
|
1187
|
-
return true;
|
|
1188
|
-
}
|
|
1189
|
-
if (value === undefined || !matches || matches[0] === "") {
|
|
1190
|
-
throw new errorClass(errorCode);
|
|
1191
|
-
}
|
|
1192
|
-
return true;
|
|
1193
|
-
}
|
|
1194
|
-
function checkValidRange(value, rangePattern, errorCode, errorClass) {
|
|
1195
|
-
var ranges = rangePattern.split("#");
|
|
1196
|
-
value = value * 1.0;
|
|
1197
|
-
if (ranges[0] && value >= ranges[0]) {
|
|
1198
|
-
if (ranges[1] && (ranges[1] === "*" || value <= ranges[1])) {
|
|
1199
|
-
return true;
|
|
1200
|
-
}
|
|
1201
|
-
else {
|
|
1202
|
-
throw new errorClass(errorCode);
|
|
1203
|
-
}
|
|
1204
|
-
}
|
|
1205
|
-
else {
|
|
1206
|
-
throw new errorClass(errorCode);
|
|
1207
|
-
}
|
|
1208
|
-
}
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
/***/ }),
|
|
1212
|
-
|
|
1213
|
-
/***/ 340:
|
|
1214
|
-
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
1215
|
-
|
|
1216
|
-
__webpack_require__.r(__webpack_exports__);
|
|
1217
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1218
|
-
/* harmony export */ aicc_constants: function() { return /* binding */ aicc_constants; },
|
|
1219
|
-
/* harmony export */ global_constants: function() { return /* binding */ global_constants; },
|
|
1220
|
-
/* harmony export */ scorm12_constants: function() { return /* binding */ scorm12_constants; },
|
|
1221
|
-
/* harmony export */ scorm2004_constants: function() { return /* binding */ scorm2004_constants; }
|
|
1222
|
-
/* harmony export */ });
|
|
1223
|
-
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(635);
|
|
1224
|
-
|
|
1225
|
-
var global_constants = {
|
|
1226
|
-
SCORM_TRUE: "true",
|
|
1227
|
-
SCORM_FALSE: "false",
|
|
1228
|
-
STATE_NOT_INITIALIZED: 0,
|
|
1229
|
-
STATE_INITIALIZED: 1,
|
|
1230
|
-
STATE_TERMINATED: 2,
|
|
1231
|
-
};
|
|
1232
|
-
var scorm12_constants = {
|
|
1233
|
-
cmi_children: "core,suspend_data,launch_data,comments,objectives,student_data,student_preference,interactions",
|
|
1234
|
-
core_children: "student_id,student_name,lesson_location,credit,lesson_status,entry,score,total_time,lesson_mode,exit,session_time",
|
|
1235
|
-
score_children: "raw,min,max",
|
|
1236
|
-
comments_children: "content,location,time",
|
|
1237
|
-
objectives_children: "id,score,status",
|
|
1238
|
-
correct_responses_children: "pattern",
|
|
1239
|
-
student_data_children: "mastery_score,max_time_allowed,time_limit_action",
|
|
1240
|
-
student_preference_children: "audio,language,speed,text",
|
|
1241
|
-
interactions_children: "id,objectives,time,type,correct_responses,weighting,student_response,result,latency",
|
|
1242
|
-
error_descriptions: {
|
|
1243
|
-
"101": {
|
|
1244
|
-
basicMessage: "General Exception",
|
|
1245
|
-
detailMessage: "No specific error code exists to describe the error. Use LMSGetDiagnostic for more information",
|
|
1246
|
-
},
|
|
1247
|
-
"201": {
|
|
1248
|
-
basicMessage: "Invalid argument error",
|
|
1249
|
-
detailMessage: "Indicates that an argument represents an invalid data model element or is otherwise incorrect.",
|
|
1250
|
-
},
|
|
1251
|
-
"202": {
|
|
1252
|
-
basicMessage: "Element cannot have children",
|
|
1253
|
-
detailMessage: 'Indicates that LMSGetValue was called with a data model element name that ends in "_children" for a data model element that does not support the "_children" suffix.',
|
|
134
|
+
"202": {
|
|
135
|
+
basicMessage: "Element cannot have children",
|
|
136
|
+
detailMessage: 'Indicates that LMSGetValue was called with a data model element name that ends in "_children" for a data model element that does not support the "_children" suffix.',
|
|
1254
137
|
},
|
|
1255
138
|
"203": {
|
|
1256
139
|
basicMessage: "Element not an array - cannot have count",
|
|
@@ -1418,441 +301,1242 @@ var scorm2004_constants = {
|
|
|
1418
301
|
};
|
|
1419
302
|
|
|
1420
303
|
|
|
1421
|
-
/***/ }),
|
|
304
|
+
/***/ }),
|
|
305
|
+
|
|
306
|
+
/***/ 417:
|
|
307
|
+
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
308
|
+
|
|
309
|
+
__webpack_require__.r(__webpack_exports__);
|
|
310
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
311
|
+
/* harmony export */ aicc_regex: function() { return /* binding */ aicc_regex; },
|
|
312
|
+
/* harmony export */ scorm12_regex: function() { return /* binding */ scorm12_regex; },
|
|
313
|
+
/* harmony export */ scorm2004_regex: function() { return /* binding */ scorm2004_regex; }
|
|
314
|
+
/* harmony export */ });
|
|
315
|
+
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(635);
|
|
316
|
+
|
|
317
|
+
var scorm12_regex = {
|
|
318
|
+
CMIString256: "^.{0,255}$",
|
|
319
|
+
CMIString4096: "^.{0,4096}$",
|
|
320
|
+
CMITime: "^(?:[01]\\d|2[0123]):(?:[012345]\\d):(?:[012345]\\d)$",
|
|
321
|
+
CMITimespan: "^([0-9]{2,}):([0-9]{2}):([0-9]{2})(.[0-9]{1,2})?$",
|
|
322
|
+
CMIInteger: "^\\d+$",
|
|
323
|
+
CMISInteger: "^-?([0-9]+)$",
|
|
324
|
+
CMIDecimal: "^-?([0-9]{0,3})(.[0-9]*)?$",
|
|
325
|
+
CMIIdentifier: "^[\\u0021-\\u007E\\s]{0,255}$",
|
|
326
|
+
CMIFeedback: "^.*$",
|
|
327
|
+
CMIIndex: "[._](\\d+).",
|
|
328
|
+
CMIStatus: "^(passed|completed|failed|incomplete|browsed)$",
|
|
329
|
+
CMIStatus2: "^(passed|completed|failed|incomplete|browsed|not attempted)$",
|
|
330
|
+
CMIExit: "^(time-out|suspend|logout|)$",
|
|
331
|
+
CMIType: "^(true-false|choice|fill-in|matching|performance|sequencing|likert|numeric)$",
|
|
332
|
+
CMIResult: "^(correct|wrong|unanticipated|neutral|([0-9]{0,3})?(\\.[0-9]*)?)$",
|
|
333
|
+
NAVEvent: "^(previous|continue)$",
|
|
334
|
+
score_range: "0#100",
|
|
335
|
+
audio_range: "-1#100",
|
|
336
|
+
speed_range: "-100#100",
|
|
337
|
+
weighting_range: "-100#100",
|
|
338
|
+
text_range: "-1#1",
|
|
339
|
+
};
|
|
340
|
+
var aicc_regex = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({}, scorm12_regex), {
|
|
341
|
+
CMIIdentifier: "^\\w{1,255}$",
|
|
342
|
+
});
|
|
343
|
+
var scorm2004_regex = {
|
|
344
|
+
CMIString200: "^[\\u0000-\\uFFFF]{0,200}$",
|
|
345
|
+
CMIString250: "^[\\u0000-\\uFFFF]{0,250}$",
|
|
346
|
+
CMIString1000: "^[\\u0000-\\uFFFF]{0,1000}$",
|
|
347
|
+
CMIString4000: "^[\\u0000-\\uFFFF]{0,4000}$",
|
|
348
|
+
CMIString64000: "^[\\u0000-\\uFFFF]{0,64000}$",
|
|
349
|
+
CMILang: "^([a-zA-Z]{2,3}|i|x)(-[a-zA-Z0-9-]{2,8})?$|^$",
|
|
350
|
+
CMILangString250: "^({lang=([a-zA-Z]{2,3}|i|x)(-[a-zA-Z0-9-]{2,8})?})?((?!{.*$).{0,250}$)?$",
|
|
351
|
+
CMILangcr: "^(({lang=([a-zA-Z]{2,3}|i|x)?(-[a-zA-Z0-9-]{2,8})?}))(.*?)$",
|
|
352
|
+
CMILangString250cr: "^(({lang=([a-zA-Z]{2,3}|i|x)?(-[a-zA-Z0-9-]{2,8})?})?(.{0,250})?)?$",
|
|
353
|
+
CMILangString4000: "^({lang=([a-zA-Z]{2,3}|i|x)(-[a-zA-Z0-9-]{2,8})?})?((?!{.*$).{0,4000}$)?$",
|
|
354
|
+
CMITime: "^(19[7-9]{1}[0-9]{1}|20[0-2]{1}[0-9]{1}|203[0-8]{1})((-(0[1-9]{1}|1[0-2]{1}))((-(0[1-9]{1}|[1-2]{1}[0-9]{1}|3[0-1]{1}))(T([0-1]{1}[0-9]{1}|2[0-3]{1})((:[0-5]{1}[0-9]{1})((:[0-5]{1}[0-9]{1})((\\.[0-9]{1,2})((Z|([+|-]([0-1]{1}[0-9]{1}|2[0-3]{1})))(:[0-5]{1}[0-9]{1})?)?)?)?)?)?)?)?$",
|
|
355
|
+
CMITimespan: "^P(?:([.,\\d]+)Y)?(?:([.,\\d]+)M)?(?:([.,\\d]+)W)?(?:([.,\\d]+)D)?(?:T?(?:([.,\\d]+)H)?(?:([.,\\d]+)M)?(?:([.,\\d]+)S)?)?$",
|
|
356
|
+
CMIInteger: "^\\d+$",
|
|
357
|
+
CMISInteger: "^-?([0-9]+)$",
|
|
358
|
+
CMIDecimal: "^-?([0-9]{1,5})(\\.[0-9]{1,18})?$",
|
|
359
|
+
CMIIdentifier: "^\\S{1,250}[a-zA-Z0-9]$",
|
|
360
|
+
CMIShortIdentifier: "^[\\w\\.\\-\\_]{1,250}$",
|
|
361
|
+
CMILongIdentifier: "^(?:(?!urn:)\\S{1,4000}|urn:[A-Za-z0-9-]{1,31}:\\S{1,4000}|.{1,4000})$",
|
|
362
|
+
CMIFeedback: "^.*$",
|
|
363
|
+
CMIIndex: "[._](\\d+).",
|
|
364
|
+
CMIIndexStore: ".N(\\d+).",
|
|
365
|
+
CMICStatus: "^(completed|incomplete|not attempted|unknown)$",
|
|
366
|
+
CMISStatus: "^(passed|failed|unknown)$",
|
|
367
|
+
CMIExit: "^(time-out|suspend|logout|normal)$",
|
|
368
|
+
CMIType: "^(true-false|choice|fill-in|long-fill-in|matching|performance|sequencing|likert|numeric|other)$",
|
|
369
|
+
CMIResult: "^(correct|incorrect|unanticipated|neutral|-?([0-9]{1,4})(\\.[0-9]{1,18})?)$",
|
|
370
|
+
NAVEvent: "^(previous|continue|exit|exitAll|abandon|abandonAll|suspendAll|_none_|(\\{target=(?<choice_target>\\S{0,}[a-zA-Z0-9-_]+)})?choice|(\\{target=(?<jump_target>\\S{0,}[a-zA-Z0-9-_]+)})?jump)$",
|
|
371
|
+
NAVBoolean: "^(unknown|true|false$)",
|
|
372
|
+
NAVTarget: "^{target=\\S{0,}[a-zA-Z0-9-_]+}$",
|
|
373
|
+
scaled_range: "-1#1",
|
|
374
|
+
audio_range: "0#*",
|
|
375
|
+
speed_range: "0#*",
|
|
376
|
+
text_range: "-1#1",
|
|
377
|
+
progress_range: "0#1",
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
/***/ }),
|
|
382
|
+
|
|
383
|
+
/***/ 429:
|
|
384
|
+
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
385
|
+
|
|
386
|
+
// ESM COMPAT FLAG
|
|
387
|
+
__webpack_require__.r(__webpack_exports__);
|
|
388
|
+
|
|
389
|
+
// EXPORTS
|
|
390
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
391
|
+
"default": function() { return /* binding */ src_BaseAPI; }
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
// EXTERNAL MODULE: ./node_modules/tslib/tslib.es6.mjs
|
|
395
|
+
var tslib_es6 = __webpack_require__(635);
|
|
396
|
+
// EXTERNAL MODULE: ./src/cmi/common/array.ts
|
|
397
|
+
var array = __webpack_require__(589);
|
|
398
|
+
// EXTERNAL MODULE: ./src/exceptions.ts
|
|
399
|
+
var exceptions = __webpack_require__(784);
|
|
400
|
+
// EXTERNAL MODULE: ./src/constants/api_constants.ts
|
|
401
|
+
var api_constants = __webpack_require__(340);
|
|
402
|
+
// EXTERNAL MODULE: ./src/utilities.ts
|
|
403
|
+
var utilities = __webpack_require__(864);
|
|
404
|
+
// EXTERNAL MODULE: ./src/constants/enums.ts
|
|
405
|
+
var enums = __webpack_require__(56);
|
|
406
|
+
;// ./src/constants/default_settings.ts
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
var DefaultSettings = {
|
|
411
|
+
autocommit: false,
|
|
412
|
+
autocommitSeconds: 10,
|
|
413
|
+
asyncCommit: false,
|
|
414
|
+
sendFullCommit: true,
|
|
415
|
+
lmsCommitUrl: false,
|
|
416
|
+
dataCommitFormat: "json",
|
|
417
|
+
commitRequestDataType: "application/json;charset=UTF-8",
|
|
418
|
+
autoProgress: false,
|
|
419
|
+
logLevel: enums.LogLevelEnum.ERROR,
|
|
420
|
+
selfReportSessionTime: false,
|
|
421
|
+
alwaysSendTotalTime: false,
|
|
422
|
+
renderCommonCommitFields: false,
|
|
423
|
+
strict_errors: true,
|
|
424
|
+
xhrHeaders: {},
|
|
425
|
+
xhrWithCredentials: false,
|
|
426
|
+
fetchMode: "cors",
|
|
427
|
+
responseHandler: function (response) {
|
|
428
|
+
return (0,tslib_es6.__awaiter)(this, void 0, void 0, function () {
|
|
429
|
+
var responseText, httpResult;
|
|
430
|
+
return (0,tslib_es6.__generator)(this, function (_a) {
|
|
431
|
+
switch (_a.label) {
|
|
432
|
+
case 0:
|
|
433
|
+
if (!(typeof response !== "undefined")) return [3, 2];
|
|
434
|
+
return [4, response.text()];
|
|
435
|
+
case 1:
|
|
436
|
+
responseText = _a.sent();
|
|
437
|
+
httpResult = null;
|
|
438
|
+
if (responseText) {
|
|
439
|
+
httpResult = JSON.parse(responseText);
|
|
440
|
+
}
|
|
441
|
+
if (httpResult === null ||
|
|
442
|
+
!{}.hasOwnProperty.call(httpResult, "result")) {
|
|
443
|
+
if (response.status === 200) {
|
|
444
|
+
return [2, {
|
|
445
|
+
result: api_constants.global_constants.SCORM_TRUE,
|
|
446
|
+
errorCode: 0
|
|
447
|
+
}];
|
|
448
|
+
}
|
|
449
|
+
else {
|
|
450
|
+
return [2, {
|
|
451
|
+
result: api_constants.global_constants.SCORM_FALSE,
|
|
452
|
+
errorCode: 101
|
|
453
|
+
}];
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
else {
|
|
457
|
+
return [2, {
|
|
458
|
+
result: httpResult.result,
|
|
459
|
+
errorCode: typeof httpResult.errorCode === "number"
|
|
460
|
+
? httpResult.errorCode
|
|
461
|
+
: httpResult.result === true || httpResult.result === api_constants.global_constants.SCORM_TRUE
|
|
462
|
+
? 0
|
|
463
|
+
: 101
|
|
464
|
+
}];
|
|
465
|
+
}
|
|
466
|
+
// removed by dead control flow
|
|
467
|
+
|
|
468
|
+
case 2: return [2, {
|
|
469
|
+
result: api_constants.global_constants.SCORM_FALSE,
|
|
470
|
+
errorCode: 101
|
|
471
|
+
}];
|
|
472
|
+
}
|
|
473
|
+
});
|
|
474
|
+
});
|
|
475
|
+
},
|
|
476
|
+
requestHandler: function (commitObject) {
|
|
477
|
+
return commitObject;
|
|
478
|
+
},
|
|
479
|
+
onLogMessage: function (messageLevel, logMessage) {
|
|
480
|
+
switch (messageLevel) {
|
|
481
|
+
case "4":
|
|
482
|
+
case 4:
|
|
483
|
+
case "ERROR":
|
|
484
|
+
case enums.LogLevelEnum.ERROR:
|
|
485
|
+
console.error(logMessage);
|
|
486
|
+
break;
|
|
487
|
+
case "3":
|
|
488
|
+
case 3:
|
|
489
|
+
case "WARN":
|
|
490
|
+
case enums.LogLevelEnum.WARN:
|
|
491
|
+
console.warn(logMessage);
|
|
492
|
+
break;
|
|
493
|
+
case "2":
|
|
494
|
+
case 2:
|
|
495
|
+
case "INFO":
|
|
496
|
+
case enums.LogLevelEnum.INFO:
|
|
497
|
+
console.info(logMessage);
|
|
498
|
+
break;
|
|
499
|
+
case "1":
|
|
500
|
+
case 1:
|
|
501
|
+
case "DEBUG":
|
|
502
|
+
case enums.LogLevelEnum.DEBUG:
|
|
503
|
+
if (console.debug) {
|
|
504
|
+
console.debug(logMessage);
|
|
505
|
+
}
|
|
506
|
+
else {
|
|
507
|
+
console.log(logMessage);
|
|
508
|
+
}
|
|
509
|
+
break;
|
|
510
|
+
}
|
|
511
|
+
},
|
|
512
|
+
scoItemIds: [],
|
|
513
|
+
scoItemIdValidator: false,
|
|
514
|
+
globalObjectiveIds: []
|
|
515
|
+
};
|
|
516
|
+
|
|
517
|
+
;// ./src/helpers/scheduled_commit.ts
|
|
518
|
+
|
|
519
|
+
var ScheduledCommit = (function () {
|
|
520
|
+
function ScheduledCommit(API, when, callback) {
|
|
521
|
+
this._cancelled = false;
|
|
522
|
+
this._API = API;
|
|
523
|
+
this._timeout = setTimeout(this.wrapper.bind(this), when);
|
|
524
|
+
this._callback = callback;
|
|
525
|
+
}
|
|
526
|
+
ScheduledCommit.prototype.cancel = function () {
|
|
527
|
+
this._cancelled = true;
|
|
528
|
+
if (this._timeout) {
|
|
529
|
+
clearTimeout(this._timeout);
|
|
530
|
+
}
|
|
531
|
+
};
|
|
532
|
+
ScheduledCommit.prototype.wrapper = function () {
|
|
533
|
+
var _this = this;
|
|
534
|
+
if (!this._cancelled) {
|
|
535
|
+
(function () { return (0,tslib_es6.__awaiter)(_this, void 0, void 0, function () { return (0,tslib_es6.__generator)(this, function (_a) {
|
|
536
|
+
switch (_a.label) {
|
|
537
|
+
case 0: return [4, this._API.commit(this._callback)];
|
|
538
|
+
case 1: return [2, _a.sent()];
|
|
539
|
+
}
|
|
540
|
+
}); }); })();
|
|
541
|
+
}
|
|
542
|
+
};
|
|
543
|
+
return ScheduledCommit;
|
|
544
|
+
}());
|
|
1422
545
|
|
|
1423
|
-
/***/ 56:
|
|
1424
|
-
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
1425
546
|
|
|
1426
|
-
|
|
1427
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1428
|
-
/* harmony export */ CompletionStatus: function() { return /* binding */ CompletionStatus; },
|
|
1429
|
-
/* harmony export */ LogLevelEnum: function() { return /* binding */ LogLevelEnum; },
|
|
1430
|
-
/* harmony export */ NAVBoolean: function() { return /* binding */ NAVBoolean; },
|
|
1431
|
-
/* harmony export */ SuccessStatus: function() { return /* binding */ SuccessStatus; }
|
|
1432
|
-
/* harmony export */ });
|
|
1433
|
-
var NAVBoolean;
|
|
1434
|
-
(function (NAVBoolean) {
|
|
1435
|
-
NAVBoolean["unknown"] = "unknown";
|
|
1436
|
-
NAVBoolean["true"] = "true";
|
|
1437
|
-
NAVBoolean["false"] = "false";
|
|
1438
|
-
})(NAVBoolean || (NAVBoolean = {}));
|
|
1439
|
-
var SuccessStatus;
|
|
1440
|
-
(function (SuccessStatus) {
|
|
1441
|
-
SuccessStatus["passed"] = "passed";
|
|
1442
|
-
SuccessStatus["failed"] = "failed";
|
|
1443
|
-
SuccessStatus["unknown"] = "unknown";
|
|
1444
|
-
})(SuccessStatus || (SuccessStatus = {}));
|
|
1445
|
-
var CompletionStatus;
|
|
1446
|
-
(function (CompletionStatus) {
|
|
1447
|
-
CompletionStatus["completed"] = "completed";
|
|
1448
|
-
CompletionStatus["incomplete"] = "incomplete";
|
|
1449
|
-
CompletionStatus["unknown"] = "unknown";
|
|
1450
|
-
})(CompletionStatus || (CompletionStatus = {}));
|
|
1451
|
-
var LogLevelEnum;
|
|
1452
|
-
(function (LogLevelEnum) {
|
|
1453
|
-
LogLevelEnum[LogLevelEnum["_"] = 0] = "_";
|
|
1454
|
-
LogLevelEnum[LogLevelEnum["DEBUG"] = 1] = "DEBUG";
|
|
1455
|
-
LogLevelEnum[LogLevelEnum["INFO"] = 2] = "INFO";
|
|
1456
|
-
LogLevelEnum[LogLevelEnum["WARN"] = 3] = "WARN";
|
|
1457
|
-
LogLevelEnum[LogLevelEnum["ERROR"] = 4] = "ERROR";
|
|
1458
|
-
LogLevelEnum[LogLevelEnum["NONE"] = 5] = "NONE";
|
|
1459
|
-
})(LogLevelEnum || (LogLevelEnum = {}));
|
|
547
|
+
;// ./src/BaseAPI.ts
|
|
1460
548
|
|
|
1461
549
|
|
|
1462
|
-
/***/ }),
|
|
1463
550
|
|
|
1464
|
-
/***/ 797:
|
|
1465
|
-
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
1466
551
|
|
|
1467
|
-
__webpack_require__.r(__webpack_exports__);
|
|
1468
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1469
|
-
/* harmony export */ global_errors: function() { return /* binding */ global_errors; },
|
|
1470
|
-
/* harmony export */ scorm12_errors: function() { return /* binding */ scorm12_errors; },
|
|
1471
|
-
/* harmony export */ scorm2004_errors: function() { return /* binding */ scorm2004_errors; }
|
|
1472
|
-
/* harmony export */ });
|
|
1473
|
-
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(635);
|
|
1474
552
|
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
};
|
|
1505
|
-
|
|
1506
|
-
var
|
|
553
|
+
|
|
554
|
+
|
|
555
|
+
|
|
556
|
+
var BaseAPI = (function () {
|
|
557
|
+
function BaseAPI(error_codes, settings) {
|
|
558
|
+
var _newTarget = this.constructor;
|
|
559
|
+
var _a, _c;
|
|
560
|
+
this._settings = DefaultSettings;
|
|
561
|
+
if (_newTarget === BaseAPI) {
|
|
562
|
+
throw new TypeError("Cannot construct BaseAPI instances directly");
|
|
563
|
+
}
|
|
564
|
+
this.currentState = api_constants.global_constants.STATE_NOT_INITIALIZED;
|
|
565
|
+
this.lastErrorCode = "0";
|
|
566
|
+
this.listenerArray = [];
|
|
567
|
+
this._error_codes = error_codes;
|
|
568
|
+
if (settings) {
|
|
569
|
+
this.settings = (0,tslib_es6.__assign)((0,tslib_es6.__assign)({}, DefaultSettings), settings);
|
|
570
|
+
}
|
|
571
|
+
this.apiLogLevel = (_a = this.settings.logLevel) !== null && _a !== void 0 ? _a : enums.LogLevelEnum.ERROR;
|
|
572
|
+
this.selfReportSessionTime = (_c = this.settings.selfReportSessionTime) !== null && _c !== void 0 ? _c : false;
|
|
573
|
+
}
|
|
574
|
+
BaseAPI.prototype.commonReset = function (settings) {
|
|
575
|
+
this.apiLog("reset", "Called", enums.LogLevelEnum.INFO);
|
|
576
|
+
this.settings = (0,tslib_es6.__assign)((0,tslib_es6.__assign)({}, this.settings), settings);
|
|
577
|
+
this.clearScheduledCommit();
|
|
578
|
+
this.currentState = api_constants.global_constants.STATE_NOT_INITIALIZED;
|
|
579
|
+
this.lastErrorCode = "0";
|
|
580
|
+
this.listenerArray = [];
|
|
581
|
+
this.startingData = {};
|
|
582
|
+
};
|
|
583
|
+
BaseAPI.prototype.initialize = function (callbackName, initializeMessage, terminationMessage) {
|
|
584
|
+
var returnValue = api_constants.global_constants.SCORM_FALSE;
|
|
585
|
+
if (this.isInitialized()) {
|
|
586
|
+
this.throwSCORMError(this._error_codes.INITIALIZED, initializeMessage);
|
|
587
|
+
}
|
|
588
|
+
else if (this.isTerminated()) {
|
|
589
|
+
this.throwSCORMError(this._error_codes.TERMINATED, terminationMessage);
|
|
590
|
+
}
|
|
591
|
+
else {
|
|
592
|
+
if (this.selfReportSessionTime) {
|
|
593
|
+
this.cmi.setStartTime();
|
|
594
|
+
}
|
|
595
|
+
this.currentState = api_constants.global_constants.STATE_INITIALIZED;
|
|
596
|
+
this.lastErrorCode = "0";
|
|
597
|
+
returnValue = api_constants.global_constants.SCORM_TRUE;
|
|
598
|
+
this.processListeners(callbackName);
|
|
599
|
+
}
|
|
600
|
+
this.apiLog(callbackName, "returned: " + returnValue, enums.LogLevelEnum.INFO);
|
|
601
|
+
this.clearSCORMError(returnValue);
|
|
602
|
+
return returnValue;
|
|
603
|
+
};
|
|
604
|
+
BaseAPI.prototype.apiLog = function (functionName, logMessage, messageLevel, CMIElement) {
|
|
605
|
+
logMessage = (0,utilities.formatMessage)(functionName, logMessage, CMIElement);
|
|
606
|
+
if (messageLevel >= this.apiLogLevel) {
|
|
607
|
+
this.settings.onLogMessage(messageLevel, logMessage);
|
|
608
|
+
}
|
|
609
|
+
};
|
|
610
|
+
Object.defineProperty(BaseAPI.prototype, "error_codes", {
|
|
611
|
+
get: function () {
|
|
612
|
+
return this._error_codes;
|
|
613
|
+
},
|
|
614
|
+
enumerable: false,
|
|
615
|
+
configurable: true
|
|
616
|
+
});
|
|
617
|
+
Object.defineProperty(BaseAPI.prototype, "settings", {
|
|
618
|
+
get: function () {
|
|
619
|
+
return this._settings;
|
|
620
|
+
},
|
|
621
|
+
set: function (settings) {
|
|
622
|
+
this._settings = (0,tslib_es6.__assign)((0,tslib_es6.__assign)({}, this._settings), settings);
|
|
623
|
+
},
|
|
624
|
+
enumerable: false,
|
|
625
|
+
configurable: true
|
|
626
|
+
});
|
|
627
|
+
BaseAPI.prototype.terminate = function (callbackName, checkTerminated) {
|
|
628
|
+
return (0,tslib_es6.__awaiter)(this, void 0, void 0, function () {
|
|
629
|
+
var returnValue, result;
|
|
630
|
+
return (0,tslib_es6.__generator)(this, function (_a) {
|
|
631
|
+
switch (_a.label) {
|
|
632
|
+
case 0:
|
|
633
|
+
returnValue = api_constants.global_constants.SCORM_FALSE;
|
|
634
|
+
if (!this.checkState(checkTerminated, this._error_codes.TERMINATION_BEFORE_INIT, this._error_codes.MULTIPLE_TERMINATION)) return [3, 2];
|
|
635
|
+
this.currentState = api_constants.global_constants.STATE_TERMINATED;
|
|
636
|
+
return [4, this.storeData(true)];
|
|
637
|
+
case 1:
|
|
638
|
+
result = _a.sent();
|
|
639
|
+
if (typeof result.errorCode !== "undefined" && result.errorCode > 0) {
|
|
640
|
+
this.throwSCORMError(result.errorCode);
|
|
641
|
+
}
|
|
642
|
+
returnValue =
|
|
643
|
+
typeof result !== "undefined" && (result.result === true || result.result === api_constants.global_constants.SCORM_TRUE)
|
|
644
|
+
? api_constants.global_constants.SCORM_TRUE
|
|
645
|
+
: api_constants.global_constants.SCORM_FALSE;
|
|
646
|
+
if (checkTerminated)
|
|
647
|
+
this.lastErrorCode = "0";
|
|
648
|
+
returnValue = api_constants.global_constants.SCORM_TRUE;
|
|
649
|
+
this.processListeners(callbackName);
|
|
650
|
+
_a.label = 2;
|
|
651
|
+
case 2:
|
|
652
|
+
this.apiLog(callbackName, "returned: " + returnValue, enums.LogLevelEnum.INFO);
|
|
653
|
+
this.clearSCORMError(returnValue);
|
|
654
|
+
return [2, returnValue];
|
|
655
|
+
}
|
|
656
|
+
});
|
|
657
|
+
});
|
|
658
|
+
};
|
|
659
|
+
BaseAPI.prototype.getValue = function (callbackName, checkTerminated, CMIElement) {
|
|
660
|
+
var returnValue = "";
|
|
661
|
+
if (this.checkState(checkTerminated, this._error_codes.RETRIEVE_BEFORE_INIT, this._error_codes.RETRIEVE_AFTER_TERM)) {
|
|
662
|
+
if (checkTerminated)
|
|
663
|
+
this.lastErrorCode = "0";
|
|
664
|
+
try {
|
|
665
|
+
returnValue = this.getCMIValue(CMIElement);
|
|
666
|
+
}
|
|
667
|
+
catch (e) {
|
|
668
|
+
returnValue = this.handleValueAccessException(e, returnValue);
|
|
669
|
+
}
|
|
670
|
+
this.processListeners(callbackName, CMIElement);
|
|
671
|
+
}
|
|
672
|
+
this.apiLog(callbackName, ": returned: " + returnValue, enums.LogLevelEnum.INFO, CMIElement);
|
|
673
|
+
if (returnValue === undefined) {
|
|
674
|
+
return "";
|
|
675
|
+
}
|
|
676
|
+
this.clearSCORMError(returnValue);
|
|
677
|
+
return returnValue;
|
|
678
|
+
};
|
|
679
|
+
BaseAPI.prototype.setValue = function (callbackName, commitCallback, checkTerminated, CMIElement, value) {
|
|
680
|
+
if (value !== undefined) {
|
|
681
|
+
value = String(value);
|
|
682
|
+
}
|
|
683
|
+
var returnValue = api_constants.global_constants.SCORM_FALSE;
|
|
684
|
+
if (this.checkState(checkTerminated, this._error_codes.STORE_BEFORE_INIT, this._error_codes.STORE_AFTER_TERM)) {
|
|
685
|
+
if (checkTerminated)
|
|
686
|
+
this.lastErrorCode = "0";
|
|
687
|
+
try {
|
|
688
|
+
returnValue = this.setCMIValue(CMIElement, value);
|
|
689
|
+
}
|
|
690
|
+
catch (e) {
|
|
691
|
+
this.handleValueAccessException(e, returnValue);
|
|
692
|
+
}
|
|
693
|
+
this.processListeners(callbackName, CMIElement, value);
|
|
694
|
+
}
|
|
695
|
+
if (returnValue === undefined) {
|
|
696
|
+
returnValue = api_constants.global_constants.SCORM_FALSE;
|
|
697
|
+
}
|
|
698
|
+
if (String(this.lastErrorCode) === "0") {
|
|
699
|
+
if (this.settings.autocommit) {
|
|
700
|
+
this.scheduleCommit(this.settings.autocommitSeconds * 1000, commitCallback);
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
this.apiLog(callbackName, ": " + value + ": result: " + returnValue, enums.LogLevelEnum.INFO, CMIElement);
|
|
704
|
+
this.clearSCORMError(returnValue);
|
|
705
|
+
return returnValue;
|
|
706
|
+
};
|
|
707
|
+
BaseAPI.prototype.commit = function (callbackName_1) {
|
|
708
|
+
return (0,tslib_es6.__awaiter)(this, arguments, void 0, function (callbackName, checkTerminated) {
|
|
709
|
+
var returnValue, result;
|
|
710
|
+
if (checkTerminated === void 0) { checkTerminated = false; }
|
|
711
|
+
return (0,tslib_es6.__generator)(this, function (_a) {
|
|
712
|
+
switch (_a.label) {
|
|
713
|
+
case 0:
|
|
714
|
+
this.clearScheduledCommit();
|
|
715
|
+
returnValue = api_constants.global_constants.SCORM_FALSE;
|
|
716
|
+
if (!this.checkState(checkTerminated, this._error_codes.COMMIT_BEFORE_INIT, this._error_codes.COMMIT_AFTER_TERM)) return [3, 2];
|
|
717
|
+
return [4, this.storeData(false)];
|
|
718
|
+
case 1:
|
|
719
|
+
result = _a.sent();
|
|
720
|
+
if (result.errorCode && result.errorCode > 0) {
|
|
721
|
+
this.throwSCORMError(result.errorCode);
|
|
722
|
+
}
|
|
723
|
+
returnValue =
|
|
724
|
+
typeof result !== "undefined" && (result.result === true || result.result === api_constants.global_constants.SCORM_TRUE)
|
|
725
|
+
? api_constants.global_constants.SCORM_TRUE
|
|
726
|
+
: api_constants.global_constants.SCORM_FALSE;
|
|
727
|
+
this.apiLog(callbackName, " Result: " + returnValue, enums.LogLevelEnum.DEBUG, "HttpRequest");
|
|
728
|
+
if (checkTerminated)
|
|
729
|
+
this.lastErrorCode = "0";
|
|
730
|
+
this.processListeners(callbackName);
|
|
731
|
+
_a.label = 2;
|
|
732
|
+
case 2:
|
|
733
|
+
this.apiLog(callbackName, "returned: " + returnValue, enums.LogLevelEnum.INFO);
|
|
734
|
+
this.clearSCORMError(returnValue);
|
|
735
|
+
return [2, returnValue];
|
|
736
|
+
}
|
|
737
|
+
});
|
|
738
|
+
});
|
|
739
|
+
};
|
|
740
|
+
BaseAPI.prototype.getLastError = function (callbackName) {
|
|
741
|
+
var returnValue = String(this.lastErrorCode);
|
|
742
|
+
this.processListeners(callbackName);
|
|
743
|
+
this.apiLog(callbackName, "returned: " + returnValue, enums.LogLevelEnum.INFO);
|
|
744
|
+
return returnValue;
|
|
745
|
+
};
|
|
746
|
+
BaseAPI.prototype.getErrorString = function (callbackName, CMIErrorCode) {
|
|
747
|
+
var returnValue = "";
|
|
748
|
+
if (CMIErrorCode !== null && CMIErrorCode !== "") {
|
|
749
|
+
returnValue = this.getLmsErrorMessageDetails(CMIErrorCode);
|
|
750
|
+
this.processListeners(callbackName);
|
|
751
|
+
}
|
|
752
|
+
this.apiLog(callbackName, "returned: " + returnValue, enums.LogLevelEnum.INFO);
|
|
753
|
+
return returnValue;
|
|
754
|
+
};
|
|
755
|
+
BaseAPI.prototype.getDiagnostic = function (callbackName, CMIErrorCode) {
|
|
756
|
+
var returnValue = "";
|
|
757
|
+
if (CMIErrorCode !== null && CMIErrorCode !== "") {
|
|
758
|
+
returnValue = this.getLmsErrorMessageDetails(CMIErrorCode, true);
|
|
759
|
+
this.processListeners(callbackName);
|
|
760
|
+
}
|
|
761
|
+
this.apiLog(callbackName, "returned: " + returnValue, enums.LogLevelEnum.INFO);
|
|
762
|
+
return returnValue;
|
|
763
|
+
};
|
|
764
|
+
BaseAPI.prototype.checkState = function (checkTerminated, beforeInitError, afterTermError) {
|
|
765
|
+
if (this.isNotInitialized()) {
|
|
766
|
+
this.throwSCORMError(beforeInitError);
|
|
767
|
+
return false;
|
|
768
|
+
}
|
|
769
|
+
else if (checkTerminated && this.isTerminated()) {
|
|
770
|
+
this.throwSCORMError(afterTermError);
|
|
771
|
+
return false;
|
|
772
|
+
}
|
|
773
|
+
return true;
|
|
774
|
+
};
|
|
775
|
+
BaseAPI.prototype.getLmsErrorMessageDetails = function (_errorNumber, _detail) {
|
|
776
|
+
if (_detail === void 0) { _detail = false; }
|
|
777
|
+
throw new Error("The getLmsErrorMessageDetails method has not been implemented");
|
|
778
|
+
};
|
|
779
|
+
BaseAPI.prototype.getCMIValue = function (_CMIElement) {
|
|
780
|
+
throw new Error("The getCMIValue method has not been implemented");
|
|
781
|
+
};
|
|
782
|
+
BaseAPI.prototype.setCMIValue = function (_CMIElement, _value) {
|
|
783
|
+
throw new Error("The setCMIValue method has not been implemented");
|
|
784
|
+
};
|
|
785
|
+
BaseAPI.prototype._commonSetCMIValue = function (methodName, scorm2004, CMIElement, value) {
|
|
786
|
+
if (!CMIElement || CMIElement === "") {
|
|
787
|
+
return api_constants.global_constants.SCORM_FALSE;
|
|
788
|
+
}
|
|
789
|
+
var structure = CMIElement.split(".");
|
|
790
|
+
var refObject = this;
|
|
791
|
+
var returnValue = api_constants.global_constants.SCORM_FALSE;
|
|
792
|
+
var foundFirstIndex = false;
|
|
793
|
+
var invalidErrorMessage = "The data model element passed to ".concat(methodName, " (").concat(CMIElement, ") is not a valid SCORM data model element.");
|
|
794
|
+
var invalidErrorCode = scorm2004
|
|
795
|
+
? this._error_codes.UNDEFINED_DATA_MODEL
|
|
796
|
+
: this._error_codes.GENERAL;
|
|
797
|
+
for (var idx = 0; idx < structure.length; idx++) {
|
|
798
|
+
var attribute = structure[idx];
|
|
799
|
+
if (!attribute) {
|
|
800
|
+
this.throwSCORMError(invalidErrorCode, invalidErrorMessage);
|
|
801
|
+
return api_constants.global_constants.SCORM_FALSE;
|
|
802
|
+
}
|
|
803
|
+
if (idx === structure.length - 1) {
|
|
804
|
+
if (scorm2004 && attribute.substring(0, 8) === "{target=") {
|
|
805
|
+
if (this.isInitialized()) {
|
|
806
|
+
this.throwSCORMError(this._error_codes.READ_ONLY_ELEMENT);
|
|
807
|
+
}
|
|
808
|
+
else {
|
|
809
|
+
refObject = (0,tslib_es6.__assign)((0,tslib_es6.__assign)({}, refObject), { attribute: value });
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
else if (!this._checkObjectHasProperty(refObject, attribute)) {
|
|
813
|
+
this.throwSCORMError(invalidErrorCode, invalidErrorMessage);
|
|
814
|
+
}
|
|
815
|
+
else {
|
|
816
|
+
if ((0,utilities.stringMatches)(CMIElement, "\\.correct_responses\\.\\d+") &&
|
|
817
|
+
this.isInitialized()) {
|
|
818
|
+
this.validateCorrectResponse(CMIElement, value);
|
|
819
|
+
}
|
|
820
|
+
if (!scorm2004 || this.lastErrorCode === "0") {
|
|
821
|
+
refObject[attribute] = value;
|
|
822
|
+
returnValue = api_constants.global_constants.SCORM_TRUE;
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
else {
|
|
827
|
+
refObject = refObject[attribute];
|
|
828
|
+
if (!refObject) {
|
|
829
|
+
this.throwSCORMError(invalidErrorCode, invalidErrorMessage);
|
|
830
|
+
break;
|
|
831
|
+
}
|
|
832
|
+
if (refObject instanceof array.CMIArray) {
|
|
833
|
+
var index = parseInt(structure[idx + 1] || "0", 10);
|
|
834
|
+
if (!isNaN(index)) {
|
|
835
|
+
var item = refObject.childArray[index];
|
|
836
|
+
if (item) {
|
|
837
|
+
refObject = item;
|
|
838
|
+
foundFirstIndex = true;
|
|
839
|
+
}
|
|
840
|
+
else {
|
|
841
|
+
var newChild = this.getChildElement(CMIElement, value, foundFirstIndex);
|
|
842
|
+
foundFirstIndex = true;
|
|
843
|
+
if (!newChild) {
|
|
844
|
+
this.throwSCORMError(invalidErrorCode, invalidErrorMessage);
|
|
845
|
+
}
|
|
846
|
+
else {
|
|
847
|
+
if (refObject.initialized)
|
|
848
|
+
newChild.initialize();
|
|
849
|
+
refObject.childArray.push(newChild);
|
|
850
|
+
refObject = newChild;
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
idx++;
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
if (returnValue === api_constants.global_constants.SCORM_FALSE) {
|
|
859
|
+
this.apiLog(methodName, "There was an error setting the value for: ".concat(CMIElement, ", value of: ").concat(value), enums.LogLevelEnum.WARN);
|
|
860
|
+
}
|
|
861
|
+
return returnValue;
|
|
862
|
+
};
|
|
863
|
+
BaseAPI.prototype._commonGetCMIValue = function (methodName, scorm2004, CMIElement) {
|
|
864
|
+
if (!CMIElement || CMIElement === "") {
|
|
865
|
+
return "";
|
|
866
|
+
}
|
|
867
|
+
var structure = CMIElement.split(".");
|
|
868
|
+
var refObject = this;
|
|
869
|
+
var attribute = null;
|
|
870
|
+
var uninitializedErrorMessage = "The data model element passed to ".concat(methodName, " (").concat(CMIElement, ") has not been initialized.");
|
|
871
|
+
var invalidErrorMessage = "The data model element passed to ".concat(methodName, " (").concat(CMIElement, ") is not a valid SCORM data model element.");
|
|
872
|
+
var invalidErrorCode = scorm2004
|
|
873
|
+
? this._error_codes.UNDEFINED_DATA_MODEL
|
|
874
|
+
: this._error_codes.GENERAL;
|
|
875
|
+
for (var idx = 0; idx < structure.length; idx++) {
|
|
876
|
+
attribute = structure[idx];
|
|
877
|
+
if (!attribute) {
|
|
878
|
+
this.throwSCORMError(invalidErrorCode, invalidErrorMessage);
|
|
879
|
+
return;
|
|
880
|
+
}
|
|
881
|
+
if (!scorm2004) {
|
|
882
|
+
if (idx === structure.length - 1) {
|
|
883
|
+
if (!this._checkObjectHasProperty(refObject, attribute)) {
|
|
884
|
+
this.throwSCORMError(invalidErrorCode, invalidErrorMessage);
|
|
885
|
+
return;
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
else {
|
|
890
|
+
if (String(attribute).substring(0, 8) === "{target=" &&
|
|
891
|
+
typeof refObject._isTargetValid == "function") {
|
|
892
|
+
var target = String(attribute).substring(8, String(attribute).length - 9);
|
|
893
|
+
return refObject._isTargetValid(target);
|
|
894
|
+
}
|
|
895
|
+
else if (!this._checkObjectHasProperty(refObject, attribute)) {
|
|
896
|
+
this.throwSCORMError(invalidErrorCode, invalidErrorMessage);
|
|
897
|
+
return;
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
refObject = refObject[attribute];
|
|
901
|
+
if (refObject === undefined) {
|
|
902
|
+
this.throwSCORMError(invalidErrorCode, invalidErrorMessage);
|
|
903
|
+
break;
|
|
904
|
+
}
|
|
905
|
+
if (refObject instanceof array.CMIArray) {
|
|
906
|
+
var index = parseInt(structure[idx + 1] || "", 10);
|
|
907
|
+
if (!isNaN(index)) {
|
|
908
|
+
var item = refObject.childArray[index];
|
|
909
|
+
if (item) {
|
|
910
|
+
refObject = item;
|
|
911
|
+
}
|
|
912
|
+
else {
|
|
913
|
+
this.throwSCORMError(this._error_codes.VALUE_NOT_INITIALIZED, uninitializedErrorMessage);
|
|
914
|
+
break;
|
|
915
|
+
}
|
|
916
|
+
idx++;
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
if (refObject === null || refObject === undefined) {
|
|
921
|
+
if (!scorm2004) {
|
|
922
|
+
if (attribute === "_children") {
|
|
923
|
+
this.throwSCORMError(this._error_codes.CHILDREN_ERROR);
|
|
924
|
+
}
|
|
925
|
+
else if (attribute === "_count") {
|
|
926
|
+
this.throwSCORMError(this._error_codes.COUNT_ERROR);
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
else {
|
|
931
|
+
return refObject;
|
|
932
|
+
}
|
|
933
|
+
};
|
|
934
|
+
BaseAPI.prototype.isInitialized = function () {
|
|
935
|
+
return this.currentState === api_constants.global_constants.STATE_INITIALIZED;
|
|
936
|
+
};
|
|
937
|
+
BaseAPI.prototype.isNotInitialized = function () {
|
|
938
|
+
return this.currentState === api_constants.global_constants.STATE_NOT_INITIALIZED;
|
|
939
|
+
};
|
|
940
|
+
BaseAPI.prototype.isTerminated = function () {
|
|
941
|
+
return this.currentState === api_constants.global_constants.STATE_TERMINATED;
|
|
942
|
+
};
|
|
943
|
+
BaseAPI.prototype.on = function (listenerName, callback) {
|
|
944
|
+
var _a, _c;
|
|
945
|
+
if (!callback)
|
|
946
|
+
return;
|
|
947
|
+
var listenerFunctions = listenerName.split(" ");
|
|
948
|
+
for (var i = 0; i < listenerFunctions.length; i++) {
|
|
949
|
+
var listenerSplit = (_a = listenerFunctions[i]) === null || _a === void 0 ? void 0 : _a.split(".");
|
|
950
|
+
if (!listenerSplit || listenerSplit.length === 0)
|
|
951
|
+
return;
|
|
952
|
+
var functionName = listenerSplit[0];
|
|
953
|
+
var CMIElement = null;
|
|
954
|
+
if (listenerSplit.length > 1) {
|
|
955
|
+
CMIElement = (_c = listenerFunctions[i]) === null || _c === void 0 ? void 0 : _c.replace(functionName + ".", "");
|
|
956
|
+
}
|
|
957
|
+
this.listenerArray.push({
|
|
958
|
+
functionName: functionName,
|
|
959
|
+
CMIElement: CMIElement,
|
|
960
|
+
callback: callback
|
|
961
|
+
});
|
|
962
|
+
this.apiLog("on", "Added event listener: ".concat(this.listenerArray.length), enums.LogLevelEnum.INFO, functionName);
|
|
963
|
+
}
|
|
964
|
+
};
|
|
965
|
+
BaseAPI.prototype.off = function (listenerName, callback) {
|
|
966
|
+
var _a, _c;
|
|
967
|
+
if (!callback)
|
|
968
|
+
return;
|
|
969
|
+
var listenerFunctions = listenerName.split(" ");
|
|
970
|
+
var _loop_1 = function (i) {
|
|
971
|
+
var listenerSplit = (_a = listenerFunctions[i]) === null || _a === void 0 ? void 0 : _a.split(".");
|
|
972
|
+
if (!listenerSplit || listenerSplit.length === 0)
|
|
973
|
+
return { value: void 0 };
|
|
974
|
+
var functionName = listenerSplit[0];
|
|
975
|
+
var CMIElement = null;
|
|
976
|
+
if (listenerSplit.length > 1) {
|
|
977
|
+
CMIElement = (_c = listenerFunctions[i]) === null || _c === void 0 ? void 0 : _c.replace(functionName + ".", "");
|
|
978
|
+
}
|
|
979
|
+
var removeIndex = this_1.listenerArray.findIndex(function (obj) {
|
|
980
|
+
return obj.functionName === functionName &&
|
|
981
|
+
obj.CMIElement === CMIElement &&
|
|
982
|
+
obj.callback === callback;
|
|
983
|
+
});
|
|
984
|
+
if (removeIndex !== -1) {
|
|
985
|
+
this_1.listenerArray.splice(removeIndex, 1);
|
|
986
|
+
this_1.apiLog("off", "Removed event listener: ".concat(this_1.listenerArray.length), enums.LogLevelEnum.INFO, functionName);
|
|
987
|
+
}
|
|
988
|
+
};
|
|
989
|
+
var this_1 = this;
|
|
990
|
+
for (var i = 0; i < listenerFunctions.length; i++) {
|
|
991
|
+
var state_1 = _loop_1(i);
|
|
992
|
+
if (typeof state_1 === "object")
|
|
993
|
+
return state_1.value;
|
|
994
|
+
}
|
|
995
|
+
};
|
|
996
|
+
BaseAPI.prototype.clear = function (listenerName) {
|
|
997
|
+
var _a, _c;
|
|
998
|
+
var listenerFunctions = listenerName.split(" ");
|
|
999
|
+
var _loop_2 = function (i) {
|
|
1000
|
+
var listenerSplit = (_a = listenerFunctions[i]) === null || _a === void 0 ? void 0 : _a.split(".");
|
|
1001
|
+
if (!listenerSplit || (listenerSplit === null || listenerSplit === void 0 ? void 0 : listenerSplit.length) === 0)
|
|
1002
|
+
return { value: void 0 };
|
|
1003
|
+
var functionName = listenerSplit[0];
|
|
1004
|
+
var CMIElement = null;
|
|
1005
|
+
if (listenerSplit.length > 1) {
|
|
1006
|
+
CMIElement = (_c = listenerFunctions[i]) === null || _c === void 0 ? void 0 : _c.replace(functionName + ".", "");
|
|
1007
|
+
}
|
|
1008
|
+
this_2.listenerArray = this_2.listenerArray.filter(function (obj) {
|
|
1009
|
+
return obj.functionName !== functionName && obj.CMIElement !== CMIElement;
|
|
1010
|
+
});
|
|
1011
|
+
};
|
|
1012
|
+
var this_2 = this;
|
|
1013
|
+
for (var i = 0; i < listenerFunctions.length; i++) {
|
|
1014
|
+
var state_2 = _loop_2(i);
|
|
1015
|
+
if (typeof state_2 === "object")
|
|
1016
|
+
return state_2.value;
|
|
1017
|
+
}
|
|
1018
|
+
};
|
|
1019
|
+
BaseAPI.prototype.processListeners = function (functionName, CMIElement, value) {
|
|
1020
|
+
this.apiLog(functionName, value, enums.LogLevelEnum.INFO, CMIElement);
|
|
1021
|
+
for (var i = 0; i < this.listenerArray.length; i++) {
|
|
1022
|
+
var listener = this.listenerArray[i];
|
|
1023
|
+
var functionsMatch = listener.functionName === functionName;
|
|
1024
|
+
var listenerHasCMIElement = !!listener.CMIElement;
|
|
1025
|
+
var CMIElementsMatch = false;
|
|
1026
|
+
if (CMIElement &&
|
|
1027
|
+
listener.CMIElement &&
|
|
1028
|
+
listener.CMIElement.substring(listener.CMIElement.length - 1) === "*") {
|
|
1029
|
+
CMIElementsMatch =
|
|
1030
|
+
CMIElement.indexOf(listener.CMIElement.substring(0, listener.CMIElement.length - 1)) === 0;
|
|
1031
|
+
}
|
|
1032
|
+
else {
|
|
1033
|
+
CMIElementsMatch = listener.CMIElement === CMIElement;
|
|
1034
|
+
}
|
|
1035
|
+
if (functionsMatch && (!listenerHasCMIElement || CMIElementsMatch)) {
|
|
1036
|
+
this.apiLog("processListeners", "Processing listener: ".concat(listener.functionName), enums.LogLevelEnum.INFO, CMIElement);
|
|
1037
|
+
listener.callback(CMIElement, value);
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
};
|
|
1041
|
+
BaseAPI.prototype.throwSCORMError = function (errorNumber, message) {
|
|
1042
|
+
if (!message) {
|
|
1043
|
+
message = this.getLmsErrorMessageDetails(errorNumber);
|
|
1044
|
+
}
|
|
1045
|
+
this.apiLog("throwSCORMError", errorNumber + ": " + message, enums.LogLevelEnum.ERROR);
|
|
1046
|
+
this.lastErrorCode = String(errorNumber);
|
|
1047
|
+
};
|
|
1048
|
+
BaseAPI.prototype.clearSCORMError = function (success) {
|
|
1049
|
+
if (success !== undefined && success !== api_constants.global_constants.SCORM_FALSE) {
|
|
1050
|
+
this.lastErrorCode = "0";
|
|
1051
|
+
}
|
|
1052
|
+
};
|
|
1053
|
+
BaseAPI.prototype.loadFromFlattenedJSON = function (json, CMIElement) {
|
|
1054
|
+
var _this = this;
|
|
1055
|
+
if (!CMIElement) {
|
|
1056
|
+
CMIElement = "";
|
|
1057
|
+
}
|
|
1058
|
+
if (!this.isNotInitialized()) {
|
|
1059
|
+
console.error("loadFromFlattenedJSON can only be called before the call to lmsInitialize.");
|
|
1060
|
+
return;
|
|
1061
|
+
}
|
|
1062
|
+
function testPattern(a, c, a_pattern) {
|
|
1063
|
+
var a_match = a.match(a_pattern);
|
|
1064
|
+
var c_match;
|
|
1065
|
+
if (a_match !== null && (c_match = c.match(a_pattern)) !== null) {
|
|
1066
|
+
var a_num = Number(a_match[2]);
|
|
1067
|
+
var c_num = Number(c_match[2]);
|
|
1068
|
+
if (a_num === c_num) {
|
|
1069
|
+
if (a_match[3] === "id") {
|
|
1070
|
+
return -1;
|
|
1071
|
+
}
|
|
1072
|
+
else if (a_match[3] === "type") {
|
|
1073
|
+
if (c_match[3] === "id") {
|
|
1074
|
+
return 1;
|
|
1075
|
+
}
|
|
1076
|
+
else {
|
|
1077
|
+
return -1;
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
else {
|
|
1081
|
+
return 1;
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
return a_num - c_num;
|
|
1085
|
+
}
|
|
1086
|
+
return null;
|
|
1087
|
+
}
|
|
1088
|
+
var int_pattern = /^(cmi\.interactions\.)(\d+)\.(.*)$/;
|
|
1089
|
+
var obj_pattern = /^(cmi\.objectives\.)(\d+)\.(.*)$/;
|
|
1090
|
+
var result = Object.keys(json).map(function (key) {
|
|
1091
|
+
return [String(key), json[key]];
|
|
1092
|
+
});
|
|
1093
|
+
result.sort(function (_a, _c) {
|
|
1094
|
+
var a = _a[0], _b = _a[1];
|
|
1095
|
+
var c = _c[0], _d = _c[1];
|
|
1096
|
+
var test;
|
|
1097
|
+
if ((test = testPattern(a, c, int_pattern)) !== null) {
|
|
1098
|
+
return test;
|
|
1099
|
+
}
|
|
1100
|
+
if ((test = testPattern(a, c, obj_pattern)) !== null) {
|
|
1101
|
+
return test;
|
|
1102
|
+
}
|
|
1103
|
+
if (a < c) {
|
|
1104
|
+
return -1;
|
|
1105
|
+
}
|
|
1106
|
+
if (a > c) {
|
|
1107
|
+
return 1;
|
|
1108
|
+
}
|
|
1109
|
+
return 0;
|
|
1110
|
+
});
|
|
1111
|
+
var obj;
|
|
1112
|
+
result.forEach(function (element) {
|
|
1113
|
+
obj = {};
|
|
1114
|
+
obj[element[0]] = element[1];
|
|
1115
|
+
_this.loadFromJSON((0,utilities.unflatten)(obj), CMIElement);
|
|
1116
|
+
});
|
|
1117
|
+
};
|
|
1118
|
+
BaseAPI.prototype.loadFromJSON = function (json, CMIElement) {
|
|
1119
|
+
if (CMIElement === void 0) { CMIElement = ""; }
|
|
1120
|
+
if ((!CMIElement || CMIElement === "") &&
|
|
1121
|
+
!Object.hasOwnProperty.call(json, "cmi") &&
|
|
1122
|
+
!Object.hasOwnProperty.call(json, "adl")) {
|
|
1123
|
+
CMIElement = "cmi";
|
|
1124
|
+
}
|
|
1125
|
+
if (!this.isNotInitialized()) {
|
|
1126
|
+
console.error("loadFromJSON can only be called before the call to lmsInitialize.");
|
|
1127
|
+
return;
|
|
1128
|
+
}
|
|
1129
|
+
CMIElement = CMIElement !== undefined ? CMIElement : "cmi";
|
|
1130
|
+
this.startingData = json;
|
|
1131
|
+
for (var key in json) {
|
|
1132
|
+
if ({}.hasOwnProperty.call(json, key) && json[key]) {
|
|
1133
|
+
var currentCMIElement = (CMIElement ? CMIElement + "." : "") + key;
|
|
1134
|
+
var value = json[key];
|
|
1135
|
+
if (value["childArray"]) {
|
|
1136
|
+
for (var i = 0; i < value["childArray"].length; i++) {
|
|
1137
|
+
this.loadFromJSON(value["childArray"][i], currentCMIElement + "." + i);
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
else if (value.constructor === Object) {
|
|
1141
|
+
this.loadFromJSON(value, currentCMIElement);
|
|
1142
|
+
}
|
|
1143
|
+
else {
|
|
1144
|
+
this.setCMIValue(currentCMIElement, value);
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
};
|
|
1149
|
+
BaseAPI.prototype.renderCMIToJSONString = function () {
|
|
1150
|
+
var cmi = this.cmi;
|
|
1151
|
+
if (this.settings.sendFullCommit) {
|
|
1152
|
+
return JSON.stringify({ cmi: cmi });
|
|
1153
|
+
}
|
|
1154
|
+
return JSON.stringify({ cmi: cmi }, function (k, v) { return (v === undefined ? null : v); }, 2);
|
|
1155
|
+
};
|
|
1156
|
+
BaseAPI.prototype.renderCMIToJSONObject = function () {
|
|
1157
|
+
return JSON.parse(this.renderCMIToJSONString());
|
|
1158
|
+
};
|
|
1159
|
+
BaseAPI.prototype.processHttpRequest = function (url_1, params_1) {
|
|
1160
|
+
return (0,tslib_es6.__awaiter)(this, arguments, void 0, function (url, params, immediate) {
|
|
1161
|
+
var api, genericError, process;
|
|
1162
|
+
var _this = this;
|
|
1163
|
+
if (immediate === void 0) { immediate = false; }
|
|
1164
|
+
return (0,tslib_es6.__generator)(this, function (_a) {
|
|
1165
|
+
switch (_a.label) {
|
|
1166
|
+
case 0:
|
|
1167
|
+
api = this;
|
|
1168
|
+
genericError = {
|
|
1169
|
+
result: api_constants.global_constants.SCORM_FALSE,
|
|
1170
|
+
errorCode: this.error_codes.GENERAL
|
|
1171
|
+
};
|
|
1172
|
+
if (immediate) {
|
|
1173
|
+
params = this.settings.requestHandler(params);
|
|
1174
|
+
this.performFetch(url, params).then(function (response) { return (0,tslib_es6.__awaiter)(_this, void 0, void 0, function () {
|
|
1175
|
+
return (0,tslib_es6.__generator)(this, function (_a) {
|
|
1176
|
+
switch (_a.label) {
|
|
1177
|
+
case 0: return [4, this.transformResponse(response)];
|
|
1178
|
+
case 1:
|
|
1179
|
+
_a.sent();
|
|
1180
|
+
return [2];
|
|
1181
|
+
}
|
|
1182
|
+
});
|
|
1183
|
+
}); });
|
|
1184
|
+
return [2, {
|
|
1185
|
+
result: api_constants.global_constants.SCORM_TRUE,
|
|
1186
|
+
errorCode: 0
|
|
1187
|
+
}];
|
|
1188
|
+
}
|
|
1189
|
+
process = function (url, params, settings) { return (0,tslib_es6.__awaiter)(_this, void 0, void 0, function () {
|
|
1190
|
+
var response, e_1, message;
|
|
1191
|
+
return (0,tslib_es6.__generator)(this, function (_a) {
|
|
1192
|
+
switch (_a.label) {
|
|
1193
|
+
case 0:
|
|
1194
|
+
_a.trys.push([0, 2, , 3]);
|
|
1195
|
+
params = settings.requestHandler(params);
|
|
1196
|
+
return [4, this.performFetch(url, params)];
|
|
1197
|
+
case 1:
|
|
1198
|
+
response = _a.sent();
|
|
1199
|
+
return [2, this.transformResponse(response)];
|
|
1200
|
+
case 2:
|
|
1201
|
+
e_1 = _a.sent();
|
|
1202
|
+
message = e_1 instanceof Error ? e_1.message : String(e_1);
|
|
1203
|
+
this.apiLog("processHttpRequest", message, enums.LogLevelEnum.ERROR);
|
|
1204
|
+
api.processListeners("CommitError");
|
|
1205
|
+
return [2, genericError];
|
|
1206
|
+
case 3: return [2];
|
|
1207
|
+
}
|
|
1208
|
+
});
|
|
1209
|
+
}); };
|
|
1210
|
+
return [4, process(url, params, this.settings)];
|
|
1211
|
+
case 1: return [2, _a.sent()];
|
|
1212
|
+
}
|
|
1213
|
+
});
|
|
1214
|
+
});
|
|
1215
|
+
};
|
|
1216
|
+
BaseAPI.prototype.scheduleCommit = function (when, callback) {
|
|
1217
|
+
if (!this._timeout) {
|
|
1218
|
+
this._timeout = new ScheduledCommit(this, when, callback);
|
|
1219
|
+
this.apiLog("scheduleCommit", "scheduled", enums.LogLevelEnum.DEBUG, "");
|
|
1220
|
+
}
|
|
1221
|
+
};
|
|
1222
|
+
BaseAPI.prototype.clearScheduledCommit = function () {
|
|
1223
|
+
if (this._timeout) {
|
|
1224
|
+
this._timeout.cancel();
|
|
1225
|
+
this._timeout = undefined;
|
|
1226
|
+
this.apiLog("clearScheduledCommit", "cleared", enums.LogLevelEnum.DEBUG, "");
|
|
1227
|
+
}
|
|
1228
|
+
};
|
|
1229
|
+
BaseAPI.prototype._checkObjectHasProperty = function (refObject, attribute) {
|
|
1230
|
+
return (Object.hasOwnProperty.call(refObject, attribute) ||
|
|
1231
|
+
Object.getOwnPropertyDescriptor(Object.getPrototypeOf(refObject), attribute) != null ||
|
|
1232
|
+
attribute in refObject);
|
|
1233
|
+
};
|
|
1234
|
+
BaseAPI.prototype.handleValueAccessException = function (e, returnValue) {
|
|
1235
|
+
if (e instanceof exceptions.ValidationError) {
|
|
1236
|
+
this.lastErrorCode = String(e.errorCode);
|
|
1237
|
+
returnValue = api_constants.global_constants.SCORM_FALSE;
|
|
1238
|
+
}
|
|
1239
|
+
else {
|
|
1240
|
+
if (e instanceof Error && e.message) {
|
|
1241
|
+
console.error(e.message);
|
|
1242
|
+
}
|
|
1243
|
+
else {
|
|
1244
|
+
console.error(e);
|
|
1245
|
+
}
|
|
1246
|
+
this.throwSCORMError(this._error_codes.GENERAL);
|
|
1247
|
+
}
|
|
1248
|
+
return returnValue;
|
|
1249
|
+
};
|
|
1250
|
+
BaseAPI.prototype.getCommitObject = function (terminateCommit) {
|
|
1251
|
+
var shouldTerminateCommit = terminateCommit || this.settings.alwaysSendTotalTime;
|
|
1252
|
+
var commitObject = this.settings.renderCommonCommitFields
|
|
1253
|
+
? this.renderCommitObject(shouldTerminateCommit)
|
|
1254
|
+
: this.renderCommitCMI(shouldTerminateCommit);
|
|
1255
|
+
if ([enums.LogLevelEnum.DEBUG, "1", 1, "DEBUG"].includes(this.apiLogLevel)) {
|
|
1256
|
+
console.debug("Commit (terminated: " + (terminateCommit ? "yes" : "no") + "): ");
|
|
1257
|
+
console.debug(commitObject);
|
|
1258
|
+
}
|
|
1259
|
+
return commitObject;
|
|
1260
|
+
};
|
|
1261
|
+
BaseAPI.prototype.performFetch = function (url, params) {
|
|
1262
|
+
return (0,tslib_es6.__awaiter)(this, void 0, void 0, function () {
|
|
1263
|
+
var init;
|
|
1264
|
+
return (0,tslib_es6.__generator)(this, function (_a) {
|
|
1265
|
+
init = {
|
|
1266
|
+
method: "POST",
|
|
1267
|
+
mode: this.settings.fetchMode,
|
|
1268
|
+
body: params instanceof Array ? params.join("&") : JSON.stringify(params),
|
|
1269
|
+
headers: (0,tslib_es6.__assign)((0,tslib_es6.__assign)({}, this.settings.xhrHeaders), { "Content-Type": this.settings.commitRequestDataType }),
|
|
1270
|
+
keepalive: true
|
|
1271
|
+
};
|
|
1272
|
+
if (this.settings.xhrWithCredentials) {
|
|
1273
|
+
init = (0,tslib_es6.__assign)((0,tslib_es6.__assign)({}, init), { credentials: "include" });
|
|
1274
|
+
}
|
|
1275
|
+
return [2, fetch(url, init)];
|
|
1276
|
+
});
|
|
1277
|
+
});
|
|
1278
|
+
};
|
|
1279
|
+
BaseAPI.prototype.transformResponse = function (response) {
|
|
1280
|
+
return (0,tslib_es6.__awaiter)(this, void 0, void 0, function () {
|
|
1281
|
+
var result, _a;
|
|
1282
|
+
return (0,tslib_es6.__generator)(this, function (_c) {
|
|
1283
|
+
switch (_c.label) {
|
|
1284
|
+
case 0:
|
|
1285
|
+
if (!(typeof this.settings.responseHandler === "function")) return [3, 2];
|
|
1286
|
+
return [4, this.settings.responseHandler(response)];
|
|
1287
|
+
case 1:
|
|
1288
|
+
_a = _c.sent();
|
|
1289
|
+
return [3, 4];
|
|
1290
|
+
case 2: return [4, response.json()];
|
|
1291
|
+
case 3:
|
|
1292
|
+
_a = _c.sent();
|
|
1293
|
+
_c.label = 4;
|
|
1294
|
+
case 4:
|
|
1295
|
+
result = _a;
|
|
1296
|
+
if (response.status >= 200 &&
|
|
1297
|
+
response.status <= 299 &&
|
|
1298
|
+
(result.result === true || result.result === api_constants.global_constants.SCORM_TRUE)) {
|
|
1299
|
+
this.processListeners("CommitSuccess");
|
|
1300
|
+
}
|
|
1301
|
+
else {
|
|
1302
|
+
this.processListeners("CommitError");
|
|
1303
|
+
}
|
|
1304
|
+
return [2, result];
|
|
1305
|
+
}
|
|
1306
|
+
});
|
|
1307
|
+
});
|
|
1308
|
+
};
|
|
1309
|
+
return BaseAPI;
|
|
1310
|
+
}());
|
|
1311
|
+
/* harmony default export */ var src_BaseAPI = (BaseAPI);
|
|
1507
1312
|
|
|
1508
1313
|
|
|
1509
1314
|
/***/ }),
|
|
1510
1315
|
|
|
1511
|
-
/***/
|
|
1316
|
+
/***/ 434:
|
|
1512
1317
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
1513
1318
|
|
|
1514
1319
|
__webpack_require__.r(__webpack_exports__);
|
|
1515
1320
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1516
|
-
/* harmony export */
|
|
1517
|
-
/* harmony export */ scorm12_regex: function() { return /* binding */ scorm12_regex; },
|
|
1518
|
-
/* harmony export */ scorm2004_regex: function() { return /* binding */ scorm2004_regex; }
|
|
1321
|
+
/* harmony export */ CMIScore: function() { return /* binding */ CMIScore; }
|
|
1519
1322
|
/* harmony export */ });
|
|
1520
1323
|
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(635);
|
|
1324
|
+
/* harmony import */ var _constants_api_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(340);
|
|
1325
|
+
/* harmony import */ var _constants_regex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(417);
|
|
1326
|
+
/* harmony import */ var _base_cmi__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(319);
|
|
1327
|
+
/* harmony import */ var _validation__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(449);
|
|
1328
|
+
/* harmony import */ var _constants_error_codes__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(797);
|
|
1521
1329
|
|
|
1522
|
-
var scorm12_regex = {
|
|
1523
|
-
CMIString256: "^.{0,255}$",
|
|
1524
|
-
CMIString4096: "^.{0,4096}$",
|
|
1525
|
-
CMITime: "^(?:[01]\\d|2[0123]):(?:[012345]\\d):(?:[012345]\\d)$",
|
|
1526
|
-
CMITimespan: "^([0-9]{2,}):([0-9]{2}):([0-9]{2})(.[0-9]{1,2})?$",
|
|
1527
|
-
CMIInteger: "^\\d+$",
|
|
1528
|
-
CMISInteger: "^-?([0-9]+)$",
|
|
1529
|
-
CMIDecimal: "^-?([0-9]{0,3})(.[0-9]*)?$",
|
|
1530
|
-
CMIIdentifier: "^[\\u0021-\\u007E\\s]{0,255}$",
|
|
1531
|
-
CMIFeedback: "^.*$",
|
|
1532
|
-
CMIIndex: "[._](\\d+).",
|
|
1533
|
-
CMIStatus: "^(passed|completed|failed|incomplete|browsed)$",
|
|
1534
|
-
CMIStatus2: "^(passed|completed|failed|incomplete|browsed|not attempted)$",
|
|
1535
|
-
CMIExit: "^(time-out|suspend|logout|)$",
|
|
1536
|
-
CMIType: "^(true-false|choice|fill-in|matching|performance|sequencing|likert|numeric)$",
|
|
1537
|
-
CMIResult: "^(correct|wrong|unanticipated|neutral|([0-9]{0,3})?(\\.[0-9]*)?)$",
|
|
1538
|
-
NAVEvent: "^(previous|continue)$",
|
|
1539
|
-
score_range: "0#100",
|
|
1540
|
-
audio_range: "-1#100",
|
|
1541
|
-
speed_range: "-100#100",
|
|
1542
|
-
weighting_range: "-100#100",
|
|
1543
|
-
text_range: "-1#1",
|
|
1544
|
-
};
|
|
1545
|
-
var aicc_regex = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({}, scorm12_regex), {
|
|
1546
|
-
CMIIdentifier: "^\\w{1,255}$",
|
|
1547
|
-
});
|
|
1548
|
-
var scorm2004_regex = {
|
|
1549
|
-
CMIString200: "^[\\u0000-\\uFFFF]{0,200}$",
|
|
1550
|
-
CMIString250: "^[\\u0000-\\uFFFF]{0,250}$",
|
|
1551
|
-
CMIString1000: "^[\\u0000-\\uFFFF]{0,1000}$",
|
|
1552
|
-
CMIString4000: "^[\\u0000-\\uFFFF]{0,4000}$",
|
|
1553
|
-
CMIString64000: "^[\\u0000-\\uFFFF]{0,64000}$",
|
|
1554
|
-
CMILang: "^([a-zA-Z]{2,3}|i|x)(-[a-zA-Z0-9-]{2,8})?$|^$",
|
|
1555
|
-
CMILangString250: "^({lang=([a-zA-Z]{2,3}|i|x)(-[a-zA-Z0-9-]{2,8})?})?((?!{.*$).{0,250}$)?$",
|
|
1556
|
-
CMILangcr: "^(({lang=([a-zA-Z]{2,3}|i|x)?(-[a-zA-Z0-9-]{2,8})?}))(.*?)$",
|
|
1557
|
-
CMILangString250cr: "^(({lang=([a-zA-Z]{2,3}|i|x)?(-[a-zA-Z0-9-]{2,8})?})?(.{0,250})?)?$",
|
|
1558
|
-
CMILangString4000: "^({lang=([a-zA-Z]{2,3}|i|x)(-[a-zA-Z0-9-]{2,8})?})?((?!{.*$).{0,4000}$)?$",
|
|
1559
|
-
CMITime: "^(19[7-9]{1}[0-9]{1}|20[0-2]{1}[0-9]{1}|203[0-8]{1})((-(0[1-9]{1}|1[0-2]{1}))((-(0[1-9]{1}|[1-2]{1}[0-9]{1}|3[0-1]{1}))(T([0-1]{1}[0-9]{1}|2[0-3]{1})((:[0-5]{1}[0-9]{1})((:[0-5]{1}[0-9]{1})((\\.[0-9]{1,2})((Z|([+|-]([0-1]{1}[0-9]{1}|2[0-3]{1})))(:[0-5]{1}[0-9]{1})?)?)?)?)?)?)?)?$",
|
|
1560
|
-
CMITimespan: "^P(?:([.,\\d]+)Y)?(?:([.,\\d]+)M)?(?:([.,\\d]+)W)?(?:([.,\\d]+)D)?(?:T?(?:([.,\\d]+)H)?(?:([.,\\d]+)M)?(?:([.,\\d]+)S)?)?$",
|
|
1561
|
-
CMIInteger: "^\\d+$",
|
|
1562
|
-
CMISInteger: "^-?([0-9]+)$",
|
|
1563
|
-
CMIDecimal: "^-?([0-9]{1,5})(\\.[0-9]{1,18})?$",
|
|
1564
|
-
CMIIdentifier: "^\\S{1,250}[a-zA-Z0-9]$",
|
|
1565
|
-
CMIShortIdentifier: "^[\\w\\.\\-\\_]{1,250}$",
|
|
1566
|
-
CMILongIdentifier: "^(?:(?!urn:)\\S{1,4000}|urn:[A-Za-z0-9-]{1,31}:\\S{1,4000}|.{1,4000})$",
|
|
1567
|
-
CMIFeedback: "^.*$",
|
|
1568
|
-
CMIIndex: "[._](\\d+).",
|
|
1569
|
-
CMIIndexStore: ".N(\\d+).",
|
|
1570
|
-
CMICStatus: "^(completed|incomplete|not attempted|unknown)$",
|
|
1571
|
-
CMISStatus: "^(passed|failed|unknown)$",
|
|
1572
|
-
CMIExit: "^(time-out|suspend|logout|normal)$",
|
|
1573
|
-
CMIType: "^(true-false|choice|fill-in|long-fill-in|matching|performance|sequencing|likert|numeric|other)$",
|
|
1574
|
-
CMIResult: "^(correct|incorrect|unanticipated|neutral|-?([0-9]{1,4})(\\.[0-9]{1,18})?)$",
|
|
1575
|
-
NAVEvent: "^(previous|continue|exit|exitAll|abandon|abandonAll|suspendAll|_none_|(\\{target=(?<choice_target>\\S{0,}[a-zA-Z0-9-_]+)})?choice|(\\{target=(?<jump_target>\\S{0,}[a-zA-Z0-9-_]+)})?jump)$",
|
|
1576
|
-
NAVBoolean: "^(unknown|true|false$)",
|
|
1577
|
-
NAVTarget: "^{target=\\S{0,}[a-zA-Z0-9-_]+}$",
|
|
1578
|
-
scaled_range: "-1#1",
|
|
1579
|
-
audio_range: "0#*",
|
|
1580
|
-
speed_range: "0#*",
|
|
1581
|
-
text_range: "-1#1",
|
|
1582
|
-
progress_range: "0#1",
|
|
1583
|
-
};
|
|
1584
1330
|
|
|
1585
1331
|
|
|
1586
|
-
/***/ }),
|
|
1587
1332
|
|
|
1588
|
-
/***/ 784:
|
|
1589
|
-
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
1590
1333
|
|
|
1591
|
-
__webpack_require__.r(__webpack_exports__);
|
|
1592
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1593
|
-
/* harmony export */ BaseScormValidationError: function() { return /* binding */ BaseScormValidationError; },
|
|
1594
|
-
/* harmony export */ ValidationError: function() { return /* binding */ ValidationError; }
|
|
1595
|
-
/* harmony export */ });
|
|
1596
|
-
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(635);
|
|
1597
1334
|
|
|
1598
|
-
var
|
|
1599
|
-
(0,tslib__WEBPACK_IMPORTED_MODULE_0__.__extends)(
|
|
1600
|
-
function
|
|
1601
|
-
var _this = _super.call(this
|
|
1602
|
-
_this.
|
|
1603
|
-
_this.
|
|
1335
|
+
var CMIScore = (function (_super) {
|
|
1336
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_0__.__extends)(CMIScore, _super);
|
|
1337
|
+
function CMIScore(params) {
|
|
1338
|
+
var _this = _super.call(this) || this;
|
|
1339
|
+
_this._raw = "";
|
|
1340
|
+
_this._min = "";
|
|
1341
|
+
_this.__children = params.score_children || _constants_api_constants__WEBPACK_IMPORTED_MODULE_1__.scorm12_constants.score_children;
|
|
1342
|
+
_this.__score_range = !params.score_range
|
|
1343
|
+
? false
|
|
1344
|
+
: _constants_regex__WEBPACK_IMPORTED_MODULE_2__.scorm12_regex.score_range;
|
|
1345
|
+
_this._max = params.max || params.max === "" ? params.max : "100";
|
|
1346
|
+
_this.__invalid_error_code =
|
|
1347
|
+
params.invalidErrorCode || _constants_error_codes__WEBPACK_IMPORTED_MODULE_5__.scorm12_errors.INVALID_SET_VALUE;
|
|
1348
|
+
_this.__invalid_type_code =
|
|
1349
|
+
params.invalidTypeCode || _constants_error_codes__WEBPACK_IMPORTED_MODULE_5__.scorm12_errors.TYPE_MISMATCH;
|
|
1350
|
+
_this.__invalid_range_code =
|
|
1351
|
+
params.invalidRangeCode || _constants_error_codes__WEBPACK_IMPORTED_MODULE_5__.scorm12_errors.VALUE_OUT_OF_RANGE;
|
|
1352
|
+
_this.__decimal_regex = params.decimalRegex || _constants_regex__WEBPACK_IMPORTED_MODULE_2__.scorm12_regex.CMIDecimal;
|
|
1353
|
+
_this.__error_class = params.errorClass;
|
|
1604
1354
|
return _this;
|
|
1605
1355
|
}
|
|
1606
|
-
|
|
1356
|
+
CMIScore.prototype.reset = function () {
|
|
1357
|
+
this._initialized = false;
|
|
1358
|
+
};
|
|
1359
|
+
Object.defineProperty(CMIScore.prototype, "_children", {
|
|
1607
1360
|
get: function () {
|
|
1608
|
-
return this.
|
|
1361
|
+
return this.__children;
|
|
1362
|
+
},
|
|
1363
|
+
set: function (_children) {
|
|
1364
|
+
throw new this.__error_class(this.__invalid_error_code);
|
|
1609
1365
|
},
|
|
1610
1366
|
enumerable: false,
|
|
1611
1367
|
configurable: true
|
|
1612
1368
|
});
|
|
1613
|
-
|
|
1614
|
-
}(Error));
|
|
1615
|
-
|
|
1616
|
-
var ValidationError = (function (_super) {
|
|
1617
|
-
(0,tslib__WEBPACK_IMPORTED_MODULE_0__.__extends)(ValidationError, _super);
|
|
1618
|
-
function ValidationError(errorCode, errorMessage, detailedMessage) {
|
|
1619
|
-
var _this = _super.call(this, errorCode) || this;
|
|
1620
|
-
_this._detailedMessage = "";
|
|
1621
|
-
_this.message = errorMessage;
|
|
1622
|
-
_this._errorMessage = errorMessage;
|
|
1623
|
-
if (detailedMessage) {
|
|
1624
|
-
_this._detailedMessage = detailedMessage;
|
|
1625
|
-
}
|
|
1626
|
-
return _this;
|
|
1627
|
-
}
|
|
1628
|
-
Object.defineProperty(ValidationError.prototype, "errorMessage", {
|
|
1369
|
+
Object.defineProperty(CMIScore.prototype, "raw", {
|
|
1629
1370
|
get: function () {
|
|
1630
|
-
return this.
|
|
1371
|
+
return this._raw;
|
|
1372
|
+
},
|
|
1373
|
+
set: function (raw) {
|
|
1374
|
+
if ((0,_validation__WEBPACK_IMPORTED_MODULE_4__.checkValidFormat)(raw, this.__decimal_regex, this.__invalid_type_code, this.__error_class) &&
|
|
1375
|
+
(!this.__score_range ||
|
|
1376
|
+
(0,_validation__WEBPACK_IMPORTED_MODULE_4__.checkValidRange)(raw, this.__score_range, this.__invalid_range_code, this.__error_class))) {
|
|
1377
|
+
this._raw = raw;
|
|
1378
|
+
}
|
|
1631
1379
|
},
|
|
1632
1380
|
enumerable: false,
|
|
1633
1381
|
configurable: true
|
|
1634
1382
|
});
|
|
1635
|
-
Object.defineProperty(
|
|
1383
|
+
Object.defineProperty(CMIScore.prototype, "min", {
|
|
1636
1384
|
get: function () {
|
|
1637
|
-
return this.
|
|
1385
|
+
return this._min;
|
|
1386
|
+
},
|
|
1387
|
+
set: function (min) {
|
|
1388
|
+
if ((0,_validation__WEBPACK_IMPORTED_MODULE_4__.checkValidFormat)(min, this.__decimal_regex, this.__invalid_type_code, this.__error_class) &&
|
|
1389
|
+
(!this.__score_range ||
|
|
1390
|
+
(0,_validation__WEBPACK_IMPORTED_MODULE_4__.checkValidRange)(min, this.__score_range, this.__invalid_range_code, this.__error_class))) {
|
|
1391
|
+
this._min = min;
|
|
1392
|
+
}
|
|
1638
1393
|
},
|
|
1639
1394
|
enumerable: false,
|
|
1640
1395
|
configurable: true
|
|
1641
1396
|
});
|
|
1642
|
-
|
|
1643
|
-
|
|
1397
|
+
Object.defineProperty(CMIScore.prototype, "max", {
|
|
1398
|
+
get: function () {
|
|
1399
|
+
return this._max;
|
|
1400
|
+
},
|
|
1401
|
+
set: function (max) {
|
|
1402
|
+
if ((0,_validation__WEBPACK_IMPORTED_MODULE_4__.checkValidFormat)(max, this.__decimal_regex, this.__invalid_type_code, this.__error_class) &&
|
|
1403
|
+
(!this.__score_range ||
|
|
1404
|
+
(0,_validation__WEBPACK_IMPORTED_MODULE_4__.checkValidRange)(max, this.__score_range, this.__invalid_range_code, this.__error_class))) {
|
|
1405
|
+
this._max = max;
|
|
1406
|
+
}
|
|
1407
|
+
},
|
|
1408
|
+
enumerable: false,
|
|
1409
|
+
configurable: true
|
|
1410
|
+
});
|
|
1411
|
+
CMIScore.prototype.toJSON = function () {
|
|
1412
|
+
this.jsonString = true;
|
|
1413
|
+
var result = {
|
|
1414
|
+
raw: this.raw,
|
|
1415
|
+
min: this.min,
|
|
1416
|
+
max: this.max,
|
|
1417
|
+
};
|
|
1418
|
+
delete this.jsonString;
|
|
1419
|
+
return result;
|
|
1420
|
+
};
|
|
1421
|
+
return CMIScore;
|
|
1422
|
+
}(_base_cmi__WEBPACK_IMPORTED_MODULE_3__.BaseCMI));
|
|
1644
1423
|
|
|
1645
1424
|
|
|
1646
1425
|
|
|
1647
1426
|
/***/ }),
|
|
1648
1427
|
|
|
1649
|
-
/***/
|
|
1428
|
+
/***/ 449:
|
|
1650
1429
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
1651
1430
|
|
|
1652
1431
|
__webpack_require__.r(__webpack_exports__);
|
|
1653
1432
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1654
|
-
/* harmony export */
|
|
1655
|
-
/* harmony export */
|
|
1656
|
-
/* harmony export */ SECONDS_PER_MINUTE: function() { return /* binding */ SECONDS_PER_MINUTE; },
|
|
1657
|
-
/* harmony export */ SECONDS_PER_SECOND: function() { return /* binding */ SECONDS_PER_SECOND; },
|
|
1658
|
-
/* harmony export */ addHHMMSSTimeStrings: function() { return /* binding */ addHHMMSSTimeStrings; },
|
|
1659
|
-
/* harmony export */ addTwoDurations: function() { return /* binding */ addTwoDurations; },
|
|
1660
|
-
/* harmony export */ countDecimals: function() { return /* binding */ countDecimals; },
|
|
1661
|
-
/* harmony export */ flatten: function() { return /* binding */ flatten; },
|
|
1662
|
-
/* harmony export */ formatMessage: function() { return /* binding */ formatMessage; },
|
|
1663
|
-
/* harmony export */ getDurationAsSeconds: function() { return /* binding */ getDurationAsSeconds; },
|
|
1664
|
-
/* harmony export */ getSecondsAsHHMMSS: function() { return /* binding */ getSecondsAsHHMMSS; },
|
|
1665
|
-
/* harmony export */ getSecondsAsISODuration: function() { return /* binding */ getSecondsAsISODuration; },
|
|
1666
|
-
/* harmony export */ getTimeAsSeconds: function() { return /* binding */ getTimeAsSeconds; },
|
|
1667
|
-
/* harmony export */ stringMatches: function() { return /* binding */ stringMatches; },
|
|
1668
|
-
/* harmony export */ unflatten: function() { return /* binding */ unflatten; }
|
|
1433
|
+
/* harmony export */ checkValidFormat: function() { return /* binding */ checkValidFormat; },
|
|
1434
|
+
/* harmony export */ checkValidRange: function() { return /* binding */ checkValidRange; }
|
|
1669
1435
|
/* harmony export */ });
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
var SECONDS_PER_DAY = 24 * SECONDS_PER_HOUR;
|
|
1674
|
-
var designations = {
|
|
1675
|
-
D: SECONDS_PER_DAY,
|
|
1676
|
-
H: SECONDS_PER_HOUR,
|
|
1677
|
-
M: SECONDS_PER_MINUTE,
|
|
1678
|
-
S: SECONDS_PER_SECOND,
|
|
1679
|
-
};
|
|
1680
|
-
function getSecondsAsHHMMSS(totalSeconds) {
|
|
1681
|
-
if (!totalSeconds || totalSeconds <= 0) {
|
|
1682
|
-
return "00:00:00";
|
|
1683
|
-
}
|
|
1684
|
-
var hours = Math.floor(totalSeconds / SECONDS_PER_HOUR);
|
|
1685
|
-
var dateObj = new Date(totalSeconds * 1000);
|
|
1686
|
-
var minutes = dateObj.getUTCMinutes();
|
|
1687
|
-
var seconds = dateObj.getSeconds();
|
|
1688
|
-
var ms = totalSeconds % 1.0;
|
|
1689
|
-
var msStr = "";
|
|
1690
|
-
if (countDecimals(ms) > 0) {
|
|
1691
|
-
if (countDecimals(ms) > 2) {
|
|
1692
|
-
msStr = ms.toFixed(2);
|
|
1693
|
-
}
|
|
1694
|
-
else {
|
|
1695
|
-
msStr = String(ms);
|
|
1696
|
-
}
|
|
1697
|
-
msStr = "." + msStr.split(".")[1];
|
|
1698
|
-
}
|
|
1699
|
-
return ((hours + ":" + minutes + ":" + seconds).replace(/\b\d\b/g, "0$&") + msStr);
|
|
1700
|
-
}
|
|
1701
|
-
function getSecondsAsISODuration(seconds) {
|
|
1702
|
-
if (!seconds || seconds <= 0) {
|
|
1703
|
-
return "PT0S";
|
|
1704
|
-
}
|
|
1705
|
-
var duration = "P";
|
|
1706
|
-
var remainder = seconds;
|
|
1707
|
-
for (var designationsKey in designations) {
|
|
1708
|
-
var current_seconds = designations[designationsKey] || 1;
|
|
1709
|
-
var value = Math.floor(remainder / current_seconds);
|
|
1710
|
-
remainder = remainder % current_seconds;
|
|
1711
|
-
if (countDecimals(remainder) > 2) {
|
|
1712
|
-
remainder = Number(Number(remainder).toFixed(2));
|
|
1713
|
-
}
|
|
1714
|
-
if (designationsKey === "S" && remainder > 0) {
|
|
1715
|
-
value += remainder;
|
|
1716
|
-
}
|
|
1717
|
-
if (value) {
|
|
1718
|
-
if ((duration.indexOf("D") > 0 ||
|
|
1719
|
-
designationsKey === "H" ||
|
|
1720
|
-
designationsKey === "M" ||
|
|
1721
|
-
designationsKey === "S") &&
|
|
1722
|
-
duration.indexOf("T") === -1) {
|
|
1723
|
-
duration += "T";
|
|
1724
|
-
}
|
|
1725
|
-
duration += "".concat(value).concat(designationsKey);
|
|
1726
|
-
}
|
|
1727
|
-
}
|
|
1728
|
-
return duration;
|
|
1729
|
-
}
|
|
1730
|
-
function getTimeAsSeconds(timeString, timeRegex) {
|
|
1731
|
-
if (typeof timeString === "number" || typeof timeString === "boolean") {
|
|
1732
|
-
timeString = String(timeString);
|
|
1733
|
-
}
|
|
1734
|
-
if (typeof timeRegex === "string") {
|
|
1735
|
-
timeRegex = new RegExp(timeRegex);
|
|
1736
|
-
}
|
|
1737
|
-
if (!timeString || !timeString.match(timeRegex)) {
|
|
1738
|
-
return 0;
|
|
1739
|
-
}
|
|
1740
|
-
var parts = timeString.split(":");
|
|
1741
|
-
var hours = Number(parts[0]);
|
|
1742
|
-
var minutes = Number(parts[1]);
|
|
1743
|
-
var seconds = Number(parts[2]);
|
|
1744
|
-
return hours * 3600 + minutes * 60 + seconds;
|
|
1745
|
-
}
|
|
1746
|
-
function getDurationAsSeconds(duration, durationRegex) {
|
|
1747
|
-
if (typeof durationRegex === "string") {
|
|
1748
|
-
durationRegex = new RegExp(durationRegex);
|
|
1749
|
-
}
|
|
1750
|
-
if (!duration || !duration.match(durationRegex)) {
|
|
1751
|
-
return 0;
|
|
1752
|
-
}
|
|
1753
|
-
var _a = new RegExp(durationRegex).exec(duration) || [], years = _a[1], _ = _a[2], days = _a[4], hours = _a[5], minutes = _a[6], seconds = _a[7];
|
|
1754
|
-
var result = 0.0;
|
|
1755
|
-
result += Number(seconds) || 0.0;
|
|
1756
|
-
result += Number(minutes) * 60.0 || 0.0;
|
|
1757
|
-
result += Number(hours) * 3600.0 || 0.0;
|
|
1758
|
-
result += Number(days) * (60 * 60 * 24.0) || 0.0;
|
|
1759
|
-
result += Number(years) * (60 * 60 * 24 * 365.0) || 0.0;
|
|
1760
|
-
return result;
|
|
1761
|
-
}
|
|
1762
|
-
function addTwoDurations(first, second, durationRegex) {
|
|
1763
|
-
var regex = typeof durationRegex === "string"
|
|
1764
|
-
? new RegExp(durationRegex)
|
|
1765
|
-
: durationRegex;
|
|
1766
|
-
return getSecondsAsISODuration(getDurationAsSeconds(first, regex) + getDurationAsSeconds(second, regex));
|
|
1767
|
-
}
|
|
1768
|
-
function addHHMMSSTimeStrings(first, second, timeRegex) {
|
|
1769
|
-
if (typeof timeRegex === "string") {
|
|
1770
|
-
timeRegex = new RegExp(timeRegex);
|
|
1771
|
-
}
|
|
1772
|
-
return getSecondsAsHHMMSS(getTimeAsSeconds(first, timeRegex) + getTimeAsSeconds(second, timeRegex));
|
|
1773
|
-
}
|
|
1774
|
-
function flatten(data) {
|
|
1775
|
-
var result = {};
|
|
1776
|
-
function recurse(cur, prop) {
|
|
1777
|
-
if (Object(cur) !== cur) {
|
|
1778
|
-
result[prop] = cur;
|
|
1779
|
-
}
|
|
1780
|
-
else if (Array.isArray(cur)) {
|
|
1781
|
-
for (var i = 0, l = cur.length; i < l; i++) {
|
|
1782
|
-
recurse(cur[i], prop + "[" + i + "]");
|
|
1783
|
-
if (l === 0)
|
|
1784
|
-
result[prop] = [];
|
|
1785
|
-
}
|
|
1786
|
-
}
|
|
1787
|
-
else {
|
|
1788
|
-
var isEmpty = true;
|
|
1789
|
-
for (var p in cur) {
|
|
1790
|
-
if ({}.hasOwnProperty.call(cur, p)) {
|
|
1791
|
-
isEmpty = false;
|
|
1792
|
-
recurse(cur[p], prop ? prop + "." + p : p);
|
|
1793
|
-
}
|
|
1794
|
-
}
|
|
1795
|
-
if (isEmpty && prop)
|
|
1796
|
-
result[prop] = {};
|
|
1797
|
-
}
|
|
1436
|
+
function checkValidFormat(value, regexPattern, errorCode, errorClass, allowEmptyString) {
|
|
1437
|
+
if (typeof value !== "string") {
|
|
1438
|
+
return false;
|
|
1798
1439
|
}
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
"use strict";
|
|
1804
|
-
if (Object(data) !== data || Array.isArray(data))
|
|
1805
|
-
return data;
|
|
1806
|
-
var regex = /\.?([^.[\]]+)|\[(\d+)]/g;
|
|
1807
|
-
var result = {};
|
|
1808
|
-
for (var p in data) {
|
|
1809
|
-
if ({}.hasOwnProperty.call(data, p)) {
|
|
1810
|
-
var cur = result;
|
|
1811
|
-
var prop = "";
|
|
1812
|
-
var m = regex.exec(p);
|
|
1813
|
-
while (m) {
|
|
1814
|
-
cur = cur[prop] || (cur[prop] = m[2] ? [] : {});
|
|
1815
|
-
prop = m[2] || m[1] || "";
|
|
1816
|
-
m = regex.exec(p);
|
|
1817
|
-
}
|
|
1818
|
-
cur[prop] = data[p];
|
|
1819
|
-
}
|
|
1440
|
+
var formatRegex = new RegExp(regexPattern);
|
|
1441
|
+
var matches = value.match(formatRegex);
|
|
1442
|
+
if (allowEmptyString && value === "") {
|
|
1443
|
+
return true;
|
|
1820
1444
|
}
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
function countDecimals(num) {
|
|
1824
|
-
if (Math.floor(num) === num || String(num).indexOf(".") < 0)
|
|
1825
|
-
return 0;
|
|
1826
|
-
var parts = num.toString().split(".")[1];
|
|
1827
|
-
return (parts === null || parts === void 0 ? void 0 : parts.length) || 0;
|
|
1828
|
-
}
|
|
1829
|
-
function formatMessage(functionName, message, CMIElement) {
|
|
1830
|
-
var baseLength = 20;
|
|
1831
|
-
var messageString = "";
|
|
1832
|
-
messageString += functionName;
|
|
1833
|
-
var fillChars = baseLength - messageString.length;
|
|
1834
|
-
for (var i = 0; i < fillChars; i++) {
|
|
1835
|
-
messageString += " ";
|
|
1445
|
+
if (value === undefined || !matches || matches[0] === "") {
|
|
1446
|
+
throw new errorClass(errorCode);
|
|
1836
1447
|
}
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1448
|
+
return true;
|
|
1449
|
+
}
|
|
1450
|
+
function checkValidRange(value, rangePattern, errorCode, errorClass) {
|
|
1451
|
+
var ranges = rangePattern.split("#");
|
|
1452
|
+
value = value * 1.0;
|
|
1453
|
+
if (ranges[0] && value >= ranges[0]) {
|
|
1454
|
+
if (ranges[1] && (ranges[1] === "*" || value <= ranges[1])) {
|
|
1455
|
+
return true;
|
|
1456
|
+
}
|
|
1457
|
+
else {
|
|
1458
|
+
throw new errorClass(errorCode);
|
|
1844
1459
|
}
|
|
1845
1460
|
}
|
|
1846
|
-
|
|
1847
|
-
|
|
1461
|
+
else {
|
|
1462
|
+
throw new errorClass(errorCode);
|
|
1848
1463
|
}
|
|
1849
|
-
return messageString;
|
|
1850
|
-
}
|
|
1851
|
-
function stringMatches(str, tester) {
|
|
1852
|
-
return (str === null || str === void 0 ? void 0 : str.match(tester)) !== null;
|
|
1853
1464
|
}
|
|
1854
1465
|
|
|
1855
1466
|
|
|
1467
|
+
/***/ }),
|
|
1468
|
+
|
|
1469
|
+
/***/ 589:
|
|
1470
|
+
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
1471
|
+
|
|
1472
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1473
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1474
|
+
/* harmony export */ CMIArray: function() { return /* binding */ CMIArray; }
|
|
1475
|
+
/* harmony export */ });
|
|
1476
|
+
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(635);
|
|
1477
|
+
/* harmony import */ var _base_cmi__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(319);
|
|
1478
|
+
/* harmony import */ var _exceptions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(784);
|
|
1479
|
+
/* harmony import */ var _constants_error_codes__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(797);
|
|
1480
|
+
|
|
1481
|
+
|
|
1482
|
+
|
|
1483
|
+
|
|
1484
|
+
var CMIArray = (function (_super) {
|
|
1485
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_0__.__extends)(CMIArray, _super);
|
|
1486
|
+
function CMIArray(params) {
|
|
1487
|
+
var _this = _super.call(this) || this;
|
|
1488
|
+
_this.__children = params.children;
|
|
1489
|
+
_this._errorCode = params.errorCode || _constants_error_codes__WEBPACK_IMPORTED_MODULE_3__.scorm12_errors.GENERAL;
|
|
1490
|
+
_this._errorClass = params.errorClass || _exceptions__WEBPACK_IMPORTED_MODULE_2__.BaseScormValidationError;
|
|
1491
|
+
_this.childArray = [];
|
|
1492
|
+
return _this;
|
|
1493
|
+
}
|
|
1494
|
+
CMIArray.prototype.reset = function (wipe) {
|
|
1495
|
+
if (wipe === void 0) { wipe = false; }
|
|
1496
|
+
this._initialized = false;
|
|
1497
|
+
if (wipe) {
|
|
1498
|
+
this.childArray = [];
|
|
1499
|
+
}
|
|
1500
|
+
else {
|
|
1501
|
+
for (var i = 0; i < this.childArray.length; i++) {
|
|
1502
|
+
this.childArray[i].reset();
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
};
|
|
1506
|
+
Object.defineProperty(CMIArray.prototype, "_children", {
|
|
1507
|
+
get: function () {
|
|
1508
|
+
return this.__children;
|
|
1509
|
+
},
|
|
1510
|
+
set: function (_children) {
|
|
1511
|
+
throw new this._errorClass(this._errorCode);
|
|
1512
|
+
},
|
|
1513
|
+
enumerable: false,
|
|
1514
|
+
configurable: true
|
|
1515
|
+
});
|
|
1516
|
+
Object.defineProperty(CMIArray.prototype, "_count", {
|
|
1517
|
+
get: function () {
|
|
1518
|
+
return this.childArray.length;
|
|
1519
|
+
},
|
|
1520
|
+
set: function (_count) {
|
|
1521
|
+
throw new this._errorClass(this._errorCode);
|
|
1522
|
+
},
|
|
1523
|
+
enumerable: false,
|
|
1524
|
+
configurable: true
|
|
1525
|
+
});
|
|
1526
|
+
CMIArray.prototype.toJSON = function () {
|
|
1527
|
+
this.jsonString = true;
|
|
1528
|
+
var result = {};
|
|
1529
|
+
for (var i = 0; i < this.childArray.length; i++) {
|
|
1530
|
+
result[i + ""] = this.childArray[i];
|
|
1531
|
+
}
|
|
1532
|
+
delete this.jsonString;
|
|
1533
|
+
return result;
|
|
1534
|
+
};
|
|
1535
|
+
return CMIArray;
|
|
1536
|
+
}(_base_cmi__WEBPACK_IMPORTED_MODULE_1__.BaseCMI));
|
|
1537
|
+
|
|
1538
|
+
|
|
1539
|
+
|
|
1856
1540
|
/***/ }),
|
|
1857
1541
|
|
|
1858
1542
|
/***/ 635:
|
|
@@ -1885,6 +1569,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1885
1569
|
/* harmony export */ __propKey: function() { return /* binding */ __propKey; },
|
|
1886
1570
|
/* harmony export */ __read: function() { return /* binding */ __read; },
|
|
1887
1571
|
/* harmony export */ __rest: function() { return /* binding */ __rest; },
|
|
1572
|
+
/* harmony export */ __rewriteRelativeImportExtension: function() { return /* binding */ __rewriteRelativeImportExtension; },
|
|
1888
1573
|
/* harmony export */ __runInitializers: function() { return /* binding */ __runInitializers; },
|
|
1889
1574
|
/* harmony export */ __setFunctionName: function() { return /* binding */ __setFunctionName; },
|
|
1890
1575
|
/* harmony export */ __spread: function() { return /* binding */ __spread; },
|
|
@@ -2079,197 +1764,537 @@ function __read(o, n) {
|
|
|
2079
1764
|
try {
|
|
2080
1765
|
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
2081
1766
|
}
|
|
2082
|
-
catch (error) { e = { error: error }; }
|
|
2083
|
-
finally {
|
|
1767
|
+
catch (error) { e = { error: error }; }
|
|
1768
|
+
finally {
|
|
1769
|
+
try {
|
|
1770
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
1771
|
+
}
|
|
1772
|
+
finally { if (e) throw e.error; }
|
|
1773
|
+
}
|
|
1774
|
+
return ar;
|
|
1775
|
+
}
|
|
1776
|
+
|
|
1777
|
+
/** @deprecated */
|
|
1778
|
+
function __spread() {
|
|
1779
|
+
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
1780
|
+
ar = ar.concat(__read(arguments[i]));
|
|
1781
|
+
return ar;
|
|
1782
|
+
}
|
|
1783
|
+
|
|
1784
|
+
/** @deprecated */
|
|
1785
|
+
function __spreadArrays() {
|
|
1786
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
1787
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
1788
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
1789
|
+
r[k] = a[j];
|
|
1790
|
+
return r;
|
|
1791
|
+
}
|
|
1792
|
+
|
|
1793
|
+
function __spreadArray(to, from, pack) {
|
|
1794
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
1795
|
+
if (ar || !(i in from)) {
|
|
1796
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
1797
|
+
ar[i] = from[i];
|
|
1798
|
+
}
|
|
1799
|
+
}
|
|
1800
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
1801
|
+
}
|
|
1802
|
+
|
|
1803
|
+
function __await(v) {
|
|
1804
|
+
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
1805
|
+
}
|
|
1806
|
+
|
|
1807
|
+
function __asyncGenerator(thisArg, _arguments, generator) {
|
|
1808
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
1809
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
1810
|
+
return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
1811
|
+
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
|
|
1812
|
+
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
|
|
1813
|
+
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
1814
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
1815
|
+
function fulfill(value) { resume("next", value); }
|
|
1816
|
+
function reject(value) { resume("throw", value); }
|
|
1817
|
+
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
1818
|
+
}
|
|
1819
|
+
|
|
1820
|
+
function __asyncDelegator(o) {
|
|
1821
|
+
var i, p;
|
|
1822
|
+
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
|
1823
|
+
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
|
|
1824
|
+
}
|
|
1825
|
+
|
|
1826
|
+
function __asyncValues(o) {
|
|
1827
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
1828
|
+
var m = o[Symbol.asyncIterator], i;
|
|
1829
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
1830
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
1831
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
1832
|
+
}
|
|
1833
|
+
|
|
1834
|
+
function __makeTemplateObject(cooked, raw) {
|
|
1835
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
1836
|
+
return cooked;
|
|
1837
|
+
};
|
|
1838
|
+
|
|
1839
|
+
var __setModuleDefault = Object.create ? (function(o, v) {
|
|
1840
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
1841
|
+
}) : function(o, v) {
|
|
1842
|
+
o["default"] = v;
|
|
1843
|
+
};
|
|
1844
|
+
|
|
1845
|
+
var ownKeys = function(o) {
|
|
1846
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
1847
|
+
var ar = [];
|
|
1848
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
1849
|
+
return ar;
|
|
1850
|
+
};
|
|
1851
|
+
return ownKeys(o);
|
|
1852
|
+
};
|
|
1853
|
+
|
|
1854
|
+
function __importStar(mod) {
|
|
1855
|
+
if (mod && mod.__esModule) return mod;
|
|
1856
|
+
var result = {};
|
|
1857
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
1858
|
+
__setModuleDefault(result, mod);
|
|
1859
|
+
return result;
|
|
1860
|
+
}
|
|
1861
|
+
|
|
1862
|
+
function __importDefault(mod) {
|
|
1863
|
+
return (mod && mod.__esModule) ? mod : { default: mod };
|
|
1864
|
+
}
|
|
1865
|
+
|
|
1866
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
1867
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
1868
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
1869
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
1870
|
+
}
|
|
1871
|
+
|
|
1872
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
1873
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
1874
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
1875
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
1876
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
1877
|
+
}
|
|
1878
|
+
|
|
1879
|
+
function __classPrivateFieldIn(state, receiver) {
|
|
1880
|
+
if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object");
|
|
1881
|
+
return typeof state === "function" ? receiver === state : state.has(receiver);
|
|
1882
|
+
}
|
|
1883
|
+
|
|
1884
|
+
function __addDisposableResource(env, value, async) {
|
|
1885
|
+
if (value !== null && value !== void 0) {
|
|
1886
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
1887
|
+
var dispose, inner;
|
|
1888
|
+
if (async) {
|
|
1889
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
1890
|
+
dispose = value[Symbol.asyncDispose];
|
|
1891
|
+
}
|
|
1892
|
+
if (dispose === void 0) {
|
|
1893
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
1894
|
+
dispose = value[Symbol.dispose];
|
|
1895
|
+
if (async) inner = dispose;
|
|
1896
|
+
}
|
|
1897
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
1898
|
+
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
1899
|
+
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
1900
|
+
}
|
|
1901
|
+
else if (async) {
|
|
1902
|
+
env.stack.push({ async: true });
|
|
1903
|
+
}
|
|
1904
|
+
return value;
|
|
1905
|
+
}
|
|
1906
|
+
|
|
1907
|
+
var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
1908
|
+
var e = new Error(message);
|
|
1909
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
1910
|
+
};
|
|
1911
|
+
|
|
1912
|
+
function __disposeResources(env) {
|
|
1913
|
+
function fail(e) {
|
|
1914
|
+
env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
1915
|
+
env.hasError = true;
|
|
1916
|
+
}
|
|
1917
|
+
var r, s = 0;
|
|
1918
|
+
function next() {
|
|
1919
|
+
while (r = env.stack.pop()) {
|
|
2084
1920
|
try {
|
|
2085
|
-
|
|
1921
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
1922
|
+
if (r.dispose) {
|
|
1923
|
+
var result = r.dispose.call(r.value);
|
|
1924
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
1925
|
+
}
|
|
1926
|
+
else s |= 1;
|
|
2086
1927
|
}
|
|
2087
|
-
|
|
1928
|
+
catch (e) {
|
|
1929
|
+
fail(e);
|
|
1930
|
+
}
|
|
1931
|
+
}
|
|
1932
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
1933
|
+
if (env.hasError) throw env.error;
|
|
2088
1934
|
}
|
|
2089
|
-
return
|
|
1935
|
+
return next();
|
|
2090
1936
|
}
|
|
2091
1937
|
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
1938
|
+
function __rewriteRelativeImportExtension(path, preserveJsx) {
|
|
1939
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
1940
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
1941
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
1942
|
+
});
|
|
1943
|
+
}
|
|
1944
|
+
return path;
|
|
2097
1945
|
}
|
|
2098
1946
|
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
1947
|
+
/* harmony default export */ __webpack_exports__["default"] = ({
|
|
1948
|
+
__extends,
|
|
1949
|
+
__assign,
|
|
1950
|
+
__rest,
|
|
1951
|
+
__decorate,
|
|
1952
|
+
__param,
|
|
1953
|
+
__esDecorate,
|
|
1954
|
+
__runInitializers,
|
|
1955
|
+
__propKey,
|
|
1956
|
+
__setFunctionName,
|
|
1957
|
+
__metadata,
|
|
1958
|
+
__awaiter,
|
|
1959
|
+
__generator,
|
|
1960
|
+
__createBinding,
|
|
1961
|
+
__exportStar,
|
|
1962
|
+
__values,
|
|
1963
|
+
__read,
|
|
1964
|
+
__spread,
|
|
1965
|
+
__spreadArrays,
|
|
1966
|
+
__spreadArray,
|
|
1967
|
+
__await,
|
|
1968
|
+
__asyncGenerator,
|
|
1969
|
+
__asyncDelegator,
|
|
1970
|
+
__asyncValues,
|
|
1971
|
+
__makeTemplateObject,
|
|
1972
|
+
__importStar,
|
|
1973
|
+
__importDefault,
|
|
1974
|
+
__classPrivateFieldGet,
|
|
1975
|
+
__classPrivateFieldSet,
|
|
1976
|
+
__classPrivateFieldIn,
|
|
1977
|
+
__addDisposableResource,
|
|
1978
|
+
__disposeResources,
|
|
1979
|
+
__rewriteRelativeImportExtension,
|
|
1980
|
+
});
|
|
2107
1981
|
|
|
2108
|
-
function __spreadArray(to, from, pack) {
|
|
2109
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
2110
|
-
if (ar || !(i in from)) {
|
|
2111
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
2112
|
-
ar[i] = from[i];
|
|
2113
|
-
}
|
|
2114
|
-
}
|
|
2115
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
2116
|
-
}
|
|
2117
1982
|
|
|
2118
|
-
|
|
2119
|
-
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
2120
|
-
}
|
|
1983
|
+
/***/ }),
|
|
2121
1984
|
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
2125
|
-
return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
2126
|
-
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
|
|
2127
|
-
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
|
|
2128
|
-
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
2129
|
-
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
2130
|
-
function fulfill(value) { resume("next", value); }
|
|
2131
|
-
function reject(value) { resume("throw", value); }
|
|
2132
|
-
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
2133
|
-
}
|
|
1985
|
+
/***/ 784:
|
|
1986
|
+
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
2134
1987
|
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
}
|
|
1988
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1989
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1990
|
+
/* harmony export */ BaseScormValidationError: function() { return /* binding */ BaseScormValidationError; },
|
|
1991
|
+
/* harmony export */ ValidationError: function() { return /* binding */ ValidationError; }
|
|
1992
|
+
/* harmony export */ });
|
|
1993
|
+
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(635);
|
|
2140
1994
|
|
|
2141
|
-
function
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
1995
|
+
var BaseScormValidationError = (function (_super) {
|
|
1996
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_0__.__extends)(BaseScormValidationError, _super);
|
|
1997
|
+
function BaseScormValidationError(errorCode) {
|
|
1998
|
+
var _this = _super.call(this, errorCode.toString()) || this;
|
|
1999
|
+
_this._errorCode = errorCode;
|
|
2000
|
+
_this.name = "ScormValidationError";
|
|
2001
|
+
return _this;
|
|
2002
|
+
}
|
|
2003
|
+
Object.defineProperty(BaseScormValidationError.prototype, "errorCode", {
|
|
2004
|
+
get: function () {
|
|
2005
|
+
return this._errorCode;
|
|
2006
|
+
},
|
|
2007
|
+
enumerable: false,
|
|
2008
|
+
configurable: true
|
|
2009
|
+
});
|
|
2010
|
+
return BaseScormValidationError;
|
|
2011
|
+
}(Error));
|
|
2012
|
+
|
|
2013
|
+
var ValidationError = (function (_super) {
|
|
2014
|
+
(0,tslib__WEBPACK_IMPORTED_MODULE_0__.__extends)(ValidationError, _super);
|
|
2015
|
+
function ValidationError(errorCode, errorMessage, detailedMessage) {
|
|
2016
|
+
var _this = _super.call(this, errorCode) || this;
|
|
2017
|
+
_this._detailedMessage = "";
|
|
2018
|
+
_this.message = errorMessage;
|
|
2019
|
+
_this._errorMessage = errorMessage;
|
|
2020
|
+
if (detailedMessage) {
|
|
2021
|
+
_this._detailedMessage = detailedMessage;
|
|
2022
|
+
}
|
|
2023
|
+
return _this;
|
|
2024
|
+
}
|
|
2025
|
+
Object.defineProperty(ValidationError.prototype, "errorMessage", {
|
|
2026
|
+
get: function () {
|
|
2027
|
+
return this._errorMessage;
|
|
2028
|
+
},
|
|
2029
|
+
enumerable: false,
|
|
2030
|
+
configurable: true
|
|
2031
|
+
});
|
|
2032
|
+
Object.defineProperty(ValidationError.prototype, "detailedMessage", {
|
|
2033
|
+
get: function () {
|
|
2034
|
+
return this._detailedMessage;
|
|
2035
|
+
},
|
|
2036
|
+
enumerable: false,
|
|
2037
|
+
configurable: true
|
|
2038
|
+
});
|
|
2039
|
+
return ValidationError;
|
|
2040
|
+
}(BaseScormValidationError));
|
|
2041
|
+
|
|
2042
|
+
|
|
2043
|
+
|
|
2044
|
+
/***/ }),
|
|
2045
|
+
|
|
2046
|
+
/***/ 797:
|
|
2047
|
+
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
2048
|
+
|
|
2049
|
+
__webpack_require__.r(__webpack_exports__);
|
|
2050
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2051
|
+
/* harmony export */ global_errors: function() { return /* binding */ global_errors; },
|
|
2052
|
+
/* harmony export */ scorm12_errors: function() { return /* binding */ scorm12_errors; },
|
|
2053
|
+
/* harmony export */ scorm2004_errors: function() { return /* binding */ scorm2004_errors; }
|
|
2054
|
+
/* harmony export */ });
|
|
2055
|
+
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(635);
|
|
2056
|
+
|
|
2057
|
+
var global_errors = {
|
|
2058
|
+
GENERAL: 101,
|
|
2059
|
+
INITIALIZATION_FAILED: 101,
|
|
2060
|
+
INITIALIZED: 101,
|
|
2061
|
+
TERMINATED: 101,
|
|
2062
|
+
TERMINATION_FAILURE: 101,
|
|
2063
|
+
TERMINATION_BEFORE_INIT: 101,
|
|
2064
|
+
MULTIPLE_TERMINATION: 101,
|
|
2065
|
+
RETRIEVE_BEFORE_INIT: 101,
|
|
2066
|
+
RETRIEVE_AFTER_TERM: 101,
|
|
2067
|
+
STORE_BEFORE_INIT: 101,
|
|
2068
|
+
STORE_AFTER_TERM: 101,
|
|
2069
|
+
COMMIT_BEFORE_INIT: 101,
|
|
2070
|
+
COMMIT_AFTER_TERM: 101,
|
|
2071
|
+
ARGUMENT_ERROR: 101,
|
|
2072
|
+
CHILDREN_ERROR: 101,
|
|
2073
|
+
COUNT_ERROR: 101,
|
|
2074
|
+
GENERAL_GET_FAILURE: 101,
|
|
2075
|
+
GENERAL_SET_FAILURE: 101,
|
|
2076
|
+
GENERAL_COMMIT_FAILURE: 101,
|
|
2077
|
+
UNDEFINED_DATA_MODEL: 101,
|
|
2078
|
+
UNIMPLEMENTED_ELEMENT: 101,
|
|
2079
|
+
VALUE_NOT_INITIALIZED: 101,
|
|
2080
|
+
INVALID_SET_VALUE: 101,
|
|
2081
|
+
READ_ONLY_ELEMENT: 101,
|
|
2082
|
+
WRITE_ONLY_ELEMENT: 101,
|
|
2083
|
+
TYPE_MISMATCH: 101,
|
|
2084
|
+
VALUE_OUT_OF_RANGE: 101,
|
|
2085
|
+
DEPENDENCY_NOT_ESTABLISHED: 101,
|
|
2086
|
+
};
|
|
2087
|
+
var scorm12_errors = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({}, global_errors), { RETRIEVE_BEFORE_INIT: 301, STORE_BEFORE_INIT: 301, COMMIT_BEFORE_INIT: 301, ARGUMENT_ERROR: 201, CHILDREN_ERROR: 202, COUNT_ERROR: 203, UNDEFINED_DATA_MODEL: 401, UNIMPLEMENTED_ELEMENT: 401, VALUE_NOT_INITIALIZED: 301, INVALID_SET_VALUE: 402, READ_ONLY_ELEMENT: 403, WRITE_ONLY_ELEMENT: 404, TYPE_MISMATCH: 405, VALUE_OUT_OF_RANGE: 407, DEPENDENCY_NOT_ESTABLISHED: 408 });
|
|
2088
|
+
var scorm2004_errors = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({}, global_errors), { INITIALIZATION_FAILED: 102, INITIALIZED: 103, TERMINATED: 104, TERMINATION_FAILURE: 111, TERMINATION_BEFORE_INIT: 112, MULTIPLE_TERMINATIONS: 113, RETRIEVE_BEFORE_INIT: 122, RETRIEVE_AFTER_TERM: 123, STORE_BEFORE_INIT: 132, STORE_AFTER_TERM: 133, COMMIT_BEFORE_INIT: 142, COMMIT_AFTER_TERM: 143, ARGUMENT_ERROR: 201, GENERAL_GET_FAILURE: 301, GENERAL_SET_FAILURE: 351, GENERAL_COMMIT_FAILURE: 391, UNDEFINED_DATA_MODEL: 401, UNIMPLEMENTED_ELEMENT: 402, VALUE_NOT_INITIALIZED: 403, READ_ONLY_ELEMENT: 404, WRITE_ONLY_ELEMENT: 405, TYPE_MISMATCH: 406, VALUE_OUT_OF_RANGE: 407, DEPENDENCY_NOT_ESTABLISHED: 408 });
|
|
2089
|
+
|
|
2090
|
+
|
|
2091
|
+
/***/ }),
|
|
2092
|
+
|
|
2093
|
+
/***/ 864:
|
|
2094
|
+
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
2095
|
+
|
|
2096
|
+
__webpack_require__.r(__webpack_exports__);
|
|
2097
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2098
|
+
/* harmony export */ SECONDS_PER_DAY: function() { return /* binding */ SECONDS_PER_DAY; },
|
|
2099
|
+
/* harmony export */ SECONDS_PER_HOUR: function() { return /* binding */ SECONDS_PER_HOUR; },
|
|
2100
|
+
/* harmony export */ SECONDS_PER_MINUTE: function() { return /* binding */ SECONDS_PER_MINUTE; },
|
|
2101
|
+
/* harmony export */ SECONDS_PER_SECOND: function() { return /* binding */ SECONDS_PER_SECOND; },
|
|
2102
|
+
/* harmony export */ addHHMMSSTimeStrings: function() { return /* binding */ addHHMMSSTimeStrings; },
|
|
2103
|
+
/* harmony export */ addTwoDurations: function() { return /* binding */ addTwoDurations; },
|
|
2104
|
+
/* harmony export */ countDecimals: function() { return /* binding */ countDecimals; },
|
|
2105
|
+
/* harmony export */ flatten: function() { return /* binding */ flatten; },
|
|
2106
|
+
/* harmony export */ formatMessage: function() { return /* binding */ formatMessage; },
|
|
2107
|
+
/* harmony export */ getDurationAsSeconds: function() { return /* binding */ getDurationAsSeconds; },
|
|
2108
|
+
/* harmony export */ getSecondsAsHHMMSS: function() { return /* binding */ getSecondsAsHHMMSS; },
|
|
2109
|
+
/* harmony export */ getSecondsAsISODuration: function() { return /* binding */ getSecondsAsISODuration; },
|
|
2110
|
+
/* harmony export */ getTimeAsSeconds: function() { return /* binding */ getTimeAsSeconds; },
|
|
2111
|
+
/* harmony export */ stringMatches: function() { return /* binding */ stringMatches; },
|
|
2112
|
+
/* harmony export */ unflatten: function() { return /* binding */ unflatten; }
|
|
2113
|
+
/* harmony export */ });
|
|
2114
|
+
var SECONDS_PER_SECOND = 1.0;
|
|
2115
|
+
var SECONDS_PER_MINUTE = 60;
|
|
2116
|
+
var SECONDS_PER_HOUR = 60 * SECONDS_PER_MINUTE;
|
|
2117
|
+
var SECONDS_PER_DAY = 24 * SECONDS_PER_HOUR;
|
|
2118
|
+
var designations = {
|
|
2119
|
+
D: SECONDS_PER_DAY,
|
|
2120
|
+
H: SECONDS_PER_HOUR,
|
|
2121
|
+
M: SECONDS_PER_MINUTE,
|
|
2122
|
+
S: SECONDS_PER_SECOND,
|
|
2123
|
+
};
|
|
2124
|
+
function getSecondsAsHHMMSS(totalSeconds) {
|
|
2125
|
+
if (!totalSeconds || totalSeconds <= 0) {
|
|
2126
|
+
return "00:00:00";
|
|
2127
|
+
}
|
|
2128
|
+
var hours = Math.floor(totalSeconds / SECONDS_PER_HOUR);
|
|
2129
|
+
var dateObj = new Date(totalSeconds * 1000);
|
|
2130
|
+
var minutes = dateObj.getUTCMinutes();
|
|
2131
|
+
var seconds = dateObj.getSeconds();
|
|
2132
|
+
var ms = totalSeconds % 1.0;
|
|
2133
|
+
var msStr = "";
|
|
2134
|
+
if (countDecimals(ms) > 0) {
|
|
2135
|
+
if (countDecimals(ms) > 2) {
|
|
2136
|
+
msStr = ms.toFixed(2);
|
|
2137
|
+
}
|
|
2138
|
+
else {
|
|
2139
|
+
msStr = String(ms);
|
|
2140
|
+
}
|
|
2141
|
+
msStr = "." + msStr.split(".")[1];
|
|
2142
|
+
}
|
|
2143
|
+
return ((hours + ":" + minutes + ":" + seconds).replace(/\b\d\b/g, "0$&") + msStr);
|
|
2147
2144
|
}
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
var
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2145
|
+
function getSecondsAsISODuration(seconds) {
|
|
2146
|
+
if (!seconds || seconds <= 0) {
|
|
2147
|
+
return "PT0S";
|
|
2148
|
+
}
|
|
2149
|
+
var duration = "P";
|
|
2150
|
+
var remainder = seconds;
|
|
2151
|
+
for (var designationsKey in designations) {
|
|
2152
|
+
var current_seconds = designations[designationsKey] || 1;
|
|
2153
|
+
var value = Math.floor(remainder / current_seconds);
|
|
2154
|
+
remainder = remainder % current_seconds;
|
|
2155
|
+
if (countDecimals(remainder) > 2) {
|
|
2156
|
+
remainder = Number(Number(remainder).toFixed(2));
|
|
2157
|
+
}
|
|
2158
|
+
if (designationsKey === "S" && remainder > 0) {
|
|
2159
|
+
value += remainder;
|
|
2160
|
+
}
|
|
2161
|
+
if (value) {
|
|
2162
|
+
if ((duration.indexOf("D") > 0 ||
|
|
2163
|
+
designationsKey === "H" ||
|
|
2164
|
+
designationsKey === "M" ||
|
|
2165
|
+
designationsKey === "S") &&
|
|
2166
|
+
duration.indexOf("T") === -1) {
|
|
2167
|
+
duration += "T";
|
|
2168
|
+
}
|
|
2169
|
+
duration += "".concat(value).concat(designationsKey);
|
|
2170
|
+
}
|
|
2171
|
+
}
|
|
2172
|
+
return duration;
|
|
2166
2173
|
}
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2174
|
+
function getTimeAsSeconds(timeString, timeRegex) {
|
|
2175
|
+
if (typeof timeString === "number" || typeof timeString === "boolean") {
|
|
2176
|
+
timeString = String(timeString);
|
|
2177
|
+
}
|
|
2178
|
+
if (typeof timeRegex === "string") {
|
|
2179
|
+
timeRegex = new RegExp(timeRegex);
|
|
2180
|
+
}
|
|
2181
|
+
if (!timeString || !timeString.match(timeRegex)) {
|
|
2182
|
+
return 0;
|
|
2183
|
+
}
|
|
2184
|
+
var parts = timeString.split(":");
|
|
2185
|
+
var hours = Number(parts[0]);
|
|
2186
|
+
var minutes = Number(parts[1]);
|
|
2187
|
+
var seconds = Number(parts[2]);
|
|
2188
|
+
return hours * 3600 + minutes * 60 + seconds;
|
|
2170
2189
|
}
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2190
|
+
function getDurationAsSeconds(duration, durationRegex) {
|
|
2191
|
+
if (typeof durationRegex === "string") {
|
|
2192
|
+
durationRegex = new RegExp(durationRegex);
|
|
2193
|
+
}
|
|
2194
|
+
if (!duration || !duration.match(durationRegex)) {
|
|
2195
|
+
return 0;
|
|
2196
|
+
}
|
|
2197
|
+
var _a = new RegExp(durationRegex).exec(duration) || [], years = _a[1], _ = _a[2], days = _a[4], hours = _a[5], minutes = _a[6], seconds = _a[7];
|
|
2198
|
+
var result = 0.0;
|
|
2199
|
+
result += Number(seconds) || 0.0;
|
|
2200
|
+
result += Number(minutes) * 60.0 || 0.0;
|
|
2201
|
+
result += Number(hours) * 3600.0 || 0.0;
|
|
2202
|
+
result += Number(days) * (60 * 60 * 24.0) || 0.0;
|
|
2203
|
+
result += Number(years) * (60 * 60 * 24 * 365.0) || 0.0;
|
|
2204
|
+
return result;
|
|
2176
2205
|
}
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
2206
|
+
function addTwoDurations(first, second, durationRegex) {
|
|
2207
|
+
var regex = typeof durationRegex === "string"
|
|
2208
|
+
? new RegExp(durationRegex)
|
|
2209
|
+
: durationRegex;
|
|
2210
|
+
return getSecondsAsISODuration(getDurationAsSeconds(first, regex) + getDurationAsSeconds(second, regex));
|
|
2183
2211
|
}
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2212
|
+
function addHHMMSSTimeStrings(first, second, timeRegex) {
|
|
2213
|
+
if (typeof timeRegex === "string") {
|
|
2214
|
+
timeRegex = new RegExp(timeRegex);
|
|
2215
|
+
}
|
|
2216
|
+
return getSecondsAsHHMMSS(getTimeAsSeconds(first, timeRegex) + getTimeAsSeconds(second, timeRegex));
|
|
2188
2217
|
}
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2218
|
+
function flatten(data) {
|
|
2219
|
+
var result = {};
|
|
2220
|
+
function recurse(cur, prop) {
|
|
2221
|
+
if (Object(cur) !== cur) {
|
|
2222
|
+
result[prop] = cur;
|
|
2223
|
+
}
|
|
2224
|
+
else if (Array.isArray(cur)) {
|
|
2225
|
+
for (var i = 0, l = cur.length; i < l; i++) {
|
|
2226
|
+
recurse(cur[i], prop + "[" + i + "]");
|
|
2227
|
+
if (l === 0)
|
|
2228
|
+
result[prop] = [];
|
|
2229
|
+
}
|
|
2230
|
+
}
|
|
2231
|
+
else {
|
|
2232
|
+
var isEmpty = true;
|
|
2233
|
+
for (var p in cur) {
|
|
2234
|
+
if ({}.hasOwnProperty.call(cur, p)) {
|
|
2235
|
+
isEmpty = false;
|
|
2236
|
+
recurse(cur[p], prop ? prop + "." + p : p);
|
|
2237
|
+
}
|
|
2238
|
+
}
|
|
2239
|
+
if (isEmpty && prop)
|
|
2240
|
+
result[prop] = {};
|
|
2241
|
+
}
|
|
2197
2242
|
}
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2243
|
+
recurse(data, "");
|
|
2244
|
+
return result;
|
|
2245
|
+
}
|
|
2246
|
+
function unflatten(data) {
|
|
2247
|
+
"use strict";
|
|
2248
|
+
if (Object(data) !== data || Array.isArray(data))
|
|
2249
|
+
return data;
|
|
2250
|
+
var regex = /\.?([^.[\]]+)|\[(\d+)]/g;
|
|
2251
|
+
var result = {};
|
|
2252
|
+
for (var p in data) {
|
|
2253
|
+
if ({}.hasOwnProperty.call(data, p)) {
|
|
2254
|
+
var cur = result;
|
|
2255
|
+
var prop = "";
|
|
2256
|
+
var m = regex.exec(p);
|
|
2257
|
+
while (m) {
|
|
2258
|
+
cur = cur[prop] || (cur[prop] = m[2] ? [] : {});
|
|
2259
|
+
prop = m[2] || m[1] || "";
|
|
2260
|
+
m = regex.exec(p);
|
|
2261
|
+
}
|
|
2262
|
+
cur[prop] = data[p];
|
|
2263
|
+
}
|
|
2202
2264
|
}
|
|
2203
|
-
|
|
2204
|
-
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
2205
|
-
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
2206
|
-
}
|
|
2207
|
-
else if (async) {
|
|
2208
|
-
env.stack.push({ async: true });
|
|
2209
|
-
}
|
|
2210
|
-
return value;
|
|
2265
|
+
return result[""] || result;
|
|
2211
2266
|
}
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
function
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2267
|
+
function countDecimals(num) {
|
|
2268
|
+
if (Math.floor(num) === num || String(num).indexOf(".") < 0)
|
|
2269
|
+
return 0;
|
|
2270
|
+
var parts = num.toString().split(".")[1];
|
|
2271
|
+
return (parts === null || parts === void 0 ? void 0 : parts.length) || 0;
|
|
2272
|
+
}
|
|
2273
|
+
function formatMessage(functionName, message, CMIElement) {
|
|
2274
|
+
var baseLength = 20;
|
|
2275
|
+
var messageString = "";
|
|
2276
|
+
messageString += functionName;
|
|
2277
|
+
var fillChars = baseLength - messageString.length;
|
|
2278
|
+
for (var i = 0; i < fillChars; i++) {
|
|
2279
|
+
messageString += " ";
|
|
2280
|
+
}
|
|
2281
|
+
messageString += ": ";
|
|
2282
|
+
if (CMIElement) {
|
|
2283
|
+
var CMIElementBaseLength = 70;
|
|
2284
|
+
messageString += CMIElement;
|
|
2285
|
+
fillChars = CMIElementBaseLength - messageString.length;
|
|
2286
|
+
for (var j = 0; j < fillChars; j++) {
|
|
2287
|
+
messageString += " ";
|
|
2231
2288
|
}
|
|
2232
|
-
else s |= 1;
|
|
2233
|
-
}
|
|
2234
|
-
catch (e) {
|
|
2235
|
-
fail(e);
|
|
2236
|
-
}
|
|
2237
2289
|
}
|
|
2238
|
-
if (
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2290
|
+
if (message) {
|
|
2291
|
+
messageString += message;
|
|
2292
|
+
}
|
|
2293
|
+
return messageString;
|
|
2294
|
+
}
|
|
2295
|
+
function stringMatches(str, tester) {
|
|
2296
|
+
return (str === null || str === void 0 ? void 0 : str.match(tester)) !== null;
|
|
2242
2297
|
}
|
|
2243
|
-
|
|
2244
|
-
/* harmony default export */ __webpack_exports__["default"] = ({
|
|
2245
|
-
__extends,
|
|
2246
|
-
__assign,
|
|
2247
|
-
__rest,
|
|
2248
|
-
__decorate,
|
|
2249
|
-
__param,
|
|
2250
|
-
__metadata,
|
|
2251
|
-
__awaiter,
|
|
2252
|
-
__generator,
|
|
2253
|
-
__createBinding,
|
|
2254
|
-
__exportStar,
|
|
2255
|
-
__values,
|
|
2256
|
-
__read,
|
|
2257
|
-
__spread,
|
|
2258
|
-
__spreadArrays,
|
|
2259
|
-
__spreadArray,
|
|
2260
|
-
__await,
|
|
2261
|
-
__asyncGenerator,
|
|
2262
|
-
__asyncDelegator,
|
|
2263
|
-
__asyncValues,
|
|
2264
|
-
__makeTemplateObject,
|
|
2265
|
-
__importStar,
|
|
2266
|
-
__importDefault,
|
|
2267
|
-
__classPrivateFieldGet,
|
|
2268
|
-
__classPrivateFieldSet,
|
|
2269
|
-
__classPrivateFieldIn,
|
|
2270
|
-
__addDisposableResource,
|
|
2271
|
-
__disposeResources,
|
|
2272
|
-
});
|
|
2273
2298
|
|
|
2274
2299
|
|
|
2275
2300
|
/***/ })
|
|
@@ -4506,13 +4531,13 @@ var Scorm2004Impl = (function (_super) {
|
|
|
4506
4531
|
Scorm2004Impl.prototype.lmsCommit = function () {
|
|
4507
4532
|
var _this = this;
|
|
4508
4533
|
if (this.settings.asyncCommit) {
|
|
4509
|
-
this.scheduleCommit(500, "
|
|
4534
|
+
this.scheduleCommit(500, "Commit");
|
|
4510
4535
|
}
|
|
4511
4536
|
else {
|
|
4512
4537
|
(function () { return (0,tslib_es6.__awaiter)(_this, void 0, void 0, function () {
|
|
4513
4538
|
return (0,tslib_es6.__generator)(this, function (_a) {
|
|
4514
4539
|
switch (_a.label) {
|
|
4515
|
-
case 0: return [4, this.commit("
|
|
4540
|
+
case 0: return [4, this.commit("Commit", false)];
|
|
4516
4541
|
case 1:
|
|
4517
4542
|
_a.sent();
|
|
4518
4543
|
return [2];
|