/
githubmirror
/
angular
Обзор
Документация
Войти
/
githubmirror
/
angular
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
adev/src/app/editor/preview/preview.component.ts
48 строк
2 KB
Kam
feat(docs-infra): add Angie to the embedded editor loading steps
09 июл 2026, 22:00
09 июл 2026, 22:00
c92d995
Код
Авторство
О чём код?
/*! * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import {Component, computed, inject} from '@angular/core'; import {toSignal} from '@angular/core/rxjs-interop'; import {DomSanitizer} from '@angular/platform-browser'; import {LoadingStep} from '../enums/loading-steps'; import {NodeRuntimeSandbox} from '../node-runtime-sandbox.service'; import {NodeRuntimeState} from '../node-runtime-state.service'; import {PreviewError} from './preview-error.component'; const ANGIE_DIR = 'assets/images/angie'; const BOOT_POSES: Partial<Record<LoadingStep, string>> = { [LoadingStep.INSTALL]: 'coding-01', [LoadingStep.START_DEV_SERVER]: 'superhero', }; @Component({ selector: 'docs-tutorial-preview', templateUrl: './preview.component.html', styleUrls: ['./preview.component.scss'], imports: [PreviewError], }) export class Preview { private readonly domSanitizer = inject(DomSanitizer); private readonly nodeRuntimeSandbox = inject(NodeRuntimeSandbox); private readonly nodeRuntimeState = inject(NodeRuntimeState); loadingProgressValue = this.nodeRuntimeState.loadingStep; protected loadingEnum = LoadingStep; readonly previewUrl = toSignal(this.nodeRuntimeSandbox.previewUrl$, {initialValue: null}); protected readonly previewUrlForIFrame = computed(() => { const url = this.previewUrl(); return url !== null ? this.domSanitizer.bypassSecurityTrustResourceUrl(url) : null; }); protected readonly bootPoseSrc = computed(() => { const pose = BOOT_POSES[this.loadingProgressValue() as LoadingStep] ?? 'greeting'; return `${ANGIE_DIR}/${pose}.svg`; }); }