@doenet/doenetml-iframe 0.7.0-beta5 → 0.7.0-beta6

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 +362 -79
  2. package/index.js.map +1 -1
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -30,6 +30,338 @@ function watchForResize(ref, getHeight, setHeight) {
30
30
  clearInterval(interval);
31
31
  };
32
32
  }
33
+ /**
34
+ * @license
35
+ * Copyright 2019 Google LLC
36
+ * SPDX-License-Identifier: Apache-2.0
37
+ */
38
+ const proxyMarker = Symbol("Comlink.proxy");
39
+ const createEndpoint = Symbol("Comlink.endpoint");
40
+ const releaseProxy = Symbol("Comlink.releaseProxy");
41
+ const finalizer = Symbol("Comlink.finalizer");
42
+ const throwMarker = Symbol("Comlink.thrown");
43
+ const isObject$2 = (val) => typeof val === "object" && val !== null || typeof val === "function";
44
+ const proxyTransferHandler = {
45
+ canHandle: (val) => isObject$2(val) && val[proxyMarker],
46
+ serialize(obj) {
47
+ const { port1, port2 } = new MessageChannel();
48
+ expose(obj, port1);
49
+ return [port2, [port2]];
50
+ },
51
+ deserialize(port) {
52
+ port.start();
53
+ return wrap$2(port);
54
+ }
55
+ };
56
+ const throwTransferHandler = {
57
+ canHandle: (value) => isObject$2(value) && throwMarker in value,
58
+ serialize({ value }) {
59
+ let serialized;
60
+ if (value instanceof Error) {
61
+ serialized = {
62
+ isError: true,
63
+ value: {
64
+ message: value.message,
65
+ name: value.name,
66
+ stack: value.stack
67
+ }
68
+ };
69
+ } else {
70
+ serialized = { isError: false, value };
71
+ }
72
+ return [serialized, []];
73
+ },
74
+ deserialize(serialized) {
75
+ if (serialized.isError) {
76
+ throw Object.assign(new Error(serialized.value.message), serialized.value);
77
+ }
78
+ throw serialized.value;
79
+ }
80
+ };
81
+ const transferHandlers = /* @__PURE__ */ new Map([
82
+ ["proxy", proxyTransferHandler],
83
+ ["throw", throwTransferHandler]
84
+ ]);
85
+ function isAllowedOrigin(allowedOrigins, origin) {
86
+ for (const allowedOrigin of allowedOrigins) {
87
+ if (origin === allowedOrigin || allowedOrigin === "*") {
88
+ return true;
89
+ }
90
+ if (allowedOrigin instanceof RegExp && allowedOrigin.test(origin)) {
91
+ return true;
92
+ }
93
+ }
94
+ return false;
95
+ }
96
+ function expose(obj, ep = globalThis, allowedOrigins = ["*"]) {
97
+ ep.addEventListener("message", function callback(ev) {
98
+ if (!ev || !ev.data) {
99
+ return;
100
+ }
101
+ if (!isAllowedOrigin(allowedOrigins, ev.origin)) {
102
+ console.warn(`Invalid origin '${ev.origin}' for comlink proxy`);
103
+ return;
104
+ }
105
+ const { id: id2, type, path: path2 } = Object.assign({ path: [] }, ev.data);
106
+ const argumentList = (ev.data.argumentList || []).map(fromWireValue);
107
+ let returnValue;
108
+ try {
109
+ const parent = path2.slice(0, -1).reduce((obj2, prop) => obj2[prop], obj);
110
+ const rawValue = path2.reduce((obj2, prop) => obj2[prop], obj);
111
+ switch (type) {
112
+ case "GET":
113
+ {
114
+ returnValue = rawValue;
115
+ }
116
+ break;
117
+ case "SET":
118
+ {
119
+ parent[path2.slice(-1)[0]] = fromWireValue(ev.data.value);
120
+ returnValue = true;
121
+ }
122
+ break;
123
+ case "APPLY":
124
+ {
125
+ returnValue = rawValue.apply(parent, argumentList);
126
+ }
127
+ break;
128
+ case "CONSTRUCT":
129
+ {
130
+ const value = new rawValue(...argumentList);
131
+ returnValue = proxy(value);
132
+ }
133
+ break;
134
+ case "ENDPOINT":
135
+ {
136
+ const { port1, port2 } = new MessageChannel();
137
+ expose(obj, port2);
138
+ returnValue = transfer(port1, [port1]);
139
+ }
140
+ break;
141
+ case "RELEASE":
142
+ {
143
+ returnValue = void 0;
144
+ }
145
+ break;
146
+ default:
147
+ return;
148
+ }
149
+ } catch (value) {
150
+ returnValue = { value, [throwMarker]: 0 };
151
+ }
152
+ Promise.resolve(returnValue).catch((value) => {
153
+ return { value, [throwMarker]: 0 };
154
+ }).then((returnValue2) => {
155
+ const [wireValue, transferables] = toWireValue(returnValue2);
156
+ ep.postMessage(Object.assign(Object.assign({}, wireValue), { id: id2 }), transferables);
157
+ if (type === "RELEASE") {
158
+ ep.removeEventListener("message", callback);
159
+ closeEndPoint(ep);
160
+ if (finalizer in obj && typeof obj[finalizer] === "function") {
161
+ obj[finalizer]();
162
+ }
163
+ }
164
+ }).catch((error) => {
165
+ const [wireValue, transferables] = toWireValue({
166
+ value: new TypeError("Unserializable return value"),
167
+ [throwMarker]: 0
168
+ });
169
+ ep.postMessage(Object.assign(Object.assign({}, wireValue), { id: id2 }), transferables);
170
+ });
171
+ });
172
+ if (ep.start) {
173
+ ep.start();
174
+ }
175
+ }
176
+ function isMessagePort(endpoint) {
177
+ return endpoint.constructor.name === "MessagePort";
178
+ }
179
+ function closeEndPoint(endpoint) {
180
+ if (isMessagePort(endpoint))
181
+ endpoint.close();
182
+ }
183
+ function wrap$2(ep, target) {
184
+ const pendingListeners = /* @__PURE__ */ new Map();
185
+ ep.addEventListener("message", function handleMessage(ev) {
186
+ const { data } = ev;
187
+ if (!data || !data.id) {
188
+ return;
189
+ }
190
+ const resolver = pendingListeners.get(data.id);
191
+ if (!resolver) {
192
+ return;
193
+ }
194
+ try {
195
+ resolver(data);
196
+ } finally {
197
+ pendingListeners.delete(data.id);
198
+ }
199
+ });
200
+ return createProxy(ep, pendingListeners, [], target);
201
+ }
202
+ function throwIfProxyReleased(isReleased) {
203
+ if (isReleased) {
204
+ throw new Error("Proxy has been released and is not useable");
205
+ }
206
+ }
207
+ function releaseEndpoint(ep) {
208
+ return requestResponseMessage(ep, /* @__PURE__ */ new Map(), {
209
+ type: "RELEASE"
210
+ }).then(() => {
211
+ closeEndPoint(ep);
212
+ });
213
+ }
214
+ const proxyCounter = /* @__PURE__ */ new WeakMap();
215
+ const proxyFinalizers = "FinalizationRegistry" in globalThis && new FinalizationRegistry((ep) => {
216
+ const newCount = (proxyCounter.get(ep) || 0) - 1;
217
+ proxyCounter.set(ep, newCount);
218
+ if (newCount === 0) {
219
+ releaseEndpoint(ep);
220
+ }
221
+ });
222
+ function registerProxy(proxy2, ep) {
223
+ const newCount = (proxyCounter.get(ep) || 0) + 1;
224
+ proxyCounter.set(ep, newCount);
225
+ if (proxyFinalizers) {
226
+ proxyFinalizers.register(proxy2, ep, proxy2);
227
+ }
228
+ }
229
+ function unregisterProxy(proxy2) {
230
+ if (proxyFinalizers) {
231
+ proxyFinalizers.unregister(proxy2);
232
+ }
233
+ }
234
+ function createProxy(ep, pendingListeners, path2 = [], target = function() {
235
+ }) {
236
+ let isProxyReleased = false;
237
+ const proxy2 = new Proxy(target, {
238
+ get(_target, prop) {
239
+ throwIfProxyReleased(isProxyReleased);
240
+ if (prop === releaseProxy) {
241
+ return () => {
242
+ unregisterProxy(proxy2);
243
+ releaseEndpoint(ep);
244
+ pendingListeners.clear();
245
+ isProxyReleased = true;
246
+ };
247
+ }
248
+ if (prop === "then") {
249
+ if (path2.length === 0) {
250
+ return { then: () => proxy2 };
251
+ }
252
+ const r = requestResponseMessage(ep, pendingListeners, {
253
+ type: "GET",
254
+ path: path2.map((p) => p.toString())
255
+ }).then(fromWireValue);
256
+ return r.then.bind(r);
257
+ }
258
+ return createProxy(ep, pendingListeners, [...path2, prop]);
259
+ },
260
+ set(_target, prop, rawValue) {
261
+ throwIfProxyReleased(isProxyReleased);
262
+ const [value, transferables] = toWireValue(rawValue);
263
+ return requestResponseMessage(ep, pendingListeners, {
264
+ type: "SET",
265
+ path: [...path2, prop].map((p) => p.toString()),
266
+ value
267
+ }, transferables).then(fromWireValue);
268
+ },
269
+ apply(_target, _thisArg, rawArgumentList) {
270
+ throwIfProxyReleased(isProxyReleased);
271
+ const last2 = path2[path2.length - 1];
272
+ if (last2 === createEndpoint) {
273
+ return requestResponseMessage(ep, pendingListeners, {
274
+ type: "ENDPOINT"
275
+ }).then(fromWireValue);
276
+ }
277
+ if (last2 === "bind") {
278
+ return createProxy(ep, pendingListeners, path2.slice(0, -1));
279
+ }
280
+ const [argumentList, transferables] = processArguments(rawArgumentList);
281
+ return requestResponseMessage(ep, pendingListeners, {
282
+ type: "APPLY",
283
+ path: path2.map((p) => p.toString()),
284
+ argumentList
285
+ }, transferables).then(fromWireValue);
286
+ },
287
+ construct(_target, rawArgumentList) {
288
+ throwIfProxyReleased(isProxyReleased);
289
+ const [argumentList, transferables] = processArguments(rawArgumentList);
290
+ return requestResponseMessage(ep, pendingListeners, {
291
+ type: "CONSTRUCT",
292
+ path: path2.map((p) => p.toString()),
293
+ argumentList
294
+ }, transferables).then(fromWireValue);
295
+ }
296
+ });
297
+ registerProxy(proxy2, ep);
298
+ return proxy2;
299
+ }
300
+ function myFlat(arr) {
301
+ return Array.prototype.concat.apply([], arr);
302
+ }
303
+ function processArguments(argumentList) {
304
+ const processed = argumentList.map(toWireValue);
305
+ return [processed.map((v) => v[0]), myFlat(processed.map((v) => v[1]))];
306
+ }
307
+ const transferCache = /* @__PURE__ */ new WeakMap();
308
+ function transfer(obj, transfers) {
309
+ transferCache.set(obj, transfers);
310
+ return obj;
311
+ }
312
+ function proxy(obj) {
313
+ return Object.assign(obj, { [proxyMarker]: true });
314
+ }
315
+ function windowEndpoint(w, context = globalThis, targetOrigin = "*") {
316
+ return {
317
+ postMessage: (msg, transferables) => w.postMessage(msg, targetOrigin, transferables),
318
+ addEventListener: context.addEventListener.bind(context),
319
+ removeEventListener: context.removeEventListener.bind(context)
320
+ };
321
+ }
322
+ function toWireValue(value) {
323
+ for (const [name2, handler] of transferHandlers) {
324
+ if (handler.canHandle(value)) {
325
+ const [serializedValue, transferables] = handler.serialize(value);
326
+ return [
327
+ {
328
+ type: "HANDLER",
329
+ name: name2,
330
+ value: serializedValue
331
+ },
332
+ transferables
333
+ ];
334
+ }
335
+ }
336
+ return [
337
+ {
338
+ type: "RAW",
339
+ value
340
+ },
341
+ transferCache.get(value) || []
342
+ ];
343
+ }
344
+ function fromWireValue(value) {
345
+ switch (value.type) {
346
+ case "HANDLER":
347
+ return transferHandlers.get(value.name).deserialize(value.value);
348
+ case "RAW":
349
+ return value.value;
350
+ }
351
+ }
352
+ function requestResponseMessage(ep, pendingListeners, msg, transfers) {
353
+ return new Promise((resolve) => {
354
+ const id2 = generateUUID();
355
+ pendingListeners.set(id2, resolve);
356
+ if (ep.start) {
357
+ ep.start();
358
+ }
359
+ ep.postMessage(Object.assign({ id: id2 }, msg), transfers);
360
+ });
361
+ }
362
+ function generateUUID() {
363
+ return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
364
+ }
33
365
  var DefaultContext = {
34
366
  color: void 0,
35
367
  size: void 0,
@@ -23279,6 +23611,9 @@ const mathjaxConfig = {
23279
23611
  sech: "\\operatorname{sech}"
23280
23612
  },
23281
23613
  displayMath: [["\\[", "\\]"]]
23614
+ },
23615
+ output: {
23616
+ displayOverflow: "linebreak"
23282
23617
  }
