@doenet/v06-to-v07 0.7.26-dev.549 → 0.7.26-dev.551

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.
@@ -47291,7 +47291,7 @@ async function cidFromArrayBuffer(data) {
47291
47291
  await crypto.subtle.digest("SHA-256", new Uint8Array());
47292
47292
  digest = (data2) => crypto.subtle.digest("SHA-256", data2);
47293
47293
  } catch (e22) {
47294
- const sha256 = (await import("./sha256-DT5xJ2Hv-CEjYUY-P-xyGL0MuB.js").then((n2) => n2.s)).default;
47294
+ const sha256 = (await import("./sha256-DT5xJ2Hv-BKf1gPKZ-BIVxkAku.js").then((n2) => n2.s)).default;
47295
47295
  digest = (data2) => sha256(data2, {
47296
47296
  asBytes: true
47297
47297
  });
@@ -54453,13 +54453,9 @@ function postProcessCopy({
54453
54453
  }
54454
54454
  }
54455
54455
  }
54456
- for (let ind in serializedComponents) {
54457
- let component = serializedComponents[ind];
54458
- if (typeof component !== "object") {
54459
- continue;
54460
- }
54461
- postProcessCopy({
54462
- serializedComponents: component.children,
54456
+ function recurse(nestedComponents) {
54457
+ return postProcessCopy({
54458
+ serializedComponents: nestedComponents,
54463
54459
  componentIdx,
54464
54460
  addShadowDependencies,
54465
54461
  markAsPrimaryShadow,
@@ -54469,34 +54465,28 @@ function postProcessCopy({
54469
54465
  componentIndicesFound,
54470
54466
  init: false
54471
54467
  });
54468
+ }
54469
+ for (let ind in serializedComponents) {
54470
+ let component = serializedComponents[ind];
54471
+ if (typeof component !== "object") {
54472
+ continue;
54473
+ }
54474
+ recurse(component.children);
54472
54475
  for (let attrName in component.attributes) {
54473
54476
  let attribute = component.attributes[attrName];
54474
54477
  if (attribute.component) {
54475
- attribute.component = postProcessCopy({
54476
- serializedComponents: [attribute.component],
54477
- componentIdx,
54478
- addShadowDependencies,
54479
- markAsPrimaryShadow,
54480
- identifierPrefix,
54481
- unlinkExternalCopies,
54482
- copiesByRefIdx,
54483
- componentIndicesFound,
54484
- init: false
54485
- })[0];
54478
+ attribute.component = recurse([attribute.component])[0];
54486
54479
  }
54487
54480
  }
54488
54481
  if (component.replacements) {
54489
- postProcessCopy({
54490
- serializedComponents: component.replacements,
54491
- componentIdx,
54492
- addShadowDependencies,
54493
- markAsPrimaryShadow,
54494
- identifierPrefix,
54495
- unlinkExternalCopies,
54496
- copiesByRefIdx,
54497
- componentIndicesFound,
54498
- init: false
54499
- });
54482
+ recurse(component.replacements);
54483
+ }
54484
+ if (component.extending) {
54485
+ for (const pathPart of unwrapSource(component.extending).originalPath ?? []) {
54486
+ for (const index2 of pathPart.index) {
54487
+ recurse(index2.value);
54488
+ }
54489
+ }
54500
54490
  }
54501
54491
  }
54502
54492
  if (init && unlinkExternalCopies) {
@@ -64234,6 +64224,23 @@ const _RefResolutionDependency = class _RefResolutionDependency2 extends Depende
64234
64224
  source = this.dependencyHandler._components[source.shadows?.componentIdx];
64235
64225
  }
64236
64226
  }
64227
+ /**
64228
+ * Whether `resolution` landed on the reference itself or on a component containing it.
64229
+ *
64230
+ * A reference can legitimately point at its own container — `$P` inside `P`'s label
64231
+ * is how a label says "my own value" — so such a resolution is used when it is the
64232
+ * only one on offer. It is not what a *copy* wants, though. A composite that names
64233
+ * the item it creates, as `<repeat valueName="i">` does, hands that name to the copy
64234
+ * itself, so a `$i` that the copied content already carried now finds the copy rather
64235
+ * than what it named in the original. Preferring a candidate origin that resolves
64236
+ * outside the reference keeps the copied `$i` pointing where the original one did.
64237
+ */
64238
+ resolvesIntoOwnAncestry(composite, resolution) {
64239
+ const nodeIdx = resolution.nodeIdx;
64240
+ return nodeIdx === composite.componentIdx || (composite.ancestors?.some(
64241
+ (ancestor) => ancestor.componentIdx === nodeIdx
64242
+ ) ?? false);
64243
+ }
64237
64244
  async determineDownstreamComponents({ force = false } = {}) {
64238
64245
  this.compositeReplacementDependencies = [];
64239
64246
  let composite = this.dependencyHandler._components[this.compositeIdx];
@@ -64328,14 +64335,20 @@ const _RefResolutionDependency = class _RefResolutionDependency2 extends Depende
64328
64335
  );
64329
64336
  const skip_parent_search = resolveComponentResult.path[0].name === "";
64330
64337
  let refResolution;
64338
+ let selfReferentialResolution;
64331
64339
  let firstResolutionError;
64332
64340
  for (const origin of this.originsToResolveFrom(composite)) {
64333
64341
  try {
64334
- refResolution = this.dependencyHandler.core.resolvePath(
64342
+ const candidateResolution = this.dependencyHandler.core.resolvePath(
64335
64343
  { path: resolveComponentResult.path },
64336
64344
  origin,
64337
64345
  skip_parent_search
64338
64346
  );
64347
+ if (this.resolvesIntoOwnAncestry(composite, candidateResolution)) {
64348
+ selfReferentialResolution ??= candidateResolution;
64349
+ continue;
64350
+ }
64351
+ refResolution = candidateResolution;
64339
64352
  break;
64340
64353
  } catch (e32) {
64341
64354
  if (e32 === "NonUniqueReferent" || e32 === "NoReferent") {
@@ -64345,6 +64358,7 @@ const _RefResolutionDependency = class _RefResolutionDependency2 extends Depende
64345
64358
  }
64346
64359
  }
64347
64360
  }
64361
+ refResolution ??= selfReferentialResolution;
64348
64362
  if (refResolution === void 0) {
64349
64363
  const referenceText = getDoenetMLStringForReference();
64350
64364
  this.dependencyHandler.core.addDiagnostic(
@@ -242436,4 +242450,4 @@ export {
242436
242450
  getDefaultExportFromCjs$1 as g,
242437
242451
  updateSyntaxFromV06toV07 as u
242438
242452
  };
242439
- //# sourceMappingURL=index-8ukpKAbm.js.map
242453
+ //# sourceMappingURL=index-D5mqYa1b.js.map