@frontmcp/sdk 1.12.2 → 1.13.0-rc.1
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/agent/agent.instance.d.ts +2 -0
- package/agent/agent.instance.d.ts.map +1 -1
- package/app/instances/app.lazy.instance.d.ts.map +1 -1
- package/app/lazy/lazy-app.rules.d.ts +5 -0
- package/app/lazy/lazy-app.rules.d.ts.map +1 -1
- package/auth/flows/auth.verify.flow.d.ts.map +1 -1
- package/auth/flows/oauth.authorize.flow.d.ts +2 -0
- package/auth/flows/oauth.authorize.flow.d.ts.map +1 -1
- package/auth/flows/oauth.callback.flow.d.ts +1 -0
- package/auth/flows/oauth.callback.flow.d.ts.map +1 -1
- package/auth/flows/oauth.provider-callback.flow.d.ts +1 -0
- package/auth/flows/oauth.provider-callback.flow.d.ts.map +1 -1
- package/auth/flows/session.verify.flow.d.ts +2 -0
- package/auth/flows/session.verify.flow.d.ts.map +1 -1
- package/auth/instances/instance.local-primary-auth.d.ts +9 -4
- package/auth/instances/instance.local-primary-auth.d.ts.map +1 -1
- package/auth/instances/instance.remote-primary-auth.d.ts +3 -0
- package/auth/instances/instance.remote-primary-auth.d.ts.map +1 -1
- package/auth/session-scope-identity.d.ts +5 -3
- package/auth/session-scope-identity.d.ts.map +1 -1
- package/auth/transparent-audience.d.ts +21 -0
- package/auth/transparent-audience.d.ts.map +1 -0
- package/browser/agent/agent.instance.mjs +9 -1
- package/browser/app/instances/app.lazy.instance.mjs +10 -2
- package/browser/app/lazy/lazy-app.rules.mjs +11 -1
- package/browser/auth/flows/oauth.authorize.flow.mjs +7 -1
- package/browser/auth/flows/oauth.callback.flow.mjs +6 -2
- package/browser/auth/flows/oauth.provider-callback.flow.mjs +8 -4
- package/browser/auth/flows/session.verify.flow.mjs +27 -18
- package/browser/auth/instances/instance.local-primary-auth.mjs +46 -12
- package/browser/auth/instances/instance.remote-primary-auth.mjs +21 -1
- package/browser/auth/session-scope-identity.mjs +6 -1
- package/browser/auth/transparent-audience.mjs +52 -0
- package/browser/common/interfaces/flow.interface.mjs +7 -1
- package/browser/common/interfaces/tool.interface.mjs +4 -0
- package/browser/common/metadata/app.metadata.mjs +2 -0
- package/browser/common/metadata/front-mcp.metadata.mjs +4 -0
- package/browser/common/metadata/input-policy.mjs +12 -0
- package/browser/common/metadata/output-policy.mjs +1 -0
- package/browser/common/metadata/tool.metadata.mjs +3 -1
- package/browser/common/tokens/app.tokens.mjs +1 -0
- package/browser/common/tokens/front-mcp.tokens.mjs +1 -0
- package/browser/common/tokens/tool.tokens.mjs +2 -1
- package/browser/common/types/auth/session.types.mjs +2 -1
- package/browser/common/utils/auth-info.utils.mjs +3 -2
- package/browser/context/frontmcp-context.mjs +2 -2
- package/browser/elicitation/questions/ask-question.mjs +1 -2
- package/browser/elicitation/questions/question.store.mjs +22 -8
- package/browser/elicitation/send-elicitation-result.tool.mjs +11 -6
- package/browser/flows/flow.instance.mjs +43 -5
- package/browser/hooks/hooks.utils.mjs +10 -4
- package/browser/index.cjs +6138 -5052
- package/browser/notification/notification.service.mjs +29 -4
- package/browser/notification/resource-update-access.mjs +22 -0
- package/browser/plugin/enforced-metadata.check.mjs +2 -1
- package/browser/prompt/flows/get-prompt.flow.mjs +13 -0
- package/browser/remote-mcp/factories/record-builders.mjs +2 -0
- package/browser/remote-mcp/mcp-client.service.mjs +26 -13
- package/browser/remote-mcp/remote-request-headers.mjs +6 -3
- package/browser/resource/flows/read-resource.flow.mjs +52 -32
- package/browser/resource/flows/subscribe-resource.flow.mjs +9 -4
- package/browser/scope/scope.instance.mjs +3 -1
- package/browser/server/security/resolve-allowed-hosts.mjs +3 -2
- package/browser/task/store/storage-task.store.mjs +69 -20
- package/browser/task/store/task-session-index.mjs +300 -0
- package/browser/task/store/task-store.factory.mjs +4 -1
- package/browser/tool/flows/call-tool.flow.mjs +103 -21
- package/browser/tool/flows/tools-list.flow.mjs +49 -8
- package/browser/tool/tool-output-policy.mjs +14 -3
- package/browser/tool/tool.instance.mjs +9 -2
- package/browser/tool/tool.utils.mjs +90 -3
- package/browser/tool/ui/app-only-tools.mjs +17 -0
- package/browser/tool/ui/ui-shared.mjs +9 -0
- package/browser/tool/undeclared-arguments-message.mjs +61 -0
- package/browser/tool/undeclared-arguments.mjs +35 -0
- package/browser/transport/flows/handle.mcp-20260728.flow.mjs +21 -19
- package/browser/transport/mcp-20260728/index.mjs +1 -1
- package/browser/transport/mcp-20260728/subscriptions.mjs +8 -6
- package/common/entries/tool.entry.d.ts +12 -1
- package/common/entries/tool.entry.d.ts.map +1 -1
- package/common/interfaces/flow.interface.d.ts +4 -1
- package/common/interfaces/flow.interface.d.ts.map +1 -1
- package/common/interfaces/tool.interface.d.ts +17 -0
- package/common/interfaces/tool.interface.d.ts.map +1 -1
- package/common/metadata/app.metadata.d.ts +35 -16
- package/common/metadata/app.metadata.d.ts.map +1 -1
- package/common/metadata/front-mcp.metadata.d.ts +198 -46
- package/common/metadata/front-mcp.metadata.d.ts.map +1 -1
- package/common/metadata/index.d.ts +1 -0
- package/common/metadata/index.d.ts.map +1 -1
- package/common/metadata/input-policy.d.ts +22 -0
- package/common/metadata/input-policy.d.ts.map +1 -0
- package/common/metadata/output-policy.d.ts +21 -3
- package/common/metadata/output-policy.d.ts.map +1 -1
- package/common/metadata/tool.metadata.d.ts +20 -1
- package/common/metadata/tool.metadata.d.ts.map +1 -1
- package/common/records/app.record.d.ts +2 -1
- package/common/records/app.record.d.ts.map +1 -1
- package/common/tokens/app.tokens.d.ts.map +1 -1
- package/common/tokens/front-mcp.tokens.d.ts.map +1 -1
- package/common/tokens/tool.tokens.d.ts +1 -0
- package/common/tokens/tool.tokens.d.ts.map +1 -1
- package/common/types/auth/session.types.d.ts +6 -0
- package/common/types/auth/session.types.d.ts.map +1 -1
- package/common/types/options/http/interfaces.d.ts +4 -1
- package/common/types/options/http/interfaces.d.ts.map +1 -1
- package/common/utils/auth-info.utils.d.ts +1 -0
- package/common/utils/auth-info.utils.d.ts.map +1 -1
- package/elicitation/elicitation.types.d.ts +2 -0
- package/elicitation/elicitation.types.d.ts.map +1 -1
- package/elicitation/questions/ask-question.d.ts.map +1 -1
- package/elicitation/questions/question.store.d.ts +5 -0
- package/elicitation/questions/question.store.d.ts.map +1 -1
- package/esm/index.mjs +32 -32
- package/flows/flow.instance.d.ts.map +1 -1
- package/hooks/hooks.utils.d.ts +2 -4
- package/hooks/hooks.utils.d.ts.map +1 -1
- package/index.d.ts +20 -20
- package/index.js +42 -42
- package/notification/notification.service.d.ts +7 -2
- package/notification/notification.service.d.ts.map +1 -1
- package/notification/resource-update-access.d.ts +9 -0
- package/notification/resource-update-access.d.ts.map +1 -0
- package/package.json +10 -10
- package/plugin/enforced-metadata.check.d.ts +3 -1
- package/plugin/enforced-metadata.check.d.ts.map +1 -1
- package/prompt/flows/get-prompt.flow.d.ts +3 -1
- package/prompt/flows/get-prompt.flow.d.ts.map +1 -1
- package/remote-mcp/factories/record-builders.d.ts.map +1 -1
- package/remote-mcp/mcp-client.service.d.ts.map +1 -1
- package/remote-mcp/mcp-client.types.d.ts.map +1 -1
- package/remote-mcp/remote-request-headers.d.ts +22 -8
- package/remote-mcp/remote-request-headers.d.ts.map +1 -1
- package/resource/flows/read-resource.flow.d.ts +15 -1
- package/resource/flows/read-resource.flow.d.ts.map +1 -1
- package/resource/flows/subscribe-resource.flow.d.ts.map +1 -1
- package/scope/flows/http.request.flow.d.ts +1 -0
- package/scope/flows/http.request.flow.d.ts.map +1 -1
- package/scope/scope.instance.d.ts.map +1 -1
- package/server/adapters/express.host.adapter.d.ts +3 -2
- package/server/adapters/express.host.adapter.d.ts.map +1 -1
- package/server/security/resolve-allowed-hosts.d.ts +4 -2
- package/server/security/resolve-allowed-hosts.d.ts.map +1 -1
- package/shared/shared-endpoint.d.ts +5 -1
- package/shared/shared-endpoint.d.ts.map +1 -1
- package/shared/unix-socket-fetch.d.ts +7 -0
- package/shared/unix-socket-fetch.d.ts.map +1 -1
- package/task/store/storage-task.store.d.ts +19 -2
- package/task/store/storage-task.store.d.ts.map +1 -1
- package/task/store/task-session-index.d.ts +100 -0
- package/task/store/task-session-index.d.ts.map +1 -0
- package/task/store/task-store.factory.d.ts +5 -0
- package/task/store/task-store.factory.d.ts.map +1 -1
- package/task/task.types.d.ts +6 -0
- package/task/task.types.d.ts.map +1 -1
- package/tool/flows/call-tool.flow.d.ts +13 -1
- package/tool/flows/call-tool.flow.d.ts.map +1 -1
- package/tool/flows/tools-list.flow.d.ts +8 -1
- package/tool/flows/tools-list.flow.d.ts.map +1 -1
- package/tool/tool-output-policy.d.ts +6 -1
- package/tool/tool-output-policy.d.ts.map +1 -1
- package/tool/tool.instance.d.ts +2 -0
- package/tool/tool.instance.d.ts.map +1 -1
- package/tool/tool.utils.d.ts +12 -0
- package/tool/tool.utils.d.ts.map +1 -1
- package/tool/ui/app-only-tools.d.ts +9 -0
- package/tool/ui/app-only-tools.d.ts.map +1 -0
- package/tool/ui/ui-shared.d.ts +4 -0
- package/tool/ui/ui-shared.d.ts.map +1 -1
- package/tool/undeclared-arguments-message.d.ts +13 -0
- package/tool/undeclared-arguments-message.d.ts.map +1 -0
- package/tool/undeclared-arguments.d.ts +7 -0
- package/tool/undeclared-arguments.d.ts.map +1 -0
- package/transport/flows/handle.mcp-20260728.flow.d.ts.map +1 -1
- package/transport/mcp-20260728/subscriptions.d.ts +5 -3
- package/transport/mcp-20260728/subscriptions.d.ts.map +1 -1
|
@@ -10,6 +10,7 @@ import { validateElicitationContent } from "../helpers/validate-elicitation-cont
|
|
|
10
10
|
import { deserializeAndDecrypt, encryptAndSerialize } from "../store/elicitation-encryption.mjs";
|
|
11
11
|
import { QuestionAlreadyAnsweredError, QuestionNotFoundError, QuestionStoreBusyError } from "./question.errors.mjs";
|
|
12
12
|
var QUESTIONS_TOPIC = "questions";
|
|
13
|
+
var QUESTION_TOPIC_PREFIX = "question:";
|
|
13
14
|
var RECORD_PREFIX = "q:";
|
|
14
15
|
var MAX_ATTEMPTS = 16;
|
|
15
16
|
var textEncoder = new TextEncoder();
|
|
@@ -43,7 +44,7 @@ var QuestionStore = class {
|
|
|
43
44
|
}
|
|
44
45
|
const { record, raw } = current;
|
|
45
46
|
if (record.answer) {
|
|
46
|
-
if (await this.claim(storageKey, raw)) {
|
|
47
|
+
if (await this.claim(storageKey, raw, record.expiresAt)) {
|
|
47
48
|
return { kind: "answered", answer: record.answer, expiresAt: record.expiresAt };
|
|
48
49
|
}
|
|
49
50
|
continue;
|
|
@@ -62,7 +63,7 @@ var QuestionStore = class {
|
|
|
62
63
|
if (!current || current.record.waiter !== waiter) return { kind: "superseded" };
|
|
63
64
|
const { record, raw } = current;
|
|
64
65
|
if (!record.answer) return { kind: "waiting", question: view(record) };
|
|
65
|
-
if (await this.claim(storageKey, raw)) {
|
|
66
|
+
if (await this.claim(storageKey, raw, record.expiresAt)) {
|
|
66
67
|
return { kind: "answered", answer: record.answer, expiresAt: record.expiresAt };
|
|
67
68
|
}
|
|
68
69
|
}
|
|
@@ -116,6 +117,10 @@ var QuestionStore = class {
|
|
|
116
117
|
subscribe(topic, listener) {
|
|
117
118
|
return this.options.feed.subscribe(topic, listener);
|
|
118
119
|
}
|
|
120
|
+
/** Call `listener` when the question `key` of `subject` changes, here or in another process, and for no other. */
|
|
121
|
+
subscribeToQuestion(subject, key, listener) {
|
|
122
|
+
return this.options.feed.subscribe(this.questionTopic(this.recordKey(subject, key)), listener);
|
|
123
|
+
}
|
|
119
124
|
async close() {
|
|
120
125
|
await this.options.feed.close();
|
|
121
126
|
await this.options.storage.disconnect();
|
|
@@ -140,12 +145,12 @@ var QuestionStore = class {
|
|
|
140
145
|
});
|
|
141
146
|
const stored = await this.read(storageKey, request.subject);
|
|
142
147
|
if (stored?.record.id !== record.id) return void 0;
|
|
143
|
-
await this.changed();
|
|
148
|
+
await this.changed(storageKey, record.expiresAt);
|
|
144
149
|
return record;
|
|
145
150
|
}
|
|
146
|
-
async claim(storageKey, raw) {
|
|
151
|
+
async claim(storageKey, raw, expiresAt) {
|
|
147
152
|
const claimed = await this.options.storage.deleteIfEquals(storageKey, raw);
|
|
148
|
-
if (claimed) await this.changed();
|
|
153
|
+
if (claimed) await this.changed(storageKey, expiresAt);
|
|
149
154
|
return claimed;
|
|
150
155
|
}
|
|
151
156
|
async replace(storageKey, raw, record) {
|
|
@@ -153,7 +158,7 @@ var QuestionStore = class {
|
|
|
153
158
|
const { storage } = this.options;
|
|
154
159
|
if (!await storage.setIfEquals(storageKey, raw, next)) return false;
|
|
155
160
|
await storage.expireIfEquals(storageKey, next, ttlSecondsUntil(record.expiresAt));
|
|
156
|
-
await this.changed();
|
|
161
|
+
await this.changed(storageKey, record.expiresAt);
|
|
157
162
|
return true;
|
|
158
163
|
}
|
|
159
164
|
async read(storageKey, subject) {
|
|
@@ -203,9 +208,18 @@ var QuestionStore = class {
|
|
|
203
208
|
const text = `${kind}:${value}`;
|
|
204
209
|
return secret === void 0 ? sha256Hex(text) : bytesToHex(hmacSha256(textEncoder.encode(secret), textEncoder.encode(text)));
|
|
205
210
|
}
|
|
206
|
-
|
|
211
|
+
/** A question's topic names it by its storage key, made of digests, so it shows neither the subject nor the key. */
|
|
212
|
+
questionTopic(storageKey) {
|
|
213
|
+
return QUESTION_TOPIC_PREFIX + storageKey;
|
|
214
|
+
}
|
|
215
|
+
/** Tell the inbox, and the call waiting on this question; a polling feed drops the question's counter with it. */
|
|
216
|
+
async changed(storageKey, expiresAt) {
|
|
217
|
+
const { feed } = this.options;
|
|
207
218
|
try {
|
|
208
|
-
await
|
|
219
|
+
await Promise.all([
|
|
220
|
+
feed.publish(QUESTIONS_TOPIC),
|
|
221
|
+
feed.publish(this.questionTopic(storageKey), { ttlSeconds: ttlSecondsUntil(expiresAt) })
|
|
222
|
+
]);
|
|
209
223
|
} catch {
|
|
210
224
|
}
|
|
211
225
|
}
|
|
@@ -96,12 +96,17 @@ var SendElicitationResultTool = class extends ToolContext {
|
|
|
96
96
|
// The call context of this call, whose caller is the owner: its auth info as its transport
|
|
97
97
|
// gave it (the tool reads it as `this.auth`), on the surface it was made from. Not the
|
|
98
98
|
// request context object, whose auth info is a getter a call context does not carry over.
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
99
|
+
// The first try's idempotency key is kept, not enumerable, as its dispatcher set it.
|
|
100
|
+
ctx: Object.defineProperty(
|
|
101
|
+
{
|
|
102
|
+
authInfo: this.authInfo,
|
|
103
|
+
requestId: this.tryGetContext()?.requestId ?? this.runId,
|
|
104
|
+
surface: getCallSurface(),
|
|
105
|
+
...this.signal ? { signal: this.signal } : {}
|
|
106
|
+
},
|
|
107
|
+
"idempotencyKey",
|
|
108
|
+
{ value: pending.idempotencyKey }
|
|
109
|
+
)
|
|
105
110
|
});
|
|
106
111
|
this.logger.info("sendElicitationResult: original tool completed", {
|
|
107
112
|
elicitId,
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
withHookTrace
|
|
21
21
|
} from "../hooks/hook-observers.mjs";
|
|
22
22
|
import { hookOwnerName } from "../hooks/hook-order.mjs";
|
|
23
|
-
import { bindContextHookTargets, staticHooksFor } from "../hooks/hooks.utils.mjs";
|
|
23
|
+
import { bindContextHookTargets, sourceMetadataOf, staticHooksFor } from "../hooks/hooks.utils.mjs";
|
|
24
24
|
import { writeHttpResponse } from "../server/server.validation.mjs";
|
|
25
25
|
import { flowErrorToHttpOutput } from "../transport/flow-error-output.mjs";
|
|
26
26
|
import { deferredFlowLoader } from "./deferred-flow.mjs";
|
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
} from "./flow.stages.mjs";
|
|
34
34
|
import { collectFlowMetadata } from "./flow.utils.mjs";
|
|
35
35
|
var FAILED_OUTCOMES = /* @__PURE__ */ new Set(["fail", "abort", "unknown_error"]);
|
|
36
|
+
var REGISTRY_HOOK_ORDER_START = -1e6;
|
|
36
37
|
var CAP = (s) => s ? s[0].toUpperCase() + s.slice(1) : s;
|
|
37
38
|
var stageKeysByName = /* @__PURE__ */ new Map();
|
|
38
39
|
function stageKeysOf(stage) {
|
|
@@ -377,9 +378,12 @@ var FlowInstance = class extends FlowEntry {
|
|
|
377
378
|
const hookOwnerId = await FlowClass.resolveHookOwnerId?.(input, scope);
|
|
378
379
|
const entryClass = await FlowClass.resolveHookEntryClass?.(input, scope);
|
|
379
380
|
const entryStaticHooks = entryClass ? staticHooksFor(this.hooks.getClsHooks(entryClass), name) : [];
|
|
381
|
+
const bindRun = { sessionKey, contextProviders: mergedDeps, contextSource: this.globalProviders };
|
|
382
|
+
const ownerHooks = this.hooks.getFlowHooksForOwner(name, hookOwnerId) ?? [];
|
|
383
|
+
let registryHookOrder = REGISTRY_HOOK_ORDER_START + ownerHooks.length;
|
|
380
384
|
const initialInjectedHooks = await bindContextHookTargets(
|
|
381
|
-
|
|
382
|
-
|
|
385
|
+
ownerHooks,
|
|
386
|
+
bindRun
|
|
383
387
|
);
|
|
384
388
|
let contextReady = false;
|
|
385
389
|
const trace = this.tracesHooks ? [] : void 0;
|
|
@@ -426,9 +430,43 @@ var FlowInstance = class extends FlowEntry {
|
|
|
426
430
|
const appendContextHooks = async (hooks) => {
|
|
427
431
|
await materializeAndMerge(hooks);
|
|
428
432
|
};
|
|
429
|
-
|
|
433
|
+
let entryHooks = [...ownerHooks, ...entryStaticHooks];
|
|
434
|
+
let entryTarget = { ownerId: hookOwnerId, entryClass };
|
|
435
|
+
const retargetEntryHooks = async (ownerId, nextEntryClass) => {
|
|
436
|
+
if (ownerId === entryTarget.ownerId && nextEntryClass === entryTarget.entryClass) return;
|
|
437
|
+
entryTarget = { ownerId, entryClass: nextEntryClass };
|
|
438
|
+
const nextStaticHooks = nextEntryClass ? staticHooksFor(this.hooks.getClsHooks(nextEntryClass), name) : [];
|
|
439
|
+
const nextOwnerHooks = this.hooks.getFlowHooksForOwner(name, ownerId) ?? [];
|
|
440
|
+
const nextHooks = [...nextOwnerHooks, ...nextStaticHooks];
|
|
441
|
+
const leaving = new Set(entryHooks.filter((hook) => !nextHooks.includes(hook)).map((hook) => hook.metadata));
|
|
442
|
+
const joining = nextHooks.filter((hook) => !entryHooks.includes(hook));
|
|
443
|
+
entryHooks = nextHooks;
|
|
444
|
+
if (leaving.size > 0) {
|
|
445
|
+
if (!ownsStages) {
|
|
446
|
+
stages = cloneStageMap(baseStages);
|
|
447
|
+
ownsStages = true;
|
|
448
|
+
}
|
|
449
|
+
for (const key of Object.keys(stages)) {
|
|
450
|
+
stages[key] = stages[key].filter((entry) => !leaving.has(sourceMetadataOf(entry.hook)));
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
const joiningOwnerHooks = joining.filter((hook) => nextOwnerHooks.includes(hook));
|
|
454
|
+
await materializeAndMerge(await bindContextHookTargets(joiningOwnerHooks, bindRun), {
|
|
455
|
+
orderStart: registryHookOrder
|
|
456
|
+
});
|
|
457
|
+
registryHookOrder += joiningOwnerHooks.length;
|
|
458
|
+
await materializeAndMerge(joining.filter((hook) => !nextOwnerHooks.includes(hook)));
|
|
459
|
+
};
|
|
460
|
+
const context = new FlowClass(
|
|
461
|
+
this.metadata,
|
|
462
|
+
input,
|
|
463
|
+
scope,
|
|
464
|
+
appendContextHooks,
|
|
465
|
+
mergedDeps,
|
|
466
|
+
retargetEntryHooks
|
|
467
|
+
);
|
|
430
468
|
contextReady = true;
|
|
431
|
-
await materializeAndMerge(initialInjectedHooks, { orderStart:
|
|
469
|
+
await materializeAndMerge(initialInjectedHooks, { orderStart: REGISTRY_HOOK_ORDER_START });
|
|
432
470
|
if (ownsStages) orderBase = nextStageOrder(stages);
|
|
433
471
|
await materializeAndMerge(entryStaticHooks);
|
|
434
472
|
if (this.loggedHookOrders) this.logHookOrderOnce(this.loggedHookOrders, stages, hookOwnerId, entryClass);
|
|
@@ -56,6 +56,10 @@ function contextInstanceOf(providers, token) {
|
|
|
56
56
|
return typeof instance === "object" && instance !== null ? instance : void 0;
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
|
+
var boundFrom = /* @__PURE__ */ new WeakMap();
|
|
60
|
+
function sourceMetadataOf(metadata) {
|
|
61
|
+
return boundFrom.get(metadata) ?? metadata;
|
|
62
|
+
}
|
|
59
63
|
async function bindContextHookTargets(hooks, run) {
|
|
60
64
|
if (!hooks.some((hook) => hook.metadata.contextTarget)) return [...hooks];
|
|
61
65
|
const bound = [];
|
|
@@ -66,10 +70,11 @@ async function bindContextHookTargets(hooks, run) {
|
|
|
66
70
|
continue;
|
|
67
71
|
}
|
|
68
72
|
const target = await contextTarget(run);
|
|
69
|
-
if (target)
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
});
|
|
73
|
+
if (target) {
|
|
74
|
+
const metadata = { ...hook.metadata, target, contextTarget: void 0 };
|
|
75
|
+
boundFrom.set(metadata, hook.metadata);
|
|
76
|
+
bound.push({ metadata });
|
|
77
|
+
}
|
|
73
78
|
}
|
|
74
79
|
return bound;
|
|
75
80
|
}
|
|
@@ -87,5 +92,6 @@ export {
|
|
|
87
92
|
normalizeHooksFromCls,
|
|
88
93
|
normalizeHooksFromProviders,
|
|
89
94
|
serverProviderHooks,
|
|
95
|
+
sourceMetadataOf,
|
|
90
96
|
staticHooksFor
|
|
91
97
|
};
|