23283
23618
  };
23284
23619
  /*! https://mths.be/cssesc v3.0.0 by @mathias */
@@ -23373,23 +23708,10 @@ function requireCssesc() {
23373
23708
  return cssesc_1;
23374
23709
  }
23375
23710
  requireCssesc();
23376
- 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 if (e.origin !== window.parent.location.origin) {\n return;\n }\n if (e.data.subject?.startsWith("SPLICE") && !e.data.subject?.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';
23377
- 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';
23711
+ 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 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';
23712
+ 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';
23378
23713
  function createHtmlForDoenetViewer(id2, doenetML, doenetViewerProps, standaloneUrl, cssUrl) {
23379
- const haveViewerCallbacks = [];
23380
- const callbackNames = [
23381
- "reportScoreAndStateCallback",
23382
- "setIsInErrorState",
23383
- "generatedVariantCallback",
23384
- "documentStructureCallback",
23385
- "initializedCallback",
23386
- "setErrorsAndWarningsCallback"
23387
- ];
23388
- for (const callback of callbackNames) {
23389
- if (callback in doenetViewerProps) {
23390
- haveViewerCallbacks.push(callback);
23391
- }
23392
- }
23714
+ const doenetViewerPropsSpecified = Object.keys(doenetViewerProps);
23393
23715
  return `
23394
23716
  <html style="overflow:hidden">
23395
23717
  <head>
@@ -23400,10 +23722,11 @@ function createHtmlForDoenetViewer(id2, doenetML, doenetViewerProps, standaloneU
23400
23722
  <script type="module">
23401
23723
  const viewerId = "${id2}";
23402
23724
  const doenetViewerProps = ${JSON.stringify(doenetViewerProps)};
23403
- const haveViewerCallbacks = ${JSON.stringify(haveViewerCallbacks)};
23404
-
23725
+ const doenetViewerPropsSpecified = ${JSON.stringify(doenetViewerPropsSpecified)};
23726
+ import * as ComlinkViewer from "https://unpkg.com/comlink/dist/esm/comlink.mjs";
23727
+
23405
23728
  // This source code has been compiled by vite and should be directly included.
23406
- // It assumes that viewerId, doenetViewerProps, and haveViewerCallbacks are defined in the global scope.
23729
+ // It assumes that viewerId, doenetViewerProps, doenetViewerPropsSpecified, and ComlinkViewer are defined in the global scope.
23407
23730
  ${viewerIframeJsSource}
23408
23731
  <\/script>
23409
23732
  <div id="root">
@@ -23415,17 +23738,7 @@ function createHtmlForDoenetViewer(id2, doenetML, doenetViewerProps, standaloneU
23415
23738
  }
23416
23739
  function createHtmlForDoenetEditor(id2, doenetML, width, doenetEditorProps, standaloneUrl, cssUrl) {
23417
23740
  const augmentedProps = { width, height: "100vh", ...doenetEditorProps };
23418
- const haveEditorCallbacks = [];
23419
- const callbackNames = [
23420
- "doenetmlChangeCallback",
23421
- "immediateDoenetmlChangeCallback",
23422
- "documentStructureCallback"
23423
- ];
23424
- for (const callback of callbackNames) {
23425
- if (callback in doenetEditorProps) {
23426
- haveEditorCallbacks.push(callback);
23427
- }
23428
- }
23741
+ const doenetEditorPropsSpecified = Object.keys(augmentedProps);
23429
23742
  return `
23430
23743
  <html style="overflow:hidden">
23431
23744
  <head>
@@ -23436,10 +23749,11 @@ function createHtmlForDoenetEditor(id2, doenetML, width, doenetEditorProps, stan
23436
23749
  <script type="module">
23437
23750
  const editorId = "${id2}";
23438
23751
  const doenetEditorProps = ${JSON.stringify(augmentedProps)};
23439
- const haveEditorCallbacks = ${JSON.stringify(haveEditorCallbacks)};
23752
+ const doenetEditorPropsSpecified = ${JSON.stringify(doenetEditorPropsSpecified)};
23753
+ import * as ComlinkEditor from "https://unpkg.com/comlink/dist/esm/comlink.mjs";
23440
23754
 
23441
23755
  // This source code has been compiled by vite and should be directly included.
23442
- // It assumes that editorId, doenetEditorProps, and have EditorCallbacks are defined in the global scope.
23756
+ // It assumes that editorId, doenetEditorProps, doenetEditorPropsSpecified, and ComlinkEditor are defined in the global scope.
23443
23757
  ${editorIframeJsSource}
23444
23758
  <\/script>
23445
23759
  <div id="root">
@@ -46449,7 +46763,7 @@ function ExternalVirtualKeyboard() {
46449
46763
  }
46450
46764
  );
46451
46765
  }
46452
- const version = "0.7.0-beta5";
46766
+ const version = "0.7.0-beta6";
46453
46767
  const latestDoenetmlVersion = version;
46454
46768
  function DoenetViewer({
46455
46769
  doenetML,
@@ -46491,7 +46805,7 @@ function DoenetViewer({
46491
46805
  if (event.origin !== window.location.origin) {
46492
46806
  return;
46493
46807
  }
46494
- if (event.data.subject === "SPLICE.getState.response" || event.data.subject === "SPLICE.requestSolutionView.response") {
46808
+ if (event.data.subject === "SPLICE.getState.response" || event.data.subject === "SPLICE.requestSolutionView.response" || event.data.subject == "SPLICE.submitAllAnswers") {
46495
46809
  ref.current?.contentWindow?.postMessage(event.data);
46496
46810
  return;
46497
46811
  }
@@ -46502,39 +46816,17 @@ function DoenetViewer({
46502
46816
  if (data.error) {
46503
46817
  return setInErrorState(data.error);
46504
46818
  }
46505
- switch (data.callback) {
46506
- case "reportScoreAndStateCallback": {
46507
- return doenetViewerProps.reportScoreAndStateCallback?.(
46508
- data.args
46509
- );
46510
- }
46511
- case "setIsInErrorState": {
46512
- return doenetViewerProps.setIsInErrorState?.(data.args);
46513
- }
46514
- case "generatedVariantCallback": {
46515
- return doenetViewerProps.generatedVariantCallback?.(
46516
- data.args
46517
- );
46518
- }
46519
- case "documentStructureCallback": {
46520
- return doenetViewerProps.documentStructureCallback?.(
46521
- data.args
46522
- );
46523
- }
46524
- case "initializedCallback": {
46525
- return doenetViewerProps.initializedCallback?.(data.args);
46526
- }
46527
- case "setErrorsAndWarningsCallback": {
46528
- return doenetViewerProps.setErrorsAndWarningsCallback?.(
46529
- data.args
46530
- );
46531
- }
46532
- }
46533
46819
  };
46534
46820
  if (ref.current) {
46535
46821
  window.addEventListener("message", listener);
46536
46822
  }
46537
46823
  const clearResize = watchForResize(ref, () => height, setHeight);
46824
+ if (ref.current) {
46825
+ expose(
46826
+ doenetViewerProps,
46827
+ windowEndpoint(ref.current.contentWindow)
46828
+ );
46829
+ }
46538
46830
  return () => {
46539
46831
  window.removeEventListener("message", listener);
46540
46832
  clearResize();
@@ -46571,6 +46863,7 @@ function DoenetViewer({
46571
46863
  return /* @__PURE__ */ React__default__default.createElement(React__default__default.Fragment, null, addVirtualKeyboard ? /* @__PURE__ */ React__default__default.createElement(ExternalVirtualKeyboard, null) : null, /* @__PURE__ */ React__default__default.createElement(
46572
46864
  "iframe",
46573
46865
  {
46866
+ title: "Doenet document",
46574
46867
  ref,
46575
46868
  srcDoc: createHtmlForDoenetViewer(
46576
46869
  id2,
@@ -46646,27 +46939,16 @@ function DoenetEditor({
46646
46939
  if (data.error) {
46647
46940
  return setInErrorState(data.error);
46648
46941
  }
46649
- switch (data.callback) {
46650
- case "doenetmlChangeCallback": {
46651
- return doenetEditorProps.doenetmlChangeCallback?.(
46652
- data.args
46653
- );
46654
- }
46655
- case "immediateDoenetmlChangeCallback": {
46656
- return doenetEditorProps.immediateDoenetmlChangeCallback?.(
46657
- data.args
46658
- );
46659
- }
46660
- case "documentStructureCallback": {
46661
- return doenetEditorProps.documentStructureCallback?.(
46662
- data.args
46663
- );
46664
- }
46665
- }
46666
46942
  };
46667
46943
  if (ref.current) {
46668
46944
  window.addEventListener("message", listener);
46669
46945
  }
46946
+ if (ref.current) {
46947
+ expose(
46948
+ doenetEditorProps,
46949
+ windowEndpoint(ref.current.contentWindow)
46950
+ );
46951
+ }
46670
46952
  return () => {
46671
46953
  window.removeEventListener("message", listener);
46672
46954
  };
@@ -46714,6 +46996,7 @@ function DoenetEditor({
46714
46996
  return /* @__PURE__ */ React__default__default.createElement(React__default__default.Fragment, null, addVirtualKeyboard ? /* @__PURE__ */ React__default__default.createElement(ExternalVirtualKeyboard, null) : null, /* @__PURE__ */ React__default__default.createElement(
46715
46997
  "iframe",
46716
46998
  {
46999
+ title: "Doenet Editor",
46717
47000
  ref,
46718
47001
  srcDoc: createHtmlForDoenetEditor(
46719
47002
  id2,