@instructure/quiz-core 17.52.0 → 17.52.1-rc.1

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.
@@ -1,16 +1,15 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
3
  import handleFrameResize from './subjectHandlers/lti.frameResize';
4
+ import handleCapabilities from './subjectHandlers/lti.capabilities';
4
5
 
5
6
  var PostMessageService = function PostMessageService() {
6
7
  var _this = this;
7
8
 
8
9
  _classCallCheck(this, PostMessageService);
9
10
 
10
- this.SUBJECT_ALLOW_LIST = ['lti.frameResize'];
11
-
12
11
  this.subjectNotAllowed = function (subject) {
13
- return !_this.SUBJECT_ALLOW_LIST.includes(subject);
12
+ return !_this.handlerMap.has(subject);
14
13
  };
15
14
 
16
15
  this.messageHandlerDispatcher = function (event) {
@@ -18,10 +17,19 @@ var PostMessageService = function PostMessageService() {
18
17
  return null;
19
18
  }
20
19
 
21
- switch (event.data.subject) {
22
- case 'lti.frameResize':
23
- return handleFrameResize(event);
24
- }
20
+ return _this.handlerMap.get(event.data.subject)(event, _this);
21
+ };
22
+
23
+ this.subjectAllowList = function () {
24
+ return Array.from(_this.handlerMap.keys());
25
+ };
26
+
27
+ this.capabilities = function () {
28
+ return _this.subjectAllowList().map(function (subject) {
29
+ return {
30
+ subject: subject
31
+ };
32
+ });
25
33
  };
26
34
 
27
35
  this.configurePostMessageListener = function () {
@@ -49,6 +57,10 @@ var PostMessageService = function PostMessageService() {
49
57
  error: error
50
58
  }, sourceWindow);
51
59
  };
60
+
61
+ this.handlerMap = new Map();
62
+ this.handlerMap.set('lti.frameResize', handleFrameResize);
63
+ this.handlerMap.set('lti.capabilities', handleCapabilities);
52
64
  };
53
65
 
54
66
  export { PostMessageService as default };
@@ -0,0 +1,14 @@
1
+ var handleCapabilities = function handleCapabilities(event, postMessageService) {
2
+ try {
3
+ var sourceWindow = event.source;
4
+ var supported_messages = postMessageService.capabilities();
5
+ postMessageService.sendResponse('lti.capabilities', {
6
+ supported_messages: supported_messages
7
+ }, sourceWindow);
8
+ return true;
9
+ } catch (_unused) {
10
+ return false;
11
+ }
12
+ };
13
+
14
+ export default handleCapabilities;
@@ -13,14 +13,15 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/cl
13
13
 
14
14
  var _lti = _interopRequireDefault(require("./subjectHandlers/lti.frameResize"));
15
15
 
16
+ var _lti2 = _interopRequireDefault(require("./subjectHandlers/lti.capabilities"));
17
+
16
18
  var PostMessageService = function PostMessageService() {
17
19
  var _this = this;
18
20
 
19
21
  (0, _classCallCheck2.default)(this, PostMessageService);
20
- this.SUBJECT_ALLOW_LIST = ['lti.frameResize'];
21
22
 
22
23
  this.subjectNotAllowed = function (subject) {
23
- return !_this.SUBJECT_ALLOW_LIST.includes(subject);
24
+ return !_this.handlerMap.has(subject);
24
25
  };
25
26
 
26
27
  this.messageHandlerDispatcher = function (event) {
@@ -28,10 +29,19 @@ var PostMessageService = function PostMessageService() {
28
29
  return null;
29
30
  }
30
31
 
31
- switch (event.data.subject) {
32
- case 'lti.frameResize':
33
- return (0, _lti.default)(event);
34
- }
32
+ return _this.handlerMap.get(event.data.subject)(event, _this);
33
+ };
34
+
35
+ this.subjectAllowList = function () {
36
+ return Array.from(_this.handlerMap.keys());
37
+ };
38
+
39
+ this.capabilities = function () {
40
+ return _this.subjectAllowList().map(function (subject) {
41
+ return {
42
+ subject: subject
43
+ };
44
+ });
35
45
  };
36
46
 
37
47
  this.configurePostMessageListener = function () {
@@ -59,6 +69,10 @@ var PostMessageService = function PostMessageService() {
59
69
  error: error
60
70
  }, sourceWindow);
61
71
  };
