@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,710 @@
1
+ import * as react from "react";
2
+ import * as managedLazyGeneration from "./managed-lazy-generation.js";
3
+ import * as outletErrorPipeline from "./outlet-error-pipeline.js";
4
+ import * as outletInput from "./outlet-input.js";
5
+ import * as outletReporterBoundary from "./outlet-reporter-boundary.js";
6
+ import * as reactAdapterDiagnostics from "../react-adapter-diagnostics.js";
7
+ import * as reactAdapterErrorRuntime from "../react-adapter-error.js";
8
+ /** Vytvoří nový render-pure opaque retry generation token. */
9
+ function createRetryGenerationToken() {
10
+ return Object.freeze({});
11
+ }
12
+ /** Vytvoří počáteční nebo identity-reset state před renderem nové membership. */
13
+ function createMembershipBoundaryState(props, subtreeGeneration = 0) {
14
+ const seed = props.membership.seed;
15
+ return {
16
+ capturedCause: undefined,
17
+ escalationCause: undefined,
18
+ errorAttemptToken: undefined,
19
+ hasCapturedCause: false,
20
+ lazyComponent: undefined,
21
+ lazyLoad: seed.kind === "loading" ? seed.load : undefined,
22
+ lazyStatus: seed.kind === "loading" ? "loading" : "inactive",
23
+ rawRegistry: props.rawRegistry,
24
+ registrationId: props.membership.seed.registrationId,
25
+ membershipToken: props.membership.token,
26
+ mode: "rendering",
27
+ primaryError: undefined,
28
+ retry: undefined,
29
+ retryGeneration: 0,
30
+ retryToken: createRetryGenerationToken(),
31
+ subtreeGeneration,
32
+ };
33
+ }
34
+ /** Renderuje ready nebo loading větev uvnitř package class boundary. */
35
+ function OutletMembershipRenderer(props) {
36
+ const seed = props.seed;
37
+ if (seed.kind === "loading") {
38
+ if (props.input.renderLoading === undefined) {
39
+ return null;
40
+ }
41
+ const rendered = outletInput.callCapturedOutletCallback(props.input.renderLoading, seed.renderState);
42
+ return react.createElement(react.Fragment, null, rendered);
43
+ }
44
+ if (props.input.renderContribution !== undefined) {
45
+ const rendered = outletInput.callCapturedOutletCallback(props.input.renderContribution, seed.renderState);
46
+ return react.createElement(react.Fragment, null, rendered);
47
+ }
48
+ return react.createElement(seed.renderState.component, seed.renderState.componentProps);
49
+ }
50
+ /** Volá contribution fallback uvnitř samostatné reporter class boundary. */
51
+ function OutletContributionFallbackRenderer(props) {
52
+ const state = Object.freeze({
53
+ ...props.seed.renderState,
54
+ error: props.error,
55
+ retry: props.retry,
56
+ });
57
+ const rendered = outletInput.callCapturedOutletCallback(props.renderContributionError, state);
58
+ return react.createElement(react.Fragment, null, rendered);
59
+ }
60
+ /** Vrátí exact synthetic cause, nebo původní classifier cause ReactAdapterErroru. */
61
+ function resolveProjectedFailureCause(error) {
62
+ return Object.hasOwn(error, "cause") ? error.cause : error;
63
+ }
64
+ /** Odvodí public phase z bezpečných details, jinak použije render. */
65
+ function resolveProjectedFailurePhase(error) {
66
+ const phase = error.details.phase;
67
+ return phase === "configuration"
68
+ || phase === "resolve"
69
+ || phase === "load"
70
+ || phase === "render"
71
+ || phase === "customRender"
72
+ || phase === "fallback"
73
+ || phase === "policy"
74
+ || phase === "projection"
75
+ || phase === "callback"
76
+ || phase === "lifecycle"
77
+ ? phase
78
+ : "render";
79
+ }
80
+ /** Projektuje pouze bezpečnou identitu current managed-lazy contribution. */
81
+ function createManagedLazyContributionMetadata(seed) {
82
+ const contribution = seed.renderState.contribution;
83
+ return Object.freeze({
84
+ registrationId: seed.registrationId,
85
+ contributionId: contribution.contributionId,
86
+ ...(contribution.contributorId === undefined
87
+ ? {}
88
+ : { contributorId: contribution.contributorId }),
89
+ ...(contribution.label === undefined ? {} : { label: contribution.label }),
90
+ ...(contribution.localName === undefined
91
+ ? {}
92
+ : { localName: contribution.localName }),
93
+ });
94
+ }
95
+ /** Ověří active live registry bez propouštění hostile state accessoru. */
96
+ function isManagedLazyRegistryActive(rawRegistry) {
97
+ try {
98
+ return Reflect.get(rawRegistry, "state", rawRegistry) === "active";
99
+ }
100
+ catch {
101
+ return false;
102
+ }
103
+ }
104
+ /**
105
+ * Interní class error boundary jedné exact Core membership.
106
+ */
107
+ export class OutletMembershipBoundary extends react.Component {
108
+ /** Current identity/generation/presentation state. */
109
+ state;
110
+ /** Current commit-owned boundary ID lease. */
111
+ #boundaryLease;
112
+ /** Membership token, pro který current lease vznikla. */
113
+ #boundaryLeaseToken;
114
+ /** Current mutable primary attempt authority. */
115
+ #primaryAttempt;
116
+ /** Poslední retry generation již doručená onRetry callbacku. */
117
+ #reportedRetryGeneration = 0;
118
+ /** Current resource-free nebo started managed-lazy operation. */
119
+ #lazyOperation;
120
+ /** Membership token owning current lazy operation. */
121
+ #lazyOperationMembershipToken;
122
+ /** Retry token owning current lazy operation. */
123
+ #lazyOperationRetryToken;
124
+ /** Zabraňuje novému attemptu během loading-error invalidace a abortu. */
125
+ #lazyStartBarrier = 0;
126
+ /** Terminální guard skutečného unmountu i Strict grace mezery. */
127
+ #unmounted = false;
128
+ /** Vytvoří resource-free initial state a operation bez loader side effectu. */
129
+ constructor(props) {
130
+ super(props);
131
+ this.state = createMembershipBoundaryState(props);
132
+ this.#synchronizeLazyOperation();
133
+ }
134
+ /** Capture descendant error bez sinku, callbacku, policy nebo Core callu. */
135
+ static getDerivedStateFromError(cause) {
136
+ return {
137
+ capturedCause: cause,
138
+ errorAttemptToken: Object.freeze({}),
139
+ hasCapturedCause: true,
140
+ mode: "captured",
141
+ primaryError: undefined,
142
+ retry: undefined,
143
+ };
144
+ }
145
+ /** Resetuje celý boundary state před renderem jiné identity tuple. */
146
+ static getDerivedStateFromProps(props, state) {
147
+ return props.rawRegistry === state.rawRegistry
148
+ && props.membership.seed.registrationId === state.registrationId
149
+ && props.membership.token === state.membershipToken
150
+ ? null
151
+ : createMembershipBoundaryState(props, state.subtreeGeneration + 1);
152
+ }
153
+ /** Commit acquire boundary identity a případné synthetic seed failure. */
154
+ componentDidMount() {
155
+ this.#unmounted = false;
156
+ this.#synchronizeBoundaryLease();
157
+ this.#reactivatePreservedPrimaryAttempt();
158
+ const operationChanged = this.#synchronizeLazyOperation();
159
+ this.#commitProjectedFailure();
160
+ if (operationChanged) {
161
+ this.forceUpdate();
162
+ }
163
+ }
164
+ /** Synchronizuje identity switch, committed retry event a current seed failure. */
165
+ componentDidUpdate(_previousProps, previousState) {
166
+ if (previousState.membershipToken !== this.state.membershipToken
167
+ || previousState.rawRegistry !== this.state.rawRegistry
168
+ || previousState.registrationId !== this.state.registrationId) {
169
+ this.#invalidatePrimaryAttempt();
170
+ const dispatchAbort = this.#invalidateLazyOperation();
171
+ dispatchAbort();
172
+ this.#reportedRetryGeneration = 0;
173
+ }
174
+ this.#synchronizeBoundaryLease();
175
+ this.#reactivatePreservedPrimaryAttempt();
176
+ const operationChanged = this.#synchronizeLazyOperation();
177
+ if (previousState.retryGeneration !== this.state.retryGeneration) {
178
+ this.#reportCommittedRetry();
179
+ }
180
+ this.#commitProjectedFailure();
181
+ if (operationChanged) {
182
+ this.forceUpdate();
183
+ }
184
+ }
185
+ /** Commit point primary render chyby spustí pipeline právě jednou. */
186
+ componentDidCatch(cause, info) {
187
+ const attemptToken = this.state.errorAttemptToken;
188
+ if (!this.state.hasCapturedCause || attemptToken === undefined) {
189
+ return;
190
+ }
191
+ const phase = this.#readRenderFailurePhase();
192
+ const reactComponentStack = outletErrorPipeline.normalizeReactComponentStack(info.componentStack);
193
+ if (this.state.lazyStatus !== "loading") {
194
+ this.#commitPrimaryFailure(attemptToken, "REACT_RENDER_FAILED", phase, cause, reactComponentStack);
195
+ return;
196
+ }
197
+ const dispatchAbort = this.#invalidateLazyOperation();
198
+ this.#lazyStartBarrier += 1;
199
+ try {
200
+ this.#commitPrimaryFailure(attemptToken, "REACT_RENDER_FAILED", phase, cause, reactComponentStack);
201
+ }
202
+ finally {
203
+ try {
204
+ dispatchAbort();
205
+ }
206
+ finally {
207
+ this.#lazyStartBarrier -= 1;
208
+ }
209
+ }
210
+ }
211
+ /** Synchronous invalidace před release commit-owned boundary lease. */
212
+ componentWillUnmount() {
213
+ this.#unmounted = true;
214
+ this.#invalidatePrimaryAttempt();
215
+ this.#releaseBoundaryLease();
216
+ }
217
+ /** Renderuje current membership, provisional null, fallback nebo exact escalation. */
218
+ render() {
219
+ if (this.state.mode === "escalating") {
220
+ throw this.state.escalationCause;
221
+ }
222
+ if (this.state.mode === "captured" || this.state.mode === "hidden") {
223
+ return null;
224
+ }
225
+ if (this.state.mode === "fallback") {
226
+ return this.#renderFallback();
227
+ }
228
+ const seed = this.props.membership.seed;
229
+ if (seed.kind === "failed") {
230
+ return null;
231
+ }
232
+ if (seed.kind === "loading" && this.state.lazyStatus === "failed") {
233
+ return null;
234
+ }
235
+ const rendered = react.createElement(OutletMembershipRenderer, {
236
+ key: `${this.state.subtreeGeneration}:${this.state.retryGeneration}`,
237
+ input: this.props.input,
238
+ seed: this.#createCurrentRenderSeed(seed),
239
+ });
240
+ const operation = this.#readCurrentLazyOperation();
241
+ return operation === undefined
242
+ ? rendered
243
+ : react.createElement(managedLazyGeneration.ManagedLazyCommitLease, { children: rendered, operation });
244
+ }
245
+ /**
246
+ * Převede loaded lazy componentu na ready seed s nejnovějším render inputem.
247
+ */
248
+ #createCurrentRenderSeed(seed) {
249
+ if (seed.kind !== "loading" || this.state.lazyStatus !== "ready") {
250
+ return seed;
251
+ }
252
+ const component = this.state.lazyComponent;
253
+ const componentProps = Object.freeze({
254
+ context: seed.renderState.context,
255
+ contribution: seed.renderState.contribution,
256
+ placement: seed.renderState.placement,
257
+ });
258
+ return Object.freeze({
259
+ kind: "ready",
260
+ registrationId: seed.registrationId,
261
+ renderState: Object.freeze({
262
+ ...seed.renderState,
263
+ component,
264
+ componentProps,
265
+ }),
266
+ });
267
+ }
268
+ /** Vrátí operation pouze pro exact renderovanou loading generation. */
269
+ #readCurrentLazyOperation() {
270
+ return this.state.lazyStatus === "loading"
271
+ && this.#lazyStartBarrier === 0
272
+ && this.#lazyOperationMembershipToken === this.state.membershipToken
273
+ && this.#lazyOperationRetryToken === this.state.retryToken
274
+ ? this.#lazyOperation
275
+ : undefined;
276
+ }
277
+ /**
278
+ * Vytvoří nejvýše jednu resource-free operation pro exact retry generation.
279
+ */
280
+ #synchronizeLazyOperation() {
281
+ const load = this.state.lazyLoad;
282
+ const seed = this.props.membership.seed;
283
+ const outletLease = this.props.outletLease;
284
+ if (outletLease === undefined
285
+ || this.state.lazyStatus !== "loading" || load === undefined
286
+ || seed.kind !== "loading" || this.#lazyStartBarrier > 0) {
287
+ return false;
288
+ }
289
+ if (this.#lazyOperation !== undefined
290
+ && this.#lazyOperationMembershipToken === this.state.membershipToken
291
+ && this.#lazyOperationRetryToken === this.state.retryToken) {
292
+ this.#lazyOperation.requestStartRecheck();
293
+ return false;
294
+ }
295
+ const dispatchPreviousAbort = this.#invalidateLazyOperation();
296
+ dispatchPreviousAbort();
297
+ const membershipToken = this.state.membershipToken;
298
+ const retryToken = this.state.retryToken;
299
+ const retryGeneration = this.state.retryGeneration;
300
+ const scope = this.props.scope;
301
+ const scopeGeneration = this.props.scopeGeneration;
302
+ const rawRegistry = this.props.rawRegistry;
303
+ const configuration = this.props.input.configuration;
304
+ const contribution = createManagedLazyContributionMetadata(seed);
305
+ const point = reactAdapterDiagnostics.createPointMetadata(seed.renderState.point);
306
+ let diagnosticChannel;
307
+ let lifecycleFailureReported = false;
308
+ let operation;
309
+ /** Otestuje current operation včetně committed outlet a scope lease. */
310
+ function isCurrentOperation(boundary) {
311
+ return boundary.#lazyOperation === operation
312
+ && boundary.state.lazyStatus === "loading"
313
+ && boundary.#lazyStartBarrier === 0
314
+ && boundary.#isGenerationCurrent(membershipToken, retryToken);
315
+ }
316
+ operation = new managedLazyGeneration.ManagedLazyGenerationOperation(retryGeneration, load, Object.freeze({
317
+ isCurrent: () => isCurrentOperation(this),
318
+ onResolved: (component) => {
319
+ this.#publishLazyComponent(operation, membershipToken, retryToken, component);
320
+ },
321
+ onFailed: (failure) => {
322
+ this.#publishLazyFailure(operation, membershipToken, retryToken, failure);
323
+ },
324
+ onLate: (outcome) => {
325
+ this.#reportLateLazyResult(operation, diagnosticChannel, outcome);
326
+ },
327
+ onLifecycleFailure: (cause) => {
328
+ if (lifecycleFailureReported) {
329
+ return;
330
+ }
331
+ lifecycleFailureReported = true;
332
+ this.#reportLazyLifecycleFailure(diagnosticChannel, cause);
333
+ },
334
+ registerInvalidation: (invalidate) => {
335
+ const boundaryLease = this.#boundaryLease;
336
+ if (boundaryLease !== undefined
337
+ && boundaryLease.isCurrent()
338
+ && outletLease.isCurrent()
339
+ && scope.isGenerationActive(scopeGeneration)) {
340
+ diagnosticChannel = Object.freeze({
341
+ boundaryId: boundaryLease.id,
342
+ configuration,
343
+ contribution,
344
+ outletLease,
345
+ ...(point === undefined ? {} : { point }),
346
+ rawRegistry,
347
+ retryGeneration,
348
+ scope,
349
+ scopeGeneration,
350
+ });
351
+ }
352
+ return scope.registerEpochAbortable(scopeGeneration, () => {
353
+ if (this.#lazyOperation === operation) {
354
+ this.#lazyOperation = undefined;
355
+ this.#lazyOperationMembershipToken = undefined;
356
+ this.#lazyOperationRetryToken = undefined;
357
+ }
358
+ return invalidate();
359
+ });
360
+ },
361
+ }));
362
+ this.#lazyOperation = operation;
363
+ this.#lazyOperationMembershipToken = membershipToken;
364
+ this.#lazyOperationRetryToken = retryToken;
365
+ return true;
366
+ }
367
+ /** Doručí jeden safe late-result event pouze do stále vlastněného channelu. */
368
+ #reportLateLazyResult(operation, channel, outcome) {
369
+ if (channel === undefined
370
+ || !channel.scope.isGenerationActive(channel.scopeGeneration)
371
+ || !channel.outletLease.isCurrent()
372
+ || !isManagedLazyRegistryActive(channel.rawRegistry)
373
+ || !channel.scope.claimDiagnosticAttempt(operation.loadAttemptToken)) {
374
+ return;
375
+ }
376
+ reactAdapterDiagnostics.reportReactAdapterDiagnostic(reactAdapterDiagnostics.createLateLazyResultDiagnostic({
377
+ boundaryId: channel.boundaryId,
378
+ contribution: channel.contribution,
379
+ outcome,
380
+ outletId: channel.outletLease.id,
381
+ ...(channel.point === undefined ? {} : { point: channel.point }),
382
+ retryGeneration: channel.retryGeneration,
383
+ }), channel.configuration);
384
+ }
385
+ /** Publikuje abort/unsubscribe failure bez UI, callback nebo policy autority. */
386
+ #reportLazyLifecycleFailure(channel, cause) {
387
+ if (channel === undefined
388
+ || !channel.scope.isGenerationActive(channel.scopeGeneration)
389
+ || !channel.outletLease.isCurrent()
390
+ || !isManagedLazyRegistryActive(channel.rawRegistry)) {
391
+ return;
392
+ }
393
+ const error = reactAdapterDiagnostics.createReactAdapterErrorEvent({
394
+ boundaryId: channel.boundaryId,
395
+ code: "REACT_CALLBACK_FAILED",
396
+ cause,
397
+ contribution: channel.contribution,
398
+ outletId: channel.outletLease.id,
399
+ phase: "lifecycle",
400
+ ...(channel.point === undefined ? {} : { point: channel.point }),
401
+ retryGeneration: channel.retryGeneration,
402
+ });
403
+ reactAdapterDiagnostics.reportReactAdapterDiagnostic(reactAdapterDiagnostics.createErrorDiagnostic(error), channel.configuration);
404
+ }
405
+ /** Publikuje validní componentu pouze do exact current loading generation. */
406
+ #publishLazyComponent(operation, membershipToken, retryToken, component) {
407
+ if (this.#lazyOperation !== operation
408
+ || this.state.lazyStatus !== "loading"
409
+ || !this.#isGenerationCurrent(membershipToken, retryToken)) {
410
+ return;
411
+ }
412
+ this.setState({ lazyComponent: component, lazyStatus: "ready" });
413
+ }
414
+ /** Převede current lazy failure do committed contribution error pipeline. */
415
+ #publishLazyFailure(operation, membershipToken, retryToken, failure) {
416
+ if (this.#lazyOperation !== operation
417
+ || this.state.lazyStatus !== "loading"
418
+ || !this.#isGenerationCurrent(membershipToken, retryToken)) {
419
+ return;
420
+ }
421
+ const cause = Object.hasOwn(failure, "cause")
422
+ ? failure.cause
423
+ : new reactAdapterErrorRuntime.ReactAdapterError("REACT_POINT_IMPLEMENTATION_INVALID", "The managed React contribution loader returned a non-component value.", { details: { field: "loader.result", phase: "load" } });
424
+ const errorAttemptToken = Object.freeze({});
425
+ this.setState({ lazyComponent: undefined, lazyStatus: "failed" },
426
+ /** Pipeline smí začít až po commitu failed presentation. */
427
+ () => {
428
+ if (this.#lazyOperation !== operation
429
+ || this.state.lazyStatus !== "failed"
430
+ || !this.#isGenerationCurrent(membershipToken, retryToken)) {
431
+ return;
432
+ }
433
+ this.#commitPrimaryFailure(errorAttemptToken, failure.code, "load", cause, undefined);
434
+ });
435
+ }
436
+ /** Zneplatní current lazy operation a vrátí oddělený abort dispatch. */
437
+ #invalidateLazyOperation() {
438
+ const operation = this.#lazyOperation;
439
+ this.#lazyOperation = undefined;
440
+ this.#lazyOperationMembershipToken = undefined;
441
+ this.#lazyOperationRetryToken = undefined;
442
+ return operation?.invalidate() ?? managedLazyGeneration.skipManagedLazyAbortDispatch;
443
+ }
444
+ /** Ověří a případně obnoví commit lease current membership tokenu. */
445
+ #synchronizeBoundaryLease() {
446
+ const membershipToken = this.state.membershipToken;
447
+ if (this.props.outletLease?.isCurrent() !== true) {
448
+ this.#releaseBoundaryLease();
449
+ return;
450
+ }
451
+ if (this.#boundaryLeaseToken === membershipToken
452
+ && this.#boundaryLease?.isCurrent() === true) {
453
+ return;
454
+ }
455
+ this.#releaseBoundaryLease();
456
+ this.#boundaryLease = this.props.scope.acquireCommitLease(this.props.scopeGeneration, "boundary", membershipToken);
457
+ this.#boundaryLeaseToken = membershipToken;
458
+ }
459
+ /** Idempotentně release boundary lease bez změny Core registry. */
460
+ #releaseBoundaryLease() {
461
+ this.#boundaryLease?.release();
462
+ this.#boundaryLease = undefined;
463
+ this.#boundaryLeaseToken = undefined;
464
+ }
465
+ /** Ověří current committed membership, retry generation, outlet i scope lease. */
466
+ #isGenerationCurrent(membershipToken, retryToken) {
467
+ return !this.#unmounted
468
+ && this.state.membershipToken === membershipToken
469
+ && this.state.retryToken === retryToken
470
+ && this.props.rawRegistry === this.state.rawRegistry
471
+ && this.props.membership.token === membershipToken
472
+ && this.props.membership.seed.registrationId === this.state.registrationId
473
+ && this.#boundaryLeaseToken === membershipToken
474
+ && this.#boundaryLease?.isCurrent() === true
475
+ && this.props.outletLease?.isCurrent() === true;
476
+ }
477
+ /** Ověří celý primary attempt včetně sync retry invalidace. */
478
+ #isPrimaryAttemptCurrent(attempt) {
479
+ return attempt.authoritative
480
+ && this.#primaryAttempt === attempt
481
+ && this.#boundaryLease === attempt.boundaryLease
482
+ && attempt.boundaryLease.isCurrent()
483
+ && this.#isGenerationCurrent(attempt.membershipToken, attempt.retryToken);
484
+ }
485
+ /** Vytvoří retry capability svázanou s current boundary lease a UI generation. */
486
+ #createPrimaryAttempt(errorAttemptToken, boundaryLease) {
487
+ const attempt = {
488
+ authoritative: true,
489
+ boundaryLease,
490
+ published: false,
491
+ errorAttemptToken,
492
+ membershipToken: this.state.membershipToken,
493
+ retry: () => { },
494
+ retryToken: this.state.retryToken,
495
+ };
496
+ const boundary = this;
497
+ /** Přijme právě první current retry call dané primary capability. */
498
+ function retry() {
499
+ boundary.#acceptRetry(attempt);
500
+ }
501
+ attempt.retry = Object.freeze(retry);
502
+ return attempt;
503
+ }
504
+ /** Zneplatní primary capability dříve než začne další lifecycle práce. */
505
+ #invalidatePrimaryAttempt() {
506
+ if (this.#primaryAttempt !== undefined) {
507
+ this.#primaryAttempt.authoritative = false;
508
+ this.#primaryAttempt = undefined;
509
+ }
510
+ }
511
+ /**
512
+ * Naváže zachovanou failed presentation na novou Activity epochu bez replaye pipeline.
513
+ */
514
+ #reactivatePreservedPrimaryAttempt() {
515
+ if (this.state.primaryError === undefined
516
+ || this.state.retry === undefined
517
+ || (this.state.mode !== "fallback" && this.state.mode !== "hidden")) {
518
+ return;
519
+ }
520
+ const currentAttempt = this.#primaryAttempt;
521
+ if (currentAttempt !== undefined && this.#isPrimaryAttemptCurrent(currentAttempt)) {
522
+ return;
523
+ }
524
+ this.#invalidatePrimaryAttempt();
525
+ const boundaryLease = this.#boundaryLease;
526
+ if (boundaryLease === undefined
527
+ || !this.#isGenerationCurrent(this.state.membershipToken, this.state.retryToken)) {
528
+ return;
529
+ }
530
+ const attempt = this.#createPrimaryAttempt(Object.freeze({}), boundaryLease);
531
+ attempt.published = true;
532
+ this.#primaryAttempt = attempt;
533
+ this.setState({ retry: attempt.retry });
534
+ }
535
+ /** Převede current failed projection na committed primary pipeline. */
536
+ #commitProjectedFailure() {
537
+ const seed = this.props.membership.seed;
538
+ if (seed.kind !== "failed" || this.state.mode !== "rendering") {
539
+ return;
540
+ }
541
+ this.#commitPrimaryFailure(Object.freeze({}), seed.error.code, resolveProjectedFailurePhase(seed.error), resolveProjectedFailureCause(seed.error), undefined);
542
+ }
543
+ /** Spustí at-most-once pipeline jednoho exact membership/error attemptu. */
544
+ #commitPrimaryFailure(errorAttemptToken, code, phase, cause, reactComponentStack) {
545
+ this.#synchronizeBoundaryLease();
546
+ const membershipToken = this.state.membershipToken;
547
+ const retryToken = this.state.retryToken;
548
+ if (!this.#isGenerationCurrent(membershipToken, retryToken)) {
549
+ return;
550
+ }
551
+ if (this.#primaryAttempt?.errorAttemptToken === errorAttemptToken) {
552
+ return;
553
+ }
554
+ this.#invalidatePrimaryAttempt();
555
+ const lease = this.#boundaryLease;
556
+ const outletLease = this.props.outletLease;
557
+ if (lease === undefined || outletLease === undefined) {
558
+ return;
559
+ }
560
+ const attempt = this.#createPrimaryAttempt(errorAttemptToken, lease);
561
+ this.#primaryAttempt = attempt;
562
+ if (!this.props.scope.claimDiagnosticAttempt(errorAttemptToken)) {
563
+ attempt.authoritative = false;
564
+ return;
565
+ }
566
+ attempt.published = true;
567
+ const seed = this.props.membership.seed;
568
+ const decision = outletErrorPipeline.runOutletPrimaryErrorPipeline({
569
+ boundaryId: lease.id,
570
+ code,
571
+ configuration: this.props.input.configuration,
572
+ context: seed.renderState.context,
573
+ contribution: seed.renderState.contribution,
574
+ cause,
575
+ hasFallback: this.props.input.renderContributionError !== undefined,
576
+ isolateErrors: this.props.input.isolateErrors,
577
+ isCurrent: () => this.#isPrimaryAttemptCurrent(attempt),
578
+ onError: this.props.input.onError,
579
+ outletId: outletLease.id,
580
+ phase,
581
+ point: seed.renderState.point,
582
+ ...(reactComponentStack === undefined ? {} : { reactComponentStack }),
583
+ registrationId: seed.registrationId,
584
+ retry: attempt.retry,
585
+ retryGeneration: this.state.retryGeneration,
586
+ });
587
+ if (decision.kind === "stale" || !this.#isPrimaryAttemptCurrent(attempt)) {
588
+ return;
589
+ }
590
+ if (decision.kind === "hide") {
591
+ this.setState({ mode: "hidden", primaryError: decision.error, retry: attempt.retry });
592
+ return;
593
+ }
594
+ if (decision.kind === "renderFallback") {
595
+ this.setState({
596
+ mode: "fallback",
597
+ primaryError: decision.error,
598
+ retry: attempt.retry,
599
+ });
600
+ return;
601
+ }
602
+ this.setState({
603
+ escalationCause: decision.cause,
604
+ mode: "escalating",
605
+ primaryError: decision.error,
606
+ retry: attempt.retry,
607
+ });
608
+ }
609
+ /** Sync accepted retry invaliduje starý attempt a naplánuje novou subtree generation. */
610
+ #acceptRetry(attempt) {
611
+ if (!this.#isPrimaryAttemptCurrent(attempt)) {
612
+ return;
613
+ }
614
+ attempt.authoritative = false;
615
+ this.#primaryAttempt = undefined;
616
+ const dispatchAbort = this.#invalidateLazyOperation();
617
+ dispatchAbort();
618
+ this.setState((state) => ({
619
+ capturedCause: undefined,
620
+ escalationCause: undefined,
621
+ errorAttemptToken: undefined,
622
+ hasCapturedCause: false,
623
+ lazyComponent: undefined,
624
+ lazyStatus: state.lazyLoad === undefined ? "inactive" : "loading",
625
+ mode: "rendering",
626
+ primaryError: undefined,
627
+ retry: undefined,
628
+ retryGeneration: state.retryGeneration + 1,
629
+ retryToken: createRetryGenerationToken(),
630
+ }));
631
+ }
632
+ /** Doručí onRetry až po commitu nové current generation. */
633
+ #reportCommittedRetry() {
634
+ if (this.state.retryGeneration <= this.#reportedRetryGeneration) {
635
+ return;
636
+ }
637
+ this.#reportedRetryGeneration = this.state.retryGeneration;
638
+ const lease = this.#boundaryLease;
639
+ const outletLease = this.props.outletLease;
640
+ const membershipToken = this.state.membershipToken;
641
+ const retryToken = this.state.retryToken;
642
+ if (lease === undefined
643
+ || outletLease === undefined
644
+ || !this.#isGenerationCurrent(membershipToken, retryToken)) {
645
+ return;
646
+ }
647
+ const seed = this.props.membership.seed;
648
+ outletErrorPipeline.dispatchOutletRetryCallback({
649
+ boundaryId: lease.id,
650
+ configuration: this.props.input.configuration,
651
+ context: seed.renderState.context,
652
+ contribution: seed.renderState.contribution,
653
+ isCurrent: () => this.#isGenerationCurrent(membershipToken, retryToken),
654
+ onRetry: this.props.input.onRetry,
655
+ outletId: outletLease.id,
656
+ point: seed.renderState.point,
657
+ registrationId: seed.registrationId,
658
+ retryGeneration: this.state.retryGeneration,
659
+ });
660
+ }
661
+ /** Odliší default render od custom ready/loading rendereru. */
662
+ #readRenderFailurePhase() {
663
+ if (this.props.membership.seed.kind === "loading"
664
+ && this.state.lazyStatus !== "ready") {
665
+ return this.props.input.renderLoading === undefined ? "render" : "customRender";
666
+ }
667
+ return this.props.input.renderContribution === undefined ? "render" : "customRender";
668
+ }
669
+ /** Renderuje current fallback pod sink-only reporter boundary. */
670
+ #renderFallback() {
671
+ const renderContributionError = this.props.input.renderContributionError;
672
+ const error = this.state.primaryError;
673
+ const retry = this.state.retry;
674
+ const lease = this.#boundaryLease;
675
+ const outletLease = this.props.outletLease;
676
+ if (renderContributionError === undefined
677
+ || error === undefined
678
+ || retry === undefined
679
+ || lease === undefined
680
+ || outletLease === undefined) {
681
+ return null;
682
+ }
683
+ const seed = this.props.membership.seed;
684
+ const membershipToken = this.state.membershipToken;
685
+ const retryToken = this.state.retryToken;
686
+ const reporterInput = {
687
+ boundaryId: lease.id,
688
+ configuration: this.props.input.configuration,
689
+ context: seed.renderState.context,
690
+ contribution: seed.renderState.contribution,
691
+ isCurrent: () => this.#isGenerationCurrent(membershipToken, retryToken),
692
+ outletId: outletLease.id,
693
+ point: seed.renderState.point,
694
+ registrationId: seed.registrationId,
695
+ retryGeneration: this.state.retryGeneration,
696
+ };
697
+ const children = react.createElement(OutletContributionFallbackRenderer, {
698
+ error,
699
+ renderContributionError,
700
+ retry,
701
+ seed,
702
+ });
703
+ return react.createElement(outletReporterBoundary.OutletReporterBoundary, {
704
+ children,
705
+ errorInput: reporterInput,
706
+ generationToken: retryToken,
707
+ });
708
+ }
709
+ }
710
+ //# sourceMappingURL=outlet-membership-boundary.js.map