@doenet/doenetml-iframe 0.7.0-beta8 → 0.7.0-beta9

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 +39 -15
  2. package/index.js.map +1 -1
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -23709,8 +23709,8 @@ function requireCssesc() {
23709
23709
  return cssesc_1;
23710
23710
  }
23711
23711
  requireCssesc();
23712
- 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 wrappedDoenetViewerProps = ComlinkViewer.wrap(\n ComlinkViewer.windowEndpoint(globalThis.parent)\n );\n const augmentedDoenetViewerProps = { ...doenetViewerProps };\n augmentedDoenetViewerProps.externalVirtualKeyboardProvided = true;\n for (const propName of doenetViewerPropsSpecified) {\n if (!(propName in doenetViewerProps)) {\n augmentedDoenetViewerProps[propName] = wrappedDoenetViewerProps[propName];\n }\n }\n if (!doenetViewerPropsSpecified.includes("requestScrollTo")) {\n augmentedDoenetViewerProps.requestScrollTo = (offset) => {\n messageParentFromViewer({ type: "scrollTo", offset });\n };\n }\n window.renderDoenetViewerToContainer(\n document.getElementById("root"),\n void 0,\n augmentedDoenetViewerProps\n );\n });\n window.addEventListener("message", (e) => {\n if (e.origin !== window.parent.location.origin) {\n return;\n }\n if (e.data.subject?.startsWith("SPLICE") && (!e.data.subject?.endsWith("response") || e.data.subject.endsWith("submitAllAnswers.response")) && !e.data.subject.endsWith("submitAllAnswers")) {\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';
23713
- 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 wrappedDoenetEditorProps = ComlinkEditor.wrap(\n ComlinkEditor.windowEndpoint(globalThis.parent)\n );\n const augmentedDoenetEditorProps = { ...doenetEditorProps };\n augmentedDoenetEditorProps.externalVirtualKeyboardProvided = true;\n for (const propName of doenetEditorPropsSpecified) {\n if (!(propName in doenetEditorProps)) {\n augmentedDoenetEditorProps[propName] = wrappedDoenetEditorProps[propName];\n }\n }\n window.renderDoenetEditorToContainer(\n document.getElementById("root"),\n void 0,\n augmentedDoenetEditorProps\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';
23712
+ 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 });\n ComlinkViewer.expose(\n { renderViewerWithFunctionProps },\n ComlinkViewer.windowEndpoint(globalThis.parent)\n );\n function renderViewerWithFunctionProps(...args) {\n const augmentedDoenetViewerProps = { ...doenetViewerProps };\n augmentedDoenetViewerProps.externalVirtualKeyboardProvided = true;\n for (const propName of doenetViewerPropsSpecified) {\n if (!(propName in doenetViewerProps)) {\n const idx = args.indexOf(propName);\n if (idx !== -1) {\n augmentedDoenetViewerProps[propName] = args[idx + 1];\n }\n }\n }\n if (!doenetViewerPropsSpecified.includes("requestScrollTo")) {\n augmentedDoenetViewerProps.requestScrollTo = (offset) => {\n messageParentFromViewer({ type: "scrollTo", offset });\n };\n }\n window.renderDoenetViewerToContainer(\n document.getElementById("root"),\n void 0,\n augmentedDoenetViewerProps\n );\n }\n messageParentFromViewer({ iframeReady: true });\n window.addEventListener("message", (e) => {\n if (e.origin !== window.parent.location.origin) {\n return;\n }\n if (e.data.subject?.startsWith("SPLICE") && (!e.data.subject?.endsWith("response") || e.data.subject.endsWith("submitAllAnswers.response")) && !e.data.subject.endsWith("submitAllAnswers")) {\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';
23713
+ 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 });\n ComlinkEditor.expose(\n { renderEditorWithFunctionProps },\n ComlinkEditor.windowEndpoint(globalThis.parent)\n );\n function renderEditorWithFunctionProps(...args) {\n const augmentedDoenetEditorProps = { ...doenetEditorProps };\n augmentedDoenetEditorProps.externalVirtualKeyboardProvided = true;\n for (const propName of doenetEditorPropsSpecified) {\n if (!(propName in doenetEditorProps)) {\n const idx = args.indexOf(propName);\n if (idx !== -1) {\n augmentedDoenetEditorProps[propName] = args[idx + 1];\n }\n }\n }\n window.renderDoenetEditorToContainer(\n document.getElementById("root"),\n void 0,\n augmentedDoenetEditorProps\n );\n }\n messageParentFromEditor({ iframeReady: true });\n function messageParentFromEditor(data) {\n window.parent.postMessage(\n {\n origin: editorId,\n data\n },\n window.parent.origin\n );\n }\n})();\n';
23714
23714
  function createHtmlForDoenetViewer(id2, doenetML, doenetViewerProps, standaloneUrl, cssUrl) {
23715
23715
  const doenetViewerPropsSpecified = Object.keys(doenetViewerProps);
23716
23716
  return `
@@ -46764,7 +46764,7 @@ function ExternalVirtualKeyboard() {
46764
46764
  }
46765
46765
  );
46766
46766
  }
46767
- const version = "0.7.0-beta8";
46767
+ const version = "0.7.0-beta9";
46768
46768
  const latestDoenetmlVersion = version;
46769
46769
  function DoenetViewer({
46770
46770
  doenetML,
@@ -46824,18 +46824,30 @@ function DoenetViewer({
46824
46824
  }
46825
46825
  if (data.error) {
46826
46826
  return setInErrorState(data.error);
46827
+ } else if (data.iframeReady) {
46828
+ if (ref.current) {
46829
+ const viewerIframe = wrap$2(
46830
+ windowEndpoint(ref.current.contentWindow)
46831
+ );
46832
+ const proxiedFunctions = [];
46833
+ for (const [key, prop] of Object.entries(
46834
+ doenetViewerProps
46835
+ )) {
46836
+ if (typeof prop === "function") {
46837
+ proxiedFunctions.push(key);
46838
+ proxiedFunctions.push(proxy(prop));
46839
+ }
46840
+ }
46841
+ viewerIframe?.renderViewerWithFunctionProps(
46842
+ ...proxiedFunctions
46843
+ );
46844
+ }
46827
46845
  }
46828
46846
  };
46829
46847
  if (ref.current) {
46830
46848
  window.addEventListener("message", listener);
46831
46849
  }
46832
46850
  const clearResize = watchForResize(ref, () => height, setHeight);
46833
- if (ref.current) {
46834
- expose(
46835
- doenetViewerProps,
46836
- windowEndpoint(ref.current.contentWindow)
46837
- );
46838
- }
46839
46851
  return () => {
46840
46852
  window.removeEventListener("message", listener);
46841
46853
  clearResize();
@@ -46947,17 +46959,29 @@ function DoenetEditor({
46947
46959
  const data = event.data.data;
46948
46960
  if (data.error) {
46949
46961
  return setInErrorState(data.error);
46962
+ } else if (data.iframeReady) {
46963
+ if (ref.current) {
46964
+ const editorIframe = wrap$2(
46965
+ windowEndpoint(ref.current.contentWindow)
46966
+ );
46967
+ const proxiedFunctions = [];
46968
+ for (const [key, prop] of Object.entries(
46969
+ doenetEditorProps
46970
+ )) {
46971
+ if (typeof prop === "function") {
46972
+ proxiedFunctions.push(key);
46973
+ proxiedFunctions.push(proxy(prop));
46974
+ }
46975
+ }
46976
+ editorIframe?.renderEditorWithFunctionProps(
46977
+ ...proxiedFunctions
46978
+ );
46979
+ }
46950
46980
  }
46951
46981
  };
46952
46982
  if (ref.current) {
46953
46983
  window.addEventListener("message", listener);
46954
46984
  }
46955
- if (ref.current) {
46956
- expose(
46957
- doenetEditorProps,
46958
- windowEndpoint(ref.current.contentWindow)
46959
- );
46960
- }
46961
46985
  return () => {
46962
46986
  window.removeEventListener("message", listener);
46963
46987
  };