@doenet/v06-to-v07 0.7.20-dev.321 → 0.7.20-dev.324
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-D7QB7nkv.js → index-Bf9-6Dgz.js} +83 -19
- package/{index-D7QB7nkv.js.map → index-Bf9-6Dgz.js.map} +1 -1
- package/index.js +1 -1
- package/package.json +1 -1
- package/{sha256-C0vj3HDn-BWgi3hyU-CUhpeiV-.js → sha256-C0vj3HDn-BqmkOZ2t-j7M8ytAj.js} +2 -2
- package/{sha256-C0vj3HDn-BWgi3hyU-CUhpeiV-.js.map → sha256-C0vj3HDn-BqmkOZ2t-j7M8ytAj.js.map} +1 -1
|
@@ -40963,7 +40963,7 @@ async function cidFromArrayBuffer(data) {
|
|
|
40963
40963
|
await crypto.subtle.digest("SHA-256", new Uint8Array());
|
|
40964
40964
|
digest = (data2) => crypto.subtle.digest("SHA-256", data2);
|
|
40965
40965
|
} catch (e22) {
|
|
40966
|
-
const sha256 = (await import("./sha256-C0vj3HDn-
|
|
40966
|
+
const sha256 = (await import("./sha256-C0vj3HDn-BqmkOZ2t-j7M8ytAj.js").then((n2) => n2.s)).default;
|
|
40967
40967
|
digest = (data2) => sha256(data2, {
|
|
40968
40968
|
asBytes: true
|
|
40969
40969
|
});
|
|
@@ -64640,13 +64640,14 @@ class StatePersistence {
|
|
|
64640
64640
|
await this.saveChangesToDatabase(true);
|
|
64641
64641
|
}
|
|
64642
64642
|
}
|
|
64643
|
-
|
|
64644
|
-
|
|
64643
|
+
/**
|
|
64644
|
+
* Build the serialized document-state payload — the shape
|
|
64645
|
+
* `reportScoreAndState` delivers to hosts and `DocViewer`'s
|
|
64646
|
+
* `initialState` accepts back.
|
|
64647
|
+
*/
|
|
64648
|
+
buildDocStatePayload(onSubmission = false) {
|
|
64645
64649
|
const core2 = this.core;
|
|
64646
|
-
|
|
64647
|
-
return;
|
|
64648
|
-
}
|
|
64649
|
-
let coreStateString = JSON.stringify(
|
|
64650
|
+
const coreStateString = JSON.stringify(
|
|
64650
64651
|
core2.cumulativeStateVariableChanges,
|
|
64651
64652
|
serializedComponentsReplacer
|
|
64652
64653
|
);
|
|
@@ -64657,6 +64658,29 @@ class StatePersistence {
|
|
|
64657
64658
|
serializedComponentsReplacer
|
|
64658
64659
|
);
|
|
64659
64660
|
}
|
|
64661
|
+
return {
|
|
64662
|
+
payload: {
|
|
64663
|
+
cid: core2.cid,
|
|
64664
|
+
coreInfo: core2.coreInfoString,
|
|
64665
|
+
coreState: coreStateString,
|
|
64666
|
+
rendererState: rendererStateString,
|
|
64667
|
+
initializeCounters: core2.initializeCounters,
|
|
64668
|
+
docId: core2.docId,
|
|
64669
|
+
attemptNumber: core2.attemptNumber,
|
|
64670
|
+
activityId: core2.activityId,
|
|
64671
|
+
onSubmission
|
|
64672
|
+
},
|
|
64673
|
+
coreStateString,
|
|
64674
|
+
rendererStateString
|
|
64675
|
+
};
|
|
64676
|
+
}
|
|
64677
|
+
async saveState(overrideThrottle = false, onSubmission = false) {
|
|
64678
|
+
this.saveDocStateTimeoutID = null;
|
|
64679
|
+
const core2 = this.core;
|
|
64680
|
+
if (!core2.flags.allowSaveState && !core2.flags.allowLocalState) {
|
|
64681
|
+
return;
|
|
64682
|
+
}
|
|
64683
|
+
const { payload, coreStateString, rendererStateString } = this.buildDocStatePayload(onSubmission);
|
|
64660
64684
|
if (core2.flags.allowLocalState) {
|
|
64661
64685
|
await set(
|
|
64662
64686
|
`${core2.activityId}|${core2.docId}|${core2.attemptNumber}|${core2.cid}`,
|
|
@@ -64671,20 +64695,30 @@ class StatePersistence {
|
|
|
64671
64695
|
if (!core2.flags.allowSaveState) {
|
|
64672
64696
|
return;
|
|
64673
64697
|
}
|
|
64674
|
-
this.docStateToBeSavedToDatabase =
|
|
64675
|
-
cid: core2.cid,
|
|
64676
|
-
coreInfo: core2.coreInfoString,
|
|
64677
|
-
coreState: coreStateString,
|
|
64678
|
-
rendererState: rendererStateString,
|
|
64679
|
-
initializeCounters: core2.initializeCounters,
|
|
64680
|
-
docId: core2.docId,
|
|
64681
|
-
attemptNumber: core2.attemptNumber,
|
|
64682
|
-
activityId: core2.activityId,
|
|
64683
|
-
onSubmission
|
|
64684
|
-
};
|
|
64698
|
+
this.docStateToBeSavedToDatabase = payload;
|
|
64685
64699
|
this.changesToBeSaved = true;
|
|
64686
64700
|
await this.saveChangesToDatabase(overrideThrottle);
|
|
64687
64701
|
}
|
|
64702
|
+
/**
|
|
64703
|
+
* Flush-state-on-demand (Doenet/DoenetML#1440): push any pending changes
|
|
64704
|
+
* through the normal `reportScoreAndState` pipeline (via `saveImmediately`)
|
|
64705
|
+
* so a persistence host saves them right away — exactly as it does for a
|
|
64706
|
+
* routine autosave, with no knowledge that a flush occurred. Reports honor
|
|
64707
|
+
* the `allowSaveState`/`allowLocalState` flags, so nothing is emitted when
|
|
64708
|
+
* saving is off (there is no persistence host to receive it).
|
|
64709
|
+
*
|
|
64710
|
+
* Returns whether this viewer held any state: `false` before document
|
|
64711
|
+
* generation has produced `coreInfoString` (the viewer holds nothing
|
|
64712
|
+
* beyond what it was initialized with, so tearing it down loses nothing
|
|
64713
|
+
* either way).
|
|
64714
|
+
*/
|
|
64715
|
+
async flushState() {
|
|
64716
|
+
if (!this.core.coreInfoString) {
|
|
64717
|
+
return false;
|
|
64718
|
+
}
|
|
64719
|
+
await this.saveImmediately();
|
|
64720
|
+
return true;
|
|
64721
|
+
}
|
|
64688
64722
|
async saveChangesToDatabase(overrideThrottle = false) {
|
|
64689
64723
|
if (!this.changesToBeSaved) {
|
|
64690
64724
|
return;
|
|
@@ -68191,6 +68225,26 @@ class Core {
|
|
|
68191
68225
|
async saveImmediately() {
|
|
68192
68226
|
return this.statePersistence.saveImmediately();
|
|
68193
68227
|
}
|
|
68228
|
+
/**
|
|
68229
|
+
* Flush-state-on-demand (Doenet/DoenetML#1440): wait briefly for
|
|
68230
|
+
* in-flight action processing to settle (the same bounded wait
|
|
68231
|
+
* `terminate` uses), then push any pending state through the normal
|
|
68232
|
+
* `reportScoreAndState` pipeline so a persistence host saves it. Returns
|
|
68233
|
+
* whether the viewer held any state. Hosts use this to unmount the
|
|
68234
|
+
* document losslessly.
|
|
68235
|
+
*/
|
|
68236
|
+
async flushState() {
|
|
68237
|
+
if (this.processQueue.processing) {
|
|
68238
|
+
const pause100 = () => new Promise((resolve) => setTimeout(resolve, 100));
|
|
68239
|
+
for (let i2 = 0; i2 < 10; i2++) {
|
|
68240
|
+
await pause100();
|
|
68241
|
+
if (!this.processQueue.processing) {
|
|
68242
|
+
break;
|
|
68243
|
+
}
|
|
68244
|
+
}
|
|
68245
|
+
}
|
|
68246
|
+
return this.statePersistence.flushState();
|
|
68247
|
+
}
|
|
68194
68248
|
async saveState(overrideThrottle = false, onSubmission = false) {
|
|
68195
68249
|
return this.statePersistence.saveState(overrideThrottle, onSubmission);
|
|
68196
68250
|
}
|
|
@@ -227406,6 +227460,16 @@ let PublicDoenetMLCore$1 = class PublicDoenetMLCore2 {
|
|
|
227406
227460
|
async saveImmediately() {
|
|
227407
227461
|
await this.core?.saveImmediately();
|
|
227408
227462
|
}
|
|
227463
|
+
/**
|
|
227464
|
+
* Flush-state-on-demand (Doenet/DoenetML#1440): after letting in-flight
|
|
227465
|
+
* updates settle, push any pending state through the normal
|
|
227466
|
+
* `reportScoreAndState` pipeline so a persistence host saves it, letting a
|
|
227467
|
+
* host unmount this document losslessly. Returns whether the viewer held
|
|
227468
|
+
* any state (`false` when the core/document has not been created yet).
|
|
227469
|
+
*/
|
|
227470
|
+
async flushState() {
|
|
227471
|
+
return await this.core?.flushState() ?? false;
|
|
227472
|
+
}
|
|
227409
227473
|
};
|
|
227410
227474
|
const AFFECTED_ATTRIBUTES = [
|
|
227411
227475
|
"target",
|
|
@@ -229299,4 +229363,4 @@ export {
|
|
|
229299
229363
|
getDefaultExportFromCjs as g,
|
|
229300
229364
|
updateSyntaxFromV06toV07 as u
|
|
229301
229365
|
};
|
|
229302
|
-
//# sourceMappingURL=index-
|
|
229366
|
+
//# sourceMappingURL=index-Bf9-6Dgz.js.map
|