@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,590 @@
1
+ import type * as contribKitCore from "@primafuture/contrib-kit-core";
2
+ import * as react from "react";
3
+
4
+ import type * as adapterConfiguration from "./internal/adapter-configuration.js";
5
+ import type * as outletCommitLease from "./internal/outlet-commit-lease.js";
6
+ import * as outletErrorPipeline from "./internal/outlet-error-pipeline.js";
7
+ import * as outletInput from "./internal/outlet-input.js";
8
+ import * as outletMembership from "./internal/outlet-membership.js";
9
+ import * as outletMembershipBoundary from "./internal/outlet-membership-boundary.js";
10
+ import * as outletProjection from "./internal/outlet-projection.js";
11
+ import * as reactAdapterDiagnostics from "./react-adapter-diagnostics.js";
12
+ import type * as reactExtensionPoint from "./react-extension-point.js";
13
+ import * as resolvedContributions from "./resolved-contributions.js";
14
+
15
+ /**
16
+ * Společný frozen render state jedné logical outlet membership.
17
+ *
18
+ * @public
19
+ */
20
+ export interface ExtensionContributionRenderStateBase<
21
+ Point extends import("./react-extension-point.js").AnyReactExtensionPoint,
22
+ > {
23
+ /** Context exact outlet resolution snapshotu. */
24
+ readonly context: contribKitCore.ExtensionPointContext<Point>;
25
+ /** Bezpečný public contribution view bez registration identity. */
26
+ readonly contribution: import("./contribution-component.js").ExtensionContributionView<
27
+ contribKitCore.ExtensionPointData<Point>
28
+ >;
29
+ /** Outlet-local logická pozice ve finálním Core pořadí. */
30
+ readonly placement: import("./contribution-component.js").ResolvedContributionPlacement;
31
+ /** Exact canonical React extension point. */
32
+ readonly point: Point;
33
+ }
34
+
35
+ /**
36
+ * Frozen render state eager nebo již načtené contribution.
37
+ *
38
+ * @public
39
+ */
40
+ export interface ExtensionContributionReadyRenderState<
41
+ Point extends import("./react-extension-point.js").AnyReactExtensionPoint,
42
+ > extends ExtensionContributionRenderStateBase<Point> {
43
+ /** Exact ověřená React contribution component reference. */
44
+ readonly component: import("./contribution-component.js").ReactContributionComponent<
45
+ contribKitCore.ExtensionPointContext<Point>,
46
+ contribKitCore.ExtensionPointData<Point>
47
+ >;
48
+ /** Frozen default-render props sdílející tutéž placement referenci. */
49
+ readonly componentProps: import("./contribution-component.js").ExtensionContributionProps<
50
+ contribKitCore.ExtensionPointContext<Point>,
51
+ contribKitCore.ExtensionPointData<Point>
52
+ >;
53
+ }
54
+
55
+ /**
56
+ * Frozen render state dosud nenačtené managed-lazy membership.
57
+ *
58
+ * @public
59
+ */
60
+ export interface ExtensionContributionLoadingRenderState<
61
+ Point extends import("./react-extension-point.js").AnyReactExtensionPoint,
62
+ > extends ExtensionContributionRenderStateBase<Point> {}
63
+
64
+ /**
65
+ * Frozen render state izolované contribution chyby.
66
+ *
67
+ * @public
68
+ */
69
+ export interface ExtensionContributionErrorRenderState<
70
+ Point extends import("./react-extension-point.js").AnyReactExtensionPoint,
71
+ > extends ExtensionContributionRenderStateBase<Point> {
72
+ /** Tentýž frozen primary event použitý sinkem a policy. */
73
+ readonly error: import("./react-adapter-diagnostics.js").ReactAdapterErrorEvent;
74
+ /** Generation-bound recovery command dané membership. */
75
+ retry(): void;
76
+ }
77
+
78
+ /**
79
+ * Placement-free frozen stav úspěšného prázdného outletu.
80
+ *
81
+ * @public
82
+ */
83
+ export interface ExtensionEmptyRenderState<
84
+ Point extends import("./react-extension-point.js").AnyReactExtensionPoint,
85
+ > {
86
+ /** Context úspěšného empty resolution snapshotu. */
87
+ readonly context: contribKitCore.ExtensionPointContext<Point>;
88
+ /** Exact canonical point. */
89
+ readonly point: Point;
90
+ /** Rozlišení prázdného katalogu od policy-excluded výsledku. */
91
+ readonly reason: import("./resolved-contributions.js").ExtensionOutletEmptyReason;
92
+ }
93
+
94
+ /**
95
+ * Placement-free frozen stav neúspěšného outlet resolution.
96
+ *
97
+ * @public
98
+ */
99
+ export interface ExtensionResolveErrorRenderState<
100
+ Point extends import("./react-extension-point.js").AnyReactExtensionPoint,
101
+ > {
102
+ /** Context neúspěšného query attemptu. */
103
+ readonly context: contribKitCore.ExtensionPointContext<Point>;
104
+ /** Frozen primary resolve event. */
105
+ readonly error: import("./react-adapter-diagnostics.js").ReactAdapterErrorEvent;
106
+ /** Exact canonical point. */
107
+ readonly point: Point;
108
+ /** Stabilní outlet-local invalidace bez Core commitu. */
109
+ refresh(): void;
110
+ }
111
+
112
+ /**
113
+ * Frozen discriminovaná recovery capability doručená outlet `onError` callbacku.
114
+ *
115
+ * @public
116
+ */
117
+ export type ExtensionOutletErrorEmission =
118
+ | {
119
+ /** Rozlišuje per-membership chybu. */
120
+ readonly kind: "contribution";
121
+ /** Frozen primary contribution event. */
122
+ readonly error: import("./react-adapter-diagnostics.js").ReactAdapterErrorEvent;
123
+ /** Generation-bound membership retry. */
124
+ retry(): void;
125
+ }
126
+ | {
127
+ /** Rozlišuje celý failed resolve attempt. */
128
+ readonly kind: "resolve";
129
+ /** Frozen primary resolve event. */
130
+ readonly error: import("./react-adapter-diagnostics.js").ReactAdapterErrorEvent;
131
+ /** Stabilní outlet-local refresh command. */
132
+ refresh(): void;
133
+ };
134
+
135
+ /**
136
+ * Frozen evidence jednoho committed accepted membership retry.
137
+ *
138
+ * @public
139
+ */
140
+ export interface ExtensionOutletRetryEvent {
141
+ /** Opaque scope-local boundary identita. */
142
+ readonly boundaryId: string;
143
+ /** Veřejná contribution identita bez business dat. */
144
+ readonly contributionId: string;
145
+ /** Opaque scope-local outlet identita. */
146
+ readonly outletId: string;
147
+ /** Veřejná point identita. */
148
+ readonly pointId: string;
149
+ /** Opaque exact Core activation identita. */
150
+ readonly registrationId: string;
151
+ /** Nově committed monotonická retry generation. */
152
+ readonly retryGeneration: number;
153
+ }
154
+
155
+ /**
156
+ * Read-once props headless outletu inferované z exact React pointu.
157
+ *
158
+ * @public
159
+ */
160
+ export interface ExtensionOutletProps<
161
+ Point extends import("./react-extension-point.js").AnyReactExtensionPoint,
162
+ > {
163
+ /** Context předaný Core resolution pipeline a contribution props. */
164
+ readonly context: contribKitCore.ExtensionPointContext<Point>;
165
+ /** Lokální contribution policy; null obnoví package default. */
166
+ readonly errorPolicy?: import("./react-adapter-diagnostics.js").ReactErrorPolicy | null | undefined;
167
+ /** False eskaluje contribution failure bez policy izolace. */
168
+ readonly isolateErrors?: boolean | undefined;
169
+ /** Committed error callback s omezenou retry nebo refresh capability. */
170
+ readonly onError?: ((event: ExtensionOutletErrorEmission) => void) | undefined;
171
+ /** Callback až po commitu accepted retry generation. */
172
+ readonly onRetry?: ((event: ExtensionOutletRetryEvent) => void) | undefined;
173
+ /** Exact canonical React extension point. */
174
+ readonly point: Point;
175
+ /** Lokální pure context projector; null zruší inherited projector. */
176
+ readonly projectContext?: (
177
+ (context: contribKitCore.ExtensionPointContext<Point>) => unknown
178
+ ) | null | undefined;
179
+ /** Explicitní registry s předností před nearest providerem. */
180
+ readonly registry?: contribKitCore.ExtensionRegistry | undefined;
181
+ /** Optional headless renderer ready membershipu. */
182
+ readonly renderContribution?: ((
183
+ state: ExtensionContributionReadyRenderState<Point>,
184
+ ) => react.ReactNode) | undefined;
185
+ /** Optional fallback renderer izolované contribution chyby. */
186
+ readonly renderContributionError?: ((
187
+ state: ExtensionContributionErrorRenderState<Point>,
188
+ ) => react.ReactNode) | undefined;
189
+ /** Optional renderer úspěšného prázdného výsledku. */
190
+ readonly renderEmpty?: ((state: ExtensionEmptyRenderState<Point>) => react.ReactNode) | undefined;
191
+ /** Optional renderer managed-lazy loading membershipu. */
192
+ readonly renderLoading?: ((
193
+ state: ExtensionContributionLoadingRenderState<Point>,
194
+ ) => react.ReactNode) | undefined;
195
+ /** Optional renderer celého resolve failure. */
196
+ readonly renderResolveError?: ((
197
+ state: ExtensionResolveErrorRenderState<Point>,
198
+ ) => react.ReactNode) | undefined;
199
+ /** Lokální diagnostic sink; null obnoví bezpečný package fallback. */
200
+ readonly sink?: import("./react-adapter-diagnostics.js").ReactAdapterSink | null | undefined;
201
+ }
202
+
203
+ /** Vstup outlet-level rendereru bez contribution identity. */
204
+ interface OutletGlobalRendererProps {
205
+ /** Read-once captured renderer callback. */
206
+ readonly render: outletInput.CapturedOutletCallback<unknown, react.ReactNode>;
207
+ /** Frozen empty nebo resolve-error render state. */
208
+ readonly state: unknown;
209
+ }
210
+
211
+ /** Vstup sink-only outlet-level reporter boundary. */
212
+ interface OutletGlobalReporterProps<
213
+ Point extends reactExtensionPoint.AnyReactExtensionPoint,
214
+ > {
215
+ /** React subtree host rendereru. */
216
+ readonly children: react.ReactNode;
217
+ /** Effective sink konfigurace outletu. */
218
+ readonly configuration: adapterConfiguration.AdapterScopeConfiguration;
219
+ /** Exact generation resetující stale reporter state. */
220
+ readonly generationToken: object;
221
+ /** Current query/outlet authority. */
222
+ readonly isCurrent: () => boolean;
223
+ /** Optional committed outlet lease. */
224
+ readonly outletLease: outletCommitLease.OutletCommitLease | undefined;
225
+ /** Exact canonical point pro bezpečná metadata. */
226
+ readonly point: Point;
227
+ }
228
+
229
+ /** State outlet reporteru oddělující capture, report a exact escalation. */
230
+ interface OutletGlobalReporterState {
231
+ /** Captured host renderer cause. */
232
+ readonly cause: unknown;
233
+ /** Exact cause připravený pro následující host escalation. */
234
+ readonly escalationCause: unknown;
235
+ /** Rozlišuje skutečně captured undefined cause. */
236
+ readonly hasFailure: boolean;
237
+ /** Zda následující render musí eskalovat. */
238
+ readonly hasEscalation: boolean;
239
+ /** Exact render generation owning current state. */
240
+ readonly generationToken: object;
241
+ }
242
+
243
+ /** Props committed hostu atomicky držícího poslední membership snapshot. */
244
+ interface OutletCommittedHostProps<
245
+ Point extends reactExtensionPoint.AnyReactExtensionPoint,
246
+ > {
247
+ /** Sdílený hook/scope binding current renderu. */
248
+ readonly binding: resolvedContributions.OutletResolvedContributionsBinding<Point>;
249
+ /** Pure outlet projection current renderu. */
250
+ readonly projection: outletProjection.OutletProjectionSnapshot<Point>;
251
+ }
252
+
253
+ /** Class state představující pouze atomicky odvozený membership snapshot. */
254
+ interface OutletCommittedHostState<
255
+ Point extends reactExtensionPoint.AnyReactExtensionPoint,
256
+ > {
257
+ /** Poslední React state derivací přijatý immutable snapshot. */
258
+ readonly snapshot: outletMembership.OutletMembershipSnapshot<Point>;
259
+ /** Poslední autoritativní lease a raw registry pro Activity-only state retention. */
260
+ readonly retainedLease:
261
+ | {
262
+ /** Lease, která byla v některém předchozím commitu current. */
263
+ readonly lease: outletCommitLease.OutletCommitLease;
264
+ /** Raw registry identita, pro kterou byla lease přijata. */
265
+ readonly rawRegistry: object;
266
+ }
267
+ | undefined;
268
+ }
269
+
270
+ /** Render effectu pro committed resolve `onError`. */
271
+ interface OutletResolveCallbackAttempt<
272
+ Point extends reactExtensionPoint.AnyReactExtensionPoint,
273
+ > {
274
+ /** Exact sdílený hook binding current renderu. */
275
+ readonly binding: resolvedContributions.OutletResolvedContributionsBinding<Point>;
276
+ /** Read-once outlet input včetně callbacku. */
277
+ readonly input: outletInput.CapturedOutletInput<Point>;
278
+ }
279
+
280
+ /** Vytvoří čistý outlet reporter state pro novou render generation. */
281
+ function createGlobalReporterState(generationToken: object): OutletGlobalReporterState {
282
+ return {
283
+ cause: undefined,
284
+ escalationCause: undefined,
285
+ hasFailure: false,
286
+ hasEscalation: false,
287
+ generationToken,
288
+ };
289
+ }
290
+
291
+ /** Volá host renderer s undefined receiverem uvnitř jeho reporter boundary. */
292
+ function OutletGlobalRenderer(props: OutletGlobalRendererProps): react.ReactElement {
293
+ const rendered = outletInput.callCapturedOutletCallback(props.render, props.state);
294
+ return react.createElement(react.Fragment, null, rendered);
295
+ }
296
+
297
+ /**
298
+ * Outlet-level class boundary reportující custom renderer chybu bez contribution policy.
299
+ */
300
+ class OutletGlobalReporterBoundary<
301
+ Point extends reactExtensionPoint.AnyReactExtensionPoint,
302
+ > extends react.Component<OutletGlobalReporterProps<Point>, OutletGlobalReporterState> {
303
+ /** State začíná bez failure v exact projection generation. */
304
+ public override state = createGlobalReporterState(this.props.generationToken);
305
+
306
+ /** Zachytí host renderer cause bez sink side effectu. */
307
+ public static getDerivedStateFromError(cause: unknown): Partial<OutletGlobalReporterState> {
308
+ return { cause, hasFailure: true, hasEscalation: false };
309
+ }
310
+
311
+ /** Resetuje reporter dříve, než renderuje novou projection generation. */
312
+ public static getDerivedStateFromProps(
313
+ props: OutletGlobalReporterProps<reactExtensionPoint.AnyReactExtensionPoint>,
314
+ state: OutletGlobalReporterState,
315
+ ): OutletGlobalReporterState | null {
316
+ return props.generationToken === state.generationToken
317
+ ? null
318
+ : createGlobalReporterState(props.generationToken);
319
+ }
320
+
321
+ /** Reportuje committed failure právě jednou a připraví exact escalation. */
322
+ public override componentDidCatch(cause: unknown, info: react.ErrorInfo): void {
323
+ if (!this.state.hasFailure || !this.props.isCurrent()) {
324
+ return;
325
+ }
326
+ const point = reactAdapterDiagnostics.createPointMetadata(this.props.point);
327
+ const reactComponentStack = outletErrorPipeline.normalizeReactComponentStack(
328
+ info.componentStack,
329
+ );
330
+ const outletId = this.props.outletLease?.isCurrent() === true
331
+ ? this.props.outletLease.id
332
+ : undefined;
333
+ const event = reactAdapterDiagnostics.createReactAdapterErrorEvent({
334
+ code: "REACT_RENDER_FAILED",
335
+ cause,
336
+ phase: "customRender",
337
+ ...(outletId === undefined ? {} : { outletId }),
338
+ ...(point === undefined ? {} : { point }),
339
+ ...(reactComponentStack === undefined ? {} : { reactComponentStack }),
340
+ });
341
+ reactAdapterDiagnostics.reportReactAdapterDiagnostic(
342
+ reactAdapterDiagnostics.createErrorDiagnostic(event),
343
+ this.props.configuration,
344
+ );
345
+ if (this.props.isCurrent()) {
346
+ this.setState({ escalationCause: cause, hasEscalation: true });
347
+ }
348
+ }
349
+
350
+ /** Failed commit nejprve zobrazí null, další render vyhodí exact cause hostu. */
351
+ public override render(): react.ReactNode {
352
+ if (this.state.hasEscalation) {
353
+ throw this.state.escalationCause;
354
+ }
355
+ return this.state.hasFailure ? null : this.props.children;
356
+ }
357
+ }
358
+
359
+ /** Reportuje secondary callback failure bez změny primary resolve outcome. */
360
+ function reportResolveCallbackFailure<
361
+ Point extends reactExtensionPoint.AnyReactExtensionPoint,
362
+ >(
363
+ attempt: OutletResolveCallbackAttempt<Point>,
364
+ cause: unknown,
365
+ ): void {
366
+ if (!attempt.binding.isCurrent()) {
367
+ return;
368
+ }
369
+ const point = reactAdapterDiagnostics.createPointMetadata(attempt.input.point);
370
+ const event = reactAdapterDiagnostics.createReactAdapterErrorEvent({
371
+ code: "REACT_CALLBACK_FAILED",
372
+ cause,
373
+ phase: "callback",
374
+ ...(point === undefined ? {} : { point }),
375
+ });
376
+ reactAdapterDiagnostics.reportReactAdapterDiagnostic(
377
+ reactAdapterDiagnostics.createErrorDiagnostic(event),
378
+ attempt.input.configuration,
379
+ );
380
+ }
381
+
382
+ /** Pohltí sync, Promise i hostile thenable výsledek resolve callbacku. */
383
+ function consumeResolveCallbackResult<
384
+ Point extends reactExtensionPoint.AnyReactExtensionPoint,
385
+ >(
386
+ result: unknown,
387
+ attempt: OutletResolveCallbackAttempt<Point>,
388
+ ): void {
389
+ let reported = false;
390
+ /** Přeloží nejvýše jednu current rejection na secondary diagnostiku. */
391
+ function reportFailure(cause: unknown): void {
392
+ if (reported) {
393
+ return;
394
+ }
395
+ reported = true;
396
+ reportResolveCallbackFailure(attempt, cause);
397
+ }
398
+ try {
399
+ void Promise.resolve(result).catch(reportFailure);
400
+ } catch (cause: unknown) {
401
+ reportFailure(cause);
402
+ }
403
+ }
404
+
405
+ /** Renderuje outlet-level empty nebo resolve-error callback pod reporter boundary. */
406
+ function renderGlobalProjection<
407
+ Point extends reactExtensionPoint.AnyReactExtensionPoint,
408
+ >(
409
+ binding: resolvedContributions.OutletResolvedContributionsBinding<Point>,
410
+ render: outletInput.CapturedOutletCallback<unknown, react.ReactNode> | undefined,
411
+ state: unknown,
412
+ generationToken: object,
413
+ ): react.ReactElement | null {
414
+ if (render === undefined) {
415
+ return null;
416
+ }
417
+ const children = react.createElement(OutletGlobalRenderer, { render, state });
418
+ const outletLease = binding.outletLease;
419
+ /** Ověří query i případnou committed outlet lease bez jejího vytvoření. */
420
+ function isCurrent(): boolean {
421
+ return binding.isCurrent()
422
+ && (outletLease === undefined || outletLease.isCurrent());
423
+ }
424
+ return react.createElement(OutletGlobalReporterBoundary<Point>, {
425
+ children,
426
+ configuration: binding.input.configuration,
427
+ generationToken,
428
+ isCurrent,
429
+ outletLease,
430
+ point: binding.input.point,
431
+ });
432
+ }
433
+
434
+ /**
435
+ * Class host publikuje jeden celý membership proposal místo render-time ref mutací.
436
+ */
437
+ class OutletCommittedHost<
438
+ Point extends reactExtensionPoint.AnyReactExtensionPoint,
439
+ > extends react.Component<OutletCommittedHostProps<Point>, OutletCommittedHostState<Point>> {
440
+ /** První snapshot vzniká čistě z initial props bez commit-owned resource. */
441
+ public override state: OutletCommittedHostState<Point> = {
442
+ snapshot: outletMembership.reconcileOutletMemberships(
443
+ undefined,
444
+ this.props.binding.rawRegistry,
445
+ this.props.projection,
446
+ ),
447
+ retainedLease: undefined,
448
+ };
449
+
450
+ /** Odvodí celý nový immutable proposal před jediným React state publish. */
451
+ public static getDerivedStateFromProps(
452
+ props: OutletCommittedHostProps<reactExtensionPoint.AnyReactExtensionPoint>,
453
+ state: OutletCommittedHostState<reactExtensionPoint.AnyReactExtensionPoint>,
454
+ ): OutletCommittedHostState<reactExtensionPoint.AnyReactExtensionPoint> {
455
+ const outletLease = props.binding.outletLease;
456
+ return {
457
+ snapshot: outletMembership.reconcileOutletMemberships(
458
+ state.snapshot,
459
+ props.binding.rawRegistry,
460
+ props.projection,
461
+ ),
462
+ retainedLease: outletLease?.isCurrent() === true
463
+ ? Object.freeze({
464
+ lease: outletLease,
465
+ rawRegistry: props.binding.rawRegistry,
466
+ })
467
+ : state.retainedLease,
468
+ };
469
+ }
470
+
471
+ /** Renderuje placement-free global stav nebo ordered membership Fragment. */
472
+ public override render(): react.ReactElement | null {
473
+ const binding = this.props.binding;
474
+ const snapshot = this.state.snapshot;
475
+ if (snapshot.projection.kind === "resolveFailed") {
476
+ return renderGlobalProjection(
477
+ binding,
478
+ binding.input.renderResolveError,
479
+ snapshot.projection.renderState,
480
+ snapshot.projection,
481
+ );
482
+ }
483
+ const outletLease = binding.outletLease;
484
+ const retainsActivitySubtree = snapshot.rawRegistry === binding.rawRegistry
485
+ && this.state.retainedLease?.rawRegistry === binding.rawRegistry
486
+ && this.state.retainedLease.lease === outletLease;
487
+ // Inaktivní lease při Activity reveal smí držet pouze subtree stejné registry.
488
+ // Registry switch zůstává null bariérou a resetuje membership state; callback
489
+ // a resource autoritu v retained větvi nadále střeží current-lease gate boundary.
490
+ if ((outletLease === undefined && !binding.serverSnapshot)
491
+ || (outletLease !== undefined
492
+ && !outletLease.isCurrent()
493
+ && !retainsActivitySubtree)) {
494
+ return null;
495
+ }
496
+ if (snapshot.projection.kind === "empty") {
497
+ return renderGlobalProjection(
498
+ binding,
499
+ binding.input.renderEmpty,
500
+ snapshot.projection.renderState,
501
+ snapshot.projection,
502
+ );
503
+ }
504
+ const generation = binding.generation;
505
+ if (generation === undefined) {
506
+ return null;
507
+ }
508
+ return react.createElement(
509
+ react.Fragment,
510
+ null,
511
+ ...snapshot.memberships.map(
512
+ /** Vytvoří samostatnou keyed package boundary v exact Core pořadí. */
513
+ function renderMembership(membership): react.ReactElement {
514
+ return react.createElement(
515
+ outletMembershipBoundary.OutletMembershipBoundary<Point>,
516
+ {
517
+ key: membership.seed.registrationId,
518
+ input: binding.input,
519
+ membership,
520
+ outletLease,
521
+ rawRegistry: binding.rawRegistry,
522
+ scope: binding.scope,
523
+ scopeGeneration: generation,
524
+ },
525
+ );
526
+ },
527
+ ),
528
+ );
529
+ }
530
+ }
531
+
532
+ /**
533
+ * Renderuje exact Core resolved kolekci jako headless React Fragment.
534
+ *
535
+ * @public
536
+ */
537
+ export function ExtensionOutlet<
538
+ Point extends import("./react-extension-point.js").AnyReactExtensionPoint,
539
+ >(
540
+ props: ExtensionOutletProps<Point>,
541
+ ): react.ReactElement | null {
542
+ const [reportedResolveAttempts] = react.useState(
543
+ /** Vytvoří outlet-local Strict dedup ledger bez global historie. */
544
+ function createResolveAttemptLedger(): WeakSet<object> {
545
+ return new WeakSet<object>();
546
+ },
547
+ );
548
+ /** Doručí resolve callback z engine effectu až po committed sink diagnostice. */
549
+ function reportCommittedResolveError(
550
+ binding: resolvedContributions.OutletResolvedContributionsBinding<Point>,
551
+ ): void {
552
+ const current: OutletResolveCallbackAttempt<Point> = Object.freeze({
553
+ binding,
554
+ input: binding.input,
555
+ });
556
+ if (current.input.onError === undefined
557
+ || current.binding.attempt.state.status !== "failed"
558
+ || !current.binding.isCurrent()
559
+ || reportedResolveAttempts.has(current.binding.attempt.token)) {
560
+ return;
561
+ }
562
+ reportedResolveAttempts.add(current.binding.attempt.token);
563
+ const emission: ExtensionOutletErrorEmission = Object.freeze({
564
+ kind: "resolve",
565
+ error: current.binding.attempt.state.error,
566
+ refresh: current.binding.result.refresh,
567
+ });
568
+ try {
569
+ const result = outletInput.callCapturedOutletCallback(
570
+ current.input.onError,
571
+ emission,
572
+ );
573
+ consumeResolveCallbackResult(result, current);
574
+ } catch (cause: unknown) {
575
+ reportResolveCallbackFailure(current, cause);
576
+ }
577
+ }
578
+
579
+ const binding = resolvedContributions.useResolvedContributionsForOutlet<Point>(
580
+ props,
581
+ reportCommittedResolveError,
582
+ );
583
+ const projection = outletProjection.projectOutletSnapshot(
584
+ binding.input.point,
585
+ binding.input.context,
586
+ binding.result,
587
+ binding.checkpoint,
588
+ );
589
+ return react.createElement(OutletCommittedHost<Point>, { binding, projection });
590
+ }