@lorion-org/react 1.0.0-beta.2 → 1.0.0-beta.4

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/README.md CHANGED
@@ -1,8 +1,15 @@
1
1
  # @lorion-org/react
2
2
 
3
+ [![npm](https://img.shields.io/npm/v/@lorion-org/react)](https://www.npmjs.com/package/@lorion-org/react)
4
+ [![CI](https://github.com/lorion-org/lorion/actions/workflows/ci.yml/badge.svg)](https://github.com/lorion-org/lorion/actions/workflows/ci.yml)
5
+
3
6
  React capability runtime and Vite helpers for LORION descriptor-based applications.
4
7
 
5
- Use this package when a React application is assembled from local capability packages that expose a `capability.json` descriptor and a `./capability` activation export.
8
+ Use this package when a React application is assembled from local capability
9
+ packages that each expose a `capability.json` descriptor. It supports two
10
+ deliberate consumption models over the same LORION discovery and composition
11
+ graph, and both are first-class: pick one per product (see Two Composition
12
+ Models).
6
13
 
7
14
  ## Install
8
15
 
@@ -17,11 +24,35 @@ Add Vite, TanStack Router, or another router in the host application as needed.
17
24
  The runtime helpers do not own routing; the Vite entry point only prepares
18
25
  capability discovery and TanStack-compatible virtual route config.
19
26
 
27
+ ## Quick start
28
+
29
+ Add the Vite capability loader, then consume the resolved capabilities with your
30
+ own runtime (this is the loader-only path, Model B):
31
+
32
+ ```ts
33
+ // vite.config.ts
34
+ import { capabilityLoader } from '@lorion-org/react/vite';
35
+
36
+ export default defineConfig({
37
+ plugins: [capabilityLoader({ workspaceRoot: import.meta.dirname })],
38
+ });
39
+ ```
40
+
41
+ ```ts
42
+ // main.ts
43
+ import { capabilityModules } from 'virtual:capabilities';
44
+ // register the pre-resolved capabilities with your own plugin runtime
45
+ ```
46
+
47
+ For a batteries-included React runtime and file-based routing instead, use
48
+ `lorionReact()` (Model A). Both are described under Two Composition Models.
49
+
20
50
  ## What It Is
21
51
 
22
52
  - a small React binding for immutable capability contributions
23
53
  - a Vite virtual module helper for active capability activation exports
24
54
  - a TanStack virtual route config helper for capability-owned route folders
55
+ - scoped public runtime config for active capabilities
25
56
  - a React adapter over LORION descriptor discovery and composition graph packages
26
57
 
27
58
  ## What It Is Not
@@ -31,7 +62,41 @@ capability discovery and TanStack-compatible virtual route config.
31
62
  - not a package manager
32
63
  - not an application naming convention
33
64
 
34
- ## Basic Runtime
65
+ ## Two Composition Models
66
+
67
+ Both models build on the same LORION discovery, composition graph, provider
68
+ selection, and `virtual:capabilities` build output. They differ only in how much
69
+ of the React side the host delegates to this package. Neither is a special case;
70
+ choose one per product.
71
+
72
+ ### Model A: React capability runtime and routing
73
+
74
+ `lorionReact()` wires the Vite capability loader, the React capability runtime
75
+ (`createCapabilityRuntime`), and TanStack file-based route composition together.
76
+ Capabilities activate through the `./capability` convention and own route
77
+ folders. Use this when the product wants a batteries-included React runtime and
78
+ file-based routing from LORION.
79
+
80
+ ### Model B: capability loader with your own runtime
81
+
82
+ `capabilityLoader()` on its own resolves the descriptor graph at build time and
83
+ emits `virtual:capabilities`; the host consumes that pre-resolved module list
84
+ with its own plugin registry, its own routing, and its own lifecycle. Nothing
85
+ from the React runtime or route config is required. Capabilities activate through
86
+ an explicit `activation` resolver against their existing package exports, and
87
+ dependency-only libraries stay graph-only. Use this when the product already owns
88
+ a plugin system, or when one package set ships as several product distributions,
89
+ and only needs LORION for selection and activation.
90
+
91
+ | | Model A | Model B |
92
+ | ------------- | ---------------------------------------- | ---------------------------------------------------- |
93
+ | Vite entry | `lorionReact()` | `capabilityLoader()` |
94
+ | React runtime | `createCapabilityRuntime` (this package) | host-owned |
95
+ | Routing | TanStack file-based via `routeConfig` | host-owned (for example code-based) |
96
+ | Activation | `./capability` convention | explicit `activation` resolver, graph-only otherwise |
97
+ | Host consumes | provider and contribution contracts | `capabilityModules` from `virtual:capabilities` |
98
+
99
+ ## React Capability Runtime (Model A)
35
100
 
36
101
  ```ts
37
102
  import { CapabilityRuntimeProvider, createCapabilityRuntime } from '@lorion-org/react';
@@ -114,10 +179,13 @@ to TanStack Router as a capability-owned route subtree.
114
179
  ## Vite
115
180
 
116
181
  ```ts
117
- import { lorionReact } from '@lorion-org/react/vite';
182
+ import { capabilityLoader, lorionReact } from '@lorion-org/react/vite';
118
183
  ```
119
184
 
120
- The Vite helper discovers `capabilities/*/capability.json`, validates the descriptor shape with LORION, resolves selected descriptors through the LORION composition graph, resolves each package `./capability` export, and exposes `virtual:capabilities`.
185
+ `capabilityLoader` is the standalone loader used by Model B. `lorionReact()`
186
+ bundles that loader with the Model A route config.
187
+
188
+ The Vite helper discovers `capabilities/*/capability.json`, validates the descriptor shape with LORION, resolves selected descriptors through the LORION composition graph, resolves each active capability's activation entry, and exposes `virtual:capabilities`.
121
189
 
122
190
  ```ts
123
191
  const lorion = lorionReact({
@@ -148,12 +216,214 @@ Route config generation stays TanStack-focused and only includes enabled,
148
216
  selected capability route directories. If no `selected`, seed value,
149
217
  `defaultSelection`, or `baseDescriptors` are provided, every enabled local
150
218
  capability remains active.
219
+
151
220
  Use `indexRouteFile: false` when `/` is owned by a capability route.
152
221
 
153
222
  The virtual module exports `capabilityModules`, `selectedCapabilityIds`, and
154
223
  `resolvedCapabilityIds` so host code can distinguish the seed from the final
155
224
  graph resolution.
156
225
 
226
+ ### Activation
227
+
228
+ Activation binds a resolved descriptor to the module the host imports. LORION
229
+ supports two models, chosen by the host.
230
+
231
+ Convention (default): each capability activates through a `./capability` package
232
+ export with a `capability` named export. No option is required.
233
+
234
+ Explicit resolver: pass an `activation` resolver to bind against an existing
235
+ package export, so capabilities that already expose their contribution from
236
+ another entry point need no dedicated activation file:
237
+
238
+ ```ts
239
+ capabilityLoader({
240
+ workspaceRoot,
241
+ activation: ({ descriptor }) => ({
242
+ exportSubpath: './web',
243
+ exportName: `${descriptor.id}WebPlugin`,
244
+ }),
245
+ });
246
+ ```
247
+
248
+ The generated import then uses the resolved subpath and export name (for example
249
+ `import { homeWebPlugin as homeCapability } from '@scope/home/web'`), and
250
+ specifier resolution is left to the host bundler rather than self-resolved by
251
+ LORION.
252
+
253
+ Graph-only: when the resolver returns a nullish activation for a descriptor, that
254
+ capability still takes part in dependency resolution but activates nothing. No
255
+ import is emitted and it never reaches `capabilityModules`. Use this for
256
+ dependency-only libraries that shape the graph without contributing a runtime
257
+ plugin.
258
+
259
+ ## Bring Your Own Runtime (Model B)
260
+
261
+ In Model B the host uses only the Vite capability loader and composes the
262
+ resolved modules with its own runtime. The build resolves the descriptor graph
263
+ (base, selected features, transitive dependencies, and exactly one provider per
264
+ capability) and emits `capabilityModules` already ordered and filtered.
265
+
266
+ ```ts
267
+ // vite.config.ts
268
+ capabilityLoader({
269
+ workspaceRoot,
270
+ capabilitiesDir: 'packages',
271
+ baseDescriptors: ['shell', 'auth'], // always-on platform base
272
+ defaultSelection: ['home', 'reports'], // default feature set
273
+ selectionSeed: { cliKeys: ['features'], envKeys: ['APP_FEATURES'] },
274
+ // Read a host-defined descriptor field; return undefined to keep a package
275
+ // graph-only. LORION descriptors carry host keys unchanged, so annotate the read.
276
+ activation: ({ descriptor }) =>
277
+ (descriptor as { surfaces?: { web?: { exportName?: string; exportSubpath?: string } } })
278
+ .surfaces?.web,
279
+ });
280
+ ```
281
+
282
+ To reuse the framework-free surface convention from
283
+ [`@lorion-org/surface-activation`](../surface-activation) directly — without a
284
+ per-host adapter — pass `surface` instead of `activation`. Pass exactly one of the
285
+ two (passing both throws). The `fileSurfaceConvention` preset detects a surface by a
286
+ file marker and derives its export name and import subpath (here the canonical
287
+ `@scope/<id>/web/plugin` entry); the raw `SurfaceConvention` object stays available
288
+ for cases the preset does not cover:
289
+
290
+ ```ts
291
+ import { existsSync } from 'node:fs';
292
+ import { join } from 'node:path';
293
+ import { conventionActivation, fileSurfaceConvention } from '@lorion-org/surface-activation';
294
+
295
+ capabilityLoader({
296
+ workspaceRoot,
297
+ capabilitiesDir: 'packages',
298
+ baseDescriptors: ['shell', 'auth'],
299
+ defaultSelection: ['home', 'reports'],
300
+ surface: {
301
+ name: 'web',
302
+ resolver: conventionActivation({
303
+ web: fileSurfaceConvention({
304
+ files: ['src/web/plugin.ts'],
305
+ exportSuffix: 'WebPlugin',
306
+ exportSubpath: './web/plugin',
307
+ exists: existsSync, // injected — surface-activation itself touches no filesystem
308
+ join,
309
+ }),
310
+ }),
311
+ },
312
+ });
313
+ ```
314
+
315
+ Migrating from a hand-written adapter: replace
316
+ `activation: ({ capabilityDir, descriptor }) => resolver('web', { directory: capabilityDir, id: descriptor.id })`
317
+ with `surface: { name: 'web', resolver }`.
318
+
319
+ ```ts
320
+ // main.ts: consume the pre-resolved list with your own registry
321
+ import { capabilityModules } from 'virtual:capabilities';
322
+ import { createRegistry } from './my-plugin-system';
323
+
324
+ const registry = createRegistry();
325
+ for (const plugin of capabilityModules) registry.register(plugin);
326
+ await registry.setup();
327
+ ```
328
+
329
+ The host runtime lists no capability by hand and makes no provider decision.
330
+ Adding or removing a package changes only the descriptor graph, not the runtime
331
+ wiring. Route ownership, i18n merging, and lifecycle hooks stay in the host's own
332
+ plugin system.
333
+
334
+ ## Runtime Config
335
+
336
+ React runtime config follows the same LORION ownership model as other
337
+ capability data: a capability owns its config contract, deployment inputs provide
338
+ values, and the framework adapter exposes only the safe runtime view.
339
+
340
+ By default the React Vite adapter looks for:
341
+
342
+ ```text
343
+ capabilities/<capability>/capability.schema.json
344
+ .data/runtime-config/<capability>/capability.runtime.json
345
+ ```
346
+
347
+ Hosts can configure the convention once:
348
+
349
+ ```ts
350
+ const lorion = lorionReact({
351
+ workspaceRoot,
352
+ routesDirectory,
353
+ runtimeConfig: {
354
+ configFileName: 'capability.runtime.json',
355
+ schemaFileName: 'capability.schema.json',
356
+ },
357
+ });
358
+ ```
359
+
360
+ By default, file-backed config is read from `<workspaceRoot>/.data`. Hosts that
361
+ need a deployment-controlled var dir can configure an env key:
362
+
363
+ ```ts
364
+ const lorion = lorionReact({
365
+ workspaceRoot,
366
+ routesDirectory,
367
+ runtimeConfig: {
368
+ varDir: {
369
+ envKey: 'REACT_VAR_DIR',
370
+ },
371
+ },
372
+ });
373
+ ```
374
+
375
+ Runtime files use unprefixed capability-local sections:
376
+
377
+ ```json
378
+ {
379
+ "public": {
380
+ "url": "https://id.example.test",
381
+ "realm": "demo",
382
+ "clientId": "web"
383
+ },
384
+ "private": {
385
+ "clientSecret": "server-only"
386
+ }
387
+ }
388
+ ```
389
+
390
+ The adapter also reads Vite env files and process env. Public keys use the
391
+ `VITE_<CAPABILITY>_<KEY>` convention, while private keys use
392
+ `<CAPABILITY>_<KEY>`:
393
+
394
+ ```text
395
+ VITE_AUTH_OIDC_URL=https://id.example.test
396
+ VITE_AUTH_OIDC_REALM=demo
397
+ VITE_AUTH_OIDC_CLIENT_ID=web
398
+ AUTH_OIDC_CLIENT_SECRET=server-only
399
+ ```
400
+
401
+ Env values override runtime files. Only `public` config is emitted through
402
+ `virtual:capability-runtime-config`; server code can opt into
403
+ `virtual:capability-runtime-config/server`. The server virtual module is
404
+ SSR-only and fails during client builds to prevent private config from being
405
+ bundled.
406
+
407
+ Render the config provider near the capability runtime provider:
408
+
409
+ ```tsx
410
+ import { CapabilityRuntimeConfigProvider } from '@lorion-org/react';
411
+ import { capabilityRuntimeConfig } from 'virtual:capability-runtime-config';
412
+
413
+ <CapabilityRuntimeConfigProvider runtimeConfig={capabilityRuntimeConfig}>
414
+ <App />
415
+ </CapabilityRuntimeConfigProvider>;
416
+ ```
417
+
418
+ Capability code reads scoped public config:
419
+
420
+ ```ts
421
+ import { useCapabilityRuntimeConfig } from '@lorion-org/react';
422
+
423
+ const authOidc = useCapabilityRuntimeConfig('auth-oidc');
424
+ console.log(authOidc.public.url);
425
+ ```
426
+
157
427
  ## Provider Selection
158
428
 
159
429
  Capabilities that implement another capability can declare `providesFor`.
@@ -205,7 +475,7 @@ preferences. `selectedProviders` can mirror the descriptor seed at runtime, and
205
475
  `fallbackProviders` are merged with descriptor defaults and only used when no
206
476
  configured or selected provider exists.
207
477
 
208
- The React playground uses the first variant by default: Stripe declares
478
+ The React example uses the first variant by default: Stripe declares
209
479
  `defaultFor: "checkout"` and is selected as the fallback provider. Selecting
210
480
  `web payment-provider-invoice` through the seed switches checkout to Invoice and
211
481
  leaves Stripe out of the resolved capabilities.
@@ -214,23 +484,42 @@ leaves Stripe out of the resolved capabilities.
214
484
 
215
485
  The package exposes two public entry points:
216
486
 
217
- - `@lorion-org/react` for runtime, contribution contracts, provider selection, and React context helpers
218
- - `@lorion-org/react/vite` for capability discovery, the Vite virtual module, and TanStack-compatible route config
487
+ - `@lorion-org/react` for runtime, contribution contracts, provider selection, runtime config, and React context helpers
488
+ - `@lorion-org/react/vite` for capability discovery, runtime-config virtual modules, and TanStack-compatible route config
489
+
490
+ ## Example apps
219
491
 
220
- ## Playground
492
+ Two runnable examples (at the repo root under `examples/`) demonstrate the two
493
+ models. Both run with Lorion's `lorion-source` export condition so local
494
+ workspace imports resolve to `src` instead of stale `dist` output.
221
495
 
222
- The package includes a React playground that mirrors the Nuxt package playground with a demo shop, checkout providers, and a tech monitor.
496
+ Model A, `examples/react-runtime`, mirrors the Nuxt example with a demo shop,
497
+ checkout providers, and a tech monitor (composition runtime and file-based
498
+ routing):
223
499
 
224
500
  ```sh
225
- pnpm --filter @lorion-org/react dev:playground
501
+ pnpm --filter @lorion-examples/react-runtime dev
226
502
  ```
227
503
 
228
- The playground scripts run with Lorion's `lorion-source` export condition so
229
- local workspace package imports resolve to `src` instead of stale `dist` output.
504
+ It runs on `http://localhost:3200` with capabilities under
505
+ `examples/react-runtime/capabilities`. Select a different profile or provider with
506
+ `--capabilities=admin`, `--capabilities=web,payment-provider-invoice`, or
507
+ `LORION_CAPABILITIES="web payment-provider-invoice"`.
508
+
509
+ Model B, `examples/react-loader`, shows the capability-loader-only path: explicit
510
+ activation, a graph-only library, a base plus seed selection, provider selection,
511
+ and a small hand-written registry that consumes `virtual:capabilities` with no
512
+ LORION React runtime and no route config:
513
+
514
+ ```sh
515
+ pnpm --filter @lorion-examples/react-loader dev
516
+ ```
230
517
 
231
- The playground runs on `http://localhost:3200` and uses local demo capabilities under `playground/capabilities`.
232
- Select a different profile or provider with `--capabilities=admin`,
233
- `--capabilities=web,payment-provider-invoice`, or `LORION_CAPABILITIES="web payment-provider-invoice"`.
518
+ It runs on `http://localhost:3201` with capabilities under
519
+ `examples/react-loader/capabilities`. The seed replaces the default selection, while
520
+ the base and providers resolve through the graph: switch the auth provider with
521
+ `--features=dashboard,auth-oidc`, or change the feature set with
522
+ `LORION_FEATURES="dashboard reports"`.
234
523
 
235
524
  ## Local Commands
236
525
 
package/dist/index.cjs CHANGED
@@ -20,53 +20,58 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
+ CapabilityRuntimeConfigProvider: () => CapabilityRuntimeConfigProvider,
23
24
  CapabilityRuntimeProvider: () => CapabilityRuntimeProvider,
24
- createCapabilityCompositionPolicy: () => createCapabilityCompositionPolicy,
25
+ createCapabilityCompositionPolicy: () => import_descriptor_selection.descriptorSelectionPolicy,
25
26
  createCapabilityRuntime: () => createCapabilityRuntime,
26
27
  createContributionContract: () => createContributionContract,
27
- defaultCapabilityRelationDescriptors: () => defaultCapabilityRelationDescriptors,
28
- defaultCapabilityResolutionRelations: () => defaultCapabilityResolutionRelations,
28
+ defaultCapabilityRelationDescriptors: () => import_descriptor_selection.providerRelationDescriptors,
29
+ defaultCapabilityResolutionRelations: () => import_descriptor_selection.defaultResolutionRelations,
29
30
  defineCapability: () => defineCapability,
30
31
  defineContribution: () => defineContribution,
31
32
  defineExtensionPoint: () => defineExtensionPoint,
32
33
  getCapabilityProviderSelection: () => getCapabilityProviderSelection,
33
- useCapabilityRuntime: () => useCapabilityRuntime
34
+ getCapabilityRuntimeConfig: () => getCapabilityRuntimeConfig,
35
+ getCapabilityRuntimeConfigScope: () => getCapabilityRuntimeConfigScope,
36
+ useCapabilityRuntime: () => useCapabilityRuntime,
37
+ useCapabilityRuntimeConfig: () => useCapabilityRuntimeConfig,
38
+ useCapabilityRuntimeConfigRoot: () => useCapabilityRuntimeConfigRoot,
39
+ useCapabilityRuntimeConfigScope: () => useCapabilityRuntimeConfigScope
34
40
  });
35
41
  module.exports = __toCommonJS(index_exports);
36
- var import_react = require("react");
42
+ var import_react2 = require("react");
37
43
  var import_composition_graph = require("@lorion-org/composition-graph");
38
44
  var import_provider_selection = require("@lorion-org/provider-selection");
39
45
 
40
46
  // src/relations.ts
41
- var defaultCapabilityResolutionRelations = [
42
- "dependencies",
43
- "defaultProviders",
44
- "providerPreferences"
45
- ];
46
- var defaultCapabilityRelationDescriptors = [
47
- {
48
- direction: "incoming",
49
- field: "defaultFor",
50
- id: "defaultProviders"
51
- },
52
- {
53
- field: "providerPreferences",
54
- id: "providerPreferences",
55
- targetMode: "values"
56
- }
57
- ];
58
- function createCapabilityCompositionPolicy(policy) {
47
+ var import_descriptor_selection = require("@lorion-org/descriptor-selection");
48
+
49
+ // src/runtime-config.ts
50
+ var import_react = require("react");
51
+ var emptyRuntimeConfig = Object.freeze({ public: Object.freeze({}) });
52
+ var CapabilityRuntimeConfigContext = (0, import_react.createContext)(emptyRuntimeConfig);
53
+ function CapabilityRuntimeConfigProvider({
54
+ children,
55
+ runtimeConfig
56
+ }) {
57
+ return (0, import_react.createElement)(CapabilityRuntimeConfigContext.Provider, { value: runtimeConfig }, children);
58
+ }
59
+ function useCapabilityRuntimeConfigScope(capabilityId) {
60
+ return getCapabilityRuntimeConfigScope(useCapabilityRuntimeConfigRoot(), capabilityId);
61
+ }
62
+ function useCapabilityRuntimeConfig(capabilityId) {
63
+ return getCapabilityRuntimeConfig(useCapabilityRuntimeConfigRoot(), capabilityId);
64
+ }
65
+ function useCapabilityRuntimeConfigRoot() {
66
+ return (0, import_react.useContext)(CapabilityRuntimeConfigContext);
67
+ }
68
+ function getCapabilityRuntimeConfigScope(runtimeConfig, capabilityId) {
69
+ const publicConfig = runtimeConfig.public[capabilityId];
70
+ return publicConfig && typeof publicConfig === "object" && !Array.isArray(publicConfig) ? publicConfig : {};
71
+ }
72
+ function getCapabilityRuntimeConfig(runtimeConfig, capabilityId) {
59
73
  return {
60
- ...policy,
61
- inspectionRelationIds: policy?.inspectionRelationIds ?? [
62
- ...defaultCapabilityResolutionRelations
63
- ],
64
- provenanceRelationIds: policy?.provenanceRelationIds ?? [
65
- ...defaultCapabilityResolutionRelations
66
- ],
67
- resolutionRelationIds: policy?.resolutionRelationIds ?? [
68
- ...defaultCapabilityResolutionRelations
69
- ]
74
+ public: getCapabilityRuntimeConfigScope(runtimeConfig, capabilityId)
70
75
  };
71
76
  }
72
77
 
@@ -140,15 +145,15 @@ function createCapabilityRuntime(capabilities) {
140
145
  getContributions: (extensionPoint) => [...contributions.get(extensionPoint.id) ?? []]
141
146
  };
142
147
  }
143
- var CapabilityRuntimeContext = (0, import_react.createContext)(null);
148
+ var CapabilityRuntimeContext = (0, import_react2.createContext)(null);
144
149
  function CapabilityRuntimeProvider({
145
150
  children,
146
151
  runtime
147
152
  }) {
148
- return (0, import_react.createElement)(CapabilityRuntimeContext.Provider, { value: runtime }, children);
153
+ return (0, import_react2.createElement)(CapabilityRuntimeContext.Provider, { value: runtime }, children);
149
154
  }
150
155
  function useCapabilityRuntime() {
151
- const runtime = (0, import_react.useContext)(CapabilityRuntimeContext);
156
+ const runtime = (0, import_react2.useContext)(CapabilityRuntimeContext);
152
157
  if (!runtime) {
153
158
  throw new Error("useCapabilityRuntime must be used inside CapabilityRuntimeProvider.");
154
159
  }
@@ -186,11 +191,12 @@ function collectContributions(capabilities) {
186
191
  function createCapabilityCatalog(capabilities) {
187
192
  return (0, import_composition_graph.createDescriptorCatalog)({
188
193
  descriptors: capabilities.map((capability) => capability.manifest),
189
- relationDescriptors: defaultCapabilityRelationDescriptors
194
+ relationDescriptors: import_descriptor_selection.providerRelationDescriptors
190
195
  });
191
196
  }
192
197
  // Annotate the CommonJS export names for ESM import in node:
193
198
  0 && (module.exports = {
199
+ CapabilityRuntimeConfigProvider,
194
200
  CapabilityRuntimeProvider,
195
201
  createCapabilityCompositionPolicy,
196
202
  createCapabilityRuntime,
@@ -201,5 +207,10 @@ function createCapabilityCatalog(capabilities) {
201
207
  defineContribution,
202
208
  defineExtensionPoint,
203
209
  getCapabilityProviderSelection,
204
- useCapabilityRuntime
210
+ getCapabilityRuntimeConfig,
211
+ getCapabilityRuntimeConfigScope,
212
+ useCapabilityRuntime,
213
+ useCapabilityRuntimeConfig,
214
+ useCapabilityRuntimeConfigRoot,
215
+ useCapabilityRuntimeConfigScope
205
216
  });
package/dist/index.d.cts CHANGED
@@ -1,15 +1,31 @@
1
1
  import { ReactNode, ReactElement } from 'react';
2
- import { CompositionPolicy, RelationDescriptor, Descriptor, DescriptorCatalog } from '@lorion-org/composition-graph';
2
+ import { Descriptor, DescriptorCatalog } from '@lorion-org/composition-graph';
3
3
  import { ProviderPreferenceMap, ProviderSelectionResolution } from '@lorion-org/provider-selection';
4
+ import { RuntimeConfigSection, RuntimeConfigValidationPolicy } from '@lorion-org/runtime-config';
5
+ export { descriptorSelectionPolicy as createCapabilityCompositionPolicy, providerRelationDescriptors as defaultCapabilityRelationDescriptors, defaultResolutionRelations as defaultCapabilityResolutionRelations } from '@lorion-org/descriptor-selection';
4
6
 
5
- declare const defaultCapabilityResolutionRelations: readonly ["dependencies", "defaultProviders", "providerPreferences"];
6
- declare const defaultCapabilityRelationDescriptors: RelationDescriptor[];
7
- declare function createCapabilityCompositionPolicy(policy?: Partial<CompositionPolicy>): Partial<CompositionPolicy>;
7
+ type CapabilityRuntimeConfig = {
8
+ public: Record<string, RuntimeConfigSection>;
9
+ };
10
+ type CapabilityRuntimeConfigFragment<T extends RuntimeConfigSection = RuntimeConfigSection> = {
11
+ public: T;
12
+ };
13
+ type CapabilityRuntimeConfigProviderProps = {
14
+ children: ReactNode;
15
+ runtimeConfig: CapabilityRuntimeConfig;
16
+ };
17
+ declare function CapabilityRuntimeConfigProvider({ children, runtimeConfig, }: CapabilityRuntimeConfigProviderProps): ReactElement;
18
+ declare function useCapabilityRuntimeConfigScope<T extends RuntimeConfigSection = RuntimeConfigSection>(capabilityId: string): T;
19
+ declare function useCapabilityRuntimeConfig<T extends RuntimeConfigSection = RuntimeConfigSection>(capabilityId: string): CapabilityRuntimeConfigFragment<T>;
20
+ declare function useCapabilityRuntimeConfigRoot(): CapabilityRuntimeConfig;
21
+ declare function getCapabilityRuntimeConfigScope<T extends RuntimeConfigSection = RuntimeConfigSection>(runtimeConfig: CapabilityRuntimeConfig, capabilityId: string): T;
22
+ declare function getCapabilityRuntimeConfig<T extends RuntimeConfigSection = RuntimeConfigSection>(runtimeConfig: CapabilityRuntimeConfig, capabilityId: string): CapabilityRuntimeConfigFragment<T>;
8
23
 
9
24
  type CapabilityManifest = Descriptor & {
10
25
  defaultFor?: string | string[];
11
26
  description?: string;
12
27
  providerPreferences?: ProviderPreferenceMap;
28
+ runtimeConfig?: RuntimeConfigValidationPolicy;
13
29
  };
14
30
  type ExtensionPoint<T> = {
15
31
  id: string;
@@ -53,4 +69,4 @@ type CapabilityRuntimeProviderProps = {
53
69
  declare function CapabilityRuntimeProvider({ children, runtime, }: CapabilityRuntimeProviderProps): ReactElement;
54
70
  declare function useCapabilityRuntime(): CapabilityRuntime;
55
71
 
56
- export { type CapabilityContribution, type CapabilityManifest, type CapabilityProviderSelectionOptions, type CapabilityRuntime, CapabilityRuntimeProvider, type CapabilityRuntimeProviderProps, type ContributionContract, type ExtensionPoint, type RuntimeCapability, createCapabilityCompositionPolicy, createCapabilityRuntime, createContributionContract, defaultCapabilityRelationDescriptors, defaultCapabilityResolutionRelations, defineCapability, defineContribution, defineExtensionPoint, getCapabilityProviderSelection, useCapabilityRuntime };
72
+ export { type CapabilityContribution, type CapabilityManifest, type CapabilityProviderSelectionOptions, type CapabilityRuntime, type CapabilityRuntimeConfig, type CapabilityRuntimeConfigFragment, CapabilityRuntimeConfigProvider, type CapabilityRuntimeConfigProviderProps, CapabilityRuntimeProvider, type CapabilityRuntimeProviderProps, type ContributionContract, type ExtensionPoint, type RuntimeCapability, createCapabilityRuntime, createContributionContract, defineCapability, defineContribution, defineExtensionPoint, getCapabilityProviderSelection, getCapabilityRuntimeConfig, getCapabilityRuntimeConfigScope, useCapabilityRuntime, useCapabilityRuntimeConfig, useCapabilityRuntimeConfigRoot, useCapabilityRuntimeConfigScope };
package/dist/index.d.ts CHANGED
@@ -1,15 +1,31 @@
1
1
  import { ReactNode, ReactElement } from 'react';
2
- import { CompositionPolicy, RelationDescriptor, Descriptor, DescriptorCatalog } from '@lorion-org/composition-graph';
2
+ import { Descriptor, DescriptorCatalog } from '@lorion-org/composition-graph';
3
3
  import { ProviderPreferenceMap, ProviderSelectionResolution } from '@lorion-org/provider-selection';
4
+ import { RuntimeConfigSection, RuntimeConfigValidationPolicy } from '@lorion-org/runtime-config';
5
+ export { descriptorSelectionPolicy as createCapabilityCompositionPolicy, providerRelationDescriptors as defaultCapabilityRelationDescriptors, defaultResolutionRelations as defaultCapabilityResolutionRelations } from '@lorion-org/descriptor-selection';
4
6
 
5
- declare const defaultCapabilityResolutionRelations: readonly ["dependencies", "defaultProviders", "providerPreferences"];
6
- declare const defaultCapabilityRelationDescriptors: RelationDescriptor[];
7
- declare function createCapabilityCompositionPolicy(policy?: Partial<CompositionPolicy>): Partial<CompositionPolicy>;
7
+ type CapabilityRuntimeConfig = {
8
+ public: Record<string, RuntimeConfigSection>;
9
+ };
10
+ type CapabilityRuntimeConfigFragment<T extends RuntimeConfigSection = RuntimeConfigSection> = {
11
+ public: T;
12
+ };
13
+ type CapabilityRuntimeConfigProviderProps = {
14
+ children: ReactNode;
15
+ runtimeConfig: CapabilityRuntimeConfig;
16
+ };
17
+ declare function CapabilityRuntimeConfigProvider({ children, runtimeConfig, }: CapabilityRuntimeConfigProviderProps): ReactElement;
18
+ declare function useCapabilityRuntimeConfigScope<T extends RuntimeConfigSection = RuntimeConfigSection>(capabilityId: string): T;
19
+ declare function useCapabilityRuntimeConfig<T extends RuntimeConfigSection = RuntimeConfigSection>(capabilityId: string): CapabilityRuntimeConfigFragment<T>;
20
+ declare function useCapabilityRuntimeConfigRoot(): CapabilityRuntimeConfig;
21
+ declare function getCapabilityRuntimeConfigScope<T extends RuntimeConfigSection = RuntimeConfigSection>(runtimeConfig: CapabilityRuntimeConfig, capabilityId: string): T;
22
+ declare function getCapabilityRuntimeConfig<T extends RuntimeConfigSection = RuntimeConfigSection>(runtimeConfig: CapabilityRuntimeConfig, capabilityId: string): CapabilityRuntimeConfigFragment<T>;
8
23
 
9
24
  type CapabilityManifest = Descriptor & {
10
25
  defaultFor?: string | string[];
11
26
  description?: string;
12
27
  providerPreferences?: ProviderPreferenceMap;
28
+ runtimeConfig?: RuntimeConfigValidationPolicy;
13
29
  };
14
30
  type ExtensionPoint<T> = {
15
31
  id: string;
@@ -53,4 +69,4 @@ type CapabilityRuntimeProviderProps = {
53
69
  declare function CapabilityRuntimeProvider({ children, runtime, }: CapabilityRuntimeProviderProps): ReactElement;
54
70
  declare function useCapabilityRuntime(): CapabilityRuntime;
55
71
 
56
- export { type CapabilityContribution, type CapabilityManifest, type CapabilityProviderSelectionOptions, type CapabilityRuntime, CapabilityRuntimeProvider, type CapabilityRuntimeProviderProps, type ContributionContract, type ExtensionPoint, type RuntimeCapability, createCapabilityCompositionPolicy, createCapabilityRuntime, createContributionContract, defaultCapabilityRelationDescriptors, defaultCapabilityResolutionRelations, defineCapability, defineContribution, defineExtensionPoint, getCapabilityProviderSelection, useCapabilityRuntime };
72
+ export { type CapabilityContribution, type CapabilityManifest, type CapabilityProviderSelectionOptions, type CapabilityRuntime, type CapabilityRuntimeConfig, type CapabilityRuntimeConfigFragment, CapabilityRuntimeConfigProvider, type CapabilityRuntimeConfigProviderProps, CapabilityRuntimeProvider, type CapabilityRuntimeProviderProps, type ContributionContract, type ExtensionPoint, type RuntimeCapability, createCapabilityRuntime, createContributionContract, defineCapability, defineContribution, defineExtensionPoint, getCapabilityProviderSelection, getCapabilityRuntimeConfig, getCapabilityRuntimeConfigScope, useCapabilityRuntime, useCapabilityRuntimeConfig, useCapabilityRuntimeConfigRoot, useCapabilityRuntimeConfigScope };