@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.
Files changed (49) hide show
  1. package/dist/agent-runtime.cjs.map +1 -1
  2. package/dist/agent-runtime.mjs +1 -1
  3. package/dist/{chunk-TWOCKYU7.mjs → chunk-5VHPEW6N.mjs} +2 -2
  4. package/dist/{chunk-ZCTTYTRZ.mjs → chunk-7BX7NEA7.mjs} +2 -2
  5. package/dist/{chunk-PWLQWGXD.mjs → chunk-JUQB43GK.mjs} +14 -5
  6. package/dist/chunk-JUQB43GK.mjs.map +1 -0
  7. package/dist/{chunk-XFYFRBX5.mjs → chunk-MFH7BNPY.mjs} +2 -2
  8. package/dist/{chunk-XFYFRBX5.mjs.map → chunk-MFH7BNPY.mjs.map} +1 -1
  9. package/dist/{chunk-6OKRBYDC.mjs → chunk-UNDUIGWC.mjs} +33 -15
  10. package/dist/chunk-UNDUIGWC.mjs.map +1 -0
  11. package/dist/{chunk-SBLHLAE3.mjs → chunk-ZYDQS2TT.mjs} +88 -5
  12. package/dist/chunk-ZYDQS2TT.mjs.map +1 -0
  13. package/dist/{chunk-DGJPXXVL.mjs → chunk-ZYHIM7O7.mjs} +6 -6
  14. package/dist/{devtools-NVNCOYRJ.mjs → devtools-4RDGBT72.mjs} +3 -3
  15. package/dist/docs.cjs.map +1 -1
  16. package/dist/docs.mjs +3 -3
  17. package/dist/index.cjs +136 -20
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.mjs +9 -7
  20. package/dist/index.mjs.map +1 -1
  21. package/dist/integrations.cjs +82 -4
  22. package/dist/integrations.cjs.map +1 -1
  23. package/dist/integrations.mjs +3 -1
  24. package/dist/internal/build-runtime.cjs +134 -20
  25. package/dist/internal/build-runtime.cjs.map +1 -1
  26. package/dist/internal/build-runtime.mjs +7 -7
  27. package/dist/internal/config-runtime.cjs +75 -4
  28. package/dist/internal/config-runtime.cjs.map +1 -1
  29. package/dist/internal/config-runtime.mjs +2 -2
  30. package/dist/plugin.cjs +62 -15
  31. package/dist/plugin.cjs.map +1 -1
  32. package/dist/plugin.mjs +4 -4
  33. package/dist/server.cjs +138 -20
  34. package/dist/server.cjs.map +1 -1
  35. package/dist/server.mjs +5 -5
  36. package/dist/version.cjs +1 -1
  37. package/dist/version.cjs.map +1 -1
  38. package/dist/version.mjs +1 -1
  39. package/dist/vite.cjs +25 -3
  40. package/dist/vite.cjs.map +1 -1
  41. package/dist/vite.mjs +3 -3
  42. package/package.json +1 -1
  43. package/dist/chunk-6OKRBYDC.mjs.map +0 -1
  44. package/dist/chunk-PWLQWGXD.mjs.map +0 -1
  45. package/dist/chunk-SBLHLAE3.mjs.map +0 -1
  46. /package/dist/{chunk-TWOCKYU7.mjs.map → chunk-5VHPEW6N.mjs.map} +0 -0
  47. /package/dist/{chunk-ZCTTYTRZ.mjs.map → chunk-7BX7NEA7.mjs.map} +0 -0
  48. /package/dist/{chunk-DGJPXXVL.mjs.map → chunk-ZYHIM7O7.mjs.map} +0 -0
  49. /package/dist/{devtools-NVNCOYRJ.mjs.map → devtools-4RDGBT72.mjs.map} +0 -0
@@ -1,19 +1,19 @@
1
1
  import {
2
2
  build
3
- } from "../chunk-DGJPXXVL.mjs";
3
+ } from "../chunk-ZYHIM7O7.mjs";
4
4
  import "../chunk-4S3ORGFA.mjs";
5
5
  import "../chunk-SL6HTIOK.mjs";
