fisrt commit
13
.dockerignore
Normal file
@ -0,0 +1,13 @@
|
||||
node_modules
|
||||
dist
|
||||
.git
|
||||
.gitignore
|
||||
*.md
|
||||
.drone.yml
|
||||
k8s
|
||||
.vscode
|
||||
.idea
|
||||
*.log
|
||||
.DS_Store
|
||||
.env
|
||||
.env.*
|
||||
93
.drone.yml
Normal file
@ -0,0 +1,93 @@
|
||||
---
|
||||
kind: pipeline
|
||||
type: kubernetes
|
||||
name: build-deploy
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- main
|
||||
- master
|
||||
event:
|
||||
- push
|
||||
|
||||
steps:
|
||||
# ============================================================
|
||||
# СБОРКА ОБРАЗА
|
||||
# ============================================================
|
||||
|
||||
- name: build
|
||||
image: plugins/kaniko
|
||||
settings:
|
||||
registry: registry.vigdorov.ru
|
||||
repo: registry.vigdorov.ru/library/chicken-game
|
||||
dockerfile: Dockerfile
|
||||
context: .
|
||||
tags:
|
||||
- ${DRONE_COMMIT_SHA:0:7}
|
||||
- latest
|
||||
cache: true
|
||||
cache_repo: registry.vigdorov.ru/library/chicken-game-cache
|
||||
username:
|
||||
from_secret: HARBOR_USER
|
||||
password:
|
||||
from_secret: HARBOR_PASSWORD
|
||||
no_push_metadata: true
|
||||
|
||||
# ============================================================
|
||||
# ДЕПЛОЙ
|
||||
# ============================================================
|
||||
|
||||
- name: deploy
|
||||
image: alpine/k8s:1.28.2
|
||||
depends_on:
|
||||
- build
|
||||
environment:
|
||||
KUBE_CONFIG_CONTENT:
|
||||
from_secret: KUBE_CONFIG
|
||||
commands:
|
||||
- mkdir -p ~/.kube
|
||||
- echo "$KUBE_CONFIG_CONTENT" > ~/.kube/config
|
||||
- chmod 600 ~/.kube/config
|
||||
- sed -i "s|https://127.0.0.1:6443|https://10.10.10.100:6443|g" ~/.kube/config
|
||||
- export APP_NAMESPACE="prod-ns"
|
||||
- export IMAGE_TAG="${DRONE_COMMIT_SHA:0:7}"
|
||||
- export IMAGE="registry.vigdorov.ru/library/chicken-game"
|
||||
- kubectl cluster-info
|
||||
- sed -e "s|__IMAGE__|$IMAGE:$IMAGE_TAG|g" k8s/deployment.yaml | kubectl apply -n $APP_NAMESPACE -f -
|
||||
- kubectl apply -n $APP_NAMESPACE -f k8s/service.yaml
|
||||
- kubectl rollout status deployment/chicken-game -n $APP_NAMESPACE --timeout=300s
|
||||
- echo "✅ Chicken Game deployed (image:$IMAGE_TAG)"
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: kubernetes
|
||||
name: infra-pipeline
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- main
|
||||
- master
|
||||
event:
|
||||
- push
|
||||
paths:
|
||||
include:
|
||||
- k8s/**
|
||||
|
||||
steps:
|
||||
- name: deploy-infra
|
||||
image: alpine/k8s:1.28.2
|
||||
environment:
|
||||
KUBE_CONFIG_CONTENT:
|
||||
from_secret: KUBE_CONFIG
|
||||
commands:
|
||||
- mkdir -p ~/.kube
|
||||
- echo "$KUBE_CONFIG_CONTENT" > ~/.kube/config
|
||||
- chmod 600 ~/.kube/config
|
||||
- sed -i "s|https://127.0.0.1:6443|https://10.10.10.100:6443|g" ~/.kube/config
|
||||
- export APP_NAMESPACE="prod-ns"
|
||||
- export HOSTNAME="chicken.vigdorov.ru"
|
||||
- export SECRET_NAME="wildcard-cert"
|
||||
- kubectl cluster-info
|
||||
- kubectl apply -n $APP_NAMESPACE -f k8s/service.yaml
|
||||
- sed -e "s|__HOSTNAME__|$HOSTNAME|g" -e "s|__SECRET_NAME__|$SECRET_NAME|g" k8s/ingress.yaml | kubectl apply -n $APP_NAMESPACE -f -
|
||||
- echo "✅ Infrastructure updated for chicken.vigdorov.ru"
|
||||
BIN
.playwright-mcp/after-click-screenshot.png
Normal file
|
After Width: | Height: | Size: 79 KiB |
BIN
.playwright-mcp/back-to-menu.png
Normal file
|
After Width: | Height: | Size: 42 KiB |
BIN
.playwright-mcp/game-action.png
Normal file
|
After Width: | Height: | Size: 64 KiB |
BIN
.playwright-mcp/game-gameplay.png
Normal file
|
After Width: | Height: | Size: 80 KiB |
BIN
.playwright-mcp/game-gameplay2.png
Normal file
|
After Width: | Height: | Size: 62 KiB |
BIN
.playwright-mcp/game-ingame.png
Normal file
|
After Width: | Height: | Size: 80 KiB |
BIN
.playwright-mcp/game-menu.png
Normal file
|
After Width: | Height: | Size: 42 KiB |
BIN
.playwright-mcp/game-menu2.png
Normal file
|
After Width: | Height: | Size: 42 KiB |
BIN
.playwright-mcp/game-menu3.png
Normal file
|
After Width: | Height: | Size: 80 KiB |
BIN
.playwright-mcp/game-menu4.png
Normal file
|
After Width: | Height: | Size: 42 KiB |
BIN
.playwright-mcp/game-play1.png
Normal file
|
After Width: | Height: | Size: 80 KiB |
BIN
.playwright-mcp/game-play2.png
Normal file
|
After Width: | Height: | Size: 37 KiB |
BIN
.playwright-mcp/game-play3.png
Normal file
|
After Width: | Height: | Size: 65 KiB |
BIN
.playwright-mcp/game-playing.png
Normal file
|
After Width: | Height: | Size: 39 KiB |
BIN
.playwright-mcp/game-running.png
Normal file
|
After Width: | Height: | Size: 37 KiB |
BIN
.playwright-mcp/game-screenshot.png
Normal file
|
After Width: | Height: | Size: 42 KiB |
BIN
.playwright-mcp/game-start.png
Normal file
|
After Width: | Height: | Size: 42 KiB |
BIN
.playwright-mcp/game-start2.png
Normal file
|
After Width: | Height: | Size: 80 KiB |
BIN
.playwright-mcp/game-test1.png
Normal file
|
After Width: | Height: | Size: 80 KiB |
BIN
.playwright-mcp/game-test2.png
Normal file
|
After Width: | Height: | Size: 41 KiB |
BIN
.playwright-mcp/game-textures.png
Normal file
|
After Width: | Height: | Size: 31 KiB |
BIN
.playwright-mcp/hardcore-game.png
Normal file
|
After Width: | Height: | Size: 65 KiB |
BIN
.playwright-mcp/hardcore-gameplay.png
Normal file
|
After Width: | Height: | Size: 67 KiB |
BIN
.playwright-mcp/highscores-fixed.png
Normal file
|
After Width: | Height: | Size: 39 KiB |
BIN
.playwright-mcp/menu-screenshot.png
Normal file
|
After Width: | Height: | Size: 42 KiB |
BIN
.playwright-mcp/menu-test.png
Normal file
|
After Width: | Height: | Size: 42 KiB |
BIN
.playwright-mcp/menu-test2.png
Normal file
|
After Width: | Height: | Size: 42 KiB |
BIN
.playwright-mcp/parallax-jump.png
Normal file
|
After Width: | Height: | Size: 68 KiB |
BIN
.playwright-mcp/parallax-move1.png
Normal file
|
After Width: | Height: | Size: 80 KiB |
BIN
.playwright-mcp/parallax-move2.png
Normal file
|
After Width: | Height: | Size: 80 KiB |
BIN
.playwright-mcp/parallax-test1.png
Normal file
|
After Width: | Height: | Size: 80 KiB |
BIN
.playwright-mcp/play-direct.png
Normal file
|
After Width: | Height: | Size: 64 KiB |
BIN
.playwright-mcp/player-fall.png
Normal file
|
After Width: | Height: | Size: 38 KiB |
BIN
.playwright-mcp/player-jump.png
Normal file
|
After Width: | Height: | Size: 38 KiB |
BIN
.playwright-mcp/player-run.png
Normal file
|
After Width: | Height: | Size: 37 KiB |
BIN
.playwright-mcp/player-shoot.png
Normal file
|
After Width: | Height: | Size: 36 KiB |
BIN
.playwright-mcp/settings-fixed.png
Normal file
|
After Width: | Height: | Size: 42 KiB |
BIN
.playwright-mcp/shop-fixed.png
Normal file
|
After Width: | Height: | Size: 80 KiB |
BIN
.playwright-mcp/shop-screenshot.png
Normal file
|
After Width: | Height: | Size: 42 KiB |
7
.prettierrc
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"semi": true,
|
||||
"singleQuote": true,
|
||||
"tabWidth": 2,
|
||||
"trailingComma": "es5",
|
||||
"printWidth": 100
|
||||
}
|
||||
94
CLAUDE.md
Normal file
@ -0,0 +1,94 @@
|
||||
# Platformer Game
|
||||
|
||||
Browser-based platformer game built with Phaser 3 and TypeScript.
|
||||
|
||||
## Tech Stack
|
||||
|
||||
- **Engine:** Phaser 3
|
||||
- **Language:** TypeScript
|
||||
- **Build:** Vite
|
||||
- **Package Manager:** npm
|
||||
|
||||
## Project Structure
|
||||
|
||||
```
|
||||
src/
|
||||
├── scenes/ # Game scenes (Boot, Menu, Game, etc.)
|
||||
├── entities/ # Game objects (Player, Enemies, Items)
|
||||
├── systems/ # Core systems (Physics, Input, Audio)
|
||||
├── config/ # Game configuration
|
||||
└── assets/ # Sprites, sounds, tilemaps
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
npm install
|
||||
npm run dev
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
- [Game Design](./docs/DESIGN.md) - gameplay mechanics, levels
|
||||
- [Architecture](./docs/ARCHITECTURE.md) - code structure, patterns
|
||||
- [Assets](./docs/ASSETS.md) - sprites, audio, tilemaps
|
||||
|
||||
## Commands
|
||||
|
||||
- `npm run dev` - development server
|
||||
- `npm run build` - production build
|
||||
- `npm run preview` - preview build
|
||||
- `npm run check` - **запускать перед коммитом** (typecheck + lint)
|
||||
- `npm run lint` - проверка ESLint
|
||||
- `npm run lint:fix` - автоисправление ESLint/Prettier
|
||||
- `npm run typecheck` - проверка TypeScript
|
||||
- `npm run format` - форматирование Prettier
|
||||
|
||||
## Phaser 3 — Правила разработки
|
||||
|
||||
### 1. Обработчики событий накапливаются при рестарте
|
||||
|
||||
Keyboard Keys в Phaser переиспользуются между рестартами сцены. **Всегда удаляй старые обработчики:**
|
||||
|
||||
```typescript
|
||||
// ПРАВИЛЬНО
|
||||
key.removeAllListeners('down');
|
||||
key.on('down', () => this.shoot());
|
||||
|
||||
// Для событий сцены
|
||||
this.events.off('shoot', this.handleShoot, this);
|
||||
this.events.on('shoot', this.handleShoot, this);
|
||||
```
|
||||
|
||||
### 2. scene.start() НЕ останавливает текущую сцену
|
||||
|
||||
Оверлеи (GameOver, Pause) остаются видимыми. **Явно останавливай сцены:**
|
||||
|
||||
```typescript
|
||||
const sceneManager = this.game.scene; // Используй глобальный менеджер!
|
||||
sceneManager.stop('UIScene');
|
||||
sceneManager.stop('GameOverScene');
|
||||
sceneManager.start('GameScene');
|
||||
```
|
||||
|
||||
### 3. Null reference при рестарте UI-сцены
|
||||
|
||||
`update()` может вызваться до `create()`. **Сбрасывай массивы и добавляй проверки:**
|
||||
|
||||
```typescript
|
||||
create(): void {
|
||||
this.indicators = []; // Сбрасывай в начале create()
|
||||
}
|
||||
|
||||
update(): void {
|
||||
if (!this.runState || !this.scoreText) return; // Guard-проверка
|
||||
}
|
||||
```
|
||||
|
||||
### 4. Чеклист при работе со сценами
|
||||
|
||||
- [ ] Очищать обработчики клавиш в `setupControls()`
|
||||
- [ ] Очищать `this.events` обработчики в `create()` или `shutdown()`
|
||||
- [ ] Сбрасывать массивы/объекты в начале `create()`
|
||||
- [ ] Добавлять null-проверки в `update()` для UI
|
||||
- [ ] Использовать `this.game.scene` для остановки текущей сцены
|
||||
36
Dockerfile
Normal file
@ -0,0 +1,36 @@
|
||||
# Build stage
|
||||
FROM node:20-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package files
|
||||
COPY package.json ./
|
||||
COPY package-lock.json ./
|
||||
|
||||
# Install dependencies
|
||||
RUN npm ci
|
||||
|
||||
# Copy source code
|
||||
COPY . .
|
||||
|
||||
# Build the application
|
||||
RUN npm run build
|
||||
|
||||
# Production stage
|
||||
FROM nginx:alpine
|
||||
|
||||
# Copy built files from builder
|
||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||
|
||||
# Copy nginx configuration
|
||||
COPY nginx.conf /etc/nginx/nginx.conf
|
||||
|
||||
# Expose port
|
||||
EXPOSE 80
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s \
|
||||
CMD wget --quiet --tries=1 --spider http://localhost/health || exit 1
|
||||
|
||||
# Start nginx
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
6363
dist/assets/index-BQJdTMPx.js
vendored
Normal file
1
dist/assets/index-BQJdTMPx.js.map
vendored
Normal file
31
dist/index.html
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Roguelite Platformer</title>
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
body {
|
||||
background-color: #1a1a2e;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
overflow: hidden;
|
||||
}
|
||||
#game-container {
|
||||
border: 2px solid #4a4a6a;
|
||||
border-radius: 4px;
|
||||
}
|
||||
</style>
|
||||
<script type="module" crossorigin src="/assets/index-BQJdTMPx.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="game-container"></div>
|
||||
</body>
|
||||
</html>
|
||||
944
docs/ARCHITECTURE.md
Normal file
@ -0,0 +1,944 @@
|
||||
# Architecture
|
||||
|
||||
Technical architecture for the Roguelite Platformer game.
|
||||
|
||||
---
|
||||
|
||||
## Project Structure
|
||||
|
||||
```
|
||||
src/
|
||||
├── main.ts # Entry point, Phaser config
|
||||
├── types/ # TypeScript interfaces
|
||||
│ ├── index.ts # Re-exports
|
||||
│ ├── game-state.ts # RunState, MetaState
|
||||
│ ├── entities.ts # EnemyConfig, HazardConfig
|
||||
│ ├── upgrades.ts # Upgrade, UpgradeEffect
|
||||
│ └── level-gen.ts # RoomTemplate, SpawnPoint
|
||||
│
|
||||
├── config/ # Configuration
|
||||
│ ├── game.config.ts # Phaser config
|
||||
│ ├── physics.config.ts # Arcade physics settings
|
||||
│ ├── controls.config.ts # Key bindings
|
||||
│ ├── balance.config.ts # Balance (speeds, timings)
|
||||
│ └── upgrades.config.ts # All shop upgrades
|
||||
│
|
||||
├── scenes/ # Phaser scenes
|
||||
│ ├── BootScene.ts # Initialization
|
||||
│ ├── PreloadScene.ts # Asset loading
|
||||
│ ├── MenuScene.ts # Main menu
|
||||
│ ├── GameScene.ts # Core gameplay
|
||||
│ ├── UIScene.ts # HUD (parallel with GameScene)
|
||||
│ ├── PauseScene.ts # Pause menu
|
||||
│ ├── ShopScene.ts # Upgrade shop
|
||||
│ └── GameOverScene.ts # Death screen
|
||||
│
|
||||
├── entities/ # Game objects
|
||||
│ ├── Player.ts # Player entity
|
||||
│ ├── PlayerController.ts # Controls + game feel
|
||||
│ ├── enemies/ # Enemy types
|
||||
│ │ ├── Enemy.ts # Base class
|
||||
│ │ ├── Patroller.ts # Patrol enemy
|
||||
│ │ ├── Jumper.ts # Jumping enemy
|
||||
│ │ ├── Flyer.ts # Flying enemy
|
||||
│ │ ├── Chaser.ts # Chasing enemy
|
||||
│ │ └── Sprinter.ts # Fast patrol enemy
|
||||
│ ├── Projectile.ts # Player projectile
|
||||
│ ├── Coin.ts # Collectible coin
|
||||
│ ├── PowerUp.ts # Power-up item
|
||||
│ └── hazards/ # Hazard types
|
||||
│ ├── Spikes.ts # Static spikes
|
||||
│ ├── FallingPlatform.ts # Crumbling platform
|
||||
│ ├── Saw.ts # Moving saw
|
||||
│ ├── Turret.ts # Shooting turret
|
||||
│ └── Laser.ts # Toggle laser
|
||||
│
|
||||
├── systems/ # Managers/Systems
|
||||
│ ├── InputManager.ts # Input buffering, abstraction
|
||||
│ ├── AudioManager.ts # Sound and music
|
||||
│ ├── SaveManager.ts # localStorage persistence
|
||||
│ ├── GameStateManager.ts # Run state + Meta state
|
||||
│ ├── UpgradeManager.ts # Upgrade application
|
||||
│ ├── ScoreManager.ts # Score and combo
|
||||
│ ├── ParticleManager.ts # Particle effects
|
||||
│ └── CameraManager.ts # Screen shake
|
||||
│
|
||||
├── level-generation/ # Procedural generation
|
||||
│ ├── LevelGenerator.ts # Main generator
|
||||
│ ├── RoomPlacer.ts # Room placement
|
||||
│ ├── PathValidator.ts # Path validation
|
||||
│ └── templates/ # JSON room templates
|
||||
│
|
||||
├── ui/ # UI components
|
||||
│ ├── HUD.ts # Heads-up display
|
||||
│ ├── Button.ts # Reusable button
|
||||
│ ├── ProgressBar.ts # Progress/health bar
|
||||
│ └── ComboDisplay.ts # Combo counter
|
||||
│
|
||||
└── utils/ # Utilities
|
||||
├── math.ts # Math helpers
|
||||
└── SeededRandom.ts # Seed-based RNG
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Scene Architecture
|
||||
|
||||
### Scene Flow
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ │
|
||||
│ BootScene → PreloadScene → MenuScene ─┬→ GameScene ←──┐ │
|
||||
│ │ │ │ │
|
||||
│ │ ▼ │ │
|
||||
│ │ UIScene │ │
|
||||
│ │ (parallel) │ │
|
||||
│ │ │ │ │
|
||||
│ │ ▼ │ │
|
||||
│ │ PauseScene │ │
|
||||
│ │ │ │ │
|
||||
│ │ ▼ │ │
|
||||
│ │ GameOverScene│ │
|
||||
│ │ │ │ │
|
||||
│ │ ▼ │ │
|
||||
│ └→ ShopScene ───┘ │
|
||||
│ │
|
||||
└─────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
### Scene Responsibilities
|
||||
|
||||
| Scene | Responsibility |
|
||||
|-------|---------------|
|
||||
| **BootScene** | Initialize game settings, configure physics |
|
||||
| **PreloadScene** | Load all assets (sprites, audio, tilemaps) |
|
||||
| **MenuScene** | Main menu, navigation to other scenes |
|
||||
| **GameScene** | Core gameplay loop, entity management |
|
||||
| **UIScene** | HUD overlay, runs parallel with GameScene |
|
||||
| **PauseScene** | Pause menu, settings access during gameplay |
|
||||
| **ShopScene** | Meta-progression shop, upgrade purchases |
|
||||
| **GameOverScene** | Death screen, stats, navigation |
|
||||
|
||||
### Scene Communication
|
||||
|
||||
Scenes communicate through:
|
||||
|
||||
1. **Registry** (`this.registry`) - shared data store
|
||||
2. **Events** (`this.events`) - event-based messaging
|
||||
3. **Scene Manager** - scene transitions
|
||||
|
||||
```typescript
|
||||
// Example: GameScene emits coin collection
|
||||
this.events.emit('coin-collected', { amount: 1, total: this.coins });
|
||||
|
||||
// UIScene listens and updates display
|
||||
this.scene.get('GameScene').events.on('coin-collected', this.updateCoinDisplay, this);
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## State Management
|
||||
|
||||
### Dual-State Pattern
|
||||
|
||||
The game uses two separate state objects:
|
||||
|
||||
```typescript
|
||||
// RunState - reset every run
|
||||
interface RunState {
|
||||
currentLevel: number;
|
||||
coins: number;
|
||||
score: number;
|
||||
combo: number;
|
||||
projectilesAvailable: number;
|
||||
activePowerUp: PowerUpType | null;
|
||||
powerUpTimer: number;
|
||||
hp: number;
|
||||
hasUsedSecondChance: boolean;
|
||||
enemiesStunned: number;
|
||||
timeElapsed: number;
|
||||
levelSeed: string;
|
||||
}
|
||||
|
||||
// MetaState - persists across runs
|
||||
interface MetaState {
|
||||
gasCoins: number;
|
||||
purchasedUpgrades: string[];
|
||||
activeUpgrades: string[];
|
||||
achievements: string[];
|
||||
totalCoinsCollected: number;
|
||||
totalEnemiesStunned: number;
|
||||
totalDeaths: number;
|
||||
highScores: HighScore[];
|
||||
settings: GameSettings;
|
||||
}
|
||||
```
|
||||
|
||||
### State Flow
|
||||
|
||||
```
|
||||
┌────────────────────────────────────────────────────────────┐
|
||||
│ GameStateManager │
|
||||
├────────────────────────────────────────────────────────────┤
|
||||
│ │
|
||||
│ ┌─────────────┐ ┌─────────────────────────┐ │
|
||||
│ │ RunState │ │ MetaState │ │
|
||||
│ │ (memory) │ │ (localStorage) │ │
|
||||
│ ├─────────────┤ ├─────────────────────────┤ │
|
||||
│ │ level: 1 │ ──death──▶ │ gasCoins += runCoins │ │
|
||||
│ │ coins: 42 │ │ totalDeaths++ │ │
|
||||
│ │ score: 1200 │ │ highScores.push(...) │ │
|
||||
│ │ ... │ │ │ │
|
||||
│ └─────────────┘ └─────────────────────────┘ │
|
||||
│ │ │ │
|
||||
│ │ reset on new run │ load on boot │
|
||||
│ ▼ ▼ save on change │
|
||||
│ │
|
||||
└────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Entity System
|
||||
|
||||
### Entity Hierarchy
|
||||
|
||||
```
|
||||
Phaser.GameObjects.Sprite
|
||||
│
|
||||
│
|
||||
┌───────────────┼───────────────┐
|
||||
│ │ │
|
||||
Player Enemy Hazard
|
||||
│ │ │
|
||||
│ ┌───────┼───────┐ │
|
||||
│ │ │ │ │
|
||||
│ Patroller Flyer Chaser │
|
||||
│ │ │ │
|
||||
│ Jumper Sprinter │
|
||||
│ │
|
||||
│ ┌───────┼───────┐
|
||||
│ │ │ │
|
||||
│ Spikes Saw Laser
|
||||
│ │
|
||||
│ FallingPlatform
|
||||
│ │
|
||||
│ Turret
|
||||
│
|
||||
PlayerController
|
||||
```
|
||||
|
||||
### Enemy States
|
||||
|
||||
```typescript
|
||||
enum EnemyState {
|
||||
ACTIVE = 'active', // Dangerous, kills on contact
|
||||
STUNNED = 'stunned', // Safe, can pass through
|
||||
RECOVERING = 'recovering' // Brief transition state
|
||||
}
|
||||
```
|
||||
|
||||
State machine for enemies:
|
||||
|
||||
```
|
||||
┌─────────┐ hit by projectile ┌─────────┐ timer expires ┌────────────┐
|
||||
│ ACTIVE │ ─────────────────▶ │ STUNNED │ ──────────────▶ │ RECOVERING │
|
||||
└─────────┘ └─────────┘ └────────────┘
|
||||
▲ │
|
||||
│ recovery complete │
|
||||
└────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Physics Configuration
|
||||
|
||||
### Arcade Physics Settings
|
||||
|
||||
```typescript
|
||||
// physics.config.ts
|
||||
export const PHYSICS_CONFIG = {
|
||||
gravity: { y: 1200 },
|
||||
|
||||
player: {
|
||||
speed: 300,
|
||||
jumpVelocity: -500,
|
||||
acceleration: 2000,
|
||||
drag: 1500,
|
||||
},
|
||||
|
||||
projectile: {
|
||||
speed: 600,
|
||||
lifetime: 1000, // ms
|
||||
},
|
||||
|
||||
enemies: {
|
||||
patroller: { speed: 100 },
|
||||
jumper: { speed: 80, jumpForce: -400 },
|
||||
flyer: { speed: 120 },
|
||||
chaser: { speed: 60 },
|
||||
sprinter: { speed: 200 },
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
### Collision Groups
|
||||
|
||||
```
|
||||
Player ←→ Enemy (active) = Death
|
||||
Player ←→ Enemy (stunned) = Pass through
|
||||
Player ←→ Hazard = Death
|
||||
Player ←→ Coin = Collect
|
||||
Player ←→ PowerUp = Collect
|
||||
Player ←→ Platform = Land
|
||||
Projectile ←→ Enemy = Stun enemy
|
||||
Projectile ←→ Wall = Destroy (or ricochet)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Game Feel Implementation
|
||||
|
||||
### Coyote Time
|
||||
|
||||
```typescript
|
||||
// PlayerController.ts
|
||||
private coyoteTime = 100; // ms
|
||||
private coyoteTimer = 0;
|
||||
private wasGrounded = false;
|
||||
|
||||
update(delta: number) {
|
||||
if (this.body.onFloor()) {
|
||||
this.coyoteTimer = this.coyoteTime;
|
||||
this.wasGrounded = true;
|
||||
} else if (this.wasGrounded) {
|
||||
this.coyoteTimer -= delta;
|
||||
if (this.coyoteTimer <= 0) {
|
||||
this.wasGrounded = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
canJump(): boolean {
|
||||
return this.body.onFloor() || this.coyoteTimer > 0;
|
||||
}
|
||||
```
|
||||
|
||||
### Input Buffering
|
||||
|
||||
```typescript
|
||||
// InputManager.ts
|
||||
private jumpBufferTime = 100; // ms
|
||||
private jumpBufferTimer = 0;
|
||||
|
||||
update(delta: number) {
|
||||
if (this.jumpPressed) {
|
||||
this.jumpBufferTimer = this.jumpBufferTime;
|
||||
} else {
|
||||
this.jumpBufferTimer = Math.max(0, this.jumpBufferTimer - delta);
|
||||
}
|
||||
}
|
||||
|
||||
hasBufferedJump(): boolean {
|
||||
return this.jumpBufferTimer > 0;
|
||||
}
|
||||
|
||||
consumeJumpBuffer() {
|
||||
this.jumpBufferTimer = 0;
|
||||
}
|
||||
```
|
||||
|
||||
### Variable Jump Height
|
||||
|
||||
```typescript
|
||||
// PlayerController.ts
|
||||
private minJumpVelocity = -250;
|
||||
private maxJumpVelocity = -500;
|
||||
|
||||
onJumpPressed() {
|
||||
if (this.canJump()) {
|
||||
this.body.setVelocityY(this.maxJumpVelocity);
|
||||
this.isJumping = true;
|
||||
}
|
||||
}
|
||||
|
||||
onJumpReleased() {
|
||||
if (this.isJumping && this.body.velocity.y < this.minJumpVelocity) {
|
||||
this.body.setVelocityY(this.minJumpVelocity);
|
||||
}
|
||||
this.isJumping = false;
|
||||
}
|
||||
```
|
||||
|
||||
### Edge Correction
|
||||
|
||||
```typescript
|
||||
// PlayerController.ts
|
||||
private edgeCorrectionDistance = 4; // pixels
|
||||
|
||||
handleCollision(tile: Phaser.Tilemaps.Tile) {
|
||||
if (this.body.velocity.y < 0) { // Moving upward
|
||||
const overlap = this.getHorizontalOverlap(tile);
|
||||
if (overlap > 0 && overlap <= this.edgeCorrectionDistance) {
|
||||
this.x += overlap * this.getOverlapDirection(tile);
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Level Generation
|
||||
|
||||
### Spelunky-Style Room Grid
|
||||
|
||||
```
|
||||
┌─────┬─────┬─────┬─────┐
|
||||
│ S │ │ │ │ S = Start
|
||||
├─────┼─────┼─────┼─────┤ E = Exit
|
||||
│ ↓ │ ←──┤ │ │ ↓ → = Path direction
|
||||
├─────┼─────┼─────┼─────┤
|
||||
│ │ ↓ │ │ │
|
||||
├─────┼─────┼─────┼─────┤
|
||||
│ │ E │ │ │
|
||||
└─────┴─────┴─────┴─────┘
|
||||
```
|
||||
|
||||
### Generation Algorithm
|
||||
|
||||
```typescript
|
||||
// LevelGenerator.ts
|
||||
class LevelGenerator {
|
||||
generateLevel(level: number, seed: string): Level {
|
||||
const rng = new SeededRandom(seed);
|
||||
const config = this.getLevelConfig(level);
|
||||
|
||||
// 1. Create room grid
|
||||
const grid = this.createGrid(config.gridSize);
|
||||
|
||||
// 2. Generate guaranteed path
|
||||
const path = this.generatePath(grid, rng);
|
||||
|
||||
// 3. Place room templates along path
|
||||
this.placeRooms(grid, path, config.difficulty, rng);
|
||||
|
||||
// 4. Fill remaining cells with optional rooms
|
||||
this.fillOptionalRooms(grid, rng);
|
||||
|
||||
// 5. Place entities
|
||||
this.placeCoins(grid, config.coinCount, rng);
|
||||
this.placeEnemies(grid, config.enemyCount, level, rng);
|
||||
this.placeHazards(grid, config.hazardCount, level, rng);
|
||||
this.placePowerUp(grid, rng); // 10% chance
|
||||
|
||||
// 6. Validate
|
||||
if (!this.validatePath(grid)) {
|
||||
return this.generateLevel(level, seed + '_retry');
|
||||
}
|
||||
|
||||
return this.buildLevel(grid);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Room Templates
|
||||
|
||||
```typescript
|
||||
// types/level-gen.ts
|
||||
interface RoomTemplate {
|
||||
id: string;
|
||||
width: number; // tiles
|
||||
height: number; // tiles
|
||||
difficulty: number; // 1-10
|
||||
exits: {
|
||||
top: boolean;
|
||||
bottom: boolean;
|
||||
left: boolean;
|
||||
right: boolean;
|
||||
};
|
||||
tiles: number[][]; // tile IDs
|
||||
spawnPoints: SpawnPoint[];
|
||||
}
|
||||
|
||||
interface SpawnPoint {
|
||||
type: 'coin' | 'enemy' | 'hazard' | 'powerup';
|
||||
x: number;
|
||||
y: number;
|
||||
probability?: number;
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Upgrade System
|
||||
|
||||
### Upgrade Configuration
|
||||
|
||||
```typescript
|
||||
// config/upgrades.config.ts
|
||||
export const UPGRADES: Upgrade[] = [
|
||||
{
|
||||
id: 'light_boots',
|
||||
name: 'Light Boots',
|
||||
description: '+10% movement speed',
|
||||
category: 'character',
|
||||
price: 100,
|
||||
effects: [{ type: 'speed_multiplier', value: 1.1 }],
|
||||
unlockRequirement: null,
|
||||
},
|
||||
{
|
||||
id: 'heavy_armor',
|
||||
name: 'Heavy Armor',
|
||||
description: '+1 HP per run, -15% speed',
|
||||
category: 'character',
|
||||
price: 500,
|
||||
effects: [
|
||||
{ type: 'extra_hp', value: 1 },
|
||||
{ type: 'speed_multiplier', value: 0.85 },
|
||||
],
|
||||
unlockRequirement: null,
|
||||
},
|
||||
// ... more upgrades
|
||||
];
|
||||
```
|
||||
|
||||
### Upgrade Application
|
||||
|
||||
```typescript
|
||||
// UpgradeManager.ts
|
||||
class UpgradeManager {
|
||||
applyUpgrades(player: Player, activeUpgrades: string[]) {
|
||||
const stats = { ...DEFAULT_PLAYER_STATS };
|
||||
|
||||
for (const upgradeId of activeUpgrades) {
|
||||
const upgrade = this.getUpgrade(upgradeId);
|
||||
for (const effect of upgrade.effects) {
|
||||
this.applyEffect(stats, effect);
|
||||
}
|
||||
}
|
||||
|
||||
player.setStats(stats);
|
||||
}
|
||||
|
||||
private applyEffect(stats: PlayerStats, effect: UpgradeEffect) {
|
||||
switch (effect.type) {
|
||||
case 'speed_multiplier':
|
||||
stats.speed *= effect.value;
|
||||
break;
|
||||
case 'jump_multiplier':
|
||||
stats.jumpVelocity *= effect.value;
|
||||
break;
|
||||
case 'extra_hp':
|
||||
stats.maxHp += effect.value;
|
||||
break;
|
||||
case 'extra_projectile':
|
||||
stats.maxProjectiles += effect.value;
|
||||
break;
|
||||
// ... more effect types
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Audio System
|
||||
|
||||
### Audio Manager
|
||||
|
||||
```typescript
|
||||
// AudioManager.ts
|
||||
class AudioManager {
|
||||
private music: Phaser.Sound.BaseSound | null = null;
|
||||
private sfxVolume: number = 1;
|
||||
private musicVolume: number = 0.5;
|
||||
|
||||
playMusic(key: string, loop = true) {
|
||||
if (this.music) this.music.stop();
|
||||
this.music = this.scene.sound.add(key, {
|
||||
loop,
|
||||
volume: this.musicVolume
|
||||
});
|
||||
this.music.play();
|
||||
}
|
||||
|
||||
playSFX(key: string, config?: Phaser.Types.Sound.SoundConfig) {
|
||||
this.scene.sound.play(key, {
|
||||
volume: this.sfxVolume,
|
||||
...config
|
||||
});
|
||||
}
|
||||
|
||||
setMusicVolume(volume: number) {
|
||||
this.musicVolume = volume;
|
||||
if (this.music) this.music.setVolume(volume);
|
||||
}
|
||||
|
||||
setSFXVolume(volume: number) {
|
||||
this.sfxVolume = volume;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Sound Effects List
|
||||
|
||||
| Event | Sound Key |
|
||||
|-------|-----------|
|
||||
| Jump | `sfx_jump` |
|
||||
| Land | `sfx_land` |
|
||||
| Shoot | `sfx_shoot` |
|
||||
| Enemy stunned | `sfx_stun` |
|
||||
| Coin collected | `sfx_coin` |
|
||||
| PowerUp collected | `sfx_powerup` |
|
||||
| Player death | `sfx_death` |
|
||||
| Level complete | `sfx_level_complete` |
|
||||
| Menu select | `sfx_menu_select` |
|
||||
| Purchase | `sfx_purchase` |
|
||||
|
||||
---
|
||||
|
||||
## Save System
|
||||
|
||||
### SaveManager
|
||||
|
||||
```typescript
|
||||
// SaveManager.ts
|
||||
class SaveManager {
|
||||
private readonly SAVE_KEY = 'roguelite_platformer_save';
|
||||
|
||||
save(metaState: MetaState): void {
|
||||
const data = JSON.stringify(metaState);
|
||||
localStorage.setItem(this.SAVE_KEY, data);
|
||||
}
|
||||
|
||||
load(): MetaState | null {
|
||||
const data = localStorage.getItem(this.SAVE_KEY);
|
||||
if (!data) return null;
|
||||
|
||||
try {
|
||||
return JSON.parse(data) as MetaState;
|
||||
} catch {
|
||||
console.error('Failed to parse save data');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
reset(): void {
|
||||
localStorage.removeItem(this.SAVE_KEY);
|
||||
}
|
||||
|
||||
exists(): boolean {
|
||||
return localStorage.getItem(this.SAVE_KEY) !== null;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Data Stored
|
||||
|
||||
```typescript
|
||||
interface SaveData {
|
||||
version: string; // For migration
|
||||
metaState: MetaState;
|
||||
lastPlayed: number; // Timestamp
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## TypeScript Interfaces
|
||||
|
||||
### Core Types
|
||||
|
||||
```typescript
|
||||
// types/game-state.ts
|
||||
interface RunState {
|
||||
currentLevel: number;
|
||||
coins: number;
|
||||
totalCoinsOnLevel: number;
|
||||
score: number;
|
||||
combo: number;
|
||||
comboTimer: number;
|
||||
projectilesAvailable: number;
|
||||
projectileCooldowns: number[];
|
||||
activePowerUp: PowerUpType | null;
|
||||
powerUpTimer: number;
|
||||
hp: number;
|
||||
maxHp: number;
|
||||
hasUsedSecondChance: boolean;
|
||||
enemiesStunned: number;
|
||||
timeElapsed: number;
|
||||
levelSeed: string;
|
||||
isPaused: boolean;
|
||||
}
|
||||
|
||||
interface MetaState {
|
||||
gasCoins: number;
|
||||
purchasedUpgrades: string[];
|
||||
activeUpgrades: string[];
|
||||
achievements: Achievement[];
|
||||
stats: GlobalStats;
|
||||
highScores: HighScore[];
|
||||
settings: GameSettings;
|
||||
}
|
||||
|
||||
interface GlobalStats {
|
||||
totalCoinsCollected: number;
|
||||
totalEnemiesStunned: number;
|
||||
totalDeaths: number;
|
||||
totalLevelsCompleted: number;
|
||||
totalPlayTime: number;
|
||||
highestLevel: number;
|
||||
highestCombo: number;
|
||||
}
|
||||
|
||||
interface HighScore {
|
||||
score: number;
|
||||
level: number;
|
||||
date: number;
|
||||
seed?: string;
|
||||
}
|
||||
|
||||
interface GameSettings {
|
||||
musicVolume: number;
|
||||
sfxVolume: number;
|
||||
screenShake: boolean;
|
||||
showFPS: boolean;
|
||||
}
|
||||
```
|
||||
|
||||
### Entity Types
|
||||
|
||||
```typescript
|
||||
// types/entities.ts
|
||||
interface EnemyConfig {
|
||||
type: EnemyType;
|
||||
speed: number;
|
||||
patrolDistance?: number;
|
||||
jumpInterval?: number;
|
||||
flightPattern?: FlightPattern;
|
||||
detectionRange?: number;
|
||||
}
|
||||
|
||||
type EnemyType = 'patroller' | 'jumper' | 'flyer' | 'chaser' | 'sprinter';
|
||||
|
||||
interface HazardConfig {
|
||||
type: HazardType;
|
||||
damage: number;
|
||||
interval?: number; // For turrets, lasers
|
||||
path?: Phaser.Math.Vector2[]; // For saws
|
||||
}
|
||||
|
||||
type HazardType = 'spikes' | 'falling_platform' | 'saw' | 'turret' | 'laser';
|
||||
|
||||
type PowerUpType = 'shield' | 'magnet' | 'clock' | 'coffee' | 'infinity' | 'ghost';
|
||||
|
||||
interface PowerUpConfig {
|
||||
type: PowerUpType;
|
||||
duration: number;
|
||||
effect: () => void;
|
||||
}
|
||||
```
|
||||
|
||||
### Upgrade Types
|
||||
|
||||
```typescript
|
||||
// types/upgrades.ts
|
||||
interface Upgrade {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
category: UpgradeCategory;
|
||||
price: number;
|
||||
effects: UpgradeEffect[];
|
||||
unlockRequirement: UnlockRequirement | null;
|
||||
tradeoff?: string; // Description of downside
|
||||
}
|
||||
|
||||
type UpgradeCategory =
|
||||
| 'character'
|
||||
| 'weapon'
|
||||
| 'survival'
|
||||
| 'risk_reward'
|
||||
| 'cosmetic';
|
||||
|
||||
interface UpgradeEffect {
|
||||
type: EffectType;
|
||||
value: number;
|
||||
}
|
||||
|
||||
type EffectType =
|
||||
| 'speed_multiplier'
|
||||
| 'jump_multiplier'
|
||||
| 'extra_hp'
|
||||
| 'extra_projectile'
|
||||
| 'projectile_cooldown_multiplier'
|
||||
| 'projectile_range_multiplier'
|
||||
| 'stun_duration_multiplier'
|
||||
| 'coin_multiplier'
|
||||
| 'score_multiplier'
|
||||
| 'hitbox_multiplier'
|
||||
| 'enable_double_jump'
|
||||
| 'enable_dash'
|
||||
| 'enable_ricochet'
|
||||
| 'enable_explosive';
|
||||
|
||||
interface UnlockRequirement {
|
||||
type: 'level_reached' | 'coins_collected' | 'deaths' | 'enemies_stunned' | 'achievement';
|
||||
value: number | string;
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Visual Effects
|
||||
|
||||
### Particle System
|
||||
|
||||
```typescript
|
||||
// ParticleManager.ts
|
||||
class ParticleManager {
|
||||
private emitters: Map<string, Phaser.GameObjects.Particles.ParticleEmitter>;
|
||||
|
||||
createDustEffect(x: number, y: number) {
|
||||
this.emitters.get('dust')?.explode(5, x, y);
|
||||
}
|
||||
|
||||
createStunEffect(x: number, y: number) {
|
||||
this.emitters.get('stars')?.explode(8, x, y);
|
||||
}
|
||||
|
||||
createCoinSparkle(x: number, y: number) {
|
||||
this.emitters.get('sparkle')?.explode(3, x, y);
|
||||
}
|
||||
|
||||
createDeathEffect(x: number, y: number) {
|
||||
this.emitters.get('explosion')?.explode(20, x, y);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Screen Shake
|
||||
|
||||
```typescript
|
||||
// CameraManager.ts
|
||||
class CameraManager {
|
||||
private camera: Phaser.Cameras.Scene2D.Camera;
|
||||
private shakeEnabled: boolean = true;
|
||||
|
||||
shake(intensity: number, duration: number) {
|
||||
if (!this.shakeEnabled) return;
|
||||
this.camera.shake(duration, intensity);
|
||||
}
|
||||
|
||||
microShake() {
|
||||
this.shake(0.002, 50);
|
||||
}
|
||||
|
||||
deathShake() {
|
||||
this.shake(0.01, 200);
|
||||
}
|
||||
|
||||
setShakeEnabled(enabled: boolean) {
|
||||
this.shakeEnabled = enabled;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Squash & Stretch
|
||||
|
||||
```typescript
|
||||
// Player.ts
|
||||
jumpSquash() {
|
||||
this.setScale(0.8, 1.2);
|
||||
this.scene.tweens.add({
|
||||
targets: this,
|
||||
scaleX: 1,
|
||||
scaleY: 1,
|
||||
duration: 150,
|
||||
ease: 'Back.out',
|
||||
});
|
||||
}
|
||||
|
||||
landSquash() {
|
||||
this.setScale(1.2, 0.8);
|
||||
this.scene.tweens.add({
|
||||
targets: this,
|
||||
scaleX: 1,
|
||||
scaleY: 1,
|
||||
duration: 100,
|
||||
ease: 'Back.out',
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
### Hitstop
|
||||
|
||||
```typescript
|
||||
// GameScene.ts
|
||||
hitStop(duration: number = 50) {
|
||||
this.physics.pause();
|
||||
this.time.delayedCall(duration, () => {
|
||||
this.physics.resume();
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Performance Considerations
|
||||
|
||||
### Object Pooling
|
||||
|
||||
```typescript
|
||||
// Projectile pooling
|
||||
class ProjectilePool {
|
||||
private pool: Phaser.GameObjects.Group;
|
||||
|
||||
get(): Projectile {
|
||||
const projectile = this.pool.getFirstDead(true);
|
||||
if (projectile) {
|
||||
projectile.setActive(true).setVisible(true);
|
||||
return projectile;
|
||||
}
|
||||
return this.pool.add(new Projectile(this.scene));
|
||||
}
|
||||
|
||||
release(projectile: Projectile) {
|
||||
projectile.setActive(false).setVisible(false);
|
||||
projectile.body.stop();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Culling
|
||||
|
||||
- Entities outside viewport are deactivated
|
||||
- Physics calculations only for active entities
|
||||
- Particle systems use burst mode, not continuous
|
||||
|
||||
### Asset Loading
|
||||
|
||||
- Sprites loaded as atlases
|
||||
- Audio preloaded in PreloadScene
|
||||
- Level templates loaded on demand
|
||||
|
||||
---
|
||||
|
||||
## Testing Strategy
|
||||
|
||||
### Unit Tests
|
||||
- State management logic
|
||||
- Level generation algorithms
|
||||
- Upgrade calculations
|
||||
- Collision detection helpers
|
||||
|
||||
### Integration Tests
|
||||
- Scene transitions
|
||||
- Save/load functionality
|
||||
- Input handling
|
||||
|
||||
### Manual Testing
|
||||
- Game feel tuning
|
||||
- Balance verification
|
||||
- Performance profiling
|
||||
211
docs/CONTEXT.md
Normal file
@ -0,0 +1,211 @@
|
||||
# Project Context
|
||||
|
||||
Quick reference for agents to restore context. Updated after significant actions.
|
||||
|
||||
---
|
||||
|
||||
## Project Summary
|
||||
|
||||
**Type:** Roguelite platformer (browser-based)
|
||||
**Tech Stack:** Phaser 3 + TypeScript + Vite
|
||||
**Current Phase:** Phase 1 - Core Loop (in progress)
|
||||
|
||||
---
|
||||
|
||||
## Key Documents
|
||||
|
||||
| Document | Purpose |
|
||||
|----------|---------|
|
||||
| `CLAUDE.md` | Agent instructions, project structure |
|
||||
| `docs/REQUIREMENTS.md` | Full game design, mechanics, upgrades |
|
||||
| `docs/ARCHITECTURE.md` | Technical architecture, patterns, interfaces |
|
||||
| `docs/ROADMAP.md` | Development phases, task checklists |
|
||||
| `docs/CONTEXT.md` | This file - action log for agents |
|
||||
|
||||
---
|
||||
|
||||
## Core Mechanics (Quick Reference)
|
||||
|
||||
- **One-hit kill** platformer (by default)
|
||||
- **Stun projectiles** - 3 max, 3s cooldown each, stun enemies for 3s
|
||||
- **Collect all coins** to complete level
|
||||
- **GasCoins** - meta-currency earned from collected coins
|
||||
- **Shop** - buy upgrades between runs
|
||||
- **Procedural generation** - Spelunky-style room grid (4x4)
|
||||
|
||||
---
|
||||
|
||||
## Game Feel Constants
|
||||
|
||||
```
|
||||
Coyote Time: 100ms
|
||||
Input Buffer: 100ms
|
||||
Edge Correction: 4px
|
||||
Stun Duration: 3s (base)
|
||||
Projectile Cooldown: 3s (base)
|
||||
Max Projectiles: 3 (base)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Action Log
|
||||
|
||||
### 2025-01-17
|
||||
|
||||
**Phase 1 Core Implementation Started**
|
||||
|
||||
1. **Project Initialized**
|
||||
- Vite + TypeScript + Phaser 3 configured
|
||||
- `package.json`, `tsconfig.json`, `vite.config.ts` created
|
||||
- Path aliases (`@/`) configured
|
||||
|
||||
2. **Config Files Created**
|
||||
- `src/config/game.config.ts` - Phaser config (1280x720, Arcade Physics)
|
||||
- `src/config/physics.config.ts` - Movement speeds, gravity, timings
|
||||
- `src/config/controls.config.ts` - Key bindings, game feel constants
|
||||
- `src/config/balance.config.ts` - Scoring, level progression, spawn rates
|
||||
|
||||
3. **Type Definitions Created**
|
||||
- `src/types/game-state.ts` - RunState, MetaState interfaces
|
||||
- `src/types/entities.ts` - Enemy, Hazard, Player configs
|
||||
|
||||
4. **Base Scenes Implemented**
|
||||
- `BootScene` - Initializes registry with state
|
||||
- `PreloadScene` - Generates placeholder textures
|
||||
- `GameScene` - Core gameplay with test level
|
||||
- `UIScene` - HUD (coins, projectiles, score)
|
||||
- `GameOverScene` - Death screen with stats, GasCoin conversion
|
||||
|
||||
5. **Entities Implemented**
|
||||
- `Player` - Movement, jump with game feel (coyote time, input buffer, variable jump)
|
||||
- `Enemy` - Patroller with stun mechanic, visual indicator
|
||||
- `Coin` - Collection with animation
|
||||
- `Projectile` - Firing and collision
|
||||
|
||||
6. **Core Systems Working**
|
||||
- Player movement with responsive controls
|
||||
- Projectile system with cooldowns
|
||||
- Enemy stunning with timer
|
||||
- Coin collection and level completion
|
||||
- Death/restart cycle
|
||||
- HUD updates
|
||||
- GasCoin earning on death
|
||||
- LocalStorage save/load
|
||||
|
||||
### 2025-01-16
|
||||
|
||||
**Documentation Phase Complete**
|
||||
|
||||
1. Created `docs/ARCHITECTURE.md`
|
||||
2. Created `docs/ROADMAP.md`
|
||||
3. Created `docs/CONTEXT.md`
|
||||
|
||||
---
|
||||
|
||||
## Current State
|
||||
|
||||
```
|
||||
[x] Requirements defined (REQUIREMENTS.md)
|
||||
[x] Architecture designed (ARCHITECTURE.md)
|
||||
[x] Roadmap created (ROADMAP.md)
|
||||
[x] Project initialized (Vite + Phaser + TS)
|
||||
[x] Config files created
|
||||
[x] Type definitions created
|
||||
[x] Base scenes implemented
|
||||
[x] Player with game feel
|
||||
[x] Patroller enemy with stun
|
||||
[x] Coins and collection
|
||||
[x] Projectile system
|
||||
[x] Basic HUD
|
||||
[x] Game Over with GasCoins
|
||||
[ ] Particles and visual juice
|
||||
[ ] Audio system
|
||||
[ ] Shop scene
|
||||
[ ] More enemy types
|
||||
[ ] Procedural level generation
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Project Structure (Current)
|
||||
|
||||
```
|
||||
src/
|
||||
├── main.ts # Entry point
|
||||
├── vite-env.d.ts # Vite types
|
||||
├── config/
|
||||
│ ├── game.config.ts
|
||||
│ ├── physics.config.ts
|
||||
│ ├── controls.config.ts
|
||||
│ └── balance.config.ts
|
||||
├── types/
|
||||
│ ├── index.ts
|
||||
│ ├── game-state.ts
|
||||
│ └── entities.ts
|
||||
├── scenes/
|
||||
│ ├── BootScene.ts
|
||||
│ ├── PreloadScene.ts
|
||||
│ ├── GameScene.ts
|
||||
│ ├── UIScene.ts
|
||||
│ └── GameOverScene.ts
|
||||
└── entities/
|
||||
├── Player.ts
|
||||
├── Enemy.ts
|
||||
├── Coin.ts
|
||||
└── Projectile.ts
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Next Actions
|
||||
|
||||
1. Add particles (dust, stun stars, coin sparkle)
|
||||
2. Add screen shake options
|
||||
3. Add basic sound effects
|
||||
4. Implement ShopScene
|
||||
5. Add more enemy types (Jumper, Flyer)
|
||||
6. Implement procedural level generation
|
||||
|
||||
---
|
||||
|
||||
## Commands
|
||||
|
||||
```bash
|
||||
npm run dev # Start dev server (http://localhost:3000)
|
||||
npm run build # Production build
|
||||
npm run preview # Preview production build
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Key Decisions Made
|
||||
|
||||
| Decision | Rationale |
|
||||
|----------|-----------|
|
||||
| Phaser 3 Arcade Physics | Simple, performant, good for platformers |
|
||||
| Dual-state pattern | Clean separation of run vs persistent data |
|
||||
| Placeholder textures | Quick iteration, real assets later |
|
||||
| Registry for state | Shared state between scenes |
|
||||
| Arrow function callbacks | Cleaner collision handling |
|
||||
|
||||
---
|
||||
|
||||
## Known Issues
|
||||
|
||||
- None critical at this point
|
||||
|
||||
---
|
||||
|
||||
## How to Use This File
|
||||
|
||||
**For agents starting work:**
|
||||
1. Read this file first for quick context
|
||||
2. Check "Current State" for project status
|
||||
3. Check "Next Actions" for immediate tasks
|
||||
4. Read relevant docs (ARCHITECTURE.md, ROADMAP.md) as needed
|
||||
|
||||
**After completing work:**
|
||||
1. Add entry to "Action Log" with date
|
||||
2. Update "Current State" checkboxes
|
||||
3. Update "Next Actions" if changed
|
||||
4. Note any "Known Issues" discovered
|
||||
412
docs/REQUIREMENTS.md
Normal file
@ -0,0 +1,412 @@
|
||||
# Game Requirements
|
||||
|
||||
## Overview
|
||||
|
||||
Хардкорный roguelite-платформер с процедурной генерацией уровней. Игрок собирает монетки, избегая врагов и ловушек. Уникальная механика оружия — оглушающие "газовые" снаряды. Между забегами игрок тратит накопленную валюту на апгрейды в магазине.
|
||||
|
||||
---
|
||||
|
||||
## Core Gameplay
|
||||
|
||||
### Цель игры
|
||||
- Собрать все монетки на уровне
|
||||
- Избегать контакта с врагами и ловушками
|
||||
- Пройти как можно больше уровней
|
||||
- Накопить валюту для покупки апгрейдов
|
||||
|
||||
### Персонаж
|
||||
- Базовое управление: движение влево/вправо, прыжок
|
||||
- Оружие: выпускает оглушающие снаряды ("пуки")
|
||||
- Смерть при любом контакте с активным врагом (one-hit kill по умолчанию)
|
||||
|
||||
### Система снарядов
|
||||
- Максимум **3 снаряда** в запасе (базовое значение)
|
||||
- После использования снаряд **восстанавливается через время** (~3 сек)
|
||||
- Нельзя "спамить" — требуется тактическое использование
|
||||
- Снаряд оглушает врага при попадании
|
||||
- Направление выстрела: в сторону движения персонажа
|
||||
|
||||
### Враги
|
||||
|
||||
#### Типы врагов
|
||||
| Тип | Поведение | Появляется с уровня |
|
||||
|-----|-----------|---------------------|
|
||||
| **Патрульный** | Ходит туда-сюда по платформе | 1 |
|
||||
| **Прыгун** | Прыгает по платформам вертикально | 3 |
|
||||
| **Летун** | Летает по фиксированной траектории | 5 |
|
||||
| **Преследователь** | Медленно движется к игроку | 7 |
|
||||
| **Спринтер** | Патрульный, но быстрый | 10 |
|
||||
|
||||
#### Состояния врагов
|
||||
- **Активное**: опасны, убивают при контакте
|
||||
- **Оглушённое**: безопасны, можно проходить сквозь
|
||||
- Оглушение действует **3 секунды** (базовое значение), затем враг восстанавливается
|
||||
- Визуальный индикатор времени оглушения над врагом (круговой таймер)
|
||||
|
||||
### Ловушки
|
||||
|
||||
| Тип | Поведение | Появляется с уровня |
|
||||
|-----|-----------|---------------------|
|
||||
| **Шипы** | Статичные, мгновенная смерть | 2 |
|
||||
| **Падающая платформа** | Падает через 0.5сек после наступания | 4 |
|
||||
| **Пила** | Движется по траектории | 6 |
|
||||
| **Турель** | Стреляет снарядами с интервалом | 8 |
|
||||
| **Лазер** | Включается/выключается по таймеру | 10 |
|
||||
|
||||
### Прогрессия уровней
|
||||
- После сбора всех монеток — переход на следующий уровень
|
||||
- С каждым уровнем сложность увеличивается:
|
||||
- Больше врагов
|
||||
- Новые типы врагов
|
||||
- Появляются ловушки
|
||||
- Больше монеток (нужно больше собрать)
|
||||
- Сложнее структура уровня
|
||||
|
||||
---
|
||||
|
||||
## Game Feel (Критически важно)
|
||||
|
||||
### Coyote Time
|
||||
- Игрок может прыгнуть в течение **100мс** после схода с платформы
|
||||
- Незаметно для игрока, но убирает фрустрацию от "несправедливых" смертей
|
||||
|
||||
### Input Buffering (Jump Buffer)
|
||||
- Если прыжок нажат за **100мс** до приземления — прыжок выполнится автоматически
|
||||
- Предотвращает ощущение "съеденных" инпутов
|
||||
|
||||
### Variable Jump Height
|
||||
- Короткое нажатие = низкий прыжок
|
||||
- Длинное нажатие = высокий прыжок
|
||||
- Даёт точный контроль над персонажем
|
||||
|
||||
### Edge Correction
|
||||
- Если персонаж чуть-чуть не допрыгнул до края платформы — подтянуть на ~4 пикселя
|
||||
- Работает только для небольших расстояний
|
||||
|
||||
### Responsive Controls
|
||||
- Минимальное время разгона/торможения
|
||||
- Мгновенная смена направления
|
||||
- Никакой "скользкости"
|
||||
|
||||
---
|
||||
|
||||
## Visual Juice
|
||||
|
||||
### Частицы
|
||||
- Пыль при приземлении
|
||||
- Пыль при беге (каждые N кадров)
|
||||
- Облачко при выстреле снарядом
|
||||
- "Звёздочки" при оглушении врага
|
||||
- Блеск/свечение монеток
|
||||
- Взрыв частиц при смерти персонажа
|
||||
|
||||
### Screen Shake
|
||||
- Лёгкая тряска при смерти
|
||||
- Микро-тряска при оглушении врага
|
||||
- **Обязательно**: опция отключения в настройках
|
||||
|
||||
### Squash & Stretch
|
||||
- Персонаж вытягивается вертикально при прыжке
|
||||
- Сжимается горизонтально при приземлении
|
||||
- Враги "сплющиваются" при оглушении
|
||||
- Монетки слегка пульсируют
|
||||
|
||||
### Хитстоп (Freeze Frame)
|
||||
- Микро-пауза (2-3 кадра) при попадании снарядом во врага
|
||||
- Усиливает ощущение импакта
|
||||
|
||||
---
|
||||
|
||||
## Meta-Progression System
|
||||
|
||||
### Валюта
|
||||
- **Газокоины** — основная мета-валюта
|
||||
- Все монетки собранные за забег конвертируются в газокоины после смерти
|
||||
- Конверсия: 1 монетка = 1 газокоин
|
||||
- Бонус за пройденные уровни: +10% за каждый уровень
|
||||
|
||||
### Магазин апгрейдов
|
||||
|
||||
Философия: апгрейды **разнообразят** игру и дают **небольшие** преимущества, но НЕ делают её лёгкой. Многие апгрейды — это tradeoff'ы (плюс в одном, минус в другом).
|
||||
|
||||
#### Категория: Персонаж
|
||||
|
||||
| Апгрейд | Эффект | Цена | Примечание |
|
||||
|---------|--------|------|------------|
|
||||
| **Лёгкие ботинки** | +10% скорость бега | 100 | — |
|
||||
| **Пружинные ботинки** | +15% высота прыжка | 150 | — |
|
||||
| **Тяжёлая броня** | +1 жизнь за забег | 500 | -15% скорость |
|
||||
| **Двойной прыжок** | Можно прыгнуть в воздухе | 800 | — |
|
||||
| **Dash** | Рывок по нажатию, 2сек кулдаун | 600 | — |
|
||||
| **Скользкий** | Неуязвим 0.5сек после урона | 400 | Работает только с доп. жизнями |
|
||||
|
||||
#### Категория: Оружие
|
||||
|
||||
| Апгрейд | Эффект | Цена | Примечание |
|
||||
|---------|--------|------|------------|
|
||||
| **Большой запас** | +1 снаряд (макс. 4) | 300 | — |
|
||||
| **Быстрая перезарядка** | -20% время восстановления | 250 | — |
|
||||
| **Дальнобойность** | +30% дальность полёта снаряда | 200 | — |
|
||||
| **Мощное оглушение** | +1сек время оглушения | 350 | — |
|
||||
| **Разрывной снаряд** | Снаряд оглушает врагов в радиусе | 700 | -1 снаряд в запасе |
|
||||
| **Рикошет** | Снаряд отскакивает от стен 1 раз | 450 | — |
|
||||
| **Скорострел** | -40% время перезарядки | 400 | -30% время оглушения |
|
||||
|
||||
#### Категория: Выживание
|
||||
|
||||
| Апгрейд | Эффект | Цена | Примечание |
|
||||
|---------|--------|------|------------|
|
||||
| **Второй шанс** | 1 раз за забег: воскрешение на месте | 1000 | Одноразовый за забег |
|
||||
| **Магнит** | Монетки притягиваются с расстояния | 200 | — |
|
||||
| **Орлиный глаз** | Видно весь уровень на мини-карте | 300 | — |
|
||||
| **Чутьё опасности** | Враги подсвечиваются за экраном | 250 | — |
|
||||
| **Ловкач** | Hitbox персонажа уменьшен на 10% | 600 | — |
|
||||
|
||||
#### Категория: Риск/Награда
|
||||
|
||||
| Апгрейд | Эффект | Цена | Примечание |
|
||||
|---------|--------|------|------------|
|
||||
| **Жадность** | +50% монеток на уровне | 400 | +25% врагов |
|
||||
| **Хардкор** | x2 очки | 300 | Нет coyote time |
|
||||
| **Берсерк** | +30% скорость, бесконечные снаряды | 500 | Активируется на 10сек при 0 HP (перед смертью) |
|
||||
| **Пацифист** | x3 очки за уровень | 350 | Нельзя использовать снаряды |
|
||||
| **Спидран** | +100 очков за каждые 10сек до таймера | 200 | Таймер 60сек на уровень, смерть по истечении |
|
||||
|
||||
#### Категория: Косметика (не влияет на геймплей)
|
||||
|
||||
| Апгрейд | Эффект | Цена |
|
||||
|---------|--------|------|
|
||||
| **Скин: Космонавт** | Новый вид персонажа | 150 |
|
||||
| **Скин: Рыцарь** | Новый вид персонажа | 150 |
|
||||
| **Скин: Ниндзя** | Новый вид персонажа | 150 |
|
||||
| **След: Радуга** | Радужный след при беге | 100 |
|
||||
| **След: Огонь** | Огненный след | 100 |
|
||||
| **Снаряд: Облачко** | Другой вид снаряда | 50 |
|
||||
| **Снаряд: Сердечко** | Другой вид снаряда | 50 |
|
||||
|
||||
### Система разблокировок
|
||||
|
||||
Некоторые апгрейды требуют достижений для разблокировки покупки:
|
||||
|
||||
| Апгрейд | Требование |
|
||||
|---------|------------|
|
||||
| Двойной прыжок | Дойти до уровня 5 |
|
||||
| Dash | Собрать 500 монеток за один забег |
|
||||
| Второй шанс | Умереть 50 раз |
|
||||
| Хардкор | Пройти уровень без использования снарядов |
|
||||
| Берсерк | Оглушить 100 врагов |
|
||||
| Пацифист | Дойти до уровня 3 без снарядов |
|
||||
|
||||
### Баланс хардкорности
|
||||
|
||||
Принципы сохранения сложности:
|
||||
1. **Базовая игра остаётся one-hit kill** — доп. жизни дорогие и имеют штрафы
|
||||
2. **Tradeoff'ы** — большинство сильных апгрейдов имеют минусы
|
||||
3. **Сложность масштабируется** — чем больше апгрейдов, тем сложнее уровни
|
||||
4. **Потолок силы** — апгрейды не стакаются бесконечно
|
||||
5. **Риск/награда** — самые выгодные апгрейды усложняют игру
|
||||
|
||||
---
|
||||
|
||||
## Level Generation
|
||||
|
||||
### Подход: комнатная генерация (Spelunky-style)
|
||||
- Уровень — сетка из "комнат" (например, 4x4)
|
||||
- Каждая комната — готовый шаблон
|
||||
- Алгоритм гарантирует путь от входа до всех монеток
|
||||
- Шаблоны подбираются по сложности уровня
|
||||
|
||||
### Параметры генерации по уровням
|
||||
|
||||
| Уровень | Комнат | Монеток | Врагов | Ловушек |
|
||||
|---------|--------|---------|--------|---------|
|
||||
| 1-2 | 6-8 | 5-8 | 2-3 | 0 |
|
||||
| 3-5 | 8-10 | 8-12 | 4-6 | 1-2 |
|
||||
| 6-9 | 10-12 | 12-16 | 6-8 | 3-4 |
|
||||
| 10+ | 12-16 | 16-20 | 8-12 | 5-6 |
|
||||
|
||||
### Seed система
|
||||
- Каждый уровень имеет seed
|
||||
- Seed отображается на экране паузы
|
||||
- Можно ввести seed для воспроизведения уровня (отдельный режим, без влияния на лидерборд)
|
||||
|
||||
---
|
||||
|
||||
## Scoring System
|
||||
|
||||
### Базовые очки
|
||||
- Монетка: **10 очков**
|
||||
- Завершение уровня: **100 очков × номер уровня**
|
||||
- Оглушение врага: **5 очков**
|
||||
|
||||
### Комбо-система
|
||||
- Сбор монеток без паузы увеличивает множитель
|
||||
- Пауза >2сек сбрасывает комбо
|
||||
- Множители: x1 → x2 → x3 → x5 → x10 (макс)
|
||||
- Попадание снарядом во врага не сбрасывает комбо
|
||||
|
||||
### Бонусы за уровень
|
||||
- **Быстрое прохождение** (<30 сек): +50% очков за уровень
|
||||
- **Без урона** (если есть доп. жизни): +25% очков
|
||||
- **Без снарядов**: +100% очков
|
||||
|
||||
---
|
||||
|
||||
## UI/UX
|
||||
|
||||
### HUD (во время игры)
|
||||
- Счётчик монеток: "собрано / всего"
|
||||
- Индикатор снарядов (иконки с cooldown-анимацией)
|
||||
- Текущее комбо (если активно)
|
||||
- Номер уровня
|
||||
- Очки
|
||||
- Мини-карта (если куплен апгрейд)
|
||||
- HP (если есть доп. жизни)
|
||||
|
||||
### Экран паузы
|
||||
- Продолжить
|
||||
- Настройки
|
||||
- Seed уровня
|
||||
- Выход в меню (с подтверждением)
|
||||
|
||||
### Game Over экран
|
||||
- Финальный счёт
|
||||
- Статистика забега:
|
||||
- Пройдено уровней
|
||||
- Собрано монеток
|
||||
- Оглушено врагов
|
||||
- Время игры
|
||||
- Заработано газокоинов
|
||||
- Кнопка "В магазин"
|
||||
- Кнопка "Играть снова"
|
||||
- Таблица лидеров
|
||||
|
||||
### Главное меню
|
||||
- Играть
|
||||
- Магазин
|
||||
- Лидерборд
|
||||
- Настройки
|
||||
- Достижения
|
||||
|
||||
### Настройки
|
||||
- Громкость музыки
|
||||
- Громкость звуков
|
||||
- Screen shake: вкл/выкл
|
||||
- Показывать FPS
|
||||
- Сбросить прогресс (с подтверждением)
|
||||
|
||||
---
|
||||
|
||||
## Power-ups (внутри забега)
|
||||
|
||||
Редкие предметы, появляющиеся на уровнях:
|
||||
|
||||
| Power-up | Эффект | Длительность |
|
||||
|----------|--------|--------------|
|
||||
| **Щит** | Защита от 1 удара | До использования |
|
||||
| **Магнит** | Притягивает монетки | 15 сек |
|
||||
| **Часы** | Замедляет врагов на 50% | 10 сек |
|
||||
| **Кофе** | +50% скорость персонажа | 10 сек |
|
||||
| **Бесконечность** | Бесконечные снаряды | 8 сек |
|
||||
| **Призрак** | Проход сквозь врагов | 5 сек |
|
||||
|
||||
Появление: 10% шанс на уровне, максимум 1 power-up на уровень.
|
||||
|
||||
---
|
||||
|
||||
## Technical Requirements
|
||||
|
||||
### Платформа
|
||||
- Браузер (desktop)
|
||||
- Поддержка клавиатуры
|
||||
- Возможно: геймпад (future)
|
||||
|
||||
### Управление
|
||||
|
||||
| Действие | Клавиатура | Геймпад (future) |
|
||||
|----------|------------|------------------|
|
||||
| Движение | A/D или ←/→ | Left Stick / D-Pad |
|
||||
| Прыжок | W / ↑ / Space | A / X |
|
||||
| Стрельба | F / J / Enter | B / Square |
|
||||
| Dash (если куплен) | Shift / K | RB / R1 |
|
||||
| Пауза | Escape / P | Start |
|
||||
|
||||
### Производительность
|
||||
- 60 FPS на современных браузерах
|
||||
- Минимальное разрешение: 800x600
|
||||
- Рекомендуемое: 1280x720
|
||||
|
||||
### Хранение данных (MVP)
|
||||
- localStorage для:
|
||||
- Газокоины (валюта)
|
||||
- Купленные апгрейды
|
||||
- Активные апгрейды
|
||||
- Лидерборд (топ-10)
|
||||
- Достижения
|
||||
- Настройки
|
||||
|
||||
---
|
||||
|
||||
## MVP Scope
|
||||
|
||||
### Фаза 1: Core Loop
|
||||
- [ ] Движение персонажа с game feel (coyote time, input buffer, variable jump)
|
||||
- [ ] Система снарядов
|
||||
- [ ] Базовый враг (патрульный)
|
||||
- [ ] Механика оглушения
|
||||
- [ ] Сбор монеток
|
||||
- [ ] Процедурная генерация (простая)
|
||||
- [ ] Переход между уровнями
|
||||
- [ ] Game Over
|
||||
|
||||
### Фаза 2: Juice & Polish
|
||||
- [ ] Частицы (пыль, эффекты)
|
||||
- [ ] Squash & stretch анимации
|
||||
- [ ] Screen shake (с опцией отключения)
|
||||
- [ ] Звуковые эффекты
|
||||
- [ ] Базовая музыка
|
||||
|
||||
### Фаза 3: Meta-Progression
|
||||
- [ ] Система газокоинов
|
||||
- [ ] Магазин с апгрейдами (5-10 базовых)
|
||||
- [ ] Сохранение прогресса
|
||||
- [ ] Экран Game Over со статистикой
|
||||
|
||||
### Фаза 4: Content
|
||||
- [ ] Дополнительные типы врагов (3-4)
|
||||
- [ ] Ловушки (2-3 типа)
|
||||
- [ ] Power-ups (3-4 типа)
|
||||
- [ ] Больше апгрейдов в магазине
|
||||
- [ ] Достижения
|
||||
|
||||
### Фаза 5: Polish
|
||||
- [ ] Комбо-система
|
||||
- [ ] Лидерборд
|
||||
- [ ] Полный UI/UX
|
||||
- [ ] Баланс сложности
|
||||
- [ ] Seed система
|
||||
|
||||
### Отложено на будущее
|
||||
- [ ] Бекенд для глобального лидерборда
|
||||
- [ ] Ежедневные челленджи (один seed на день)
|
||||
- [ ] Боссы
|
||||
- [ ] Мобильная версия
|
||||
- [ ] Мультиплеер (гонка)
|
||||
- [ ] Steam-релиз
|
||||
|
||||
---
|
||||
|
||||
## Достижения
|
||||
|
||||
| Достижение | Условие | Награда |
|
||||
|------------|---------|---------|
|
||||
| Первые шаги | Пройти уровень 1 | 10 газокоинов |
|
||||
| Коллекционер | Собрать 1000 монеток (всего) | 50 газокоинов |
|
||||
| Мастер оглушения | Оглушить 100 врагов | Разблокировка "Берсерк" |
|
||||
| Пацифист | Пройти уровень без снарядов | Разблокировка "Пацифист" |
|
||||
| Марафонец | Дойти до уровня 10 | 100 газокоинов |
|
||||
| Скоростной забег | Пройти 5 уровней за 3 минуты | 75 газокоинов |
|
||||
| Неубиваемый | Пройти 3 уровня с 1HP без урона | 150 газокоинов |
|
||||
| Богач | Накопить 5000 газокоинов | Скин "Золотой" |
|
||||
| Комбо-мастер | Собрать x10 комбо | 50 газокоинов |
|
||||
| Умер 100 раз | Умереть 100 раз | Скин "Призрак" |
|
||||
466
docs/ROADMAP.md
Normal file
@ -0,0 +1,466 @@
|
||||
# Development Roadmap
|
||||
|
||||
Phased development plan for the Roguelite Platformer.
|
||||
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
| Phase | Focus | Dependencies |
|
||||
|-------|-------|--------------|
|
||||
| 1 | Core Loop | None |
|
||||
| 2 | Juice & Polish | Phase 1 |
|
||||
| 3 | Meta-Progression | Phase 1 |
|
||||
| 4 | Content | Phases 1-3 |
|
||||
| 5 | Polish & Release | Phases 1-4 |
|
||||
|
||||
---
|
||||
|
||||
## Phase 1: Core Loop
|
||||
|
||||
**Goal:** Playable prototype with basic mechanics
|
||||
|
||||
### Project Setup
|
||||
- [ ] Initialize Vite + Phaser 3 + TypeScript project
|
||||
- [ ] Configure ESLint and Prettier
|
||||
- [ ] Set up project structure (`src/`, `assets/`, `docs/`)
|
||||
- [ ] Create `game.config.ts` with Phaser configuration
|
||||
- [ ] Create `physics.config.ts` with Arcade physics settings
|
||||
|
||||
### Base Scenes
|
||||
- [ ] **BootScene** - Initialize game settings
|
||||
- [ ] **PreloadScene** - Asset loading with progress bar
|
||||
- [ ] **GameScene** - Main gameplay scene
|
||||
- [ ] **GameOverScene** - Death screen with restart option
|
||||
|
||||
### Player
|
||||
- [ ] Create `Player.ts` entity class
|
||||
- [ ] Create `PlayerController.ts` for input handling
|
||||
- [ ] Implement horizontal movement (left/right)
|
||||
- [ ] Implement jump mechanics
|
||||
- [ ] Implement **Coyote Time** (100ms grace period)
|
||||
- [ ] Implement **Input Buffering** (100ms jump buffer)
|
||||
- [ ] Implement **Variable Jump Height** (hold for higher jump)
|
||||
- [ ] Implement **Edge Correction** (4px ledge assist)
|
||||
- [ ] Add responsive controls (minimal acceleration/drag)
|
||||
|
||||
### Projectile System
|
||||
- [ ] Create `Projectile.ts` entity class
|
||||
- [ ] Implement projectile firing (direction based on player facing)
|
||||
- [ ] Implement projectile pool (max 3 active)
|
||||
- [ ] Implement cooldown system (~3 seconds per projectile)
|
||||
- [ ] Add projectile UI indicator in HUD
|
||||
|
||||
### Enemy (Patroller)
|
||||
- [ ] Create `Enemy.ts` base class
|
||||
- [ ] Create `Patroller.ts` enemy type
|
||||
- [ ] Implement patrol behavior (back-and-forth movement)
|
||||
- [ ] Implement platform edge detection
|
||||
- [ ] Implement enemy states: ACTIVE, STUNNED
|
||||
- [ ] Implement stun mechanic (3 seconds duration)
|
||||
- [ ] Add visual stun indicator (circular timer)
|
||||
- [ ] Implement collision: active enemy kills player
|
||||
- [ ] Implement collision: stunned enemy is passable
|
||||
|
||||
### Collectibles
|
||||
- [ ] Create `Coin.ts` entity class
|
||||
- [ ] Implement coin collection mechanics
|
||||
- [ ] Add coin counter to HUD
|
||||
- [ ] Implement level completion condition (all coins collected)
|
||||
|
||||
### Level Structure
|
||||
- [ ] Implement basic tilemap loading
|
||||
- [ ] Create simple test level (single room)
|
||||
- [ ] Implement player spawn point
|
||||
- [ ] Implement level exit (triggers on all coins collected)
|
||||
- [ ] Implement level transition logic
|
||||
|
||||
### Core HUD
|
||||
- [ ] Create `UIScene.ts` (parallel overlay)
|
||||
- [ ] Display coin counter (collected/total)
|
||||
- [ ] Display projectile indicators with cooldowns
|
||||
- [ ] Display current level number
|
||||
|
||||
### Game Over
|
||||
- [ ] Implement player death on enemy contact
|
||||
- [ ] Implement player death on hazard contact (spikes)
|
||||
- [ ] Show Game Over screen with score
|
||||
- [ ] Implement restart functionality
|
||||
|
||||
### Phase 1 Completion Criteria
|
||||
- [ ] Player can move, jump, and shoot
|
||||
- [ ] Game feel mechanics working (coyote time, input buffer, variable jump)
|
||||
- [ ] Patroller enemy patrols and can be stunned
|
||||
- [ ] Coins can be collected
|
||||
- [ ] Level transitions work
|
||||
- [ ] Death/restart cycle works
|
||||
|
||||
---
|
||||
|
||||
## Phase 2: Juice & Polish
|
||||
|
||||
**Goal:** Game feels good to play
|
||||
|
||||
### Particles
|
||||
- [ ] Create `ParticleManager.ts` system
|
||||
- [ ] **Dust particles** - on landing
|
||||
- [ ] **Dust particles** - while running (periodic)
|
||||
- [ ] **Projectile cloud** - on firing
|
||||
- [ ] **Stun stars** - when enemy stunned
|
||||
- [ ] **Coin sparkle** - coin idle animation
|
||||
- [ ] **Death explosion** - on player death
|
||||
|
||||
### Visual Feedback
|
||||
- [ ] Implement **Squash & Stretch** for player jump/land
|
||||
- [ ] Implement **Squash** for enemy stun
|
||||
- [ ] Add coin pulse animation
|
||||
- [ ] Add projectile trail effect
|
||||
|
||||
### Screen Effects
|
||||
- [ ] Create `CameraManager.ts` system
|
||||
- [ ] Implement **Screen Shake** - micro shake on stun
|
||||
- [ ] Implement **Screen Shake** - stronger shake on death
|
||||
- [ ] Add settings option to disable screen shake
|
||||
|
||||
### Hitstop
|
||||
- [ ] Implement **Freeze Frame** (2-3 frames) on projectile hit
|
||||
- [ ] Apply hitstop to physics pause, not game pause
|
||||
|
||||
### Audio
|
||||
- [ ] Create `AudioManager.ts` system
|
||||
- [ ] **SFX**: Jump
|
||||
- [ ] **SFX**: Land
|
||||
- [ ] **SFX**: Shoot projectile
|
||||
- [ ] **SFX**: Enemy stunned
|
||||
- [ ] **SFX**: Coin collected
|
||||
- [ ] **SFX**: Player death
|
||||
- [ ] **SFX**: Level complete
|
||||
- [ ] **SFX**: Menu selection
|
||||
- [ ] **Music**: Gameplay loop
|
||||
- [ ] **Music**: Menu theme
|
||||
- [ ] Implement volume controls
|
||||
|
||||
### Phase 2 Completion Criteria
|
||||
- [ ] All particle effects implemented
|
||||
- [ ] Squash/stretch animations working
|
||||
- [ ] Screen shake working with toggle option
|
||||
- [ ] Hitstop adds impact to hits
|
||||
- [ ] All sound effects in place
|
||||
- [ ] Background music playing
|
||||
|
||||
---
|
||||
|
||||
## Phase 3: Meta-Progression
|
||||
|
||||
**Goal:** Death -> Shop -> New Run cycle
|
||||
|
||||
### Save System
|
||||
- [ ] Create `SaveManager.ts` with localStorage
|
||||
- [ ] Implement save data structure
|
||||
- [ ] Implement save on state change
|
||||
- [ ] Implement load on game start
|
||||
- [ ] Implement save data migration (version support)
|
||||
|
||||
### State Management
|
||||
- [ ] Create `GameStateManager.ts`
|
||||
- [ ] Implement `RunState` (resets each run)
|
||||
- [ ] Implement `MetaState` (persists across runs)
|
||||
- [ ] Implement GasCoin currency system
|
||||
- [ ] Implement coin -> GasCoin conversion (1:1 + level bonus)
|
||||
|
||||
### Shop Scene
|
||||
- [ ] Create `ShopScene.ts`
|
||||
- [ ] Design shop UI layout
|
||||
- [ ] Implement upgrade display (name, description, price)
|
||||
- [ ] Implement purchase mechanics
|
||||
- [ ] Implement upgrade activation/deactivation
|
||||
- [ ] Show owned upgrades vs available upgrades
|
||||
- [ ] Show GasCoin balance
|
||||
|
||||
### Upgrade System
|
||||
- [ ] Create `UpgradeManager.ts`
|
||||
- [ ] Define `upgrades.config.ts` with all upgrades
|
||||
- [ ] Implement upgrade effect application
|
||||
- [ ] Implement 5-10 basic upgrades:
|
||||
- [ ] Light Boots (+10% speed)
|
||||
- [ ] Spring Boots (+15% jump)
|
||||
- [ ] Heavy Armor (+1 HP, -15% speed)
|
||||
- [ ] Large Magazine (+1 projectile)
|
||||
- [ ] Fast Reload (-20% cooldown)
|
||||
- [ ] Range Boost (+30% projectile range)
|
||||
- [ ] Strong Stun (+1s stun duration)
|
||||
- [ ] Magnet (coin attraction)
|
||||
- [ ] Eagle Eye (minimap)
|
||||
- [ ] Danger Sense (enemy highlight)
|
||||
|
||||
### Game Over Enhancement
|
||||
- [ ] Show run statistics:
|
||||
- [ ] Levels completed
|
||||
- [ ] Coins collected
|
||||
- [ ] Enemies stunned
|
||||
- [ ] Time played
|
||||
- [ ] Show GasCoins earned
|
||||
- [ ] Add "Go to Shop" button
|
||||
- [ ] Add "Play Again" button
|
||||
|
||||
### Phase 3 Completion Criteria
|
||||
- [ ] Progress saves correctly
|
||||
- [ ] GasCoins accumulate across runs
|
||||
- [ ] Shop allows purchasing upgrades
|
||||
- [ ] Purchased upgrades affect gameplay
|
||||
- [ ] Game Over shows stats and earnings
|
||||
|
||||
---
|
||||
|
||||
## Phase 4: Content
|
||||
|
||||
**Goal:** Gameplay variety
|
||||
|
||||
### Additional Enemies
|
||||
- [ ] **Jumper** - Vertical jumping enemy (level 3+)
|
||||
- [ ] **Flyer** - Fixed flight path enemy (level 5+)
|
||||
- [ ] **Chaser** - Slow pursuit enemy (level 7+)
|
||||
- [ ] **Sprinter** - Fast patrol enemy (level 10+)
|
||||
- [ ] Implement enemy spawn rules by level
|
||||
|
||||
### Hazards
|
||||
- [ ] Create `Hazard.ts` base class
|
||||
- [ ] **Spikes** - Static instant death (level 2+)
|
||||
- [ ] **Falling Platform** - Collapses after 0.5s (level 4+)
|
||||
- [ ] **Saw** - Moving along path (level 6+)
|
||||
- [ ] **Turret** - Shoots at intervals (level 8+)
|
||||
- [ ] **Laser** - Toggles on/off (level 10+)
|
||||
- [ ] Implement hazard spawn rules by level
|
||||
|
||||
### Power-ups
|
||||
- [ ] Create `PowerUp.ts` entity class
|
||||
- [ ] **Shield** - Blocks 1 hit
|
||||
- [ ] **Magnet** - Attracts coins (15s)
|
||||
- [ ] **Clock** - Slows enemies 50% (10s)
|
||||
- [ ] **Coffee** - +50% player speed (10s)
|
||||
- [ ] **Infinity** - Unlimited projectiles (8s)
|
||||
- [ ] **Ghost** - Phase through enemies (5s)
|
||||
- [ ] Implement 10% spawn chance per level
|
||||
- [ ] Add power-up timer to HUD
|
||||
|
||||
### Procedural Generation
|
||||
- [ ] Create `LevelGenerator.ts`
|
||||
- [ ] Create `RoomPlacer.ts` for room grid
|
||||
- [ ] Create `PathValidator.ts` for path validation
|
||||
- [ ] Design room templates (JSON)
|
||||
- [ ] Implement 4x4 room grid system
|
||||
- [ ] Implement guaranteed path algorithm
|
||||
- [ ] Implement difficulty scaling:
|
||||
- [ ] Levels 1-2: 6-8 rooms, 5-8 coins, 2-3 enemies
|
||||
- [ ] Levels 3-5: 8-10 rooms, 8-12 coins, 4-6 enemies
|
||||
- [ ] Levels 6-9: 10-12 rooms, 12-16 coins, 6-8 enemies
|
||||
- [ ] Levels 10+: 12-16 rooms, 16-20 coins, 8-12 enemies
|
||||
- [ ] Create `SeededRandom.ts` for deterministic generation
|
||||
|
||||
### More Upgrades
|
||||
- [ ] **Double Jump** - Unlock: reach level 5
|
||||
- [ ] **Dash** - Unlock: collect 500 coins in one run
|
||||
- [ ] **Second Chance** - Unlock: die 50 times
|
||||
- [ ] **Explosive Projectile** - Area stun, -1 ammo
|
||||
- [ ] **Ricochet** - Bounces off walls
|
||||
- [ ] **Rapid Fire** - -40% cooldown, -30% stun duration
|
||||
- [ ] **Greed** - +50% coins, +25% enemies
|
||||
- [ ] **Hardcore** - x2 score, no coyote time
|
||||
- [ ] **Berserker** - Frenzy mode at 0 HP
|
||||
- [ ] **Pacifist** - x3 score, no projectiles
|
||||
- [ ] **Speedrun** - Time challenge mode
|
||||
|
||||
### Achievement System
|
||||
- [ ] Create achievement tracking
|
||||
- [ ] Implement achievement triggers
|
||||
- [ ] Add achievement notifications
|
||||
- [ ] Create achievement display in menu
|
||||
- [ ] Implement unlock requirements for upgrades
|
||||
|
||||
### Phase 4 Completion Criteria
|
||||
- [ ] All 5 enemy types implemented and balanced
|
||||
- [ ] All 5 hazard types implemented
|
||||
- [ ] All 6 power-ups working
|
||||
- [ ] Procedural generation creates varied levels
|
||||
- [ ] Difficulty scales appropriately
|
||||
- [ ] Additional upgrades purchasable
|
||||
- [ ] Achievements tracking and unlocking
|
||||
|
||||
---
|
||||
|
||||
## Phase 5: Polish & Release
|
||||
|
||||
**Goal:** Release-ready product
|
||||
|
||||
### Combo System
|
||||
- [ ] Create `ScoreManager.ts`
|
||||
- [ ] Implement combo multiplier (x1 -> x2 -> x3 -> x5 -> x10)
|
||||
- [ ] Implement 2-second combo timeout
|
||||
- [ ] Add combo display to HUD
|
||||
- [ ] Implement level bonuses:
|
||||
- [ ] Fast completion (<30s): +50% score
|
||||
- [ ] No damage: +25% score
|
||||
- [ ] No projectiles: +100% score
|
||||
|
||||
### Leaderboard
|
||||
- [ ] Implement local leaderboard (top 10)
|
||||
- [ ] Create leaderboard display screen
|
||||
- [ ] Add score entry on new high score
|
||||
- [ ] Show rank on Game Over screen
|
||||
|
||||
### Full UI/UX
|
||||
- [ ] Create `MenuScene.ts` with full menu:
|
||||
- [ ] Play button
|
||||
- [ ] Shop button
|
||||
- [ ] Leaderboard button
|
||||
- [ ] Settings button
|
||||
- [ ] Achievements button
|
||||
- [ ] Create `PauseScene.ts`:
|
||||
- [ ] Continue button
|
||||
- [ ] Settings button
|
||||
- [ ] Show current seed
|
||||
- [ ] Quit to menu (with confirmation)
|
||||
- [ ] Polish all UI transitions
|
||||
- [ ] Add button hover/click feedback
|
||||
|
||||
### Seed System
|
||||
- [ ] Display level seed on pause screen
|
||||
- [ ] Implement seed input mode
|
||||
- [ ] Add "Practice Mode" (seeded, no leaderboard)
|
||||
|
||||
### Settings
|
||||
- [ ] Music volume slider
|
||||
- [ ] SFX volume slider
|
||||
- [ ] Screen shake toggle
|
||||
- [ ] Show FPS toggle
|
||||
- [ ] Reset progress (with confirmation)
|
||||
|
||||
### Balance Pass
|
||||
- [ ] Tune player movement speeds
|
||||
- [ ] Tune jump heights
|
||||
- [ ] Tune projectile cooldowns
|
||||
- [ ] Tune stun durations
|
||||
- [ ] Tune enemy speeds and behaviors
|
||||
- [ ] Tune upgrade costs
|
||||
- [ ] Tune difficulty scaling
|
||||
- [ ] Playtest and iterate
|
||||
|
||||
### Bug Fixing & QA
|
||||
- [ ] Fix known bugs
|
||||
- [ ] Test all features end-to-end
|
||||
- [ ] Test save/load edge cases
|
||||
- [ ] Test on multiple browsers
|
||||
- [ ] Performance optimization
|
||||
- [ ] Memory leak checks
|
||||
|
||||
### Phase 5 Completion Criteria
|
||||
- [ ] Combo system adds depth to gameplay
|
||||
- [ ] Leaderboard encourages replayability
|
||||
- [ ] Full menu navigation working
|
||||
- [ ] Seed system allows practice
|
||||
- [ ] Settings all functional
|
||||
- [ ] Game balanced and fair
|
||||
- [ ] No critical bugs
|
||||
|
||||
---
|
||||
|
||||
## Future (Post-MVP)
|
||||
|
||||
### Backend Integration
|
||||
- [ ] Global leaderboard API
|
||||
- [ ] User accounts (optional)
|
||||
- [ ] Cloud save sync
|
||||
|
||||
### Daily Challenges
|
||||
- [ ] Daily seed generation
|
||||
- [ ] Separate daily leaderboard
|
||||
- [ ] Daily rewards
|
||||
|
||||
### Bosses
|
||||
- [ ] Design boss mechanics
|
||||
- [ ] Implement boss encounters (every 5 levels?)
|
||||
- [ ] Boss-specific rewards
|
||||
|
||||
### Mobile Support
|
||||
- [ ] Touch controls
|
||||
- [ ] UI scaling
|
||||
- [ ] Mobile-specific optimizations
|
||||
|
||||
### Multiplayer
|
||||
- [ ] Race mode (2 players)
|
||||
- [ ] Shared leaderboard
|
||||
- [ ] Ghost replays
|
||||
|
||||
### Platform Release
|
||||
- [ ] Steam integration
|
||||
- [ ] Achievements (Steam)
|
||||
- [ ] Cloud saves (Steam)
|
||||
|
||||
---
|
||||
|
||||
## Task Dependencies
|
||||
|
||||
```
|
||||
Phase 1 (Core Loop)
|
||||
│
|
||||
├──────────────────┐
|
||||
│ │
|
||||
▼ ▼
|
||||
Phase 2 Phase 3
|
||||
(Juice) (Meta-Progression)
|
||||
│ │
|
||||
└─────────┬────────┘
|
||||
│
|
||||
▼
|
||||
Phase 4 (Content)
|
||||
│
|
||||
▼
|
||||
Phase 5 (Polish)
|
||||
│
|
||||
▼
|
||||
RELEASE
|
||||
│
|
||||
▼
|
||||
Future Updates
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Risk Mitigation
|
||||
|
||||
| Risk | Mitigation |
|
||||
|------|------------|
|
||||
| Scope creep | Stick to MVP features per phase |
|
||||
| Game feel issues | Prioritize Phase 2 polish early |
|
||||
| Balance problems | Iterative testing each phase |
|
||||
| Save data corruption | Version migrations, backup system |
|
||||
| Performance issues | Object pooling, culling from start |
|
||||
|
||||
---
|
||||
|
||||
## Success Metrics
|
||||
|
||||
### Phase 1
|
||||
- Can play multiple rounds
|
||||
- Death/restart cycle smooth
|
||||
- Player movement feels responsive
|
||||
|
||||
### Phase 2
|
||||
- Game "feels good" to play
|
||||
- Feedback is satisfying
|
||||
- Audio enhances experience
|
||||
|
||||
### Phase 3
|
||||
- Players want to unlock upgrades
|
||||
- Meta loop is engaging
|
||||
- Progress feels meaningful
|
||||
|
||||
### Phase 4
|
||||
- Variety keeps runs interesting
|
||||
- Difficulty curve is fair
|
||||
- Content feels sufficient
|
||||
|
||||
### Phase 5
|
||||
- No critical bugs
|
||||
- Performance is stable
|
||||
- Ready for public release
|
||||
26
eslint.config.js
Normal file
@ -0,0 +1,26 @@
|
||||
import eslint from '@eslint/js';
|
||||
import tseslint from 'typescript-eslint';
|
||||
import prettier from 'eslint-plugin-prettier/recommended';
|
||||
|
||||
export default tseslint.config(
|
||||
eslint.configs.recommended,
|
||||
...tseslint.configs.recommended,
|
||||
prettier,
|
||||
{
|
||||
ignores: ['dist/**', 'node_modules/**'],
|
||||
},
|
||||
{
|
||||
files: ['**/*.ts'],
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
project: './tsconfig.json',
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
|
||||
'@typescript-eslint/explicit-function-return-type': 'off',
|
||||
'@typescript-eslint/no-explicit-any': 'warn',
|
||||
'no-console': 'off',
|
||||
},
|
||||
}
|
||||
);
|
||||
31
index.html
Normal file
@ -0,0 +1,31 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Roguelite Platformer</title>
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
body {
|
||||
background-color: #1a1a2e;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
overflow: hidden;
|
||||
}
|
||||
#game-container {
|
||||
border: 2px solid #4a4a6a;
|
||||
border-radius: 4px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="game-container"></div>
|
||||
<script type="module" src="/src/main.ts"></script>
|
||||
</body>
|
||||
</html>
|
||||
40
k8s/deployment.yaml
Normal file
@ -0,0 +1,40 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: chicken-game
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: chicken-game
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: chicken-game
|
||||
spec:
|
||||
imagePullSecrets:
|
||||
- name: harbor-creds
|
||||
containers:
|
||||
- name: chicken-game
|
||||
image: __IMAGE__
|
||||
ports:
|
||||
- containerPort: 80
|
||||
resources:
|
||||
requests:
|
||||
memory: "64Mi"
|
||||
cpu: "50m"
|
||||
limits:
|
||||
memory: "128Mi"
|
||||
cpu: "100m"
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: 80
|
||||
initialDelaySeconds: 10
|
||||
periodSeconds: 10
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: 80
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 5
|
||||
24
k8s/ingress.yaml
Normal file
@ -0,0 +1,24 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: chicken-game-ingress
|
||||
annotations:
|
||||
traefik.ingress.kubernetes.io/router.entrypoints: websecure
|
||||
traefik.ingress.kubernetes.io/router.tls: "true"
|
||||
spec:
|
||||
ingressClassName: traefik
|
||||
tls:
|
||||
- hosts:
|
||||
- __HOSTNAME__
|
||||
secretName: __SECRET_NAME__
|
||||
rules:
|
||||
- host: __HOSTNAME__
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: chicken-game-service
|
||||
port:
|
||||
number: 80
|
||||
12
k8s/service.yaml
Normal file
@ -0,0 +1,12 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: chicken-game-service
|
||||
spec:
|
||||
selector:
|
||||
app: chicken-game
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 80
|
||||
targetPort: 80
|
||||
type: ClusterIP
|
||||
49
nginx.conf
Normal file
@ -0,0 +1,49 @@
|
||||
events {}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
# Logging
|
||||
access_log /var/log/nginx/access.log;
|
||||
error_log /var/log/nginx/error.log;
|
||||
|
||||
# Performance
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
keepalive_timeout 65;
|
||||
types_hash_max_size 2048;
|
||||
|
||||
# Gzip compression
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_min_length 1024;
|
||||
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml+rss application/json application/javascript;
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
# Health check endpoint for k8s
|
||||
location /health {
|
||||
access_log off;
|
||||
return 200 "healthy\n";
|
||||
add_header Content-Type text/plain;
|
||||
}
|
||||
|
||||
# SPA fallback - all routes go to index.html
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
# Static assets with caching
|
||||
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot|mp3|ogg|wav)$ {
|
||||
expires 1y;
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
}
|
||||
}
|
||||
1
node_modules/.bin/acorn
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../acorn/bin/acorn
|
||||
1
node_modules/.bin/esbuild
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../esbuild/bin/esbuild
|
||||
1
node_modules/.bin/eslint
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../eslint/bin/eslint.js
|
||||
1
node_modules/.bin/eslint-config-prettier
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../eslint-config-prettier/bin/cli.js
|
||||
1
node_modules/.bin/js-yaml
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../js-yaml/bin/js-yaml.js
|
||||
1
node_modules/.bin/nanoid
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../nanoid/bin/nanoid.cjs
|
||||
1
node_modules/.bin/node-which
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../which/bin/node-which
|
||||
1
node_modules/.bin/prettier
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../prettier/bin/prettier.cjs
|
||||
1
node_modules/.bin/rollup
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../rollup/dist/bin/rollup
|
||||
1
node_modules/.bin/semver
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../semver/bin/semver.js
|
||||
1
node_modules/.bin/tsc
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../typescript/bin/tsc
|
||||
1
node_modules/.bin/tsserver
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../typescript/bin/tsserver
|
||||
1
node_modules/.bin/vite
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../vite/bin/vite.js
|
||||
1901
node_modules/.package-lock.json
generated
vendored
Normal file
15
node_modules/.vite/deps/_metadata.json
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"hash": "2f8f9078",
|
||||
"configHash": "b31a3159",
|
||||
"lockfileHash": "55dffb38",
|
||||
"browserHash": "9ab18f69",
|
||||
"optimized": {
|
||||
"phaser": {
|
||||
"src": "../../phaser/dist/phaser.js",
|
||||
"file": "phaser.js",
|
||||
"fileHash": "211792ef",
|
||||
"needsInterop": true
|
||||
}
|
||||
},
|
||||
"chunks": {}
|
||||
}
|
||||
3
node_modules/.vite/deps/package.json
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "module"
|
||||
}
|
||||
139279
node_modules/.vite/deps/phaser.js
generated
vendored
Normal file
7
node_modules/.vite/deps/phaser.js.map
generated
vendored
Normal file
3
node_modules/@esbuild/darwin-arm64/README.md
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
# esbuild
|
||||
|
||||
This is the macOS ARM 64-bit binary for esbuild, a JavaScript bundler and minifier. See https://github.com/evanw/esbuild for details.
|
||||
BIN
node_modules/@esbuild/darwin-arm64/bin/esbuild
generated
vendored
Executable file
20
node_modules/@esbuild/darwin-arm64/package.json
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "@esbuild/darwin-arm64",
|
||||
"version": "0.21.5",
|
||||
"description": "The macOS ARM 64-bit binary for esbuild, a JavaScript bundler.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/evanw/esbuild.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"preferUnplugged": true,
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"cpu": [
|
||||
"arm64"
|
||||
]
|
||||
}
|
||||
21
node_modules/@eslint-community/eslint-utils/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 Toru Nagashima
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
37
node_modules/@eslint-community/eslint-utils/README.md
generated
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
# @eslint-community/eslint-utils
|
||||
|
||||
[](https://www.npmjs.com/package/@eslint-community/eslint-utils)
|
||||
[](http://www.npmtrends.com/@eslint-community/eslint-utils)
|
||||
[](https://github.com/eslint-community/eslint-utils/actions)
|
||||
[](https://codecov.io/gh/eslint-community/eslint-utils)
|
||||
|
||||
## 🏁 Goal
|
||||
|
||||
This package provides utility functions and classes for make ESLint custom rules.
|
||||
|
||||
For examples:
|
||||
|
||||
- [`getStaticValue`](https://eslint-community.github.io/eslint-utils/api/ast-utils.html#getstaticvalue) evaluates static value on AST.
|
||||
- [`ReferenceTracker`](https://eslint-community.github.io/eslint-utils/api/scope-utils.html#referencetracker-class) checks the members of modules/globals as handling assignments and destructuring.
|
||||
|
||||
## 📖 Usage
|
||||
|
||||
See [documentation](https://eslint-community.github.io/eslint-utils).
|
||||
|
||||
## 📰 Changelog
|
||||
|
||||
See [releases](https://github.com/eslint-community/eslint-utils/releases).
|
||||
|
||||
## ❤️ Contributing
|
||||
|
||||
Welcome contributing!
|
||||
|
||||
Please use GitHub's Issues/PRs.
|
||||
|
||||
### Development Tools
|
||||
|
||||
- `npm run test-coverage` runs tests and measures coverage.
|
||||
- `npm run clean` removes the coverage result of `npm run test-coverage` command.
|
||||
- `npm run coverage` shows the coverage result of the last `npm run test-coverage` command.
|
||||
- `npm run lint` runs ESLint.
|
||||
- `npm run watch` runs tests on each file change.
|
||||
217
node_modules/@eslint-community/eslint-utils/index.d.mts
generated
vendored
Normal file
@ -0,0 +1,217 @@
|
||||
import * as eslint from 'eslint';
|
||||
import { Rule, AST } from 'eslint';
|
||||
import * as estree from 'estree';
|
||||
|
||||
declare const READ: unique symbol;
|
||||
declare const CALL: unique symbol;
|
||||
declare const CONSTRUCT: unique symbol;
|
||||
declare const ESM: unique symbol;
|
||||
declare class ReferenceTracker {
|
||||
constructor(globalScope: Scope$2, options?: {
|
||||
mode?: "legacy" | "strict" | undefined;
|
||||
globalObjectNames?: string[] | undefined;
|
||||
} | undefined);
|
||||
private variableStack;
|
||||
private globalScope;
|
||||
private mode;
|
||||
private globalObjectNames;
|
||||
iterateGlobalReferences<T>(traceMap: TraceMap$2<T>): IterableIterator<TrackedReferences$2<T>>;
|
||||
iterateCjsReferences<T_1>(traceMap: TraceMap$2<T_1>): IterableIterator<TrackedReferences$2<T_1>>;
|
||||
iterateEsmReferences<T_2>(traceMap: TraceMap$2<T_2>): IterableIterator<TrackedReferences$2<T_2>>;
|
||||
iteratePropertyReferences<T_3>(node: Expression, traceMap: TraceMap$2<T_3>): IterableIterator<TrackedReferences$2<T_3>>;
|
||||
private _iterateVariableReferences;
|
||||
private _iteratePropertyReferences;
|
||||
private _iterateLhsReferences;
|
||||
private _iterateImportReferences;
|
||||
}
|
||||
declare namespace ReferenceTracker {
|
||||
export { READ };
|
||||
export { CALL };
|
||||
export { CONSTRUCT };
|
||||
export { ESM };
|
||||
}
|
||||
type Scope$2 = eslint.Scope.Scope;
|
||||
type Expression = estree.Expression;
|
||||
type TraceMap$2<T> = TraceMap$1<T>;
|
||||
type TrackedReferences$2<T> = TrackedReferences$1<T>;
|
||||
|
||||
type StaticValue$2 = StaticValueProvided$1 | StaticValueOptional$1;
|
||||
type StaticValueProvided$1 = {
|
||||
optional?: undefined;
|
||||
value: unknown;
|
||||
};
|
||||
type StaticValueOptional$1 = {
|
||||
optional?: true;
|
||||
value: undefined;
|
||||
};
|
||||
type ReferenceTrackerOptions$1 = {
|
||||
globalObjectNames?: string[];
|
||||
mode?: "legacy" | "strict";
|
||||
};
|
||||
type TraceMap$1<T = unknown> = {
|
||||
[i: string]: TraceMapObject<T>;
|
||||
};
|
||||
type TraceMapObject<T> = {
|
||||
[i: string]: TraceMapObject<T>;
|
||||
[CALL]?: T;
|
||||
[CONSTRUCT]?: T;
|
||||
[READ]?: T;
|
||||
[ESM]?: boolean;
|
||||
};
|
||||
type TrackedReferences$1<T> = {
|
||||
info: T;
|
||||
node: Rule.Node;
|
||||
path: string[];
|
||||
type: typeof CALL | typeof CONSTRUCT | typeof READ;
|
||||
};
|
||||
type HasSideEffectOptions$1 = {
|
||||
considerGetters?: boolean;
|
||||
considerImplicitTypeConversion?: boolean;
|
||||
};
|
||||
type PunctuatorToken<Value extends string> = AST.Token & {
|
||||
type: "Punctuator";
|
||||
value: Value;
|
||||
};
|
||||
type ArrowToken$1 = PunctuatorToken<"=>">;
|
||||
type CommaToken$1 = PunctuatorToken<",">;
|
||||
type SemicolonToken$1 = PunctuatorToken<";">;
|
||||
type ColonToken$1 = PunctuatorToken<":">;
|
||||
type OpeningParenToken$1 = PunctuatorToken<"(">;
|
||||
type ClosingParenToken$1 = PunctuatorToken<")">;
|
||||
type OpeningBracketToken$1 = PunctuatorToken<"[">;
|
||||
type ClosingBracketToken$1 = PunctuatorToken<"]">;
|
||||
type OpeningBraceToken$1 = PunctuatorToken<"{">;
|
||||
type ClosingBraceToken$1 = PunctuatorToken<"}">;
|
||||
|
||||
declare function findVariable(initialScope: Scope$1, nameOrNode: string | Identifier): Variable | null;
|
||||
type Scope$1 = eslint.Scope.Scope;
|
||||
type Variable = eslint.Scope.Variable;
|
||||
type Identifier = estree.Identifier;
|
||||
|
||||
declare function getFunctionHeadLocation(node: FunctionNode$1, sourceCode: SourceCode$2): SourceLocation | null;
|
||||
type SourceCode$2 = eslint.SourceCode;
|
||||
type FunctionNode$1 = estree.Function;
|
||||
type SourceLocation = estree.SourceLocation;
|
||||
|
||||
declare function getFunctionNameWithKind(node: FunctionNode, sourceCode?: eslint.SourceCode | undefined): string;
|
||||
type FunctionNode = estree.Function;
|
||||
|
||||
declare function getInnermostScope(initialScope: Scope, node: Node$4): Scope;
|
||||
type Scope = eslint.Scope.Scope;
|
||||
type Node$4 = estree.Node;
|
||||
|
||||
declare function getPropertyName(node: MemberExpression | MethodDefinition | Property | PropertyDefinition, initialScope?: eslint.Scope.Scope | undefined): string | null | undefined;
|
||||
type MemberExpression = estree.MemberExpression;
|
||||
type MethodDefinition = estree.MethodDefinition;
|
||||
type Property = estree.Property;
|
||||
type PropertyDefinition = estree.PropertyDefinition;
|
||||
|
||||
declare function getStaticValue(node: Node$3, initialScope?: eslint.Scope.Scope | null | undefined): StaticValue$1 | null;
|
||||
type StaticValue$1 = StaticValue$2;
|
||||
type Node$3 = estree.Node;
|
||||
|
||||
declare function getStringIfConstant(node: Node$2, initialScope?: eslint.Scope.Scope | null | undefined): string | null;
|
||||
type Node$2 = estree.Node;
|
||||
|
||||
declare function hasSideEffect(node: Node$1, sourceCode: SourceCode$1, options?: HasSideEffectOptions$1 | undefined): boolean;
|
||||
type Node$1 = estree.Node;
|
||||
type SourceCode$1 = eslint.SourceCode;
|
||||
|
||||
declare function isArrowToken(token: CommentOrToken): token is ArrowToken$1;
|
||||
declare function isCommaToken(token: CommentOrToken): token is CommaToken$1;
|
||||
declare function isSemicolonToken(token: CommentOrToken): token is SemicolonToken$1;
|
||||
declare function isColonToken(token: CommentOrToken): token is ColonToken$1;
|
||||
declare function isOpeningParenToken(token: CommentOrToken): token is OpeningParenToken$1;
|
||||
declare function isClosingParenToken(token: CommentOrToken): token is ClosingParenToken$1;
|
||||
declare function isOpeningBracketToken(token: CommentOrToken): token is OpeningBracketToken$1;
|
||||
declare function isClosingBracketToken(token: CommentOrToken): token is ClosingBracketToken$1;
|
||||
declare function isOpeningBraceToken(token: CommentOrToken): token is OpeningBraceToken$1;
|
||||
declare function isClosingBraceToken(token: CommentOrToken): token is ClosingBraceToken$1;
|
||||
declare function isCommentToken(token: CommentOrToken): token is estree.Comment;
|
||||
declare function isNotArrowToken(arg0: CommentOrToken): boolean;
|
||||
declare function isNotCommaToken(arg0: CommentOrToken): boolean;
|
||||
declare function isNotSemicolonToken(arg0: CommentOrToken): boolean;
|
||||
declare function isNotColonToken(arg0: CommentOrToken): boolean;
|
||||
declare function isNotOpeningParenToken(arg0: CommentOrToken): boolean;
|
||||
declare function isNotClosingParenToken(arg0: CommentOrToken): boolean;
|
||||
declare function isNotOpeningBracketToken(arg0: CommentOrToken): boolean;
|
||||
declare function isNotClosingBracketToken(arg0: CommentOrToken): boolean;
|
||||
declare function isNotOpeningBraceToken(arg0: CommentOrToken): boolean;
|
||||
declare function isNotClosingBraceToken(arg0: CommentOrToken): boolean;
|
||||
declare function isNotCommentToken(arg0: CommentOrToken): boolean;
|
||||
type Token = eslint.AST.Token;
|
||||
type Comment = estree.Comment;
|
||||
type CommentOrToken = Comment | Token;
|
||||
|
||||
declare function isParenthesized(timesOrNode: Node | number, nodeOrSourceCode: Node | SourceCode, optionalSourceCode?: eslint.SourceCode | undefined): boolean;
|
||||
type Node = estree.Node;
|
||||
type SourceCode = eslint.SourceCode;
|
||||
|
||||
declare class PatternMatcher {
|
||||
constructor(pattern: RegExp, options?: {
|
||||
escaped?: boolean | undefined;
|
||||
} | undefined);
|
||||
execAll(str: string): IterableIterator<RegExpExecArray>;
|
||||
test(str: string): boolean;
|
||||
[Symbol.replace](str: string, replacer: string | ((...strs: string[]) => string)): string;
|
||||
}
|
||||
|
||||
declare namespace _default {
|
||||
export { CALL };
|
||||
export { CONSTRUCT };
|
||||
export { ESM };
|
||||
export { findVariable };
|
||||
export { getFunctionHeadLocation };
|
||||
export { getFunctionNameWithKind };
|
||||
export { getInnermostScope };
|
||||
export { getPropertyName };
|
||||
export { getStaticValue };
|
||||
export { getStringIfConstant };
|
||||
export { hasSideEffect };
|
||||
export { isArrowToken };
|
||||
export { isClosingBraceToken };
|
||||
export { isClosingBracketToken };
|
||||
export { isClosingParenToken };
|
||||
export { isColonToken };
|
||||
export { isCommaToken };
|
||||
export { isCommentToken };
|
||||
export { isNotArrowToken };
|
||||
export { isNotClosingBraceToken };
|
||||
export { isNotClosingBracketToken };
|
||||
export { isNotClosingParenToken };
|
||||
export { isNotColonToken };
|
||||
export { isNotCommaToken };
|
||||
export { isNotCommentToken };
|
||||
export { isNotOpeningBraceToken };
|
||||
export { isNotOpeningBracketToken };
|
||||
export { isNotOpeningParenToken };
|
||||
export { isNotSemicolonToken };
|
||||
export { isOpeningBraceToken };
|
||||
export { isOpeningBracketToken };
|
||||
export { isOpeningParenToken };
|
||||
export { isParenthesized };
|
||||
export { isSemicolonToken };
|
||||
export { PatternMatcher };
|
||||
export { READ };
|
||||
export { ReferenceTracker };
|
||||
}
|
||||
|
||||
type StaticValue = StaticValue$2;
|
||||
type StaticValueOptional = StaticValueOptional$1;
|
||||
type StaticValueProvided = StaticValueProvided$1;
|
||||
type ReferenceTrackerOptions = ReferenceTrackerOptions$1;
|
||||
type TraceMap<T> = TraceMap$1<T>;
|
||||
type TrackedReferences<T> = TrackedReferences$1<T>;
|
||||
type HasSideEffectOptions = HasSideEffectOptions$1;
|
||||
type ArrowToken = ArrowToken$1;
|
||||
type CommaToken = CommaToken$1;
|
||||
type SemicolonToken = SemicolonToken$1;
|
||||
type ColonToken = ColonToken$1;
|
||||
type OpeningParenToken = OpeningParenToken$1;
|
||||
type ClosingParenToken = ClosingParenToken$1;
|
||||
type OpeningBracketToken = OpeningBracketToken$1;
|
||||
type ClosingBracketToken = ClosingBracketToken$1;
|
||||
type OpeningBraceToken = OpeningBraceToken$1;
|
||||
type ClosingBraceToken = ClosingBraceToken$1;
|
||||
|
||||
export { ArrowToken, CALL, CONSTRUCT, ClosingBraceToken, ClosingBracketToken, ClosingParenToken, ColonToken, CommaToken, ESM, HasSideEffectOptions, OpeningBraceToken, OpeningBracketToken, OpeningParenToken, PatternMatcher, READ, ReferenceTracker, ReferenceTrackerOptions, SemicolonToken, StaticValue, StaticValueOptional, StaticValueProvided, TraceMap, TrackedReferences, _default as default, findVariable, getFunctionHeadLocation, getFunctionNameWithKind, getInnermostScope, getPropertyName, getStaticValue, getStringIfConstant, hasSideEffect, isArrowToken, isClosingBraceToken, isClosingBracketToken, isClosingParenToken, isColonToken, isCommaToken, isCommentToken, isNotArrowToken, isNotClosingBraceToken, isNotClosingBracketToken, isNotClosingParenToken, isNotColonToken, isNotCommaToken, isNotCommentToken, isNotOpeningBraceToken, isNotOpeningBracketToken, isNotOpeningParenToken, isNotSemicolonToken, isOpeningBraceToken, isOpeningBracketToken, isOpeningParenToken, isParenthesized, isSemicolonToken };
|
||||
217
node_modules/@eslint-community/eslint-utils/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,217 @@
|
||||
import * as eslint from 'eslint';
|
||||
import { Rule, AST } from 'eslint';
|
||||
import * as estree from 'estree';
|
||||
|
||||
declare const READ: unique symbol;
|
||||
declare const CALL: unique symbol;
|
||||
declare const CONSTRUCT: unique symbol;
|
||||
declare const ESM: unique symbol;
|
||||
declare class ReferenceTracker {
|
||||
constructor(globalScope: Scope$2, options?: {
|
||||
mode?: "legacy" | "strict" | undefined;
|
||||
globalObjectNames?: string[] | undefined;
|
||||
} | undefined);
|
||||
private variableStack;
|
||||
private globalScope;
|
||||
private mode;
|
||||
private globalObjectNames;
|
||||
iterateGlobalReferences<T>(traceMap: TraceMap$2<T>): IterableIterator<TrackedReferences$2<T>>;
|
||||
iterateCjsReferences<T_1>(traceMap: TraceMap$2<T_1>): IterableIterator<TrackedReferences$2<T_1>>;
|
||||
iterateEsmReferences<T_2>(traceMap: TraceMap$2<T_2>): IterableIterator<TrackedReferences$2<T_2>>;
|
||||
iteratePropertyReferences<T_3>(node: Expression, traceMap: TraceMap$2<T_3>): IterableIterator<TrackedReferences$2<T_3>>;
|
||||
private _iterateVariableReferences;
|
||||
private _iteratePropertyReferences;
|
||||
private _iterateLhsReferences;
|
||||
private _iterateImportReferences;
|
||||
}
|
||||
declare namespace ReferenceTracker {
|
||||
export { READ };
|
||||
export { CALL };
|
||||
export { CONSTRUCT };
|
||||
export { ESM };
|
||||
}
|
||||
type Scope$2 = eslint.Scope.Scope;
|
||||
type Expression = estree.Expression;
|
||||
type TraceMap$2<T> = TraceMap$1<T>;
|
||||
type TrackedReferences$2<T> = TrackedReferences$1<T>;
|
||||
|
||||
type StaticValue$2 = StaticValueProvided$1 | StaticValueOptional$1;
|
||||
type StaticValueProvided$1 = {
|
||||
optional?: undefined;
|
||||
value: unknown;
|
||||
};
|
||||
type StaticValueOptional$1 = {
|
||||
optional?: true;
|
||||
value: undefined;
|
||||
};
|
||||
type ReferenceTrackerOptions$1 = {
|
||||
globalObjectNames?: string[];
|
||||
mode?: "legacy" | "strict";
|
||||
};
|
||||
type TraceMap$1<T = unknown> = {
|
||||
[i: string]: TraceMapObject<T>;
|
||||
};
|
||||
type TraceMapObject<T> = {
|
||||
[i: string]: TraceMapObject<T>;
|
||||
[CALL]?: T;
|
||||
[CONSTRUCT]?: T;
|
||||
[READ]?: T;
|
||||
[ESM]?: boolean;
|
||||
};
|
||||
type TrackedReferences$1<T> = {
|
||||
info: T;
|
||||
node: Rule.Node;
|
||||
path: string[];
|
||||
type: typeof CALL | typeof CONSTRUCT | typeof READ;
|
||||
};
|
||||
type HasSideEffectOptions$1 = {
|
||||
considerGetters?: boolean;
|
||||
considerImplicitTypeConversion?: boolean;
|
||||
};
|
||||
type PunctuatorToken<Value extends string> = AST.Token & {
|
||||
type: "Punctuator";
|
||||
value: Value;
|
||||
};
|
||||
type ArrowToken$1 = PunctuatorToken<"=>">;
|
||||
type CommaToken$1 = PunctuatorToken<",">;
|
||||
type SemicolonToken$1 = PunctuatorToken<";">;
|
||||
type ColonToken$1 = PunctuatorToken<":">;
|
||||
type OpeningParenToken$1 = PunctuatorToken<"(">;
|
||||
type ClosingParenToken$1 = PunctuatorToken<")">;
|
||||
type OpeningBracketToken$1 = PunctuatorToken<"[">;
|
||||
type ClosingBracketToken$1 = PunctuatorToken<"]">;
|
||||
type OpeningBraceToken$1 = PunctuatorToken<"{">;
|
||||
type ClosingBraceToken$1 = PunctuatorToken<"}">;
|
||||
|
||||
declare function findVariable(initialScope: Scope$1, nameOrNode: string | Identifier): Variable | null;
|
||||
type Scope$1 = eslint.Scope.Scope;
|
||||
type Variable = eslint.Scope.Variable;
|
||||
type Identifier = estree.Identifier;
|
||||
|
||||
declare function getFunctionHeadLocation(node: FunctionNode$1, sourceCode: SourceCode$2): SourceLocation | null;
|
||||
type SourceCode$2 = eslint.SourceCode;
|
||||
type FunctionNode$1 = estree.Function;
|
||||
type SourceLocation = estree.SourceLocation;
|
||||
|
||||
declare function getFunctionNameWithKind(node: FunctionNode, sourceCode?: eslint.SourceCode | undefined): string;
|
||||
type FunctionNode = estree.Function;
|
||||
|
||||
declare function getInnermostScope(initialScope: Scope, node: Node$4): Scope;
|
||||
type Scope = eslint.Scope.Scope;
|
||||
type Node$4 = estree.Node;
|
||||
|
||||
declare function getPropertyName(node: MemberExpression | MethodDefinition | Property | PropertyDefinition, initialScope?: eslint.Scope.Scope | undefined): string | null | undefined;
|
||||
type MemberExpression = estree.MemberExpression;
|
||||
type MethodDefinition = estree.MethodDefinition;
|
||||
type Property = estree.Property;
|
||||
type PropertyDefinition = estree.PropertyDefinition;
|
||||
|
||||
declare function getStaticValue(node: Node$3, initialScope?: eslint.Scope.Scope | null | undefined): StaticValue$1 | null;
|
||||
type StaticValue$1 = StaticValue$2;
|
||||
type Node$3 = estree.Node;
|
||||
|
||||
declare function getStringIfConstant(node: Node$2, initialScope?: eslint.Scope.Scope | null | undefined): string | null;
|
||||
type Node$2 = estree.Node;
|
||||
|
||||
declare function hasSideEffect(node: Node$1, sourceCode: SourceCode$1, options?: HasSideEffectOptions$1 | undefined): boolean;
|
||||
type Node$1 = estree.Node;
|
||||
type SourceCode$1 = eslint.SourceCode;
|
||||
|
||||
declare function isArrowToken(token: CommentOrToken): token is ArrowToken$1;
|
||||
declare function isCommaToken(token: CommentOrToken): token is CommaToken$1;
|
||||
declare function isSemicolonToken(token: CommentOrToken): token is SemicolonToken$1;
|
||||
declare function isColonToken(token: CommentOrToken): token is ColonToken$1;
|
||||
declare function isOpeningParenToken(token: CommentOrToken): token is OpeningParenToken$1;
|
||||
declare function isClosingParenToken(token: CommentOrToken): token is ClosingParenToken$1;
|
||||
declare function isOpeningBracketToken(token: CommentOrToken): token is OpeningBracketToken$1;
|
||||
declare function isClosingBracketToken(token: CommentOrToken): token is ClosingBracketToken$1;
|
||||
declare function isOpeningBraceToken(token: CommentOrToken): token is OpeningBraceToken$1;
|
||||
declare function isClosingBraceToken(token: CommentOrToken): token is ClosingBraceToken$1;
|
||||
declare function isCommentToken(token: CommentOrToken): token is estree.Comment;
|
||||
declare function isNotArrowToken(arg0: CommentOrToken): boolean;
|
||||
declare function isNotCommaToken(arg0: CommentOrToken): boolean;
|
||||
declare function isNotSemicolonToken(arg0: CommentOrToken): boolean;
|
||||
declare function isNotColonToken(arg0: CommentOrToken): boolean;
|
||||
declare function isNotOpeningParenToken(arg0: CommentOrToken): boolean;
|
||||
declare function isNotClosingParenToken(arg0: CommentOrToken): boolean;
|
||||
declare function isNotOpeningBracketToken(arg0: CommentOrToken): boolean;
|
||||
declare function isNotClosingBracketToken(arg0: CommentOrToken): boolean;
|
||||
declare function isNotOpeningBraceToken(arg0: CommentOrToken): boolean;
|
||||
declare function isNotClosingBraceToken(arg0: CommentOrToken): boolean;
|
||||
declare function isNotCommentToken(arg0: CommentOrToken): boolean;
|
||||
type Token = eslint.AST.Token;
|
||||
type Comment = estree.Comment;
|
||||
type CommentOrToken = Comment | Token;
|
||||
|
||||
declare function isParenthesized(timesOrNode: Node | number, nodeOrSourceCode: Node | SourceCode, optionalSourceCode?: eslint.SourceCode | undefined): boolean;
|
||||
type Node = estree.Node;
|
||||
type SourceCode = eslint.SourceCode;
|
||||
|
||||
declare class PatternMatcher {
|
||||
constructor(pattern: RegExp, options?: {
|
||||
escaped?: boolean | undefined;
|
||||
} | undefined);
|
||||
execAll(str: string): IterableIterator<RegExpExecArray>;
|
||||
test(str: string): boolean;
|
||||
[Symbol.replace](str: string, replacer: string | ((...strs: string[]) => string)): string;
|
||||
}
|
||||
|
||||
declare namespace _default {
|
||||
export { CALL };
|
||||
export { CONSTRUCT };
|
||||
export { ESM };
|
||||
export { findVariable };
|
||||
export { getFunctionHeadLocation };
|
||||
export { getFunctionNameWithKind };
|
||||
export { getInnermostScope };
|
||||
export { getPropertyName };
|
||||
export { getStaticValue };
|
||||
export { getStringIfConstant };
|
||||
export { hasSideEffect };
|
||||
export { isArrowToken };
|
||||
export { isClosingBraceToken };
|
||||
export { isClosingBracketToken };
|
||||
export { isClosingParenToken };
|
||||
export { isColonToken };
|
||||
export { isCommaToken };
|
||||
export { isCommentToken };
|
||||
export { isNotArrowToken };
|
||||
export { isNotClosingBraceToken };
|
||||
export { isNotClosingBracketToken };
|
||||
export { isNotClosingParenToken };
|
||||
export { isNotColonToken };
|
||||
export { isNotCommaToken };
|
||||
export { isNotCommentToken };
|
||||
export { isNotOpeningBraceToken };
|
||||
export { isNotOpeningBracketToken };
|
||||
export { isNotOpeningParenToken };
|
||||
export { isNotSemicolonToken };
|
||||
export { isOpeningBraceToken };
|
||||
export { isOpeningBracketToken };
|
||||
export { isOpeningParenToken };
|
||||
export { isParenthesized };
|
||||
export { isSemicolonToken };
|
||||
export { PatternMatcher };
|
||||
export { READ };
|
||||
export { ReferenceTracker };
|
||||
}
|
||||
|
||||
type StaticValue = StaticValue$2;
|
||||
type StaticValueOptional = StaticValueOptional$1;
|
||||
type StaticValueProvided = StaticValueProvided$1;
|
||||
type ReferenceTrackerOptions = ReferenceTrackerOptions$1;
|
||||
type TraceMap<T> = TraceMap$1<T>;
|
||||
type TrackedReferences<T> = TrackedReferences$1<T>;
|
||||
type HasSideEffectOptions = HasSideEffectOptions$1;
|
||||
type ArrowToken = ArrowToken$1;
|
||||
type CommaToken = CommaToken$1;
|
||||
type SemicolonToken = SemicolonToken$1;
|
||||
type ColonToken = ColonToken$1;
|
||||
type OpeningParenToken = OpeningParenToken$1;
|
||||
type ClosingParenToken = ClosingParenToken$1;
|
||||
type OpeningBracketToken = OpeningBracketToken$1;
|
||||
type ClosingBracketToken = ClosingBracketToken$1;
|
||||
type OpeningBraceToken = OpeningBraceToken$1;
|
||||
type ClosingBraceToken = ClosingBraceToken$1;
|
||||
|
||||
export { ArrowToken, CALL, CONSTRUCT, ClosingBraceToken, ClosingBracketToken, ClosingParenToken, ColonToken, CommaToken, ESM, HasSideEffectOptions, OpeningBraceToken, OpeningBracketToken, OpeningParenToken, PatternMatcher, READ, ReferenceTracker, ReferenceTrackerOptions, SemicolonToken, StaticValue, StaticValueOptional, StaticValueProvided, TraceMap, TrackedReferences, _default as default, findVariable, getFunctionHeadLocation, getFunctionNameWithKind, getInnermostScope, getPropertyName, getStaticValue, getStringIfConstant, hasSideEffect, isArrowToken, isClosingBraceToken, isClosingBracketToken, isClosingParenToken, isColonToken, isCommaToken, isCommentToken, isNotArrowToken, isNotClosingBraceToken, isNotClosingBracketToken, isNotClosingParenToken, isNotColonToken, isNotCommaToken, isNotCommentToken, isNotOpeningBraceToken, isNotOpeningBracketToken, isNotOpeningParenToken, isNotSemicolonToken, isOpeningBraceToken, isOpeningBracketToken, isOpeningParenToken, isParenthesized, isSemicolonToken };
|
||||
2620
node_modules/@eslint-community/eslint-utils/index.js
generated
vendored
Normal file
1
node_modules/@eslint-community/eslint-utils/index.js.map
generated
vendored
Normal file
2579
node_modules/@eslint-community/eslint-utils/index.mjs
generated
vendored
Normal file
1
node_modules/@eslint-community/eslint-utils/index.mjs.map
generated
vendored
Normal file
89
node_modules/@eslint-community/eslint-utils/package.json
generated
vendored
Normal file
@ -0,0 +1,89 @@
|
||||
{
|
||||
"name": "@eslint-community/eslint-utils",
|
||||
"version": "4.9.1",
|
||||
"description": "Utilities for ESLint plugins.",
|
||||
"keywords": [
|
||||
"eslint"
|
||||
],
|
||||
"homepage": "https://github.com/eslint-community/eslint-utils#readme",
|
||||
"bugs": {
|
||||
"url": "https://github.com/eslint-community/eslint-utils/issues"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/eslint-community/eslint-utils"
|
||||
},
|
||||
"license": "MIT",
|
||||
"author": "Toru Nagashima",
|
||||
"sideEffects": false,
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./index.mjs",
|
||||
"require": "./index.js"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"main": "index",
|
||||
"module": "index.mjs",
|
||||
"files": [
|
||||
"index.*"
|
||||
],
|
||||
"scripts": {
|
||||
"prebuild": "npm run -s clean",
|
||||
"build": "npm run build:dts && npm run build:rollup",
|
||||
"build:dts": "tsc -p tsconfig.build.json",
|
||||
"build:rollup": "rollup -c",
|
||||
"clean": "rimraf .nyc_output coverage index.* dist",
|
||||
"coverage": "opener ./coverage/lcov-report/index.html",
|
||||
"docs:build": "vitepress build docs",
|
||||
"docs:watch": "vitepress dev docs",
|
||||
"format": "npm run -s format:prettier -- --write",
|
||||
"format:prettier": "prettier .",
|
||||
"format:check": "npm run -s format:prettier -- --check",
|
||||
"lint:eslint": "eslint .",
|
||||
"lint:format": "npm run -s format:check",
|
||||
"lint:installed-check": "installed-check -v -i installed-check -i npm-run-all2 -i knip -i rollup-plugin-dts",
|
||||
"lint:knip": "knip",
|
||||
"lint": "run-p lint:*",
|
||||
"test-coverage": "c8 mocha --reporter dot \"test/*.mjs\"",
|
||||
"test": "mocha --reporter dot \"test/*.mjs\"",
|
||||
"preversion": "npm run test-coverage && npm run -s build",
|
||||
"postversion": "git push && git push --tags",
|
||||
"prewatch": "npm run -s clean",
|
||||
"watch": "warun \"{src,test}/**/*.mjs\" -- npm run -s test:mocha"
|
||||
},
|
||||
"dependencies": {
|
||||
"eslint-visitor-keys": "^3.4.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint-community/eslint-plugin-mysticatea": "^15.6.1",
|
||||
"@types/eslint": "^9.6.1",
|
||||
"@types/estree": "^1.0.7",
|
||||
"@typescript-eslint/parser": "^5.62.0",
|
||||
"@typescript-eslint/types": "^5.62.0",
|
||||
"c8": "^8.0.1",
|
||||
"dot-prop": "^7.2.0",
|
||||
"eslint": "^8.57.1",
|
||||
"installed-check": "^8.0.1",
|
||||
"knip": "^5.33.3",
|
||||
"mocha": "^9.2.2",
|
||||
"npm-run-all2": "^6.2.3",
|
||||
"opener": "^1.5.2",
|
||||
"prettier": "2.8.8",
|
||||
"rimraf": "^3.0.2",
|
||||
"rollup": "^2.79.2",
|
||||
"rollup-plugin-dts": "^4.2.3",
|
||||
"rollup-plugin-sourcemaps": "^0.6.3",
|
||||
"semver": "^7.6.3",
|
||||
"typescript": "^4.9.5",
|
||||
"vitepress": "^1.4.1",
|
||||
"warun": "^1.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": "^6.0.0 || ^7.0.0 || >=8.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
||||
},
|
||||
"funding": "https://opencollective.com/eslint"
|
||||
}
|
||||
21
node_modules/@eslint-community/regexpp/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 Toru Nagashima
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
177
node_modules/@eslint-community/regexpp/README.md
generated
vendored
Normal file
@ -0,0 +1,177 @@
|
||||
# @eslint-community/regexpp
|
||||
|
||||
[](https://www.npmjs.com/package/@eslint-community/regexpp)
|
||||
[](http://www.npmtrends.com/@eslint-community/regexpp)
|
||||
[](https://github.com/eslint-community/regexpp/actions)
|
||||
[](https://codecov.io/gh/eslint-community/regexpp)
|
||||
|
||||
A regular expression parser for ECMAScript.
|
||||
|
||||
## 💿 Installation
|
||||
|
||||
```bash
|
||||
$ npm install @eslint-community/regexpp
|
||||
```
|
||||
|
||||
- require Node@^12.0.0 || ^14.0.0 || >=16.0.0.
|
||||
|
||||
## 📖 Usage
|
||||
|
||||
```ts
|
||||
import {
|
||||
AST,
|
||||
RegExpParser,
|
||||
RegExpValidator,
|
||||
RegExpVisitor,
|
||||
parseRegExpLiteral,
|
||||
validateRegExpLiteral,
|
||||
visitRegExpAST
|
||||
} from "@eslint-community/regexpp"
|
||||
```
|
||||
|
||||
### parseRegExpLiteral(source, options?)
|
||||
|
||||
Parse a given regular expression literal then make AST object.
|
||||
|
||||
This is equivalent to `new RegExpParser(options).parseLiteral(source)`.
|
||||
|
||||
- **Parameters:**
|
||||
- `source` (`string | RegExp`) The source code to parse.
|
||||
- `options?` ([`RegExpParser.Options`]) The options to parse.
|
||||
- **Return:**
|
||||
- The AST of the regular expression.
|
||||
|
||||
### validateRegExpLiteral(source, options?)
|
||||
|
||||
Validate a given regular expression literal.
|
||||
|
||||
This is equivalent to `new RegExpValidator(options).validateLiteral(source)`.
|
||||
|
||||
- **Parameters:**
|
||||
- `source` (`string`) The source code to validate.
|
||||
- `options?` ([`RegExpValidator.Options`]) The options to validate.
|
||||
|
||||
### visitRegExpAST(ast, handlers)
|
||||
|
||||
Visit each node of a given AST.
|
||||
|
||||
This is equivalent to `new RegExpVisitor(handlers).visit(ast)`.
|
||||
|
||||
- **Parameters:**
|
||||
- `ast` ([`AST.Node`]) The AST to visit.
|
||||
- `handlers` ([`RegExpVisitor.Handlers`]) The callbacks.
|
||||
|
||||
### RegExpParser
|
||||
|
||||
#### new RegExpParser(options?)
|
||||
|
||||
- **Parameters:**
|
||||
- `options?` ([`RegExpParser.Options`]) The options to parse.
|
||||
|
||||
#### parser.parseLiteral(source, start?, end?)
|
||||
|
||||
Parse a regular expression literal.
|
||||
|
||||
- **Parameters:**
|
||||
- `source` (`string`) The source code to parse. E.g. `"/abc/g"`.
|
||||
- `start?` (`number`) The start index in the source code. Default is `0`.
|
||||
- `end?` (`number`) The end index in the source code. Default is `source.length`.
|
||||
- **Return:**
|
||||
- The AST of the regular expression.
|
||||
|
||||
#### parser.parsePattern(source, start?, end?, flags?)
|
||||
|
||||
Parse a regular expression pattern.
|
||||
|
||||
- **Parameters:**
|
||||
- `source` (`string`) The source code to parse. E.g. `"abc"`.
|
||||
- `start?` (`number`) The start index in the source code. Default is `0`.
|
||||
- `end?` (`number`) The end index in the source code. Default is `source.length`.
|
||||
- `flags?` (`{ unicode?: boolean, unicodeSets?: boolean }`) The flags to enable Unicode mode, and Unicode Set mode.
|
||||
- **Return:**
|
||||
- The AST of the regular expression pattern.
|
||||
|
||||
#### parser.parseFlags(source, start?, end?)
|
||||
|
||||
Parse a regular expression flags.
|
||||
|
||||
- **Parameters:**
|
||||
- `source` (`string`) The source code to parse. E.g. `"gim"`.
|
||||
- `start?` (`number`) The start index in the source code. Default is `0`.
|
||||
- `end?` (`number`) The end index in the source code. Default is `source.length`.
|
||||
- **Return:**
|
||||
- The AST of the regular expression flags.
|
||||
|
||||
### RegExpValidator
|
||||
|
||||
#### new RegExpValidator(options)
|
||||
|
||||
- **Parameters:**
|
||||
- `options` ([`RegExpValidator.Options`]) The options to validate.
|
||||
|
||||
#### validator.validateLiteral(source, start, end)
|
||||
|
||||
Validate a regular expression literal.
|
||||
|
||||
- **Parameters:**
|
||||
- `source` (`string`) The source code to validate.
|
||||
- `start?` (`number`) The start index in the source code. Default is `0`.
|
||||
- `end?` (`number`) The end index in the source code. Default is `source.length`.
|
||||
|
||||
#### validator.validatePattern(source, start, end, flags)
|
||||
|
||||
Validate a regular expression pattern.
|
||||
|
||||
- **Parameters:**
|
||||
- `source` (`string`) The source code to validate.
|
||||
- `start?` (`number`) The start index in the source code. Default is `0`.
|
||||
- `end?` (`number`) The end index in the source code. Default is `source.length`.
|
||||
- `flags?` (`{ unicode?: boolean, unicodeSets?: boolean }`) The flags to enable Unicode mode, and Unicode Set mode.
|
||||
|
||||
#### validator.validateFlags(source, start, end)
|
||||
|
||||
Validate a regular expression flags.
|
||||
|
||||
- **Parameters:**
|
||||
- `source` (`string`) The source code to validate.
|
||||
- `start?` (`number`) The start index in the source code. Default is `0`.
|
||||
- `end?` (`number`) The end index in the source code. Default is `source.length`.
|
||||
|
||||
### RegExpVisitor
|
||||
|
||||
#### new RegExpVisitor(handlers)
|
||||
|
||||
- **Parameters:**
|
||||
- `handlers` ([`RegExpVisitor.Handlers`]) The callbacks.
|
||||
|
||||
#### visitor.visit(ast)
|
||||
|
||||
Validate a regular expression literal.
|
||||
|
||||
- **Parameters:**
|
||||
- `ast` ([`AST.Node`]) The AST to visit.
|
||||
|
||||
## 📰 Changelog
|
||||
|
||||
- [GitHub Releases](https://github.com/eslint-community/regexpp/releases)
|
||||
|
||||
## 🍻 Contributing
|
||||
|
||||
Welcome contributing!
|
||||
|
||||
Please use GitHub's Issues/PRs.
|
||||
|
||||
### Development Tools
|
||||
|
||||
- `npm test` runs tests and measures coverage.
|
||||
- `npm run build` compiles TypeScript source code to `index.js`, `index.js.map`, and `index.d.ts`.
|
||||
- `npm run clean` removes the temporary files which are created by `npm test` and `npm run build`.
|
||||
- `npm run lint` runs ESLint.
|
||||
- `npm run update:test` updates test fixtures.
|
||||
- `npm run update:ids` updates `src/unicode/ids.ts`.
|
||||
- `npm run watch` runs tests with `--watch` option.
|
||||
|
||||
[`AST.Node`]: src/ast.ts#L4
|
||||
[`RegExpParser.Options`]: src/parser.ts#L743
|
||||
[`RegExpValidator.Options`]: src/validator.ts#L220
|
||||
[`RegExpVisitor.Handlers`]: src/visitor.ts#L291
|
||||
1163
node_modules/@eslint-community/regexpp/index.d.ts
generated
vendored
Normal file
3042
node_modules/@eslint-community/regexpp/index.js
generated
vendored
Normal file
1
node_modules/@eslint-community/regexpp/index.js.map
generated
vendored
Normal file
3032
node_modules/@eslint-community/regexpp/index.mjs
generated
vendored
Normal file
1
node_modules/@eslint-community/regexpp/index.mjs.map
generated
vendored
Normal file
91
node_modules/@eslint-community/regexpp/package.json
generated
vendored
Normal file
@ -0,0 +1,91 @@
|
||||
{
|
||||
"name": "@eslint-community/regexpp",
|
||||
"version": "4.12.2",
|
||||
"description": "Regular expression parser for ECMAScript.",
|
||||
"keywords": [
|
||||
"regexp",
|
||||
"regular",
|
||||
"expression",
|
||||
"parser",
|
||||
"validator",
|
||||
"ast",
|
||||
"abstract",
|
||||
"syntax",
|
||||
"tree",
|
||||
"ecmascript",
|
||||
"es2015",
|
||||
"es2016",
|
||||
"es2017",
|
||||
"es2018",
|
||||
"es2019",
|
||||
"es2020",
|
||||
"es2021",
|
||||
"annexB"
|
||||
],
|
||||
"homepage": "https://github.com/eslint-community/regexpp#readme",
|
||||
"bugs": {
|
||||
"url": "https://github.com/eslint-community/regexpp/issues"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/eslint-community/regexpp"
|
||||
},
|
||||
"license": "MIT",
|
||||
"author": "Toru Nagashima",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./index.d.ts",
|
||||
"import": "./index.mjs",
|
||||
"default": "./index.js"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"main": "index",
|
||||
"files": [
|
||||
"index.*"
|
||||
],
|
||||
"scripts": {
|
||||
"prebuild": "npm run -s clean",
|
||||
"build": "run-s build:*",
|
||||
"build:tsc": "tsc --module es2015",
|
||||
"build:rollup": "rollup -c",
|
||||
"build:dts": "npm run -s build:tsc -- --removeComments false && dts-bundle --name @eslint-community/regexpp --main .temp/index.d.ts --out ../index.d.ts && prettier --write index.d.ts",
|
||||
"clean": "rimraf .temp index.*",
|
||||
"lint": "eslint . --ext .ts",
|
||||
"test": "nyc _mocha \"test/*.ts\" --reporter dot --timeout 10000",
|
||||
"debug": "mocha --require ts-node/register/transpile-only \"test/*.ts\" --reporter dot --timeout 10000",
|
||||
"update:test": "ts-node scripts/update-fixtures.ts",
|
||||
"update:unicode": "run-s update:unicode:*",
|
||||
"update:unicode:ids": "ts-node scripts/update-unicode-ids.ts",
|
||||
"update:unicode:props": "ts-node scripts/update-unicode-properties.ts",
|
||||
"update:test262:extract": "ts-node -T scripts/extract-test262.ts",
|
||||
"preversion": "npm test && npm run -s build",
|
||||
"postversion": "git push && git push --tags",
|
||||
"prewatch": "npm run -s clean",
|
||||
"watch": "_mocha \"test/*.ts\" --require ts-node/register --reporter dot --timeout 10000 --watch-extensions ts --watch --growl"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"@eslint-community/eslint-plugin-mysticatea": "^15.5.1",
|
||||
"@rollup/plugin-node-resolve": "^14.1.0",
|
||||
"@types/eslint": "^8.44.3",
|
||||
"@types/jsdom": "^16.2.15",
|
||||
"@types/mocha": "^9.1.1",
|
||||
"@types/node": "^12.20.55",
|
||||
"dts-bundle": "^0.7.3",
|
||||
"eslint": "^8.50.0",
|
||||
"js-tokens": "^8.0.2",
|
||||
"jsdom": "^19.0.0",
|
||||
"mocha": "^9.2.2",
|
||||
"npm-run-all2": "^6.2.2",
|
||||
"nyc": "^14.1.1",
|
||||
"rimraf": "^3.0.2",
|
||||
"rollup": "^2.79.1",
|
||||
"rollup-plugin-sourcemaps": "^0.6.3",
|
||||
"ts-node": "^10.9.1",
|
||||
"typescript": "~5.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^12.0.0 || ^14.0.0 || >=16.0.0"
|
||||
}
|
||||
}
|
||||
201
node_modules/@eslint/config-array/LICENSE
generated
vendored
Normal file
@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
368
node_modules/@eslint/config-array/README.md
generated
vendored
Normal file
@ -0,0 +1,368 @@
|
||||
# Config Array
|
||||
|
||||
## Description
|
||||
|
||||
A config array is a way of managing configurations that are based on glob pattern matching of filenames. Each config array contains the information needed to determine the correct configuration for any file based on the filename.
|
||||
|
||||
**Note:** This is a generic package that can be used outside of ESLint. It contains no ESLint-specific functionality.
|
||||
|
||||
## Installation
|
||||
|
||||
For Node.js and compatible runtimes:
|
||||
|
||||
```shell
|
||||
npm install @eslint/config-array
|
||||
# or
|
||||
yarn add @eslint/config-array
|
||||
# or
|
||||
pnpm install @eslint/config-array
|
||||
# or
|
||||
bun add @eslint/config-array
|
||||
```
|
||||
|
||||
For Deno:
|
||||
|
||||
```shell
|
||||
deno add @eslint/config-array
|
||||
```
|
||||
|
||||
## Background
|
||||
|
||||
The basic idea is that all configuration, including overrides, can be represented by a single array where each item in the array is a config object. Config objects appearing later in the array override config objects appearing earlier in the array. You can calculate a config for a given file by traversing all config objects in the array to find the ones that match the filename. Matching is done by specifying glob patterns in `files` and `ignores` properties on each config object. Here's an example:
|
||||
|
||||
```js
|
||||
export default [
|
||||
// match all JSON files
|
||||
{
|
||||
name: "JSON Handler",
|
||||
files: ["**/*.json"],
|
||||
handler: jsonHandler,
|
||||
},
|
||||
|
||||
// match only package.json
|
||||
{
|
||||
name: "package.json Handler",
|
||||
files: ["package.json"],
|
||||
handler: packageJsonHandler,
|
||||
},
|
||||
];
|
||||
```
|
||||
|
||||
In this example, there are two config objects: the first matches all JSON files in all directories and the second matches just `package.json` in the base path directory (all the globs are evaluated as relative to a base path that can be specified). When you retrieve a configuration for `foo.json`, only the first config object matches so `handler` is equal to `jsonHandler`; when you retrieve a configuration for `package.json`, `handler` is equal to `packageJsonHandler` (because both config objects match, the second one wins).
|
||||
|
||||
## Usage
|
||||
|
||||
First, import the `ConfigArray` constructor:
|
||||
|
||||
```js
|
||||
import { ConfigArray } from "@eslint/config-array";
|
||||
|
||||
// or using CommonJS
|
||||
|
||||
const { ConfigArray } = require("@eslint/config-array");
|
||||
```
|
||||
|
||||
When you create a new instance of `ConfigArray`, you must pass in two arguments: an array of configs and an options object. The array of configs is most likely read in from a configuration file, so here's a typical example:
|
||||
|
||||
```js
|
||||
const configFilename = path.resolve(process.cwd(), "my.config.js");
|
||||
const { default: rawConfigs } = await import(configFilename);
|
||||
const configs = new ConfigArray(rawConfigs, {
|
||||
// the path to match filenames from
|
||||
basePath: process.cwd(),
|
||||
|
||||
// additional items in each config
|
||||
schema: mySchema,
|
||||
});
|
||||
```
|
||||
|
||||
This example reads in an object or array from `my.config.js` and passes it into the `ConfigArray` constructor as the first argument. The second argument is an object specifying the `basePath` (the directory in which `my.config.js` is found) and a `schema` to define the additional properties of a config object beyond `files`, `ignores`, `basePath`, and `name`.
|
||||
|
||||
### Specifying a Schema
|
||||
|
||||
The `schema` option is required for you to use additional properties in config objects. The schema is an object that follows the format of an [`ObjectSchema`](https://npmjs.com/package/@eslint/object-schema). The schema specifies both validation and merge rules that the `ConfigArray` instance needs to combine configs when there are multiple matches. Here's an example:
|
||||
|
||||
```js
|
||||
const configFilename = path.resolve(process.cwd(), "my.config.js");
|
||||
const { default: rawConfigs } = await import(configFilename);
|
||||
|
||||
const mySchema = {
|
||||
|
||||
// define the handler key in configs
|
||||
handler: {
|
||||
required: true,
|
||||
merge(a, b) {
|
||||
if (!b) return a;
|
||||
if (!a) return b;
|
||||
},
|
||||
validate(value) {
|
||||
if (typeof value !== "function") {
|
||||
throw new TypeError("Function expected.");
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const configs = new ConfigArray(rawConfigs, {
|
||||
|
||||
// the path to match filenames from
|
||||
basePath: process.cwd(),
|
||||
|
||||
// additional item schemas in each config
|
||||
schema: mySchema,
|
||||
|
||||
// additional config types supported (default: [])
|
||||
extraConfigTypes: ["array", "function"];
|
||||
});
|
||||
```
|
||||
|
||||
### Config Arrays
|
||||
|
||||
Config arrays can be multidimensional, so it's possible for a config array to contain another config array when `extraConfigTypes` contains `"array"`, such as:
|
||||
|
||||
```js
|
||||
export default [
|
||||
// JS config
|
||||
{
|
||||
files: ["**/*.js"],
|
||||
handler: jsHandler,
|
||||
},
|
||||
|
||||
// JSON configs
|
||||
[
|
||||
// match all JSON files
|
||||
{
|
||||
name: "JSON Handler",
|
||||
files: ["**/*.json"],
|
||||
handler: jsonHandler,
|
||||
},
|
||||
|
||||
// match only package.json
|
||||
{
|
||||
name: "package.json Handler",
|
||||
files: ["package.json"],
|
||||
handler: packageJsonHandler,
|
||||
},
|
||||
],
|
||||
|
||||
// filename must match function
|
||||
{
|
||||
files: [filePath => filePath.endsWith(".md")],
|
||||
handler: markdownHandler,
|
||||
},
|
||||
|
||||
// filename must match all patterns in subarray
|
||||
{
|
||||
files: [["*.test.*", "*.js"]],
|
||||
handler: jsTestHandler,
|
||||
},
|
||||
|
||||
// filename must not match patterns beginning with !
|
||||
{
|
||||
name: "Non-JS files",
|
||||
files: ["!*.js"],
|
||||
settings: {
|
||||
js: false,
|
||||
},
|
||||
},
|
||||
|
||||
// specific settings for files inside `src` directory
|
||||
{
|
||||
name: "Source files",
|
||||
basePath: "src",
|
||||
files: ["**/*"],
|
||||
settings: {
|
||||
source: true,
|
||||
},
|
||||
},
|
||||
];
|
||||
```
|
||||
|
||||
In this example, the array contains both config objects and a config array. When a config array is normalized (see details below), it is flattened so only config objects remain. However, the order of evaluation remains the same.
|
||||
|
||||
If the `files` array contains a function, then that function is called with the path of the file as it was passed in. The function is expected to return `true` if there is a match and `false` if not. (The `ignores` array can also contain functions.)
|
||||
|
||||
If the `files` array contains an item that is an array of strings and functions, then all patterns must match in order for the config to match. In the preceding examples, both `*.test.*` and `*.js` must match in order for the config object to be used.
|
||||
|
||||
If a pattern in the files array begins with `!` then it excludes that pattern. In the preceding example, any filename that doesn't end with `.js` will automatically get a `settings.js` property set to `false`.
|
||||
|
||||
You can also specify an `ignores` key that will force files matching those patterns to not be included. If the `ignores` key is in a config object without any other keys, then those ignores will always be applied; otherwise those ignores act as exclusions. Here's an example:
|
||||
|
||||
```js
|
||||
export default [
|
||||
|
||||
// Always ignored
|
||||
{
|
||||
ignores: ["**/.git/**", "**/node_modules/**"]
|
||||
},
|
||||
|
||||
// .eslintrc.js file is ignored only when .js file matches
|
||||
{
|
||||
files: ["**/*.js"],
|
||||
ignores: [".eslintrc.js"]
|
||||
handler: jsHandler
|
||||
}
|
||||
];
|
||||
```
|
||||
|
||||
You can use negated patterns in `ignores` to exclude a file that was already ignored, such as:
|
||||
|
||||
```js
|
||||
export default [
|
||||
// Ignore all JSON files except tsconfig.json
|
||||
{
|
||||
files: ["**/*"],
|
||||
ignores: ["**/*.json", "!tsconfig.json"],
|
||||
},
|
||||
];
|
||||
```
|
||||
|
||||
### Config Functions
|
||||
|
||||
Config arrays can also include config functions when `extraConfigTypes` contains `"function"`. A config function accepts a single parameter, `context` (defined by you), and must return either a config object or a config array (it cannot return another function). Config functions allow end users to execute code in the creation of appropriate config objects. Here's an example:
|
||||
|
||||
```js
|
||||
export default [
|
||||
// JS config
|
||||
{
|
||||
files: ["**/*.js"],
|
||||
handler: jsHandler,
|
||||
},
|
||||
|
||||
// JSON configs
|
||||
function (context) {
|
||||
return [
|
||||
// match all JSON files
|
||||
{
|
||||
name: context.name + " JSON Handler",
|
||||
files: ["**/*.json"],
|
||||
handler: jsonHandler,
|
||||
},
|
||||
|
||||
// match only package.json
|
||||
{
|
||||
name: context.name + " package.json Handler",
|
||||
files: ["package.json"],
|
||||
handler: packageJsonHandler,
|
||||
},
|
||||
];
|
||||
},
|
||||
];
|
||||
```
|
||||
|
||||
When a config array is normalized, each function is executed and replaced in the config array with the return value.
|
||||
|
||||
**Note:** Config functions can also be async.
|
||||
|
||||
### Normalizing Config Arrays
|
||||
|
||||
Once a config array has been created and loaded with all of the raw config data, it must be normalized before it can be used. The normalization process goes through and flattens the config array as well as executing all config functions to get their final values.
|
||||
|
||||
To normalize a config array, call the `normalize()` method and pass in a context object:
|
||||
|
||||
```js
|
||||
await configs.normalize({
|
||||
name: "MyApp",
|
||||
});
|
||||
```
|
||||
|
||||
The `normalize()` method returns a promise, so be sure to use the `await` operator. The config array instance is normalized in-place, so you don't need to create a new variable.
|
||||
|
||||
If you want to disallow async config functions, you can call `normalizeSync()` instead. This method is completely synchronous and does not require using the `await` operator as it does not return a promise:
|
||||
|
||||
```js
|
||||
await configs.normalizeSync({
|
||||
name: "MyApp",
|
||||
});
|
||||
```
|
||||
|
||||
**Important:** Once a `ConfigArray` is normalized, it cannot be changed further. You can, however, create a new `ConfigArray` and pass in the normalized instance to create an unnormalized copy.
|
||||
|
||||
### Getting Config for a File
|
||||
|
||||
To get the config for a file, use the `getConfig()` method on a normalized config array and pass in the filename to get a config for:
|
||||
|
||||
```js
|
||||
// pass in filename
|
||||
const fileConfig = configs.getConfig(
|
||||
path.resolve(process.cwd(), "package.json"),
|
||||
);
|
||||
```
|
||||
|
||||
The config array always returns an object, even if there are no configs matching the given filename. You can then inspect the returned config object to determine how to proceed.
|
||||
|
||||
A few things to keep in mind:
|
||||
|
||||
- If a filename is not an absolute path, it will be resolved relative to the base path directory.
|
||||
- The returned config object never has `files`, `ignores`, `basePath`, or `name` properties; the only properties on the object will be the other configuration options specified.
|
||||
- The config array caches configs, so subsequent calls to `getConfig()` with the same filename will return in a fast lookup rather than another calculation.
|
||||
- A config will only be generated if the filename matches an entry in a `files` key. A config will not be generated without matching a `files` key (configs without a `files` key are only applied when another config with a `files` key is applied; configs without `files` are never applied on their own). Any config with a `files` key entry that is `*` or ends with `/**` or `/*` will only be applied if another entry in the same `files` key matches or another config matches.
|
||||
|
||||
## Determining Ignored Paths
|
||||
|
||||
You can determine if a file is ignored by using the `isFileIgnored()` method and passing in the path of any file, as in this example:
|
||||
|
||||
```js
|
||||
const ignored = configs.isFileIgnored("/foo/bar/baz.txt");
|
||||
```
|
||||
|
||||
A file is considered ignored if any of the following is true:
|
||||
|
||||
- **It's parent directory is ignored.** For example, if `foo` is in `ignores`, then `foo/a.js` is considered ignored.
|
||||
- **It has an ancestor directory that is ignored.** For example, if `foo` is in `ignores`, then `foo/baz/a.js` is considered ignored.
|
||||
- **It matches an ignored file pattern.** For example, if `**/a.js` is in `ignores`, then `foo/a.js` and `foo/baz/a.js` are considered ignored.
|
||||
- **If it matches an entry in `files` and also in `ignores`.** For example, if `**/*.js` is in `files` and `**/a.js` is in `ignores`, then `foo/a.js` and `foo/baz/a.js` are considered ignored.
|
||||
- **The file is outside the `basePath`.** If the `basePath` is `/usr/me`, then `/foo/a.js` is considered ignored.
|
||||
|
||||
For directories, use the `isDirectoryIgnored()` method and pass in the path of any directory, as in this example:
|
||||
|
||||
```js
|
||||
const ignored = configs.isDirectoryIgnored("/foo/bar/");
|
||||
```
|
||||
|
||||
A directory is considered ignored if any of the following is true:
|
||||
|
||||
- **It's parent directory is ignored.** For example, if `foo` is in `ignores`, then `foo/baz` is considered ignored.
|
||||
- **It has an ancestor directory that is ignored.** For example, if `foo` is in `ignores`, then `foo/bar/baz/a.js` is considered ignored.
|
||||
- **It matches and ignored file pattern.** For example, if `**/a.js` is in `ignores`, then `foo/a.js` and `foo/baz/a.js` are considered ignored.
|
||||
- **If it matches an entry in `files` and also in `ignores`.** For example, if `**/*.js` is in `files` and `**/a.js` is in `ignores`, then `foo/a.js` and `foo/baz/a.js` are considered ignored.
|
||||
- **The file is outside the `basePath`.** If the `basePath` is `/usr/me`, then `/foo/a.js` is considered ignored.
|
||||
|
||||
**Important:** A pattern such as `foo/**` means that `foo` and `foo/` are _not_ ignored whereas `foo/bar` is ignored. If you want to ignore `foo` and all of its subdirectories, use the pattern `foo` or `foo/` in `ignores`.
|
||||
|
||||
## Caching Mechanisms
|
||||
|
||||
Each `ConfigArray` aggressively caches configuration objects to avoid unnecessary work. This caching occurs in two ways:
|
||||
|
||||
1. **File-based Caching.** For each filename that is passed into a method, the resulting config is cached against that filename so you're always guaranteed to get the same object returned from `getConfig()` whenever you pass the same filename in.
|
||||
2. **Index-based Caching.** Whenever a config is calculated, the config elements that were used to create the config are also cached. So if a given filename matches elements 1, 5, and 7, the resulting config is cached with a key of `1,5,7`. That way, if another file is passed that matches the same config elements, the result is already known and doesn't have to be recalculated. That means two files that match all the same elements will return the same config from `getConfig()`.
|
||||
|
||||
## Acknowledgements
|
||||
|
||||
The design of this project was influenced by feedback on the ESLint RFC, and incorporates ideas from:
|
||||
|
||||
- Teddy Katz (@not-an-aardvark)
|
||||
- Toru Nagashima (@mysticatea)
|
||||
- Kai Cataldo (@kaicataldo)
|
||||
|
||||
## License
|
||||
|
||||
Apache 2.0
|
||||
|
||||
<!-- NOTE: This section is autogenerated. Do not manually edit.-->
|
||||
<!--sponsorsstart-->
|
||||
|
||||
## Sponsors
|
||||
|
||||
The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. [Become a Sponsor](https://eslint.org/donate)
|
||||
to get your logo on our READMEs and [website](https://eslint.org/sponsors).
|
||||
|
||||
<h3>Platinum Sponsors</h3>
|
||||
<p><a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="128"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="128"></a></p><h3>Gold Sponsors</h3>
|
||||
<p><a href="https://qlty.sh/"><img src="https://images.opencollective.com/qltysh/33d157d/logo.png" alt="Qlty Software" height="96"></a> <a href="https://trunk.io/"><img src="https://images.opencollective.com/trunkio/fb92d60/avatar.png" alt="trunk.io" height="96"></a> <a href="https://shopify.engineering/"><img src="https://avatars.githubusercontent.com/u/8085" alt="Shopify" height="96"></a></p><h3>Silver Sponsors</h3>
|
||||
<p><a href="https://vite.dev/"><img src="https://images.opencollective.com/vite/e6d15e1/logo.png" alt="Vite" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/5c4fa84/logo.png" alt="Liftoff" height="64"></a> <a href="https://americanexpress.io"><img src="https://avatars.githubusercontent.com/u/3853301" alt="American Express" height="64"></a> <a href="https://stackblitz.com"><img src="https://avatars.githubusercontent.com/u/28635252" alt="StackBlitz" height="64"></a></p><h3>Bronze Sponsors</h3>
|
||||
<p><a href="https://syntax.fm"><img src="https://github.com/syntaxfm.png" alt="Syntax" height="32"></a> <a href="https://cybozu.co.jp/"><img src="https://images.opencollective.com/cybozu/933e46d/logo.png" alt="Cybozu" height="32"></a> <a href="https://sentry.io"><img src="https://github.com/getsentry.png" alt="Sentry" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://www.gitbook.com"><img src="https://avatars.githubusercontent.com/u/7111340" alt="GitBook" height="32"></a> <a href="https://nx.dev"><img src="https://avatars.githubusercontent.com/u/23692104" alt="Nx" height="32"></a> <a href="https://opensource.mercedes-benz.com/"><img src="https://avatars.githubusercontent.com/u/34240465" alt="Mercedes-Benz Group" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774" alt="HeroCoders" height="32"></a> <a href="https://www.lambdatest.com"><img src="https://avatars.githubusercontent.com/u/171592363" alt="LambdaTest" height="32"></a></p>
|
||||
<h3>Technology Sponsors</h3>
|
||||
Technology sponsors allow us to use their products and services for free as part of a contribution to the open source ecosystem and our work.
|
||||
<p><a href="https://netlify.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/netlify-icon.svg" alt="Netlify" height="32"></a> <a href="https://algolia.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/algolia-icon.svg" alt="Algolia" height="32"></a> <a href="https://1password.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/1password-icon.svg" alt="1Password" height="32"></a></p>
|
||||
<!--sponsorsend-->
|
||||
1539
node_modules/@eslint/config-array/dist/cjs/index.cjs
generated
vendored
Normal file
145
node_modules/@eslint/config-array/dist/cjs/index.d.cts
generated
vendored
Normal file
@ -0,0 +1,145 @@
|
||||
export { ObjectSchema } from "@eslint/object-schema";
|
||||
export type PropertyDefinition = $eslintobjectschema.PropertyDefinition;
|
||||
export type ObjectDefinition = $eslintobjectschema.ObjectDefinition;
|
||||
export type ConfigObject = $typests.ConfigObject;
|
||||
export type IMinimatchStatic = minimatch.IMinimatchStatic;
|
||||
export type IMinimatch = minimatch.IMinimatch;
|
||||
export type ObjectSchemaInstance = ObjectSchema;
|
||||
/**
|
||||
* Represents an array of config objects and provides method for working with
|
||||
* those config objects.
|
||||
*/
|
||||
export class ConfigArray extends Array<any> {
|
||||
/**
|
||||
* Creates a new instance of ConfigArray.
|
||||
* @param {Iterable|Function|Object} configs An iterable yielding config
|
||||
* objects, or a config function, or a config object.
|
||||
* @param {Object} options The options for the ConfigArray.
|
||||
* @param {string} [options.basePath="/"] The absolute path of the config file directory.
|
||||
* Defaults to `"/"`.
|
||||
* @param {boolean} [options.normalized=false] Flag indicating if the
|
||||
* configs have already been normalized.
|
||||
* @param {Object} [options.schema] The additional schema
|
||||
* definitions to use for the ConfigArray schema.
|
||||
* @param {Array<string>} [options.extraConfigTypes] List of config types supported.
|
||||
* @throws {TypeError} When the `basePath` is not a non-empty string,
|
||||
*/
|
||||
constructor(configs: Iterable<any> | Function | any, { basePath, normalized, schema: customSchema, extraConfigTypes, }?: {
|
||||
basePath?: string;
|
||||
normalized?: boolean;
|
||||
schema?: any;
|
||||
extraConfigTypes?: Array<string>;
|
||||
});
|
||||
/**
|
||||
* The path of the config file that this array was loaded from.
|
||||
* This is used to calculate filename matches.
|
||||
* @property basePath
|
||||
* @type {string}
|
||||
*/
|
||||
basePath: string;
|
||||
/**
|
||||
* The supported config types.
|
||||
* @type {Array<string>}
|
||||
*/
|
||||
extraConfigTypes: Array<string>;
|
||||
/**
|
||||
* Returns the `files` globs from every config object in the array.
|
||||
* This can be used to determine which files will be matched by a
|
||||
* config array or to use as a glob pattern when no patterns are provided
|
||||
* for a command line interface.
|
||||
* @returns {Array<string|Function>} An array of matchers.
|
||||
*/
|
||||
get files(): Array<string | Function>;
|
||||
/**
|
||||
* Returns ignore matchers that should always be ignored regardless of
|
||||
* the matching `files` fields in any configs. This is necessary to mimic
|
||||
* the behavior of things like .gitignore and .eslintignore, allowing a
|
||||
* globbing operation to be faster.
|
||||
* @returns {Object[]} An array of config objects representing global ignores.
|
||||
*/
|
||||
get ignores(): any[];
|
||||
/**
|
||||
* Indicates if the config array has been normalized.
|
||||
* @returns {boolean} True if the config array is normalized, false if not.
|
||||
*/
|
||||
isNormalized(): boolean;
|
||||
/**
|
||||
* Normalizes a config array by flattening embedded arrays and executing
|
||||
* config functions.
|
||||
* @param {Object} [context] The context object for config functions.
|
||||
* @returns {Promise<ConfigArray>} The current ConfigArray instance.
|
||||
*/
|
||||
normalize(context?: any): Promise<ConfigArray>;
|
||||
/**
|
||||
* Normalizes a config array by flattening embedded arrays and executing
|
||||
* config functions.
|
||||
* @param {Object} [context] The context object for config functions.
|
||||
* @returns {ConfigArray} The current ConfigArray instance.
|
||||
*/
|
||||
normalizeSync(context?: any): ConfigArray;
|
||||
/**
|
||||
* Returns the config object for a given file path and a status that can be used to determine why a file has no config.
|
||||
* @param {string} filePath The path of a file to get a config for.
|
||||
* @returns {{ config?: Object, status: "ignored"|"external"|"unconfigured"|"matched" }}
|
||||
* An object with an optional property `config` and property `status`.
|
||||
* `config` is the config object for the specified file as returned by {@linkcode ConfigArray.getConfig},
|
||||
* `status` a is one of the constants returned by {@linkcode ConfigArray.getConfigStatus}.
|
||||
*/
|
||||
getConfigWithStatus(filePath: string): {
|
||||
config?: any;
|
||||
status: "ignored" | "external" | "unconfigured" | "matched";
|
||||
};
|
||||
/**
|
||||
* Returns the config object for a given file path.
|
||||
* @param {string} filePath The path of a file to get a config for.
|
||||
* @returns {Object|undefined} The config object for this file or `undefined`.
|
||||
*/
|
||||
getConfig(filePath: string): any | undefined;
|
||||
/**
|
||||
* Determines whether a file has a config or why it doesn't.
|
||||
* @param {string} filePath The path of the file to check.
|
||||
* @returns {"ignored"|"external"|"unconfigured"|"matched"} One of the following values:
|
||||
* * `"ignored"`: the file is ignored
|
||||
* * `"external"`: the file is outside the base path
|
||||
* * `"unconfigured"`: the file is not matched by any config
|
||||
* * `"matched"`: the file has a matching config
|
||||
*/
|
||||
getConfigStatus(filePath: string): "ignored" | "external" | "unconfigured" | "matched";
|
||||
/**
|
||||
* Determines if the given filepath is ignored based on the configs.
|
||||
* @param {string} filePath The path of a file to check.
|
||||
* @returns {boolean} True if the path is ignored, false if not.
|
||||
* @deprecated Use `isFileIgnored` instead.
|
||||
*/
|
||||
isIgnored(filePath: string): boolean;
|
||||
/**
|
||||
* Determines if the given filepath is ignored based on the configs.
|
||||
* @param {string} filePath The path of a file to check.
|
||||
* @returns {boolean} True if the path is ignored, false if not.
|
||||
*/
|
||||
isFileIgnored(filePath: string): boolean;
|
||||
/**
|
||||
* Determines if the given directory is ignored based on the configs.
|
||||
* This checks only default `ignores` that don't have `files` in the
|
||||
* same config. A pattern such as `/foo` be considered to ignore the directory
|
||||
* while a pattern such as `/foo/**` is not considered to ignore the
|
||||
* directory because it is matching files.
|
||||
* @param {string} directoryPath The path of a directory to check.
|
||||
* @returns {boolean} True if the directory is ignored, false if not. Will
|
||||
* return true for any directory that is not inside of `basePath`.
|
||||
* @throws {Error} When the `ConfigArray` is not normalized.
|
||||
*/
|
||||
isDirectoryIgnored(directoryPath: string): boolean;
|
||||
#private;
|
||||
}
|
||||
export namespace ConfigArraySymbol {
|
||||
let isNormalized: symbol;
|
||||
let configCache: symbol;
|
||||
let schema: symbol;
|
||||
let finalizeConfig: symbol;
|
||||
let preprocessConfig: symbol;
|
||||
}
|
||||
import type * as $eslintobjectschema from "@eslint/object-schema";
|
||||
import type * as $typests from "./types.cts";
|
||||
import minimatch from 'minimatch';
|
||||
import { ObjectSchema } from '@eslint/object-schema';
|
||||