@h-rig/core 0.0.6-alpha.151 → 0.0.6-alpha.152

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.
@@ -20,21 +20,13 @@ function applyConfigDefaults(raw) {
20
20
  };
21
21
  }
22
22
  function defineConfig(cfg) {
23
- const runtimeByName = new Map;
24
- const plugins = cfg.plugins ?? [];
25
- for (const plugin of plugins) {
26
- if (plugin?.__runtime) {
27
- runtimeByName.set(plugin.name, plugin.__runtime);
28
- }
29
- }
30
- const decoded = Schema.decodeUnknownSync(RigConfig)(applyConfigDefaults(cfg));
31
- const decodedPlugins = decoded.plugins.map((p) => {
32
- const runtime = runtimeByName.get(p.name);
33
- if (!runtime)
34
- return p;
35
- return { ...p, __runtime: runtime };
23
+ const withDefaults = applyConfigDefaults(cfg);
24
+ const explicitPlugins = Array.isArray(withDefaults.plugins) ? [...withDefaults.plugins] : [];
25
+ const decoded = Schema.decodeUnknownSync(RigConfig)({
26
+ ...withDefaults,
27
+ plugins: explicitPlugins
36
28
  });
37
- return { ...decoded, plugins: decodedPlugins };
29
+ return { ...decoded, plugins: explicitPlugins };
38
30
  }
39
31
  // packages/core/src/define-plugin.ts
40
32
  import { Schema as Schema2 } from "effect";
@@ -11,8 +11,9 @@ export type RigConfigInput = Omit<RigConfig, "plugins" | "workspace"> & {
11
11
  /** Fill optional top-level sections before Schema decode (which requires them). */
12
12
  export declare function applyConfigDefaults(raw: unknown): unknown;
13
13
  /**
14
- * Validate a Rig config and decode through Schema, preserving each plugin's
15
- * `__runtime` channel. Schema decode strips unknown fields, so we capture
16
- * the runtime objects before decoding and re-attach them after.
14
+ * Validate a Rig config while preserving the explicit plugin object identities
15
+ * supplied by the config author. Schema validates the serializable metadata
16
+ * shape, but the returned config keeps the original executable plugin objects;
17
+ * there is no name-based runtime hydration or reattachment step.
17
18
  */
18
19
  export declare function defineConfig(cfg: RigConfigInput): RigConfig;
@@ -20,21 +20,13 @@ function applyConfigDefaults(raw) {
20
20
  };
21
21
  }
22
22
  function defineConfig(cfg) {
23
- const runtimeByName = new Map;
24
- const plugins = cfg.plugins ?? [];
25
- for (const plugin of plugins) {
26
- if (plugin?.__runtime) {
27
- runtimeByName.set(plugin.name, plugin.__runtime);
28
- }
29
- }
30
- const decoded = Schema.decodeUnknownSync(RigConfig)(applyConfigDefaults(cfg));
31
- const decodedPlugins = decoded.plugins.map((p) => {
32
- const runtime = runtimeByName.get(p.name);
33
- if (!runtime)
34
- return p;
35
- return { ...p, __runtime: runtime };
23
+ const withDefaults = applyConfigDefaults(cfg);
24
+ const explicitPlugins = Array.isArray(withDefaults.plugins) ? [...withDefaults.plugins] : [];
25
+ const decoded = Schema.decodeUnknownSync(RigConfig)({
26
+ ...withDefaults,
27
+ plugins: explicitPlugins
36
28
  });
37
- return { ...decoded, plugins: decodedPlugins };
29
+ return { ...decoded, plugins: explicitPlugins };
38
30
  }
39
31
  export {
40
32
  defineConfig,
package/dist/src/index.js CHANGED
@@ -114,21 +114,13 @@ function applyConfigDefaults(raw) {
114
114
  };
115
115
  }
116
116
  function defineConfig(cfg) {
117
- const runtimeByName = new Map;
118
- const plugins = cfg.plugins ?? [];
119
- for (const plugin of plugins) {
120
- if (plugin?.__runtime) {
121
- runtimeByName.set(plugin.name, plugin.__runtime);
122
- }
123
- }
124
- const decoded = Schema2.decodeUnknownSync(RigConfig)(applyConfigDefaults(cfg));
125
- const decodedPlugins = decoded.plugins.map((p) => {
126
- const runtime = runtimeByName.get(p.name);
127
- if (!runtime)
128
- return p;
129
- return { ...p, __runtime: runtime };
117
+ const withDefaults = applyConfigDefaults(cfg);
118
+ const explicitPlugins = Array.isArray(withDefaults.plugins) ? [...withDefaults.plugins] : [];
119
+ const decoded = Schema2.decodeUnknownSync(RigConfig)({
120
+ ...withDefaults,
121
+ plugins: explicitPlugins
130
122
  });
131
- return { ...decoded, plugins: decodedPlugins };
123
+ return { ...decoded, plugins: explicitPlugins };
132
124
  }
133
125
  // packages/core/src/plugin-host.ts
134
126
  function indexById(contributions, kind) {
@@ -317,36 +317,26 @@ async function loadConfig(cwd) {
317
317
  }
318
318
  });
319
319
  const raw = mod.default ?? mod.config;
320
- return decodePreservingRuntime(raw);
320
+ return decodeExplicitPluginConfig(raw);
321
321
  }
322
322
  }
323
323
  for (const name of JSON_NAMES) {
324
324
  const p = join(cwd, name);
325
325
  if (existsSync(p)) {
326
326
  const raw = JSON.parse(readFileSync(p, "utf-8"));
327
- return decodePreservingRuntime(raw);
327
+ return decodeExplicitPluginConfig(raw);
328
328
  }
329
329
  }
330
330
  throw new Error(`no rig.config.{ts,mts,json} found in ${cwd}`);
331
331
  }
332
- function decodePreservingRuntime(raw) {
333
- const runtimeByName = new Map;
334
- const cfgIn = raw;
335
- if (Array.isArray(cfgIn?.plugins)) {
336
- for (const plugin of cfgIn.plugins) {
337
- if (plugin?.__runtime) {
338
- runtimeByName.set(plugin.name, plugin.__runtime);
339
- }
340
- }
341
- }
342
- const decoded = Schema2.decodeUnknownSync(RigConfig2)(applyConfigDefaults(raw));
343
- const plugins = decoded.plugins.map((p) => {
344
- const runtime = runtimeByName.get(p.name);
345
- if (!runtime)
346
- return p;
347
- return { ...p, __runtime: runtime };
332
+ function decodeExplicitPluginConfig(raw) {
333
+ const withDefaults = applyConfigDefaults(raw);
334
+ const explicitPlugins = Array.isArray(withDefaults.plugins) ? [...withDefaults.plugins] : [];
335
+ const decoded = Schema2.decodeUnknownSync(RigConfig2)({
336
+ ...withDefaults,
337
+ plugins: explicitPlugins
348
338
  });
349
- return { ...decoded, plugins };
339
+ return { ...decoded, plugins: explicitPlugins };
350
340
  }
351
341
  export {
352
342
  loadConfig
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@h-rig/core",
3
- "version": "0.0.6-alpha.151",
3
+ "version": "0.0.6-alpha.152",
4
4
  "type": "module",
5
5
  "description": "Config and plugin composition library for Rig's OMP extension ecosystem; not a product host/runtime.",
6
6
  "license": "UNLICENSED",
@@ -49,7 +49,7 @@
49
49
  "module": "./dist/src/index.js",
50
50
  "types": "./dist/src/index.d.ts",
51
51
  "dependencies": {
52
- "@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.151",
52
+ "@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.152",
53
53
  "effect": "4.0.0-beta.90"
54
54
  }
55
55
  }