@doenet/doenetml-iframe 0.7.0-alpha30 → 0.7.0-alpha32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.js +27 -9
  2. package/index.js.map +1 -1
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -26878,8 +26878,8 @@ const mathjaxConfig = {
26878
26878
  load: ["[tex]/noerrors"]
26879
26879
  }
26880
26880
  };
26881
- const viewerIframeJsSource = '(function() {\n "use strict";\n document.addEventListener("DOMContentLoaded", () => {\n if (typeof window.renderDoenetViewerToContainer !== "function") {\n return messageParentFromViewer({\n error: "Invalid DoenetML version or DoenetML package not found"\n });\n }\n const callbackOverrides = {};\n const callbackNames = [\n "reportScoreAndStateCallback",\n "setIsInErrorState",\n "generatedVariantCallback",\n "documentStructureCallback",\n "initializedCallback",\n "setErrorsAndWarningsCallback"\n ];\n for (const callback of callbackNames) {\n callbackOverrides[callback] = haveCallbacks.includes(callback) ? (args) => {\n messageParentFromViewer({\n callback,\n args\n });\n } : void 0;\n }\n window.renderDoenetViewerToContainer(\n document.getElementById("root"),\n void 0,\n {\n ...doenetViewerProps,\n externalVirtualKeyboardProvided: true,\n ...callbackOverrides\n }\n );\n });\n window.addEventListener("message", (e) => {\n var _a, _b;\n if (e.origin !== window.parent.location.origin) {\n return;\n }\n if (((_a = e.data.subject) == null ? void 0 : _a.startsWith("SPLICE")) && !((_b = e.data.subject) == null ? void 0 : _b.endsWith("response"))) {\n window.parent.postMessage(e.data);\n }\n });\n function messageParentFromViewer(data) {\n window.parent.postMessage(\n {\n origin: viewerId,\n data\n },\n window.parent.origin\n );\n }\n})();\n';
26882
- const editorIframeJsSource = '(function() {\n "use strict";\n document.addEventListener("DOMContentLoaded", () => {\n if (typeof window.renderDoenetEditorToContainer !== "function") {\n return messageParentFromEditor({\n error: "Invalid DoenetML version or DoenetML package not found"\n });\n }\n window.renderDoenetEditorToContainer(\n document.getElementById("root"),\n void 0,\n {\n ...doenetEditorProps,\n externalVirtualKeyboardProvided: true,\n // Callbacks have to be explicitly overridden here so that they\n // can message the parent React component (outside the iframe).\n doenetmlChangeCallback: (args) => {\n messageParentFromEditor({\n callback: "doenetmlChangeCallback",\n args\n });\n },\n immediateDoenetmlChangeCallback: (args) => {\n messageParentFromEditor({\n callback: "immediateDoenetmlChangeCallback",\n args\n });\n }\n }\n );\n });\n function messageParentFromEditor(data) {\n window.parent.postMessage(\n {\n origin: editorId,\n data\n },\n window.parent.origin\n );\n }\n})();\n';
26881
+ const viewerIframeJsSource = '(function() {\n "use strict";\n document.addEventListener("DOMContentLoaded", async () => {\n let pause100 = function() {\n return new Promise((resolve, _reject) => {\n setTimeout(resolve, 100);\n });\n };\n for (let i = 0; i < 10; i++) {\n if (typeof window.renderDoenetViewerToContainer === "function") {\n break;\n }\n await pause100();\n }\n if (typeof window.renderDoenetViewerToContainer !== "function") {\n return messageParentFromViewer({\n error: "Invalid DoenetML version or DoenetML package not found"\n });\n }\n const callbackOverrides = {};\n const callbackNames = [\n "reportScoreAndStateCallback",\n "setIsInErrorState",\n "generatedVariantCallback",\n "documentStructureCallback",\n "initializedCallback",\n "setErrorsAndWarningsCallback"\n ];\n for (const callback of callbackNames) {\n callbackOverrides[callback] = haveViewerCallbacks.includes(callback) ? (args) => {\n messageParentFromViewer({\n callback,\n args\n });\n } : void 0;\n }\n window.renderDoenetViewerToContainer(\n document.getElementById("root"),\n void 0,\n {\n ...doenetViewerProps,\n externalVirtualKeyboardProvided: true,\n ...callbackOverrides\n }\n );\n });\n window.addEventListener("message", (e) => {\n var _a, _b;\n if (e.origin !== window.parent.location.origin) {\n return;\n }\n if (((_a = e.data.subject) == null ? void 0 : _a.startsWith("SPLICE")) && !((_b = e.data.subject) == null ? void 0 : _b.endsWith("response"))) {\n window.parent.postMessage(e.data);\n } else if (e.data.subject === "requestAnswerResponses") {\n window.parent.postMessage(e.data);\n }\n });\n function messageParentFromViewer(data) {\n window.parent.postMessage(\n {\n origin: viewerId,\n data\n },\n window.parent.origin\n );\n }\n})();\n';
26882
+ const editorIframeJsSource = '(function() {\n "use strict";\n document.addEventListener("DOMContentLoaded", async () => {\n let pause100 = function() {\n return new Promise((resolve, _reject) => {\n setTimeout(resolve, 100);\n });\n };\n for (let i = 0; i < 10; i++) {\n if (typeof window.renderDoenetViewerToContainer === "function") {\n break;\n }\n await pause100();\n }\n if (typeof window.renderDoenetEditorToContainer !== "function") {\n return messageParentFromEditor({\n error: "Invalid DoenetML version or DoenetML package not found"\n });\n }\n const callbackOverrides = {};\n const callbackNames = [\n "doenetmlChangeCallback",\n "immediateDoenetmlChangeCallback",\n "documentStructureCallback"\n ];\n for (const callback of callbackNames) {\n callbackOverrides[callback] = haveEditorCallbacks.includes(callback) ? (args) => {\n messageParentFromEditor({\n callback,\n args\n });\n } : void 0;\n }\n window.renderDoenetEditorToContainer(\n document.getElementById("root"),\n void 0,\n {\n ...doenetEditorProps,\n externalVirtualKeyboardProvided: true,\n ...callbackOverrides\n }\n );\n });\n function messageParentFromEditor(data) {\n window.parent.postMessage(\n {\n origin: editorId,\n data\n },\n window.parent.origin\n );\n }\n})();\n';
26883
26883
  var __defProp$2 = Object.defineProperty;
