@learncard/core 9.0.3 → 9.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/dist/core.esm.js CHANGED
@@ -3417,6 +3417,8 @@ var pluginImplementsPlane = /* @__PURE__ */ __name((plugin, plane) => {
3417
3417
  return "getIndex" in (plugin.cache ?? {});
3418
3418
  if (plane === "id")
3419
3419
  return "did" in (plugin.id ?? {});
3420
+ if (plane === "context")
3421
+ return "resolveStaticDocument" in (plugin.context ?? {});
3420
3422
  return false;
3421
3423
  }, "pluginImplementsPlane");
3422
3424
  var learnCardImplementsPlane = /* @__PURE__ */ __name((learnCard, plane) => {
@@ -3430,6 +3432,8 @@ var learnCardImplementsPlane = /* @__PURE__ */ __name((learnCard, plane) => {
3430
3432
  return "cache" in learnCard;
3431
3433
  if (plane === "id")
3432
3434
  return "id" in learnCard;
3435
+ if (plane === "context")
3436
+ return "context" in learnCard;
3433
3437
  return false;
3434
3438
  }, "learnCardImplementsPlane");
3435
3439
  var mapObject = /* @__PURE__ */ __name((obj, callback) => {
@@ -3830,6 +3834,28 @@ var generateIdPlane = /* @__PURE__ */ __name((learnCard) => {
3830
3834
  providers: getPlaneProviders(learnCard.plugins, "id")
3831
3835
  };
3832
3836
  }, "generateIdPlane");
3837
+ var generateContextPlane = /* @__PURE__ */ __name((learnCard) => {
3838
+ return {
3839
+ resolveDocument: async (uri, allowRemote = false) => {
3840
+ learnCard.debug?.("learnCard.context.resolveDocument", uri);
3841
+ const staticResults = await Promise.all(learnCard.plugins.map(async (plugin) => {
3842
+ if (!pluginImplementsPlane(plugin, "context"))
3843
+ return void 0;
3844
+ return plugin.context.resolveStaticDocument(learnCard, uri);
3845
+ }));
3846
+ const staticResult = staticResults.find(Boolean);
3847
+ if (staticResult || !allowRemote)
3848
+ return staticResult;
3849
+ const remoteResults = await Promise.all(learnCard.plugins.map(async (plugin) => {
3850
+ if (!pluginImplementsPlane(plugin, "context"))
3851
+ return void 0;
3852
+ return plugin.context.resolveRemoteDocument?.(learnCard, uri);
3853
+ }));
3854
+ return remoteResults.find(Boolean);
3855
+ },
3856
+ providers: getPlaneProviders(learnCard.plugins, "context")
3857
+ };
3858
+ }, "generateContextPlane");
3833
3859
  var bindMethods = /* @__PURE__ */ __name((learnCard, pluginMethods) => bindLearnCardToFunctionsObject(learnCard, pluginMethods), "bindMethods");
3834
3860
  var generateLearnCard = /* @__PURE__ */ __name(async (_learnCard = {}) => {
3835
3861
  const { plugins = [] } = _learnCard;
@@ -3843,6 +3869,7 @@ var generateLearnCard = /* @__PURE__ */ __name(async (_learnCard = {}) => {
3843
3869
  index: {},
3844
3870
  cache: {},
3845
3871
  id: {},
3872
+ context: {},
3846
3873
  plugins,
3847
3874
  invoke: pluginMethods,
3848
3875
  addPlugin: function(plugin) {
@@ -3855,6 +3882,7 @@ var generateLearnCard = /* @__PURE__ */ __name(async (_learnCard = {}) => {
3855
3882
  learnCard.index = generateIndexPlane(learnCard);
3856
3883
  learnCard.cache = generateCachePlane(learnCard);
3857
3884
  learnCard.id = generateIdPlane(learnCard);
3885
+ learnCard.context = generateContextPlane(learnCard);
3858
3886
  if (pluginMethods)
3859
3887
  learnCard.invoke = bindMethods(learnCard, pluginMethods);
3860
3888
  return learnCard;