@primafuture/contrib-kit-react 1.0.0

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 (128) hide show
  1. package/LICENSE +15 -0
  2. package/README.md +294 -0
  3. package/dist/contribution-component.d.ts +82 -0
  4. package/dist/contribution-component.d.ts.map +1 -0
  5. package/dist/contribution-component.js +12 -0
  6. package/dist/contribution-component.js.map +1 -0
  7. package/dist/extension-outlet.d.ts +155 -0
  8. package/dist/extension-outlet.d.ts.map +1 -0
  9. package/dist/extension-outlet.js +229 -0
  10. package/dist/extension-outlet.js.map +1 -0
  11. package/dist/extension-registry-provider.d.ts +26 -0
  12. package/dist/extension-registry-provider.d.ts.map +1 -0
  13. package/dist/extension-registry-provider.js +82 -0
  14. package/dist/extension-registry-provider.js.map +1 -0
  15. package/dist/index.d.ts +22 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +14 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/internal/adapter-configuration.d.ts +54 -0
  20. package/dist/internal/adapter-configuration.d.ts.map +1 -0
  21. package/dist/internal/adapter-configuration.js +89 -0
  22. package/dist/internal/adapter-configuration.js.map +1 -0
  23. package/dist/internal/adapter-context.d.ts +24 -0
  24. package/dist/internal/adapter-context.d.ts.map +1 -0
  25. package/dist/internal/adapter-context.js +23 -0
  26. package/dist/internal/adapter-context.js.map +1 -0
  27. package/dist/internal/adapter-registry-bridge.d.ts +58 -0
  28. package/dist/internal/adapter-registry-bridge.d.ts.map +1 -0
  29. package/dist/internal/adapter-registry-bridge.js +494 -0
  30. package/dist/internal/adapter-registry-bridge.js.map +1 -0
  31. package/dist/internal/adapter-registry-protocol.d.ts +53 -0
  32. package/dist/internal/adapter-registry-protocol.d.ts.map +1 -0
  33. package/dist/internal/adapter-registry-protocol.js +182 -0
  34. package/dist/internal/adapter-registry-protocol.js.map +1 -0
  35. package/dist/internal/adapter-scope.d.ts +87 -0
  36. package/dist/internal/adapter-scope.d.ts.map +1 -0
  37. package/dist/internal/adapter-scope.js +346 -0
  38. package/dist/internal/adapter-scope.js.map +1 -0
  39. package/dist/internal/implementation-classifier.d.ts +21 -0
  40. package/dist/internal/implementation-classifier.d.ts.map +1 -0
  41. package/dist/internal/implementation-classifier.js +39 -0
  42. package/dist/internal/implementation-classifier.js.map +1 -0
  43. package/dist/internal/managed-lazy-generation.d.ts +100 -0
  44. package/dist/internal/managed-lazy-generation.d.ts.map +1 -0
  45. package/dist/internal/managed-lazy-generation.js +419 -0
  46. package/dist/internal/managed-lazy-generation.js.map +1 -0
  47. package/dist/internal/outlet-commit-lease.d.ts +46 -0
  48. package/dist/internal/outlet-commit-lease.d.ts.map +1 -0
  49. package/dist/internal/outlet-commit-lease.js +137 -0
  50. package/dist/internal/outlet-commit-lease.js.map +1 -0
  51. package/dist/internal/outlet-error-pipeline.d.ts +122 -0
  52. package/dist/internal/outlet-error-pipeline.d.ts.map +1 -0
  53. package/dist/internal/outlet-error-pipeline.js +214 -0
  54. package/dist/internal/outlet-error-pipeline.js.map +1 -0
  55. package/dist/internal/outlet-input.d.ts +42 -0
  56. package/dist/internal/outlet-input.d.ts.map +1 -0
  57. package/dist/internal/outlet-input.js +86 -0
  58. package/dist/internal/outlet-input.js.map +1 -0
  59. package/dist/internal/outlet-membership-boundary.d.ts +93 -0
  60. package/dist/internal/outlet-membership-boundary.d.ts.map +1 -0
  61. package/dist/internal/outlet-membership-boundary.js +710 -0
  62. package/dist/internal/outlet-membership-boundary.js.map +1 -0
  63. package/dist/internal/outlet-membership.d.ts +31 -0
  64. package/dist/internal/outlet-membership.d.ts.map +1 -0
  65. package/dist/internal/outlet-membership.js +65 -0
  66. package/dist/internal/outlet-membership.js.map +1 -0
  67. package/dist/internal/outlet-projection.d.ts +102 -0
  68. package/dist/internal/outlet-projection.d.ts.map +1 -0
  69. package/dist/internal/outlet-projection.js +228 -0
  70. package/dist/internal/outlet-projection.js.map +1 -0
  71. package/dist/internal/outlet-reporter-boundary.d.ts +42 -0
  72. package/dist/internal/outlet-reporter-boundary.d.ts.map +1 -0
  73. package/dist/internal/outlet-reporter-boundary.js +57 -0
  74. package/dist/internal/outlet-reporter-boundary.js.map +1 -0
  75. package/dist/internal/public-input-capture.d.ts +13 -0
  76. package/dist/internal/public-input-capture.d.ts.map +1 -0
  77. package/dist/internal/public-input-capture.js +34 -0
  78. package/dist/internal/public-input-capture.js.map +1 -0
  79. package/dist/internal/resolved-contributions-query.d.ts +42 -0
  80. package/dist/internal/resolved-contributions-query.d.ts.map +1 -0
  81. package/dist/internal/resolved-contributions-query.js +203 -0
  82. package/dist/internal/resolved-contributions-query.js.map +1 -0
  83. package/dist/react-adapter-diagnostics.d.ts +199 -0
  84. package/dist/react-adapter-diagnostics.d.ts.map +1 -0
  85. package/dist/react-adapter-diagnostics.js +257 -0
  86. package/dist/react-adapter-diagnostics.js.map +1 -0
  87. package/dist/react-adapter-error.d.ts +35 -0
  88. package/dist/react-adapter-error.d.ts.map +1 -0
  89. package/dist/react-adapter-error.js +37 -0
  90. package/dist/react-adapter-error.js.map +1 -0
  91. package/dist/react-extension-point.d.ts +26 -0
  92. package/dist/react-extension-point.d.ts.map +1 -0
  93. package/dist/react-extension-point.js +100 -0
  94. package/dist/react-extension-point.js.map +1 -0
  95. package/dist/react-lazy-contribution.d.ts +40 -0
  96. package/dist/react-lazy-contribution.d.ts.map +1 -0
  97. package/dist/react-lazy-contribution.js +18 -0
  98. package/dist/react-lazy-contribution.js.map +1 -0
  99. package/dist/resolved-contributions.d.ts +90 -0
  100. package/dist/resolved-contributions.d.ts.map +1 -0
  101. package/dist/resolved-contributions.js +455 -0
  102. package/dist/resolved-contributions.js.map +1 -0
  103. package/package.json +47 -0
  104. package/src/contribution-component.ts +118 -0
  105. package/src/extension-outlet.ts +590 -0
  106. package/src/extension-registry-provider.ts +179 -0
  107. package/src/index.ts +72 -0
  108. package/src/internal/adapter-configuration.ts +181 -0
  109. package/src/internal/adapter-context.ts +43 -0
  110. package/src/internal/adapter-registry-bridge.ts +723 -0
  111. package/src/internal/adapter-registry-protocol.ts +365 -0
  112. package/src/internal/adapter-scope.ts +500 -0
  113. package/src/internal/implementation-classifier.ts +59 -0
  114. package/src/internal/managed-lazy-generation.ts +540 -0
  115. package/src/internal/outlet-commit-lease.ts +216 -0
  116. package/src/internal/outlet-error-pipeline.ts +447 -0
  117. package/src/internal/outlet-input.ts +264 -0
  118. package/src/internal/outlet-membership-boundary.ts +1048 -0
  119. package/src/internal/outlet-membership.ts +125 -0
  120. package/src/internal/outlet-projection.ts +511 -0
  121. package/src/internal/outlet-reporter-boundary.ts +105 -0
  122. package/src/internal/public-input-capture.ts +55 -0
  123. package/src/internal/resolved-contributions-query.ts +318 -0
  124. package/src/react-adapter-diagnostics.ts +457 -0
  125. package/src/react-adapter-error.ts +88 -0
  126. package/src/react-extension-point.ts +181 -0
  127. package/src/react-lazy-contribution.ts +66 -0
  128. package/src/resolved-contributions.ts +895 -0
