(unit: ViewCompilationUnit, deferBlock: t.DeferredBlock)
| 650 | } |
| 651 | |
| 652 | function ingestDeferBlock(unit: ViewCompilationUnit, deferBlock: t.DeferredBlock): void { |
| 653 | let ownResolverFn: o.Expression | null = null; |
| 654 | |
| 655 | if (unit.job.deferMeta.mode === DeferBlockDepsEmitMode.PerBlock) { |
| 656 | if (!unit.job.deferMeta.blocks.has(deferBlock)) { |
| 657 | throw new Error( |
| 658 | `AssertionError: unable to find a dependency function for this deferred block`, |
| 659 | ); |
| 660 | } |
| 661 | ownResolverFn = unit.job.deferMeta.blocks.get(deferBlock) ?? null; |
| 662 | } |
| 663 | |
| 664 | // Generate the defer main view and all secondary views. |
| 665 | const main = ingestDeferView( |
| 666 | unit, |
| 667 | '', |
| 668 | deferBlock.i18n, |
| 669 | deferBlock.children, |
| 670 | deferBlock.sourceSpan, |
| 671 | )!; |
| 672 | const loading = ingestDeferView( |
| 673 | unit, |
| 674 | 'Loading', |
| 675 | deferBlock.loading?.i18n, |
| 676 | deferBlock.loading?.children, |
| 677 | deferBlock.loading?.sourceSpan, |
| 678 | ); |
| 679 | const placeholder = ingestDeferView( |
| 680 | unit, |
| 681 | 'Placeholder', |
| 682 | deferBlock.placeholder?.i18n, |
| 683 | deferBlock.placeholder?.children, |
| 684 | deferBlock.placeholder?.sourceSpan, |
| 685 | ); |
| 686 | const error = ingestDeferView( |
| 687 | unit, |
| 688 | 'Error', |
| 689 | deferBlock.error?.i18n, |
| 690 | deferBlock.error?.children, |
| 691 | deferBlock.error?.sourceSpan, |
| 692 | ); |
| 693 | |
| 694 | // Create the main defer op, and ops for all secondary views. |
| 695 | const deferXref = unit.job.allocateXrefId(); |
| 696 | const deferOp = ir.createDeferOp( |
| 697 | deferXref, |
| 698 | main.xref, |
| 699 | main.handle, |
| 700 | ownResolverFn, |
| 701 | unit.job.allDeferrableDepsFn, |
| 702 | deferBlock.sourceSpan, |
| 703 | ); |
| 704 | deferOp.placeholderView = placeholder?.xref ?? null; |
| 705 | deferOp.placeholderSlot = placeholder?.handle ?? null; |
| 706 | deferOp.loadingSlot = loading?.handle ?? null; |
| 707 | deferOp.errorSlot = error?.handle ?? null; |
| 708 | deferOp.placeholderMinimumTime = deferBlock.placeholder?.minimumTime ?? null; |
| 709 | deferOp.loadingMinimumTime = deferBlock.loading?.minimumTime ?? null; |
no test coverage detected