@doenet/doenetml-iframe 0.7.19 → 0.7.20-dev.20260602160826.26e8707
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.
- package/index.js +66 -29
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -25856,6 +25856,60 @@ const editorIframeJsSource = `(function() {
|
|
|
25856
25856
|
"use strict";
|
|
25857
25857
|
let editorControlHandle = null;
|
|
25858
25858
|
let lastAugmentedProps = null;
|
|
25859
|
+
let currentFunctionProps = {};
|
|
25860
|
+
const functionPropDispatchers = {};
|
|
25861
|
+
function getFunctionPropDispatcher(key) {
|
|
25862
|
+
let dispatcher = functionPropDispatchers[key];
|
|
25863
|
+
if (!dispatcher) {
|
|
25864
|
+
dispatcher = (...callArgs) => currentFunctionProps[key]?.(...callArgs);
|
|
25865
|
+
functionPropDispatchers[key] = dispatcher;
|
|
25866
|
+
}
|
|
25867
|
+
return dispatcher;
|
|
25868
|
+
}
|
|
25869
|
+
function functionPropArgsToMap(args) {
|
|
25870
|
+
const map = {};
|
|
25871
|
+
for (let i = 0; i < args.length; i += 2) {
|
|
25872
|
+
const key = args[i];
|
|
25873
|
+
const fn = args[i + 1];
|
|
25874
|
+
if (typeof key === "string" && typeof fn === "function") {
|
|
25875
|
+
map[key] = fn;
|
|
25876
|
+
}
|
|
25877
|
+
}
|
|
25878
|
+
return map;
|
|
25879
|
+
}
|
|
25880
|
+
function releaseFunctionProxy(fn) {
|
|
25881
|
+
try {
|
|
25882
|
+
fn?.[ComlinkEditor.releaseProxy]?.();
|
|
25883
|
+
} catch (e) {
|
|
25884
|
+
console.warn(
|
|
25885
|
+
"iframe DoenetEditor: failed to release stale Comlink proxy",
|
|
25886
|
+
e
|
|
25887
|
+
);
|
|
25888
|
+
}
|
|
25889
|
+
}
|
|
25890
|
+
function setCurrentFunctionProps(incoming) {
|
|
25891
|
+
for (const [key, fn] of Object.entries(currentFunctionProps)) {
|
|
25892
|
+
if (incoming[key] !== fn) {
|
|
25893
|
+
releaseFunctionProxy(fn);
|
|
25894
|
+
}
|
|
25895
|
+
}
|
|
25896
|
+
currentFunctionProps = incoming;
|
|
25897
|
+
}
|
|
25898
|
+
function syncAugmentedFunctionProps() {
|
|
25899
|
+
if (!lastAugmentedProps) {
|
|
25900
|
+
return;
|
|
25901
|
+
}
|
|
25902
|
+
const next = {};
|
|
25903
|
+
for (const [key, val] of Object.entries(lastAugmentedProps)) {
|
|
25904
|
+
if (typeof val !== "function") {
|
|
25905
|
+
next[key] = val;
|
|
25906
|
+
}
|
|
25907
|
+
}
|
|
25908
|
+
for (const key of Object.keys(currentFunctionProps)) {
|
|
25909
|
+
next[key] = getFunctionPropDispatcher(key);
|
|
25910
|
+
}
|
|
25911
|
+
lastAugmentedProps = next;
|
|
25912
|
+
}
|
|
25859
25913
|
let initialDoenetMLSource = null;
|
|
25860
25914
|
function resolveInitialDoenetMLSource(root) {
|
|
25861
25915
|
if (initialDoenetMLSource !== null) {
|
|
@@ -25901,30 +25955,15 @@ const editorIframeJsSource = `(function() {
|
|
|
25901
25955
|
);
|
|
25902
25956
|
return;
|
|
25903
25957
|
}
|
|
25904
|
-
const
|
|
25905
|
-
|
|
25906
|
-
|
|
25907
|
-
|
|
25908
|
-
|
|
25909
|
-
|
|
25910
|
-
|
|
25911
|
-
|
|
25912
|
-
e
|
|
25913
|
-
);
|
|
25914
|
-
}
|
|
25915
|
-
} else {
|
|
25916
|
-
next[key] = val;
|
|
25917
|
-
}
|
|
25918
|
-
}
|
|
25919
|
-
for (let i = 0; i < args.length; i += 2) {
|
|
25920
|
-
const key = args[i];
|
|
25921
|
-
const fn = args[i + 1];
|
|
25922
|
-
if (typeof key === "string" && typeof fn === "function") {
|
|
25923
|
-
next[key] = fn;
|
|
25924
|
-
}
|
|
25958
|
+
const incoming = functionPropArgsToMap(args);
|
|
25959
|
+
const prevKeys = Object.keys(currentFunctionProps).sort();
|
|
25960
|
+
const nextKeys = Object.keys(incoming).sort();
|
|
25961
|
+
const keysChanged = prevKeys.length !== nextKeys.length || prevKeys.some((key, i) => key !== nextKeys[i]);
|
|
25962
|
+
setCurrentFunctionProps(incoming);
|
|
25963
|
+
if (keysChanged) {
|
|
25964
|
+
syncAugmentedFunctionProps();
|
|
25965
|
+
renderWithLastAugmentedProps();
|
|
25925
25966
|
}
|
|
25926
|
-
lastAugmentedProps = next;
|
|
25927
|
-
renderWithLastAugmentedProps();
|
|
25928
25967
|
},
|
|
25929
25968
|
openDiagnosticsTab(tabId) {
|
|
25930
25969
|
if (!editorControlHandle) {
|
|
@@ -25957,14 +25996,12 @@ const editorIframeJsSource = `(function() {
|
|
|
25957
25996
|
ComlinkEditor.windowEndpoint(globalThis.parent)
|
|
25958
25997
|
);
|
|
25959
25998
|
function renderEditorWithFunctionProps(...args) {
|
|
25999
|
+
setCurrentFunctionProps(functionPropArgsToMap(args));
|
|
25960
26000
|
const augmentedDoenetEditorProps = { ...doenetEditorProps };
|
|
25961
26001
|
augmentedDoenetEditorProps.externalVirtualKeyboardProvided = true;
|
|
25962
26002
|
for (const propName of doenetEditorPropsSpecified) {
|
|
25963
|
-
if (!(propName in doenetEditorProps)) {
|
|
25964
|
-
|
|
25965
|
-
if (idx !== -1) {
|
|
25966
|
-
augmentedDoenetEditorProps[propName] = args[idx + 1];
|
|
25967
|
-
}
|
|
26003
|
+
if (!(propName in doenetEditorProps) && propName in currentFunctionProps) {
|
|
26004
|
+
augmentedDoenetEditorProps[propName] = getFunctionPropDispatcher(propName);
|
|
25968
26005
|
}
|
|
25969
26006
|
}
|
|
25970
26007
|
lastAugmentedProps = augmentedDoenetEditorProps;
|
|
@@ -63138,7 +63175,7 @@ function ExternalVirtualKeyboard() {
|
|
|
63138
63175
|
}
|
|
63139
63176
|
);
|
|
63140
63177
|
}
|
|
63141
|
-
const version = "0.7.
|
|
63178
|
+
const version = "0.7.20-dev.20260602160826.26e8707";
|
|
63142
63179
|
const latestDoenetmlVersion = version;
|
|
63143
63180
|
function DoenetViewer({
|
|
63144
63181
|
doenetML,
|