6
- import "../chunk-TWOCKYU7.mjs";
6
+ import "../chunk-5VHPEW6N.mjs";
7
7
  import "../chunk-V7RBCSDJ.mjs";
8
8
  import {
9
9
  loadConfig,
10
10
  resolveConfig,
11
11
  resolveDeployConfig
12
- } from "../chunk-ZCTTYTRZ.mjs";
12
+ } from "../chunk-7BX7NEA7.mjs";
13
13
  import "../chunk-UVCIEUJC.mjs";
14
- import "../chunk-6OKRBYDC.mjs";
14
+ import "../chunk-UNDUIGWC.mjs";
15
15
  import "../chunk-RQ633A5I.mjs";
16
- import "../chunk-PWLQWGXD.mjs";
16
+ import "../chunk-JUQB43GK.mjs";
17
17
  import "../chunk-LGHEOHBU.mjs";
18
18
  import "../chunk-FRPWCMMG.mjs";
19
19
  import "../chunk-53MVSX3R.mjs";
@@ -36,7 +36,7 @@ import "../chunk-ZVWA4ZQ3.mjs";
36
36
  import "../chunk-7FBJLMQH.mjs";
37
37
  import "../chunk-4E6VRJ6P.mjs";
38
38
  import "../chunk-GXASWWJU.mjs";
39
- import "../chunk-SBLHLAE3.mjs";
39
+ import "../chunk-ZYDQS2TT.mjs";
40
40
  import "../chunk-T4QJQK76.mjs";
41
41
  import "../chunk-MIUW47JX.mjs";
42
42
  import "../chunk-P7QDS5AT.mjs";
@@ -56,7 +56,7 @@ import "../chunk-KQCOGTU7.mjs";
56
56
  import "../chunk-YTMDIHQN.mjs";
57
57
  import "../chunk-RHIFZZUI.mjs";
58
58
  import "../chunk-LM2YNO4U.mjs";
59
- import "../chunk-XFYFRBX5.mjs";
59
+ import "../chunk-MFH7BNPY.mjs";
60
60
  import "../chunk-B3FFOIWS.mjs";
61
61
  import "../chunk-ITN462YM.mjs";
62
62
  import "../chunk-3HIVDX7J.mjs";
@@ -647,6 +647,15 @@ function defineIntegrationAPIOperation(operation) {
647
647
  }
648
648
  __name(defineIntegrationAPIOperation, "defineIntegrationAPIOperation");
649
649
 
650
+ // src/plugin-integration-context.ts
651
+ var FARM_PLUGIN_INTEGRATION_CONTEXT = /* @__PURE__ */ Symbol.for("@farm.js/core/plugin-integration-context");
652
+ function setFarmPluginIntegrationContext(plugin, integration) {
653
+ Object.defineProperty(plugin, FARM_PLUGIN_INTEGRATION_CONTEXT, {
654
+ value: integration
655
+ });
656
+ }
657
+ __name(setFarmPluginIntegrationContext, "setFarmPluginIntegrationContext");
658
+
650
659
  // src/request-context.ts
651
660
  var REQUEST_CONTEXT_STORE_KEY = /* @__PURE__ */ Symbol.for("farm.requestContextStore");
