@@ -22,15 +22,6 @@ const getHeading = name => ({ data: { depth: 1, name } });
2222const remarkRehypeProcessor = getRemarkRehypeWithShiki ( ) ;
2323
2424/**
25- * @typedef {{
26- * api: string;
27- * added: string;
28- * section: string;
29- * version: string;
30- * toc: string;
31- * nav: string;
32- * content: string;
33- * }} TemplateValues
3425 *
3526 * This generator generates the legacy HTML pages of the legacy API docs
3627 * for retro-compatibility and while we are implementing the new 'react' and 'html' generators.
@@ -39,8 +30,9 @@ const remarkRehypeProcessor = getRemarkRehypeWithShiki();
3930 * and generates the HTML files to the specified output directory from the configuration settings
4031 *
4132 * @typedef {Array<ApiDocMetadataEntry> } Input
33+ * @typedef {Array<import('./types').TemplateValues> } Output
4234 *
43- * @type {GeneratorMetadata<Input, Array<TemplateValues> > }
35+ * @type {GeneratorMetadata<Input, Output > }
4436 */
4537export default {
4638 name : 'legacy-html' ,
@@ -59,10 +51,10 @@ export default {
5951 * Each item is pre-grouped {head, nodes, headNodes} - no need to
6052 * recompute groupNodesByModule for every chunk.
6153 *
62- * @param {Array<{head: ApiDocMetadataEntry, nodes: ApiDocMetadataEntry[] , headNodes: ApiDocMetadataEntry[]}> } slicedInput - Pre-sliced module data
54+ * @param {Array<{ head: ApiDocMetadataEntry, nodes: Array< ApiDocMetadataEntry> , headNodes: Array< ApiDocMetadataEntry> }> } slicedInput - Pre-sliced module data
6355 * @param {number[] } itemIndices - Indices into the sliced array
64- * @param {{version: SemVer, parsedSideNav: string} } deps - Dependencies passed from generate()
65- * @returns {Promise<TemplateValues[] > } Template objects for each processed module
56+ * @param {{ version: SemVer, parsedSideNav: string } } deps - Dependencies passed from generate()
57+ * @returns {Promise<Output > } Template objects for each processed module
6658 */
6759 async processChunk ( slicedInput , itemIndices , { version, parsedSideNav } ) {
6860 const results = [ ] ;
@@ -110,7 +102,7 @@ export default {
110102 * Generates the legacy version of the API docs in HTML
111103 * @param {Input } input
112104 * @param {Partial<GeneratorOptions> } options
113- * @returns {AsyncGenerator<Array<TemplateValues> > }
105+ * @returns {AsyncGenerator<Output > }
114106 */
115107 async * generate ( input , { index, releases, version, output, worker } ) {
116108 const baseDir = import . meta. dirname ;
@@ -134,19 +126,6 @@ export default {
134126 } )
135127 ) ;
136128
137- // Create sliced input: each item contains head + its module's entries + headNodes reference
138- // This avoids sending all ~4900 entries to every worker and recomputing groupings
139- const slicedInput = headNodes . map ( head => ( {
140- head,
141- nodes : groupedModules . get ( head . api ) ,
142- headNodes,
143- } ) ) ;
144-
145- const deps = {
146- version,
147- parsedSideNav : String ( parsedSideNav ) ,
148- } ;
149-
150129 if ( output ) {
151130 // Define the source folder for API docs assets
152131 const srcAssets = join ( baseDir , 'assets' ) ;
@@ -161,12 +140,18 @@ export default {
161140 await safeCopy ( srcAssets , assetsFolder ) ;
162141 }
163142
143+ // Create sliced input: each item contains head + its module's entries + headNodes reference
144+ // This avoids sending all ~4900 entries to every worker and recomputing groupings
145+ const entries = headNodes . map ( head => ( {
146+ head,
147+ nodes : groupedModules . get ( head . api ) ,
148+ headNodes,
149+ } ) ) ;
150+
151+ const deps = { version, parsedSideNav : String ( parsedSideNav ) } ;
152+
164153 // Stream chunks as they complete - HTML files are written immediately
165- for await ( const chunkResult of worker . stream (
166- slicedInput ,
167- slicedInput ,
168- deps
169- ) ) {
154+ for await ( const chunkResult of worker . stream ( entries , entries , deps ) ) {
170155 // Write files for this chunk in the generate method (main thread)
171156 if ( output ) {
172157 for ( const template of chunkResult ) {
0 commit comments