(unit: ViewCompilationUnit, deferBlock: t.DeferredBlock)
| 766 | } |
| 767 | |
| 768 | function ingestDeferBlock(unit: ViewCompilationUnit, deferBlock: t.DeferredBlock): void { |
| 769 | let ownResolverFn: o.Expression | null = null; |
| 770 | |
| 771 | if (unit.job.deferMeta.mode === DeferBlockDepsEmitMode.PerBlock) { |
| 772 | if (!unit.job.deferMeta.blocks.has(deferBlock)) { |
| 773 | throw new Error( |
| 774 | `AssertionError: unable to find a dependency function for this deferred block`, |
| 775 | ); |
| 776 | } |
| 777 | ownResolverFn = unit.job.deferMeta.blocks.get(deferBlock) ?? null; |
| 778 | } |
| 779 | |
| 780 | // Generate the defer main view and all secondary views. |
| 781 | const main = ingestDeferView( |
| 782 | unit, |
| 783 | '', |
| 784 | deferBlock.i18n, |
| 785 | deferBlock.children, |
| 786 | deferBlock.sourceSpan, |
| 787 | )!; |
| 788 | const loading = ingestDeferView( |
| 789 | unit, |
| 790 | 'Loading', |
| 791 | deferBlock.loading?.i18n, |
| 792 | deferBlock.loading?.children, |
| 793 | deferBlock.loading?.sourceSpan, |
| 794 | ); |
| 795 | const placeholder = ingestDeferView( |
| 796 | unit, |
| 797 | 'Placeholder', |
| 798 | deferBlock.placeholder?.i18n, |
| 799 | deferBlock.placeholder?.children, |
| 800 | deferBlock.placeholder?.sourceSpan, |
| 801 | ); |
| 802 | const error = ingestDeferView( |
| 803 | unit, |
| 804 | 'Error', |
| 805 | deferBlock.error?.i18n, |
| 806 | deferBlock.error?.children, |
| 807 | deferBlock.error?.sourceSpan, |
| 808 | ); |
| 809 | |
| 810 | // Create the main defer op, and ops for all secondary views. |
| 811 | const deferXref = unit.job.allocateXrefId(); |
| 812 | const deferOp = ir.createDeferOp( |
| 813 | deferXref, |
| 814 | main.xref, |
| 815 | main.handle, |
| 816 | ownResolverFn, |
| 817 | unit.job.allDeferrableDepsFn, |
| 818 | deferBlock.sourceSpan, |
| 819 | ); |
| 820 | deferOp.placeholderView = placeholder?.xref ?? null; |
| 821 | deferOp.placeholderSlot = placeholder?.handle ?? null; |
| 822 | deferOp.loadingSlot = loading?.handle ?? null; |
| 823 | deferOp.errorSlot = error?.handle ?? null; |
| 824 | deferOp.placeholderMinimumTime = deferBlock.placeholder?.minimumTime ?? null; |
| 825 | deferOp.loadingMinimumTime = deferBlock.loading?.minimumTime ?? null; |
no test coverage detected