652
661
  function getRequestContextStore() {
@@ -1050,6 +1059,7 @@ var FARM_INTEGRATION_INTERNAL_DISPATCH_CONTEXT_KEY = "farm.integration.internalD
1050
1059
  var FARM_INTEGRATION_PLUGIN_SERVER_RUNTIME = /* @__PURE__ */ Symbol.for(
1051
1060
  "@farm.js/core/integration-plugin-server-runtime"
1052
1061
  );
1062
+ var FARM_INTEGRATION_PLUGIN_OWNER = /* @__PURE__ */ Symbol.for("@farm.js/core/integration-plugin-owner");
1053
1063
  function defineTypedIntegrationRoute(method, path5, input) {
1054
1064
  return {
1055
1065
  path: path5,
@@ -1151,14 +1161,75 @@ function resolveIntegrationPlugins(integrations) {
1151
1161
  if (!integration || !isFarmIntegration(integration)) {
1152
1162
  continue;
1153
1163
  }
1154
- plugins.push(createIntegrationPlugin(key, integration));
1155
- if (integration.plugins?.length) {
1156
- plugins.push(...integration.plugins);
1157
- }
1164
+ const owner = createIntegrationPluginOwner(key, integration, "lifecycle");
1165
+ plugins.push(withIntegrationPluginOwner(createIntegrationPlugin(key, integration), owner));
1166
+ plugins.push(...resolveIntegrationPluginContributions(key, integration));
1158
1167
  }
1159
1168
  return plugins;
1160
1169
  }
1161
1170
  __name(resolveIntegrationPlugins, "resolveIntegrationPlugins");
1171
+ function resolveIntegrationPluginContributions(key, integration) {
1172
+ const contributions = integration.plugins;
1173
+ if (!contributions) return [];
1174
+ if (!Array.isArray(contributions)) {
1175
+ throw new TypeError(`Integration "${key}" plugins must be an array`);
1176
+ }
1177
+ const names = /* @__PURE__ */ new Set();
1178
+ return contributions.map((plugin, index) => {
1179
+ if (!plugin || typeof plugin !== "object" || typeof plugin.name !== "string") {
1180
+ throw new TypeError(`Integration "${key}" plugin at index ${index} is invalid`);
1181
+ }
1182
+ const name = plugin.name.trim();
1183
+ if (!name) {
1184
+ throw new TypeError(`Integration "${key}" plugin at index ${index} requires a name`);
1185
+ }
1186
+ if (names.has(name)) {
1187
+ throw new Error(`Integration "${key}" contributes duplicate plugin name "${name}"`);
1188
+ }
1189
+ names.add(name);
1190
+ return withIntegrationPluginOwner(
1191
+ plugin,
1192
+ createIntegrationPluginOwner(key, integration, "contribution"),
1193
+ createIntegrationPluginContext(key, integration)
1194
+ );
1195
+ });
1196
+ }
1197
+ __name(resolveIntegrationPluginContributions, "resolveIntegrationPluginContributions");
1198
+ function createIntegrationPluginOwner(key, integration, source) {
1199
+ return Object.freeze({
1200
+ key,
1201
+ category: integration.category,
1202
+ type: integration.type,
1203
+ source,
1204
+ serverRuntime: integration.serverRuntime !== false
1205
+ });
1206
+ }
1207
+ __name(createIntegrationPluginOwner, "createIntegrationPluginOwner");
1208
+ function createIntegrationPluginContext(key, integration) {
1209
+ return Object.freeze({
1210
+ key,
1211
+ category: integration.category,
1212
+ type: integration.type,
1213
+ instance: integration.instance,
1214
+ serverRuntime: integration.serverRuntime !== false
1215
+ });
1216
+ }
1217
+ __name(createIntegrationPluginContext, "createIntegrationPluginContext");
1218
+ function withIntegrationPluginOwner(plugin, owner, integration) {
1219
+ const descriptors = Object.getOwnPropertyDescriptors(plugin);
1220
+ Reflect.deleteProperty(descriptors, FARM_INTEGRATION_PLUGIN_OWNER);
1221
+ Reflect.deleteProperty(descriptors, FARM_INTEGRATION_PLUGIN_SERVER_RUNTIME);
1222
+ const ownedPlugin = Object.create(Object.getPrototypeOf(plugin), descriptors);
1223
+ Object.defineProperty(ownedPlugin, FARM_INTEGRATION_PLUGIN_OWNER, { value: owner });
1224
+ Object.defineProperty(ownedPlugin, FARM_INTEGRATION_PLUGIN_SERVER_RUNTIME, {
1225
+ value: owner.serverRuntime
1226
+ });
1227
+ if (integration) {
1228
+ setFarmPluginIntegrationContext(ownedPlugin, integration);
1229
+ }
1230
+ return ownedPlugin;
1231
+ }
1232
+ __name(withIntegrationPluginOwner, "withIntegrationPluginOwner");
1162
1233
  function getIntegrationRuntimeEnv() {
1163
1234
  return typeof process !== "undefined" ? process.env : {};
1164
1235
  }