72
+
73
+ this.handlerMap = new Map();
74
+ this.handlerMap.set('lti.frameResize', _lti.default);
75
+ this.handlerMap.set('lti.capabilities', _lti2.default);
62
76
  };
63
77
 
64
78
  exports.default = PostMessageService;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var handleCapabilities = function handleCapabilities(event, postMessageService) {
9
+ try {
10
+ var sourceWindow = event.source;
11
+ var supported_messages = postMessageService.capabilities();
12
+ postMessageService.sendResponse('lti.capabilities', {
13
+ supported_messages: supported_messages
14
+ }, sourceWindow);
15
+ return true;
16
+ } catch (_unused) {
17
+ return false;
18
+ }
19
+ };
20
+
21
+ var _default = handleCapabilities;
22
+ exports.default = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/quiz-core",
3
- "version": "17.52.0",
3
+ "version": "17.52.1-rc.1+dfc989ca3",
4
4
  "license": "MIT",
5
5
  "description": "The Quiz React SDK by Instructure Inc.",
6
6
  "author": "Instructure, Inc. Engineering and Product Design",
@@ -41,11 +41,11 @@
41
41
  ],
42
42
  "dependencies": {
43
43
  "@instructure/outcomes-ui": "^2.1.7",
44
- "@instructure/quiz-common": "^17.52.0",
45
- "@instructure/quiz-i18n": "^17.52.0",
46
- "@instructure/quiz-interactions": "^17.52.0",
47
- "@instructure/quiz-number-input": "^17.52.0",
48
- "@instructure/quiz-rce": "^17.52.0",
44
+ "@instructure/quiz-common": "17.52.1-rc.1+dfc989ca3",
45
+ "@instructure/quiz-i18n": "17.52.1-rc.1+dfc989ca3",
46
+ "@instructure/quiz-interactions": "17.52.1-rc.1+dfc989ca3",
47
+ "@instructure/quiz-number-input": "17.52.1-rc.1+dfc989ca3",
48
+ "@instructure/quiz-rce": "17.52.1-rc.1+dfc989ca3",
49
49
  "@instructure/ui-a11y-content": "^7.20.0",
50
50
  "@instructure/ui-alerts": "^7.20.0",
51
51
  "@instructure/ui-avatar": "^7.20.0",
@@ -106,7 +106,7 @@
106
106
  "eventemitter3": "^3.1.0",
107
107
  "humps": "^2.0.0",
108
108
  "immutable": "^3.8.1",
109
- "instructure-validations": "^17.52.0",
109
+ "instructure-validations": "17.52.1-rc.1+dfc989ca3",
110
110
  "ipaddr.js": "^1.5.4",
111
111
  "isomorphic-fetch": "^2.2.0",
112
112
  "isuuid": "^0.1.0",
@@ -137,7 +137,7 @@
137
137
  "uuid": "^3.2.1"
138
138
  },
139
139
  "devDependencies": {
140
- "@instructure/quiz-scripts": "^17.52.0",
140
+ "@instructure/quiz-scripts": "17.52.0",
141
141
  "@instructure/ui-axe-check": "^7.20.0",
142
142
  "@instructure/ui-babel-preset": "^7.20.0",
143
143
  "@instructure/ui-karma-config": "^7.20.0",
@@ -156,7 +156,7 @@
156
156
  "intl": "^1.2.4",
157
157
  "jquery": "^2.2.3",
158
158
  "most-subject": "^5.3.0",
159
- "quiz-presets": "^17.52.0",
159
+ "quiz-presets": "17.52.1-rc.1+dfc989ca3",
160
160
  "react": "^16.8.6",
161
161
  "react-addons-test-utils": "^15.6.2",
162
162
  "react-dom": "^16.8.6",
@@ -172,5 +172,5 @@
172
172
  "publishConfig": {
173
173
  "access": "public"
174
174
  },
175
- "gitHead": "7c48951211d19e9e9ffa3ba029e7cae478505431"
175
+ "gitHead": "dfc989ca3dc41915e223f572aa8bdd57c991a0ed"
176
176
  }