@@ -0,0 +1,179 @@
1
+ import * as contribKitCore from "@primafuture/contrib-kit-core";
2
+ import * as react from "react";
3
+
4
+ import * as adapterConfiguration from "./internal/adapter-configuration.js";
5
+ import * as adapterContext from "./internal/adapter-context.js";
6
+ import * as adapterRegistryProtocol from "./internal/adapter-registry-protocol.js";
7
+ import * as adapterScope from "./internal/adapter-scope.js";
8
+ import * as publicInputCapture from "./internal/public-input-capture.js";
9
+ import * as reactAdapterError from "./react-adapter-error.js";
10
+
11
+ /**
12
+ * Props tree-local React adapter scope bez převzetí Core ownershipu.
13
+ *
14
+ * @public
15
+ */
16
+ export interface ExtensionRegistryProviderProps {
17
+ /** React subtree, kterému provider zpřístupní registry a konfiguraci. */
18
+ readonly children?: react.ReactNode;
19
+ /** Inherited contribution policy; null obnoví package default. */
20
+ readonly errorPolicy?: import("./react-adapter-diagnostics.js").ReactErrorPolicy | null | undefined;
21
+ /** Pure projekce host contextu použitelná pouze v diagnostice. */
22
+ readonly projectContext?: ((context: unknown) => unknown) | null | undefined;
23
+ /** Hostem vlastněná Core registry; provider ji nikdy nedisposuje. */
24
+ readonly registry: contribKitCore.ExtensionRegistry;
25
+ /** Inherited command-free sink; null obnoví console fallback. */
26
+ readonly sink?: import("./react-adapter-diagnostics.js").ReactAdapterSink | null | undefined;
27
+ }
28
+
29
+ /** Úspěšný read-once provider capture pro jeden render attempt. */
30
+ interface CapturedProviderRender {
31
+ /** Rozlišuje validní Context hodnotu od synchronní configuration chyby. */
32
+ readonly ok: true;
33
+ /** Frozen Context hodnota publikovaná pouze committed React tree. */
34
+ readonly contextValue: adapterContext.AdapterContextValue;
35
+ /** Provider children přečtené jako poslední známé pole. */
36
+ readonly children: react.ReactNode;
37
+ }
38
+
39
+ /** Neúspěšný provider capture držený do zavolání všech interních hooks. */
40
+ interface FailedProviderRender {
41
+ /** Rozlišuje synchronní configuration failure. */
42
+ readonly ok: false;
43
+ /** Přesná adapter chyba se zachovaným accessor cause. */
44
+ readonly error: unknown;
45
+ }
46
+
47
+ /** Jeden provider render po úplném hook-order-safe capture. */
48
+ type ProviderRender = CapturedProviderRender | FailedProviderRender;
49
+
50
+ /**
51
+ * Vytvoří nový resource-free scope pouze jako lokální React state.
52
+ */
53
+ function createProviderScope(): adapterScope.AdapterScopeRuntime {
54
+ return new adapterScope.AdapterScopeRuntime();
55
+ }
56
+
57
+ /**
58
+ * Zachytí všechna známá provider pole v normativním pořadí bez partial Contextu.
59
+ */
60
+ function captureProviderRender(
61
+ props: ExtensionRegistryProviderProps,
62
+ parent: adapterContext.AdapterContextValue | undefined,
63
+ scope: adapterScope.AdapterScopeRuntime,
64
+ checkpoint: () => void,
65
+ ): CapturedProviderRender {
66
+ const source = publicInputCapture.requireInputObject(props, "props");
67
+ const registryValue = publicInputCapture.readInputProperty(
68
+ source,
69
+ "registry",
70
+ "props.registry",
71
+ checkpoint,
72
+ );
73
+ const sinkValue = publicInputCapture.readInputProperty(
74
+ source,
75
+ "sink",
76
+ "props.sink",
77
+ checkpoint,
78
+ );
79
+ const errorPolicyValue = publicInputCapture.readInputProperty(
80
+ source,
81
+ "errorPolicy",
82
+ "props.errorPolicy",
83
+ checkpoint,
84
+ );
85
+ const projectContextValue = publicInputCapture.readInputProperty(
86
+ source,
87
+ "projectContext",
88
+ "props.projectContext",
89
+ checkpoint,
90
+ );
91
+ const children = publicInputCapture.readInputProperty(
92
+ source,
93
+ "children",
94
+ "props.children",
95
+ checkpoint,
96
+ ) as react.ReactNode;
97
+ const protocol = adapterRegistryProtocol.captureAdapterRegistryProtocol(
98
+ registryValue,
99
+ checkpoint,
100
+ );
101
+ const patch = adapterConfiguration.captureAdapterConfigurationPatch(
102
+ sinkValue,
103
+ errorPolicyValue,
104
+ projectContextValue,
105
+ checkpoint,
106
+ );
107
+ const configuration = adapterConfiguration.resolveAdapterScopeConfiguration(
108
+ parent?.generation.configuration,
109
+ patch,
110
+ );
111
+ checkpoint();
112
+ const generation = adapterScope.createAdapterScopeGeneration(protocol, configuration);
113
+ return Object.freeze({
114
+ ok: true,
115
+ children,
116
+ contextValue: adapterContext.createAdapterContextValue(scope, generation),
117
+ });
118
+ }
119
+
120
+ /**
121
+ * Poskytne tree-local registry a adapter konfiguraci bez DOM wrapperu nebo Core dispose.
122
+ *
123
+ * @public
124
+ */
125
+ export function ExtensionRegistryProvider(
126
+ props: ExtensionRegistryProviderProps,
127
+ ): react.ReactElement {
128
+ const parent = adapterContext.useAdapterContext();
129
+ const [scope] = react.useState(createProviderScope);
130
+ const renderSerial = react.useRef(0);
131
+ renderSerial.current += 1;
132
+ const currentRenderSerial = renderSerial.current;
133
+ /** Ověří, že reentrantní host seam nezneplatnil právě probíhající capture. */
134
+ function checkpointProviderRender(): void {
135
+ if (renderSerial.current !== currentRenderSerial) {
136
+ throw new reactAdapterError.ReactAdapterError(
137
+ "REACT_ADAPTER_DISPOSED",
138
+ "The provider render attempt is no longer current.",
139
+ { details: { field: "provider.render", phase: "lifecycle" } },
140
+ );
141
+ }
142
+ }
143
+
144
+ let captured: ProviderRender;
145
+ try {
146
+ captured = captureProviderRender(props, parent, scope, checkpointProviderRender);
147
+ } catch (error: unknown) {
148
+ captured = Object.freeze({ ok: false, error });
149
+ }
150
+
151
+ const generation = captured.ok ? captured.contextValue.generation : undefined;
152
+ react.useEffect(
153
+ /** Committed provider lifecycle vlastní pouze adapter scope owner lease. */
154
+ function acquireProviderScope(): void | (() => void) {
155
+ if (generation === undefined || renderSerial.current !== currentRenderSerial) {
156
+ return undefined;
157
+ }
158
+ return scope.acquireOwner(generation);
159
+ },
160
+ [
161
+ scope,
162
+ generation?.defaultProtocol.rawRegistry,
163
+ generation?.defaultProtocol.registryId,
164
+ generation?.configuration.sink?.receiver,
165
+ generation?.configuration.sink?.report,
166
+ generation?.configuration.errorPolicy,
167
+ generation?.configuration.projectContext,
168
+ ],
169
+ );
170
+
171
+ if (!captured.ok) {
172
+ throw captured.error;
173
+ }
174
+
175
+ return adapterContext.createAdapterContextProvider(
176
+ captured.contextValue,
177
+ captured.children,
178
+ );
179
+ }
package/src/index.ts ADDED
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Public React adapter contracts for typed components, managed-lazy descriptors,
3
+ * and authentic Core extension points.
4
+ *
5
+ * @packageDocumentation
6
+ */
7
+
8
+ export { defineReactContributionComponent } from "./contribution-component.js";
9
+ export { ExtensionOutlet } from "./extension-outlet.js";
10
+ export { ExtensionRegistryProvider } from "./extension-registry-provider.js";
11
+ export { ReactAdapterError } from "./react-adapter-error.js";
12
+ export { defineReactExtensionPoint } from "./react-extension-point.js";
13
+ export { defineReactLazyContribution } from "./react-lazy-contribution.js";
14
+ export { useResolvedContributions } from "./resolved-contributions.js";
15
+
16
+ export type {
17
+ ExtensionContributionProps,
18
+ ExtensionContributionView,
19
+ ReactContributionComponent,
20
+ ResolvedContributionPlacement,
21
+ } from "./contribution-component.js";
22
+
23
+ export type {
24
+ ExtensionContributionErrorRenderState,
25
+ ExtensionContributionLoadingRenderState,
26
+ ExtensionContributionReadyRenderState,
27
+ ExtensionContributionRenderStateBase,
28
+ ExtensionEmptyRenderState,
29
+ ExtensionOutletErrorEmission,
30
+ ExtensionOutletProps,
31
+ ExtensionOutletRetryEvent,
32
+ ExtensionResolveErrorRenderState,
33
+ } from "./extension-outlet.js";
34
+
35
+ export type {
36
+ ExtensionRegistryProviderProps,
37
+ } from "./extension-registry-provider.js";
38
+
39
+ export type {
40
+ ReactAdapterDiagnosticEvent,
41
+ ReactAdapterErrorEvent,
42
+ ReactAdapterSink,
43
+ ReactErrorAction,
44
+ ReactErrorPolicy,
45
+ ReadonlyContributionMetadata,
46
+ ReadonlyPointMetadata,
47
+ } from "./react-adapter-diagnostics.js";
48
+
49
+ export type {
50
+ ReactAdapterErrorCode,
51
+ ReactAdapterErrorPhase,
52
+ } from "./react-adapter-error.js";
53
+
54
+ export type {
55
+ AnyReactExtensionPoint,
56
+ ReactExtensionPoint,
57
+ ReactExtensionPointDefinition,
58
+ } from "./react-extension-point.js";
59
+
60
+ export type {
61
+ ReactContributionImplementation,
62
+ ReactLazyContribution,
63
+ ReactLazyContributionInput,
64
+ ReactLazyContributionLoadInput,
65
+ } from "./react-lazy-contribution.js";
66
+
67
+ export type {
68
+ ExtensionOutletEmptyReason,
69
+ ResolvedContributionsState,
70
+ UseResolvedContributionsOptions,
71
+ UseResolvedContributionsResult,
72
+ } from "./resolved-contributions.js";
@@ -0,0 +1,181 @@
1
+ import * as publicInputCapture from "./public-input-capture.js";
2
+ import * as reactAdapterError from "../react-adapter-error.js";
3
+
4
+ /** Read-once zachycený diagnostický sink včetně původního receiveru. */
5
+ export interface CapturedReactAdapterSink {
6
+ /** Původní strukturální receiver host callbacku. */
7
+ readonly receiver: object;
8
+ /** Stabilní reference jediného známého sink callbacku. */
9
+ readonly report: (event: unknown) => unknown;
10
+ }
11
+
12
+ /** Interní error-policy callback před materializací veřejného event typu. */
13
+ export type CapturedReactErrorPolicy = (error: unknown) => unknown;
14
+
15
+ /** Interní context projector před materializací veřejného event typu. */
16
+ export type CapturedReactContextProjector = (context: unknown) => unknown;
17
+
18
+ /** Efektivní immutable konfigurace jednoho adapter scope generation. */
19
+ export interface AdapterScopeConfiguration {
20
+ /** Custom sink nebo absence znamenající package fallback. */
21
+ readonly sink: CapturedReactAdapterSink | undefined;
22
+ /** Custom contribution error policy nebo package default. */
23
+ readonly errorPolicy: CapturedReactErrorPolicy | undefined;
24
+ /** Optional bezpečná projekce host contextu do diagnostiky. */
25
+ readonly projectContext: CapturedReactContextProjector | undefined;
26
+ }
27
+
28
+ /** Tri-state patch zachovávající inheritance a explicitní null clear. */
29
+ export interface CapturedAdapterConfigurationPatch {
30
+ /** `undefined` dědí, `null` ruší custom sink. */
31
+ readonly sink: CapturedReactAdapterSink | null | undefined;
32
+ /** `undefined` dědí, `null` obnovuje package policy. */
33
+ readonly errorPolicy: CapturedReactErrorPolicy | null | undefined;
34
+ /** `undefined` dědí, `null` projector vypíná. */
35
+ readonly projectContext: CapturedReactContextProjector | null | undefined;
36
+ }
37
+
38
+ /** Lifecycle checkpoint spuštěný po každém nested public Getu. */
39
+ export type AdapterConfigurationCheckpoint = () => void;
40
+
41
+ /** Prázdná package konfigurace bez custom host callbacku. */
42
+ export const EMPTY_ADAPTER_SCOPE_CONFIGURATION: AdapterScopeConfiguration = Object.freeze({
43
+ sink: undefined,
44
+ errorPolicy: undefined,
45
+ projectContext: undefined,
46
+ });
47
+
48
+ /**
49
+ * Zachytí optional sink a jeho jediný známý callback se správným receiverem.
50
+ */
51
+ function captureSink(
52
+ value: unknown,
53
+ checkpoint: AdapterConfigurationCheckpoint,
54
+ ): CapturedReactAdapterSink | null | undefined {
55
+ if (value === undefined || value === null) {
56
+ return value;
57
+ }
58
+
59
+ const receiver = publicInputCapture.requireInputObject(value, "options.sink");
60
+ const report = publicInputCapture.readInputProperty(
61
+ receiver,
62
+ "report",
63
+ "options.sink.report",
64
+ checkpoint,
65
+ );
66
+ if (typeof report !== "function") {
67
+ return publicInputCapture.throwInvalidCapturedArgument(
68
+ "options.sink.report",
69
+ "options.sink.report must be callable.",
70
+ );
71
+ }
72
+
73
+ return Object.freeze({
74
+ receiver,
75
+ report: report as (event: unknown) => unknown,
76
+ });
77
+ }
78
+
79
+ /**
80
+ * Ověří optional callable configuration bez čtení dalších public polí.
81
+ */
82
+ function captureOptionalCallback<Callback extends (value: unknown) => unknown>(
83
+ value: unknown,
84
+ field: "errorPolicy" | "projectContext",
85
+ ): Callback | null | undefined {
86
+ if (value === undefined || value === null) {
87
+ return value;
88
+ }
89
+ if (typeof value !== "function") {
90
+ return publicInputCapture.throwInvalidCapturedArgument(
91
+ `options.${field}`,
92
+ `options.${field} must be callable.`,
93
+ );
94
+ }
95
+
96
+ return value as Callback;
97
+ }
98
+
99
+ /**
100
+ * Zvaliduje již read-once zachycené hodnoty bez dalšího čtení parent options.
101
+ */
102
+ export function captureAdapterConfigurationPatch(
103
+ sinkValue: unknown,
104
+ errorPolicyValue: unknown,
105
+ projectContextValue: unknown,
106
+ checkpoint: AdapterConfigurationCheckpoint,
107
+ ): CapturedAdapterConfigurationPatch {
108
+ return Object.freeze({
109
+ sink: captureSink(sinkValue, checkpoint),
110
+ errorPolicy: captureOptionalCallback<CapturedReactErrorPolicy>(
111
+ errorPolicyValue,
112
+ "errorPolicy",
113
+ ),
114
+ projectContext: captureOptionalCallback<CapturedReactContextProjector>(
115
+ projectContextValue,
116
+ "projectContext",
117
+ ),
118
+ });
119
+ }
120
+
121
+ /**
122
+ * Vyřeší každou config osu samostatně nad nearest provider konfigurací.
123
+ */
124
+ export function resolveAdapterScopeConfiguration(
125
+ parent: AdapterScopeConfiguration | undefined,
126
+ patch: CapturedAdapterConfigurationPatch,
127
+ ): AdapterScopeConfiguration {
128
+ return Object.freeze({
129
+ sink: patch.sink === undefined ? parent?.sink : patch.sink ?? undefined,
130
+ errorPolicy: patch.errorPolicy === undefined
131
+ ? parent?.errorPolicy
132
+ : patch.errorPolicy ?? undefined,
133
+ projectContext: patch.projectContext === undefined
134
+ ? parent?.projectContext
135
+ : patch.projectContext ?? undefined,
136
+ });
137
+ }
138
+
139
+ /**
140
+ * Porovná dvě efektivní konfigurace pouze přes zachycené capability reference.
141
+ */
142
+ export function isSameAdapterScopeConfiguration(
143
+ left: AdapterScopeConfiguration,
144
+ right: AdapterScopeConfiguration,
145
+ ): boolean {
146
+ return left.sink?.receiver === right.sink?.receiver
147
+ && left.sink?.report === right.sink?.report
148
+ && left.errorPolicy === right.errorPolicy
149
+ && left.projectContext === right.projectContext;
150
+ }
151
+
152
+ /**
153
+ * Vybere explicitní registry bez silent fallbacku nebo nearest provider default.
154
+ */
155
+ export function resolveAdapterRegistryInput(
156
+ explicitRegistry: unknown,
157
+ inheritedRegistry: unknown | undefined,
158
+ ): unknown {
159
+ if (explicitRegistry !== undefined) {
160
+ return explicitRegistry;
161
+ }
162
+ if (inheritedRegistry !== undefined) {
163
+ return inheritedRegistry;
164
+ }
165
+
166
+ throw new reactAdapterError.ReactAdapterError(
167
+ "REACT_REGISTRY_NOT_PROVIDED",
168
+ "No extension registry was provided.",
169
+ { details: { field: "options.registry", phase: "configuration" } },
170
+ );
171
+ }
172
+
173
+ /**
174
+ * Zavolá zachycený sink s původním receiverem; výsledek vlastní vyšší pipeline.
175
+ */
176
+ export function callCapturedReactAdapterSink(
177
+ sink: CapturedReactAdapterSink,
178
+ event: unknown,
179
+ ): unknown {
180
+ return Reflect.apply(sink.report, sink.receiver, [event]);
181
+ }
@@ -0,0 +1,43 @@
1
+ import * as react from "react";
2
+
3
+ import * as adapterScope from "./adapter-scope.js";
4
+
5
+ /**
6
+ * Immutable provider value oddělující stabilní scope od aktuální generation.
7
+ */
8
+ export interface AdapterContextValue {
9
+ /** Stabilní tree-local vlastník bridge a lifecycle zdrojů. */
10
+ readonly scope: adapterScope.AdapterScopeRuntime;
11
+ /** Aktuální provider registry a inherited konfigurace. */
12
+ readonly generation: adapterScope.AdapterScopeGeneration;
13
+ }
14
+
15
+ /** Modulově lokální Context capability bez process-global registry mapy. */
16
+ const adapterContext = react.createContext<AdapterContextValue | undefined>(undefined);
17
+
18
+ /**
19
+ * Vytvoří frozen Context value pro jeden provider render.
20
+ */
21
+ export function createAdapterContextValue(
22
+ scope: adapterScope.AdapterScopeRuntime,
23
+ generation: adapterScope.AdapterScopeGeneration,
24
+ ): AdapterContextValue {
25
+ return Object.freeze({ scope, generation });
26
+ }
27
+
28
+ /**
29
+ * Vrátí nearest provider hodnotu při zachování standardního React Hook pořadí.
30
+ */
31
+ export function useAdapterContext(): AdapterContextValue | undefined {
32
+ return react.useContext(adapterContext);
33
+ }
34
+
35
+ /**
36
+ * Vystaví interní Context provider bez přidání host DOM elementu.
37
+ */
38
+ export function createAdapterContextProvider(
39
+ value: AdapterContextValue,
40
+ children: react.ReactNode,
41
+ ): react.ReactElement {
42
+ return react.createElement(adapterContext.Provider, { value }, children);
43
+ }