66use Automattic \BlocksEngine \PhpTransformer \AssetAnalysis \CssUrlRewriter ;
77use Automattic \BlocksEngine \PhpTransformer \AssetAnalysis \ReferenceAnalyzer ;
88use Automattic \BlocksEngine \PhpTransformer \Contract \ConversionReportProjection ;
9+ use Automattic \BlocksEngine \PhpTransformer \Contract \CoreHtmlFallbackEvidence ;
910use Automattic \BlocksEngine \PhpTransformer \Contract \TransformerResult ;
1011use Automattic \BlocksEngine \PhpTransformer \FormatBridge \FormatBridge ;
1112use Automattic \BlocksEngine \PhpTransformer \HtmlToBlocks \HtmlTransformer ;
@@ -172,12 +173,14 @@ public function compile(array $artifact): TransformerResult
172173 $ allFallbacks = $ entryBlocks ['fallbacks ' ];
173174 $ allGeneratedBlocks = $ entryBlocks ['generated_blocks ' ];
174175 $ allGutenbergGaps = $ entryBlocks ['gutenberg_gaps ' ];
176+ $ coreHtmlFallbackEvidence = array ($ entryBlocks ['core_html_fallback_evidence ' ]);
175177 foreach ( $ compiledHtmlDocuments as $ sourcePath => $ compiledHtmlDocument ) {
176178 $ authorStylesheetProjections = array_merge ($ authorStylesheetProjections , $ compiledHtmlDocument ['author_stylesheet_projections ' ] ?? array ());
177179 $ allDiagnostics = array_merge ($ allDiagnostics , $ this ->entryTransformDiagnostics ($ compiledHtmlDocument ['diagnostics ' ] ?? array (), (string ) $ sourcePath ));
178180 $ allFallbacks = array_merge ($ allFallbacks , $ compiledHtmlDocument ['fallbacks ' ] ?? array ());
179181 $ allGeneratedBlocks = array_merge ($ allGeneratedBlocks , $ compiledHtmlDocument ['generated_blocks ' ] ?? array ());
180182 $ allGutenbergGaps = array_merge ($ allGutenbergGaps , $ compiledHtmlDocument ['gutenberg_gaps ' ] ?? array ());
183+ $ coreHtmlFallbackEvidence [] = $ compiledHtmlDocument ['core_html_fallback_evidence ' ] ?? array ();
181184 }
182185 $ allGutenbergGaps = $ this ->dedupeRows ($ allGutenbergGaps );
183186 $ normalized ['runtime_declarations ' ] = $ this ->runtimeDeclarationsFromFallbacks ($ normalized ['runtime_declarations ' ], $ allFallbacks , $ entryPath , $ normalized ['files ' ]);
@@ -207,6 +210,7 @@ public function compile(array $artifact): TransformerResult
207210 $ serializedBlocks = (string ) $ documents ['documents ' ][0 ]['block_markup ' ];
208211 }
209212 $ sourceReports = array (
213+ 'core_html_fallback_evidence ' => CoreHtmlFallbackEvidence::merge ($ coreHtmlFallbackEvidence ),
210214 'artifact ' => array (
211215 'schema ' => self ::INPUT_SCHEMA ,
212216 'original_schema ' => is_string ($ artifact ['schema ' ] ?? null ) ? $ artifact ['schema ' ] : '' ,
@@ -676,7 +680,7 @@ public function compileFragment(string $content, string $source = 'fragment', st
676680
677681 /**
678682 * @param array<int, array<string, mixed>> $files
679- * @return array{blocks: array<int, array<string, mixed>>, serialized_blocks: string, diagnostics: array<int, array<string, mixed>>, fallbacks: array<int, array<string, mixed>>, assets: array<int, array<string, mixed>>, runtime_islands: array<int, array<string, mixed>>, generated_blocks: array<int, array<string, mixed>>, gutenberg_gaps: array<int, array<string, mixed>>, interaction_candidates: array<int, array<string, mixed>>, superseded_selectors: array<int, string>, author_stylesheet_projections: array<int, array<string, mixed>>, shell_artifacts: array<int, array<string, mixed>>}
683+ * @return array{blocks: array<int, array<string, mixed>>, serialized_blocks: string, diagnostics: array<int, array<string, mixed>>, fallbacks: array<int, array<string, mixed>>, assets: array<int, array<string, mixed>>, runtime_islands: array<int, array<string, mixed>>, generated_blocks: array<int, array<string, mixed>>, gutenberg_gaps: array<int, array<string, mixed>>, interaction_candidates: array<int, array<string, mixed>>, superseded_selectors: array<int, string>, author_stylesheet_projections: array<int, array<string, mixed>>, shell_artifacts: array<int, array<string, mixed>>, core_html_fallback_evidence: array<string, mixed> }
680684 */
681685 private function compileEntryBlocks (string $ html , string $ entryPath , array $ files , string $ generatedBlockNamespace = '' ): array
682686 {
@@ -695,12 +699,13 @@ private function compileEntryBlocks(string $html, string $entryPath, array $file
695699 'superseded_selectors ' => $ result ['superseded_selectors ' ],
696700 'author_stylesheet_projections ' => $ result ['author_stylesheet_projections ' ],
697701 'shell_artifacts ' => $ result ['shell_artifacts ' ],
702+ 'core_html_fallback_evidence ' => $ result ['core_html_fallback_evidence ' ],
698703 );
699704 }
700705
701706 /**
702707 * @param array<int, array<string, mixed>> $files
703- * @return array{blocks: array<int, array<string, mixed>>, serialized_blocks: string, diagnostics: array<int, array<string, mixed>>, fallbacks: array<int, array<string, mixed>>, assets: array<int, array<string, mixed>>, runtime_islands: array<int, array<string, mixed>>, generated_blocks: array<int, array<string, mixed>>, gutenberg_gaps: array<int, array<string, mixed>>, interaction_candidates: array<int, array<string, mixed>>, superseded_selectors: array<int, string>, author_stylesheet_projections: array<int, array<string, mixed>>, shell_artifacts: array<int, array<string, mixed>>}
708+ * @return array{blocks: array<int, array<string, mixed>>, serialized_blocks: string, diagnostics: array<int, array<string, mixed>>, fallbacks: array<int, array<string, mixed>>, assets: array<int, array<string, mixed>>, runtime_islands: array<int, array<string, mixed>>, generated_blocks: array<int, array<string, mixed>>, gutenberg_gaps: array<int, array<string, mixed>>, interaction_candidates: array<int, array<string, mixed>>, superseded_selectors: array<int, string>, author_stylesheet_projections: array<int, array<string, mixed>>, shell_artifacts: array<int, array<string, mixed>>, core_html_fallback_evidence: array<string, mixed> }
704709 */
705710 private function compileHtmlDocumentBlocks (string $ html , string $ sourcePath , array $ files , string $ sourceScope , string $ generatedBlockNamespace = '' , bool $ extractGlobalShell = false ): array
706711 {
@@ -718,6 +723,7 @@ private function compileHtmlDocumentBlocks(string $html, string $sourcePath, arr
718723 'superseded_selectors ' => array (),
719724 'author_stylesheet_projections ' => array (),
720725 'shell_artifacts ' => array (),
726+ 'core_html_fallback_evidence ' => CoreHtmlFallbackEvidence::fromBlocks (array (), array (), array ()),
721727 );
722728 }
723729
@@ -735,6 +741,7 @@ private function compileHtmlDocumentBlocks(string $html, string $sourcePath, arr
735741 'superseded_selectors ' => array (),
736742 'author_stylesheet_projections ' => array (),
737743 'shell_artifacts ' => array (),
744+ 'core_html_fallback_evidence ' => CoreHtmlFallbackEvidence::fromBlocks (array (), array (), array ()),
738745 );
739746 }
740747
@@ -758,6 +765,7 @@ private function compileHtmlDocumentBlocks(string $html, string $sourcePath, arr
758765 'serialized_blocks ' => (string ) ($ result ['serialized_blocks ' ] ?? '' ),
759766 'diagnostics ' => is_array ($ result ['diagnostics ' ] ?? null ) ? $ result ['diagnostics ' ] : array (),
760767 'fallbacks ' => is_array ($ result ['fallbacks ' ] ?? null ) ? $ result ['fallbacks ' ] : array (),
768+ 'core_html_fallback_evidence ' => is_array ($ result ['source_reports ' ]['html ' ]['core_html_fallback_evidence ' ] ?? null ) ? $ result ['source_reports ' ]['html ' ]['core_html_fallback_evidence ' ] : CoreHtmlFallbackEvidence::fromBlocks (array (), array (), array ()),
761769 'assets ' => is_array ($ result ['assets ' ] ?? null ) ? $ result ['assets ' ] : array (),
762770 'runtime_islands ' => $ this ->runtimeIslandsWithMaterializedInlineScripts (
763771 is_array ($ result ['source_reports ' ]['runtime_islands ' ] ?? null ) ? $ result ['source_reports ' ]['runtime_islands ' ] : array (),
0 commit comments