| 50 | providers: [EditorUiState], |
| 51 | }) |
| 52 | export class EmbeddedEditor { |
| 53 | // Prevents from adding, removing or renaming files |
| 54 | readonly restrictedMode = input<boolean>(false); |
| 55 | |
| 56 | readonly editorContainer = viewChild<ElementRef<HTMLDivElement>>('editorContainer'); |
| 57 | readonly matTabGroup = viewChild(MatTabGroup); |
| 58 | |
| 59 | private readonly platformId = inject(PLATFORM_ID); |
| 60 | private readonly destroyRef = inject(DestroyRef); |
| 61 | |
| 62 | private readonly diagnosticsState = inject(DiagnosticsState); |
| 63 | readonly editorUiState = inject(EditorUiState); |
| 64 | private readonly nodeRuntimeState = inject(NodeRuntimeState); |
| 65 | private readonly nodeRuntimeSandbox = inject(NodeRuntimeSandbox); |
| 66 | |
| 67 | protected readonly splitDirection = signal<'horizontal' | 'vertical'>('vertical'); |
| 68 | |
| 69 | readonly MAX_RECOMMENDED_WEBCONTAINERS_INSTANCES = MAX_RECOMMENDED_WEBCONTAINERS_INSTANCES; |
| 70 | |
| 71 | protected readonly TerminalType = TerminalType; |
| 72 | protected readonly displayOnlyTerminal = computed( |
| 73 | () => this.editorUiState.tutorialType() === TutorialType.CLI, |
| 74 | ); |
| 75 | protected readonly displayPreviewInMatTabGroup = signal<boolean>(true); |
| 76 | protected readonly selectedTabIndex = linkedSignal({ |
| 77 | source: () => this.displayPreviewInMatTabGroup(), |
| 78 | computation: () => 0, |
| 79 | }); |
| 80 | |
| 81 | protected readonly shouldEnableReset = computed( |
| 82 | () => |
| 83 | this.nodeRuntimeState.loadingStep() > LoadingStep.BOOT && |
| 84 | !this.nodeRuntimeState.isResetting(), |
| 85 | ); |
| 86 | |
| 87 | private readonly errorsCount$ = this.diagnosticsState.diagnostics$.pipe( |
| 88 | map((diagnosticsItem) => diagnosticsItem.filter((item) => item.severity === 'error').length), |
| 89 | ); |
| 90 | protected readonly errorsCount = toSignal(this.errorsCount$, {initialValue: 0}); |
| 91 | |
| 92 | constructor() { |
| 93 | if (!isPlatformBrowser(this.platformId)) { |
| 94 | return; |
| 95 | } |
| 96 | |
| 97 | const ref = afterRenderEffect({ |
| 98 | read: () => { |
| 99 | const container = this.editorContainer()?.nativeElement; |
| 100 | if (!container) { |
| 101 | return; |
| 102 | } |
| 103 | this.setResizeObserver(container); |
| 104 | ref.destroy(); |
| 105 | }, |
| 106 | }); |
| 107 | } |
| 108 | |
| 109 | protected async reset(): Promise<void> { |
nothing calls this directly
no test coverage detected
searching dependent graphs…