(s: ContentNamingState, opts: UnitOptions)
| 774 | } |
| 775 | |
| 776 | const unitsOf = (s: ContentNamingState, opts: UnitOptions): RootUnit[] => { |
| 777 | const units: RootUnit[] = [] |
| 778 | const unitsById: Record<NodeId, RootUnit> = {} |
| 779 | // a component is completed after every component it calls |
| 780 | for (const component of s.components) { |
| 781 | let written = s.written.units.get(component[0]) |
| 782 | if (!written || !readsMatch(written, component, s)) { |
| 783 | written = writeComponent(component, s, opts) |
| 784 | if (!written) continue |
| 785 | s.written.units.set(component[0], written) |
| 786 | } |
| 787 | const unit: RootUnit = { |
| 788 | name: written.name, |
| 789 | names: s.names, |
| 790 | roots: written.roots, |
| 791 | traversals: written.declaredTraversals.slice(0, written.roots.length), |
| 792 | declared: written.declared, |
| 793 | declaredTraversals: written.declaredTraversals, |
| 794 | members: written.members, |
| 795 | refs: written.refs, |
| 796 | dependencies: written.dependencies, |
| 797 | identityNamed: s.identityNamed, |
| 798 | unitsById |
| 799 | } |
| 800 | units.push(unit) |
| 801 | for (const root of written.roots) unitsById[root.id] = unit |
| 802 | } |
| 803 | return units |
| 804 | } |
| 805 | |
| 806 | // shared by a later pass reaching the component with the same names and nodes by id |
| 807 | interface WrittenUnit { |
no test coverage detected