@doenet/v06-to-v07 0.7.26-dev.539 → 0.7.26-dev.540

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.
@@ -47272,7 +47272,7 @@ async function cidFromArrayBuffer(data) {
47272
47272
  await crypto.subtle.digest("SHA-256", new Uint8Array());
47273
47273
  digest = (data2) => crypto.subtle.digest("SHA-256", data2);
47274
47274
  } catch (e22) {
47275
- const sha256 = (await import("./sha256-DT5xJ2Hv-BVeLgYWQ-CHOh3hgV.js").then((n2) => n2.s)).default;
47275
+ const sha256 = (await import("./sha256-DT5xJ2Hv-Qy06UIn3-DoA6xmY7.js").then((n2) => n2.s)).default;
47276
47276
  digest = (data2) => sha256(data2, {
47277
47277
  asBytes: true
47278
47278
  });
@@ -68088,12 +68088,8 @@ class DependencyHandler {
68088
68088
  stateVariable
68089
68089
  );
68090
68090
  }
68091
- let neededForItem = this.peekNeededToResolve({
68092
- componentIdx,
68093
- type,
68094
- stateVariable,
68095
- dependency
68096
- });
68091
+ const item = { componentIdx, type, stateVariable, dependency };
68092
+ let neededForItem = this.peekNeededToResolve(item);
68097
68093
  let determineDepsBlockers = neededForItem.determineDependencies;
