@didask/scol-r 2.0.0 → 3.0.0-beta-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,5 +1,9 @@
1
1
  export interface HTMLGeneratorProps {
2
2
  dataSource: string;
3
3
  libPath?: string;
4
+ sentry?: {
5
+ dsn: string;
6
+ tags?: Record<string, string>;
7
+ };
4
8
  }
5
9
  export declare function HTMLGenerator(props: HTMLGeneratorProps): string;
@@ -1,8 +1,20 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
2
13
  Object.defineProperty(exports, "__esModule", { value: true });
3
14
  exports.HTMLGenerator = void 0;
4
15
  function HTMLGenerator(props) {
5
- var dataSource = props.dataSource, _a = props.libPath, libPath = _a === void 0 ? "lib" : _a;
6
- return "<!DOCTYPE html>\n <html>\n <head>\n <title>SCO local endpoint</title>\n <meta charset=\"UTF-8\"/>\n <script>var exports = {};</script>\n <script type=\"text/javascript\" src=\"" + libPath + "/SCORMAdapter.js\"></script>\n <script type=\"text/javascript\" src=\"" + libPath + "/MessageHandler.js\"></script>\n <script type=\"text/javascript\" src=\"" + libPath + "/loadContent.js\"></script>\n <style type=\"text/css\">\n html, body { margin: 0; padding:0; overflow:hidden; width: 100%; height: 100%; }\n body {\n font-size: 20px;\n font-family: \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n color: #1d1046;\n }\n #wrapper { display: flex; flex-direction: column; height: 100%; }\n .container { width: 80%; max-width: 1200px; padding: 15px; margin: auto; }\n #wrapper .header {\n padding-top: 20px; padding-bottom: 20px;\n background-color: #f3f4f5;\n }\n #wrapper .messages { flex-grow: 1; padding-top: 20px; padding-bottom: 20px; }\n #wrapper .messages p { color: red; }\n #title-error-messages { color: #1d1046; }\n #wrapper .footer {\n background-color: #1d1046; color: white;\n padding-top: 10px; padding-bottom: 10px;\n }\n #wrapper .footer a { color: white; }\n\n iframe { overflow: hidden; height: 100%; width: 100%; }\n iframe + #wrapper { display: none; }\n #runtime-error {\n position: fixed;\n left: 20px; bottom: 20px; padding: 15px;\n background-color: #f44a3d; color: white;\n font-size: 16px;\n }\n #runtime-error h6, #runtime-error p { margin: 0 0 10px;}\n #runtime-error p:last-child { margin: 0;}\n #runtime-error:empty { display: none; }\n </style>\n </head>\n <!-- Set the body's data-source attribute to the SCO's remote endpoint. -->\n <body onload=\"loadContent();\" data-source=\"" + dataSource + "\">\n <div id=\"wrapper\">\n <div class=\"header\"><div class=\"container\">\n <h1 id=\"title\">Your content is loading...</h1>\n <p id=\"subtitle\">Please wait, or if your content doesn't appear, try closing and opening this window again.</p>\n </div></div>\n <div class=\"messages container\">\n <h2 id=\"title-error-messages\">If the initialization fails, error messages will appear below:</h2>\n </div>\n <div class=\"footer\"><div class=\"container\" id=\"footer-content\">\n This content is loaded via <a href=\"https://github.com/Didask/scol-r\" target=\"_blank\">SCOL-R</a>, a cross-domain SCORM connector created by <a href=\"https://www.didask.com\" target=\"_blank\">Didask</a>.\n </div></div>\n </div>\n <div id=\"runtime-error\"></div>\n </body>\n </html>";
16
+ var dataSource = props.dataSource, _a = props.libPath, libPath = _a === void 0 ? "lib" : _a, _b = props.sentry, dsn = _b.dsn, tags = _b.tags;
17
+ return "<!DOCTYPE html>\n <html>\n <head>\n <title>SCO local endpoint</title>\n <meta charset=\"UTF-8\"/>\n <script>var exports = {};</script>\n " + (dsn &&
18
+ "<script\n src=\"https://browser.sentry-cdn.com/7.3.1/bundle.min.js\"\n integrity=\"sha384-07qUw81m8MXGTEXf9FQODO4Vop82t3F03SS3v3EOfrf8j7bOb/oJNg6inMDKFk2I\"\n crossorigin=\"anonymous\"\n ></script>\n <script>Sentry.init(" + JSON.stringify(__assign({ dsn: dsn }, (tags && { initialScope: { tags: tags } }))) + ");</script>") + "\n <script type=\"text/javascript\" src=\"" + libPath + "/SCORMAdapter.js\"></script>\n <script type=\"text/javascript\" src=\"" + libPath + "/MessageHandler.js\"></script>\n <script type=\"text/javascript\" src=\"" + libPath + "/loadContent.js\"></script>\n <style type=\"text/css\">\n html, body { margin: 0; padding:0; overflow:hidden; width: 100%; height: 100%; }\n body {\n font-size: 20px;\n font-family: \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n color: #1d1046;\n }\n #wrapper { display: flex; flex-direction: column; height: 100%; }\n .container { width: 80%; max-width: 1200px; padding: 15px; margin: auto; }\n #wrapper .header {\n padding-top: 20px; padding-bottom: 20px;\n background-color: #f3f4f5;\n }\n #wrapper .messages { flex-grow: 1; padding-top: 20px; padding-bottom: 20px; }\n #wrapper .messages p { color: red; }\n #title-error-messages { color: #1d1046; }\n #wrapper .footer {\n background-color: #1d1046; color: white;\n padding-top: 10px; padding-bottom: 10px;\n }\n #wrapper .footer a { color: white; }\n\n iframe { overflow: hidden; height: 100%; width: 100%; }\n iframe + #wrapper { display: none; }\n #runtime-error {\n position: fixed;\n left: 20px; bottom: 20px; padding: 15px;\n background-color: #f44a3d; color: white;\n font-size: 16px;\n }\n #runtime-error h6, #runtime-error p { margin: 0 0 10px;}\n #runtime-error p:last-child { margin: 0;}\n #runtime-error:empty { display: none; }\n </style>\n </head>\n <!-- Set the body's data-source attribute to the SCO's remote endpoint. -->\n <body onload=\"loadContent();\" data-source=\"" + dataSource + "\">\n <div id=\"wrapper\">\n <div class=\"header\"><div class=\"container\">\n <h1 id=\"title\">Your content is loading...</h1>\n <p id=\"subtitle\">Please wait, or if your content doesn't appear, try closing and opening this window again.</p>\n </div></div>\n <div class=\"messages container\">\n <h2 id=\"title-error-messages\">If the initialization fails, error messages will appear below:</h2>\n </div>\n <div class=\"footer\"><div class=\"container\" id=\"footer-content\">\n This content is loaded via <a href=\"https://github.com/Didask/scol-r\" target=\"_blank\">SCOL-R</a>, a cross-domain SCORM connector created by <a href=\"https://www.didask.com\" target=\"_blank\">Didask</a>.\n </div></div>\n </div>\n <div id=\"runtime-error\"></div>\n </body>\n </html>";
7
19
  }
