@farm.js/core 0.1.0-beta.18 → 0.1.0-beta.19
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/agent-runtime.cjs.map +1 -1
- package/dist/agent-runtime.mjs +1 -1
- package/dist/{chunk-TWOCKYU7.mjs → chunk-5VHPEW6N.mjs} +2 -2
- package/dist/{chunk-ZCTTYTRZ.mjs → chunk-7BX7NEA7.mjs} +2 -2
- package/dist/{chunk-PWLQWGXD.mjs → chunk-JUQB43GK.mjs} +14 -5
- package/dist/chunk-JUQB43GK.mjs.map +1 -0
- package/dist/{chunk-XFYFRBX5.mjs → chunk-MFH7BNPY.mjs} +2 -2
- package/dist/{chunk-XFYFRBX5.mjs.map → chunk-MFH7BNPY.mjs.map} +1 -1
- package/dist/{chunk-6OKRBYDC.mjs → chunk-UNDUIGWC.mjs} +33 -15
- package/dist/chunk-UNDUIGWC.mjs.map +1 -0
- package/dist/{chunk-SBLHLAE3.mjs → chunk-ZYDQS2TT.mjs} +88 -5
- package/dist/chunk-ZYDQS2TT.mjs.map +1 -0
- package/dist/{chunk-DGJPXXVL.mjs → chunk-ZYHIM7O7.mjs} +6 -6
- package/dist/{devtools-NVNCOYRJ.mjs → devtools-4RDGBT72.mjs} +3 -3
- package/dist/docs.cjs.map +1 -1
- package/dist/docs.mjs +3 -3
- package/dist/index.cjs +136 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +9 -7
- package/dist/index.mjs.map +1 -1
- package/dist/integrations.cjs +82 -4
- package/dist/integrations.cjs.map +1 -1
- package/dist/integrations.mjs +3 -1
- package/dist/internal/build-runtime.cjs +134 -20
- package/dist/internal/build-runtime.cjs.map +1 -1
- package/dist/internal/build-runtime.mjs +7 -7
- package/dist/internal/config-runtime.cjs +75 -4
- package/dist/internal/config-runtime.cjs.map +1 -1
- package/dist/internal/config-runtime.mjs +2 -2
- package/dist/plugin.cjs +62 -15
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.mjs +4 -4
- package/dist/server.cjs +138 -20
- package/dist/server.cjs.map +1 -1
- package/dist/server.mjs +5 -5
- package/dist/version.cjs +1 -1
- package/dist/version.cjs.map +1 -1
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +25 -3
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.mjs +3 -3
- package/package.json +1 -1
- package/dist/chunk-6OKRBYDC.mjs.map +0 -1
- package/dist/chunk-PWLQWGXD.mjs.map +0 -1
- package/dist/chunk-SBLHLAE3.mjs.map +0 -1
- /package/dist/{chunk-TWOCKYU7.mjs.map → chunk-5VHPEW6N.mjs.map} +0 -0
- /package/dist/{chunk-ZCTTYTRZ.mjs.map → chunk-7BX7NEA7.mjs.map} +0 -0
- /package/dist/{chunk-DGJPXXVL.mjs.map → chunk-ZYHIM7O7.mjs.map} +0 -0
- /package/dist/{devtools-NVNCOYRJ.mjs.map → devtools-4RDGBT72.mjs.map} +0 -0
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
loadConfig,
|
|
6
6
|
resolveConfig,
|
|
7
7
|
resolveDeployConfig
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-7BX7NEA7.mjs";
|
|
9
9
|
import "../chunk-UVCIEUJC.mjs";
|
|
10
10
|
import "../chunk-RQ633A5I.mjs";
|
|
11
11
|
import "../chunk-E257KFBU.mjs";
|
|
@@ -19,7 +19,7 @@ import "../chunk-ZVWA4ZQ3.mjs";
|
|
|
19
19
|
import "../chunk-7FBJLMQH.mjs";
|
|
20
20
|
import "../chunk-4E6VRJ6P.mjs";
|
|
21
21
|
import "../chunk-GXASWWJU.mjs";
|
|
22
|
-
import "../chunk-
|
|
22
|
+
import "../chunk-ZYDQS2TT.mjs";
|
|
23
23
|
import "../chunk-QGOHVJ6J.mjs";
|
|
24
24
|
import "../chunk-FQYDHKKU.mjs";
|
|
25
25
|
import "../chunk-GQVGIUSN.mjs";
|
package/dist/plugin.cjs
CHANGED
|
@@ -222,6 +222,20 @@ var init_request_context = __esm({
|
|
|
222
222
|
}
|
|
223
223
|
});
|
|
224
224
|
|
|
225
|
+
// src/plugin-integration-context.ts
|
|
226
|
+
function getFarmPluginIntegrationContext(plugin) {
|
|
227
|
+
const value = plugin[FARM_PLUGIN_INTEGRATION_CONTEXT];
|
|
228
|
+
return value && typeof value === "object" ? value : void 0;
|
|
229
|
+
}
|
|
230
|
+
var FARM_PLUGIN_INTEGRATION_CONTEXT;
|
|
231
|
+
var init_plugin_integration_context = __esm({
|
|
232
|
+
"src/plugin-integration-context.ts"() {
|
|
233
|
+
"use strict";
|
|
234
|
+
FARM_PLUGIN_INTEGRATION_CONTEXT = /* @__PURE__ */ Symbol.for("@farm.js/core/plugin-integration-context");
|
|
235
|
+
__name(getFarmPluginIntegrationContext, "getFarmPluginIntegrationContext");
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
|
|
225
239
|
// src/markdown.ts
|
|
226
240
|
function resolveMarkdownConfig(config) {
|
|
227
241
|
if (config === false) {
|
|
@@ -2854,6 +2868,10 @@ var init_integration_orm = __esm({
|
|
|
2854
2868
|
});
|
|
2855
2869
|
|
|
2856
2870
|
// src/integrations.ts
|
|
2871
|
+
function getFarmIntegrationPluginOwner(plugin) {
|
|
2872
|
+
const value = plugin[FARM_INTEGRATION_PLUGIN_OWNER];
|
|
2873
|
+
return value && typeof value === "object" ? value : void 0;
|
|
2874
|
+
}
|
|
2857
2875
|
function defineTypedIntegrationRoute(method, path26, input) {
|
|
2858
2876
|
return {
|
|
2859
2877
|
path: path26,
|
|
@@ -3865,16 +3883,19 @@ function normalizeMatcher(matcher) {
|
|
|
3865
3883
|
}
|
|
3866
3884
|
return typeof matcher === "string" ? matcher : matcher.join(", ");
|
|
3867
3885
|
}
|
|
3868
|
-
var FARM_INTEGRATION_INTERNAL_DISPATCH_CONTEXT_KEY, integrationRoute, INTEGRATION_RUNTIME_REGISTRY_KEY, INTEGRATION_REQUEST_DISPATCHER_KEY, INTEGRATION_DATA_HEADER, INTEGRATION_DATA_HEADER_MAX_LENGTH, BLOCKED_INTEGRATION_DATA_KEYS;
|
|
3886
|
+
var FARM_INTEGRATION_INTERNAL_DISPATCH_CONTEXT_KEY, FARM_INTEGRATION_PLUGIN_OWNER, integrationRoute, INTEGRATION_RUNTIME_REGISTRY_KEY, INTEGRATION_REQUEST_DISPATCHER_KEY, INTEGRATION_DATA_HEADER, INTEGRATION_DATA_HEADER_MAX_LENGTH, BLOCKED_INTEGRATION_DATA_KEYS;
|
|
3869
3887
|
var init_integrations = __esm({
|
|
3870
3888
|
"src/integrations.ts"() {
|
|
3871
3889
|
"use strict";
|
|
3872
3890
|
init_integration_api();
|
|
3891
|
+
init_plugin_integration_context();
|
|
3873
3892
|
init_request_context();
|
|
3874
3893
|
init_response();
|
|
3875
3894
|
init_server_http();
|
|
3876
3895
|
init_integration_api();
|
|
3877
3896
|
FARM_INTEGRATION_INTERNAL_DISPATCH_CONTEXT_KEY = "farm.integration.internalDispatch";
|
|
3897
|
+
FARM_INTEGRATION_PLUGIN_OWNER = /* @__PURE__ */ Symbol.for("@farm.js/core/integration-plugin-owner");
|
|
3898
|
+
__name(getFarmIntegrationPluginOwner, "getFarmIntegrationPluginOwner");
|
|
3878
3899
|
__name(defineTypedIntegrationRoute, "defineTypedIntegrationRoute");
|
|
3879
3900
|
__name(createIntegrationRouteFactory, "createIntegrationRouteFactory");
|
|
3880
3901
|
integrationRoute = createIntegrationRouteFactory();
|
|
@@ -12082,6 +12103,7 @@ __export(plugin_exports, {
|
|
|
12082
12103
|
module.exports = __toCommonJS(plugin_exports);
|
|
12083
12104
|
init_env();
|
|
12084
12105
|
init_request_context();
|
|
12106
|
+
init_plugin_integration_context();
|
|
12085
12107
|
|
|
12086
12108
|
// src/app.ts
|
|
12087
12109
|
init_app_markdown();
|
|
@@ -23528,7 +23550,15 @@ window.__FARM_MANIFEST__ = ${inlineValue({
|
|
|
23528
23550
|
const startTime2 = Date.now();
|
|
23529
23551
|
try {
|
|
23530
23552
|
if (pm) {
|
|
23531
|
-
await pm.
|
|
23553
|
+
await pm.runHookParallelFiltered(
|
|
23554
|
+
"beforeRequest",
|
|
23555
|
+
(plugin) => {
|
|
23556
|
+
const owner = getFarmIntegrationPluginOwner(plugin);
|
|
23557
|
+
return owner?.source !== "lifecycle" || owner.key !== matchedRoute.key;
|
|
23558
|
+
},
|
|
23559
|
+
req,
|
|
23560
|
+
res
|
|
23561
|
+
);
|
|
23532
23562
|
}
|
|
23533
23563
|
if (res.writableEnded) {
|
|
23534
23564
|
const duration2 = Date.now() - startTime2;
|
|
@@ -26377,10 +26407,14 @@ var _PluginManager = class _PluginManager {
|
|
|
26377
26407
|
}
|
|
26378
26408
|
};
|
|
26379
26409
|
}
|
|
26380
|
-
|
|
26410
|
+
createPluginHookContext(plugin, context = this.context) {
|
|
26411
|
+
const integration = getFarmPluginIntegrationContext(plugin);
|
|
26412
|
+
return integration ? { ...context, integration } : context;
|
|
26413
|
+
}
|
|
26414
|
+
createRequestHookContext(target, plugin) {
|
|
26381
26415
|
const requestContext = this.context.requestContext;
|
|
26382
26416
|
return {
|
|
26383
|
-
...this.
|
|
26417
|
+
...this.createPluginHookContext(plugin),
|
|
26384
26418
|
req: {
|
|
26385
26419
|
set(key, value, options) {
|
|
26386
26420
|
requestContext.set(target, key, value, options);
|
|
@@ -26423,7 +26457,7 @@ var _PluginManager = class _PluginManager {
|
|
|
26423
26457
|
return {
|
|
26424
26458
|
...this.createStateHookContext(plugin),
|
|
26425
26459
|
request,
|
|
26426
|
-
req: this.createRequestHookContext(request).req,
|
|
26460
|
+
req: this.createRequestHookContext(request, plugin).req,
|
|
26427
26461
|
kind: options.kind ?? "request",
|
|
26428
26462
|
route: options.route,
|
|
26429
26463
|
signal: request.signal,
|
|
@@ -26489,7 +26523,7 @@ var _PluginManager = class _PluginManager {
|
|
|
26489
26523
|
}
|
|
26490
26524
|
createStateHookContext(plugin, context = this.context) {
|
|
26491
26525
|
return {
|
|
26492
|
-
...context,
|
|
26526
|
+
...this.createPluginHookContext(plugin, context),
|
|
26493
26527
|
state: this.pluginStates.get(plugin)
|
|
26494
26528
|
};
|
|
26495
26529
|
}
|
|
@@ -26617,14 +26651,14 @@ var _PluginManager = class _PluginManager {
|
|
|
26617
26651
|
}
|
|
26618
26652
|
return hooks;
|
|
26619
26653
|
}
|
|
26620
|
-
getHookContext(hookName, args) {
|
|
26654
|
+
getHookContext(plugin, hookName, args) {
|
|
26621
26655
|
if (hookName === "beforeRequest" || hookName === "afterResponse" || hookName === "beforeApiHandler") {
|
|
26622
26656
|
const target = args[0];
|
|
26623
26657
|
if (target && typeof target === "object") {
|
|
26624
|
-
return this.createRequestHookContext(target);
|
|
26658
|
+
return this.createRequestHookContext(target, plugin);
|
|
26625
26659
|
}
|
|
26626
26660
|
}
|
|
26627
|
-
return this.
|
|
26661
|
+
return this.createPluginHookContext(plugin);
|
|
26628
26662
|
}
|
|
26629
26663
|
addPlugin(plugin) {
|
|
26630
26664
|
this.plugins.push(plugin);
|
|
@@ -26673,7 +26707,7 @@ var _PluginManager = class _PluginManager {
|
|
|
26673
26707
|
for (const plugin of this.getSortedPlugins()) {
|
|
26674
26708
|
if (!plugin.setup) continue;
|
|
26675
26709
|
const state = await plugin.setup({
|
|
26676
|
-
...this.
|
|
26710
|
+
...this.createPluginHookContext(plugin),
|
|
26677
26711
|
env: getResolvedEnv()
|
|
26678
26712
|
});
|
|
26679
26713
|
this.pluginStates.set(plugin, state);
|
|
@@ -26844,7 +26878,7 @@ var _PluginManager = class _PluginManager {
|
|
|
26844
26878
|
const plugins = this.getSortedPlugins();
|
|
26845
26879
|
for (const plugin of plugins) {
|
|
26846
26880
|
for (const hook of this.getPluginHooks(plugin, hookName)) {
|
|
26847
|
-
const hookContext = this.getHookContext(hookName, args);
|
|
26881
|
+
const hookContext = this.getHookContext(plugin, hookName, args);
|
|
26848
26882
|
const result = await hook.apply(plugin, [...args, hookContext]);
|
|
26849
26883
|
if (result !== void 0) {
|
|
26850
26884
|
return result;
|
|
@@ -26858,7 +26892,7 @@ var _PluginManager = class _PluginManager {
|
|
|
26858
26892
|
for (const plugin of plugins) {
|
|
26859
26893
|
for (const hook of this.getPluginHooks(plugin, hookName)) {
|
|
26860
26894
|
const hookArgs = [value, ...args];
|
|
26861
|
-
const hookContext = this.getHookContext(hookName, hookArgs);
|
|
26895
|
+
const hookContext = this.getHookContext(plugin, hookName, hookArgs);
|
|
26862
26896
|
const result = await hook.apply(plugin, [...hookArgs, hookContext]);
|
|
26863
26897
|
if (result !== void 0) {
|
|
26864
26898
|
if (hookName === "beforeApiHandler" && result !== value && value && result && typeof value === "object" && typeof result === "object") {
|
|
@@ -26871,11 +26905,15 @@ var _PluginManager = class _PluginManager {
|
|
|
26871
26905
|
return value;
|
|
26872
26906
|
}
|
|
26873
26907
|
async runHookParallel(hookName, ...args) {
|
|
26908
|
+
return this.runHookParallelFiltered(hookName, () => true, ...args);
|
|
26909
|
+
}
|
|
26910
|
+
/** @internal Runs hooks for only the plugins selected by the runtime adapter. */
|
|
26911
|
+
async runHookParallelFiltered(hookName, include, ...args) {
|
|
26874
26912
|
if (hookName === "shutdown" && !this.runtimeShutdownHooksRunning) {
|
|
26875
26913
|
await this.closeRuntime(args[0]?.reason);
|
|
26876
26914
|
return false;
|
|
26877
26915
|
}
|
|
26878
|
-
const plugins = this.getSortedPlugins();
|
|
26916
|
+
const plugins = this.getSortedPlugins().filter(include);
|
|
26879
26917
|
const sequentialHooks = /* @__PURE__ */ new Set([
|
|
26880
26918
|
"ready",
|
|
26881
26919
|
"shutdown",
|
|
@@ -26898,7 +26936,7 @@ var _PluginManager = class _PluginManager {
|
|
|
26898
26936
|
return true;
|
|
26899
26937
|
}
|
|
26900
26938
|
}
|
|
26901
|
-
const hookContext = this.getHookContext(hookName, args);
|
|
26939
|
+
const hookContext = this.getHookContext(plugin, hookName, args);
|
|
26902
26940
|
try {
|
|
26903
26941
|
await hook.apply(plugin, [...args, hookContext]);
|
|
26904
26942
|
} catch (error) {
|
|
@@ -26920,7 +26958,7 @@ var _PluginManager = class _PluginManager {
|
|
|
26920
26958
|
const promises3 = [];
|
|
26921
26959
|
for (const plugin of plugins) {
|
|
26922
26960
|
for (const hook of this.getPluginHooks(plugin, hookName)) {
|
|
26923
|
-
const hookContext = this.getHookContext(hookName, args);
|
|
26961
|
+
const hookContext = this.getHookContext(plugin, hookName, args);
|
|
26924
26962
|
promises3.push(hook.apply(plugin, [...args, hookContext]));
|
|
26925
26963
|
}
|
|
26926
26964
|
}
|
|
@@ -26944,6 +26982,15 @@ function definePlugin(plugin) {
|
|
|
26944
26982
|
return plugin;
|
|
26945
26983
|
}
|
|
26946
26984
|
__name(definePlugin, "definePlugin");
|
|
26985
|
+
((definePlugin2) => {
|
|
26986
|
+
function forIntegration() {
|
|
26987
|
+
return /* @__PURE__ */ __name(function defineBoundPlugin(plugin) {
|
|
26988
|
+
return plugin;
|
|
26989
|
+
}, "defineBoundPlugin");
|
|
26990
|
+
}
|
|
26991
|
+
definePlugin2.forIntegration = forIntegration;
|
|
26992
|
+
__name(forIntegration, "forIntegration");
|
|
26993
|
+
})(definePlugin || (definePlugin = {}));
|
|
26947
26994
|
// Annotate the CommonJS export names for ESM import in node:
|
|
26948
26995
|
0 && (module.exports = {
|
|
26949
26996
|
FarmRuntimeShutdownError,
|