68098
68094
  if (determineDepsBlockers && determineDepsBlockers.length > 0) {
68099
68095
  for (let blockerCode of [...determineDepsBlockers]) {
@@ -68123,115 +68119,62 @@ class DependencyHandler {
68123
68119
  stateVarObj.currentlyResolving = true;
68124
68120
  }
68125
68121
  }
68126
- let previousNFailures = Infinity;
68127
- let nFailures = Infinity;
68128
- while (Object.keys(neededForItem).length > 0 || nFailures > 0) {
68129
- if (Number.isFinite(nFailures) && nFailures >= previousNFailures) {
68130
- break;
68131
- }
68132
- if (nFailures > 0) {
68133
- neededForItem = this.peekNeededToResolve({
68134
- componentIdx,
68135
- type,
68136
- stateVariable,
68137
- dependency
68122
+ try {
68123
+ let previousNFailures = Infinity;
68124
+ let nFailures = Infinity;
68125
+ while (Object.keys(neededForItem).length > 0 || nFailures > 0) {
68126
+ if (Number.isFinite(nFailures) && nFailures >= previousNFailures) {
68127
+ break;
68128
+ }
68129
+ if (nFailures > 0) {
68130
+ neededForItem = this.peekNeededToResolve(item);
68131
+ }
68132
+ previousNFailures = nFailures;
68133
+ let passResult = await this._resolveBlockersOfItem({
68134
+ neededForItem,
68135
+ item,
68136
+ forceBlockers: false,
68137
+ tolerateFailures: force,
68138
+ expandComposites
68138
68139
  });
68139
- }
68140
- previousNFailures = nFailures;
68141
- nFailures = 0;
68142
- for (let blockerType in neededForItem) {
68143
- if (blockerType === "determineDependencies") {
68144
- throw Error(
68145
- `Shouldn't have determine dependencies blocker after determining dependencies: ${componentIdx}, ${type}, ${stateVariable}, ${dependency}`
68146
- );
68140
+ if (passResult.failure) {
68141
+ return passResult.failure;
68147
68142
  }
68148
- for (let code of [...neededForItem[blockerType]]) {
68149
- let [
68150
- blockerComponentIdx,
68151
- blockerStateVariable,
68152
- blockerDependency
68153
- ] = typeof code === "string" ? code.split("|") : [code];
68154
- let result2 = await this.resolveItem({
68155
- componentIdx: blockerComponentIdx,
68156
- type: blockerType,
68157
- stateVariable: blockerStateVariable,
68158
- dependency: blockerDependency,
68159
- //force, //recurseUpstream
68143
+ nFailures = passResult.nFailures;
68144
+ }
68145
+ if (nFailures > 0) {
68146
+ neededForItem = this.peekNeededToResolve(item);
68147
+ while (Object.keys(neededForItem).length > 0) {
68148
+ let passResult = await this._resolveBlockersOfItem({
68149
+ neededForItem,
68150
+ item,
68151
+ forceBlockers: force,
68152
+ tolerateFailures: false,
68160
68153
  expandComposites
68161
68154
  });
68162
- if (!result2.success) {
68163
- if (force) {
68164
- nFailures++;
68165
- } else {
68166
- return result2;
68167
- }
68155
+ if (passResult.failure) {
68156
+ return passResult.failure;
68168
68157
  }
68169
68158
  }
68170
68159
  }
68171
- }
68172
- if (nFailures > 0) {
68173
- neededForItem = this.peekNeededToResolve({
68174
- componentIdx,
68175
- type,
68176
- stateVariable,
68177
- dependency
68178
- });
68179
- while (Object.keys(neededForItem).length > 0) {
68180
- for (let blockerType in neededForItem) {
68181
- if (blockerType === "determineDependencies") {
68182
- throw Error(
68183
- `Shouldn't have determine dependencies blocker after determining dependencies: ${componentIdx}, ${type}, ${stateVariable}, ${dependency}`
68184
- );
68185
- }
68186
- for (let code of [...neededForItem[blockerType]]) {
68187
- let [
68188
- blockerComponentIdx,
68189
- blockerStateVariable,
68190
- blockerDependency
68191
- ] = typeof code === "string" ? code.split("|") : [code];
68192
- let result2 = await this.resolveItem({
68193
- componentIdx: blockerComponentIdx,
68194
- type: blockerType,
68195
- stateVariable: blockerStateVariable,
68196
- dependency: blockerDependency,
68197
- force,
68198
- //recurseUpstream
68199
- expandComposites
68200
- });
68201
- if (!result2.success) {
68202
- return result2;
68203
- }
68204
- }
68205
- }
68160
+ } finally {
68161
+ if (stateVarObj) {
68162
+ stateVarObj.currentlyResolving = false;
68206
68163
  }
68207
68164
  }
68208
- if (stateVarObj) {
68209
- stateVarObj.currentlyResolving = false;
68210
- }
68211
68165
  let finalResult = await this.resolveIfReady({
68212
- componentIdx,
68213
- type,
68214
- stateVariable,
68215
- dependency,
68166
+ ...item,
68216
68167
  force,
68217
68168
  recurseUpstream,
68218
68169
  expandComposites
68219
68170
  });
68220
68171
  if (!finalResult.success) {
68221
- let stillNeededForItem = this.peekNeededToResolve({
68222
- componentIdx,
68223
- type,
68224
- stateVariable,
68225
- dependency
68226
- });
68172
+ let stillNeededForItem = this.peekNeededToResolve(item);
68227
68173
  let numNeeded = Object.keys(stillNeededForItem).length;
68228
68174
  if (numNeeded > 0) {
68229
68175
  if (numPreviouslyNeeded === void 0 || numNeeded < numPreviouslyNeeded) {
68230
68176
  finalResult = await this.resolveItem({
68231
- componentIdx,
68232
- type,
68233
- stateVariable,
68234
- dependency,
68177
+ ...item,
68235
68178
  force,
68236
68179
  recurseUpstream,
68237
68180
  expandComposites,
@@ -68242,6 +68185,61 @@ class DependencyHandler {
68242
68185
  }
68243
68186
  return finalResult;
68244
68187
  }
68188
+ /**
68189
+ * Make one pass over `neededForItem`, the live record of what is still
68190
+ * blocking `item`, resolving each blocker in turn. Entries drop out of the
68191
+ * record as their blockers resolve, so the caller can loop until it is
68192
+ * empty.
68193
+ *
68194
+ * `forceBlockers` is passed on to each blocker's own `resolveItem`.
68195
+ * `tolerateFailures` decides what an unresolved blocker means: when false,
68196
+ * the pass stops and hands back that blocker's result as `failure` for the
68197
+ * caller to propagate; when true, the pass continues and reports how many
68198
+ * blockers failed as `nFailures`.
68199
+ *
68200
+ * A `determineDependencies` blocker reaching here is a bug, so it throws:
68201
+ * `resolveItem` resolves those before it sets `currentlyResolving`, and
68202
+ * that flag is what stops a new one from being added while it works.
68203
+ */
68204
+ async _resolveBlockersOfItem({
68205
+ neededForItem,
68206
+ item,
68207
+ forceBlockers,
68208
+ tolerateFailures,
68209
+ expandComposites
68210
+ }) {
68211
+ let nFailures = 0;
68212
+ for (let blockerType in neededForItem) {
68213
+ if (blockerType === "determineDependencies") {
68214
+ throw Error(
68215
+ `Shouldn't have determine dependencies blocker after determining dependencies: ${item.componentIdx}, ${item.type}, ${item.stateVariable}, ${item.dependency}`
68216
+ );
68217
+ }
68218
+ for (let code of [...neededForItem[blockerType]]) {
68219
+ let [
68220
+ blockerComponentIdx,
68221
+ blockerStateVariable,
68222
+ blockerDependency
68223
+ ] = typeof code === "string" ? code.split("|") : [code];
68224
+ let result2 = await this.resolveItem({
68225
+ componentIdx: blockerComponentIdx,
68226
+ type: blockerType,
68227
+ stateVariable: blockerStateVariable,
68228
+ dependency: blockerDependency,
68229
+ force: forceBlockers,
68230
+ expandComposites
68231
+ });
68232
+ if (!result2.success) {
68233
+ if (tolerateFailures) {
68234
+ nFailures++;
68235
+ } else {
68236
+ return { failure: result2, nFailures };
68237
+ }
68238
+ }
68239
+ }
68240
+ }
68241
+ return { nFailures };
68242
+ }
68245
68243
  checkForCircularResolveBlocker({
68246
68244
  componentIdx,
68247
68245
  type,
@@ -239469,4 +239467,4 @@ export {
239469
239467
  getDefaultExportFromCjs$1 as g,
239470
239468
  updateSyntaxFromV06toV07 as u
239471
239469
  };
239472
- //# sourceMappingURL=index-Bin7pIAp.js.map
239470
+ //# sourceMappingURL=index-DYUgFZHa.js.map