8
20
  exports.HTMLGenerator = HTMLGenerator;
@@ -48,6 +48,11 @@ function loadContent() {
48
48
  newMessage.innerHTML = localizeMessage(message);
49
49
  messagesContainer.length && messagesContainer[0].appendChild(newMessage);
50
50
  };
51
+ var captureSentryException = function (args) {
52
+ if ("Sentry" in window) {
53
+ Sentry.captureException(new Error(args.reduce(function (acc, arg) { return (arg ? acc + " -- " + arg : acc); }, "")));
54
+ }
55
+ };
51
56
  var displayRuntimeError = function () {
52
57
  var errorContainer = document.getElementById("runtime-error");
53
58
  if (!(arguments && arguments.length)) {
@@ -63,6 +68,7 @@ function loadContent() {
63
68
  thisError.innerHTML = localizeMessage(arguments[i]);
64
69
  errorContainer.appendChild(thisError);
65
70
  }
71
+ captureSentryException(arguments);
66
72
  // Remove the messages after 6 seconds
67
73
  setTimeout(function () {
68
74
  errorContainer.innerHTML = "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@didask/scol-r",
3
- "version": "2.0.0",
3
+ "version": "3.0.0-beta-1",
4
4
  "description": "Shareable Cross-Origin Learning Resources",
5
5
  "main": "index.html",
6
6
  "types": "lib/index.d.ts",