/
spirzen
/
it-knowledge-base
Обзор
Документация
Войти
/
spirzen
/
it-knowledge-base
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
Mobile
src/components/shared/firstProgramEngine.js
889 строк
27 KB
Spirzen
Кавычки 2
26 май 2026, 23:25
26 май 2026, 23:25
7d44b4c
Код
Авторство
О чём код?
/** Конфигурации "первая программа" по языкам и фреймворкам. */ export const WORKFLOW_STEPS = [ {id: 'setup', label: 'Среда', icon: '⚙️'}, {id: 'project', label: 'Проект', icon: '📁'}, {id: 'code', label: 'Код', icon: '📝'}, {id: 'build', label: 'Сборка', icon: '🔨'}, {id: 'run', label: 'Запуск', icon: '▶️'}, ]; const DEFAULT_MSG = 'Hello, World!'; function tpl(lines, msg = DEFAULT_MSG) { return lines.map((l) => l.replace(/\{\{MSG\}\}/g, msg)).join('\n'); } /** @type {Record<string, object>} */ export const LANG_CONFIGS = { python: { label: 'Python', toolchain: 'CPython 3.x', mode: 'interpret', mainFile: 'hello.py', tree: ['hello.py'], template: ['print("{{MSG}}")'], runCmd: 'python hello.py', setupLogs: ['$ python --version', 'Python 3.13.0'], projectLogs: ['$ mkdir my-first-python && cd my-first-python', '$ touch hello.py'], buildLogs: null, runLogs: (msg) => [`$ python hello.py`, msg], }, java: { label: 'Java', toolchain: 'JDK + Maven', mode: 'compile', mainFile: 'src/main/java/com/test/Main.java', tree: ['pom.xml', 'src/main/java/com/test/Main.java'], template: [ 'package com.test;', '', 'public class Main {', ' public static void main(String[] args) {', ' System.out.println("{{MSG}}");', ' }', '}', ], runCmd: 'mvn compile exec:java', setupLogs: ['$ java -version', 'openjdk 21.0.1'], projectLogs: ['$ mvn archetype:generate -DartifactId=hello-java', 'Created Maven project'], buildLogs: ['$ mvn compile', '[INFO] BUILD SUCCESS'], runLogs: (msg) => ['$ mvn -q exec:java -Dexec.mainClass=com.test.Main', msg], }, csharp: { label: 'C#', toolchain: '.NET SDK', mode: 'compile', mainFile: 'Program.cs', tree: ['HelloWorld.sln', 'Program.cs'], template: [ 'using System;', '', 'Console.WriteLine("{{MSG}}");', ], runCmd: 'dotnet run', setupLogs: ['$ dotnet --version', '8.0.100'], projectLogs: ['$ dotnet new console -n HelloWorld', 'Шаблон создан'], buildLogs: ['$ dotnet build', 'Сборка успешно завершена.'], runLogs: (msg) => ['$ dotnet run', msg], }, cpp: { label: 'C++', toolchain: 'g++ / MSVC', mode: 'compile', mainFile: 'main.cpp', tree: ['main.cpp'], template: [ '#include <iostream>', '', 'int main() {', ' std::cout << "{{MSG}}" << std::endl;', ' return 0;', '}', ], runCmd: './main', setupLogs: ['$ g++ --version', 'g++ 13.2.0'], projectLogs: ['$ mkdir first-cpp && cd first-cpp'], buildLogs: ['$ g++ -std=c++17 -o main main.cpp', 'Компиляция без ошибок'], runLogs: (msg) => ['$ ./main', msg], }, rust: { label: 'Rust', toolchain: 'rustc + cargo', mode: 'compile', mainFile: 'src/main.rs', tree: ['Cargo.toml', 'src/main.rs'], template: [ 'fn main() {', ' println!("{{MSG}}");', '}', ], runCmd: 'cargo run', setupLogs: ['$ rustc --version', 'rustc 1.78.0'], projectLogs: ['$ cargo new hello_rust', 'Создан проект hello_rust'], buildLogs: ['$ cargo build', 'Finished dev [unoptimized] target(s)'], runLogs: (msg) => ['$ cargo run', msg], }, go: { label: 'Go', toolchain: 'go toolchain', mode: 'compile', mainFile: 'main.go', tree: ['go.mod', 'main.go'], template: [ 'package main', '', 'import "fmt"', '', 'func main() {', ' fmt.Println("{{MSG}}")', '}', ], runCmd: 'go run .', setupLogs: ['$ go version', 'go version go1.23.0'], projectLogs: ['$ go mod init hello-go', 'go: created go.mod'], buildLogs: ['$ go build -o hello', 'Сборка завершена'], runLogs: (msg) => ['$ go run .', msg], }, kotlin: { label: 'Kotlin', toolchain: 'Kotlin + Maven', mode: 'compile', mainFile: 'src/main/kotlin/Main.kt', tree: ['pom.xml', 'src/main/kotlin/Main.kt'], template: [ 'fun main() {', ' println("{{MSG}}")', '}', ], runCmd: 'mvn compile exec:java', setupLogs: ['$ kotlin -version', 'Kotlin 2.0.0'], projectLogs: ['IDEA: New Project → Kotlin → HelloKotlin'], buildLogs: ['$ mvn compile', 'BUILD SUCCESS'], runLogs: (msg) => ['$ mvn -q exec:java', msg], }, groovy: { label: 'Groovy', toolchain: 'Groovy + JVM', mode: 'interpret', mainFile: 'hello.groovy', tree: ['hello.groovy'], template: ['println "{{MSG}}"'], runCmd: 'groovy hello.groovy', setupLogs: ['$ groovy --version', 'Groovy Version: 4.0.15'], projectLogs: ['$ touch hello.groovy'], buildLogs: null, runLogs: (msg) => ['$ groovy hello.groovy', msg], }, ruby: { label: 'Ruby', toolchain: 'Ruby MRI', mode: 'interpret', mainFile: 'hello.rb', tree: ['hello.rb'], template: ['puts "{{MSG}}"'], runCmd: 'ruby hello.rb', setupLogs: ['$ ruby --version', 'ruby 3.3.0'], projectLogs: ['$ touch hello.rb'], buildLogs: null, runLogs: (msg) => ['$ ruby hello.rb', msg], }, php: { label: 'PHP', toolchain: 'PHP CLI', mode: 'interpret', mainFile: 'hello.php', tree: ['hello.php'], template: ['<?php', 'echo "{{MSG}}";', '?>'], runCmd: 'php hello.php', setupLogs: ['$ php --version', 'PHP 8.3.0'], projectLogs: ['$ mkdir myfirstphp && cd myfirstphp'], buildLogs: null, runLogs: (msg) => ['$ php hello.php', msg], }, javascript: { label: 'JavaScript', toolchain: 'Браузер (без установки)', mode: 'web', mainFile: 'index.html', tree: ['index.html'], template: [ '<!DOCTYPE html>', '<html lang="ru">', '<body>', ' <h1 id="out"></h1>', ' <script>', ' document.getElementById("out").textContent = "{{MSG}}";', ' </script>', '</body>', '</html>', ], runCmd: 'Открыть index.html в браузере', setupLogs: ['Папка с файлами проекта', 'Достаточно браузера — Node.js для этой программы не нужен'], projectLogs: ['Сохраните index.html', 'Можно открыть двойным щелчком или через Live Server в VS Code'], buildLogs: null, runLogs: (msg) => ['Браузер выполнил скрипт на странице', msg], previewType: 'web', }, haskell: { label: 'Haskell', toolchain: 'GHC', mode: 'compile', mainFile: 'hello.hs', tree: ['hello.hs'], template: [ 'main :: IO ()', 'main = putStrLn "{{MSG}}"', ], runCmd: './hello', setupLogs: ['$ ghc --version', 'GHC 9.6.3'], projectLogs: ['$ touch hello.hs'], buildLogs: ['$ ghc hello.hs', 'Создан hello.exe'], runLogs: (msg) => ['$ ./hello', msg], }, scala: { label: 'Scala', toolchain: 'sbt + Scala', mode: 'compile', mainFile: 'src/main/scala/Main.scala', tree: ['build.sbt', 'src/main/scala/Main.scala'], template: [ 'object Main extends App {', ' println("{{MSG}}")', '}', ], runCmd: 'sbt run', setupLogs: ['$ scala -version', 'Scala 3.4.0'], projectLogs: ['$ sbt new scala/scala3.g8', 'Проект создан'], buildLogs: ['$ sbt compile', '[success] Total time: 4 s'], runLogs: (msg) => ['$ sbt run', msg], }, nim: { label: 'Nim', toolchain: 'nim + nimble', mode: 'compile', mainFile: 'hello.nim', tree: ['hello.nim'], template: ['echo "{{MSG}}"'], runCmd: './hello', setupLogs: ['$ nim --version', 'Nim 2.0.0'], projectLogs: ['$ nim init hello'], buildLogs: ['$ nim c -r hello.nim', 'Компиляция OK'], runLogs: (msg) => [msg], }, zig: { label: 'Zig', toolchain: 'zig build', mode: 'compile', mainFile: 'src/main.zig', tree: ['build.zig', 'src/main.zig'], template: [ 'const std = @import("std");', '', 'pub fn main() !void {', ' try std.io.getStdOut().writer().print("{{MSG}}\\n", .{});', '}', ], runCmd: 'zig build run', setupLogs: ['$ zig version', '0.12.0'], projectLogs: ['$ zig init-exe'], buildLogs: ['$ zig build', 'Build Summary: 1/1 steps succeeded'], runLogs: (msg) => ['$ zig build run', msg], }, dart: { label: 'Dart', toolchain: 'Dart SDK', mode: 'compile', mainFile: 'bin/hello.dart', tree: ['pubspec.yaml', 'bin/hello.dart'], template: [ 'void main() {', ' print("{{MSG}}");', '}', ], runCmd: 'dart run bin/hello.dart', setupLogs: ['$ dart --version', 'Dart 3.4.0'], projectLogs: ['$ dart create hello_dart'], buildLogs: ['$ dart analyze', 'No issues found'], runLogs: (msg) => ['$ dart run bin/hello.dart', msg], }, elixir: { label: 'Elixir', toolchain: 'mix + BEAM', mode: 'interpret', mainFile: 'lib/hello.ex', tree: ['mix.exs', 'lib/hello.ex'], template: [ 'defmodule Hello do', ' def run, do: IO.puts("{{MSG}}")', 'end', ], runCmd: 'mix run -e "Hello.run()"', setupLogs: ['$ elixir --version', 'Elixir 1.16.0'], projectLogs: ['$ mix new hello_elixir'], buildLogs: ['$ mix compile', 'Generated hello_elixir app'], runLogs: (msg) => ['$ mix run -e "Hello.run()"', msg], }, julia: { label: 'Julia', toolchain: 'Julia REPL', mode: 'interpret', mainFile: 'hello.jl', tree: ['hello.jl'], template: ['println("{{MSG}}")'], runCmd: 'julia hello.jl', setupLogs: ['$ julia --version', 'julia 1.10.0'], projectLogs: ['$ touch hello.jl'], buildLogs: null, runLogs: (msg) => ['$ julia hello.jl', msg], }, r: { label: 'R', toolchain: 'Rscript', mode: 'interpret', mainFile: 'hello.R', tree: ['hello.R'], template: ['cat("{{MSG}}\\n")'], runCmd: 'Rscript hello.R', setupLogs: ['$ R --version', 'R 4.4.0'], projectLogs: ['$ touch hello.R'], buildLogs: null, runLogs: (msg) => ['$ Rscript hello.R', msg], }, bash: { label: 'Bash', toolchain: 'GNU Bash', mode: 'script', mainFile: 'hello.sh', tree: ['hello.sh'], template: ['#!/bin/bash', 'echo "{{MSG}}"'], runCmd: 'bash hello.sh', setupLogs: ['$ bash --version', 'GNU bash, version 5.2.0'], projectLogs: ['$ touch hello.sh && chmod +x hello.sh'], buildLogs: null, runLogs: (msg) => ['$ ./hello.sh', msg], }, powershell: { label: 'PowerShell', toolchain: 'pwsh', mode: 'script', mainFile: 'hello.ps1', tree: ['hello.ps1'], template: ['Write-Host "{{MSG}}"'], runCmd: 'pwsh hello.ps1', setupLogs: ['PS> $PSVersionTable.PSVersion', '7.4.0'], projectLogs: ['PS> New-Item hello.ps1'], buildLogs: null, runLogs: (msg) => ['PS> .\\hello.ps1', msg], }, lua: { label: 'Lua', toolchain: 'lua interpreter', mode: 'interpret', mainFile: 'hello.lua', tree: ['hello.lua'], template: ['print("{{MSG}}")'], runCmd: 'lua hello.lua', setupLogs: ['$ lua -v', 'Lua 5.4.6'], projectLogs: ['$ touch hello.lua'], buildLogs: null, runLogs: (msg) => ['$ lua hello.lua', msg], }, smalltalk: { label: 'Smalltalk', toolchain: 'Pharo / Squeak', mode: 'interpret', mainFile: 'Hello.st', tree: ['Hello.st'], template: [ "Transcript show: '{{MSG}}'; cr.", ], runCmd: 'DoIt в образе', setupLogs: ['Запуск Pharo VM', 'Образ загружен'], projectLogs: ['Workspace → новый метод'], buildLogs: null, runLogs: (msg) => ['Transcript', msg], }, swift: { label: 'Swift', toolchain: 'swiftc', mode: 'compile', mainFile: 'main.swift', tree: ['Package.swift', 'Sources/main.swift'], template: ['print("{{MSG}}")'], runCmd: 'swift run', setupLogs: ['$ swift --version', 'Swift 5.10'], projectLogs: ['$ swift package init --type executable'], buildLogs: ['$ swift build', 'Build complete!'], runLogs: (msg) => ['$ swift run', msg], }, c: { label: 'C', toolchain: 'gcc / clang', mode: 'compile', mainFile: 'hello.c', tree: ['hello.c'], template: [ '#include <stdio.h>', '', 'int main(void) {', ' printf("%s\\n", "{{MSG}}");', ' return 0;', '}', ], runCmd: './hello', setupLogs: ['$ gcc --version', 'gcc 13.2.0'], projectLogs: ['$ touch hello.c'], buildLogs: ['$ gcc -o hello hello.c', 'Без ошибок'], runLogs: (msg) => ['$ ./hello', msg], }, pascal: { label: 'Pascal', toolchain: 'Free Pascal', mode: 'compile', mainFile: 'hello.pas', tree: ['hello.pas'], template: [ 'program Hello;', 'begin', ' WriteLn(\'{{MSG}}\');', 'end.', ], runCmd: './hello', setupLogs: ['$ fpc -iV', '3.2.2'], projectLogs: ['$ touch hello.pas'], buildLogs: ['$ fpc hello.pas', 'Компиляция успешна'], runLogs: (msg) => ['$ ./hello', msg], }, cobol: { label: 'COBOL', toolchain: 'GnuCOBOL', mode: 'compile', mainFile: 'hello.cob', tree: ['hello.cob'], template: [ ' IDENTIFICATION DIVISION.', ' PROGRAM-ID. HELLO.', ' PROCEDURE DIVISION.', ' DISPLAY "{{MSG}}".', ' STOP RUN.', ], runCmd: './hello', setupLogs: ['$ cobc --version', 'GnuCOBOL 3.2'], projectLogs: ['$ touch hello.cob'], buildLogs: ['$ cobc -x hello.cob', 'Сборка OK'], runLogs: (msg) => ['$ ./hello', msg], }, fortran: { label: 'Fortran', toolchain: 'gfortran', mode: 'compile', mainFile: 'hello.f90', tree: ['hello.f90'], template: [ 'program hello', ' print *, "{{MSG}}"', 'end program hello', ], runCmd: './hello', setupLogs: ['$ gfortran --version', 'GNU Fortran 13'], projectLogs: ['$ touch hello.f90'], buildLogs: ['$ gfortran -o hello hello.f90'], runLogs: (msg) => ['$ ./hello', msg], }, lisp: { label: 'Lisp', toolchain: 'SBCL / CLISP', mode: 'interpret', mainFile: 'hello.lisp', tree: ['hello.lisp'], template: ['(format t "~A~%" "{{MSG}}")'], runCmd: 'sbcl --script hello.lisp', setupLogs: ['$ sbcl --version', 'SBCL 2.3.0'], projectLogs: ['$ touch hello.lisp'], buildLogs: null, runLogs: (msg) => ['$ sbcl --script hello.lisp', msg], }, assembler: { label: 'Ассемблер', toolchain: 'NASM + ld', mode: 'compile', mainFile: 'hello.asm', tree: ['hello.asm'], template: [ 'section .data', ' msg db "{{MSG}}", 10', 'section .text', ' global _start', '_start:', ' ; вывод через syscall Linux', ], runCmd: './hello', setupLogs: ['$ nasm --version', 'NASM 2.16'], projectLogs: ['$ touch hello.asm'], buildLogs: ['$ nasm -f elf64 hello.asm && ld -o hello hello.o'], runLogs: (msg) => ['$ ./hello', msg], }, visualbasic: { label: 'Visual Basic', toolchain: '.NET VB', mode: 'compile', mainFile: 'Program.vb', tree: ['HelloWorld.vbproj', 'Program.vb'], template: [ 'Module Program', ' Sub Main()', ' Console.WriteLine("{{MSG}}")', ' End Sub', 'End Module', ], runCmd: 'dotnet run', setupLogs: ['$ dotnet --version', '8.0.100'], projectLogs: ['VS: Консольное приложение (.NET)'], buildLogs: ['$ dotnet build', 'Сборка успешна'], runLogs: (msg) => ['$ dotnet run', msg], }, fsharp: { label: 'F#', toolchain: '.NET + F#', mode: 'compile', mainFile: 'Program.fs', tree: ['Hello.fsproj', 'Program.fs'], template: [ 'printfn "{{MSG}}"', ], runCmd: 'dotnet run', setupLogs: ['$ dotnet --version', '8.0.100'], projectLogs: ['$ dotnet new console -lang F#'], buildLogs: ['$ dotnet build', 'Сборка успешна'], runLogs: (msg) => ['$ dotnet run', msg], }, react: { label: 'React', toolchain: 'Node.js + npm', mode: 'web', mainFile: 'src/App.js', tree: ['package.json', 'src/App.js', 'src/index.js'], template: [ 'function App() {', ' return <h1>{{MSG}}</h1>;', '}', 'export default App;', ], runCmd: 'npm start', setupLogs: ['$ node --version', 'v20.11.0', '$ npx create-react-app my-first-app'], projectLogs: ['Создана структура CRA', 'npm install завершён'], buildLogs: ['$ npm run build', 'Compiled successfully'], runLogs: (msg) => ['Dev server http://localhost:3000', msg], previewType: 'web', }, vue: { label: 'Vue.js', toolchain: 'Vite + Vue', mode: 'web', mainFile: 'src/App.vue', tree: ['package.json', 'src/App.vue'], template: [ '<template>', ' <h1>{{MSG}}</h1>', '</template>', ], runCmd: 'npm run dev', setupLogs: ['$ npm create vue@latest my-vue-app'], projectLogs: ['Проект Vue создан'], buildLogs: ['$ npm run build', '✓ built in 2s'], runLogs: (msg) => ['http://localhost:5173', msg], previewType: 'web', }, angular: { label: 'Angular', toolchain: 'Angular CLI', mode: 'web', mainFile: 'src/app/app.component.ts', tree: ['angular.json', 'src/app/app.component.ts'], template: [ '@Component({', ' template: `<h1>{{MSG}}</h1>`', '})', 'export class AppComponent {}', ], runCmd: 'ng serve', setupLogs: ['$ ng version', 'Angular 17'], projectLogs: ['$ ng new my-angular-app'], buildLogs: ['$ ng build', 'Build at: dist/'], runLogs: (msg) => ['http://localhost:4200', msg], previewType: 'web', }, django: { label: 'Django', toolchain: 'Python + Django', mode: 'web', mainFile: 'manage.py', tree: ['manage.py', 'myproject/urls.py', 'myapp/views.py'], template: [ '# views.py', 'def home(request):', ' return HttpResponse("{{MSG}}")', ], runCmd: 'python manage.py runserver', setupLogs: ['$ pip install django', 'Django 5.0'], projectLogs: ['$ django-admin startproject mysite'], buildLogs: ['$ python manage.py migrate', 'Applying migrations... OK'], runLogs: (msg) => ['http://127.0.0.1:8000/', msg], previewType: 'web', }, laravel: { label: 'Laravel', toolchain: 'PHP + Composer', mode: 'web', mainFile: 'routes/web.php', tree: ['artisan', 'routes/web.php'], template: [ "Route::get('/', fn () => '{{MSG}}');", ], runCmd: 'php artisan serve', setupLogs: ['$ composer create-project laravel/laravel hello'], projectLogs: ['Laravel skeleton создан'], buildLogs: ['$ php artisan key:generate', 'Application key set'], runLogs: (msg) => ['http://127.0.0.1:8000', msg], previewType: 'web', }, flask: { label: 'Flask', toolchain: 'Python + Flask', mode: 'web', mainFile: 'app.py', tree: ['app.py', 'templates/index.html'], template: [ '@app.get("/")', 'def index():', ' return "{{MSG}}"', ], runCmd: 'flask --app app run', setupLogs: ['$ pip install flask', 'Flask 3.x'], projectLogs: ['$ mkdir flask-todo', 'templates/index.html'], buildLogs: null, runLogs: (msg) => ['http://127.0.0.1:5000/', msg], previewType: 'web', }, fastapi: { label: 'FastAPI', toolchain: 'Python + Uvicorn', mode: 'web', mainFile: 'main.py', tree: ['main.py'], template: [ '@app.get("/health")', 'def health():', ' return {"status": "ok", "msg": "{{MSG}}"}', ], runCmd: 'uvicorn main:app --reload', setupLogs: ['$ pip install "fastapi[standard]"', 'FastAPI установлен'], projectLogs: ['main.py создан'], buildLogs: null, runLogs: (msg) => ['http://127.0.0.1:8000/docs', msg], previewType: 'web', }, symfony: { label: 'Symfony', toolchain: 'PHP + Symfony CLI', mode: 'web', mainFile: 'src/Controller/HelloController.php', tree: ['public/index.php', 'src/Controller/HelloController.php'], template: [ '#[Route("/hello")]', 'public function hello(): Response', ' return new Response("{{MSG}}");', ], runCmd: 'symfony server:start', setupLogs: ['$ symfony new app --webapp', 'Symfony skeleton'], projectLogs: ['make:controller HelloController'], buildLogs: ['$ php bin/console cache:clear', 'Cache cleared'], runLogs: (msg) => ['http://127.0.0.1:8000/hello', msg], previewType: 'web', }, node: { label: 'Node.js', toolchain: 'Node.js + Express', mode: 'web', mainFile: 'server.js', tree: ['server.js', 'package.json'], template: [ "app.get('/', (_req, res) => {", " res.json({ message: '{{MSG}}' });", '});', ], runCmd: 'node server.js', setupLogs: ['$ node --version', 'v20.x', '$ npm install express'], projectLogs: ['$ npm init -y', 'server.js'], buildLogs: null, runLogs: (msg) => ['http://127.0.0.1:3000/health', msg], previewType: 'web', }, nextjs: { label: 'Next.js', toolchain: 'Node.js + Next.js', mode: 'web', mainFile: 'app/page.tsx', tree: ['app/page.tsx', 'app/layout.tsx'], template: [ 'export default function Page() {', ' return <h1>{{MSG}}</h1>;', '}', ], runCmd: 'npm run dev', setupLogs: ['$ npx create-next-app@latest my-app', 'App Router'], projectLogs: ['app/page.tsx'], buildLogs: ['$ npm run build', 'Compiled successfully'], runLogs: (msg) => ['http://localhost:3000', msg], previewType: 'web', }, aspnet: { label: 'ASP.NET Core', toolchain: '.NET SDK', mode: 'web', mainFile: 'Program.cs', tree: ['Program.cs', 'HelloApi.csproj'], template: [ 'app.MapGet("/hello", () => "{{MSG}}");', ], runCmd: 'dotnet run', setupLogs: ['$ dotnet --version', '8.0.x', '$ dotnet new webapi -n HelloApi'], projectLogs: ['Program.cs настроен'], buildLogs: ['$ dotnet build', 'Build succeeded'], runLogs: (msg) => ['https://localhost:5001/swagger', msg], previewType: 'web', }, spring: { label: 'Spring', toolchain: 'Spring Boot', mode: 'web', mainFile: 'src/main/java/.../Application.java', tree: ['pom.xml', 'src/main/java/Application.java'], template: [ '@RestController', 'class Hello {', ' @GetMapping("/")', ' String hi() { return "{{MSG}}"; }', '}', ], runCmd: './mvnw spring-boot:run', setupLogs: ['start.spring.io → Spring Boot 3'], projectLogs: ['Скачан starter.zip', 'mvnw добавлен'], buildLogs: ['$ ./mvnw compile', 'BUILD SUCCESS'], runLogs: (msg) => ['http://localhost:8080/', msg], previewType: 'web', }, jsf: { label: 'JavaServer Faces', toolchain: 'Jakarta Faces + Maven', mode: 'web', mainFile: 'src/main/webapp/index.xhtml', tree: ['pom.xml', 'src/main/webapp/index.xhtml'], template: [ '<h:body>', ' <h1>{{MSG}}</h1>', '</h:body>', ], runCmd: 'mvn jetty:run', setupLogs: ['JDK 17 + Maven'], projectLogs: ['Шаблон JSF-приложения'], buildLogs: ['$ mvn package', 'WAR собран'], runLogs: (msg) => ['http://localhost:8080/', msg], previewType: 'web', }, javabean: { label: 'JavaBean', toolchain: 'JSP + Servlet', mode: 'web', mainFile: 'hello.jsp', tree: ['WEB-INF/web.xml', 'hello.jsp'], template: [ '<%@ page contentType="text/html" %>', '<h1><%= "{{MSG}}" %></h1>', ], runCmd: 'mvn tomcat7:run', setupLogs: ['Tomcat / Maven plugin'], projectLogs: ['Создан web-проект'], buildLogs: ['$ mvn compile', 'OK'], runLogs: (msg) => ['http://localhost:8080/hello.jsp', msg], previewType: 'web', }, }; /** Путь статьи → id языка для демо */ export const ARTICLE_LANG_MAP = { '5-02-python/16.md': 'python', '5-03-java/13.md': 'java', '5-05-csharp/16.md': 'csharp', '5-06-cpp/1002.md': 'cpp', '5-13-rust/20.md': 'rust', '5-10-go/24.md': 'go', '5-09-kotlin/2.md': 'kotlin', '5-12-groovy/2.md': 'groovy', '5-11-ruby/20.md': 'ruby', '5-07-php/13.md': 'php', '5-17-haskell/7.md': 'haskell', '5-18-scala/7.md': 'scala', '5-21-nim/7.md': 'nim', '5-20-zig/7.md': 'zig', '5-22-dart/7.md': 'dart', '5-19-elixir/7.md': 'elixir', '5-24-julia/7.md': 'julia', '5-23-r/7.md': 'r', '5-25-bash/122.md': 'bash', '5-26-powershell/122.md': 'powershell', '5-15-lua-i-luau/13.md': 'lua', '5-08-smalltalk/11.md': 'smalltalk', '5-14-swift/20.md': 'swift', '5-16-starye-yazyki/c-language/7.md': 'c', '5-16-starye-yazyki/Pascal/7.md': 'pascal', '5-16-starye-yazyki/Cobol/7.md': 'cobol', '5-16-starye-yazyki/Fortran/7.md': 'fortran', '5-16-starye-yazyki/Lisp/7.md': 'lisp', '5-16-starye-yazyki/assembler/7.md': 'assembler', '5-16-starye-yazyki/visual-basic/7.md': 'visualbasic', '5-04-platforma-dotnet/182.md': 'fsharp', '5-01-javascript/272.md': 'react', '5-01-javascript/282.md': 'vue', '5-01-javascript/292.md': 'angular', '5-02-python/3011.md': 'django', '5-02-python/3411.md': 'flask', '5-02-python/3432.md': 'fastapi', '5-07-php/1431.md': 'laravel', '5-07-php/1441.md': 'symfony', '5-01-javascript/262.md': 'node', '5-01-javascript/2731.md': 'nextjs', '5-05-csharp/4511.md': 'aspnet', '5-03-java/271.md': 'spring', '5-03-java/251.md': 'jsf', '5-03-java/261.md': 'javabean', }; export function getLangConfig(language) { const key = (language || 'python').toLowerCase(); return LANG_CONFIGS[key] ?? LANG_CONFIGS.python; } export function buildCode(config, message = DEFAULT_MSG) { return tpl(config.template, message); } export function getActiveSteps(config) { const skipBuild = !config.buildLogs; return WORKFLOW_STEPS.filter((s) => s.id !== 'build' || !skipBuild); } /** @returns {{ stepId: string, lines: {text: string, type?: string}[], delay: number }[]} */ export function buildRunTimeline(config, message = DEFAULT_MSG) { const out = message.trim() || DEFAULT_MSG; const timeline = []; const push = (stepId, lines, delay = 400) => { timeline.push({ stepId, lines: lines.map((text) => ({ text, type: text.includes('error') || text.includes('Error') ? 'error' : 'info', })), delay, }); }; push('setup', config.setupLogs ?? [], 350); push('project', config.projectLogs ?? [], 450); push('code', [`Файл: ${config.mainFile}`, 'Код готов к запуску'], 300); if (config.buildLogs) { push('build', config.buildLogs, 500); } const runLines = config.runLogs(out); push('run', runLines, 400); return timeline; } export function stepIndexForId(activeSteps, stepId) { return activeSteps.findIndex((s) => s.id === stepId); }