| 64 | ], |
| 65 | }) |
| 66 | export class CodeEditor { |
| 67 | readonly restrictedMode = input(false); |
| 68 | readonly codeEditorWrapperRef = |
| 69 | viewChild.required<ElementRef<HTMLDivElement>>('codeEditorWrapper'); |
| 70 | readonly matTabGroup = viewChild.required(MatTabGroup); |
| 71 | |
| 72 | readonly createFileInputRef = viewChild<ElementRef<HTMLInputElement>>('createFileInput'); |
| 73 | |
| 74 | readonly renameFileInputRef = viewChild<ElementRef<HTMLInputElement>>('renameFileInput'); |
| 75 | |
| 76 | private readonly destroyRef = inject(DestroyRef); |
| 77 | |
| 78 | private readonly nodeRuntimeState = inject(NodeRuntimeState); |
| 79 | private readonly nodeRuntimeSandbox = inject(NodeRuntimeSandbox, { |
| 80 | optional: true, |
| 81 | }); |
| 82 | private readonly previewUrl = toSignal(this.nodeRuntimeSandbox?.previewUrl$ ?? EMPTY, { |
| 83 | initialValue: null, |
| 84 | }); |
| 85 | private readonly trustedPreviewOrigin = computed(() => { |
| 86 | const url = this.previewUrl(); |
| 87 | return url ? new URL(url).origin : null; |
| 88 | }); |
| 89 | private readonly codeMirrorEditor = inject(CodeMirrorEditor); |
| 90 | private readonly diagnosticsState = inject(DiagnosticsState); |
| 91 | private readonly downloadManager = inject(DownloadManager); |
| 92 | private readonly stackblitzOpener = inject(StackBlitzOpener); |
| 93 | private readonly title = inject(Title); |
| 94 | private readonly location = inject(Location); |
| 95 | private readonly environmentInjector = inject(EnvironmentInjector); |
| 96 | |
| 97 | readonly TerminalType = TerminalType; |
| 98 | |
| 99 | protected readonly errors = computed(() => |
| 100 | this.nodeRuntimeState.loadingStep() !== LoadingStep.READY |
| 101 | ? [] |
| 102 | : this.diagnosticsState |
| 103 | .diagnostics() |
| 104 | .filter((item) => item.severity === 'error') |
| 105 | .sort((a, b) => |
| 106 | a.lineNumber != b.lineNumber |
| 107 | ? a.lineNumber - b.lineNumber |
| 108 | : a.characterPosition - b.characterPosition, |
| 109 | ), |
| 110 | ); |
| 111 | |
| 112 | protected readonly displayErrorsBox = linkedSignal(() => this.errors().length > 0); |
| 113 | protected readonly files = this.codeMirrorEditor.openFiles; |
| 114 | protected readonly isCreatingFile = signal<boolean>(false); |
| 115 | protected readonly isRenamingFile = signal<boolean>(false); |
| 116 | |
| 117 | constructor() { |
| 118 | afterRenderEffect(() => { |
| 119 | const createFileInput = this.createFileInputRef(); |
| 120 | createFileInput?.nativeElement.focus(); |
| 121 | }); |
| 122 | |
| 123 | afterRenderEffect(() => { |
nothing calls this directly
no test coverage detected