26884
26884
  var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
26885
26885
  var __publicField = (obj, key, value) => __defNormalProp$2(obj, key + "", value);
@@ -40129,7 +40129,7 @@ var utils = {
40129
40129
  canBreak
40130
40130
  };
40131
40131
  function createHtmlForDoenetViewer(id2, doenetML, doenetViewerProps, standaloneUrl, cssUrl) {
40132
- const haveCallbacks = [];
40132
+ const haveViewerCallbacks = [];
40133
40133
  const callbackNames = [
40134
40134
  "reportScoreAndStateCallback",
40135
40135
  "setIsInErrorState",
@@ -40140,7 +40140,7 @@ function createHtmlForDoenetViewer(id2, doenetML, doenetViewerProps, standaloneU
40140
40140
  ];
40141
40141
  for (const callback of callbackNames) {
40142
40142
  if (callback in doenetViewerProps) {
40143
- haveCallbacks.push(callback);
40143
+ haveViewerCallbacks.push(callback);
40144
40144
  }
40145
40145
  }
40146
40146
  return `
@@ -40153,10 +40153,10 @@ function createHtmlForDoenetViewer(id2, doenetML, doenetViewerProps, standaloneU
40153
40153
  <script type="module">
40154
40154
  const viewerId = "${id2}";
40155
40155
  const doenetViewerProps = ${JSON.stringify(doenetViewerProps)};
40156
- const haveCallbacks = ${JSON.stringify(haveCallbacks)};
40156
+ const haveViewerCallbacks = ${JSON.stringify(haveViewerCallbacks)};
40157
40157
 
40158
40158
  // This source code has been compiled by vite and should be directly included.
40159
- // It assumes that viewerId, doenetViewerProps, and haveCallbacks are defined in the global scope.
40159
+ // It assumes that viewerId, doenetViewerProps, and haveViewerCallbacks are defined in the global scope.
40160
40160
  ${viewerIframeJsSource}
40161
40161
  <\/script>
40162
40162
  <div id="root">
@@ -40168,6 +40168,17 @@ function createHtmlForDoenetViewer(id2, doenetML, doenetViewerProps, standaloneU
40168
40168
  }
40169
40169
  function createHtmlForDoenetEditor(id2, doenetML, width, doenetEditorProps, standaloneUrl, cssUrl) {
40170
40170
  const augmentedProps = { width, height: "100vh", ...doenetEditorProps };
40171
+ const haveEditorCallbacks = [];
40172
+ const callbackNames = [
40173
+ "doenetmlChangeCallback",
40174
+ "immediateDoenetmlChangeCallback",
40175
+ "documentStructureCallback"
40176
+ ];
40177
+ for (const callback of callbackNames) {
40178
+ if (callback in doenetEditorProps) {
40179
+ haveEditorCallbacks.push(callback);
40180
+ }
40181
+ }
40171
40182
  return `
40172
40183
  <html style="overflow:hidden">
40173
40184
  <head>
@@ -40178,9 +40189,10 @@ function createHtmlForDoenetEditor(id2, doenetML, width, doenetEditorProps, stan
40178
40189
  <script type="module">
40179
40190
  const editorId = "${id2}";
40180
40191
  const doenetEditorProps = ${JSON.stringify(augmentedProps)};
40192
+ const haveEditorCallbacks = ${JSON.stringify(haveEditorCallbacks)};
40181
40193
 
40182
40194
  // This source code has been compiled by vite and should be directly included.
40183
- // It assumes that editorId and doenetEditorProps are defined in the global scope.
40195
+ // It assumes that editorId, doenetEditorProps, and have EditorCallbacks are defined in the global scope.
40184
40196
  ${editorIframeJsSource}
40185
40197
  <\/script>
40186
40198
  <div id="root">
@@ -49576,7 +49588,7 @@ function ExternalVirtualKeyboard() {
49576
49588
  }
49577
49589
  );
49578
49590
  }
49579
- const version = "0.7.0-alpha30";
49591
+ const version = "0.7.0-alpha32";
49580
49592
  const latestDoenetmlVersion = version;
49581
49593
  function DoenetViewer({
49582
49594
  doenetML,
@@ -49764,7 +49776,7 @@ function DoenetEditor({
49764
49776
  }
49765
49777
  React__default__default.useEffect(() => {
49766
49778
  const listener3 = (event) => {
49767
- var _a, _b, _c;
49779
+ var _a, _b, _c, _d;
49768
49780
  if (event.origin !== window.location.origin || ((_a = event.data) == null ? void 0 : _a.origin) !== id2) {
49769
49781
  return;
49770
49782
  }
@@ -49785,6 +49797,12 @@ function DoenetEditor({
49785
49797
  data.args
49786
49798
  );
49787
49799
  }
49800
+ case "documentStructureCallback": {
49801
+ return (_d = doenetEditorProps.documentStructureCallback) == null ? void 0 : _d.call(
49802
+ doenetEditorProps,
49803
+ data.args
49804
+ );
49805
+ }
49788
49806
  }
49789
49807
  };
49790
49808
  if (ref.current) {