@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.cjs.development.js +28 -0
- package/dist/core.cjs.development.js.map +2 -2
- package/dist/core.cjs.production.min.js +1 -1
- package/dist/core.cjs.production.min.js.map +2 -2
- package/dist/core.esm.js +28 -0
- package/dist/core.esm.js.map +2 -2
- package/dist/types/planes.d.ts +11 -1
- package/dist/types/wallet.d.ts +6 -1
- package/dist/wallet/base/wallet.d.ts +1 -0
- package/package.json +1 -1
@@ -3432,6 +3432,8 @@ var pluginImplementsPlane = /* @__PURE__ */ __name((plugin, plane) => {
|
|
3432
3432
|
return "getIndex" in (plugin.cache ?? {});
|
3433
3433
|
if (plane === "id")
|
3434
3434
|
return "did" in (plugin.id ?? {});
|
3435
|
+
if (plane === "context")
|
3436
|
+
return "resolveStaticDocument" in (plugin.context ?? {});
|
3435
3437
|
return false;
|
3436
3438
|
}, "pluginImplementsPlane");
|
3437
3439
|
var learnCardImplementsPlane = /* @__PURE__ */ __name((learnCard, plane) => {
|
@@ -3445,6 +3447,8 @@ var learnCardImplementsPlane = /* @__PURE__ */ __name((learnCard, plane) => {
|
|
3445
3447
|
return "cache" in learnCard;
|
3446
3448
|
if (plane === "id")
|
3447
3449
|
return "id" in learnCard;
|
3450
|
+
if (plane === "context")
|
3451
|
+
return "context" in learnCard;
|
3448
3452
|
return false;
|
3449
3453
|
}, "learnCardImplementsPlane");
|
3450
3454
|
var mapObject = /* @__PURE__ */ __name((obj, callback) => {
|
@@ -3845,6 +3849,28 @@ var generateIdPlane = /* @__PURE__ */ __name((learnCard) => {
|
|
3845
3849
|
providers: getPlaneProviders(learnCard.plugins, "id")
|
3846
3850
|
};
|
3847
3851
|
}, "generateIdPlane");
|
3852
|
+
var generateContextPlane = /* @__PURE__ */ __name((learnCard) => {
|
3853
|
+
return {
|
3854
|
+
resolveDocument: async (uri, allowRemote = false) => {
|
3855
|
+
learnCard.debug?.("learnCard.context.resolveDocument", uri);
|
3856
|
+
const staticResults = await Promise.all(learnCard.plugins.map(async (plugin) => {
|
3857
|
+
if (!pluginImplementsPlane(plugin, "context"))
|
3858
|
+
return void 0;
|
3859
|
+
return plugin.context.resolveStaticDocument(learnCard, uri);
|
3860
|
+
}));
|
3861
|
+
const staticResult = staticResults.find(Boolean);
|
3862
|
+
if (staticResult || !allowRemote)
|
3863
|
+
return staticResult;
|
3864
|
+
const remoteResults = await Promise.all(learnCard.plugins.map(async (plugin) => {
|
3865
|
+
if (!pluginImplementsPlane(plugin, "context"))
|
3866
|
+
return void 0;
|
3867
|
+
return plugin.context.resolveRemoteDocument?.(learnCard, uri);
|
3868
|
+
}));
|
3869
|
+
return remoteResults.find(Boolean);
|
3870
|
+
},
|
3871
|
+
providers: getPlaneProviders(learnCard.plugins, "context")
|
3872
|
+
};
|
3873
|
+
}, "generateContextPlane");
|
3848
3874
|
var bindMethods = /* @__PURE__ */ __name((learnCard, pluginMethods) => bindLearnCardToFunctionsObject(learnCard, pluginMethods), "bindMethods");
|
3849
3875
|
var generateLearnCard = /* @__PURE__ */ __name(async (_learnCard = {}) => {
|
3850
3876
|
const { plugins = [] } = _learnCard;
|
@@ -3858,6 +3884,7 @@ var generateLearnCard = /* @__PURE__ */ __name(async (_learnCard = {}) => {
|
|
3858
3884
|
index: {},
|
3859
3885
|
cache: {},
|
3860
3886
|
id: {},
|
3887
|
+
context: {},
|
3861
3888
|
plugins,
|
3862
3889
|
invoke: pluginMethods,
|
3863
3890
|
addPlugin: function(plugin) {
|
@@ -3870,6 +3897,7 @@ var generateLearnCard = /* @__PURE__ */ __name(async (_learnCard = {}) => {
|
|
3870
3897
|
learnCard.index = generateIndexPlane(learnCard);
|
3871
3898
|
learnCard.cache = generateCachePlane(learnCard);
|
3872
3899
|
learnCard.id = generateIdPlane(learnCard);
|
3900
|
+
learnCard.context = generateContextPlane(learnCard);
|
3873
3901
|
if (pluginMethods)
|
3874
3902
|
learnCard.invoke = bindMethods(learnCard, pluginMethods);
|
3875
3903
|
return learnCard;
|