obsidian-dev-utils 101.8.0 → 102.1.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 102.1.0
4
+
5
+ - test(integration): reword a comment so cspell accepts it
6
+ - test(integration): opt back into the settings popout the harness now switches off
7
+ - chore(spellcheck): accept remapper, the pathRemapper seam's noun
8
+ - feat(obsidian/link): add editBacklinksSnapshot, the primitive editBacklinks now wraps
9
+ - chore: update libs
10
+
11
+ ## 102.0.0
12
+
13
+ - feat(script-utils)!: write demo-vault archives with fflate, dropping adm-zip from the package
14
+
3
15
  ## 101.8.0
4
16
 
5
17
  - feat(script-utils): enforce the transport's script-timeout cap on in-Obsidian closures
@@ -8658,6 +8658,7 @@ var require_react_production = __commonJS({
8658
8658
  var REACT_MEMO_TYPE = /* @__PURE__ */ Symbol.for("react.memo");
8659
8659
  var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
8660
8660
  var REACT_ACTIVITY_TYPE = /* @__PURE__ */ Symbol.for("react.activity");
8661
+ var REACT_VIEW_TRANSITION_TYPE = /* @__PURE__ */ Symbol.for("react.view_transition");
8661
8662
  var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
8662
8663
  function getIteratorFn(maybeIterable) {
8663
8664
  if (null === maybeIterable || "object" !== typeof maybeIterable) return null;
@@ -8845,19 +8846,18 @@ var require_react_production = __commonJS({
8845
8846
  }
8846
8847
  function lazyInitializer(payload) {
8847
8848
  if (-1 === payload._status) {
8848
- var ctor = payload._result;
8849
- ctor = ctor();
8850
- ctor.then(
8849
+ var ctor = payload._result, thenable = ctor();
8850
+ thenable.then(
8851
8851
  function(moduleObject) {
8852
8852
  if (0 === payload._status || -1 === payload._status)
8853
- payload._status = 1, payload._result = moduleObject;
8853
+ payload._status = 1, payload._result = moduleObject, void 0 === thenable.status && (thenable.status = "fulfilled", thenable.value = moduleObject);
8854
8854
  },
8855
8855
  function(error) {
8856
8856
  if (0 === payload._status || -1 === payload._status)
8857
- payload._status = 2, payload._result = error;
8857
+ payload._status = 2, payload._result = error, void 0 === thenable.status && (thenable.status = "rejected", thenable.reason = error);
8858
8858
  }
8859
8859
  );
8860
- -1 === payload._status && (payload._status = 0, payload._result = ctor);
8860
+ -1 === payload._status && (payload._status = 0, payload._result = thenable);
8861
8861
  }
8862
8862
  if (1 === payload._status) return payload._result.default;
8863
8863
  throw payload._result;
@@ -8877,6 +8877,27 @@ var require_react_production = __commonJS({
8877
8877
  }
8878
8878
  console.error(error);
8879
8879
  };
8880
+ function startTransition(scope) {
8881
+ var prevTransition = ReactSharedInternals.T, currentTransition = {};
8882
+ currentTransition.types = null !== prevTransition ? prevTransition.types : null;
8883
+ ReactSharedInternals.T = currentTransition;
8884
+ try {
8885
+ var returnValue = scope(), onStartTransitionFinish = ReactSharedInternals.S;
8886
+ null !== onStartTransitionFinish && onStartTransitionFinish(currentTransition, returnValue);
8887
+ "object" === typeof returnValue && null !== returnValue && "function" === typeof returnValue.then && returnValue.then(noop3, reportGlobalError);
8888
+ } catch (error) {
8889
+ reportGlobalError(error);
8890
+ } finally {
8891
+ null !== prevTransition && null !== currentTransition.types && (prevTransition.types = currentTransition.types), ReactSharedInternals.T = prevTransition;
8892
+ }
8893
+ }
8894
+ function addTransitionType(type) {
8895
+ var transition = ReactSharedInternals.T;
8896
+ if (null !== transition) {
8897
+ var transitionTypes = transition.types;
8898
+ null === transitionTypes ? transition.types = [type] : -1 === transitionTypes.indexOf(type) && transitionTypes.push(type);
8899
+ } else startTransition(addTransitionType.bind(null, type));
8900
+ }
8880
8901
  var Children = {
8881
8902
  map: mapChildren,
8882
8903
  forEach: function(children, forEachFunc, forEachContext) {
@@ -8916,6 +8937,7 @@ var require_react_production = __commonJS({
8916
8937
  exports2.PureComponent = PureComponent;
8917
8938
  exports2.StrictMode = REACT_STRICT_MODE_TYPE;
8918
8939
  exports2.Suspense = REACT_SUSPENSE_TYPE;
8940
+ exports2.ViewTransition = REACT_VIEW_TRANSITION_TYPE;
8919
8941
  exports2.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = ReactSharedInternals;
8920
8942
  exports2.__COMPILER_RUNTIME = {
8921
8943
  __proto__: null,
@@ -8923,6 +8945,7 @@ var require_react_production = __commonJS({
8923
8945
  return ReactSharedInternals.H.useMemoCache(size);
8924
8946
  }
8925
8947
  };
8948
+ exports2.addTransitionType = addTransitionType;
8926
8949
  exports2.cache = function(fn) {
8927
8950
  return function() {
8928
8951
  return fn.apply(null, arguments);
@@ -9003,19 +9026,7 @@ var require_react_production = __commonJS({
9003
9026
  compare: void 0 === compare ? null : compare
9004
9027
  };
9005
9028
  };
9006
- exports2.startTransition = function(scope) {
9007
- var prevTransition = ReactSharedInternals.T, currentTransition = {};
9008
- ReactSharedInternals.T = currentTransition;
9009
- try {
9010
- var returnValue = scope(), onStartTransitionFinish = ReactSharedInternals.S;
9011
- null !== onStartTransitionFinish && onStartTransitionFinish(currentTransition, returnValue);
9012
- "object" === typeof returnValue && null !== returnValue && "function" === typeof returnValue.then && returnValue.then(noop3, reportGlobalError);
9013
- } catch (error) {
9014
- reportGlobalError(error);
9015
- } finally {
9016
- null !== prevTransition && null !== currentTransition.types && (prevTransition.types = currentTransition.types), ReactSharedInternals.T = prevTransition;
9017
- }
9018
- };
9029
+ exports2.startTransition = startTransition;
9019
9030
  exports2.unstable_useCacheRefresh = function() {
9020
9031
  return ReactSharedInternals.H.useCacheRefresh();
9021
9032
  };
@@ -9079,7 +9090,7 @@ var require_react_production = __commonJS({
9079
9090
  exports2.useTransition = function() {
9080
9091
  return ReactSharedInternals.H.useTransition();
9081
9092
  };
9082
- exports2.version = "19.2.8";
9093
+ exports2.version = "19.3.0";
9083
9094
  }
9084
9095
  });
9085
9096
 
@@ -9170,6 +9181,8 @@ var require_react_development = __commonJS({
9170
9181
  return "SuspenseList";
9171
9182
  case REACT_ACTIVITY_TYPE:
9172
9183
  return "Activity";
9184
+ case REACT_VIEW_TRANSITION_TYPE:
9185
+ return "ViewTransition";
9173
9186
  }
9174
9187
  if ("object" === typeof type)
9175
9188
  switch ("number" === typeof type.tag && console.error(
@@ -9426,8 +9439,11 @@ var require_react_development = __commonJS({
9426
9439
  }
9427
9440
  function lazyInitializer(payload) {
9428
9441
  if (-1 === payload._status) {
9429
- var ioInfo = payload._ioInfo;
9430
- null != ioInfo && (ioInfo.start = ioInfo.end = performance.now());
9442
+ var resolveDebugValue = null, rejectDebugValue = null, ioInfo = payload._ioInfo;
9443
+ null != ioInfo && (ioInfo.start = ioInfo.end = performance.now(), ioInfo.value = new Promise(function(resolve2, reject) {
9444
+ resolveDebugValue = resolve2;
9445
+ rejectDebugValue = reject;
9446
+ }));
9431
9447
  ioInfo = payload._result;
9432
9448
  var thenable = ioInfo();
9433
9449
  thenable.then(
@@ -9436,7 +9452,13 @@ var require_react_development = __commonJS({
9436
9452
  payload._status = 1;
9437
9453
  payload._result = moduleObject;
9438
9454
  var _ioInfo = payload._ioInfo;
9439
- null != _ioInfo && (_ioInfo.end = performance.now());
9455
+ if (null != _ioInfo) {
9456
+ _ioInfo.end = performance.now();
9457
+ var debugValue = null == moduleObject ? void 0 : moduleObject.default;
9458
+ resolveDebugValue(debugValue);
9459
+ _ioInfo.value.status = "fulfilled";
9460
+ _ioInfo.value.value = debugValue;
9461
+ }
9440
9462
  void 0 === thenable.status && (thenable.status = "fulfilled", thenable.value = moduleObject);
9441
9463
  }
9442
9464
  },
@@ -9445,14 +9467,13 @@ var require_react_development = __commonJS({
9445
9467
  payload._status = 2;
9446
9468
  payload._result = error;
9447
9469
  var _ioInfo2 = payload._ioInfo;
9448
- null != _ioInfo2 && (_ioInfo2.end = performance.now());
9470
+ null != _ioInfo2 && (_ioInfo2.end = performance.now(), _ioInfo2.value.then(noop3, noop3), rejectDebugValue(error), _ioInfo2.value.status = "rejected", _ioInfo2.value.reason = error);
9449
9471
  void 0 === thenable.status && (thenable.status = "rejected", thenable.reason = error);
9450
9472
  }
9451
9473
  }
9452
9474
  );
9453
9475
  ioInfo = payload._ioInfo;
9454
9476
  if (null != ioInfo) {
9455
- ioInfo.value = thenable;
9456
9477
  var displayName = thenable.displayName;
9457
9478
  "string" === typeof displayName && (ioInfo.name = displayName);
9458
9479
  }
@@ -9478,6 +9499,35 @@ var require_react_development = __commonJS({
9478
9499
  function releaseAsyncTransition() {
9479
9500
  ReactSharedInternals.asyncTransitions--;
9480
9501
  }
9502
+ function startTransition(scope) {
9503
+ var prevTransition = ReactSharedInternals.T, currentTransition = {};
9504
+ currentTransition.types = null !== prevTransition ? prevTransition.types : null;
9505
+ currentTransition._updatedFibers = /* @__PURE__ */ new Set();
9506
+ ReactSharedInternals.T = currentTransition;
9507
+ try {
9508
+ var returnValue = scope(), onStartTransitionFinish = ReactSharedInternals.S;
9509
+ null !== onStartTransitionFinish && onStartTransitionFinish(currentTransition, returnValue);
9510
+ "object" === typeof returnValue && null !== returnValue && "function" === typeof returnValue.then && (ReactSharedInternals.asyncTransitions++, returnValue.then(releaseAsyncTransition, releaseAsyncTransition), returnValue.then(noop3, reportGlobalError));
9511
+ } catch (error) {
9512
+ reportGlobalError(error);
9513
+ } finally {
9514
+ null === prevTransition && currentTransition._updatedFibers && (scope = currentTransition._updatedFibers.size, currentTransition._updatedFibers.clear(), 10 < scope && console.warn(
9515
+ "Detected a large number of updates inside startTransition. If this is due to a subscription please re-write it to use React provided hooks. Otherwise concurrent mode guarantees are off the table."
9516
+ )), null !== prevTransition && null !== currentTransition.types && (null !== prevTransition.types && prevTransition.types !== currentTransition.types && console.error(
9517
+ "We expected inner Transitions to have transferred the outer types set and that you cannot add to the outer Transition while inside the inner.This is a bug in React."
9518
+ ), prevTransition.types = currentTransition.types), ReactSharedInternals.T = prevTransition;
9519
+ }
9520
+ }
9521
+ function addTransitionType(type) {
9522
+ var transition = ReactSharedInternals.T;
9523
+ if (null !== transition) {
9524
+ var transitionTypes = transition.types;
9525
+ null === transitionTypes ? transition.types = [type] : -1 === transitionTypes.indexOf(type) && transitionTypes.push(type);
9526
+ } else
9527
+ 0 === ReactSharedInternals.asyncTransitions && console.error(
9528
+ "addTransitionType can only be called inside a `startTransition()` callback. It must be associated with a specific Transition."
9529
+ ), startTransition(addTransitionType.bind(null, type));
9530
+ }
9481
9531
  function enqueueTask(task) {
9482
9532
  if (null === enqueueTaskImpl)
9483
9533
  try {
@@ -9552,7 +9602,7 @@ var require_react_development = __commonJS({
9552
9602
  }
9553
9603
  }
9554
9604
  "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
9555
- var REACT_ELEMENT_TYPE = /* @__PURE__ */ Symbol.for("react.transitional.element"), REACT_PORTAL_TYPE = /* @__PURE__ */ Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = /* @__PURE__ */ Symbol.for("react.fragment"), REACT_STRICT_MODE_TYPE = /* @__PURE__ */ Symbol.for("react.strict_mode"), REACT_PROFILER_TYPE = /* @__PURE__ */ Symbol.for("react.profiler"), REACT_CONSUMER_TYPE = /* @__PURE__ */ Symbol.for("react.consumer"), REACT_CONTEXT_TYPE = /* @__PURE__ */ Symbol.for("react.context"), REACT_FORWARD_REF_TYPE = /* @__PURE__ */ Symbol.for("react.forward_ref"), REACT_SUSPENSE_TYPE = /* @__PURE__ */ Symbol.for("react.suspense"), REACT_SUSPENSE_LIST_TYPE = /* @__PURE__ */ Symbol.for("react.suspense_list"), REACT_MEMO_TYPE = /* @__PURE__ */ Symbol.for("react.memo"), REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy"), REACT_ACTIVITY_TYPE = /* @__PURE__ */ Symbol.for("react.activity"), MAYBE_ITERATOR_SYMBOL = Symbol.iterator, didWarnStateUpdateForUnmountedComponent = {}, ReactNoopUpdateQueue = {
9605
+ var REACT_ELEMENT_TYPE = /* @__PURE__ */ Symbol.for("react.transitional.element"), REACT_PORTAL_TYPE = /* @__PURE__ */ Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = /* @__PURE__ */ Symbol.for("react.fragment"), REACT_STRICT_MODE_TYPE = /* @__PURE__ */ Symbol.for("react.strict_mode"), REACT_PROFILER_TYPE = /* @__PURE__ */ Symbol.for("react.profiler"), REACT_CONSUMER_TYPE = /* @__PURE__ */ Symbol.for("react.consumer"), REACT_CONTEXT_TYPE = /* @__PURE__ */ Symbol.for("react.context"), REACT_FORWARD_REF_TYPE = /* @__PURE__ */ Symbol.for("react.forward_ref"), REACT_SUSPENSE_TYPE = /* @__PURE__ */ Symbol.for("react.suspense"), REACT_SUSPENSE_LIST_TYPE = /* @__PURE__ */ Symbol.for("react.suspense_list"), REACT_MEMO_TYPE = /* @__PURE__ */ Symbol.for("react.memo"), REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy"), REACT_ACTIVITY_TYPE = /* @__PURE__ */ Symbol.for("react.activity"), REACT_VIEW_TRANSITION_TYPE = /* @__PURE__ */ Symbol.for("react.view_transition"), MAYBE_ITERATOR_SYMBOL = Symbol.iterator, didWarnStateUpdateForUnmountedComponent = {}, ReactNoopUpdateQueue = {
9556
9606
  isMounted: function() {
9557
9607
  return false;
9558
9608
  },
@@ -9687,6 +9737,7 @@ var require_react_development = __commonJS({
9687
9737
  exports2.PureComponent = PureComponent;
9688
9738
  exports2.StrictMode = REACT_STRICT_MODE_TYPE;
9689
9739
  exports2.Suspense = REACT_SUSPENSE_TYPE;
9740
+ exports2.ViewTransition = REACT_VIEW_TRANSITION_TYPE;
9690
9741
  exports2.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = ReactSharedInternals;
9691
9742
  exports2.__COMPILER_RUNTIME = deprecatedAPIs;
9692
9743
  exports2.act = function(callback) {
@@ -9766,6 +9817,7 @@ var require_react_development = __commonJS({
9766
9817
  }
9767
9818
  };
9768
9819
  };
9820
+ exports2.addTransitionType = addTransitionType;
9769
9821
  exports2.cache = function(fn) {
9770
9822
  return function() {
9771
9823
  return fn.apply(null, arguments);
@@ -9842,6 +9894,7 @@ var require_react_development = __commonJS({
9842
9894
  exports2.createElement = function(type, config, children) {
9843
9895
  for (var i2 = 2; i2 < arguments.length; i2++)
9844
9896
  validateChildKeys(arguments[i2]);
9897
+ var propName;
9845
9898
  i2 = {};
9846
9899
  var key = null;
9847
9900
  if (null != config)
@@ -9864,13 +9917,13 @@ var require_react_development = __commonJS({
9864
9917
  i2,
9865
9918
  "function" === typeof type ? type.displayName || type.name || "Unknown" : type
9866
9919
  );
9867
- var propName = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
9920
+ (propName = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++) ? (childArray = Error.stackTraceLimit, Error.stackTraceLimit = 10, childrenLength = Error("react-stack-top-frame"), Error.stackTraceLimit = childArray) : childrenLength = unknownOwnerDebugStack;
9868
9921
  return ReactElement(
9869
9922
  type,
9870
9923
  key,
9871
9924
  i2,
9872
9925
  getOwner(),
9873
- propName ? Error("react-stack-top-frame") : unknownOwnerDebugStack,
9926
+ childrenLength,
9874
9927
  propName ? createTask(getTaskName(type)) : unknownOwnerDebugTask
9875
9928
  );
9876
9929
  };
@@ -9950,24 +10003,7 @@ var require_react_development = __commonJS({
9950
10003
  });
9951
10004
  return compare;
9952
10005
  };
9953
- exports2.startTransition = function(scope) {
9954
- var prevTransition = ReactSharedInternals.T, currentTransition = {};
9955
- currentTransition._updatedFibers = /* @__PURE__ */ new Set();
9956
- ReactSharedInternals.T = currentTransition;
9957
- try {
9958
- var returnValue = scope(), onStartTransitionFinish = ReactSharedInternals.S;
9959
- null !== onStartTransitionFinish && onStartTransitionFinish(currentTransition, returnValue);
9960
- "object" === typeof returnValue && null !== returnValue && "function" === typeof returnValue.then && (ReactSharedInternals.asyncTransitions++, returnValue.then(releaseAsyncTransition, releaseAsyncTransition), returnValue.then(noop3, reportGlobalError));
9961
- } catch (error) {
9962
- reportGlobalError(error);
9963
- } finally {
9964
- null === prevTransition && currentTransition._updatedFibers && (scope = currentTransition._updatedFibers.size, currentTransition._updatedFibers.clear(), 10 < scope && console.warn(
9965
- "Detected a large number of updates inside startTransition. If this is due to a subscription please re-write it to use React provided hooks. Otherwise concurrent mode guarantees are off the table."
9966
- )), null !== prevTransition && null !== currentTransition.types && (null !== prevTransition.types && prevTransition.types !== currentTransition.types && console.error(
9967
- "We expected inner Transitions to have transferred the outer types set and that you cannot add to the outer Transition while inside the inner.This is a bug in React."
9968
- ), prevTransition.types = currentTransition.types), ReactSharedInternals.T = prevTransition;
9969
- }
9970
- };
10006
+ exports2.startTransition = startTransition;
9971
10007
  exports2.unstable_useCacheRefresh = function() {
9972
10008
  return resolveDispatcher().useCacheRefresh();
9973
10009
  };
@@ -10049,7 +10085,7 @@ var require_react_development = __commonJS({
10049
10085
  exports2.useTransition = function() {
10050
10086
  return resolveDispatcher().useTransition();
10051
10087
  };
10052
- exports2.version = "19.2.8";
10088
+ exports2.version = "19.3.0";
10053
10089
  "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
10054
10090
  })();
10055
10091
  }
@@ -10513,6 +10549,7 @@ __export(merged_exports, {
10513
10549
  blobToDataUrl: () => blobToDataUrl,
10514
10550
  blobToJpegArrayBuffer: () => blobToJpegArrayBuffer,
10515
10551
  bootstrapDemoVault: () => bootstrapDemoVault,
10552
+ buildBacklinksSnapshot: () => buildBacklinksSnapshot,
10516
10553
  bypassStrictProxy: () => bypassStrictProxy,
10517
10554
  castTo: () => castTo,
10518
10555
  chain: () => chain,
@@ -10560,6 +10597,7 @@ __export(merged_exports, {
10560
10597
  doesExist: () => doesExist,
10561
10598
  drainCollectedUnhandledAsyncErrors: () => drainCollectedUnhandledAsyncErrors,
10562
10599
  editBacklinks: () => editBacklinks,
10600
+ editBacklinksSnapshot: () => editBacklinksSnapshot,
10563
10601
  editFieldsInPopover: () => editFieldsInPopover,
10564
10602
  editLinks: () => editLinks,
10565
10603
  editLinksInContent: () => editLinksInContent,
@@ -13368,8 +13406,10 @@ var link_exports = {};
13368
13406
  __export(link_exports, {
13369
13407
  LinkPathStyle: () => LinkPathStyle,
13370
13408
  LinkStyle: () => LinkStyle,
13409
+ buildBacklinksSnapshot: () => buildBacklinksSnapshot,
13371
13410
  convertLink: () => convertLink,
13372
13411
  editBacklinks: () => editBacklinks,
13412
+ editBacklinksSnapshot: () => editBacklinksSnapshot,
13373
13413
  editLinks: () => editLinks,
13374
13414
  editLinksInContent: () => editLinksInContent,
13375
13415
  extractLinkFile: () => extractLinkFile,
@@ -25417,6 +25457,28 @@ var LinkStyle = /* @__PURE__ */ ((LinkStyle2) => {
25417
25457
  LinkStyle2["Wikilink"] = "Wikilink";
25418
25458
  return LinkStyle2;
25419
25459
  })(LinkStyle || {});
25460
+ function buildBacklinksSnapshot(params) {
25461
+ const {
25462
+ backlinks,
25463
+ linkIdentityKeyProvider = defaultLinkIdentityKeyProvider,
25464
+ pathRemapper,
25465
+ payloadProvider,
25466
+ target
25467
+ } = params;
25468
+ const snapshot2 = target ?? /* @__PURE__ */ new Map();
25469
+ for (const backlinkPath of backlinks.keys()) {
25470
+ const newBacklinkPath = pathRemapper?.(backlinkPath) ?? backlinkPath;
25471
+ let payloads = snapshot2.get(newBacklinkPath);
25472
+ if (!payloads) {
25473
+ payloads = /* @__PURE__ */ new Map();
25474
+ snapshot2.set(newBacklinkPath, payloads);
25475
+ }
25476
+ for (const link2 of backlinks.get(backlinkPath) ?? []) {
25477
+ payloads.set(linkIdentityKeyProvider(link2), payloadProvider(link2));
25478
+ }
25479
+ }
25480
+ return snapshot2;
25481
+ }
25420
25482
  function convertLink(params) {
25421
25483
  const targetFile = extractLinkFile({
25422
25484
  app: params.app,
@@ -25452,19 +25514,44 @@ async function editBacklinks(params) {
25452
25514
  ...options
25453
25515
  } = params;
25454
25516
  const backlinks = await getBacklinksForFileSafe({ app, pathOrFile, ...options });
25455
- const backlinkNotePaths = [...backlinks.keys()];
25517
+ const snapshot2 = buildBacklinksSnapshot({
25518
+ backlinks,
25519
+ payloadProvider: getUndefinedPayload
25520
+ });
25521
+ await editBacklinksSnapshot(normalizeOptionalProperties({
25522
+ app,
25523
+ linkConverter: ({ link: link2 }) => linkConverter(link2),
25524
+ linkUpdateProgressReporter,
25525
+ snapshot: snapshot2,
25526
+ ...options
25527
+ }));
25528
+ }
25529
+ async function editBacklinksSnapshot(params) {
25530
+ const {
25531
+ app,
25532
+ linkConverter,
25533
+ linkIdentityKeyProvider = defaultLinkIdentityKeyProvider,
25534
+ linkUpdateProgressReporter,
25535
+ shouldVisitUnmatchedLinks = false,
25536
+ snapshot: snapshot2,
25537
+ ...options
25538
+ } = params;
25539
+ const backlinkNotePaths = [...snapshot2.keys()];
25456
25540
  let processed = 0;
25457
25541
  for (const backlinkNotePath of backlinkNotePaths) {
25458
- const currentLinks = ensureNonNullable(backlinks.get(backlinkNotePath));
25459
- const linkJsons = new Set(currentLinks.map((link2) => JSON.stringify(link2)));
25542
+ const payloads = ensureNonNullable(snapshot2.get(backlinkNotePath));
25460
25543
  await editLinks({
25461
25544
  app,
25462
25545
  linkConverter: (link2) => {
25463
- const linkJson = JSON.stringify(link2);
25464
- if (!linkJsons.has(linkJson)) {
25546
+ const linkIdentityKey = linkIdentityKeyProvider(link2);
25547
+ if (!payloads.has(linkIdentityKey) && !shouldVisitUnmatchedLinks) {
25465
25548
  return;
25466
25549
  }
25467
- return linkConverter(link2);
25550
+ return linkConverter({
25551
+ link: link2,
25552
+ payload: payloads.get(linkIdentityKey),
25553
+ sourcePath: backlinkNotePath
25554
+ });
25468
25555
  },
25469
25556
  pathOrFile: backlinkNotePath,
25470
25557
  ...options
@@ -25889,6 +25976,9 @@ async function updateLinksInFile(params) {
25889
25976
  pathOrFile: newSourcePathOrFile
25890
25977
  });
25891
25978
  }
25979
+ function defaultLinkIdentityKeyProvider(link2) {
25980
+ return JSON.stringify(link2);
25981
+ }
25892
25982
  function fixFrontmatterMarkdownLinksImpl(params) {
25893
25983
  const {
25894
25984
  cache,
@@ -26117,6 +26207,8 @@ function getLinkConfig(params) {
26117
26207
  shouldUseLeadingSlashForAbsolutePaths: params.shouldUseLeadingSlashForAbsolutePaths ?? (params.originalLink ? hasLeadingSlash(params.originalLink) : void 0) ?? false
26118
26208
  };
26119
26209
  }
26210
+ function getUndefinedPayload() {
26211
+ }
26120
26212
  function normalizeFileUrlLink(link2, shouldUseAngleBrackets) {
26121
26213
  if (isParseLinkFrontmatterReference(link2)) {
26122
26214
  if (!link2.parseLinkResult.isFileUrl) {
@@ -32488,46 +32580,53 @@ var RenameHandler = class _RenameHandler {
32488
32580
  if (!settings.shouldHandleRenames) {
32489
32581
  return;
32490
32582
  }
32491
- const backlinkEntries = [...combinedBacklinksMap, ...this.interruptedCombinedBacklinksMap];
32492
- let processedBacklinkFiles = 0;
32493
- for (const [newBacklinkPath, linkKeyToPathMap] of backlinkEntries) {
32494
- let linkIndex = 0;
32495
- await editLinks({
32496
- app: this.app,
32497
- linkConverter: (link2) => {
32498
- linkIndex++;
32499
- const oldAttachmentPath = linkKeyToPathMap.get(getLinkIdentityKey(link2));
32500
- if (!oldAttachmentPath) {
32501
- getLibDebugger("RenameDeleteHandler:updateBacklinks")(
32502
- `No snapshot entry for link ${toJson(link2)} in ${newBacklinkPath}; leaving it unchanged.`
32503
- );
32504
- return;
32505
- }
32506
- const newAttachmentPath = renameMap.get(oldAttachmentPath) ?? oldAttachmentPath;
32507
- renamedFilePaths.add(newBacklinkPath);
32508
- renamedLinks.add(`${newBacklinkPath}//${String(linkIndex)}`);
32509
- return updateLink(normalizeOptionalProperties({
32510
- app: this.app,
32511
- link: link2,
32512
- newSourcePathOrFile: newBacklinkPath,
32513
- newTargetPathOrFile: newAttachmentPath,
32514
- oldTargetPathOrFile: oldAttachmentPath,
32515
- shouldUpdateFileNameAlias: settings.shouldUpdateFileNameAliases
32516
- }));
32517
- },
32518
- pathOrFile: newBacklinkPath,
32519
- pluginNoticeComponent,
32520
- resourceLockComponent: this.resourceLockComponent,
32521
- shouldFailOnMissingFile: false
32522
- });
32523
- this.abortSignal.throwIfAborted();
32524
- processedBacklinkFiles++;
32525
- this.linkUpdateProgressReporter?.({
32526
- currentPath: newBacklinkPath,
32527
- processed: processedBacklinkFiles,
32528
- total: backlinkEntries.length
32529
- });
32583
+ for (const [interruptedBacklinkPath, interruptedLinkKeyToPathMap] of this.interruptedCombinedBacklinksMap) {
32584
+ const linkKeyToPathMap = combinedBacklinksMap.get(interruptedBacklinkPath);
32585
+ if (!linkKeyToPathMap) {
32586
+ combinedBacklinksMap.set(interruptedBacklinkPath, interruptedLinkKeyToPathMap);
32587
+ continue;
32588
+ }
32589
+ for (const [linkKey, oldTargetPath] of interruptedLinkKeyToPathMap) {
32590
+ if (!linkKeyToPathMap.has(linkKey)) {
32591
+ linkKeyToPathMap.set(linkKey, oldTargetPath);
32592
+ }
32593
+ }
32530
32594
  }
32595
+ const linkIndexes = /* @__PURE__ */ new Map();
32596
+ await editBacklinksSnapshot(normalizeOptionalProperties({
32597
+ abortSignal: this.abortSignal,
32598
+ app: this.app,
32599
+ linkConverter: ({ link: link2, payload: oldAttachmentPath, sourcePath: newBacklinkPath }) => {
32600
+ const linkIndex = (linkIndexes.get(newBacklinkPath) ?? 0) + 1;
32601
+ linkIndexes.set(newBacklinkPath, linkIndex);
32602
+ if (!oldAttachmentPath) {
32603
+ getLibDebugger("RenameDeleteHandler:updateBacklinks")(
32604
+ `No snapshot entry for link ${toJson(link2)} in ${newBacklinkPath}; leaving it unchanged.`
32605
+ );
32606
+ return;
32607
+ }
32608
+ const newAttachmentPath = renameMap.get(oldAttachmentPath) ?? oldAttachmentPath;
32609
+ renamedFilePaths.add(newBacklinkPath);
32610
+ renamedLinks.add(`${newBacklinkPath}//${String(linkIndex)}`);
32611
+ return updateLink(normalizeOptionalProperties({
32612
+ app: this.app,
32613
+ link: link2,
32614
+ newSourcePathOrFile: newBacklinkPath,
32615
+ newTargetPathOrFile: newAttachmentPath,
32616
+ oldTargetPathOrFile: oldAttachmentPath,
32617
+ shouldUpdateFileNameAlias: settings.shouldUpdateFileNameAliases
32618
+ }));
32619
+ },
32620
+ linkIdentityKeyProvider: getLinkIdentityKey,
32621
+ linkUpdateProgressReporter: this.linkUpdateProgressReporter ?? void 0,
32622
+ pluginNoticeComponent,
32623
+ resourceLockComponent: this.resourceLockComponent,
32624
+ shouldFailOnMissingFile: false,
32625
+ // The converter logs every link it declines, so it has to be shown the ones the snapshot does not name.
32626
+ shouldVisitUnmatchedLinks: true,
32627
+ snapshot: combinedBacklinksMap
32628
+ }));
32629
+ this.abortSignal.throwIfAborted();
32531
32630
  if (isNote(this.newPath)) {
32532
32631
  await updateLinksInFile(normalizeOptionalProperties({
32533
32632
  app: this.app,
@@ -32782,14 +32881,13 @@ var RenameMap = class {
32782
32881
  path,
32783
32882
  singleBacklinksMap
32784
32883
  } = params;
32785
- for (const [backlinkPath, links] of singleBacklinksMap) {
32786
- const newBacklinkPath = this.map.get(backlinkPath) ?? backlinkPath;
32787
- const linkKeyToPathMap = combinedBacklinksMap.get(newBacklinkPath) ?? /* @__PURE__ */ new Map();
32788
- combinedBacklinksMap.set(newBacklinkPath, linkKeyToPathMap);
32789
- for (const link2 of links) {
32790
- linkKeyToPathMap.set(getLinkIdentityKey(link2), path);
32791
- }
32792
- }
32884
+ buildBacklinksSnapshot({
32885
+ backlinks: singleBacklinksMap,
32886
+ linkIdentityKeyProvider: getLinkIdentityKey,
32887
+ pathRemapper: (backlinkPath) => this.map.get(backlinkPath) ?? backlinkPath,
32888
+ payloadProvider: () => path,
32889
+ target: combinedBacklinksMap
32890
+ });
32793
32891
  }
32794
32892
  initOriginalLinksMap(combinedBacklinksMap) {
32795
32893
  for (const oldPathLink of this.oldPathLinks) {