Compare commits
167
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3ac36446bf | ||
|
|
ac95a64115 | ||
|
|
1d07698df7 | ||
|
|
583622f091 | ||
|
|
bfdbd0313d | ||
|
|
a70f93af0a | ||
|
|
26970e6adc | ||
|
|
63bc49949a | ||
|
|
ce45f2d4b6 | ||
|
|
bec1080cb8 | ||
|
|
ed4826484c | ||
|
|
77e6bf1d55 | ||
|
|
fa6413e953 | ||
|
|
53a9931e94 | ||
|
|
055ead345a | ||
|
|
89c247e913 | ||
|
|
df7df20c46 | ||
|
|
b738072e05 | ||
|
|
414ac3b194 | ||
|
|
f3b48ac302 | ||
|
|
bea39455e6 | ||
|
|
1a984251b6 | ||
|
|
67ca2abdbc | ||
|
|
b10e7d0a7f | ||
|
|
6be56b9966 | ||
|
|
4951a2d047 | ||
|
|
3fa1aeb80c | ||
|
|
c6b27a6079 | ||
|
|
c8c619210f | ||
|
|
01f923b806 | ||
|
|
487cb46f03 | ||
|
|
d05f93e610 | ||
|
|
701b7b3b23 | ||
|
|
1eff015bbb | ||
|
|
84129f1d9e | ||
|
|
60dbc5af66 | ||
|
|
8abc2ea2ef | ||
|
|
76243e08c0 | ||
|
|
57d6bbbe02 | ||
|
|
e1910011aa | ||
|
|
f81d9315e0 | ||
|
|
48cf43e68d | ||
|
|
f30a539ebf | ||
|
|
57a602eb60 | ||
|
|
a2c8dd2f55 | ||
|
|
f272a9a617 | ||
|
|
8fe71c637d | ||
|
|
aee5154eaf | ||
|
|
ae8c422c2f | ||
|
|
e61928b2a1 | ||
|
|
7749804365 | ||
|
|
c115058008 | ||
|
|
86c97ec191 | ||
|
|
b5b925dd06 | ||
|
|
7488677f7a | ||
|
|
14a8bf5369 | ||
|
|
96e4a1c591 | ||
|
|
6cb6dfd1d6 | ||
|
|
c31871b321 | ||
|
|
245118412f | ||
|
|
a75a4f0f9a | ||
|
|
f8664d8255 | ||
|
|
dad91079b2 | ||
|
|
273112424c | ||
|
|
9cc51f483a | ||
|
|
0adef65616 | ||
|
|
5b2b8a0a8d | ||
|
|
f33e7efb8d | ||
|
|
425dcbbc8e | ||
|
|
484104a2b0 | ||
|
|
7e34ab6da0 | ||
|
|
5b45d79790 | ||
|
|
7684d23398 | ||
|
|
a5610f0c8d | ||
|
|
4d178544e5 | ||
|
|
8a58f4a732 | ||
|
|
026eaae074 | ||
|
|
6515b43711 | ||
|
|
94a0ca4731 | ||
|
|
de60ed3ffe | ||
|
|
f5898b253a | ||
|
|
561a44fe77 | ||
|
|
b431fc526a | ||
|
|
3deefc9607 | ||
|
|
20363d509b | ||
|
|
134c3a5443 | ||
|
|
ab4cb2553a | ||
|
|
3bc3b3461f | ||
|
|
11a75b6458 | ||
|
|
62b8436353 | ||
|
|
875eda7ea2 | ||
|
|
82246daab0 | ||
|
|
7513ff9dfa | ||
|
|
96b032c2d0 | ||
|
|
de4f77d250 | ||
|
|
7c59ba4dc3 | ||
|
|
951e070466 | ||
|
|
adadce06b1 | ||
|
|
2341409bb4 | ||
|
|
7fee8e9fcf | ||
|
|
682c21296c | ||
|
|
aec6f20edc | ||
|
|
c89b55884f | ||
|
|
ded3ae9416 | ||
|
|
0808326967 | ||
|
|
889bd5aade | ||
|
|
a17aafa6f6 | ||
|
|
18da3a492c | ||
|
|
2fd3f84b2f | ||
|
|
68d350572f | ||
|
|
7660e707f7 | ||
|
|
f510c7de34 | ||
|
|
35e9e7d70d | ||
|
|
74f3793313 | ||
|
|
913e25ccac | ||
|
|
2ec151c68b | ||
|
|
cf49eef883 | ||
|
|
b56dacf04f | ||
|
|
22bb77492e | ||
|
|
ca1447f26a | ||
|
|
7f1bf00ef7 | ||
|
|
aeb9ddb96b | ||
|
|
3852e1175d | ||
|
|
1474e28de0 | ||
|
|
8a5ace61b2 | ||
|
|
932713e7a2 | ||
|
|
50228a43c8 | ||
|
|
326c69e92f | ||
|
|
e3225d4dab | ||
|
|
23d1538ea2 | ||
|
|
5f89715ee6 | ||
|
|
22f22ead37 | ||
|
|
5eff117972 | ||
|
|
b92e5b3683 | ||
|
|
b79f0f025d | ||
|
|
f40615ee21 | ||
|
|
222ae0950e | ||
|
|
afe89f8c0e | ||
|
|
867e495353 | ||
|
|
6263f7766b | ||
|
|
d65600786f | ||
|
|
a3a04d84c0 | ||
|
|
f295609ea2 | ||
|
|
80064996e9 | ||
|
|
973bef6386 | ||
|
|
4e2287aa5f | ||
|
|
17b8c7bb62 | ||
|
|
d10c68004a | ||
|
|
10830efca5 | ||
|
|
c3d9b2b536 | ||
|
|
3a04c64e79 | ||
|
|
eea424a826 | ||
|
|
4edcce2468 | ||
|
|
d54d9a480c | ||
|
|
b7d76b5e58 | ||
|
|
e83e45e8b9 | ||
|
|
86b7550c38 | ||
|
|
09b4b44c3e | ||
|
|
c6b26d20bc | ||
|
|
36ee84857b | ||
|
|
25b19ec635 | ||
|
|
614d3af796 | ||
|
|
bc05d93ce8 | ||
|
|
c0789f831c | ||
|
|
3be23a3ebc | ||
|
|
abd40ede1b | ||
|
|
aab5e39aa3 |
No files matched your search
@@ -0,0 +1,16 @@
|
||||
# Database Migrations & Schema Modification Rules
|
||||
|
||||
## 1. Defensive Migrations
|
||||
When making database schema changes, you must ensure that generated migrations are resilient against environmental discrepancies.
|
||||
|
||||
- **Review Generated SQL**: Always review the `.sql` files generated by `npx prisma migrate dev`.
|
||||
- **Add "IF EXISTS" clauses**: SQLite and Prisma can sometimes produce brittle drop statements (`DROP INDEX "my_index"`). To prevent migrations from crashing if a state desynchronization occurs (e.g., the index was already dropped or never created), manually edit the migration file to use `DROP INDEX IF EXISTS "my_index";` or `DROP TABLE IF EXISTS "table_name";`.
|
||||
- **Data Preservation**: When dropping columns or renaming, SQLite does not cleanly support it and requires table recreation. Carefully review the `INSERT INTO "new_table" SELECT ...` clauses to ensure data is correctly mapped.
|
||||
|
||||
## 2. Managing Failed Migrations
|
||||
If a migration fails in production:
|
||||
- **Never blindly mark as resolved**: Do not run `prisma migrate resolve --applied <migration_name>` unless you have explicitly verified that the database schema precisely matches the expected state.
|
||||
- If you use `resolve --applied`, Prisma will permanently skip that migration in the future, leaving your database structurally out of sync with your Prisma Client.
|
||||
|
||||
## 3. Backups Before DDL
|
||||
Never perform direct DDL operations (ALTER, DROP, CREATE) on a production database (via Prisma or direct SQLite access) without first confirming an automated backup exists, or manually taking a backup of the `wwv.db` file.
|
||||
+22
-4
@@ -1,7 +1,25 @@
|
||||
node_modules
|
||||
.next
|
||||
**/node_modules
|
||||
**/dist
|
||||
**/.next
|
||||
.git
|
||||
*.md
|
||||
artifacts
|
||||
|
||||
# Database files at ANY depth
|
||||
/data
|
||||
packages/*/data
|
||||
**/*.db
|
||||
**/*.sqlite
|
||||
**/*.sqlite3
|
||||
**/*-journal
|
||||
**/*.db-wal
|
||||
**/*.db-shm
|
||||
|
||||
# Environment files
|
||||
.env*
|
||||
!.env.example
|
||||
!*.env.example
|
||||
|
||||
# Non-build directories
|
||||
artifacts/
|
||||
performance/
|
||||
tmp/
|
||||
*.geojson
|
||||
@@ -1,4 +1,15 @@
|
||||
DATABASE_URL=file:./data/wwv.db
|
||||
|
||||
# Default plugins enabled on boot for demo edition
|
||||
# Comma-separated list of plugin IDs
|
||||
NEXT_PUBLIC_DEMO_DEFAULT_PLUGINS=iranwarlive,satellite,gps_jamming
|
||||
|
||||
# Edition: "local" | "cloud" | "demo"
|
||||
NEXT_PUBLIC_WWV_EDITION=local
|
||||
NEXT_PUBLIC_WWV_EDITION=local
|
||||
|
||||
# Auth Secret (REQUIRED for Docker — generate with: openssl rand -hex 32)
|
||||
# Must be stable across container restarts to preserve sessions.
|
||||
# [WARNING] NEVER commit real secrets here. Real secrets must ONLY go into .env.local!
|
||||
AUTH_SECRET=changeme_d64c1f35b447da89cf6ed5a0988da1379b21904edb91a87c3f5a63942e3d23a4_changeme
|
||||
|
||||
|
||||
@@ -13,6 +13,12 @@ DATABASE_URL=file:./data/wwv.db
|
||||
# Copy everything below into a new file called .env.local
|
||||
# .env.local is gitignored and overrides .env values.
|
||||
|
||||
# Auth Secret (REQUIRED — generate with: openssl rand -hex 32)
|
||||
# Must remain stable across restarts to preserve sessions and tokens.
|
||||
# For Docker: also set this in the host environment or a .env file
|
||||
# at the project root so docker-compose can inject it.
|
||||
AUTH_SECRET=
|
||||
|
||||
# Cesium Ion Access Token (optional — get one free at https://ion.cesium.com/)
|
||||
NEXT_PUBLIC_CESIUM_ION_TOKEN=
|
||||
|
||||
@@ -25,16 +31,27 @@ NEXT_PUBLIC_BING_MAPS_KEY=
|
||||
NEXT_PUBLIC_SUPABASE_URL=
|
||||
NEXT_PUBLIC_SUPABASE_ANON_KEY=
|
||||
SUPABASE_SERVICE_ROLE_KEY=
|
||||
SUPABASE_DATABASE_URL=
|
||||
|
||||
# OpenSky Network — multi-account credential rotation
|
||||
# Comma-separated clientId:clientSecret pairs.
|
||||
# Example: OPENSKY_CREDENTIALS=acct1-id:acct1-secret,acct2-id:acct2-secret
|
||||
OPENSKY_CREDENTIALS=
|
||||
|
||||
# ACLED API — Civil Unrest & Conflict data (free for non-commercial use)
|
||||
# Register at https://developer.acleddata.com/ to obtain credentials.
|
||||
# Data is updated weekly (Mondays) with global protest, riot, and violence events.
|
||||
ACLED_EMAIL=
|
||||
ACLED_PASSWORD=
|
||||
|
||||
# Marketplace Bridge Token — shared secret for marketplace → WWV install requests
|
||||
# Generate any random string, then set the same value in the marketplace instance config.
|
||||
WWV_BRIDGE_TOKEN=
|
||||
|
||||
# Default plugins enabled on boot for demo edition
|
||||
# Comma-separated list of plugin IDs
|
||||
NEXT_PUBLIC_DEMO_DEFAULT_PLUGINS=
|
||||
|
||||
# Edition: "local" | "cloud" | "demo"
|
||||
NEXT_PUBLIC_WWV_EDITION=local
|
||||
|
||||
|
||||
@@ -1,37 +1,29 @@
|
||||
---
|
||||
name: Bug Report
|
||||
about: Report something that isn't working correctly
|
||||
about: Create a report to help us improve WorldWideView
|
||||
title: '[BUG] '
|
||||
labels: bug
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
## Describe the Bug
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
## Steps to Reproduce
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '...'
|
||||
3. See error
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
## Expected Behaviour
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
What you expected to happen.
|
||||
**Screenshots/Logs**
|
||||
If applicable, add screenshots or console output to help explain your problem.
|
||||
|
||||
## Actual Behaviour
|
||||
|
||||
What actually happened. Include screenshots or console errors if applicable.
|
||||
|
||||
## Environment
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| OS | e.g. Windows 11 |
|
||||
| Browser | e.g. Chrome 122 |
|
||||
| Node.js | e.g. 20.x |
|
||||
| Plugin(s) affected | e.g. ADS-B, AIS |
|
||||
|
||||
## Additional Context
|
||||
|
||||
Any other context about the problem — relevant config, data source URLs, Cesium Ion token issues, etc.
|
||||
**Environment (please complete the following information):**
|
||||
- OS: [e.g. Windows, macOS]
|
||||
- Browser [e.g. chrome, safari, firefox]
|
||||
- WorldWideView Edition [e.g. local, demo, cloud]
|
||||
@@ -1,29 +1,19 @@
|
||||
---
|
||||
name: Feature Request
|
||||
about: Suggest a new feature or improvement
|
||||
name: Core Feature Request
|
||||
about: Suggest an idea for the core WorldWideView engine
|
||||
title: '[FEATURE] '
|
||||
labels: enhancement
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
## Summary
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
A brief, one-line description of the feature.
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
## Motivation
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
Why is this needed? What problem does it solve or what use case does it enable?
|
||||
|
||||
## Proposed Solution
|
||||
|
||||
Describe your suggested approach. If this is a new **plugin**, describe:
|
||||
- The data source (URL, format, update frequency)
|
||||
- What it would render on the globe (icons, paths, primitives)
|
||||
- Any external APIs or credentials required
|
||||
|
||||
## Alternatives Considered
|
||||
|
||||
Any other approaches you thought about and why you ruled them out.
|
||||
|
||||
## Additional Context
|
||||
|
||||
Screenshots, mockups, links to similar tools, or relevant documentation.
|
||||
**Note:** If this is about adding a new data source (like mapping vessels or plotting weather), please use the **Plugin Proposal** template instead! This template is for core engine features (like camera logic, filtering, or rendering pipeline upgrades).
|
||||
@@ -0,0 +1,25 @@
|
||||
---
|
||||
name: Plugin Proposal
|
||||
about: Suggest a new real-time data source plugin
|
||||
title: '[PLUGIN] '
|
||||
labels: plugin-idea, help-wanted
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**What data source do you want to add?**
|
||||
Please provide a brief description of the intelligence data (e.g., Global Earthquakes, Shipping Vessels, Weather Radar, Local Train Networks).
|
||||
|
||||
**Is there an available API?**
|
||||
Please link to any public or authenticated APIs that provide this data.
|
||||
*(e.g., USGS Earthquake API: https://earthquake.usgs.gov/earthquakes/feed/v1.0/geojson.php)*
|
||||
|
||||
**What should the plugin render?**
|
||||
- What kind of marker? (e.g., dots, icons, 3D models)
|
||||
- Does it require historical tracking (paths), or just current position?
|
||||
|
||||
**Would you be interested in building this?**
|
||||
- [ ] Yes, I'd like to try building it!
|
||||
- [ ] No, just putting the idea out there.
|
||||
|
||||
*(Looking to build it yourself? Check out the [Build a Plugin in 5 Minutes](https://github.com/silvertakana/worldwideview#build-a-plugin-in-5-minutes) guide in the README!)*
|
||||
@@ -0,0 +1,59 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
typecheck:
|
||||
name: Type Check
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 9
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
cache: pnpm
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- run: npx prisma generate
|
||||
- run: pnpm exec tsc --noEmit
|
||||
|
||||
test:
|
||||
name: Unit Tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 9
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
cache: pnpm
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- run: npx prisma generate
|
||||
- run: pnpm test
|
||||
|
||||
build:
|
||||
name: Build
|
||||
runs-on: ubuntu-latest
|
||||
needs: [typecheck, test]
|
||||
env:
|
||||
DATABASE_URL: file:./data/wwv.db
|
||||
AUTH_SECRET: ci-placeholder-secret-not-used-in-tests
|
||||
NEXT_PUBLIC_WWV_EDITION: local
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 9
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
cache: pnpm
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- run: npx prisma generate
|
||||
- run: pnpm build
|
||||
@@ -0,0 +1,44 @@
|
||||
name: Claude Code Review
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
types: [opened, synchronize, ready_for_review, reopened]
|
||||
# Optional: Only run on specific file changes
|
||||
# paths:
|
||||
# - "src/**/*.ts"
|
||||
# - "src/**/*.tsx"
|
||||
# - "src/**/*.js"
|
||||
# - "src/**/*.jsx"
|
||||
|
||||
jobs:
|
||||
claude-review:
|
||||
# Optional: Filter by PR author
|
||||
# if: |
|
||||
# github.event.pull_request.user.login == 'external-contributor' ||
|
||||
# github.event.pull_request.user.login == 'new-developer' ||
|
||||
# github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: read
|
||||
issues: read
|
||||
id-token: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Run Claude Code Review
|
||||
id: claude-review
|
||||
uses: anthropics/claude-code-action@v1
|
||||
with:
|
||||
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
|
||||
plugin_marketplaces: 'https://github.com/anthropics/claude-code.git'
|
||||
plugins: 'code-review@claude-code-plugins'
|
||||
prompt: '/code-review:code-review ${{ github.repository }}/pull/${{ github.event.pull_request.number }}'
|
||||
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
|
||||
# or https://code.claude.com/docs/en/cli-reference for available options
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
name: Claude Code
|
||||
|
||||
on:
|
||||
issue_comment:
|
||||
types: [created]
|
||||
pull_request_review_comment:
|
||||
types: [created]
|
||||
issues:
|
||||
types: [opened, assigned]
|
||||
pull_request_review:
|
||||
types: [submitted]
|
||||
|
||||
jobs:
|
||||
claude:
|
||||
if: |
|
||||
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
|
||||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
|
||||
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
|
||||
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: read
|
||||
issues: read
|
||||
id-token: write
|
||||
actions: read # Required for Claude to read CI results on PRs
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Run Claude Code
|
||||
id: claude
|
||||
uses: anthropics/claude-code-action@v1
|
||||
with:
|
||||
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
|
||||
|
||||
# This is an optional setting that allows Claude to read CI results on PRs
|
||||
additional_permissions: |
|
||||
actions: read
|
||||
|
||||
# Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it.
|
||||
# prompt: 'Update the pull request description to include a summary of changes.'
|
||||
|
||||
# Optional: Add claude_args to customize behavior and configuration
|
||||
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
|
||||
# or https://code.claude.com/docs/en/cli-reference for available options
|
||||
# claude_args: '--allowed-tools Bash(gh pr:*)'
|
||||
|
||||
+28
-3
@@ -1,7 +1,7 @@
|
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
node_modules/
|
||||
/.pnp
|
||||
.pnp.*
|
||||
.yarn/*
|
||||
@@ -20,17 +20,30 @@
|
||||
# agents
|
||||
/.agents/
|
||||
|
||||
# claude code IDE config
|
||||
/.claude/
|
||||
/.cline/
|
||||
|
||||
# performance
|
||||
/performance/
|
||||
|
||||
# artifacts
|
||||
/artifacts/
|
||||
|
||||
# scripts
|
||||
/scripts/
|
||||
# scripts (tracked, but temporary scratchpads should go in /local-scripts/)
|
||||
|
||||
|
||||
# local database
|
||||
/data/
|
||||
packages/*/data/
|
||||
*.db
|
||||
*.sqlite
|
||||
*.sqlite3
|
||||
*.db-shm
|
||||
*.db-wal
|
||||
|
||||
# temporary files and credentials
|
||||
/tmp/
|
||||
|
||||
# generated prisma client
|
||||
/src/generated/
|
||||
@@ -61,3 +74,15 @@ next-env.d.ts
|
||||
|
||||
# Plugin build artifacts
|
||||
packages/*/dist/
|
||||
|
||||
# Reference Reference Codebases
|
||||
/worldmonitor/
|
||||
|
||||
# Developmental scripts & temporary sandbox
|
||||
/local-scripts/
|
||||
|
||||
# git worktrees
|
||||
/.worktrees/
|
||||
|
||||
# proprietary extracted services
|
||||
packages/wwv-data-engine/
|
||||
Vendored
+36
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Next.js: debug server-side",
|
||||
"type": "node-terminal",
|
||||
"request": "launch",
|
||||
"command": "pnpm run dev",
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
{
|
||||
"name": "Next.js: debug client-side",
|
||||
"type": "chrome",
|
||||
"request": "launch",
|
||||
"url": "http://localhost:3000",
|
||||
"webRoot": "${workspaceFolder}",
|
||||
"sourceMapPathOverrides": {
|
||||
"webpack://_N_E/*": "${webRoot}/*"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "WWV Data Engine: debug",
|
||||
"type": "node-terminal",
|
||||
"request": "launch",
|
||||
"command": "pnpm --filter wwv-data-engine run dev",
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
{
|
||||
"name": "Full Stack: debug",
|
||||
"type": "node-terminal",
|
||||
"request": "launch",
|
||||
"command": "pnpm run dev:all",
|
||||
"cwd": "${workspaceFolder}"
|
||||
}
|
||||
]
|
||||
}
|
||||
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "npm: dev:all",
|
||||
"type": "npm",
|
||||
"script": "dev:all",
|
||||
"problemMatcher": [],
|
||||
"isBackground": true,
|
||||
"presentation": {
|
||||
"reveal": "always",
|
||||
"panel": "new"
|
||||
},
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,345 @@
|
||||
# WorldWideView — Agent Rules
|
||||
|
||||
## 1. Project Identity
|
||||
|
||||
WorldWideView is a **real-time geospatial intelligence engine** that visualizes live global data on an interactive 3D globe. Built with **Next.js 16**, **CesiumJS**, **React 19**, and **Zustand**, it renders everything from live aircraft and maritime vessels to conflict events, satellites, and environmental data — all through a modular plugin architecture.
|
||||
|
||||
### Target Inspiration
|
||||
Our primary design, feature-set, and operational layout goal is to mimic the structure and capabilities of `www.worldmonitor.app`.
|
||||
- **Reference Codebase**: [GitHub - koala73/worldmonitor](https://github.com/koala73/worldmonitor)
|
||||
---
|
||||
|
||||
## 2. Tech Stack
|
||||
|
||||
| Layer | Technology |
|
||||
|---|---|
|
||||
| Framework | Next.js 16 (App Router, `output: "standalone"`) |
|
||||
| Language | TypeScript 5, strict mode |
|
||||
| 3D Engine | CesiumJS + Resium (Google Photorealistic 3D Tiles) |
|
||||
| State | Zustand (slice-based: globe, layers, timeline, UI, filters, data, config, favorites, geojson) |
|
||||
| Event Bus | Custom typed `DataBus` (pub/sub singleton) |
|
||||
| Styling | Vanilla CSS — **no Tailwind** |
|
||||
| Database | SQLite via Prisma (local), PostgreSQL (cloud) |
|
||||
| Auth | NextAuth v5 beta (Credentials provider, JWT sessions) |
|
||||
| Package Manager | pnpm (monorepo with `pnpm-workspace.yaml`) |
|
||||
| Testing | Vitest + jsdom + React Testing Library |
|
||||
| Deployment | Docker multi-stage build → Coolify |
|
||||
| Analytics | Vercel Analytics / custom `trackEvent` |
|
||||
|
||||
---
|
||||
|
||||
## 3. Directory Structure
|
||||
|
||||
```
|
||||
worldwideview/
|
||||
├── src/
|
||||
│ ├── app/ # Next.js App Router (pages, API routes, layouts)
|
||||
│ │ ├── api/ # Server-side API routes (auth, aviation, camera, etc.)
|
||||
│ │ ├── login/ # Login page
|
||||
│ │ ├── setup/ # First-time setup page
|
||||
│ │ └── globals.css # Root stylesheet
|
||||
│ ├── components/
|
||||
│ │ ├── common/ # Shared UI: BootOverlay, FloatingWindow, PluginIcon
|
||||
│ │ ├── layout/ # AppShell, Header, SearchBar, DataBusSubscriber
|
||||
│ │ ├── panels/ # LayerPanel, EntityInfoCard, FilterPanel, GraphicsSettings
|
||||
│ │ ├── timeline/ # Timeline component
|
||||
│ │ ├── marketplace/ # Plugin install/unverified dialogs
|
||||
│ │ ├── ui/ # Tooltip, ReloadToast
|
||||
│ │ └── video/ # Floating video manager
|
||||
│ ├── core/
|
||||
│ │ ├── data/ # DataBus, PollingManager, CacheLayer, SmartFetcher
|
||||
│ │ ├── filters/ # filterEngine (applies plugin filters to entities)
|
||||
│ │ ├── globe/ # GlobeView, EntityRenderer, AnimationLoop, StackManager,
|
||||
│ │ │ │ CameraController, InteractionHandler, SelectionHandler,
|
||||
│ │ │ │ ModelManager, ImageryProviderFactory
|
||||
│ │ │ └── hooks/ # useCameraActions, useEntityRendering, useModelRendering, etc.
|
||||
│ │ ├── hooks/ # useBootSequence, useIsMobile, useMarketplaceSync
|
||||
│ │ ├── plugins/ # PluginManager, PluginRegistry, PluginManifest,
|
||||
│ │ │ │ loadPluginFromManifest, validateManifest, InstalledPluginsLoader
|
||||
│ │ │ └── loaders/ # DeclarativePlugin, StaticDataPlugin, mapJsonToEntities
|
||||
│ │ └── state/ # Zustand store + slices (config, data, globe, layers, timeline, ui, etc.)
|
||||
│ ├── lib/ # auth, db, rateLimit, analytics, AIS stream, marketplace APIs
|
||||
│ ├── plugins/ # GeoJSON plugin registrations
|
||||
│ ├── styles/ # HUD animations CSS
|
||||
│ ├── types/ # GeoJSON types, Umami types
|
||||
│ └── generated/ # Prisma generated client (gitignored)
|
||||
├── packages/ # pnpm monorepo workspace packages
|
||||
│ ├── wwv-plugin-sdk/ # Plugin SDK: type definitions, manifest schema
|
||||
│ ├── wwv-plugin-aviation/
|
||||
│ ├── wwv-plugin-maritime/
|
||||
│ ├── wwv-plugin-wildfire/
|
||||
│ ├── wwv-plugin-borders/
|
||||
│ ├── wwv-plugin-camera/
|
||||
│ ├── wwv-plugin-military-aviation/
|
||||
│ ├── wwv-plugin-satellite/
|
||||
│ ├── wwv-plugin-iranwarlive/ # Includes standalone backend/ microservice
|
||||
│ └── wwv-plugin-{airports,embassies,lighthouses,nuclear,seaports,spaceports,volcanoes}/
|
||||
├── prisma/ # schema.prisma, migrations/
|
||||
├── public/ # Static assets, Cesium workers, plugin GeoJSON data
|
||||
├── scripts/ # Build scripts (copy-cesium, scaffold-osm-plugin, setup)
|
||||
├── data/ # SQLite database (gitignored, Docker volume)
|
||||
├── Dockerfile # Multi-stage production build
|
||||
├── docker-compose.yml # Main app + microservice backends
|
||||
└── .agents/ # Agent documentation, rules, skills, workflows
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 4. Architecture Patterns
|
||||
|
||||
### 4.1 Plugin System (Core Abstraction)
|
||||
|
||||
Every data source is a **plugin** implementing the `WorldPlugin` interface from `@worldwideview/wwv-plugin-sdk`. The lifecycle utilizes a real-time WebSocket Firehose pipeline:
|
||||
|
||||
```text
|
||||
PluginRegistry.register() → PluginManager.registerPlugin()
|
||||
→ plugin.initialize(context)
|
||||
|
||||
Visibility Toggle → DataBusSubscriber subscribes to layer via WsClient
|
||||
→ Engine responds with instantaneous websocket snapshots over /stream
|
||||
→ WsClient pipes to DataBus.emit("dataUpdated", WsStreamPayload)
|
||||
→ Store → EntityRenderer → Globe
|
||||
```
|
||||
|
||||
Four plugin architectures exist:
|
||||
1. **Static** — GeoJSON file in `public/data/`, loaded by `StaticDataPlugin`
|
||||
2. **Active Proxied** — Next.js API routes in `src/app/api/` as CORS proxy
|
||||
3. **Microservice** — Standalone Fastify container with SQLite (e.g., `iranwarlive-backend`)
|
||||
4. **Dynamic CDN Loaded (Bundle)** — Externally developed plugins dynamically imported at runtime via ES module CDNs (e.g., `unpkg.com` version-pinned URLs). Handled by `loadBundlePlugin` using `import(/* webpackIgnore: true */ entry)`.
|
||||
|
||||
Plugin types are re-exported from SDK through `src/core/plugins/PluginTypes.ts` and `PluginManifest.ts` — **source of truth is always `@worldwideview/wwv-plugin-sdk`**.
|
||||
|
||||
### 4.2 State Management
|
||||
|
||||
Zustand store with **nine slices**: `globe`, `layers`, `timeline`, `ui`, `filter`, `data`, `config`, `favorites`, `geojson`. Each slice is in its own file under `src/core/state/`.
|
||||
|
||||
- Access via `useStore` hook or `useStore.getState()` outside React
|
||||
- Plugin settings stored in `configSlice.dataConfig.pluginSettings`
|
||||
- Polling intervals stored in `configSlice.dataConfig.pollingIntervals`
|
||||
|
||||
### 4.3 Data Pipeline
|
||||
|
||||
```text
|
||||
Engine push /stream → DataBusSubscriber WsClient router
|
||||
→ WsClient.handleMessage() → DataBus.emit("websocketData")
|
||||
→ DataBusSubscriber → _hydrateSnapshot() → Store.entitiesByPlugin
|
||||
→ GlobeView (memoized visible entities)
|
||||
→ EntityRenderer (billboard/point primitives)
|
||||
→ AnimationLoop (horizon culling, hover/selection)
|
||||
→ StackManager (co-located entity grouping)
|
||||
```
|
||||
|
||||
### 4.4 Rendering Pipeline
|
||||
|
||||
- **Primitive-based**: Uses `PointPrimitiveCollection`, `BillboardCollection`, `LabelCollection` — NOT Cesium Entity API
|
||||
- **Chunked processing**: Large datasets (10k+) rendered via `ChunkedProcessor`
|
||||
- **LOD system**: Model-type entities promoted to 3D models at close range (`useModelRendering`)
|
||||
- **Horizon culling**: Manual dot-product calculation against Earth radius (NOT depth testing)
|
||||
- **Stack/Spiderifier**: `StackManager` groups co-located entities; `stackAnimation` handles expansion
|
||||
|
||||
### 4.5 Edition System
|
||||
|
||||
Three editions controlled by `NEXT_PUBLIC_WWV_EDITION`:
|
||||
- **`local`** — Self-hosted, full features, auth enabled
|
||||
- **`cloud`** — Managed cloud instance, full features
|
||||
- **`demo`** — Public demo, auth disabled, optional admin via `WWV_DEMO_ADMIN_SECRET`
|
||||
|
||||
Feature flags derived from edition in `src/core/edition.ts`.
|
||||
|
||||
---
|
||||
|
||||
## 5. Critical Conventions
|
||||
|
||||
### 5.1 File Size
|
||||
|
||||
**Max 150 lines per file.** If a file grows beyond this, modularize it. Extract helpers, split components, use hooks.
|
||||
|
||||
### 5.2 Import Aliases
|
||||
|
||||
- `@/*` → `./src/*`
|
||||
- `@worldwideview/wwv-plugin-sdk` → `./packages/wwv-plugin-sdk/src`
|
||||
- Each plugin has its own alias in `tsconfig.json`
|
||||
|
||||
### 5.3 CSS Rules
|
||||
|
||||
- **Vanilla CSS only** — no Tailwind, no CSS-in-JS
|
||||
- Global styles in `src/app/globals.css`
|
||||
- Component-scoped styles use CSS Modules (`.module.css`) or co-located `.css` files
|
||||
- HUD animations in `src/styles/hud-animations.css`
|
||||
|
||||
### 5.4 Rendering Entity Rules
|
||||
|
||||
When returning `CesiumEntityOptions` from `renderEntity()`:
|
||||
|
||||
- **Points**: Use `type: "point"` with `color`, `size`, `outlineColor`, `outlineWidth`
|
||||
- **Billboards**: Use `type: "billboard"` with `iconUrl`, `color`, `iconScale`
|
||||
- **NEVER mix**: Do not use `size`/`outlineWidth`/`outlineColor` on billboard entities — causes GPU clipping
|
||||
|
||||
### 5.5 Plugin Registration
|
||||
|
||||
Built-in plugins are instantiated in `AppShell.tsx` and registered via `PluginRegistry` → `PluginManager`. Marketplace-installed plugins are loaded from the database via `InstalledPluginsLoader`.
|
||||
|
||||
### 5.6 Workspace Rules
|
||||
|
||||
- Always run `pnpm install` from project root after creating new packages
|
||||
- Plugin packages go in `packages/wwv-plugin-<name>/`
|
||||
- Microservice backends go in `packages/wwv-plugin-<name>/backend/`
|
||||
- Both globs (`packages/*` and `packages/*/backend`) are in `pnpm-workspace.yaml`
|
||||
- Add new plugins to `transpilePackages` in `next.config.ts` and `paths` in `tsconfig.json`
|
||||
|
||||
### 5.7 AI Meta-Directives: Antigravity Standard (Claude Code)
|
||||
|
||||
> [!NOTE]
|
||||
> This repository is orchestrated via the **Antigravity open standard** using **Claude Code** as the active agent. The entry point for Claude Code is `CLAUDE.md` at the project root.
|
||||
|
||||
> [!WARNING]
|
||||
> - **Always** use standard `.md` file extensions for rules, skills, and workflows.
|
||||
> - **Never** use proprietary `.mdc` extensions.
|
||||
> - **Never** reference Cursor IDE rules; we use the open `.agents/` standard.
|
||||
> - **MUST**: You MUST update Semantic Versioning numbering inside the relevant `package.json` file prior to executing any code commits, adhering strictly to the `[/commit]` workflow rules (`feat:` -> Minor, `fix/refactor/perf:` -> Patch).
|
||||
> - **MUST Detail Commit Levels & Bumps**: On description changes or release notes, you must detail the level of commit (Major/Minor/Fix) for *each* individual change. If there are multiple accumulated changes, you MUST EITHER commit them individually and bump the version each time, OR commit them all at once and bump the version multiple times.
|
||||
> - **MUST Explain Complex Concepts Simply**: Whenever providing a complicated technical explanation to the user, you MUST include a simple explanation below it. Use an analogy comparing the concept to something from everyday life to ensure the user easily understands it.
|
||||
|
||||
### 5.8 Workspace Hygiene
|
||||
Whenever agents generate temporary debugging scripts, test REST endpoints via `.mjs`, or dump traces/JSON outputs, they **MUST** save these exclusively inside `/local-scripts/`. The root directory is strictly for production configuration files.
|
||||
|
||||
---
|
||||
|
||||
## 6. Environment Variables
|
||||
|
||||
| Variable | Required | Description |
|
||||
|---|---|---|
|
||||
| `DATABASE_URL` | Yes | SQLite: `file:./data/wwv.db` |
|
||||
| `AUTH_SECRET` | Yes | JWT signing secret (generate with `openssl rand -hex 32`) |
|
||||
| `NEXT_PUBLIC_CESIUM_ION_TOKEN` | No | Cesium Ion access token |
|
||||
| `NEXT_PUBLIC_BING_MAPS_KEY` | No | Bing Maps imagery |
|
||||
| `NEXT_PUBLIC_GOOGLE_MAPS_API_KEY` | No | Google 3D Tiles |
|
||||
| `NEXT_PUBLIC_WWV_EDITION` | No | `local` / `cloud` / `demo` (default: `local`) |
|
||||
| `OPENSKY_CREDENTIALS` | No | Comma-separated `id:secret` pairs for credential rotation |
|
||||
| `WWV_BRIDGE_TOKEN` | No | Shared secret for marketplace → WWV install bridge |
|
||||
| `WWV_DEMO_ADMIN_SECRET` | No | Demo edition admin password |
|
||||
| `IRANWARLIVE_BACKEND_URL` | No | Override for IranWarLive microservice URL |
|
||||
|
||||
Secrets go in `.env.local` (gitignored). Non-secrets go in `.env` (committed).
|
||||
|
||||
---
|
||||
|
||||
## 7. Development Commands
|
||||
|
||||
```bash
|
||||
pnpm install # Install all workspace dependencies
|
||||
pnpm run setup # Generate .env.local with AUTH_SECRET (first-time setup)
|
||||
pnpm dev # Next.js frontend only (auto-runs prisma migrate deploy + copy-cesium)
|
||||
pnpm dev:all # Frontend + wwv-data-engine concurrently (normal development)
|
||||
pnpm dev:backends # Run only the data engine in dev mode
|
||||
pnpm build # Production build
|
||||
pnpm test # Run all Vitest tests (scoped to src/lib, src/core, src/plugins)
|
||||
pnpm db:reset # Reset and re-migrate the frontend SQLite database (destructive)
|
||||
pnpm start:backends # Start all plugin microservice backends in parallel
|
||||
pnpm clean:backends # Wipe all plugin SQLite databases
|
||||
pnpm run scaffold-osm-plugin <name> # Generate a new plugin from scaffold
|
||||
```
|
||||
|
||||
Frontend runs at `http://localhost:3000`.
|
||||
|
||||
---
|
||||
|
||||
## 8. Deployment
|
||||
|
||||
- **Docker**: Multi-stage Dockerfile using the Extractor Pattern (`deps` → `builder` → `runner`). The `node_modules` folders must be explicitly untracked in from `git` across the workspace to prevent corrupted BuildKit contextual cache overlaps during the `COPY . .` stage.
|
||||
- **Standalone output**: `next.config.ts` uses `output: "standalone"`.
|
||||
- **Cesium assets**: Copied to `public/cesium/` via `scripts/copy-cesium.mjs` at build time, excluded from output tracing.
|
||||
- **Prisma Configuration**: `prisma.config.ts` must export a native javascript object instead of dynamically importing CLI wrapper binaries (`prisma/config` or `dotenv`). The standalone Next.js tracer strips CLI devDependencies during the build, which will cause fatal runtime container crashes if imported.
|
||||
- **Microservices**: Separate containers defined in `docker-compose.yml`, proxied via `next.config.ts` rewrites.
|
||||
- **Coolify**: Deployed via Dockerfile builder natively mapping environment variables continuously into the container shell. Persistent storage mount required at `/app/data` for the SQLite root node database.
|
||||
- **Docker volumes**: Mount `/app/data` (frontend SQLite), `/app/packages/wwv-data-engine/data` (data engine SQLite), `/data` (Redis)
|
||||
|
||||
---
|
||||
|
||||
## 9. Testing Strategy
|
||||
|
||||
- **Framework**: Vitest with jsdom environment
|
||||
- **Coverage**: `src/lib/**`, `src/core/**`, `src/plugins/**`
|
||||
- **Run**: `pnpm test` (or `vitest run`)
|
||||
- **Key test files**: `rateLimit.test.ts`, `edition.test.ts`, `demoAdmin.test.ts`, `DeclarativePlugin.test.ts`, `cors.test.ts`, `repository.test.ts`, `marketplaceToken.test.ts`
|
||||
|
||||
---
|
||||
|
||||
## 10. Security Headers
|
||||
|
||||
Configured in `next.config.ts` `headers()`:
|
||||
- **CSP**: Restrictive with exceptions for CesiumJS (`unsafe-eval`, `unsafe-inline`), camera streams (`http: https:`), and analytics
|
||||
- **X-Frame-Options**: DENY
|
||||
- **X-Content-Type-Options**: nosniff
|
||||
- **Referrer-Policy**: strict-origin-when-cross-origin
|
||||
- **Permissions-Policy**: camera/microphone disabled, geolocation self-only
|
||||
|
||||
---
|
||||
|
||||
## 11. Related Repositories
|
||||
|
||||
| Repo | Purpose |
|
||||
|---|---|
|
||||
| `worldwideview` | Main application (this repo) |
|
||||
| `worldwideview-marketplace` | Plugin marketplace web app |
|
||||
| `worldwideview-web` | Marketing / landing page |
|
||||
|
||||
---
|
||||
|
||||
## 12. On-Demand Rules
|
||||
|
||||
Read the relevant rule file when working in that domain:
|
||||
|
||||
| Rule | When to use | Path |
|
||||
|---|---|---|
|
||||
| `monorepo-workflow` | pnpm commands, adding packages, workspace config | `.agents/rules/monorepo-workflow.md` |
|
||||
| `plugin-architecture` | Creating/modifying plugins, lifecycle, registration | `.agents/rules/plugin-architecture.md` |
|
||||
| `cesium-rendering` | Globe rendering, entity types, primitives, LOD, culling | `.agents/rules/cesium-rendering.md` |
|
||||
| `state-management` | Zustand slices, store access, plugin settings | `.agents/rules/state-management.md` |
|
||||
| `database-migrations` | Prisma schema changes, migrations, SQLite/Postgres | `.agents/rules/database-migrations.md` |
|
||||
| `continuous-improvement` | When to create/update rules, skills, or workflows | `.agents/rules/continuous-improvement.md` |
|
||||
| `context-and-memory` | How to orient and maintain project context between sessions | `.agents/rules/context-and-memory.md` |
|
||||
|
||||
---
|
||||
|
||||
## 13. Slash Commands / Workflows
|
||||
|
||||
Invoke by name. Read the skill/workflow file and follow its steps.
|
||||
|
||||
| Command | Description | File |
|
||||
|---|---|---|
|
||||
| `/commit` | **Required before every commit** — bump semver + conventional commit | `.agents/skills/commit/SKILL.md` |
|
||||
| `/remember` | Save a lesson, constraint, or fact into `.agents/` permanent memory | `.agents/skills/remember/SKILL.md` |
|
||||
| `/pr-review` | 6-role comprehensive pull request review | `.agents/skills/pr-review/SKILL.md` |
|
||||
| `/update-context` | Sync `.agents/context/` with current project state | Global skill |
|
||||
| `/local-dev` | Check, start, and troubleshoot local dev environment | `.agents/workflows/local-dev.md` |
|
||||
| `/data-engine-cli` | Use the wwv-data-engine CLI wrapper | `.agents/workflows/data-engine-cli.md` |
|
||||
| `/debugging-coolify` | Troubleshoot deployed apps on Coolify via MCP/SSH | `.agents/workflows/debugging-coolify.md` |
|
||||
| `/five` | Five Whys root cause analysis | `.agents/workflows/five.md` |
|
||||
| `/stitch-to-nextjs` | Generate UI with Stitch MCP, port into Next.js | `.agents/workflows/stitch-to-nextjs.md` |
|
||||
| `/bing-news-hydration` | Hydrate event attributes with Bing RSS news | `.agents/workflows/bing-news-hydration.md` |
|
||||
| `/generate-user-roadmap` | Generate updated user-facing roadmap | `.agents/workflows/generate-user-roadmap.md` |
|
||||
|
||||
---
|
||||
|
||||
## 14. Agent Skills Reference
|
||||
|
||||
Refer to these skill documents for specialized tasks:
|
||||
|
||||
### Project Skills (`.agents/skills/`)
|
||||
|
||||
| Skill | When to Use |
|
||||
|---|---|
|
||||
| `worldwideview-plugin-creation` | **Use when creating any plugin** — strict architectural checklist |
|
||||
| `plugin-creation-master-guide.md` | Decision matrix for choosing plugin architecture |
|
||||
| `osm-static-plugin-creation.md` | Creating static GeoJSON plugins from OpenStreetMap |
|
||||
| `microservice-plugin-creation.md` | Building standalone Fastify microservice backends |
|
||||
| `database-operations.md` | Prisma schema changes, migrations, database queries |
|
||||
| `database-incident-recovery-procedures.md` | Authoritative protocol for safely restoring a broken production database |
|
||||
| `index-documentation.md` | Maintaining project documentation index |
|
||||
| `context7` | Fetch up-to-date library docs via Context7 API |
|
||||
| `cesium-context7` | CesiumJS-specific documentation lookup |
|
||||
|
||||
### Global Skills
|
||||
|
||||
52 skills are available across all projects. See `.agents/global-skills-index.md` for the full list and invocation paths.
|
||||
+2
-2
@@ -32,9 +32,9 @@ This project is licensed under the [Elastic License 2.0](./LICENSE). By submitti
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
4. **Copy the environment file** and fill in your API keys:
|
||||
4. **Generate environment file** (auto-creates `.env.local` with `AUTH_SECRET`):
|
||||
```bash
|
||||
cp .env.example .env.local
|
||||
npm run setup
|
||||
```
|
||||
5. **Start the dev server**:
|
||||
```bash
|
||||
|
||||
+58
-12
@@ -1,32 +1,78 @@
|
||||
# Stage 1: Install dependencies
|
||||
FROM node:22-alpine AS deps
|
||||
# Stage 0: Extract package.json files for layer caching
|
||||
FROM alpine AS extractor
|
||||
WORKDIR /app
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm ci
|
||||
|
||||
# Stage 2: Build the application
|
||||
FROM node:22-alpine AS builder
|
||||
WORKDIR /app
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
RUN find . -type f \! -name 'package.json' \! -name 'pnpm-workspace.yaml' \! -name 'pnpm-lock.yaml' -delete && \
|
||||
find . -type d -empty -delete
|
||||
|
||||
# Stage 1: Install ALL dependencies (needed for build)
|
||||
FROM node:22-alpine AS deps
|
||||
RUN corepack enable pnpm
|
||||
RUN apk add --no-cache python3 make g++
|
||||
WORKDIR /app
|
||||
# Copy only the extracted package.jsons
|
||||
COPY --from=extractor /app ./
|
||||
# Install dependencies with cache mount for pnpm store
|
||||
RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store pnpm install --frozen-lockfile
|
||||
|
||||
|
||||
# Stage 3: Build the application
|
||||
FROM deps AS builder
|
||||
# Copy full source code
|
||||
COPY . .
|
||||
RUN DATABASE_URL="file:./data/wwv.db" npx prisma generate
|
||||
|
||||
# Create an empty SQLite database with all tables applied
|
||||
RUN mkdir -p ./data && DATABASE_URL=file:./data/wwv.db npx prisma migrate deploy
|
||||
|
||||
# Next.js inlines NEXT_PUBLIC_* vars at build time — must be declared as ARGs
|
||||
ARG NEXT_PUBLIC_CESIUM_ION_TOKEN
|
||||
ARG NEXT_PUBLIC_GOOGLE_MAPS_API_KEY
|
||||
ARG NEXT_PUBLIC_BING_MAPS_KEY
|
||||
ARG NEXT_PUBLIC_WWV_EDITION
|
||||
ARG NEXT_PUBLIC_WS_ENGINE_URL
|
||||
ARG NEXT_PUBLIC_ADSENSE_CLIENT_ID
|
||||
ARG NEXT_PUBLIC_SUPABASE_URL
|
||||
ARG NEXT_PUBLIC_SUPABASE_ANON_KEY
|
||||
|
||||
# Run Next.js build with Webpack cache mounted
|
||||
RUN --mount=type=cache,target=/app/.next/cache NODE_OPTIONS="--max_old_space_size=3072" pnpm run build
|
||||
RUN node scripts/copy-cesium.mjs
|
||||
|
||||
# Stage 3: Production runner
|
||||
# Stage 4: Production runner
|
||||
FROM node:22-alpine AS runner
|
||||
WORKDIR /app
|
||||
|
||||
ENV NODE_ENV=production
|
||||
ENV HOSTNAME=0.0.0.0
|
||||
ENV PORT=3000
|
||||
ENV DATABASE_URL=file:./data/wwv.db
|
||||
ENV AUTH_TRUST_HOST=true
|
||||
|
||||
# Copy Prisma schema + migrations for runtime DB init
|
||||
COPY --from=builder /app/prisma ./prisma
|
||||
COPY --from=builder /app/prisma.config.ts ./prisma.config.ts
|
||||
|
||||
# Copy Prisma generated client
|
||||
COPY --from=builder /app/src/generated ./src/generated
|
||||
|
||||
# Copy standalone server output
|
||||
COPY --from=builder /app/.next/standalone ./
|
||||
|
||||
# We no longer copy proddeps/node_modules. Next.js standalone output
|
||||
# already traces and copies all the exact node_modules needed for production.
|
||||
|
||||
# Copy static assets that standalone mode does NOT include
|
||||
COPY --from=builder /app/.next/static ./.next/static
|
||||
COPY --from=builder /app/public ./public
|
||||
|
||||
# Entrypoint: migrate DB on first run, then start server
|
||||
COPY docker-entrypoint.sh ./docker-entrypoint.sh
|
||||
RUN chmod +x ./docker-entrypoint.sh
|
||||
|
||||
# Declare /app/data as a persistent volume mount point.
|
||||
VOLUME ["/app/data"]
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
CMD ["node", "server.js"]
|
||||
ENTRYPOINT ["./docker-entrypoint.sh"]
|
||||
@@ -1,38 +1,91 @@
|
||||
# WorldWideView
|
||||
<div align="center">
|
||||
|
||||
**WorldWideView** is a modular, real-time geospatial intelligence engine built on top of a CesiumJS 3D globe. It is designed to ingest live data streams, transform them through a generalized plugin system, and render them as high-performance visual layers.
|
||||
# WorldWideView 🌍
|
||||
|
||||
As a real-time situational awareness platform, it turns raw geospatial signals—such as aircraft positions, maritime AIS, or satellite orbits—into interactive, cinematic layers on a high-fidelity 3D globe.
|
||||
**The Open-Source, Plugin-Driven Geospatial Intelligence Engine**
|
||||
|
||||
## Key Philosophies
|
||||
[](LICENSE)
|
||||
[](CONTRIBUTING.md)
|
||||
|
||||
- **Modular Intelligence**: Every data source is a plugin. The core engine is data-agnostic.
|
||||
- **High-Performance Rendering**: Engineered for scale using Cesium primitives to handle 100,000+ objects smoothly.
|
||||
- **Situational Awareness**: Designed for real-time updates and cinematic visualization (orientated icons, smooth tracking).
|
||||
- **Extensible & Open**: Add new intelligence layers without touching the core architecture.
|
||||
*A modular situational awareness platform designed to ingest live data streams and render them as interactive, cinematic layers on a high-fidelity CesiumJS 3D globe.*
|
||||
|
||||
## Quick Start
|
||||
<!-- 📸 Replace with a high-res GIF or screenshot of the platform running with multiple layers enabled -->
|
||||

|
||||
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
## ⚡ Build a Plugin in 5 Minutes
|
||||
|
||||
WorldWideView’s architecture means **everything is a plugin**. The core engine is completely data-agnostic. Rather than touching complex 3D rendering code, you can build a plugin that simply pipes a REST API into GeoJSON, and the engine handles the rest!
|
||||
|
||||
Ready to add a new intelligence layer (like Earthquakes, Weather, or Satellites)? We have a scaffold generator ready for you:
|
||||
|
||||
```bash
|
||||
# 1. Generate the boilerplate plugin from a template
|
||||
pnpm run scaffold-osm-plugin my-new-data-source
|
||||
|
||||
# 2. Add your data fetching logic in the generated files
|
||||
# 3. Reload the dev server and watch it map on the globe!
|
||||
```
|
||||
|
||||
📖 **[Read the Full Plugin Guide](docs/PLUGIN_GUIDE.md)** for a deep dive into hooking up websockets or static datasets.
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Installation & Setup (Local Development)
|
||||
|
||||
```bash
|
||||
git clone https://github.com/silvertakana/worldwideview.git
|
||||
cd worldwideview
|
||||
npm install
|
||||
npm run dev
|
||||
pnpm install
|
||||
pnpm run setup # generates .env.local with AUTH_SECRET
|
||||
pnpm run dev:all # starts the app, data engine, and marketplace concurrently
|
||||
```
|
||||
|
||||
Visit `http://localhost:3000` to see the live globe.
|
||||
|
||||
## Fair-Use Notice
|
||||
---
|
||||
|
||||
This application may contain copyrighted material the use of which has not always been specifically authorized by the copyright owner. Such material is made available for educational purposes, situational awareness, and to advance understanding of global events. It is believed that this constitutes a "fair use" of any such copyrighted material as provided for in section 107 of the US Copyright Law.
|
||||
## 🐋 Production Deployment (Docker & Coolify)
|
||||
|
||||
## Key Documentation Sections
|
||||
WorldWideView uses a multi-stage Dockerfile designed for standalone output, natively supporting deployment via Coolify or standard Docker Compose. The `docker-compose.yml` spins up the front-end application alongside the high-performance Data Engine and Redis cache.
|
||||
|
||||
```bash
|
||||
# Start the core app, Redis cache, and Data Engine microservice in production mode
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
**Persistent Storage Requirements:**
|
||||
When deploying to production, ensure you mount the following volumes to prevent data loss:
|
||||
- Mount `/app/data` to persist the core SQLite database.
|
||||
- Mount `/app/packages/wwv-data-engine/data` to persist the custom plugin microservices SQLite layer.
|
||||
- Mount `/data` to persist the standalone Redis container.
|
||||
|
||||
---
|
||||
|
||||
## 🧠 Core Architecture & Philosophies
|
||||
|
||||
- **Dynamic, Decentralized Plugins**: The plugin ecosystem uses a decentralized architecture fetching ES module CDN bundles (e.g., from unpkg) at runtime. The core engine is a lightweight shell that loads data providers dynamically via the marketplace.
|
||||
- **High-Performance Rendering**: Engineered for scale using raw Cesium primitives to smoothly handle upwards of 100,000+ objects simultaneously without GPU stalls.
|
||||
- **Cinematic Situational Awareness**: Implements horizon culling, smooth camera tracking, orientation-locked billboarding, and stack spiderification for dense locations.
|
||||
|
||||
---
|
||||
|
||||
## 📚 Documentation Index
|
||||
|
||||
- **[Setup & Installation Guide](docs/SETUP.md)**: Detailed environment and local development setup.
|
||||
- **[Architecture (Engineering Depth)](docs/ARCHITECTURE.md)**: Deep dive into the Cesium rendering pipeline, event data bus, and performance optimizations.
|
||||
- **[Plugin System Guide](docs/PLUGIN_GUIDE.md)**: How to build and register custom data layers.
|
||||
- **[Contributions Guide](CONTRIBUTING.md)**: How to help out, coding standards, and commit conventions.
|
||||
- **[User Guide](docs/USER_GUIDE.md)**: Application features and navigation tips.
|
||||
|
||||
---
|
||||
|
||||
For a full list of resources, see the **[Documentation Index](docs/index.md)**.
|
||||
## 🤝 Contributing & Community
|
||||
|
||||
We are actively looking for contributors to help build new data plugins and optimize the core 3D engine!
|
||||
- Found a bug or have an idea? Search the [Issue Tracker](https://github.com/silvertakana/worldwideview/issues) and submit a report.
|
||||
- Want to build something? Check out our **[Pinned Plugin Wishlist](https://github.com/silvertakana/worldwideview/issues)** for great first issues!
|
||||
|
||||
> **Fair-Use Notice:** This application may contain copyrighted material the use of which has not always been specifically authorized by the copyright owner. Such material is made available for educational purposes, situational awareness, and to advance understanding of global events under "fair use" (Section 107 of the US Copyright Law).
|
||||
+161
@@ -0,0 +1,161 @@
|
||||
# WorldWideView — Implementation Roadmap
|
||||
|
||||
Each stage is **self-contained and demo-able**. Any stage can be shipped independently.
|
||||
|
||||
---
|
||||
|
||||
## Stage 1: Plugin SDK & Manifest Schema ✅
|
||||
**Demo:** "Here's the schema that defines a plugin. Our existing aviation plugin has a manifest file."
|
||||
|
||||
- [x] `plugin.json` manifest files for each existing plugin
|
||||
- [x] Manifest validation logic (`validateManifest()`)
|
||||
- [x] `type` field on `WorldPlugin` interface (`"data-layer" | "extension"`)
|
||||
- [x] `capabilities` field on `WorldPlugin` interface
|
||||
- [x] `@worldwideview/wwv-plugin-sdk` npm package — shared types published to npm
|
||||
|
||||
---
|
||||
|
||||
## Stage 2: Marketplace Browse UI (Static Catalog) ✅
|
||||
**Demo:** "Open the marketplace, see all available plugins with categories and search."
|
||||
|
||||
- [x] `worldwideview-marketplace` repo (Next.js)
|
||||
- [x] Browse page — grid of plugin cards with icons, descriptions, categories
|
||||
- [x] Search + category filter
|
||||
- [x] Plugin detail page (readme, version history, install count)
|
||||
|
||||
---
|
||||
|
||||
## Stage 3: Prisma ORM & Local Database ✅
|
||||
**Demo:** "Run `pnpm run dev` on a fresh clone. SQLite auto-creates. App works with zero config."
|
||||
|
||||
- [x] Prisma (`prisma` + `@prisma/client`)
|
||||
- [x] Schema: `InstalledPlugin`, `Setting`, `User`, `AviationHistory`, `NpmCache`
|
||||
- [x] SQLite default: `DATABASE_URL=file:./data/wwv.db`
|
||||
- [x] `predev` script: `prisma migrate deploy`
|
||||
- [x] DB auto-creates on first run — zero manual setup
|
||||
|
||||
---
|
||||
|
||||
## Stage 4: Bridge API & One-Click Install ✅
|
||||
**Demo:** "Click 'Install' on marketplace → plugin appears in your local WWV instance."
|
||||
|
||||
- [x] `GET /api/marketplace/install-redirect` — session-based redirect install flow
|
||||
- [x] `GET /api/marketplace/grant-token` — issues marketplace JWT without install
|
||||
- [x] `GET /api/marketplace/status` — list installed plugins (session or JWT auth)
|
||||
- [x] `POST /api/marketplace/uninstall` — delete installed plugin record
|
||||
- [x] `GET /api/marketplace/load` — serve valid manifests to client at startup
|
||||
- [x] `GET /api/auth/setup-status` — CORS-enabled connection test endpoint
|
||||
- [x] `src/lib/marketplace/marketplaceToken.ts` — `issueMarketplaceToken()` / `verifyMarketplaceToken()`
|
||||
- [x] `src/lib/marketplace/auth.ts` — `validateMarketplaceAuth()` (session → JWT → legacy token)
|
||||
- [x] `src/lib/marketplace/registryClient.ts` — Ed25519 registry verification + 5-min cache
|
||||
- [x] Marketplace: `InstanceConfig`, `InstallButton`, `useInstalledPlugins`, `InstalledPluginCard`, Manage page
|
||||
- [x] NPM-driven submission: Admin enters package name → marketplace fetches + parses `"worldwideview"` block from `package.json`
|
||||
- [x] `NpmCache` table — decouples marketplace from live NPM registry
|
||||
|
||||
---
|
||||
|
||||
## Stage 5: AI & Sharing Features (Immediate User Value)
|
||||
**Demo:** "Chat with the AI to explore the globe, record a narrated briefing, and share the view via a URL."
|
||||
|
||||
- [ ] Unified Data Format schema (WWVDocument) with snapshot radius bounding
|
||||
- [ ] Base64url view link sharing (`#v=...`)
|
||||
- [ ] Shared `ActionExecutor` core for Animation & Copilot
|
||||
- [ ] Animation Engine (TrackScheduler, Player, overlays, TTS voice)
|
||||
- [ ] MCP Server (tools wrapping the action vocabulary)
|
||||
- [ ] Hybrid Spatial Awareness (Pre-computed summaries + MCP spatial query tools)
|
||||
|
||||
---
|
||||
|
||||
## Stage 6: Publisher Workflow
|
||||
**Demo:** "A plugin author submits their plugin. After review, it appears in the catalog."
|
||||
|
||||
- [ ] Marketplace user accounts (Supabase Auth — email/password + GitHub OAuth)
|
||||
- [ ] Publisher submission form (upload bundle, fill metadata, declare capabilities)
|
||||
- [ ] Admin review queue (approve/reject with notes)
|
||||
- [ ] Version management (semver, changelogs)
|
||||
- [ ] Publisher dashboard (install counts, download analytics)
|
||||
- [ ] Publisher namespaces (`publisher.plugin-name`)
|
||||
|
||||
---
|
||||
|
||||
## Stage 7: Cloud Platform & Accounts
|
||||
**Demo:** "User registers, gets [user].app.worldwideview.dev, installs plugins from marketplace."
|
||||
|
||||
- [ ] `app.worldwideview.dev` — auth/register/dashboard
|
||||
- [ ] Auto-provisioning on signup (tenant DB row → instance live immediately)
|
||||
- [ ] RLS tenant isolation in PostgreSQL
|
||||
- [ ] Cloud edition adapters (`auth.ts`, `storage.ts`, `tenant.ts`)
|
||||
- [ ] Runtime settings store + setup wizard
|
||||
- [ ] License key validation with RSA public key
|
||||
- [ ] Tier gating (free/pro/enterprise feature flags)
|
||||
- [ ] Cloudflare Turnstile + nginx rate limiting for bot prevention
|
||||
- [ ] SSO: marketplace redirects to `app.worldwideview.dev` for login
|
||||
|
||||
---
|
||||
|
||||
## Stage 8: Built-In Data Services
|
||||
**Demo:** "Aviation and maritime data with full history, served from api.worldwideview.dev."
|
||||
|
||||
- [ ] `api.worldwideview.dev` — aviation/maritime polling + persistence
|
||||
- [ ] Redesign aviation as declarative plugin pointing to `api.worldwideview.dev`
|
||||
- [ ] Redesign maritime the same way
|
||||
- [ ] History/timeline with `%t` parameter substitution
|
||||
- [ ] Snapshot capture (pro tier — counts toward storage quota)
|
||||
- [ ] API key proxy with per-tenant-per-plugin rate limiting and response caching
|
||||
|
||||
---
|
||||
|
||||
## Stage 9: Trust Tiers, Extensions & Polish
|
||||
**Demo:** "Install a verified extension plugin that adds cockpit view to aviation."
|
||||
|
||||
- [x] Ed25519-signed plugin registry (`GET /api/registry` on marketplace)
|
||||
- [x] Server-side trust stamping at install time
|
||||
- [x] Trust tier badges (`TrustBadge` component — Official / Verified / Unverified)
|
||||
- [x] Unverified plugin warning dialog (`UnverifiedPluginDialog` + `useMarketplaceSync`)
|
||||
- [ ] Extension plugin type support in `PluginManager`
|
||||
- [ ] Activation events and contribution points
|
||||
- [ ] Capability enforcement at runtime (`PluginPermissionError`)
|
||||
- [ ] Web Worker sandboxing for unverified plugins (`comlink`)
|
||||
- [ ] Reviews & ratings system
|
||||
- [ ] Extension packs (bundles of related plugins)
|
||||
- [ ] Auto-update mechanism (local: manual opt-in; cloud: automatic CDN swap)
|
||||
- [ ] Plausible/Umami self-hosted analytics
|
||||
|
||||
---
|
||||
|
||||
## Stage 10: Infrastructure & Monetization
|
||||
**Demo:** "Buy Pro, paste license key, unlock snapshot history and higher rate limits."
|
||||
|
||||
- [ ] Coolify on ThinkPad T480s — deploy all services
|
||||
- [ ] Uptime Kuma monitoring (all subdomains)
|
||||
- [ ] Stripe Checkout for license purchase
|
||||
- [ ] Storage quota enforcement (cloud only)
|
||||
- [ ] Stripe Connect for marketplace revenue split on paid plugins
|
||||
- [ ] Cloudflare R2 as CDN for plugin bundles (`cdn.worldwideview.dev`)
|
||||
|
||||
---
|
||||
|
||||
## Resolved Architectural Decisions
|
||||
|
||||
| Decision | Resolution |
|
||||
|---|---|
|
||||
| **License** | EL2.0 for WorldWideView core; Open Source for marketplace |
|
||||
| **Shared types** | `@worldwideview/plugin-sdk` npm package (MIT) |
|
||||
| **Hosting** | Coolify (ThinkPad T480s). Landing page on Vercel (static export) |
|
||||
| **Database** | Supabase PostgreSQL (cloud), SQLite (local), Prisma ORM |
|
||||
| **Tenant isolation** | Row-Level Security (RLS) in shared PostgreSQL |
|
||||
| **User settings** | Runtime settings store in DB, not `.env` |
|
||||
| **Bot prevention** | Email verification + Cloudflare Turnstile + rate limiting |
|
||||
| **Plugin execution** | Client-side (browser), not server-side |
|
||||
| **Plugin architecture** | VS Code model — activation events, contribution points, namespaces |
|
||||
| **Server-side compute** | Not supported — third-party backends handle compute |
|
||||
| **Auth** | Auth.js on `app.worldwideview.dev`. `Credentials` (local), `@auth/supabase-adapter` (cloud). Marketplace uses SSO redirect |
|
||||
| **Instance provisioning** | Auto-provision on signup — just a DB row insert |
|
||||
| **API proxy** | `apikey` plugins routed through cached proxy, per-tenant-per-plugin rate limits |
|
||||
| **History** | Third-party `historyUrl` with `%t` (all tiers), WWV snapshot capture (pro only) |
|
||||
| **Built-in data** | Aviation/maritime → declarative plugins → `api.worldwideview.dev` |
|
||||
| **CI/CD** | GitHub Actions → GHCR → Coolify webhook |
|
||||
| **Plugin trust registry** | Ed25519-signed JSON, public key hardcoded in WWV, trust stamped server-side at install |
|
||||
| **Package manager** | pnpm workspaces (migrated from npm) |
|
||||
| **NPM submission flow** | Admin enters package name → marketplace infers manifest from `"worldwideview"` block in `package.json` |
|
||||
| **NPM caching** | `NpmCache` table decouples marketplace from live NPM registry |
|
||||
@@ -0,0 +1 @@
|
||||
{"message":"fix(aviation): implement exponential backoff for rate limits","tree":"55c74a09dac7ce178ecf94d5cb48b2502e57e759","parents":["e25ddc0b648b757ea32b7376bab50d8e75d6d330"]}
|
||||
@@ -0,0 +1,54 @@
|
||||
const fs = require("fs");
|
||||
const { execSync } = require("child_process");
|
||||
|
||||
const uuidsToDelete = [
|
||||
"i331gbc1zzytx7via8lntdm6",
|
||||
"pow71xsobdas7etf5r3hy5ug",
|
||||
"l79dyd03lhtcpgi7swkoxm55",
|
||||
"ry6160tpy4gh2xjfwr011no0",
|
||||
"gfe78t8jm53lltentz19ze60",
|
||||
"e1cg7q8khyvpti5rkp351559",
|
||||
"c35cvvqxhdbslk8yc24g04wk",
|
||||
"ijj9pqkavlusy2wmzsbjtc74",
|
||||
"ghe6bzlr6ex6j51lgxzyhd46",
|
||||
"h3v45w2u1essulzeg56i27a3",
|
||||
"oxk05amog4fla0lskmkfx64x",
|
||||
"yxm4mn60lfp9qah0q4yf2hij",
|
||||
"ezjxo4ehs96lv0ji1n2r0auw",
|
||||
"t12x7pgptsqiu5gbvv35gun5",
|
||||
"urq1ll00a3vv9on6pulmpofe",
|
||||
"eb5zgw5wlgvio2gggbiphpam",
|
||||
"ld1h3pody4nxj3b44pbskl53",
|
||||
"x111xfygqxrlbf5wqlx59f6d",
|
||||
"se1weqr4dj7thp4p1l055wfc",
|
||||
"cqses6urxff0n94i0u6lktzt",
|
||||
"nvcir33nyuvzk5niy3s7eg9w",
|
||||
"s63onga2s6v8r3k10lrdwzth",
|
||||
"cf3uedqnjmwv48h7tm91d95r",
|
||||
"o9124dnnieau9wxoefyxvfgu",
|
||||
"kxzobc8qlvigbsk1d35dpiyi",
|
||||
"eh8lzjbsy2c9kwj2emztcmf6",
|
||||
"umfsos2vcmotfk2cfpqdoycc",
|
||||
"yn1mdh0fngiati6r4625qvv9"
|
||||
];
|
||||
|
||||
const token = "1|vPZPgvB8vVi8ZD5ZKS8lrCrwNlPofVv4I8Tjmqmyd01f92d2";
|
||||
const baseUrl = "https://coolify.worldwideview.dev/api/v1";
|
||||
const appUuid = "nmn55t4io3myfubs72worn7k";
|
||||
|
||||
async function run() {
|
||||
for (const id of uuidsToDelete) {
|
||||
console.log("Deleting", id);
|
||||
try {
|
||||
const res = await fetch(`${baseUrl}/applications/${appUuid}/envs/${id}`, {
|
||||
method: "DELETE",
|
||||
headers: { "Authorization": `Bearer ${token}` }
|
||||
});
|
||||
console.log(id, res.status);
|
||||
} catch(e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
run();
|
||||
@@ -0,0 +1,21 @@
|
||||
services:
|
||||
wwv:
|
||||
build: .
|
||||
ports:
|
||||
- "3000:3000"
|
||||
volumes:
|
||||
- wwv-data:/app/data
|
||||
env_file:
|
||||
- path: .env
|
||||
required: false
|
||||
environment:
|
||||
- "AUTH_SECRET=${AUTH_SECRET:-default_secret_for_local_dev}"
|
||||
- "WWV_DEMO_ADMIN_SECRET=${WWV_DEMO_ADMIN_SECRET:-}"
|
||||
- "WWV_BRIDGE_TOKEN=${WWV_BRIDGE_TOKEN:-}"
|
||||
|
||||
volumes:
|
||||
wwv-data:
|
||||
|
||||
networks:
|
||||
coolify:
|
||||
external: true
|
||||
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
# ─── Docker Entrypoint ───────────────────────────────────────
|
||||
# Ensures the SQLite database exists and is migrated before
|
||||
# starting the application. On first run with a fresh volume
|
||||
# the DB file won't exist yet, so we run prisma migrate deploy.
|
||||
|
||||
set -e
|
||||
|
||||
mkdir -p ./data
|
||||
echo "[entrypoint] Running database migrations..."
|
||||
npx -y prisma migrate deploy
|
||||
echo "[entrypoint] Migrations complete."
|
||||
|
||||
exec node server.js
|
||||
@@ -4,7 +4,9 @@ WorldWideView is a high-performance, event-driven geospatial intelligence engine
|
||||
|
||||
## Module Breakdown
|
||||
|
||||
1. **`src/core/plugins`**: The registration and lifecycle management layer. Defines how plugins are booted and destroyed.
|
||||
1. **`src/core/plugins`**: The registration and lifecycle management layer.
|
||||
- **PluginManager**: Orchestrator for enabling/disabling plugins.
|
||||
- **InstalledPluginsLoader**: Dynamically discovers and loads external marketplace plugins at runtime via CDN bundles (e.g. UNPKG).
|
||||
2. **`src/core/data`**: The "Heartbeat" of the system.
|
||||
- **DataBus**: Decentralized event pipeline for all system actions.
|
||||
- **PollingManager**: Intelligent scheduler for external API calls with backoff logic.
|
||||
@@ -12,7 +14,7 @@ WorldWideView is a high-performance, event-driven geospatial intelligence engine
|
||||
3. **`src/core/globe`**: The Rendering Engine.
|
||||
- **Cesium Integration**: Low-level control over the Cesium Viewer.
|
||||
- **EntityRenderer**: High-performance "Primitive" renderer.
|
||||
4. **`src/plugins`**: Domain-specific logic (Aviation, Maritime, etc.).
|
||||
4. **`packages/wwv-plugin-*`**: Monorepo plugin packages, externalized into standalone dynamically loaded CDNs.
|
||||
|
||||
## Performance: Primitives vs. Entities
|
||||
|
||||
@@ -20,7 +22,7 @@ One of our core design decisions is using **Cesium Primitives** instead of the s
|
||||
|
||||
| Feature | Entity API | Primitive API (WWV) |
|
||||
|---|---|---|
|
||||
| **Abstration** | High (Easy to use) | Low (Direct GPU access) |
|
||||
| **Abstraction** | High (Easy to use) | Low (Direct GPU access) |
|
||||
| **Overhead** | Significant per-entity JS objects | Minimal (Batched rendering) |
|
||||
| **Max Capacity** | ~1,000 entities | **100,000+ points/billboards** |
|
||||
| **WWV Use Case** | Info window content | Live data point visualization |
|
||||
|
||||
+22
-28
@@ -5,46 +5,40 @@ Follow these steps to set up your development environment and get WorldWideView
|
||||
## Requirements
|
||||
|
||||
- **Node.js**: v18.17 or higher (tested on v20+)
|
||||
- **NPM**: v9 or higher
|
||||
- **pnpm**: v8 or higher (`npm install -g pnpm`)
|
||||
- **Browser**: Chrome, Firefox, or Edge (CesiumJS requires WebGL support)
|
||||
|
||||
## Environment Setup
|
||||
|
||||
WorldWideView requires several API keys to function correctly. You can copy the provided `.env.example` file to `.env.local` and fill in the values:
|
||||
Run the setup script to auto-generate `.env.local` with a secure `AUTH_SECRET`:
|
||||
|
||||
```bash
|
||||
cp .env.example .env.local
|
||||
pnpm run setup
|
||||
```
|
||||
|
||||
Or manually create a `.env.local` file in the root directory:
|
||||
This copies `.env.example` → `.env.local` and fills in `AUTH_SECRET` automatically. You can then optionally add API keys for enhanced features (Cesium Ion, Bing Maps, OpenSky, etc.).
|
||||
|
||||
```env
|
||||
# Cesium Ion Access Token (Required for terrain and default imagery)
|
||||
NEXT_PUBLIC_CESIUM_ION_TOKEN=your_token_here
|
||||
|
||||
# Bing Maps API Key (Optional, for high-res imagery)
|
||||
NEXT_PUBLIC_BING_MAPS_KEY=your_key_here
|
||||
|
||||
# Supabase Configuration (Required for persistence and historical data)
|
||||
NEXT_PUBLIC_SUPABASE_URL=your_project_url
|
||||
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_anon_key
|
||||
SUPABASE_SERVICE_ROLE_KEY=your_service_role_key
|
||||
```
|
||||
> [!NOTE]
|
||||
> `AUTH_SECRET` must remain stable across restarts. The setup script generates it once and writes it to `.env.local`. Never commit `.env.local` to git.
|
||||
|
||||
## Running Locally
|
||||
|
||||
1. **Install Dependencies**:
|
||||
```bash
|
||||
npm install
|
||||
pnpm install
|
||||
```
|
||||
|
||||
2. **Start Dev Server**:
|
||||
2. **Generate environment file** (first time only):
|
||||
```bash
|
||||
npm run dev
|
||||
pnpm run setup
|
||||
```
|
||||
*Note: Our `dev` script automatically runs `predev` to copy Cesium assets to the public directory.*
|
||||
|
||||
3. **Open Browser**:
|
||||
3. **Start Dev Server**:
|
||||
```bash
|
||||
pnpm run dev:all
|
||||
```
|
||||
|
||||
4. **Open Browser**:
|
||||
Navigate to [http://localhost:3000](http://localhost:3000).
|
||||
|
||||
## Folder Structure Explanation
|
||||
@@ -53,9 +47,9 @@ Understanding the project layout:
|
||||
|
||||
```text
|
||||
worldwideview/
|
||||
├── .agents/ # Agentic AI workflows and memory
|
||||
├── docs/ # Project documentation (Markdowns)
|
||||
├── public/ # Static assets (Imagery, GeoJSON, Cesium dependencies)
|
||||
├── docs/ # Project documentation
|
||||
├── packages/ # Plugin packages (pnpm workspaces)
|
||||
├── public/ # Static assets (GeoJSON data files, Cesium dependencies)
|
||||
├── scripts/ # Build and utility scripts (e.g., copy-cesium.mjs)
|
||||
└── src/
|
||||
├── app/ # Next.js App Router (Layouts, Pages, API Routes)
|
||||
@@ -64,8 +58,8 @@ worldwideview/
|
||||
│ ├── data/ # Data management (DataBus, Polling, Cache)
|
||||
│ ├── globe/ # Cesium-specific hooks and view logic
|
||||
│ └── plugins/ # Plugin system base and registry
|
||||
├── lib/ # Utility libraries and server-side polling
|
||||
└── plugins/ # Feature-specific plugins (Aviation, Maritime, etc.)
|
||||
├── lib/ # Utility libraries and server-side logic
|
||||
└── plugins/ # Built-in plugins (Aviation, Maritime, etc.)
|
||||
```
|
||||
|
||||
## Verification
|
||||
@@ -77,5 +71,5 @@ To verify your setup:
|
||||
|
||||
---
|
||||
|
||||
> [!IMPORTANT]
|
||||
> If you encounter issues with hot reloading (HMR), ensure you are running with the `--webpack` flag in the dev script (this is the default in our `package.json`).
|
||||
> [!TIP]
|
||||
> The database is created automatically on first run — no manual setup is required. If you need to reset it, delete `data/wwv.db` and restart the dev server.
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 816 KiB |
+59
-75
@@ -21,7 +21,8 @@ There are **three plugin formats**:
|
||||
## Prerequisites
|
||||
|
||||
- Node.js ≥ 18
|
||||
- npm account (for publishing)
|
||||
- pnpm (`npm install -g pnpm`)
|
||||
- A npm account (for publishing to the npm registry)
|
||||
- The WorldWideView monorepo cloned locally
|
||||
|
||||
---
|
||||
@@ -61,10 +62,23 @@ Create `package.json`:
|
||||
"author": "WorldWideView",
|
||||
"peerDependencies": {
|
||||
"@worldwideview/wwv-plugin-sdk": "*"
|
||||
},
|
||||
"worldwideview": {
|
||||
"id": "my-data",
|
||||
"icon": "MapPin",
|
||||
"category": "Custom",
|
||||
"format": "bundle"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
> [!IMPORTANT]
|
||||
> The `"worldwideview"` object block is strictly required if you intend to publish your plugin to the WorldWideView Marketplace. The marketplace uses this internal manifest to determine how to categorize and display your plugin automatically.
|
||||
> * `id`: The unique string identifier.
|
||||
> * `icon`: The Lucide React icon name (e.g. `MapPin`, `Satellite`, `Plane`).
|
||||
> * `category`: Must match an existing category (e.g. `Aviation`, `Maritime`, `Natural Disaster`, `Custom`).
|
||||
> * `format`: Either `bundle`, `static`, or `declarative`.
|
||||
|
||||
> [!IMPORTANT]
|
||||
> The SDK is declared as a **peer dependency**, not a direct dependency. The host application provides it at runtime.
|
||||
|
||||
@@ -176,72 +190,39 @@ export class MyDataPlugin implements WorldPlugin {
|
||||
|
||||
```bash
|
||||
cd packages/wwv-plugin-my-data
|
||||
npm publish --access public
|
||||
pnpm publish --access public
|
||||
```
|
||||
|
||||
> [!NOTE]
|
||||
> The marketplace pulls metadata (version, description, keywords) directly from the npm registry at runtime. You do not need to duplicate this metadata in the marketplace.
|
||||
> The marketplace pulls metadata (version, description, keywords, readme) directly from the npm registry. You do not need to duplicate this information anywhere else.
|
||||
|
||||
---
|
||||
|
||||
## Step 4 — Register in the Marketplace
|
||||
## Step 4 — Submit to the Marketplace
|
||||
|
||||
### 4a. Add to `knownPlugins.ts`
|
||||
Once your package is published to npm, submit it for listing in the WorldWideView Marketplace:
|
||||
|
||||
Open `worldwideview-marketplace/src/data/knownPlugins.ts` and add your plugin:
|
||||
1. Go to [marketplace.worldwideview.dev/submit](https://marketplace.worldwideview.dev/submit) (or open the Admin UI on a local marketplace instance)
|
||||
2. Enter your **npm package name** (e.g. `@worldwideview/wwv-plugin-my-data`)
|
||||
3. The marketplace automatically fetches your metadata from npm and reads the `"worldwideview"` block from your `package.json`
|
||||
4. Your plugin enters a **pending** state for review
|
||||
5. Once approved, it appears in the browse catalog
|
||||
|
||||
```typescript
|
||||
{
|
||||
id: "my-data",
|
||||
npmPackage: "@worldwideview/wwv-plugin-my-data",
|
||||
icon: "MapPin", // Lucide icon name
|
||||
category: "Custom", // Must match a value in CATEGORIES
|
||||
format: "static", // "static" | "bundle"
|
||||
trust: "verified", // "built-in" | "verified" | "unverified"
|
||||
capabilities: ["data:own"],
|
||||
longDescription:
|
||||
"Description shown on the plugin detail page in the marketplace.",
|
||||
changelog:
|
||||
"v1.0.0 — Initial release.",
|
||||
},
|
||||
```
|
||||
> [!IMPORTANT]
|
||||
> The `"worldwideview"` block in your `package.json` is required for submission. Make sure `id`, `icon`, `category`, and `format` are correctly set before publishing.
|
||||
|
||||
### 4b. Add a manifest (static plugins only)
|
||||
### For static format plugins
|
||||
|
||||
For **static** format plugins, open `worldwideview-marketplace/src/data/pluginManifests.ts` and add:
|
||||
If your plugin uses `"format": "static"`, your **GeoJSON file** must be hosted and accessible at a public URL, or included in the `public/data/` folder of the host WorldWideView application. The `dataFile` path in your manifest should point to that URL.
|
||||
|
||||
```typescript
|
||||
"my-data": {
|
||||
id: "my-data",
|
||||
name: "My Data Layer",
|
||||
version: "1.0.0",
|
||||
description: "My custom data layer",
|
||||
type: "data-layer",
|
||||
format: "static",
|
||||
trust: "verified",
|
||||
capabilities: ["data:own"],
|
||||
category: "Custom",
|
||||
icon: "MapPin",
|
||||
dataFile: "/data/my_data.geojson", // Path to GeoJSON in public/
|
||||
rendering: {
|
||||
entityType: "point",
|
||||
color: "#3b82f6",
|
||||
labelField: "name",
|
||||
clusterEnabled: true,
|
||||
clusterDistance: 50,
|
||||
maxEntities: 5000,
|
||||
},
|
||||
},
|
||||
```
|
||||
|
||||
Bundle plugins do **not** need a manifest entry here — their code is loaded via dynamic import.
|
||||
If you are contributing a plugin for inclusion in the official WorldWideView release, place the GeoJSON at `public/data/<name>.geojson` and open a pull request.
|
||||
|
||||
---
|
||||
|
||||
## Step 5 — Test Locally
|
||||
|
||||
1. Start the WorldWideView app: `npm run dev` (in the `worldwideview` directory)
|
||||
2. Start the marketplace: `npm run dev` (in the `worldwideview-marketplace` directory)
|
||||
1. Start all WorldWideView services: `pnpm run dev:all` (in the monorepo root)
|
||||
2. (Wait for both the main app and marketplace to start)
|
||||
3. Open the marketplace at `http://localhost:3001/browse`
|
||||
4. Find your plugin and click **Install**
|
||||
5. Verify the data appears on the globe at `http://localhost:3000`
|
||||
@@ -350,29 +331,32 @@ A static GeoJSON plugin where the npm package is just metadata:
|
||||
Developer writes plugin
|
||||
│
|
||||
▼
|
||||
Publish to npm ──────────────────────────────────► npm registry
|
||||
│ │
|
||||
▼ │
|
||||
Add to knownPlugins.ts ──► Marketplace ◄────────────┘
|
||||
(+ pluginManifests.ts shows plugin (fetches version,
|
||||
for static plugins) in browse grid description, etc.)
|
||||
│
|
||||
▼
|
||||
User clicks "Install"
|
||||
│
|
||||
▼
|
||||
Marketplace sends manifest
|
||||
to WorldWideView instance
|
||||
│
|
||||
▼
|
||||
InstalledPluginsLoader saves
|
||||
manifest to database (Prisma)
|
||||
│
|
||||
▼
|
||||
loadPluginFromManifest() routes
|
||||
by format: static → StaticDataPlugin
|
||||
bundle → dynamic import
|
||||
│
|
||||
▼
|
||||
Plugin renders on the 3D globe
|
||||
Publish to npm ► npm registry (stores version, description, keywords, readme)
|
||||
│
|
||||
▼
|
||||
Submit npm package name to Marketplace
|
||||
│
|
||||
▼
|
||||
Marketplace fetches metadata from npm ← npm registry
|
||||
and reads the "worldwideview" block from package.json
|
||||
│
|
||||
▼
|
||||
Review → Plugin appears in browse catalog
|
||||
│
|
||||
▼
|
||||
User clicks "Install"
|
||||
│
|
||||
▼
|
||||
Marketplace sends manifest to WorldWideView instance
|
||||
│
|
||||
▼
|
||||
Plugin saved to database (Prisma) → loaded on next startup
|
||||
│
|
||||
▼
|
||||
loadPluginFromManifest() routes by format:
|
||||
static → StaticDataPlugin (GeoJSON loader)
|
||||
bundle → dynamic import()
|
||||
│
|
||||
▼
|
||||
Plugin renders on the 3D globe
|
||||
```
|
||||
@@ -0,0 +1,216 @@
|
||||
# Plugin Architecture Migration Plan
|
||||
|
||||
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||
|
||||
**Goal:** Migrate the WorldWideView plugin architecture from compile-time hardcoded imports to a dynamic, runtime-loaded ecosystem where external developers can build, host, and distribute plugins without touching the core repository.
|
||||
|
||||
**Architecture:** We will introduce a bundler (`tsup`) to the SDK to compile `bundle` plugins into browser-ready ECMAScript Modules (ESM). We will expose shared dependencies (`react`, `cesium`, `lucide-react`) via a global `window.__WWV_SHARED__` object. Finally, we will refactor `AppShell.tsx` to dynamically load all plugins at runtime via `import(/* webpackIgnore: true */)`, removing the hardcoded imports, and we will update `loadPluginFromManifest.ts` to seamlessly handle the global dependency injection.
|
||||
|
||||
**Tech Stack:** Next.js, React, CesiumJS, tsup.
|
||||
|
||||
---
|
||||
|
||||
## User Review Required
|
||||
|
||||
> [!WARNING]
|
||||
> **Breaking Change**: This migration will decouple your built-in plugins from `AppShell.tsx`. They will now act as true "external" plugins that are loaded at runtime. During the transition, if the build steps aren't executed, the plugins will temporarily stop appearing on the globe. We will mitigate this by ensuring the build step runs before `next dev`.
|
||||
|
||||
> [!IMPORTANT]
|
||||
> **Static GeoJSON Files**: Since static `.geojson` files currently live in `public/data`, we will leave them there during phase 1 of this migration to ensure the app doesn't break, but we will point the plugin manifests to load them via absolute or absolute-relative URLs (`/data/...`). In phase 2, we will introduce a symlink script to move them out of `public` entirely.
|
||||
|
||||
## Open Questions
|
||||
|
||||
1. **Build Tool Choice**: I am proposing `tsup` because it requires zero configuration to output multiple formats, automatically externalizes dependencies, and natively transpiles TypeScript/React. Are you comfortable adding `tsup` to the `wwv-plugin-sdk` package?
|
||||
2. **Local Serving**: To test "built-in" plugins using the dynamic loading method, we need the Next.js app to serve their compiled `plugin.js` bundles. My plan adds a quick copy script to the root `package.json` that copies their `dist` folders into `public/builtin-plugins/` so they can be fetched locally via HTTP. Does this sound good?
|
||||
|
||||
## Proposed Changes
|
||||
|
||||
### Task 1: Initialize Global Shared Dependencies
|
||||
|
||||
**Files:**
|
||||
- Modify: `c:\dev\worldwideview\src\components\layout\AppShell.tsx`
|
||||
- Create: `c:\dev\worldwideview\src\core\plugins\PluginGlobals.ts`
|
||||
|
||||
- [ ] **Step 1: Create the PluginGlobals initializer**
|
||||
|
||||
```typescript
|
||||
import React from "react";
|
||||
import ReactDOM from "react-dom";
|
||||
import * as ReactDomServer from "react-dom/server";
|
||||
import { Plane, Ship, Camera, Shield, Flame, Map, Swords, Atom, Landmark, Mountain, PlaneTakeoff, Anchor, Lamp, Rocket, SunMoon, Cable, Pickaxe, ShieldAlert, Crosshair, SatelliteDish, Hand, Radar, Scale } from "lucide-react";
|
||||
import * as Cesium from "cesium";
|
||||
import * as WWVPluginSDK from "@worldwideview/wwv-plugin-sdk";
|
||||
|
||||
export function initPluginGlobals() {
|
||||
if (typeof window === "undefined") return;
|
||||
|
||||
// Create a registry of Lucide icons commonly used by plugins to prevent them from bundling the massive icon library
|
||||
const lucideIcons = {
|
||||
Plane, Ship, Camera, Shield, Flame, Map, Swords, Atom, Landmark, Mountain,
|
||||
PlaneTakeoff, Anchor, Lamp, Rocket, SunMoon, Cable, Pickaxe, ShieldAlert,
|
||||
Crosshair, SatelliteDish, Hand, Radar, Scale
|
||||
};
|
||||
|
||||
(window as any).__WWV_SHARED__ = {
|
||||
"react": React,
|
||||
"react-dom": ReactDOM,
|
||||
"react-dom/server": ReactDomServer,
|
||||
"cesium": Cesium,
|
||||
"@worldwideview/wwv-plugin-sdk": WWVPluginSDK,
|
||||
"lucide-react": lucideIcons
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
- [ ] **Step 2: Inject globals in AppShell before anything loads**
|
||||
|
||||
In `AppShell.tsx`, import and call `initPluginGlobals()` at the top of the file, outside of any React components.
|
||||
|
||||
```tsx
|
||||
import { initPluginGlobals } from "@/core/plugins/PluginGlobals";
|
||||
import dynamic from "next/dynamic";
|
||||
|
||||
// Initialize globals immediately so they exist before any dynamic imports
|
||||
if (typeof window !== "undefined") {
|
||||
initPluginGlobals();
|
||||
}
|
||||
//... rest of the file
|
||||
```
|
||||
|
||||
### Task 2: Configure SDK Build Tool (`tsup`)
|
||||
|
||||
**Files:**
|
||||
- Modify: `c:\dev\worldwideview\packages\wwv-plugin-sdk\package.json`
|
||||
- Create: `c:\dev\worldwideview\packages\wwv-plugin-sdk\bin\wwv-plugin-build.js`
|
||||
|
||||
- [ ] **Step 1: Add tsup dependency**
|
||||
|
||||
Run: `pnpm --filter @worldwideview/wwv-plugin-sdk add -D tsup`
|
||||
|
||||
- [ ] **Step 2: Create the wwv-plugin-build CLI wrapper**
|
||||
|
||||
Add this to `wwv-plugin-sdk/bin/wwv-plugin-build.js`:
|
||||
|
||||
```javascript
|
||||
#!/usr/bin/env node
|
||||
const { build } = require("tsup");
|
||||
const path = require("path");
|
||||
|
||||
async function run() {
|
||||
const cwd = process.cwd();
|
||||
await build({
|
||||
entry: ["src/index.ts"],
|
||||
outDir: "dist",
|
||||
format: ["esm"],
|
||||
target: "es2022",
|
||||
clean: true,
|
||||
dts: false,
|
||||
minify: false,
|
||||
sourcemap: true,
|
||||
// Mark all these as externals so they aren't bundled
|
||||
external: ["react", "react-dom", "cesium", "@worldwideview/wwv-plugin-sdk", "lucide-react"],
|
||||
// Provide a shim that converts bare imports into global lookups
|
||||
esbuildPlugins: [{
|
||||
name: "wwv-globals",
|
||||
setup(build) {
|
||||
build.onResolve({ filter: /^(react|react-dom|cesium|@worldwideview\/wwv-plugin-sdk|lucide-react)$/ }, args => {
|
||||
return { path: args.path, namespace: "wwv-global" };
|
||||
});
|
||||
build.onLoad({ filter: /.*/, namespace: "wwv-global" }, args => {
|
||||
let globalKey = args.path;
|
||||
if (args.path === "lucide-react") return { contents: `module.exports = window.__WWV_SHARED__["lucide-react"];` };
|
||||
return { contents: `module.exports = window.__WWV_SHARED__["${globalKey}"];` };
|
||||
});
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
run();
|
||||
```
|
||||
|
||||
- [ ] **Step 3: Update SDK package.json to expose the bin**
|
||||
|
||||
```json
|
||||
"bin": {
|
||||
"wwv-plugin-build": "./bin/wwv-plugin-build.js"
|
||||
},
|
||||
```
|
||||
|
||||
### Task 3: Refactor Plugins to use Build Tool and Manifests
|
||||
|
||||
**Files:**
|
||||
- Modify: `wwv-plugin-aviation/package.json`
|
||||
- Modify: `wwv-plugin-aviation/plugin.json` (Create)
|
||||
|
||||
- [ ] **Step 1: Add build script to aviation plugin**
|
||||
|
||||
```json
|
||||
"scripts": {
|
||||
"build": "wwv-plugin-build"
|
||||
},
|
||||
```
|
||||
|
||||
- [ ] **Step 2: Create plugin.json for aviation**
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "aviation",
|
||||
"name": "Aviation",
|
||||
"version": "1.0.7",
|
||||
"type": "data-layer",
|
||||
"format": "bundle",
|
||||
"trust": "built-in",
|
||||
"capabilities": ["data:own", "network:fetch"],
|
||||
"category": "aviation",
|
||||
"icon": "Plane",
|
||||
"entry": "/builtin-plugins/aviation/index.mjs"
|
||||
}
|
||||
```
|
||||
|
||||
*(Repeat for all other built-in plugins)*
|
||||
|
||||
### Task 4: Dynamic Initial Loader
|
||||
|
||||
**Files:**
|
||||
- Modify: `c:\dev\worldwideview\src\components\layout\AppShell.tsx`
|
||||
- Modify: `c:\dev\worldwideview\package.json`
|
||||
|
||||
- [ ] **Step 1: Remove Hardcoded Plugins**
|
||||
|
||||
In `AppShell.tsx`, delete the `builtIns` array and `import` statements at the top.
|
||||
|
||||
- [ ] **Step 2: Fetch and load all plugins via manifest**
|
||||
|
||||
Modify `AppShell.tsx` `startPlatform`:
|
||||
|
||||
```typescript
|
||||
// Fetch the unified list of ALL installed plugins (both built-in and dynamic)
|
||||
const res = await fetch("/api/marketplace/load");
|
||||
if (res.ok) {
|
||||
const data = await res.json();
|
||||
for (const manifest of data.manifests) {
|
||||
if (disabledIds.has(manifest.id)) continue;
|
||||
try {
|
||||
await pluginManager.loadFromManifest(manifest);
|
||||
initLayer(manifest.id);
|
||||
} catch (e) {
|
||||
console.error("Failed to load plugin", manifest.id, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- [ ] **Step 3: Add predev copy-script**
|
||||
|
||||
Modify `package.json` to copy compiled plugin `dist` folders to `public/builtin-plugins` so the Next.js server can serve them at the `/builtin-plugins/...` path.
|
||||
|
||||
## Verification Plan
|
||||
|
||||
### Automated Tests
|
||||
- Run `pnpm --filter wwv-plugin-aviation build` to ensure `tsup` generates a valid ES Module with no bundled React.
|
||||
- Verify `dist/index.mjs` contains `window.__WWV_SHARED__["react"]` lookups.
|
||||
|
||||
### Manual Verification
|
||||
- Start the Next.js server.
|
||||
- Open network tab in browser and verify `GET /builtin-plugins/aviation/index.mjs` succeeds.
|
||||
- Verify the Aviation plugin appears on the globe and renders planes successfully, indicating that it successfully retrieved Cesium and React from the global shared context.
|
||||
@@ -0,0 +1,475 @@
|
||||
# Demo Google AdSense Panel Implementation Plan
|
||||
|
||||
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||
|
||||
**Goal:** Add a Google AdSense vertical ad strip to the right side of the demo instance, with a dismissible banner explaining it's temporary to fund hosting.
|
||||
|
||||
**Architecture:** Three layers: (1) load the AdSense script conditionally in the root layout only when `isDemo` is true, (2) a reusable `AdUnit` client component that calls `adsbygoogle.push({})`, (3) a `DemoAdStrip` shell component that wraps the ad unit + a "why ads?" dismissible message, positioned as a fixed vertical strip on the right edge. CSP headers in `next.config.ts` must be updated to allow the AdSense domains.
|
||||
|
||||
**Tech Stack:** Next.js 16 (App Router, `next/script`), Google AdSense, vanilla CSS, Vitest
|
||||
|
||||
---
|
||||
|
||||
## File Structure
|
||||
|
||||
| File | Action | Responsibility |
|
||||
|---|---|---|
|
||||
| `src/app/layout.tsx` | MODIFY | Conditionally load AdSense `<Script>` for demo |
|
||||
| `next.config.ts` | MODIFY | Add AdSense domains to CSP `script-src` and `frame-src` |
|
||||
| `.env` | MODIFY | Add `NEXT_PUBLIC_ADSENSE_CLIENT_ID` placeholder |
|
||||
| `src/components/ads/AdUnit.tsx` | CREATE | Generic reusable AdSense unit component |
|
||||
| `src/components/ads/DemoAdStrip.tsx` | CREATE | Demo-only vertical strip: ad + "why ads?" message |
|
||||
| `src/components/ads/DemoAdStrip.css` | CREATE | Styles for the vertical ad strip |
|
||||
| `src/components/layout/AppShell.tsx` | MODIFY | Import and render `<DemoAdStrip />` |
|
||||
| `src/types/adsense.d.ts` | CREATE | TypeScript ambient declaration for `window.adsbygoogle` |
|
||||
|
||||
---
|
||||
|
||||
> [!IMPORTANT]
|
||||
> **Before starting:** You need a Google AdSense publisher ID (`ca-pub-XXXXXXXXXXXXXXXX`) and an ad slot ID. These go into `.env` as `NEXT_PUBLIC_ADSENSE_CLIENT_ID` and are passed to the ad unit component. You can get these from [Google AdSense](https://www.google.com/adsense/). Without them the ads will not render, but the component framework will still work.
|
||||
|
||||
---
|
||||
|
||||
### Task 1: TypeScript Ambient Declaration for AdSense
|
||||
|
||||
**Files:**
|
||||
- Create: `src/types/adsense.d.ts`
|
||||
|
||||
- [ ] **Step 1: Create the ambient type declaration**
|
||||
|
||||
```ts
|
||||
// src/types/adsense.d.ts
|
||||
interface Window {
|
||||
adsbygoogle: Array<Record<string, unknown>>;
|
||||
}
|
||||
```
|
||||
|
||||
- [ ] **Step 2: Commit**
|
||||
|
||||
```bash
|
||||
git add src/types/adsense.d.ts
|
||||
git commit -m "chore: add adsense ambient type declaration"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 2: Environment Variable
|
||||
|
||||
**Files:**
|
||||
- Modify: `.env`
|
||||
|
||||
- [ ] **Step 1: Add the AdSense client ID placeholder**
|
||||
|
||||
Add the following line to the end of `.env`:
|
||||
|
||||
```
|
||||
# Google AdSense — only used on demo edition
|
||||
NEXT_PUBLIC_ADSENSE_CLIENT_ID=
|
||||
```
|
||||
|
||||
The actual value (`ca-pub-XXXXXXXXXXXXXXXX`) should be set in `.env.local` for local testing or in the deployment environment. The ad slot IDs will be hardcoded in the component since there's only one placement.
|
||||
|
||||
- [ ] **Step 2: Commit**
|
||||
|
||||
```bash
|
||||
git add .env
|
||||
git commit -m "chore: add NEXT_PUBLIC_ADSENSE_CLIENT_ID env var"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 3: CSP Headers Update
|
||||
|
||||
**Files:**
|
||||
- Modify: `next.config.ts:29-52`
|
||||
|
||||
- [ ] **Step 1: Update CSP in next.config.ts**
|
||||
|
||||
In the `headers()` function, modify the `script-src` and `frame-src` directives to allow AdSense domains.
|
||||
|
||||
```ts
|
||||
// Change this line (line 39):
|
||||
"script-src 'self' 'unsafe-eval' 'unsafe-inline' blob: https://analytics.worldwideview.dev https://va.vercel-scripts.com",
|
||||
|
||||
// To this:
|
||||
"script-src 'self' 'unsafe-eval' 'unsafe-inline' blob: https://analytics.worldwideview.dev https://va.vercel-scripts.com https://pagead2.googlesyndication.com https://adservice.google.com https://www.googletagservices.com",
|
||||
```
|
||||
|
||||
```ts
|
||||
// Change this line (line 49):
|
||||
"frame-src 'self' *.youtube.com *.youtube-nocookie.com *.twitch.tv *.vimeo.com *.webcamera.pl *.ivideon.com *.rtsp.me *.bnu.tv",
|
||||
|
||||
// To this:
|
||||
"frame-src 'self' *.youtube.com *.youtube-nocookie.com *.twitch.tv *.vimeo.com *.webcamera.pl *.ivideon.com *.rtsp.me *.bnu.tv https://googleads.g.doubleclick.net https://tpc.googlesyndication.com",
|
||||
```
|
||||
|
||||
- [ ] **Step 2: Commit**
|
||||
|
||||
```bash
|
||||
git add next.config.ts
|
||||
git commit -m "feat: add Google AdSense domains to CSP headers"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 4: AdSense Script in Root Layout
|
||||
|
||||
**Files:**
|
||||
- Modify: `src/app/layout.tsx:24-39`
|
||||
|
||||
- [ ] **Step 1: Conditionally load AdSense script for demo edition**
|
||||
|
||||
Add the AdSense `<Script>` tag inside `<head>`, using the `NEXT_PUBLIC_` env var for the client ID and the `NEXT_PUBLIC_WWV_EDITION` env var to gate loading.
|
||||
|
||||
```tsx
|
||||
// src/app/layout.tsx — updated <head> section
|
||||
<head>
|
||||
{/* Load CesiumJS base styles (optional, but helps with UI widgets if used later) */}
|
||||
<link rel="stylesheet" href="/cesium/Widgets/widgets.css" />
|
||||
</head>
|
||||
<body suppressHydrationWarning>
|
||||
{children}
|
||||
<Analytics />
|
||||
<Script
|
||||
src="https://analytics.worldwideview.dev/script.js"
|
||||
data-website-id="2c8f6c09-2651-4a2a-af99-b8cee1612b9a"
|
||||
strategy="afterInteractive"
|
||||
/>
|
||||
{process.env.NEXT_PUBLIC_WWV_EDITION === "demo" &&
|
||||
process.env.NEXT_PUBLIC_ADSENSE_CLIENT_ID && (
|
||||
<Script
|
||||
src={`https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=${process.env.NEXT_PUBLIC_ADSENSE_CLIENT_ID}`}
|
||||
crossOrigin="anonymous"
|
||||
strategy="afterInteractive"
|
||||
/>
|
||||
)}
|
||||
</body>
|
||||
```
|
||||
|
||||
> **Note:** We use the raw env var at the layout level (Server Component) rather than importing `isDemo` which uses `process.env.NEXT_PUBLIC_WWV_EDITION` anyway. This avoids importing the edition module into the root layout.
|
||||
|
||||
- [ ] **Step 2: Commit**
|
||||
|
||||
```bash
|
||||
git add src/app/layout.tsx
|
||||
git commit -m "feat: conditionally load AdSense script on demo edition"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 5: Reusable AdUnit Component
|
||||
|
||||
**Files:**
|
||||
- Create: `src/components/ads/AdUnit.tsx`
|
||||
|
||||
- [ ] **Step 1: Create the generic AdSense unit component**
|
||||
|
||||
```tsx
|
||||
// src/components/ads/AdUnit.tsx
|
||||
"use client";
|
||||
|
||||
import { useEffect, useRef } from "react";
|
||||
|
||||
interface AdUnitProps {
|
||||
adSlot: string;
|
||||
adFormat?: string;
|
||||
style?: React.CSSProperties;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export function AdUnit({ adSlot, adFormat = "auto", style, className }: AdUnitProps) {
|
||||
const pushed = useRef(false);
|
||||
const clientId = process.env.NEXT_PUBLIC_ADSENSE_CLIENT_ID;
|
||||
|
||||
useEffect(() => {
|
||||
if (pushed.current || !clientId) return;
|
||||
try {
|
||||
(window.adsbygoogle = window.adsbygoogle || []).push({});
|
||||
pushed.current = true;
|
||||
} catch (err) {
|
||||
console.error("[AdUnit] AdSense push error:", err);
|
||||
}
|
||||
}, [clientId]);
|
||||
|
||||
if (!clientId) return null;
|
||||
|
||||
return (
|
||||
<div className={className} style={style}>
|
||||
<ins
|
||||
className="adsbygoogle"
|
||||
style={{ display: "block" }}
|
||||
data-ad-client={clientId}
|
||||
data-ad-slot={adSlot}
|
||||
data-ad-format={adFormat}
|
||||
data-full-width-responsive="false"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
> **Key detail:** The `pushed` ref prevents double-push on React strict mode / hot reload. `data-full-width-responsive="false"` prevents the ad from expanding beyond the container — critical for a fixed-width vertical strip.
|
||||
|
||||
- [ ] **Step 2: Commit**
|
||||
|
||||
```bash
|
||||
git add src/components/ads/AdUnit.tsx
|
||||
git commit -m "feat: add reusable AdUnit component"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 6: DemoAdStrip Component + Styles
|
||||
|
||||
**Files:**
|
||||
- Create: `src/components/ads/DemoAdStrip.tsx`
|
||||
- Create: `src/components/ads/DemoAdStrip.css`
|
||||
|
||||
- [ ] **Step 1: Create the CSS for the vertical ad strip**
|
||||
|
||||
```css
|
||||
/* src/components/ads/DemoAdStrip.css */
|
||||
|
||||
.demo-ad-strip {
|
||||
position: fixed;
|
||||
right: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
width: 160px;
|
||||
z-index: 45;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: var(--space-md);
|
||||
padding: var(--space-sm);
|
||||
pointer-events: none;
|
||||
transition: transform var(--duration-slow) var(--ease-smooth),
|
||||
opacity var(--duration-slow) var(--ease-smooth);
|
||||
}
|
||||
|
||||
.demo-ad-strip--hidden {
|
||||
transform: translateX(200px);
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.demo-ad-strip__ad {
|
||||
pointer-events: auto;
|
||||
width: 160px;
|
||||
min-height: 600px;
|
||||
}
|
||||
|
||||
.demo-ad-strip__banner {
|
||||
pointer-events: auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: var(--space-xs);
|
||||
padding: var(--space-sm) var(--space-md);
|
||||
background: var(--bg-glass);
|
||||
backdrop-filter: blur(var(--glass-blur));
|
||||
-webkit-backdrop-filter: blur(var(--glass-blur));
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: var(--radius-md);
|
||||
max-width: 160px;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
transition: all var(--duration-fast) var(--ease-smooth);
|
||||
}
|
||||
|
||||
.demo-ad-strip__banner:hover {
|
||||
border-color: rgba(var(--accent-rgb), 0.3);
|
||||
box-shadow: var(--glow-cyan);
|
||||
}
|
||||
|
||||
.demo-ad-strip__banner-label {
|
||||
font-size: 9px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.12em;
|
||||
text-transform: uppercase;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.demo-ad-strip__banner-text {
|
||||
font-size: 11px;
|
||||
line-height: 1.4;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.demo-ad-strip__close {
|
||||
position: absolute;
|
||||
top: var(--space-xs);
|
||||
right: var(--space-xs);
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border-radius: 50%;
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: var(--text-muted);
|
||||
font-size: 12px;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: color var(--duration-fast) var(--ease-smooth);
|
||||
}
|
||||
|
||||
.demo-ad-strip__close:hover {
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
/* Hide on mobile — ads shouldn't overlay the full-screen globe */
|
||||
@media (max-width: 768px) {
|
||||
.demo-ad-strip {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- [ ] **Step 2: Create the DemoAdStrip component**
|
||||
|
||||
```tsx
|
||||
// src/components/ads/DemoAdStrip.tsx
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { isDemo } from "@/core/edition";
|
||||
import { AdUnit } from "./AdUnit";
|
||||
import { X } from "lucide-react";
|
||||
import "./DemoAdStrip.css";
|
||||
|
||||
/** The ad slot ID for the vertical skyscraper unit — set this in AdSense dashboard. */
|
||||
const VERTICAL_AD_SLOT = "REPLACE_WITH_YOUR_AD_SLOT_ID";
|
||||
|
||||
export function DemoAdStrip() {
|
||||
const [showMessage, setShowMessage] = useState(false);
|
||||
const [closed, setClosed] = useState(false);
|
||||
|
||||
if (!isDemo || closed) return null;
|
||||
|
||||
return (
|
||||
<aside className="demo-ad-strip" aria-label="Sponsored content">
|
||||
<AdUnit
|
||||
adSlot={VERTICAL_AD_SLOT}
|
||||
adFormat="vertical"
|
||||
className="demo-ad-strip__ad"
|
||||
/>
|
||||
|
||||
<div
|
||||
className="demo-ad-strip__banner"
|
||||
onClick={() => setShowMessage((prev) => !prev)}
|
||||
role="button"
|
||||
tabIndex={0}
|
||||
onKeyDown={(e) => { if (e.key === "Enter") setShowMessage((prev) => !prev); }}
|
||||
>
|
||||
<button
|
||||
className="demo-ad-strip__close"
|
||||
onClick={(e) => { e.stopPropagation(); setClosed(true); }}
|
||||
aria-label="Dismiss ad panel"
|
||||
>
|
||||
<X size={12} />
|
||||
</button>
|
||||
<span className="demo-ad-strip__banner-label">Why ads?</span>
|
||||
{showMessage ? (
|
||||
<span className="demo-ad-strip__banner-text">
|
||||
This isn't permanent — it's temporary because I'm a single
|
||||
dev and need to cover hosting costs. Thank you for understanding.
|
||||
</span>
|
||||
) : (
|
||||
<span className="demo-ad-strip__banner-text">
|
||||
Click to learn more
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</aside>
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
- [ ] **Step 3: Commit**
|
||||
|
||||
```bash
|
||||
git add src/components/ads/DemoAdStrip.tsx src/components/ads/DemoAdStrip.css
|
||||
git commit -m "feat: add DemoAdStrip with Google AdSense vertical unit"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 7: Integrate into AppShell
|
||||
|
||||
**Files:**
|
||||
- Modify: `src/components/layout/AppShell.tsx:8-9,168`
|
||||
|
||||
- [ ] **Step 1: Add import**
|
||||
|
||||
After the existing `CameraStatsPanel` import (line 8), add:
|
||||
|
||||
```tsx
|
||||
import CameraStatsPanel from "@/components/panels/CameraStatsPanel";
|
||||
import { DemoAdStrip } from "@/components/ads/DemoAdStrip"; // ADD THIS
|
||||
import { Timeline } from "@/components/timeline/Timeline";
|
||||
```
|
||||
|
||||
- [ ] **Step 2: Add the JSX**
|
||||
|
||||
After `<EntityInfoCard />` (line 168), add:
|
||||
|
||||
```tsx
|
||||
<EntityInfoCard />
|
||||
<DemoAdStrip />
|
||||
<Timeline />
|
||||
```
|
||||
|
||||
- [ ] **Step 3: Commit**
|
||||
|
||||
```bash
|
||||
git add src/components/layout/AppShell.tsx
|
||||
git commit -m "feat: integrate DemoAdStrip into AppShell"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 8: ads.txt for AdSense Verification
|
||||
|
||||
**Files:**
|
||||
- Create: `public/ads.txt`
|
||||
|
||||
- [ ] **Step 1: Create ads.txt**
|
||||
|
||||
```
|
||||
google.com, ca-pub-XXXXXXXXXXXXXXXX, DIRECT, f08c47fec0942fa0
|
||||
```
|
||||
|
||||
> Replace `ca-pub-XXXXXXXXXXXXXXXX` with your actual publisher ID. This file is required by AdSense for domain verification.
|
||||
|
||||
- [ ] **Step 2: Commit**
|
||||
|
||||
```bash
|
||||
git add public/ads.txt
|
||||
git commit -m "chore: add ads.txt for AdSense domain verification"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Open Questions
|
||||
|
||||
> [!IMPORTANT]
|
||||
> **Do you have a Google AdSense publisher ID yet?** If not, you'll need to sign up at https://www.google.com/adsense/ and get your `ca-pub-XXXX` ID and create a 160x600 "Wide Skyscraper" ad unit to get the slot ID. The code will render nothing gracefully until these are configured.
|
||||
|
||||
> [!WARNING]
|
||||
> **CSP changes are required for AdSense to work.** The current CSP is restrictive and blocks `pagead2.googlesyndication.com` and `googleads.g.doubleclick.net`. Task 3 adds them. Without this, ads will be silently blocked by the browser.
|
||||
|
||||
---
|
||||
|
||||
## Verification Plan
|
||||
|
||||
### Manual Verification
|
||||
|
||||
1. Set `NEXT_PUBLIC_WWV_EDITION=demo` and `NEXT_PUBLIC_ADSENSE_CLIENT_ID=ca-pub-XXXX` in `.env.local`
|
||||
2. Run `pnpm dev`
|
||||
3. Verify: A 160px vertical strip appears on the right edge of the screen
|
||||
4. Verify: The "Why ads?" banner is clickable and toggles the explanation message
|
||||
5. Verify: Clicking the X dismisses the entire strip
|
||||
6. Verify: On mobile viewport widths (< 768px), the strip is hidden
|
||||
7. Verify: Set `NEXT_PUBLIC_WWV_EDITION=local` → strip does not render at all
|
||||
8. Verify: Browser console shows no CSP violations related to AdSense domains
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,145 @@
|
||||
# Expand OSM Chips Implementation Plan
|
||||
|
||||
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||
|
||||
**Goal:** Expand the available OSM search chips to include a curated list of ~30 pre-loaded OSINT-relevant tags, and add a live Taginfo API autocomplete search to dynamically find and select any of the millions of other OSM tags.
|
||||
|
||||
**Architecture:** We will replace the current small `COMMON_TAGS` array with a richer, categorized list inside the `OSMSidebar` file. To allow access to "all" tags without crashing the UI, we will add a debounced fetch hook that hits `https://taginfo.openstreetmap.org/api/4/tags/popular` (or the equivalent search endpoint) when the user types in the filter box. These dynamically fetched tags will temporarily populate the chip list.
|
||||
|
||||
**Tech Stack:** React, TypeScript, Taginfo API
|
||||
|
||||
---
|
||||
|
||||
### Task 1: Update Pre-Loaded COMMON_TAGS
|
||||
|
||||
**Files:**
|
||||
- Modify: `c:\dev\worldwideview\packages\wwv-plugin-osm-search\src\components\OSMSidebar.tsx:6-11`
|
||||
|
||||
- [ ] **Step 1: Replace existing COMMON_TAGS array**
|
||||
|
||||
```tsx
|
||||
const COMMON_TAGS = [
|
||||
// Military & Security
|
||||
"military=base", "military=bunker", "amenity=police", "amenity=prison",
|
||||
// Aviation & Maritime
|
||||
"aeroway=aerodrome", "aeroway=helipad", "aeroway=hangar", "man_made=pier", "harbour=yes",
|
||||
// Infrastructure & Utilities
|
||||
"power=plant", "power=substation", "telecom=antenna", "man_made=communications_tower", "man_made=water_tower",
|
||||
// Transport
|
||||
"highway=bus_stop", "railway=station", "amenity=fuel", "amenity=parking",
|
||||
// Medical & Emergency
|
||||
"amenity=hospital", "amenity=fire_station", "amenity=clinic",
|
||||
// General Commercial & Industrial
|
||||
"shop=supermarket", "tourism=hotel", "industrial=factory", "landuse=industrial",
|
||||
// Education & Amenities
|
||||
"amenity=school", "amenity=university", "amenity=cafe", "building=house"
|
||||
];
|
||||
```
|
||||
|
||||
- [ ] **Step 2: Commit**
|
||||
|
||||
```bash
|
||||
git add packages/wwv-plugin-osm-search/src/components/OSMSidebar.tsx
|
||||
git commit -m "feat(osm-search): expand quick preset tags with OSINT categories"
|
||||
```
|
||||
|
||||
### Task 2: Implement Taginfo Dynamic Autocomplete
|
||||
|
||||
**Files:**
|
||||
- Modify: `c:\dev\worldwideview\packages\wwv-plugin-osm-search\src\components\OSMSidebar.tsx`
|
||||
|
||||
- [ ] **Step 1: Add state and debounced fetch logic inside OSMSidebar component**
|
||||
|
||||
```tsx
|
||||
const [searchText, setSearchText] = useState("");
|
||||
const [activeTags, setActiveTags] = useState<string[]>([]);
|
||||
const [dynamicTags, setDynamicTags] = useState<string[]>([]);
|
||||
const [isSearchingApi, setIsSearchingApi] = useState(false);
|
||||
|
||||
// Add this useEffect below the useState hooks
|
||||
React.useEffect(() => {
|
||||
if (searchText.length < 3) {
|
||||
setDynamicTags([]);
|
||||
return;
|
||||
}
|
||||
|
||||
const timer = setTimeout(async () => {
|
||||
setIsSearchingApi(true);
|
||||
try {
|
||||
// Fetch tags matching the search term from OSM Taginfo
|
||||
const res = await fetch(`https://taginfo.openstreetmap.org/api/4/search/by_keyword?query=${encodeURIComponent(searchText)}`);
|
||||
const data = await res.json();
|
||||
if (data && data.data) {
|
||||
// Extract exact key=value pairs or just keys, format as "key=value"
|
||||
const tags = data.data
|
||||
.filter((item: any) => item.key && item.value)
|
||||
.map((item: any) => `${item.key}=${item.value}`)
|
||||
.slice(0, 15); // Limit to top 15 results
|
||||
setDynamicTags(tags);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Taginfo fetch failed", err);
|
||||
} finally {
|
||||
setIsSearchingApi(false);
|
||||
}
|
||||
}, 500); // 500ms debounce
|
||||
|
||||
return () => clearTimeout(timer);
|
||||
}, [searchText]);
|
||||
```
|
||||
|
||||
- [ ] **Step 2: Update rendering logic to merge static and dynamic tags**
|
||||
|
||||
Look for the `renderedTags` definition and replace it:
|
||||
|
||||
```tsx
|
||||
// Combine filtered common tags with newly fetched dynamic tags, removing duplicates
|
||||
const filteredCommon = searchText
|
||||
? COMMON_TAGS.filter(t => t.toLowerCase().includes(searchText.toLowerCase()))
|
||||
: COMMON_TAGS;
|
||||
|
||||
const renderedTags = Array.from(new Set([...filteredCommon, ...dynamicTags]));
|
||||
```
|
||||
|
||||
- [ ] **Step 3: Add loading indicator to the search input area**
|
||||
|
||||
Look for the `<input>` element for `searchText` and wrap it/add a loading indicator:
|
||||
|
||||
```tsx
|
||||
<div style={{ position: "relative" }}>
|
||||
<input
|
||||
style={{
|
||||
width: "100%",
|
||||
padding: "8px",
|
||||
paddingRight: "24px",
|
||||
backgroundColor: "rgba(0,0,0,0.3)",
|
||||
color: "#fff",
|
||||
border: "1px solid var(--border-subtle)",
|
||||
borderRadius: "4px",
|
||||
fontSize: "13px"
|
||||
}}
|
||||
placeholder="Filter or search OSM for tags..."
|
||||
value={searchText}
|
||||
onChange={e => setSearchText(e.target.value)}
|
||||
/>
|
||||
{isSearchingApi && (
|
||||
<span style={{
|
||||
position: "absolute",
|
||||
right: "8px",
|
||||
top: "50%",
|
||||
transform: "translateY(-50%)",
|
||||
fontSize: "10px",
|
||||
color: "var(--text-muted)"
|
||||
}}>
|
||||
⏳
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
```
|
||||
|
||||
- [ ] **Step 4: Commit**
|
||||
|
||||
```bash
|
||||
git add packages/wwv-plugin-osm-search/src/components/OSMSidebar.tsx
|
||||
git commit -m "feat(osm-search): add live Taginfo autocomplete for unlisted tags"
|
||||
```
|
||||
@@ -0,0 +1,139 @@
|
||||
# Plugin Versioning Streamlining Implementation Plan
|
||||
|
||||
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||
|
||||
**Goal:** Refactor all WorldWideView plugin classes to derive their `version` property dynamically from their local `package.json` file rather than hardcoding string literals.
|
||||
|
||||
**Architecture:** We will replace the hardcoded `version = "x.y.z"` strings in the core `WorldPlugin` interface implementations across all monorepo packages. We will utilize TypeScript's JSON module resolution feature to `import pkg from "../package.json"` and map `version = pkg.version`. This ensures that `pnpm version patch` is the single source of truth and eliminates the double-bookkeeping that previously made CI fixes tedious.
|
||||
|
||||
**Tech Stack:** TypeScript, Next.js / bundler (JSON module resolution), pnpm workspaces.
|
||||
|
||||
---
|
||||
|
||||
## Task 1: Verify TypeScript Configuration
|
||||
|
||||
**Files:**
|
||||
- Modify: N/A (Verification step)
|
||||
|
||||
- [ ] **Step 1: Check `tsconfig.json` for JSON resolution**
|
||||
|
||||
Run: `cat tsconfig.json | grep resolveJsonModule`
|
||||
Expected: `"resolveJsonModule": true`
|
||||
|
||||
- [ ] **Step 2: Check compiler compatibility**
|
||||
|
||||
Run: `pnpm exec tsc --noEmit`
|
||||
Expected: PASS (exit code 0)
|
||||
|
||||
## Task 2: Refactor Group A Plugins (Core Infrastructure)
|
||||
|
||||
**Files:**
|
||||
- Modify: `packages/wwv-plugin-aviation/src/index.ts`
|
||||
- Modify: `packages/wwv-plugin-maritime/src/index.ts`
|
||||
- Modify: `packages/wwv-plugin-military-aviation/src/index.ts`
|
||||
|
||||
- [ ] **Step 1: Update plugin classes**
|
||||
|
||||
For each file above, modify the imports and the class body:
|
||||
|
||||
```typescript
|
||||
import pkg from "../package.json";
|
||||
// ...
|
||||
export class AviationPlugin implements WorldPlugin { // (or extends BasePlugin)
|
||||
// ...
|
||||
version = pkg.version;
|
||||
```
|
||||
|
||||
- [ ] **Step 2: Verify compilation**
|
||||
|
||||
Run: `pnpm exec tsc --noEmit`
|
||||
Expected: PASS
|
||||
|
||||
- [ ] **Step 3: Commit**
|
||||
|
||||
```bash
|
||||
git commit -am "refactor(plugins): derive version dynamically for core infrastructure plugins [Patch]"
|
||||
```
|
||||
|
||||
## Task 3: Refactor Group B Plugins (Facilities & Infrastructure)
|
||||
|
||||
**Files:**
|
||||
- Modify: `packages/wwv-plugin-airports/src/index.ts`
|
||||
- Modify: `packages/wwv-plugin-seaports/src/index.ts`
|
||||
- Modify: `packages/wwv-plugin-spaceports/src/index.ts`
|
||||
- Modify: `packages/wwv-plugin-embassies/src/index.ts`
|
||||
- Modify: `packages/wwv-plugin-lighthouses/src/index.ts`
|
||||
- Modify: `packages/wwv-plugin-nuclear/src/index.ts`
|
||||
- Modify: `packages/wwv-plugin-undersea-cables/src/index.ts`
|
||||
- Modify: `packages/wwv-plugin-mineral-mines/src/index.ts`
|
||||
|
||||
- [ ] **Step 1: Update plugin classes**
|
||||
|
||||
For each file above, replace `version = "..."` with `version = pkg.version` and add `import pkg from "../package.json";`.
|
||||
|
||||
- [ ] **Step 2: Verify compilation**
|
||||
|
||||
Run: `pnpm exec tsc --noEmit`
|
||||
Expected: PASS
|
||||
|
||||
- [ ] **Step 3: Commit**
|
||||
|
||||
```bash
|
||||
git commit -am "refactor(plugins): derive version dynamically for facility plugins [Patch]"
|
||||
```
|
||||
|
||||
## Task 4: Refactor Group C Plugins (Hazards & Events)
|
||||
|
||||
**Files:**
|
||||
- Modify: `packages/wwv-plugin-earthquakes/src/index.ts`
|
||||
- Modify: `packages/wwv-plugin-volcanoes/src/index.ts`
|
||||
- Modify: `packages/wwv-plugin-wildfire/src/index.ts`
|
||||
- Modify: `packages/wwv-plugin-conflict-events/src/index.tsx`
|
||||
- Modify: `packages/wwv-plugin-conflict-zones/src/index.tsx`
|
||||
- Modify: `packages/wwv-plugin-civil-unrest/src/index.tsx`
|
||||
- Modify: `packages/wwv-plugin-cyber-attacks/src/index.tsx`
|
||||
- Modify: `packages/wwv-plugin-international-sanctions/src/index.tsx`
|
||||
|
||||
- [ ] **Step 1: Update plugin classes**
|
||||
|
||||
For each file above, replace `version = "..."` with `version = pkg.version` and add `import pkg from "../package.json";`. Note that some files are `.tsx`.
|
||||
|
||||
- [ ] **Step 2: Verify compilation**
|
||||
|
||||
Run: `pnpm exec tsc --noEmit`
|
||||
Expected: PASS
|
||||
|
||||
- [ ] **Step 3: Commit**
|
||||
|
||||
```bash
|
||||
git commit -am "refactor(plugins): derive version dynamically for event and hazard plugins [Patch]"
|
||||
```
|
||||
|
||||
## Task 5: Refactor Group D Plugins (Misc & Utilities)
|
||||
|
||||
**Files:**
|
||||
- Modify: `packages/wwv-plugin-satellite/src/index.ts`
|
||||
- Modify: `packages/wwv-plugin-surveillance-satellites/src/index.tsx`
|
||||
- Modify: `packages/wwv-plugin-osm-search/src/index.ts`
|
||||
- Modify: `packages/wwv-plugin-iranwarlive/src/index.ts`
|
||||
- Modify: `packages/wwv-plugin-daynight/src/index.ts`
|
||||
- Modify: `packages/wwv-plugin-camera/src/index.ts`
|
||||
- Modify: `packages/wwv-plugin-borders/src/index.ts`
|
||||
- Modify: `packages/wwv-plugin-gps-jamming/src/index.tsx`
|
||||
- Modify: `packages/wwv-plugin-air-defense/src/index.tsx`
|
||||
|
||||
- [ ] **Step 1: Update plugin classes**
|
||||
|
||||
For each file above, replace `version = "..."` with `version = pkg.version` and add `import pkg from "../package.json";`.
|
||||
|
||||
- [ ] **Step 2: Verify compilation and tests**
|
||||
|
||||
Run: `pnpm exec tsc --noEmit`
|
||||
Run: `pnpm test`
|
||||
Expected: PASS
|
||||
|
||||
- [ ] **Step 3: Commit**
|
||||
|
||||
```bash
|
||||
git commit -am "refactor(plugins): derive version dynamically for utility plugins [Patch]"
|
||||
```
|
||||
@@ -0,0 +1,124 @@
|
||||
# Demo Default Plugins Implementation Plan
|
||||
|
||||
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||
|
||||
**Goal:** Enable specific plugins by default on the demo edition via environment variables so the user is immediately impressed.
|
||||
|
||||
**Architecture:** Update `layersSlice.ts` to accept an optional `defaultEnabled` parameter in `initLayer`. In `AppShell.tsx`, look up `NEXT_PUBLIC_DEMO_DEFAULT_PLUGINS` when the edition is `demo`, and pass the flag true to `initLayer` for matching plugins during registration. Document the variable in `.env.example`.
|
||||
|
||||
**Tech Stack:** Next.js, Zustand, TypeScript.
|
||||
|
||||
---
|
||||
|
||||
### Task 1: Update layer slice definition
|
||||
|
||||
**Files:**
|
||||
- Modify: `src/core/state/layersSlice.ts`
|
||||
|
||||
- [ ] **Step 1: Write the implementation**
|
||||
|
||||
Update `initLayer` in `src/core/state/layersSlice.ts` to accept a second parameter:
|
||||
|
||||
```typescript
|
||||
// Add defaultEnabled parameter to the interface
|
||||
export interface LayersSlice {
|
||||
// ...
|
||||
initLayer: (pluginId: string, defaultEnabled?: boolean) => void;
|
||||
}
|
||||
|
||||
// ...
|
||||
|
||||
// Use the parameter in the state updater
|
||||
initLayer: (pluginId, defaultEnabled = false) =>
|
||||
set((state) => ({
|
||||
layers: {
|
||||
...state.layers,
|
||||
[pluginId]: state.layers[pluginId] || { enabled: defaultEnabled, entityCount: 0, loading: false },
|
||||
},
|
||||
})),
|
||||
```
|
||||
|
||||
- [ ] **Step 2: Commit**
|
||||
|
||||
```bash
|
||||
git add src/core/state/layersSlice.ts
|
||||
npm run commit -- "feat: add defaultEnabled param to initLayer in layers slice"
|
||||
```
|
||||
|
||||
### Task 2: Apply default configuration in AppShell
|
||||
|
||||
**Files:**
|
||||
- Modify: `src/components/layout/AppShell.tsx`
|
||||
|
||||
- [ ] **Step 1: Write the implementation**
|
||||
|
||||
Add `isDemo` import at the top of `src/components/layout/AppShell.tsx`:
|
||||
|
||||
```typescript
|
||||
import { isDemo } from "@/core/edition";
|
||||
```
|
||||
|
||||
In `AppShell.tsx`, around line 71, inside `startPlatform()`, fetch the value from the environment if the instance is demo:
|
||||
|
||||
```typescript
|
||||
// Fetch disabled built-in plugins before registration
|
||||
let disabledIds = new Set<string>();
|
||||
// ... (keep existing try/catch block)
|
||||
|
||||
// Setup demo defaults
|
||||
const demoDefaultPlugins = new Set<string>();
|
||||
if (isDemo) {
|
||||
const envVar = process.env.NEXT_PUBLIC_DEMO_DEFAULT_PLUGINS || "";
|
||||
envVar.split(",").forEach(s => {
|
||||
const clean = s.trim();
|
||||
if (clean) demoDefaultPlugins.add(clean);
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
Then update the `pluginManager` registration loop to inject the boolean for `initLayer`:
|
||||
|
||||
```typescript
|
||||
for (const plugin of pluginRegistry.getAll()) {
|
||||
await pluginManager.registerPlugin(plugin);
|
||||
initLayer(plugin.id, demoDefaultPlugins.has(plugin.id));
|
||||
}
|
||||
```
|
||||
|
||||
- [ ] **Step 2: Run test to verify it passes**
|
||||
|
||||
Run type checks to verify no compilation issues:
|
||||
`npx tsc --noEmit`
|
||||
|
||||
- [ ] **Step 3: Commit**
|
||||
|
||||
```bash
|
||||
git add src/components/layout/AppShell.tsx
|
||||
npm run commit -- "feat: parse and apply default demo plugins via NEXT_PUBLIC_DEMO_DEFAULT_PLUGINS"
|
||||
```
|
||||
|
||||
### Task 3: Document environment definitions
|
||||
|
||||
**Files:**
|
||||
- Modify: `.env.example`
|
||||
- Modify: `.env`
|
||||
|
||||
- [ ] **Step 1: Write the implementation**
|
||||
|
||||
Update `.env.example` and `.env` around the `NEXT_PUBLIC_WWV_EDITION=local` definition:
|
||||
|
||||
```dotenv
|
||||
# Default plugins enabled on boot for demo edition
|
||||
# Comma-separated list of plugin IDs (e.g. aviation,maritime,iranwarlive)
|
||||
NEXT_PUBLIC_DEMO_DEFAULT_PLUGINS=
|
||||
|
||||
# Edition: "local" | "cloud" | "demo"
|
||||
NEXT_PUBLIC_WWV_EDITION=local
|
||||
```
|
||||
|
||||
- [ ] **Step 2: Commit**
|
||||
|
||||
```bash
|
||||
git add .env.example .env
|
||||
npm run commit -- "docs: add NEXT_PUBLIC_DEMO_DEFAULT_PLUGINS to env templates"
|
||||
```
|
||||
@@ -0,0 +1,177 @@
|
||||
# Decouple Plugin Proxies Implementation Plan
|
||||
|
||||
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||
|
||||
**Goal:** Strip out hardcoded proxy endpoints from the `worldwideview` core repository to enforce a fully decoupled plugin ecosystem, replacing them with direct browser fetching or a universal CORS proxy.
|
||||
|
||||
**Architecture:** Remove preferential API routes (`/api/earthquake`, `/api/undersea-cables`, `/api/camera/*`) from the `worldwideview` core app. Promote the existing camera proxy to a universal `/api/proxy` with strict SSRF defenses. Provide direct browser-fetch code for the `wwv-plugin-earthquakes` where CORS permits, and migrate traffic camera fetchers directly into the `wwv-plugin-camera` package to fetch via the universal proxy.
|
||||
|
||||
**Tech Stack:** Next.js 16 (App Router), TypeScript, pnpm workspace
|
||||
|
||||
---
|
||||
|
||||
### Task 1: Promote Universal Proxy in Core Repository
|
||||
|
||||
**Files:**
|
||||
- Create (Move): `src/app/api/proxy/route.ts`
|
||||
- Delete: `src/app/api/camera/proxy/route.ts`
|
||||
|
||||
- [ ] **Step 1: Relocate the proxy route and update logs**
|
||||
|
||||
Move the existing camera proxy to act as a system-wide universal proxy.
|
||||
|
||||
Run: `mkdir -p src/app/api/proxy`
|
||||
Run: `mv src/app/api/camera/proxy/route.ts src/app/api/proxy/route.ts`
|
||||
|
||||
- [ ] **Step 2: Update the error logging prefix in the new file**
|
||||
|
||||
Modify `src/app/api/proxy/route.ts` near line 97:
|
||||
|
||||
```json
|
||||
{
|
||||
"instruction": "Update the error logging prefix",
|
||||
"replace_chunks": [
|
||||
{
|
||||
"start_line": 96,
|
||||
"end_line": 98,
|
||||
"target_content": " } catch (error: any) {\n console.error(\"[CameraProxy] Error fetching target URL:\", error);\n return NextResponse.json(",
|
||||
"replacement_content": " } catch (error: any) {\n console.error(\"[UniversalProxy] Error fetching target URL:\", error);\n return NextResponse.json("
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
- [ ] **Step 3: Commit the Universal Proxy**
|
||||
|
||||
```bash
|
||||
git add src/app/api/proxy/route.ts src/app/api/camera/proxy/route.ts
|
||||
git commit -m "refactor: promote camera proxy to universal proxy"
|
||||
```
|
||||
|
||||
### Task 2: Strip Preferential Proxy Routes From Core Application
|
||||
|
||||
**Files:**
|
||||
- Delete: `src/app/api/earthquake/route.ts`
|
||||
- Delete: `src/app/api/undersea-cables/route.ts`
|
||||
- Delete: everything in `src/app/api/camera` codebase (`caltrans`, `extract`, `gdot`, `test`, `tfl`, `traffic`)
|
||||
|
||||
- [ ] **Step 1: Delete all plugin-specific Next.js API routes**
|
||||
|
||||
Run: `rm -rf src/app/api/earthquake`
|
||||
Run: `rm -rf src/app/api/undersea-cables`
|
||||
|
||||
**WAIT**: For `src/app/api/camera`, we must physically copy the fetchers into `worldwideview-plugins` before we delete them.
|
||||
|
||||
Run: `cp -r src/app/api/camera/caltrans ../worldwideview-plugins/packages/wwv-plugin-camera/src/`
|
||||
Run: `cp -r src/app/api/camera/gdot ../worldwideview-plugins/packages/wwv-plugin-camera/src/`
|
||||
Run: `cp -r src/app/api/camera/tfl ../worldwideview-plugins/packages/wwv-plugin-camera/src/`
|
||||
Run: `rm -rf src/app/api/camera`
|
||||
|
||||
- [ ] **Step 2: Commit the deleted API routes**
|
||||
|
||||
```bash
|
||||
git add src/app/api/earthquake src/app/api/undersea-cables src/app/api/camera
|
||||
git commit -m "refactor!: strip preferential plugin APIs from core"
|
||||
```
|
||||
|
||||
### Task 3: Migrate Earthquakes and Undersea Cables Plugins
|
||||
|
||||
**Files:**
|
||||
- Modify: `../worldwideview-plugins/packages/wwv-plugin-earthquakes/src/index.ts`
|
||||
- Modify: `../worldwideview-plugins/packages/wwv-plugin-undersea-cables/src/index.ts`
|
||||
|
||||
- [ ] **Step 1: Update Earthquakes plugin to direct browser fetch (Option A)**
|
||||
|
||||
In `../worldwideview-plugins/packages/wwv-plugin-earthquakes/src/index.ts`, replace the `/api/earthquake` fetch with the USGS direct URL.
|
||||
|
||||
```json
|
||||
{
|
||||
"instruction": "Replace the API fetch with direct USGS fetch and remove apiBasePath",
|
||||
"replace_chunks": [
|
||||
{
|
||||
"start_line": 38,
|
||||
"end_line": 40,
|
||||
"target_content": " try {\n const res = await globalThis.fetch(`/api/earthquake`);\n if (!res.ok) {",
|
||||
"replacement_content": " try {\n const res = await globalThis.fetch(`https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.geojson`);\n if (!res.ok) {"
|
||||
},
|
||||
{
|
||||
"start_line": 94,
|
||||
"end_line": 96,
|
||||
"target_content": " getServerConfig(): ServerPluginConfig {\n return { apiBasePath: \"/api/earthquake\", pollingIntervalMs: 120000, historyEnabled: false };\n }",
|
||||
"replacement_content": " getServerConfig(): ServerPluginConfig {\n return { pollingIntervalMs: 120000, historyEnabled: false };\n }"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
- [ ] **Step 2: Update Undersea Cables plugin to use Universal Proxy (Option B)**
|
||||
|
||||
In `../worldwideview-plugins/packages/wwv-plugin-undersea-cables/src/index.ts`:
|
||||
|
||||
```json
|
||||
{
|
||||
"instruction": "Proxy route to universal proxy",
|
||||
"replace_chunks": [
|
||||
{
|
||||
"start_line": 35,
|
||||
"end_line": 37,
|
||||
"target_content": " // Proxy route to bypass CORS for Telegeography submarine cable map API\n const url = \"/api/undersea-cables\";\n ",
|
||||
"replacement_content": " // Proxy route to bypass CORS for Telegeography submarine cable map API\n const targetUrl = encodeURIComponent(\"https://www.submarinecablemap.com/api/v3/cable/cable-geo.json\");\n const url = `/api/proxy?url=${targetUrl}`;\n "
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
- [ ] **Step 3: Commit the plugin migrations**
|
||||
|
||||
```bash
|
||||
cd ../worldwideview-plugins
|
||||
git add packages/wwv-plugin-earthquakes/src/index.ts packages/wwv-plugin-undersea-cables/src/index.ts
|
||||
git commit -m "refactor: transition earthquake and undersea cables to decoupled fetching"
|
||||
cd ../worldwideview
|
||||
```
|
||||
|
||||
### Task 4: Refactor Camera Plugin to Fetch Natively
|
||||
|
||||
**Files:**
|
||||
- Modify: `../worldwideview-plugins/packages/wwv-plugin-camera/src/index.ts`
|
||||
- Delete: `caltrans`, `gdot`, `tfl` previously copied components (combine into `trafficFetchers.ts`)
|
||||
|
||||
- [ ] **Step 1: Consolidate the camera fetchers**
|
||||
|
||||
Create `../worldwideview-plugins/packages/wwv-plugin-camera/src/trafficFetchers.ts`.
|
||||
Migrate the code from the `caltransFetcher.ts`, `gdotFetcher.ts`, and `tflFetcher.ts` files that we copied in Task 2.
|
||||
Crucially, when doing `fetch(...)` in these fetchers, if the endpoint doesn't support CORS, wrap it in `/api/proxy?url=${encodeURIComponent(...) }` so the browser can fetch it. Ensure the data models align.
|
||||
|
||||
- [ ] **Step 2: Update `wwv-plugin-camera/src/index.ts` to call the fetchers natively**
|
||||
|
||||
In `../worldwideview-plugins/packages/wwv-plugin-camera/src/index.ts` function `loadTrafficCameras()`:
|
||||
|
||||
```json
|
||||
{
|
||||
"instruction": "Replace API fetch with native client-side parallel fetching",
|
||||
"replace_chunks": [
|
||||
{
|
||||
"start_line": 106,
|
||||
"end_line": 118,
|
||||
"target_content": " private async loadTrafficCameras(): Promise<void> {\n try {\n const res = await fetch(\"/api/camera/traffic\");\n if (!res.ok) throw new Error(`API returned ${res.status}`);\n const data = await res.json();\n if (data.cameras && Array.isArray(data.cameras)) {\n this.sourceBuckets[\"default\"] = data.cameras.map(\n (f: unknown, i: number) => mapGeoJsonFeature(f, i, \"traffic\"),\n );\n }\n } catch (err) {\n console.warn(\"[CameraPlugin] Traffic cameras API failed:\", err);\n }",
|
||||
"replacement_content": " private async loadTrafficCameras(): Promise<void> {\n try {\n const { fetchCaltrans, fetchGdot, fetchTfl } = await import(\"./trafficFetchers\");\n const [caltrans, gdot, tfl] = await Promise.allSettled([\n fetchCaltrans(), fetchGdot(), fetchTfl()\n ]);\n \n const cameras = [];\n if (caltrans.status === \"fulfilled\") cameras.push(...caltrans.value);\n if (gdot.status === \"fulfilled\") cameras.push(...gdot.value);\n if (tfl.status === \"fulfilled\") cameras.push(...tfl.value);\n\n if (cameras.length > 0) {\n this.sourceBuckets[\"default\"] = cameras.map(\n (f: unknown, i: number) => mapGeoJsonFeature(f, i, \"traffic\"),\n );\n }\n } catch (err) {\n console.warn(\"[CameraPlugin] Traffic cameras API failed:\", err);\n }"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
- [ ] **Step 3: Remove the extra node API files from the plugin source tree**
|
||||
|
||||
Run: `rm -rf ../worldwideview-plugins/packages/wwv-plugin-camera/src/caltrans`
|
||||
Run: `rm -rf ../worldwideview-plugins/packages/wwv-plugin-camera/src/gdot`
|
||||
Run: `rm -rf ../worldwideview-plugins/packages/wwv-plugin-camera/src/tfl`
|
||||
|
||||
- [ ] **Step 4: Commit Camera plugin refactoring**
|
||||
|
||||
```bash
|
||||
cd ../worldwideview-plugins
|
||||
git add packages/wwv-plugin-camera/src
|
||||
git commit -m "feat: migrate traffic camera fetchers to client-side plugin bundle"
|
||||
cd ../worldwideview
|
||||
```
|
||||
Whitespace-only changes.
+45
-6
@@ -1,8 +1,20 @@
|
||||
import type { NextConfig } from "next";
|
||||
import webpack from "webpack";
|
||||
|
||||
const nextConfig: NextConfig = {
|
||||
output: "standalone",
|
||||
serverExternalPackages: ["better-sqlite3", "@prisma/adapter-better-sqlite3", "@prisma/client", "prisma"],
|
||||
transpilePackages: ["@worldwideview/wwv-plugin-sdk","resium",
|
||||
"react-player",
|
||||
"satellite.js"
|
||||
],
|
||||
experimental: {
|
||||
memoryBasedWorkersCount: true,
|
||||
cpus: 2,
|
||||
optimizePackageImports: ["lucide-react"],
|
||||
},
|
||||
typescript: {
|
||||
ignoreBuildErrors: true,
|
||||
},
|
||||
async headers() {
|
||||
return [
|
||||
{
|
||||
@@ -13,11 +25,17 @@ const nextConfig: NextConfig = {
|
||||
value: [
|
||||
"default-src 'self'",
|
||||
// CesiumJS requires unsafe-eval (worker compilation) and unsafe-inline (styles)
|
||||
"script-src 'self' 'unsafe-eval' 'unsafe-inline' blob:",
|
||||
"script-src 'self' 'unsafe-eval' 'unsafe-inline' blob: https://cdn.jsdelivr.net https://analytics.worldwideview.dev https://va.vercel-scripts.com https://pagead2.googlesyndication.com https://adservice.google.com https://www.googletagservices.com https://ep2.adtrafficquality.google https://static.cloudflareinsights.com",
|
||||
"style-src 'self' 'unsafe-inline' fonts.googleapis.com",
|
||||
"font-src 'self' fonts.gstatic.com",
|
||||
"img-src 'self' data: blob: *.tile.openstreetmap.org *.arcgisonline.com *.virtualearth.net *.bing.com *.googleapis.com",
|
||||
"connect-src 'self' *.supabase.co *.worldwideview.dev *.cesium.com *.arcgisonline.com *.virtualearth.net *.googleapis.com *.vercel-scripts.com",
|
||||
// Camera streams load images/MJPEG from arbitrary IPs worldwide — http: https: required
|
||||
"img-src 'self' data: blob: http: https:",
|
||||
// Camera HLS streams and external data fetches need arbitrary origins
|
||||
"connect-src 'self' http: https: ws: wss:",
|
||||
// HLS video streams from arbitrary camera sources
|
||||
"media-src 'self' blob: http: https:",
|
||||
// Embeddable video platforms for camera iframes
|
||||
"frame-src 'self' *.youtube.com *.youtube-nocookie.com *.twitch.tv *.vimeo.com *.webcamera.pl *.ivideon.com *.rtsp.me *.bnu.tv https://googleads.g.doubleclick.net https://tpc.googlesyndication.com https://ep2.adtrafficquality.google https://*.google.com",
|
||||
"worker-src 'self' blob:",
|
||||
"frame-ancestors 'none'",
|
||||
].join("; "),
|
||||
@@ -34,13 +52,14 @@ const nextConfig: NextConfig = {
|
||||
},
|
||||
];
|
||||
},
|
||||
|
||||
outputFileTracingExcludes: {
|
||||
"*": ["./public/cesium/**"],
|
||||
},
|
||||
env: {
|
||||
CESIUM_BASE_URL: "/cesium",
|
||||
},
|
||||
webpack: (config, { isServer }) => {
|
||||
webpack: (config, { isServer, webpack }) => {
|
||||
if (!isServer) {
|
||||
// Define CESIUM_BASE_URL for Cesium's worker resolution
|
||||
config.plugins?.push(
|
||||
@@ -65,4 +84,24 @@ const nextConfig: NextConfig = {
|
||||
},
|
||||
};
|
||||
|
||||
export default nextConfig;
|
||||
import { withSentryConfig } from "@sentry/nextjs";
|
||||
|
||||
export default withSentryConfig(nextConfig, {
|
||||
// For all available options, see:
|
||||
// https://github.com/getsentry/sentry-webpack-plugin#options
|
||||
org: process.env.SENTRY_ORG,
|
||||
project: process.env.SENTRY_PROJECT,
|
||||
sentryUrl: process.env.GLITCHTIP_SERVER_URL,
|
||||
authToken: process.env.SENTRY_AUTH_TOKEN,
|
||||
|
||||
// Automatically tree-shake Sentry logger statements to reduce bundle size
|
||||
disableLogger: true,
|
||||
|
||||
// Hides source maps from generated client bundles
|
||||
sourcemaps: {
|
||||
disable: true,
|
||||
},
|
||||
|
||||
// Upload a larger set of source maps for prettier stack traces (increases build time)
|
||||
widenClientFileUpload: true,
|
||||
});
|
||||
Generated
-8122
File diff suppressed because it is too large.
Load diff
+28
-12
@@ -1,43 +1,44 @@
|
||||
{
|
||||
"name": "worldwideview",
|
||||
"version": "0.1.0",
|
||||
"version": "1.12.0",
|
||||
"private": true,
|
||||
"workspaces": ["packages/*"],
|
||||
"scripts": {
|
||||
"setup": "node scripts/setup.mjs",
|
||||
"test-worktree": "node scripts/test-worktree.mjs",
|
||||
"clean": "node -e \"const fs=require('fs');fs.rmSync('.next',{recursive:true,force:true})\"",
|
||||
"dev": "next dev --webpack",
|
||||
"dev:all": "concurrently -n \"next,backends\" -c \"magenta,blue\" \"pnpm dev\" \"pnpm dev:backends\"",
|
||||
"dev:backends": "cd ../wwv-data-engine && pnpm dev",
|
||||
"predev": "npx prisma migrate deploy && node scripts/copy-cesium.mjs",
|
||||
"copy-cesium": "node scripts/copy-cesium.mjs",
|
||||
"build": "next build --webpack",
|
||||
"start": "next start",
|
||||
"test": "vitest run"
|
||||
"test": "vitest run",
|
||||
"db:reset": "npx prisma migrate reset --force"
|
||||
},
|
||||
"dependencies": {
|
||||
"@worldwideview/wwv-plugin-sdk": "*",
|
||||
"@worldwideview/wwv-plugin-aviation": "*",
|
||||
"@worldwideview/wwv-plugin-maritime": "*",
|
||||
"@worldwideview/wwv-plugin-wildfire": "*",
|
||||
"@worldwideview/wwv-plugin-borders": "*",
|
||||
"@worldwideview/wwv-plugin-camera": "*",
|
||||
"@worldwideview/wwv-plugin-military-aviation": "*",
|
||||
"@auth/prisma-adapter": "^2.11.1",
|
||||
"@prisma/adapter-better-sqlite3": "^7.5.0",
|
||||
"@prisma/client": "^7.5.0",
|
||||
"@sentry/nextjs": "^10.48.0",
|
||||
"@supabase/supabase-js": "^2.98.0",
|
||||
"@vercel/analytics": "^1.6.1",
|
||||
"@worldwideview/wwv-plugin-sdk": "workspace:*",
|
||||
"bcryptjs": "^3.0.3",
|
||||
"cesium": "^1.139.0",
|
||||
"cheerio": "^1.2.0",
|
||||
"hls.js": "^1.6.15",
|
||||
"insecam-api": "^0.0.3",
|
||||
"jose": "^6.2.2",
|
||||
"lucide-react": "^0.576.0",
|
||||
"next": "16.1.6",
|
||||
"next": "16.2.3",
|
||||
"next-auth": "^5.0.0-beta.30",
|
||||
"prisma": "^7.5.0",
|
||||
"react": "19.2.3",
|
||||
"react-dom": "19.2.3",
|
||||
"react-player": "^3.4.0",
|
||||
"resium": "^1.19.4",
|
||||
"resium": "1.19.4",
|
||||
"satellite.js": "^7.0.0",
|
||||
"tslib": "^2.8.1",
|
||||
"ws": "^8.14.2",
|
||||
"zustand": "^5.0.11"
|
||||
@@ -46,14 +47,29 @@
|
||||
"@testing-library/dom": "^10.4.1",
|
||||
"@testing-library/react": "^16.3.2",
|
||||
"@types/bcryptjs": "^3.0.0",
|
||||
"@types/cesium": "^1.70.4",
|
||||
"@types/node": "^20",
|
||||
"@types/react": "^19",
|
||||
"@types/react-dom": "^19",
|
||||
"@types/ws": "^8.18.1",
|
||||
"@vitejs/plugin-react": "^5.1.4",
|
||||
"concurrently": "^9.2.1",
|
||||
"copy-webpack-plugin": "^14.0.0",
|
||||
"jsdom": "^28.1.0",
|
||||
"rollup-plugin-external-globals": "^0.13.0",
|
||||
"typescript": "^5",
|
||||
"vite": "^8.0.8",
|
||||
"vitest": "^4.0.18"
|
||||
},
|
||||
"pnpm": {
|
||||
"onlyBuiltDependencies": [
|
||||
"@prisma/engines",
|
||||
"better-sqlite3",
|
||||
"esbuild",
|
||||
"prisma",
|
||||
"protobufjs",
|
||||
"sharp",
|
||||
"unrs-resolver"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
# @worldwideview/wwv-plugin-aviation
|
||||
|
||||
[WorldWideView](https://github.com/silvertakana/worldwideview) plugin for **real-time commercial aircraft tracking** via the [OpenSky Network](https://opensky-network.org/) API.
|
||||
|
||||
## Features
|
||||
|
||||
- 🛩️ Live aircraft positions updated every 15 seconds
|
||||
- 🎨 Altitude-based color coding (green → cyan → blue → purple → pink)
|
||||
- ✈️ 3D airplane model rendering with heading-oriented rotation
|
||||
- 🔍 Filters: country of origin, altitude range, on-ground status, callsign
|
||||
- 📡 Flight trail rendering on entity selection
|
||||
- ⏪ History playback mode support
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install @worldwideview/wwv-plugin-aviation
|
||||
```
|
||||
|
||||
### Peer Dependencies
|
||||
|
||||
- `@worldwideview/wwv-plugin-sdk`
|
||||
- `lucide-react` ≥ 0.576.0
|
||||
|
||||
## Usage
|
||||
|
||||
```ts
|
||||
import { AviationPlugin } from "@worldwideview/wwv-plugin-aviation";
|
||||
|
||||
const plugin = new AviationPlugin();
|
||||
```
|
||||
|
||||
Register the plugin with the WorldWideView plugin engine to start tracking aircraft on the globe.
|
||||
|
||||
## Data Source
|
||||
|
||||
Live data is fetched from the [OpenSky Network REST API](https://openskynetwork.github.io/opensky-api/). Requires server-side API route at `/api/aviation`.
|
||||
|
||||
## Changelog
|
||||
|
||||
- **v1.0.3** — Added README with feature list and usage docs.
|
||||
- **v1.0.2** — Package metadata updates.
|
||||
- **v1.0.1** — Package configuration fixes.
|
||||
- **v1.0.0** — Initial release with live tracking, altitude coloring, and 3D model rendering.
|
||||
|
||||
## License
|
||||
|
||||
ISC
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
import type { WorldPlugin, GeoEntity, TimeRange, PluginContext, LayerConfig, CesiumEntityOptions, SelectionBehavior, ServerPluginConfig, FilterDefinition } from "@worldwideview/wwv-plugin-sdk";
|
||||
export declare class AviationPlugin implements WorldPlugin {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
icon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
||||
category: "aviation";
|
||||
version: string;
|
||||
private context;
|
||||
initialize(ctx: PluginContext): Promise<void>;
|
||||
destroy(): void;
|
||||
fetch(_timeRange: TimeRange): Promise<GeoEntity[]>;
|
||||
getPollingInterval(): number;
|
||||
getLayerConfig(): LayerConfig;
|
||||
renderEntity(entity: GeoEntity): CesiumEntityOptions;
|
||||
getSelectionBehavior(entity: GeoEntity): SelectionBehavior | null;
|
||||
getServerConfig(): ServerPluginConfig;
|
||||
getFilterDefinitions(): FilterDefinition[];
|
||||
}
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACR,WAAW,EACX,SAAS,EACT,SAAS,EACT,aAAa,EACb,WAAW,EACX,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EACnB,MAAM,+BAA+B,CAAC;AAqBvC,qBAAa,cAAe,YAAW,WAAW;IAC9C,EAAE,SAAc;IAChB,IAAI,SAAc;IAClB,WAAW,SAAqD;IAChE,IAAI,4IAAS;IACb,QAAQ,EAAG,UAAU,CAAU;IAC/B,OAAO,SAAW;IAClB,OAAO,CAAC,OAAO,CAA8B;IAEvC,UAAU,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IACnD,OAAO,IAAI,IAAI;IAET,KAAK,CAAC,UAAU,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IA0DxD,kBAAkB,IAAI,MAAM;IAC5B,cAAc,IAAI,WAAW;IAE7B,YAAY,CAAC,MAAM,EAAE,SAAS,GAAG,mBAAmB;IAWpD,oBAAoB,CAAC,MAAM,EAAE,SAAS,GAAG,iBAAiB,GAAG,IAAI;IAKjE,eAAe,IAAI,kBAAkB;IAIrC,oBAAoB,IAAI,gBAAgB,EAAE;CAQ7C"}
|
||||
-175
@@ -1,175 +0,0 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
||||
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AviationPlugin = void 0;
|
||||
var lucide_react_1 = require("lucide-react");
|
||||
function altitudeToColor(altitude) {
|
||||
if (altitude === null || altitude <= 0)
|
||||
return "#4ade80";
|
||||
if (altitude < 3000)
|
||||
return "#22d3ee";
|
||||
if (altitude < 8000)
|
||||
return "#3b82f6";
|
||||
if (altitude < 12000)
|
||||
return "#a78bfa";
|
||||
return "#f472b6";
|
||||
}
|
||||
var AviationPlugin = /** @class */ (function () {
|
||||
function AviationPlugin() {
|
||||
this.id = "aviation";
|
||||
this.name = "Aviation";
|
||||
this.description = "Real-time aircraft tracking via OpenSky Network";
|
||||
this.icon = lucide_react_1.Plane;
|
||||
this.category = "aviation";
|
||||
this.version = "1.0.0";
|
||||
this.context = null;
|
||||
}
|
||||
AviationPlugin.prototype.initialize = function (ctx) {
|
||||
return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
|
||||
this.context = ctx;
|
||||
return [2 /*return*/];
|
||||
}); });
|
||||
};
|
||||
AviationPlugin.prototype.destroy = function () { this.context = null; };
|
||||
AviationPlugin.prototype.fetch = function (_timeRange) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var time, res_1, historyData, res, data, err_1;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
_a.trys.push([0, 6, , 7]);
|
||||
if (!this.context.isPlaybackMode()) return [3 /*break*/, 3];
|
||||
time = this.context.getCurrentTime().getTime();
|
||||
return [4 /*yield*/, fetch("/api/aviation/history?time=".concat(time))];
|
||||
case 1:
|
||||
res_1 = _a.sent();
|
||||
if (!res_1.ok)
|
||||
throw new Error("History API returned ".concat(res_1.status));
|
||||
return [4 /*yield*/, res_1.json()];
|
||||
case 2:
|
||||
historyData = _a.sent();
|
||||
if (!historyData.records || !Array.isArray(historyData.records))
|
||||
return [2 /*return*/, []];
|
||||
return [2 /*return*/, historyData.records.map(function (s) { return ({
|
||||
id: "aviation-history-".concat(s.icao24),
|
||||
pluginId: "aviation",
|
||||
latitude: s.latitude,
|
||||
longitude: s.longitude,
|
||||
altitude: (s.altitude || 0) * 10,
|
||||
heading: s.heading || undefined,
|
||||
speed: s.speed || undefined,
|
||||
timestamp: new Date(s.timestamp),
|
||||
label: s.callsign || s.icao24,
|
||||
properties: { icao24: s.icao24, callsign: s.callsign, altitude_m: s.altitude, velocity_ms: s.speed, heading: s.heading, on_ground: s.altitude === null || s.altitude <= 0 },
|
||||
}); })];
|
||||
case 3: return [4 /*yield*/, fetch("/api/aviation")];
|
||||
case 4:
|
||||
res = _a.sent();
|
||||
if (!res.ok)
|
||||
throw new Error("Aviation API returned ".concat(res.status));
|
||||
return [4 /*yield*/, res.json()];
|
||||
case 5:
|
||||
data = _a.sent();
|
||||
if (data.error && !data.states)
|
||||
return [2 /*return*/, []];
|
||||
if (!data.states || !Array.isArray(data.states))
|
||||
return [2 /*return*/, []];
|
||||
return [2 /*return*/, data.states
|
||||
.filter(function (s) { return s[6] !== null && s[5] !== null; })
|
||||
.map(function (s) {
|
||||
var _a;
|
||||
var st = {
|
||||
icao24: s[0], callsign: ((_a = s[1]) === null || _a === void 0 ? void 0 : _a.trim()) || null,
|
||||
origin_country: s[2], time_position: s[3],
|
||||
last_contact: s[4], longitude: s[5],
|
||||
latitude: s[6], baro_altitude: s[7],
|
||||
on_ground: s[8], velocity: s[9],
|
||||
true_track: s[10], vertical_rate: s[11],
|
||||
sensors: s[12], geo_altitude: s[13],
|
||||
squawk: s[14], spi: s[15], position_source: s[16],
|
||||
};
|
||||
return {
|
||||
id: "aviation-".concat(st.icao24), pluginId: "aviation",
|
||||
latitude: st.latitude, longitude: st.longitude,
|
||||
altitude: (st.baro_altitude || 0) * 10,
|
||||
heading: st.true_track || undefined, speed: st.velocity || undefined,
|
||||
timestamp: new Date((st.time_position || st.last_contact) * 1000),
|
||||
label: st.callsign || st.icao24,
|
||||
properties: { icao24: st.icao24, callsign: st.callsign, origin_country: st.origin_country, altitude_m: st.baro_altitude, velocity_ms: st.velocity, heading: st.true_track, vertical_rate: st.vertical_rate, on_ground: st.on_ground, squawk: st.squawk },
|
||||
};
|
||||
})];
|
||||
case 6:
|
||||
err_1 = _a.sent();
|
||||
console.error("[AviationPlugin] Fetch error:", err_1);
|
||||
return [2 /*return*/, []];
|
||||
case 7: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
AviationPlugin.prototype.getPollingInterval = function () { return 15000; };
|
||||
AviationPlugin.prototype.getLayerConfig = function () { return { color: "#3b82f6", clusterEnabled: true, clusterDistance: 40, maxEntities: 5000 }; };
|
||||
AviationPlugin.prototype.renderEntity = function (entity) {
|
||||
var alt = entity.properties.altitude_m;
|
||||
var isAirborne = !entity.properties.on_ground;
|
||||
return {
|
||||
type: "model", iconUrl: "/plane-icon.svg", size: isAirborne ? 8 : 5,
|
||||
modelUrl: "/airplane/scene.gltf", modelScale: 75, modelMinPixelSize: 16, modelHeadingOffset: 180,
|
||||
color: altitudeToColor(alt), rotation: entity.heading,
|
||||
labelText: entity.label || undefined, labelFont: "11px JetBrains Mono, monospace",
|
||||
};
|
||||
};
|
||||
AviationPlugin.prototype.getSelectionBehavior = function (entity) {
|
||||
if (entity.properties.on_ground)
|
||||
return null;
|
||||
return { showTrail: true, trailDurationSec: 60, trailStepSec: 5, trailColor: "#00fff7", flyToOffsetMultiplier: 3, flyToBaseDistance: 30000 };
|
||||
};
|
||||
AviationPlugin.prototype.getServerConfig = function () {
|
||||
return { apiBasePath: "/api/aviation", pollingIntervalMs: 5000, requiresAuth: true, historyEnabled: true, availabilityEnabled: true };
|
||||
};
|
||||
AviationPlugin.prototype.getFilterDefinitions = function () {
|
||||
return [
|
||||
{ id: "origin_country", label: "Country", type: "select", propertyKey: "origin_country", options: [{ value: "United States", label: "United States" }, { value: "China", label: "China" }, { value: "United Kingdom", label: "United Kingdom" }, { value: "Germany", label: "Germany" }, { value: "France", label: "France" }, { value: "Japan", label: "Japan" }, { value: "Australia", label: "Australia" }, { value: "Canada", label: "Canada" }, { value: "India", label: "India" }, { value: "Brazil", label: "Brazil" }, { value: "Russia", label: "Russia" }, { value: "Turkey", label: "Turkey" }, { value: "South Korea", label: "South Korea" }, { value: "Indonesia", label: "Indonesia" }, { value: "Mexico", label: "Mexico" }] },
|
||||
{ id: "altitude", label: "Altitude (m)", type: "range", propertyKey: "altitude_m", range: { min: 0, max: 15000, step: 500 } },
|
||||
{ id: "on_ground", label: "On Ground", type: "boolean", propertyKey: "on_ground" },
|
||||
{ id: "callsign", label: "Callsign", type: "text", propertyKey: "callsign" },
|
||||
];
|
||||
};
|
||||
return AviationPlugin;
|
||||
}());
|
||||
exports.AviationPlugin = AviationPlugin;
|
||||
@@ -1,36 +0,0 @@
|
||||
{
|
||||
"name": "@worldwideview/wwv-plugin-aviation",
|
||||
"version": "1.0.4",
|
||||
"description": "WorldWideView plugin for real-time commercial aircraft tracking via the OpenSky Network API. Renders 3D aircraft models with altitude-based coloring, flight trails, and country/altitude/callsign filters",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
"files": [
|
||||
"src"
|
||||
],
|
||||
"keywords": [
|
||||
"worldwideview",
|
||||
"worldwideview-plugin",
|
||||
"wwv-plugin-aviation",
|
||||
"aviation",
|
||||
"aircraft-tracking",
|
||||
"opensky",
|
||||
"flight-tracker",
|
||||
"cesium",
|
||||
"globe"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/silvertakana/worldwideview.git",
|
||||
"directory": "packages/wwv-plugin-aviation"
|
||||
},
|
||||
"homepage": "https://github.com/silvertakana/worldwideview#readme",
|
||||
"bugs": {
|
||||
"url": "https://github.com/silvertakana/worldwideview/issues"
|
||||
},
|
||||
"license": "ISC",
|
||||
"author": "WorldWideView",
|
||||
"peerDependencies": {
|
||||
"@worldwideview/wwv-plugin-sdk": "*",
|
||||
"lucide-react": ">=0.576.0"
|
||||
}
|
||||
}
|
||||
@@ -1,134 +0,0 @@
|
||||
import { Plane } from "lucide-react";
|
||||
import type {
|
||||
WorldPlugin,
|
||||
GeoEntity,
|
||||
TimeRange,
|
||||
PluginContext,
|
||||
LayerConfig,
|
||||
CesiumEntityOptions,
|
||||
SelectionBehavior,
|
||||
ServerPluginConfig,
|
||||
FilterDefinition,
|
||||
} from "@worldwideview/wwv-plugin-sdk";
|
||||
|
||||
interface OpenSkyState {
|
||||
icao24: string; callsign: string | null; origin_country: string;
|
||||
time_position: number | null; last_contact: number;
|
||||
longitude: number | null; latitude: number | null;
|
||||
baro_altitude: number | null; on_ground: boolean;
|
||||
velocity: number | null; true_track: number | null;
|
||||
vertical_rate: number | null; sensors: number[] | null;
|
||||
geo_altitude: number | null; squawk: string | null;
|
||||
spi: boolean; position_source: number;
|
||||
}
|
||||
|
||||
function altitudeToColor(altitude: number | null): string {
|
||||
if (altitude === null || altitude <= 0) return "#4ade80";
|
||||
if (altitude < 3000) return "#22d3ee";
|
||||
if (altitude < 8000) return "#3b82f6";
|
||||
if (altitude < 12000) return "#a78bfa";
|
||||
return "#f472b6";
|
||||
}
|
||||
|
||||
export class AviationPlugin implements WorldPlugin {
|
||||
id = "aviation";
|
||||
name = "Aviation";
|
||||
description = "Real-time aircraft tracking via OpenSky Network";
|
||||
icon = Plane;
|
||||
category = "aviation" as const;
|
||||
version = "1.0.0";
|
||||
private context: PluginContext | null = null;
|
||||
|
||||
async initialize(ctx: PluginContext): Promise<void> { this.context = ctx; }
|
||||
destroy(): void { this.context = null; }
|
||||
|
||||
async fetch(_timeRange: TimeRange): Promise<GeoEntity[]> {
|
||||
try {
|
||||
// Use PluginContext instead of direct useStore access
|
||||
if (this.context!.isPlaybackMode()) {
|
||||
const time = this.context!.getCurrentTime().getTime();
|
||||
const res = await fetch(`/api/aviation/history?time=${time}`);
|
||||
if (!res.ok) throw new Error(`History API returned ${res.status}`);
|
||||
const historyData = await res.json();
|
||||
if (!historyData.records || !Array.isArray(historyData.records)) return [];
|
||||
return historyData.records.map((s: Record<string, unknown>): GeoEntity => ({
|
||||
id: `aviation-history-${s.icao24}`,
|
||||
pluginId: "aviation",
|
||||
latitude: s.latitude as number,
|
||||
longitude: s.longitude as number,
|
||||
altitude: ((s.altitude as number) || 0) * 10,
|
||||
heading: (s.heading as number) || undefined,
|
||||
speed: (s.speed as number) || undefined,
|
||||
timestamp: new Date(s.timestamp as string),
|
||||
label: (s.callsign as string) || (s.icao24 as string),
|
||||
properties: { icao24: s.icao24, callsign: s.callsign, altitude_m: s.altitude, velocity_ms: s.speed, heading: s.heading, on_ground: (s.altitude as number) === null || (s.altitude as number) <= 0 },
|
||||
}));
|
||||
}
|
||||
|
||||
const res = await fetch("/api/aviation");
|
||||
if (!res.ok) throw new Error(`Aviation API returned ${res.status}`);
|
||||
const data = await res.json();
|
||||
if (data.error && !data.states) return [];
|
||||
if (!data.states || !Array.isArray(data.states)) return [];
|
||||
|
||||
return data.states
|
||||
.filter((s: unknown[]) => s[6] !== null && s[5] !== null)
|
||||
.map((s: unknown[]): GeoEntity => {
|
||||
const st: OpenSkyState = {
|
||||
icao24: s[0] as string, callsign: (s[1] as string)?.trim() || null,
|
||||
origin_country: s[2] as string, time_position: s[3] as number | null,
|
||||
last_contact: s[4] as number, longitude: s[5] as number | null,
|
||||
latitude: s[6] as number | null, baro_altitude: s[7] as number | null,
|
||||
on_ground: s[8] as boolean, velocity: s[9] as number | null,
|
||||
true_track: s[10] as number | null, vertical_rate: s[11] as number | null,
|
||||
sensors: s[12] as number[] | null, geo_altitude: s[13] as number | null,
|
||||
squawk: s[14] as string | null, spi: s[15] as boolean, position_source: s[16] as number,
|
||||
};
|
||||
return {
|
||||
id: `aviation-${st.icao24}`, pluginId: "aviation",
|
||||
latitude: st.latitude!, longitude: st.longitude!,
|
||||
altitude: (st.baro_altitude || 0) * 10,
|
||||
heading: st.true_track || undefined, speed: st.velocity || undefined,
|
||||
timestamp: new Date((st.time_position || st.last_contact) * 1000),
|
||||
label: st.callsign || st.icao24,
|
||||
properties: { icao24: st.icao24, callsign: st.callsign, origin_country: st.origin_country, altitude_m: st.baro_altitude, velocity_ms: st.velocity, heading: st.true_track, vertical_rate: st.vertical_rate, on_ground: st.on_ground, squawk: st.squawk },
|
||||
};
|
||||
});
|
||||
} catch (err) {
|
||||
console.error("[AviationPlugin] Fetch error:", err);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
getPollingInterval(): number { return 15000; }
|
||||
getLayerConfig(): LayerConfig { return { color: "#3b82f6", clusterEnabled: true, clusterDistance: 40, maxEntities: 5000 }; }
|
||||
|
||||
renderEntity(entity: GeoEntity): CesiumEntityOptions {
|
||||
const alt = entity.properties.altitude_m as number | null;
|
||||
const isAirborne = !entity.properties.on_ground;
|
||||
return {
|
||||
type: "model", iconUrl: "/plane-icon.svg", size: isAirborne ? 8 : 5,
|
||||
modelUrl: "/airplane/scene.gltf", modelScale: 75, modelMinPixelSize: 16, modelHeadingOffset: 180,
|
||||
color: altitudeToColor(alt), rotation: entity.heading,
|
||||
labelText: entity.label || undefined, labelFont: "11px JetBrains Mono, monospace",
|
||||
};
|
||||
}
|
||||
|
||||
getSelectionBehavior(entity: GeoEntity): SelectionBehavior | null {
|
||||
if (entity.properties.on_ground) return null;
|
||||
return { showTrail: true, trailDurationSec: 60, trailStepSec: 5, trailColor: "#00fff7", flyToOffsetMultiplier: 3, flyToBaseDistance: 30000 };
|
||||
}
|
||||
|
||||
getServerConfig(): ServerPluginConfig {
|
||||
return { apiBasePath: "/api/aviation", pollingIntervalMs: 5000, requiresAuth: true, historyEnabled: true, availabilityEnabled: true };
|
||||
}
|
||||
|
||||
getFilterDefinitions(): FilterDefinition[] {
|
||||
return [
|
||||
{ id: "origin_country", label: "Country", type: "select", propertyKey: "origin_country", options: [{ value: "United States", label: "United States" }, { value: "China", label: "China" }, { value: "United Kingdom", label: "United Kingdom" }, { value: "Germany", label: "Germany" }, { value: "France", label: "France" }, { value: "Japan", label: "Japan" }, { value: "Australia", label: "Australia" }, { value: "Canada", label: "Canada" }, { value: "India", label: "India" }, { value: "Brazil", label: "Brazil" }, { value: "Russia", label: "Russia" }, { value: "Turkey", label: "Turkey" }, { value: "South Korea", label: "South Korea" }, { value: "Indonesia", label: "Indonesia" }, { value: "Mexico", label: "Mexico" }] },
|
||||
{ id: "altitude", label: "Altitude (m)", type: "range", propertyKey: "altitude_m", range: { min: 0, max: 15000, step: 500 } },
|
||||
{ id: "on_ground", label: "On Ground", type: "boolean", propertyKey: "on_ground" },
|
||||
{ id: "callsign", label: "Callsign", type: "text", propertyKey: "callsign" },
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"outDir": "dist",
|
||||
"noEmit": false
|
||||
},
|
||||
"exclude": ["**/*.test.*"]
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "src",
|
||||
"noEmit": true
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
# @worldwideview/wwv-plugin-borders
|
||||
|
||||
[WorldWideView](https://github.com/silvertakana/worldwideview) plugin that displays **political borders and country labels** as a globe overlay.
|
||||
|
||||
## Features
|
||||
|
||||
- 🗺️ Country border outlines rendered on the 3D globe
|
||||
- 🏷️ Country name labels
|
||||
- ⚡ Zero-polling — static layer with no data fetching overhead
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install @worldwideview/wwv-plugin-borders
|
||||
```
|
||||
|
||||
### Peer Dependencies
|
||||
|
||||
- `@worldwideview/wwv-plugin-sdk`
|
||||
|
||||
## Usage
|
||||
|
||||
```ts
|
||||
import { BordersPlugin } from "@worldwideview/wwv-plugin-borders";
|
||||
|
||||
const plugin = new BordersPlugin();
|
||||
```
|
||||
|
||||
Register the plugin with the WorldWideView plugin engine to display borders on the globe. Border rendering is managed by the host application's `BordersManager`.
|
||||
|
||||
## Changelog
|
||||
|
||||
- **v1.0.3** — Added README with feature list and usage docs.
|
||||
- **v1.0.2** — Package metadata updates.
|
||||
- **v1.0.1** — Package configuration fixes.
|
||||
- **v1.0.0** — Initial release with GeoJSON-based political boundaries.
|
||||
|
||||
## License
|
||||
|
||||
ISC
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
import type { WorldPlugin, GeoEntity, TimeRange, PluginContext, LayerConfig, CesiumEntityOptions } from "@worldwideview/wwv-plugin-sdk";
|
||||
export declare class BordersPlugin implements WorldPlugin {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
icon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
||||
category: "custom";
|
||||
version: string;
|
||||
initialize(_ctx: PluginContext): Promise<void>;
|
||||
destroy(): void;
|
||||
fetch(_timeRange: TimeRange): Promise<GeoEntity[]>;
|
||||
getPollingInterval(): number;
|
||||
getLayerConfig(): LayerConfig;
|
||||
renderEntity(_entity: GeoEntity): CesiumEntityOptions;
|
||||
}
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACR,WAAW,EACX,SAAS,EACT,SAAS,EACT,aAAa,EACb,WAAW,EACX,mBAAmB,EACtB,MAAM,+BAA+B,CAAC;AAEvC,qBAAa,aAAc,YAAW,WAAW;IAC7C,EAAE,SAAa;IACf,IAAI,SAAsB;IAC1B,WAAW,SAA+D;IAC1E,IAAI,4IAAO;IACX,QAAQ,EAAG,QAAQ,CAAU;IAC7B,OAAO,SAAW;IAEZ,UAAU,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IACpD,OAAO,IAAI,IAAI;IAET,KAAK,CAAC,UAAU,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAKxD,kBAAkB,IAAI,MAAM;IAE5B,cAAc,IAAI,WAAW;IAI7B,YAAY,CAAC,OAAO,EAAE,SAAS,GAAG,mBAAmB;CAGxD"}
|
||||
-73
@@ -1,73 +0,0 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
||||
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.BordersPlugin = void 0;
|
||||
var lucide_react_1 = require("lucide-react");
|
||||
var BordersPlugin = /** @class */ (function () {
|
||||
function BordersPlugin() {
|
||||
this.id = "borders";
|
||||
this.name = "Borders & Labels";
|
||||
this.description = "Displays political borders and country labels on the map.";
|
||||
this.icon = lucide_react_1.Map;
|
||||
this.category = "custom";
|
||||
this.version = "1.0.0";
|
||||
}
|
||||
BordersPlugin.prototype.initialize = function (_ctx) {
|
||||
return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
|
||||
return [2 /*return*/];
|
||||
}); });
|
||||
};
|
||||
BordersPlugin.prototype.destroy = function () { };
|
||||
BordersPlugin.prototype.fetch = function (_timeRange) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
// Rendering is managed by BordersManager in GlobeView
|
||||
return [2 /*return*/, []];
|
||||
});
|
||||
});
|
||||
};
|
||||
BordersPlugin.prototype.getPollingInterval = function () { return 9999999; };
|
||||
BordersPlugin.prototype.getLayerConfig = function () {
|
||||
return { color: "#00ffff", clusterEnabled: false, clusterDistance: 0, maxEntities: 0 };
|
||||
};
|
||||
BordersPlugin.prototype.renderEntity = function (_entity) {
|
||||
return { type: "point" };
|
||||
};
|
||||
return BordersPlugin;
|
||||
}());
|
||||
exports.BordersPlugin = BordersPlugin;
|
||||
@@ -1,34 +0,0 @@
|
||||
{
|
||||
"name": "@worldwideview/wwv-plugin-borders",
|
||||
"version": "1.0.4",
|
||||
"description": "WorldWideView plugin that displays political borders and country labels as a globe overlay",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
"files": [
|
||||
"src"
|
||||
],
|
||||
"keywords": [
|
||||
"worldwideview",
|
||||
"worldwideview-plugin",
|
||||
"wwv-plugin-borders",
|
||||
"borders",
|
||||
"countries",
|
||||
"geopolitical",
|
||||
"cesium",
|
||||
"globe"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/silvertakana/worldwideview.git",
|
||||
"directory": "packages/wwv-plugin-borders"
|
||||
},
|
||||
"homepage": "https://github.com/silvertakana/worldwideview#readme",
|
||||
"bugs": {
|
||||
"url": "https://github.com/silvertakana/worldwideview/issues"
|
||||
},
|
||||
"license": "ISC",
|
||||
"author": "WorldWideView",
|
||||
"peerDependencies": {
|
||||
"@worldwideview/wwv-plugin-sdk": "*"
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
import { Map } from "lucide-react";
|
||||
import type {
|
||||
WorldPlugin,
|
||||
GeoEntity,
|
||||
TimeRange,
|
||||
PluginContext,
|
||||
LayerConfig,
|
||||
CesiumEntityOptions,
|
||||
} from "@worldwideview/wwv-plugin-sdk";
|
||||
|
||||
export class BordersPlugin implements WorldPlugin {
|
||||
id = "borders";
|
||||
name = "Borders & Labels";
|
||||
description = "Displays political borders and country labels on the map.";
|
||||
icon = Map;
|
||||
category = "custom" as const;
|
||||
version = "1.0.0";
|
||||
|
||||
async initialize(_ctx: PluginContext): Promise<void> { }
|
||||
destroy(): void { }
|
||||
|
||||
async fetch(_timeRange: TimeRange): Promise<GeoEntity[]> {
|
||||
// Rendering is managed by BordersManager in GlobeView
|
||||
return [];
|
||||
}
|
||||
|
||||
getPollingInterval(): number { return 9999999; }
|
||||
|
||||
getLayerConfig(): LayerConfig {
|
||||
return { color: "#00ffff", clusterEnabled: false, clusterDistance: 0, maxEntities: 0 };
|
||||
}
|
||||
|
||||
renderEntity(_entity: GeoEntity): CesiumEntityOptions {
|
||||
return { type: "point" };
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"outDir": "dist",
|
||||
"noEmit": false
|
||||
},
|
||||
"exclude": ["**/*.test.*"]
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "src",
|
||||
"noEmit": true
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
# @worldwideview/wwv-plugin-camera
|
||||
|
||||
[WorldWideView](https://github.com/silvertakana/worldwideview) plugin for displaying **public live cameras and traffic cameras** on the 3D globe.
|
||||
|
||||
## Features
|
||||
|
||||
- 📷 Multiple data sources: default camera database, traffic cameras, custom URL, file upload
|
||||
- 🌍 GeoJSON support for custom camera datasets
|
||||
- 🎥 Live camera detail view with stream embedding
|
||||
- ⚙️ Built-in settings component for source selection
|
||||
- 🔍 Filters: country, city, popular cameras
|
||||
- 📍 Clustered point rendering with labels
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install @worldwideview/wwv-plugin-camera
|
||||
```
|
||||
|
||||
### Peer Dependencies
|
||||
|
||||
- `@worldwideview/wwv-plugin-sdk`
|
||||
- `react` ≥ 18
|
||||
- `lucide-react` ≥ 0.576.0
|
||||
|
||||
## Usage
|
||||
|
||||
```ts
|
||||
import { CameraPlugin } from "@worldwideview/wwv-plugin-camera";
|
||||
|
||||
const plugin = new CameraPlugin();
|
||||
```
|
||||
|
||||
Register the plugin with the WorldWideView plugin engine. The plugin includes a settings component for switching between camera data sources and a detail component for viewing individual camera streams.
|
||||
|
||||
## Data Sources
|
||||
|
||||
| Source | Description |
|
||||
|---|---|
|
||||
| `default` | Built-in public camera GeoJSON database |
|
||||
| `traffic` | Traffic cameras via `/api/camera/traffic` endpoint |
|
||||
| `url` | Custom JSON URL providing camera data |
|
||||
| `file` | User-uploaded JSON file with camera data |
|
||||
|
||||
## Changelog
|
||||
|
||||
- **v1.0.3** — Added README with feature list and usage docs.
|
||||
- **v1.0.2** — Package metadata updates.
|
||||
- **v1.0.1** — Package configuration fixes.
|
||||
- **v1.0.0** — Initial release with curated public camera feeds.
|
||||
|
||||
## License
|
||||
|
||||
ISC
|
||||
@@ -1,8 +0,0 @@
|
||||
import React from "react";
|
||||
import type { GeoEntity } from "@worldwideview/wwv-plugin-sdk";
|
||||
interface CameraDetailProps {
|
||||
entity: GeoEntity;
|
||||
}
|
||||
export declare const CameraDetail: React.FC<CameraDetailProps>;
|
||||
export {};
|
||||
//# sourceMappingURL=CameraDetail.d.ts.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"CameraDetail.d.ts","sourceRoot":"","sources":["../src/CameraDetail.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAG/D,UAAU,iBAAiB;IAAG,MAAM,EAAE,SAAS,CAAC;CAAE;AAElD,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAmCpD,CAAC"}
|
||||
-37
@@ -1,37 +0,0 @@
|
||||
"use client";
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CameraDetail = void 0;
|
||||
var react_1 = require("react");
|
||||
var CameraStream_1 = require("@/components/video/CameraStream");
|
||||
var CameraDetail = function (_a) {
|
||||
var entity = _a.entity;
|
||||
var properties = entity.properties;
|
||||
var stream = properties.stream;
|
||||
var previewUrl = properties.preview_url;
|
||||
var city = properties.city;
|
||||
var region = properties.region;
|
||||
var country = properties.country;
|
||||
var isIframe = !!properties.is_iframe;
|
||||
var categories = properties.categories || [];
|
||||
return (<div className="flex flex-col gap-4">
|
||||
<CameraStream_1.CameraStream id={entity.id} streamUrl={stream} previewUrl={previewUrl} isIframe={isIframe} label={city || country}/>
|
||||
<div className="intel-panel__props">
|
||||
<div className="intel-panel__prop" style={{ flexDirection: "column", alignItems: "flex-start", gap: "var(--space-xs)", borderBottom: "1px solid var(--border-subtle)", padding: "var(--space-sm) 0" }}>
|
||||
<span className="intel-panel__prop-key">Location</span>
|
||||
<span className="intel-panel__prop-value" style={{ textAlign: "left", width: "100%", whiteSpace: "normal", lineHeight: "1.4", fontSize: "12px", color: "var(--text-primary)" }}>
|
||||
{[city, region, country].filter(Boolean).join(", ")}
|
||||
</span>
|
||||
</div>
|
||||
{categories.length > 0 && (<div className="intel-panel__prop" style={{ flexDirection: "column", alignItems: "flex-start", gap: "var(--space-sm)", borderBottom: "none", padding: "var(--space-sm) 0" }}>
|
||||
<span className="intel-panel__prop-key">Categories</span>
|
||||
<div style={{ display: "flex", flexWrap: "wrap", gap: "6px" }}>
|
||||
{categories.map(function (cat) { return (<span key={cat} style={{ borderRadius: "12px", backgroundColor: "var(--bg-tertiary)", padding: "2px 8px", fontSize: "10px", fontWeight: 500, color: "var(--text-secondary)", border: "1px solid var(--border-subtle)" }}>
|
||||
{cat}
|
||||
</span>); })}
|
||||
</div>
|
||||
</div>)}
|
||||
</div>
|
||||
</div>);
|
||||
};
|
||||
exports.CameraDetail = CameraDetail;
|
||||
@@ -1,5 +0,0 @@
|
||||
import React from "react";
|
||||
export declare const CameraSettings: React.FC<{
|
||||
pluginId: string;
|
||||
}>;
|
||||
//# sourceMappingURL=CameraSettings.d.ts.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"CameraSettings.d.ts","sourceRoot":"","sources":["../src/CameraSettings.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsB,MAAM,OAAO,CAAC;AAQ3C,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CA+FzD,CAAC"}
|
||||
-176
@@ -1,176 +0,0 @@
|
||||
"use client";
|
||||
"use strict";
|
||||
var __assign = (this && this.__assign) || function () {
|
||||
__assign = Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
||||
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CameraSettings = void 0;
|
||||
var react_1 = require("react");
|
||||
var store_1 = require("@/core/state/store");
|
||||
var lucide_react_1 = require("lucide-react");
|
||||
var PluginManager_1 = require("@/core/plugins/PluginManager");
|
||||
var cameraSettingsStyles_1 = require("./cameraSettingsStyles");
|
||||
var CameraSettings = function (_a) {
|
||||
var pluginId = _a.pluginId;
|
||||
var settingsRaw = (0, store_1.useStore)(function (s) { return s.dataConfig.pluginSettings[pluginId]; });
|
||||
var settings = __assign({ sourceType: "default" }, (settingsRaw || {}));
|
||||
var updatePluginSettings = (0, store_1.useStore)(function (s) { return s.updatePluginSettings; });
|
||||
var setHighlightLayerId = (0, store_1.useStore)(function (s) { return s.setHighlightLayerId; });
|
||||
var _b = react_1.default.useState(false), isLoading = _b[0], setIsLoading = _b[1];
|
||||
var handleSourceTypeChange = function (type) {
|
||||
updatePluginSettings(pluginId, { sourceType: type });
|
||||
setHighlightLayerId(null);
|
||||
};
|
||||
var triggerFetch = function () { return __awaiter(void 0, void 0, void 0, function () {
|
||||
var managed;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
managed = PluginManager_1.pluginManager.getPlugin(pluginId);
|
||||
if (!(managed && managed.enabled)) return [3 /*break*/, 2];
|
||||
return [4 /*yield*/, PluginManager_1.pluginManager.fetchForPlugin(pluginId, managed.context.timeRange)];
|
||||
case 1:
|
||||
_a.sent();
|
||||
_a.label = 2;
|
||||
case 2: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
}); };
|
||||
var handleLoadData = function () { return __awaiter(void 0, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
setIsLoading(true);
|
||||
updatePluginSettings(pluginId, { action: "load", actionId: Date.now(), loaded: true });
|
||||
setHighlightLayerId(null);
|
||||
return [4 /*yield*/, triggerFetch()];
|
||||
case 1:
|
||||
_a.sent();
|
||||
setIsLoading(false);
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
}); };
|
||||
var handleResetAll = function () { return __awaiter(void 0, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
updatePluginSettings(pluginId, { action: "reset", actionId: Date.now(), loaded: false, customUrl: "", customData: null });
|
||||
setHighlightLayerId(null);
|
||||
return [4 /*yield*/, triggerFetch()];
|
||||
case 1:
|
||||
_a.sent();
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
}); };
|
||||
var handleFileUpload = function (e) {
|
||||
var _a;
|
||||
var file = (_a = e.target.files) === null || _a === void 0 ? void 0 : _a[0];
|
||||
if (!file)
|
||||
return;
|
||||
var reader = new FileReader();
|
||||
reader.onload = function (event) { return __awaiter(void 0, void 0, void 0, function () {
|
||||
var json, _a;
|
||||
var _b;
|
||||
return __generator(this, function (_c) {
|
||||
switch (_c.label) {
|
||||
case 0:
|
||||
_c.trys.push([0, 2, , 3]);
|
||||
json = JSON.parse((_b = event.target) === null || _b === void 0 ? void 0 : _b.result);
|
||||
updatePluginSettings(pluginId, { customData: json, action: "load", actionId: Date.now(), loaded: true });
|
||||
setHighlightLayerId(null);
|
||||
return [4 /*yield*/, triggerFetch()];
|
||||
case 1:
|
||||
_c.sent();
|
||||
return [3 /*break*/, 3];
|
||||
case 2:
|
||||
_a = _c.sent();
|
||||
alert("Invalid JSON file format.");
|
||||
return [3 /*break*/, 3];
|
||||
case 3: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
}); };
|
||||
reader.readAsText(file);
|
||||
};
|
||||
return (<div style={{ display: "flex", flexDirection: "column", gap: "var(--space-md)" }}>
|
||||
<div style={{ fontSize: 11, color: "var(--text-muted)", marginBottom: "var(--space-xs)" }}>Data Source Configuration</div>
|
||||
<div style={{ display: "flex", gap: "var(--space-xs)" }}>
|
||||
{[["default", lucide_react_1.Database, "Default"], ["traffic", lucide_react_1.TrafficCone, "Traffic Cams"], ["url", lucide_react_1.Link, "URL"], ["file", lucide_react_1.Upload, "File"]].map(function (_a) {
|
||||
var type = _a[0], Icon = _a[1], label = _a[2];
|
||||
return (<button key={type} onClick={function () { return handleSourceTypeChange(type); }} style={(0, cameraSettingsStyles_1.sourceTabStyle)(settings.sourceType === type)}>
|
||||
<Icon size={14}/><span style={{ fontSize: 10 }}>{label}</span>
|
||||
</button>);
|
||||
})}
|
||||
</div>
|
||||
{settings.sourceType === "default" && (<div style={cameraSettingsStyles_1.inputGroupStyle}>
|
||||
<div style={{ fontSize: 11, color: "var(--text-secondary)" }}>Built-in camera dataset</div>
|
||||
<button onClick={handleLoadData} disabled={isLoading} style={(0, cameraSettingsStyles_1.loadButtonStyle)(isLoading)}>{isLoading ? "Loading..." : settings.loaded ? "Reload" : "Load"}</button>
|
||||
</div>)}
|
||||
{settings.sourceType === "traffic" && (<div style={cameraSettingsStyles_1.inputGroupStyle}>
|
||||
<div style={{ fontSize: 11, color: "var(--text-secondary)" }}>DOT traffic cameras (GDOT + more)</div>
|
||||
<button onClick={handleLoadData} disabled={isLoading} style={(0, cameraSettingsStyles_1.loadButtonStyle)(isLoading)}>{isLoading ? "Loading..." : settings.loaded ? "Reload" : "Load"}</button>
|
||||
</div>)}
|
||||
{settings.sourceType === "url" && (<div style={cameraSettingsStyles_1.inputGroupStyle}>
|
||||
<label style={cameraSettingsStyles_1.labelStyle}>URL</label>
|
||||
<div style={{ display: "flex", gap: "var(--space-sm)", marginTop: "4px" }}>
|
||||
<input type="text" placeholder="http://..." value={settings.customUrl || ""} onChange={function (e) { return updatePluginSettings(pluginId, { customUrl: e.target.value }); }} style={__assign(__assign({}, cameraSettingsStyles_1.inputStyle), { flex: 1 })}/>
|
||||
<button onClick={handleLoadData} disabled={!settings.customUrl || isLoading} style={(0, cameraSettingsStyles_1.loadButtonStyle)(!settings.customUrl || isLoading)}>{isLoading ? "Loading..." : "Load"}</button>
|
||||
</div>
|
||||
</div>)}
|
||||
{settings.sourceType === "file" && (<div style={cameraSettingsStyles_1.inputGroupStyle}>
|
||||
<label style={cameraSettingsStyles_1.labelStyle}>JSON File</label>
|
||||
<input type="file" accept=".json" onChange={handleFileUpload} style={__assign(__assign({}, cameraSettingsStyles_1.inputStyle), { width: "100%", marginTop: "4px", padding: "4px", fontSize: "10px" })}/>
|
||||
{settings.customData && Array.isArray(settings.customData) && (<div style={{ fontSize: 10, color: "var(--accent-green)", marginTop: "4px" }}>✓ Data loaded ({settings.customData.length} cameras)</div>)}
|
||||
</div>)}
|
||||
<button onClick={handleResetAll} style={{ display: "flex", alignItems: "center", justifyContent: "center", gap: "6px", background: "transparent", border: "1px solid var(--border-subtle)", borderRadius: "var(--radius-sm)", padding: "6px var(--space-md)", fontSize: 11, color: "var(--text-muted)", cursor: "pointer", transition: "all 0.2s ease" }}>
|
||||
<lucide_react_1.RotateCcw size={12}/> Reset All Sources
|
||||
</button>
|
||||
</div>);
|
||||
};
|
||||
exports.CameraSettings = CameraSettings;
|
||||
@@ -1,31 +0,0 @@
|
||||
/**
|
||||
* Manages Cesium Entity polylines for camera frustum outlines.
|
||||
*
|
||||
* Draws 4 side-edge lines from the camera apex to the 4 far
|
||||
* corners of the view pyramid. No far-plane rectangle is drawn
|
||||
* (it would clip the earth surface).
|
||||
*
|
||||
* Architecture: corners come from frustumGeometry.ts so a future
|
||||
* ground-projection step can replace the far-plane corners with
|
||||
* terrain-intersection points without changing this renderer.
|
||||
*/
|
||||
import type { Viewer as CesiumViewer } from "cesium";
|
||||
import type { GeoEntity } from "@worldwideview/wwv-plugin-sdk";
|
||||
export declare class FrustumRenderer {
|
||||
/** Map from entity id → array of 4 Cesium.Entity polylines */
|
||||
private entityMap;
|
||||
/**
|
||||
* Sync frustum outlines with the current set of camera entities.
|
||||
* Only draws for entities whose `properties` include heading.
|
||||
*/
|
||||
update(viewer: CesiumViewer, entities: GeoEntity[]): void;
|
||||
/** Remove all frustum entities from the viewer. */
|
||||
clear(viewer: CesiumViewer): void;
|
||||
private resolveHeading;
|
||||
private buildEdges;
|
||||
private createNew;
|
||||
private updateExisting;
|
||||
private removeStale;
|
||||
private addEdgeLine;
|
||||
}
|
||||
//# sourceMappingURL=FrustumRenderer.d.ts.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"FrustumRenderer.d.ts","sourceRoot":"","sources":["../src/FrustumRenderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAQH,OAAO,KAAK,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,QAAQ,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAW/D,qBAAa,eAAe;IACxB,8DAA8D;IAC9D,OAAO,CAAC,SAAS,CAA+B;IAEhD;;;OAGG;IACH,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,IAAI;IAuBzD,mDAAmD;IACnD,KAAK,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI;IAejC,OAAO,CAAC,cAAc;IAUtB,OAAO,CAAC,UAAU;IAclB,OAAO,CAAC,SAAS;IAQjB,OAAO,CAAC,cAAc;IAQtB,OAAO,CAAC,WAAW;IASnB,OAAO,CAAC,WAAW;CAiBtB"}
|
||||
-150
@@ -1,150 +0,0 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Manages Cesium Entity polylines for camera frustum outlines.
|
||||
*
|
||||
* Draws 4 side-edge lines from the camera apex to the 4 far
|
||||
* corners of the view pyramid. No far-plane rectangle is drawn
|
||||
* (it would clip the earth surface).
|
||||
*
|
||||
* Architecture: corners come from frustumGeometry.ts so a future
|
||||
* ground-projection step can replace the far-plane corners with
|
||||
* terrain-intersection points without changing this renderer.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.FrustumRenderer = void 0;
|
||||
var cesium_1 = require("cesium");
|
||||
var frustumGeometry_1 = require("./frustumGeometry");
|
||||
var FRUSTUM_COLOR = cesium_1.Color.fromCssColorString("#00ccff").withAlpha(0.6);
|
||||
var EDGE_WIDTH = 2;
|
||||
var FrustumRenderer = /** @class */ (function () {
|
||||
function FrustumRenderer() {
|
||||
/** Map from entity id → array of 4 Cesium.Entity polylines */
|
||||
this.entityMap = new Map();
|
||||
}
|
||||
/**
|
||||
* Sync frustum outlines with the current set of camera entities.
|
||||
* Only draws for entities whose `properties` include heading.
|
||||
*/
|
||||
FrustumRenderer.prototype.update = function (viewer, entities) {
|
||||
if (!viewer || viewer.isDestroyed())
|
||||
return;
|
||||
var activeIds = new Set();
|
||||
for (var _i = 0, entities_1 = entities; _i < entities_1.length; _i++) {
|
||||
var geo = entities_1[_i];
|
||||
if (geo.pluginId !== "camera")
|
||||
continue;
|
||||
var heading = this.resolveHeading(geo);
|
||||
if (heading === undefined)
|
||||
continue;
|
||||
activeIds.add(geo.id);
|
||||
var edges = this.buildEdges(geo, heading);
|
||||
if (this.entityMap.has(geo.id)) {
|
||||
this.updateExisting(viewer, geo.id, edges);
|
||||
}
|
||||
else {
|
||||
this.createNew(viewer, geo.id, edges);
|
||||
}
|
||||
}
|
||||
this.removeStale(viewer, activeIds);
|
||||
};
|
||||
/** Remove all frustum entities from the viewer. */
|
||||
FrustumRenderer.prototype.clear = function (viewer) {
|
||||
if (!viewer || viewer.isDestroyed()) {
|
||||
this.entityMap.clear();
|
||||
return;
|
||||
}
|
||||
for (var _i = 0, _a = this.entityMap; _i < _a.length; _i++) {
|
||||
var _b = _a[_i], lines = _b[1];
|
||||
for (var _c = 0, lines_1 = lines; _c < lines_1.length; _c++) {
|
||||
var line = lines_1[_c];
|
||||
viewer.entities.remove(line);
|
||||
}
|
||||
}
|
||||
this.entityMap.clear();
|
||||
};
|
||||
// ─── Private helpers ─────────────────────────────────────
|
||||
FrustumRenderer.prototype.resolveHeading = function (geo) {
|
||||
var p = geo.properties;
|
||||
if (typeof p.heading === "number")
|
||||
return p.heading;
|
||||
if (typeof p.azimuth === "number")
|
||||
return p.azimuth;
|
||||
if (typeof p.heading === "string") {
|
||||
return parseFloat(p.heading) || undefined;
|
||||
}
|
||||
return geo.heading;
|
||||
};
|
||||
FrustumRenderer.prototype.buildEdges = function (geo, heading) {
|
||||
var p = geo.properties;
|
||||
return (0, frustumGeometry_1.computeFrustumEdges)({
|
||||
lat: geo.latitude,
|
||||
lon: geo.longitude,
|
||||
alt: toNum(p.altitude, toNum(p.alt, frustumGeometry_1.FRUSTUM_DEFAULTS.alt)),
|
||||
headingDeg: heading,
|
||||
pitchDeg: toNum(p.pitch, frustumGeometry_1.FRUSTUM_DEFAULTS.pitchDeg),
|
||||
hFovDeg: toNum(p.fov, toNum(p.hFov, frustumGeometry_1.FRUSTUM_DEFAULTS.hFovDeg)),
|
||||
vFovDeg: toNum(p.vFov, frustumGeometry_1.FRUSTUM_DEFAULTS.vFovDeg),
|
||||
rangeMtrs: toNum(p.range, frustumGeometry_1.FRUSTUM_DEFAULTS.rangeMtrs),
|
||||
});
|
||||
};
|
||||
FrustumRenderer.prototype.createNew = function (viewer, id, edges) {
|
||||
var _this = this;
|
||||
var corners = [edges.topLeft, edges.topRight, edges.bottomLeft, edges.bottomRight];
|
||||
var lines = corners.map(function (corner) {
|
||||
return _this.addEdgeLine(viewer, id, edges.apex, corner);
|
||||
});
|
||||
this.entityMap.set(id, lines);
|
||||
};
|
||||
FrustumRenderer.prototype.updateExisting = function (viewer, id, edges) {
|
||||
var corners = [edges.topLeft, edges.topRight, edges.bottomLeft, edges.bottomRight];
|
||||
var existing = this.entityMap.get(id);
|
||||
for (var i = 0; i < 4; i++) {
|
||||
existing[i].polyline.positions = toPositions(edges.apex, corners[i]);
|
||||
}
|
||||
};
|
||||
FrustumRenderer.prototype.removeStale = function (viewer, activeIds) {
|
||||
for (var _i = 0, _a = this.entityMap; _i < _a.length; _i++) {
|
||||
var _b = _a[_i], id = _b[0], lines = _b[1];
|
||||
if (!activeIds.has(id)) {
|
||||
for (var _c = 0, lines_2 = lines; _c < lines_2.length; _c++) {
|
||||
var line = lines_2[_c];
|
||||
viewer.entities.remove(line);
|
||||
}
|
||||
this.entityMap.delete(id);
|
||||
}
|
||||
}
|
||||
};
|
||||
FrustumRenderer.prototype.addEdgeLine = function (viewer, parentId, from, to) {
|
||||
return viewer.entities.add({
|
||||
id: "frustum-".concat(parentId, "-").concat(Math.random().toString(36).slice(2, 8)),
|
||||
polyline: {
|
||||
positions: toPositions(from, to),
|
||||
width: EDGE_WIDTH,
|
||||
material: new cesium_1.PolylineGlowMaterialProperty({
|
||||
glowPower: 0.15,
|
||||
color: FRUSTUM_COLOR,
|
||||
}),
|
||||
clampToGround: false,
|
||||
},
|
||||
});
|
||||
};
|
||||
return FrustumRenderer;
|
||||
}());
|
||||
exports.FrustumRenderer = FrustumRenderer;
|
||||
// ─── Utilities ───────────────────────────────────────────────
|
||||
function toPositions(a, b) {
|
||||
return [
|
||||
cesium_1.Cartesian3.fromDegrees(a.lon, a.lat, a.alt),
|
||||
cesium_1.Cartesian3.fromDegrees(b.lon, b.lat, b.alt),
|
||||
];
|
||||
}
|
||||
function toNum(val, fallback) {
|
||||
if (typeof val === "number" && !Number.isNaN(val))
|
||||
return val;
|
||||
if (typeof val === "string") {
|
||||
var n = parseFloat(val);
|
||||
if (!Number.isNaN(n))
|
||||
return n;
|
||||
}
|
||||
return fallback;
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
import type { GeoEntity } from "@worldwideview/wwv-plugin-sdk";
|
||||
export declare function mapRawCamera(cam: Record<string, unknown>, index: number, prefix: string): GeoEntity;
|
||||
export declare function mapGeoJsonFeature(feature: unknown, index: number, prefix: string): GeoEntity;
|
||||
//# sourceMappingURL=cameraMapper.d.ts.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"cameraMapper.d.ts","sourceRoot":"","sources":["../src/cameraMapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAI/D,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,CAWnG;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,CAc5F"}
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
"use strict";
|
||||
var __assign = (this && this.__assign) || function () {
|
||||
__assign = Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.mapRawCamera = mapRawCamera;
|
||||
exports.mapGeoJsonFeature = mapGeoJsonFeature;
|
||||
var DEFAULT_CAMERA_ALT = 8;
|
||||
function mapRawCamera(cam, index, prefix) {
|
||||
var _a, _b;
|
||||
return {
|
||||
id: "camera-".concat(prefix, "-").concat(index),
|
||||
pluginId: "camera",
|
||||
latitude: cam.latitude,
|
||||
longitude: cam.longitude,
|
||||
altitude: (_b = (_a = cam.altitude) !== null && _a !== void 0 ? _a : cam.elevation) !== null && _b !== void 0 ? _b : DEFAULT_CAMERA_ALT,
|
||||
timestamp: new Date(),
|
||||
label: cam.city || cam.country || "Unknown Camera",
|
||||
properties: __assign({}, cam),
|
||||
};
|
||||
}
|
||||
function mapGeoJsonFeature(feature, index, prefix) {
|
||||
var _a, _b, _c;
|
||||
var f = feature;
|
||||
var _d = (_b = (_a = f.geometry) === null || _a === void 0 ? void 0 : _a.coordinates) !== null && _b !== void 0 ? _b : [0, 0], lon = _d[0], lat = _d[1];
|
||||
var props = (_c = f.properties) !== null && _c !== void 0 ? _c : {};
|
||||
return {
|
||||
id: "camera-".concat(prefix, "-").concat(index),
|
||||
pluginId: "camera",
|
||||
latitude: lat,
|
||||
longitude: lon,
|
||||
altitude: DEFAULT_CAMERA_ALT,
|
||||
timestamp: new Date(),
|
||||
label: props.city || props.country || "Unknown Camera",
|
||||
properties: __assign({}, props),
|
||||
};
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import type React from "react";
|
||||
export declare const inputGroupStyle: React.CSSProperties;
|
||||
export declare const labelStyle: React.CSSProperties;
|
||||
export declare const inputStyle: React.CSSProperties;
|
||||
export declare const loadButtonStyle: (disabled: boolean) => React.CSSProperties;
|
||||
export declare const sourceTabStyle: (active: boolean) => React.CSSProperties;
|
||||
//# sourceMappingURL=cameraSettingsStyles.d.ts.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"cameraSettingsStyles.d.ts","sourceRoot":"","sources":["../src/cameraSettingsStyles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,aAAwE,CAAC;AAC7G,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,aAAkI,CAAC;AAClK,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,aAAyO,CAAC;AACzQ,eAAO,MAAM,eAAe,GAAI,UAAU,OAAO,KAAG,KAAK,CAAC,aAA0S,CAAC;AACrW,eAAO,MAAM,cAAc,GAAI,QAAQ,OAAO,KAAG,KAAK,CAAC,aAAya,CAAC"}
|
||||
@@ -1,10 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.sourceTabStyle = exports.loadButtonStyle = exports.inputStyle = exports.labelStyle = exports.inputGroupStyle = void 0;
|
||||
exports.inputGroupStyle = { display: "flex", flexDirection: "column", gap: "4px" };
|
||||
exports.labelStyle = { fontSize: 10, fontWeight: 600, color: "var(--text-muted)", textTransform: "uppercase", letterSpacing: "0.05em" };
|
||||
exports.inputStyle = { background: "var(--bg-tertiary)", border: "1px solid var(--border-subtle)", color: "var(--text-primary)", padding: "var(--space-xs) var(--space-sm)", borderRadius: "var(--radius-sm)", fontSize: 12, outline: "none" };
|
||||
var loadButtonStyle = function (disabled) { return ({ background: "var(--accent-cyan)", color: "var(--bg-primary)", border: "none", borderRadius: "var(--radius-sm)", padding: "0 var(--space-md)", fontSize: 12, fontWeight: 500, cursor: disabled ? "not-allowed" : "pointer", opacity: disabled ? 0.5 : 1, transition: "all 0.2s ease" }); };
|
||||
exports.loadButtonStyle = loadButtonStyle;
|
||||
var sourceTabStyle = function (active) { return ({ flex: 1, display: "flex", flexDirection: "column", alignItems: "center", gap: "4px", padding: "8px", borderRadius: "var(--radius-md)", background: active ? "var(--accent-cyan-subtle)" : "var(--bg-tertiary)", border: active ? "1px solid var(--accent-cyan)" : "1px solid var(--border-subtle)", cursor: "pointer", color: active ? "var(--accent-cyan)" : "var(--text-secondary)", transition: "all 0.2s ease" }); };
|
||||
exports.sourceTabStyle = sourceTabStyle;
|
||||
@@ -1,58 +0,0 @@
|
||||
/**
|
||||
* Pure math for computing 3D camera frustum edges.
|
||||
* No Cesium dependency — fully unit-testable.
|
||||
*
|
||||
* The frustum is a pyramid with:
|
||||
* - apex at the camera position
|
||||
* - 4 corner rays extending outward at `range` meters
|
||||
* - orientation defined by heading, pitch, and FOV
|
||||
*
|
||||
* Architecture note: returns raw corner positions so that
|
||||
* a future ground-projection step can raycast these rays
|
||||
* onto the terrain surface.
|
||||
*/
|
||||
export interface Point3D {
|
||||
lat: number;
|
||||
lon: number;
|
||||
alt: number;
|
||||
}
|
||||
/** The 4 far-plane corners + the apex, ready for rendering. */
|
||||
export interface FrustumEdges {
|
||||
apex: Point3D;
|
||||
topLeft: Point3D;
|
||||
topRight: Point3D;
|
||||
bottomLeft: Point3D;
|
||||
bottomRight: Point3D;
|
||||
}
|
||||
export interface FrustumParams {
|
||||
lat: number;
|
||||
lon: number;
|
||||
alt: number;
|
||||
headingDeg: number;
|
||||
pitchDeg: number;
|
||||
hFovDeg: number;
|
||||
vFovDeg: number;
|
||||
rangeMtrs: number;
|
||||
}
|
||||
export declare const FRUSTUM_DEFAULTS: {
|
||||
readonly alt: 8;
|
||||
readonly headingDeg: 0;
|
||||
readonly pitchDeg: -10;
|
||||
readonly hFovDeg: 50;
|
||||
readonly vFovDeg: 35;
|
||||
readonly rangeMtrs: 200;
|
||||
};
|
||||
/**
|
||||
* Compute the 4 frustum corner points at `range` distance
|
||||
* from the camera, given orientation and FOV.
|
||||
*
|
||||
* Returns edges that can be drawn as 4 polylines from apex
|
||||
* to each corner, or passed to a ground-projection step.
|
||||
*/
|
||||
export declare function computeFrustumEdges(params: FrustumParams): FrustumEdges;
|
||||
/**
|
||||
* Convert a cardinal direction string to degrees.
|
||||
* Returns `undefined` if not recognised.
|
||||
*/
|
||||
export declare function cardinalToHeading(dir: string): number | undefined;
|
||||
//# sourceMappingURL=frustumGeometry.d.ts.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"frustumGeometry.d.ts","sourceRoot":"","sources":["../src/frustumGeometry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAOH,MAAM,WAAW,OAAO;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACf;AAED,+DAA+D;AAC/D,MAAM,WAAW,YAAY;IACzB,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,aAAa;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACrB;AAID,eAAO,MAAM,gBAAgB;;;;;;;CAOnB,CAAC;AAIX;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,aAAa,GAAG,YAAY,CAwBvE;AAeD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEjE"}
|
||||
-113
@@ -1,113 +0,0 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Pure math for computing 3D camera frustum edges.
|
||||
* No Cesium dependency — fully unit-testable.
|
||||
*
|
||||
* The frustum is a pyramid with:
|
||||
* - apex at the camera position
|
||||
* - 4 corner rays extending outward at `range` meters
|
||||
* - orientation defined by heading, pitch, and FOV
|
||||
*
|
||||
* Architecture note: returns raw corner positions so that
|
||||
* a future ground-projection step can raycast these rays
|
||||
* onto the terrain surface.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.FRUSTUM_DEFAULTS = void 0;
|
||||
exports.computeFrustumEdges = computeFrustumEdges;
|
||||
exports.cardinalToHeading = cardinalToHeading;
|
||||
var DEG2RAD = Math.PI / 180;
|
||||
var EARTH_RADIUS = 6371000; // metres
|
||||
// ─── Defaults ────────────────────────────────────────────────
|
||||
exports.FRUSTUM_DEFAULTS = {
|
||||
alt: 8,
|
||||
headingDeg: 0,
|
||||
pitchDeg: -10,
|
||||
hFovDeg: 50,
|
||||
vFovDeg: 35,
|
||||
rangeMtrs: 200,
|
||||
};
|
||||
// ─── Core computation ────────────────────────────────────────
|
||||
/**
|
||||
* Compute the 4 frustum corner points at `range` distance
|
||||
* from the camera, given orientation and FOV.
|
||||
*
|
||||
* Returns edges that can be drawn as 4 polylines from apex
|
||||
* to each corner, or passed to a ground-projection step.
|
||||
*/
|
||||
function computeFrustumEdges(params) {
|
||||
var lat = params.lat, lon = params.lon, alt = params.alt, headingDeg = params.headingDeg, pitchDeg = params.pitchDeg, hFovDeg = params.hFovDeg, vFovDeg = params.vFovDeg, rangeMtrs = params.rangeMtrs;
|
||||
var apex = { lat: lat, lon: lon, alt: alt };
|
||||
var halfH = (hFovDeg / 2) * DEG2RAD;
|
||||
var halfV = (vFovDeg / 2) * DEG2RAD;
|
||||
var heading = headingDeg * DEG2RAD;
|
||||
var pitch = pitchDeg * DEG2RAD;
|
||||
// For each corner we compute horizontal bearing offset ± halfH
|
||||
// and vertical pitch offset ± halfV, then project to a destination.
|
||||
var corners = [
|
||||
[-halfH, halfV], // topLeft
|
||||
[halfH, halfV], // topRight
|
||||
[-halfH, -halfV], // bottomLeft
|
||||
[halfH, -halfV], // bottomRight
|
||||
];
|
||||
var _a = corners.map(function (_a) {
|
||||
var hOff = _a[0], vOff = _a[1];
|
||||
return projectCorner(lat, lon, alt, heading, pitch, hOff, vOff, rangeMtrs);
|
||||
}), topLeft = _a[0], topRight = _a[1], bottomLeft = _a[2], bottomRight = _a[3];
|
||||
return { apex: apex, topLeft: topLeft, topRight: topRight, bottomLeft: bottomLeft, bottomRight: bottomRight };
|
||||
}
|
||||
// ─── Cardinal direction helper ───────────────────────────────
|
||||
var CARDINAL_MAP = {
|
||||
n: 0, north: 0, nb: 0, northbound: 0,
|
||||
ne: 45, northeast: 45, neb: 45,
|
||||
e: 90, east: 90, eb: 90, eastbound: 90,
|
||||
se: 135, southeast: 135, seb: 135,
|
||||
s: 180, south: 180, sb: 180, southbound: 180,
|
||||
sw: 225, southwest: 225, swb: 225,
|
||||
w: 270, west: 270, wb: 270, westbound: 270,
|
||||
nw: 315, northwest: 315, nwb: 315,
|
||||
};
|
||||
/**
|
||||
* Convert a cardinal direction string to degrees.
|
||||
* Returns `undefined` if not recognised.
|
||||
*/
|
||||
function cardinalToHeading(dir) {
|
||||
return CARDINAL_MAP[dir.trim().toLowerCase()];
|
||||
}
|
||||
// ─── Internal math ───────────────────────────────────────────
|
||||
/**
|
||||
* Project a single frustum corner from the camera position.
|
||||
*
|
||||
* 1. Compute the bearing = heading + horizontal offset
|
||||
* 2. Compute the ground distance = range * cos(pitch + vOff)
|
||||
* 3. Compute the altitude delta = range * sin(pitch + vOff)
|
||||
* 4. Use haversine destination formula for the ground position
|
||||
*/
|
||||
function projectCorner(latDeg, lonDeg, altM, headingRad, pitchRad, hOffRad, vOffRad, range) {
|
||||
var bearing = headingRad + hOffRad;
|
||||
var elevation = pitchRad + vOffRad;
|
||||
var groundDist = range * Math.cos(elevation);
|
||||
var altDelta = range * Math.sin(elevation);
|
||||
var dest = destinationPoint(latDeg, lonDeg, Math.abs(groundDist), bearing);
|
||||
return {
|
||||
lat: dest.lat,
|
||||
lon: dest.lon,
|
||||
alt: Math.max(0, altM + altDelta),
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Haversine destination point given start coords (deg),
|
||||
* distance (m), and bearing (rad).
|
||||
*/
|
||||
function destinationPoint(latDeg, lonDeg, distMetres, bearingRad) {
|
||||
var lat1 = latDeg * DEG2RAD;
|
||||
var lon1 = lonDeg * DEG2RAD;
|
||||
var angularDist = distMetres / EARTH_RADIUS;
|
||||
var sinLat1 = Math.sin(lat1);
|
||||
var cosLat1 = Math.cos(lat1);
|
||||
var sinD = Math.sin(angularDist);
|
||||
var cosD = Math.cos(angularDist);
|
||||
var lat2 = Math.asin(sinLat1 * cosD + cosLat1 * sinD * Math.cos(bearingRad));
|
||||
var lon2 = lon1 + Math.atan2(Math.sin(bearingRad) * sinD * cosLat1, cosD - sinLat1 * Math.sin(lat2));
|
||||
return { lat: lat2 / DEG2RAD, lon: lon2 / DEG2RAD };
|
||||
}
|
||||
-254
@@ -1,254 +0,0 @@
|
||||
"use strict";
|
||||
var __assign = (this && this.__assign) || function () {
|
||||
__assign = Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
||||
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CameraPlugin = void 0;
|
||||
var lucide_react_1 = require("lucide-react");
|
||||
var CameraDetail_1 = require("./CameraDetail");
|
||||
var CameraSettings_1 = require("./CameraSettings");
|
||||
var cameraMapper_1 = require("./cameraMapper");
|
||||
var analytics_1 = require("@/lib/analytics");
|
||||
var CameraPlugin = /** @class */ (function () {
|
||||
function CameraPlugin() {
|
||||
this.id = "camera";
|
||||
this.name = "Cameras";
|
||||
this.description = "Public live cameras from across the globe";
|
||||
this.icon = lucide_react_1.Camera;
|
||||
this.category = "infrastructure";
|
||||
this.version = "1.0.0";
|
||||
this.context = null;
|
||||
this.sourceBuckets = {};
|
||||
this.lastActionId = null;
|
||||
}
|
||||
CameraPlugin.prototype.initialize = function (ctx) {
|
||||
return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
|
||||
this.context = ctx;
|
||||
return [2 /*return*/];
|
||||
}); });
|
||||
};
|
||||
CameraPlugin.prototype.destroy = function () { this.context = null; };
|
||||
CameraPlugin.prototype.requiresConfiguration = function (settingsRaw) {
|
||||
var _a;
|
||||
var s = settingsRaw;
|
||||
var sourceType = (_a = s === null || s === void 0 ? void 0 : s.sourceType) !== null && _a !== void 0 ? _a : "default";
|
||||
if (sourceType === "default" || sourceType === "traffic")
|
||||
return false;
|
||||
if (sourceType === "url" && !(s === null || s === void 0 ? void 0 : s.customUrl))
|
||||
return true;
|
||||
if (sourceType === "file" && !(s === null || s === void 0 ? void 0 : s.customData))
|
||||
return true;
|
||||
return false;
|
||||
};
|
||||
CameraPlugin.prototype.getAllEntities = function () { return Object.values(this.sourceBuckets).flat(); };
|
||||
CameraPlugin.prototype.pushUpdate = function () { var _a; (_a = this.context) === null || _a === void 0 ? void 0 : _a.onDataUpdate(this.getAllEntities()); };
|
||||
CameraPlugin.prototype.fetch = function (_timeRange) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var rawSettings, settings, isAutoDefault, error_1;
|
||||
var _a, _b;
|
||||
return __generator(this, function (_c) {
|
||||
switch (_c.label) {
|
||||
case 0:
|
||||
rawSettings = this.context.getPluginSettings(this.id);
|
||||
settings = __assign({ sourceType: "default", action: undefined, actionId: undefined, loaded: undefined, customUrl: undefined, customData: undefined }, (rawSettings || {}));
|
||||
if (settings.action === "reset") {
|
||||
this.sourceBuckets = {};
|
||||
this.lastActionId = settings.actionId;
|
||||
return [2 /*return*/, []];
|
||||
}
|
||||
isAutoDefault = (settings.sourceType === "default" || settings.sourceType === "traffic")
|
||||
&& !this.lastActionId && !this.sourceBuckets["default"];
|
||||
if (!isAutoDefault && (settings.action !== "load" || settings.actionId === this.lastActionId)) {
|
||||
return [2 /*return*/, this.getAllEntities()];
|
||||
}
|
||||
this.lastActionId = (_a = settings.actionId) !== null && _a !== void 0 ? _a : -1;
|
||||
_c.label = 1;
|
||||
case 1:
|
||||
_c.trys.push([1, 9, , 10]);
|
||||
if (!(settings.sourceType === "default")) return [3 /*break*/, 3];
|
||||
return [4 /*yield*/, this.loadDefaultSource()];
|
||||
case 2:
|
||||
_c.sent();
|
||||
return [3 /*break*/, 8];
|
||||
case 3:
|
||||
if (!(settings.sourceType === "traffic")) return [3 /*break*/, 5];
|
||||
return [4 /*yield*/, this.loadTrafficCameras()];
|
||||
case 4:
|
||||
_c.sent();
|
||||
return [3 /*break*/, 8];
|
||||
case 5:
|
||||
if (!(settings.sourceType === "url")) return [3 /*break*/, 7];
|
||||
return [4 /*yield*/, this.loadUrlSource(settings)];
|
||||
case 6:
|
||||
_c.sent();
|
||||
return [3 /*break*/, 8];
|
||||
case 7:
|
||||
if (settings.sourceType === "file") {
|
||||
this.loadFileSource(settings);
|
||||
}
|
||||
_c.label = 8;
|
||||
case 8:
|
||||
(0, analytics_1.trackEvent)("camera-source-load", { sourceType: settings.sourceType });
|
||||
return [2 /*return*/, this.getAllEntities()];
|
||||
case 9:
|
||||
error_1 = _c.sent();
|
||||
console.error("[CameraPlugin] Fetch error:", error_1);
|
||||
(_b = this.context) === null || _b === void 0 ? void 0 : _b.onError(error_1 instanceof Error ? error_1 : new Error(String(error_1)));
|
||||
return [2 /*return*/, this.getAllEntities()];
|
||||
case 10: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
CameraPlugin.prototype.loadDefaultSource = function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var res, geojson;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, fetch("/public-cameras.json")];
|
||||
case 1:
|
||||
res = _a.sent();
|
||||
if (!res.ok) return [3 /*break*/, 3];
|
||||
return [4 /*yield*/, res.json()];
|
||||
case 2:
|
||||
geojson = _a.sent();
|
||||
if (geojson && Array.isArray(geojson.features)) {
|
||||
this.sourceBuckets["default"] = geojson.features.map(function (f, i) { return (0, cameraMapper_1.mapGeoJsonFeature)(f, i, "default"); });
|
||||
}
|
||||
_a.label = 3;
|
||||
case 3:
|
||||
this.pushUpdate();
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
CameraPlugin.prototype.loadTrafficCameras = function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var res, data, err_1;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
_a.trys.push([0, 3, , 4]);
|
||||
return [4 /*yield*/, fetch("/api/camera/traffic")];
|
||||
case 1:
|
||||
res = _a.sent();
|
||||
if (!res.ok)
|
||||
throw new Error("API returned ".concat(res.status));
|
||||
return [4 /*yield*/, res.json()];
|
||||
case 2:
|
||||
data = _a.sent();
|
||||
if (data.cameras && Array.isArray(data.cameras)) {
|
||||
this.sourceBuckets["default"] = data.cameras.map(function (f, i) { return (0, cameraMapper_1.mapGeoJsonFeature)(f, i, "traffic"); });
|
||||
}
|
||||
return [3 /*break*/, 4];
|
||||
case 3:
|
||||
err_1 = _a.sent();
|
||||
console.warn("[CameraPlugin] Traffic cameras API failed:", err_1);
|
||||
return [3 /*break*/, 4];
|
||||
case 4:
|
||||
this.pushUpdate();
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
CameraPlugin.prototype.loadUrlSource = function (settings) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var url, res, data;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
if (!settings.customUrl)
|
||||
return [2 /*return*/];
|
||||
url = settings.customUrl;
|
||||
if (!/^https?:\/\//i.test(url))
|
||||
url = "http://".concat(url);
|
||||
return [4 /*yield*/, fetch(url)];
|
||||
case 1:
|
||||
res = _a.sent();
|
||||
if (!res.ok) return [3 /*break*/, 3];
|
||||
return [4 /*yield*/, res.json()];
|
||||
case 2:
|
||||
data = _a.sent();
|
||||
if (Array.isArray(data)) {
|
||||
this.sourceBuckets["url"] = data.map(function (c, i) { return (0, cameraMapper_1.mapRawCamera)(c, i, "url"); });
|
||||
}
|
||||
_a.label = 3;
|
||||
case 3: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
CameraPlugin.prototype.loadFileSource = function (settings) {
|
||||
if (!settings.customData || !Array.isArray(settings.customData))
|
||||
return;
|
||||
this.sourceBuckets["file"] = settings.customData.map(function (c, i) { return (0, cameraMapper_1.mapRawCamera)(c, i, "file"); });
|
||||
};
|
||||
CameraPlugin.prototype.getPollingInterval = function () { return 3600000; };
|
||||
CameraPlugin.prototype.getLayerConfig = function () {
|
||||
return { color: "#60a5fa", clusterEnabled: true, clusterDistance: 50, maxEntities: 10000 };
|
||||
};
|
||||
CameraPlugin.prototype.renderEntity = function (entity) {
|
||||
return {
|
||||
type: "point", color: "#60a5fa", size: 6,
|
||||
outlineColor: "#ffffff", outlineWidth: 1.5,
|
||||
labelText: entity.label, labelFont: "11px Inter, system-ui, sans-serif",
|
||||
};
|
||||
};
|
||||
CameraPlugin.prototype.getDetailComponent = function () { return CameraDetail_1.CameraDetail; };
|
||||
CameraPlugin.prototype.getSettingsComponent = function () { return CameraSettings_1.CameraSettings; };
|
||||
CameraPlugin.prototype.getFilterDefinitions = function () {
|
||||
return [
|
||||
{ id: "country", label: "Country", type: "text", propertyKey: "country" },
|
||||
{ id: "city", label: "City", type: "text", propertyKey: "city" },
|
||||
{ id: "is_popular", label: "Popular Only", type: "boolean", propertyKey: "is_popular" },
|
||||
];
|
||||
};
|
||||
return CameraPlugin;
|
||||
}());
|
||||
exports.CameraPlugin = CameraPlugin;
|
||||
@@ -1,37 +0,0 @@
|
||||
{
|
||||
"name": "@worldwideview/wwv-plugin-camera",
|
||||
"version": "1.0.4",
|
||||
"description": "WorldWideView plugin for displaying public live cameras and traffic cameras on the globe. Supports custom data sources via URL, file upload, and GeoJSON",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
"files": [
|
||||
"src"
|
||||
],
|
||||
"keywords": [
|
||||
"worldwideview",
|
||||
"worldwideview-plugin",
|
||||
"wwv-plugin-camera",
|
||||
"camera",
|
||||
"live-camera",
|
||||
"traffic-camera",
|
||||
"cctv",
|
||||
"cesium",
|
||||
"globe"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/silvertakana/worldwideview.git",
|
||||
"directory": "packages/wwv-plugin-camera"
|
||||
},
|
||||
"homepage": "https://github.com/silvertakana/worldwideview#readme",
|
||||
"bugs": {
|
||||
"url": "https://github.com/silvertakana/worldwideview/issues"
|
||||
},
|
||||
"license": "ISC",
|
||||
"author": "WorldWideView",
|
||||
"peerDependencies": {
|
||||
"@worldwideview/wwv-plugin-sdk": "*",
|
||||
"react": ">=18",
|
||||
"lucide-react": ">=0.576.0"
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import { ExternalLink, MapPin, Tag } from "lucide-react";
|
||||
import type { GeoEntity } from "@worldwideview/wwv-plugin-sdk";
|
||||
import { CameraStream } from "@/components/video/CameraStream";
|
||||
|
||||
interface CameraDetailProps { entity: GeoEntity; }
|
||||
|
||||
export const CameraDetail: React.FC<CameraDetailProps> = ({ entity }) => {
|
||||
const { properties } = entity;
|
||||
const stream = properties.stream as string;
|
||||
const previewUrl = properties.preview_url as string;
|
||||
const city = properties.city as string;
|
||||
const region = properties.region as string;
|
||||
const country = properties.country as string;
|
||||
const isIframe = !!properties.is_iframe;
|
||||
const categories = (properties.categories as string[]) || [];
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-4">
|
||||
<CameraStream id={entity.id} streamUrl={stream} previewUrl={previewUrl} isIframe={isIframe} label={city || country} />
|
||||
<div className="intel-panel__props">
|
||||
<div className="intel-panel__prop" style={{ flexDirection: "column", alignItems: "flex-start", gap: "var(--space-xs)", borderBottom: "1px solid var(--border-subtle)", padding: "var(--space-sm) 0" }}>
|
||||
<span className="intel-panel__prop-key">Location</span>
|
||||
<span className="intel-panel__prop-value" style={{ textAlign: "left", width: "100%", whiteSpace: "normal", lineHeight: "1.4", fontSize: "12px", color: "var(--text-primary)" }}>
|
||||
{[city, region, country].filter(Boolean).join(", ")}
|
||||
</span>
|
||||
</div>
|
||||
{categories.length > 0 && (
|
||||
<div className="intel-panel__prop" style={{ flexDirection: "column", alignItems: "flex-start", gap: "var(--space-sm)", borderBottom: "none", padding: "var(--space-sm) 0" }}>
|
||||
<span className="intel-panel__prop-key">Categories</span>
|
||||
<div style={{ display: "flex", flexWrap: "wrap", gap: "6px" }}>
|
||||
{categories.map((cat) => (
|
||||
<span key={cat} style={{ borderRadius: "12px", backgroundColor: "var(--bg-tertiary)", padding: "2px 8px", fontSize: "10px", fontWeight: 500, color: "var(--text-secondary)", border: "1px solid var(--border-subtle)" }}>
|
||||
{cat}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -1,106 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import React, { ChangeEvent } from "react";
|
||||
import { useStore } from "@/core/state/store";
|
||||
import { Upload, Link as LinkIcon, Database, RotateCcw, TrafficCone } from "lucide-react";
|
||||
import { pluginManager } from "@/core/plugins/PluginManager";
|
||||
import { inputGroupStyle, labelStyle, inputStyle, loadButtonStyle, sourceTabStyle } from "./cameraSettingsStyles";
|
||||
|
||||
type SourceType = "default" | "traffic" | "url" | "file";
|
||||
|
||||
export const CameraSettings: React.FC<{ pluginId: string }> = ({ pluginId }) => {
|
||||
const settingsRaw = useStore((s) => s.dataConfig.pluginSettings[pluginId]);
|
||||
const settings = { sourceType: "default" as SourceType, ...(settingsRaw || {}) };
|
||||
const updatePluginSettings = useStore((s) => s.updatePluginSettings);
|
||||
const setHighlightLayerId = useStore((s) => s.setHighlightLayerId);
|
||||
const [isLoading, setIsLoading] = React.useState(false);
|
||||
|
||||
const handleSourceTypeChange = (type: SourceType) => {
|
||||
updatePluginSettings(pluginId, { sourceType: type });
|
||||
setHighlightLayerId(null);
|
||||
};
|
||||
|
||||
const triggerFetch = async () => {
|
||||
const managed = pluginManager.getPlugin(pluginId);
|
||||
if (managed && managed.enabled) {
|
||||
await pluginManager.fetchForPlugin(pluginId, managed.context.timeRange);
|
||||
}
|
||||
};
|
||||
|
||||
const handleLoadData = async () => {
|
||||
setIsLoading(true);
|
||||
updatePluginSettings(pluginId, { action: "load", actionId: Date.now(), loaded: true });
|
||||
setHighlightLayerId(null);
|
||||
await triggerFetch();
|
||||
setIsLoading(false);
|
||||
};
|
||||
|
||||
const handleResetAll = async () => {
|
||||
updatePluginSettings(pluginId, { action: "reset", actionId: Date.now(), loaded: false, customUrl: "", customData: null });
|
||||
setHighlightLayerId(null);
|
||||
await triggerFetch();
|
||||
};
|
||||
|
||||
const handleFileUpload = (e: ChangeEvent<HTMLInputElement>) => {
|
||||
const file = e.target.files?.[0];
|
||||
if (!file) return;
|
||||
const reader = new FileReader();
|
||||
reader.onload = async (event) => {
|
||||
try {
|
||||
const json = JSON.parse(event.target?.result as string);
|
||||
updatePluginSettings(pluginId, { customData: json, action: "load", actionId: Date.now(), loaded: true });
|
||||
setHighlightLayerId(null);
|
||||
await triggerFetch();
|
||||
} catch { alert("Invalid JSON file format."); }
|
||||
};
|
||||
reader.readAsText(file);
|
||||
};
|
||||
|
||||
return (
|
||||
<div style={{ display: "flex", flexDirection: "column", gap: "var(--space-md)" }}>
|
||||
<div style={{ fontSize: 11, color: "var(--text-muted)", marginBottom: "var(--space-xs)" }}>Data Source Configuration</div>
|
||||
<div style={{ display: "flex", gap: "var(--space-xs)" }}>
|
||||
{([["default", Database, "Default"], ["traffic", TrafficCone, "Traffic Cams"], ["url", LinkIcon, "URL"], ["file", Upload, "File"]] as const).map(
|
||||
([type, Icon, label]) => (
|
||||
<button key={type} onClick={() => handleSourceTypeChange(type)} style={sourceTabStyle(settings.sourceType === type)}>
|
||||
<Icon size={14} /><span style={{ fontSize: 10 }}>{label}</span>
|
||||
</button>
|
||||
)
|
||||
)}
|
||||
</div>
|
||||
{settings.sourceType === "default" && (
|
||||
<div style={inputGroupStyle}>
|
||||
<div style={{ fontSize: 11, color: "var(--text-secondary)" }}>Built-in camera dataset</div>
|
||||
<button onClick={handleLoadData} disabled={isLoading} style={loadButtonStyle(isLoading)}>{isLoading ? "Loading..." : settings.loaded ? "Reload" : "Load"}</button>
|
||||
</div>
|
||||
)}
|
||||
{settings.sourceType === "traffic" && (
|
||||
<div style={inputGroupStyle}>
|
||||
<div style={{ fontSize: 11, color: "var(--text-secondary)" }}>DOT traffic cameras (GDOT + more)</div>
|
||||
<button onClick={handleLoadData} disabled={isLoading} style={loadButtonStyle(isLoading)}>{isLoading ? "Loading..." : settings.loaded ? "Reload" : "Load"}</button>
|
||||
</div>
|
||||
)}
|
||||
{settings.sourceType === "url" && (
|
||||
<div style={inputGroupStyle}>
|
||||
<label style={labelStyle}>URL</label>
|
||||
<div style={{ display: "flex", gap: "var(--space-sm)", marginTop: "4px" }}>
|
||||
<input type="text" placeholder="http://..." value={(settings.customUrl as string) || ""} onChange={(e) => updatePluginSettings(pluginId, { customUrl: e.target.value })} style={{ ...inputStyle, flex: 1 }} />
|
||||
<button onClick={handleLoadData} disabled={!settings.customUrl || isLoading} style={loadButtonStyle(!settings.customUrl || isLoading)}>{isLoading ? "Loading..." : "Load"}</button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{settings.sourceType === "file" && (
|
||||
<div style={inputGroupStyle}>
|
||||
<label style={labelStyle}>JSON File</label>
|
||||
<input type="file" accept=".json" onChange={handleFileUpload} style={{ ...inputStyle, width: "100%", marginTop: "4px", padding: "4px", fontSize: "10px" }} />
|
||||
{settings.customData && Array.isArray(settings.customData) && (
|
||||
<div style={{ fontSize: 10, color: "var(--accent-green)", marginTop: "4px" }}>✓ Data loaded ({(settings.customData as unknown[]).length} cameras)</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
<button onClick={handleResetAll} style={{ display: "flex", alignItems: "center", justifyContent: "center", gap: "6px", background: "transparent", border: "1px solid var(--border-subtle)", borderRadius: "var(--radius-sm)", padding: "6px var(--space-md)", fontSize: 11, color: "var(--text-muted)", cursor: "pointer", transition: "all 0.2s ease" }}>
|
||||
<RotateCcw size={12} /> Reset All Sources
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -1,32 +0,0 @@
|
||||
import type { GeoEntity } from "@worldwideview/wwv-plugin-sdk";
|
||||
|
||||
const DEFAULT_CAMERA_ALT = 8;
|
||||
|
||||
export function mapRawCamera(cam: Record<string, unknown>, index: number, prefix: string): GeoEntity {
|
||||
return {
|
||||
id: `camera-${prefix}-${index}`,
|
||||
pluginId: "camera",
|
||||
latitude: cam.latitude as number,
|
||||
longitude: cam.longitude as number,
|
||||
altitude: (cam.altitude as number) ?? (cam.elevation as number) ?? DEFAULT_CAMERA_ALT,
|
||||
timestamp: new Date(),
|
||||
label: (cam.city as string) || (cam.country as string) || "Unknown Camera",
|
||||
properties: { ...cam },
|
||||
};
|
||||
}
|
||||
|
||||
export function mapGeoJsonFeature(feature: unknown, index: number, prefix: string): GeoEntity {
|
||||
const f = feature as { geometry?: { coordinates?: number[] }; properties?: Record<string, unknown> };
|
||||
const [lon, lat] = f.geometry?.coordinates ?? [0, 0];
|
||||
const props = f.properties ?? {};
|
||||
return {
|
||||
id: `camera-${prefix}-${index}`,
|
||||
pluginId: "camera",
|
||||
latitude: lat,
|
||||
longitude: lon,
|
||||
altitude: DEFAULT_CAMERA_ALT,
|
||||
timestamp: new Date(),
|
||||
label: (props.city as string) || (props.country as string) || "Unknown Camera",
|
||||
properties: { ...props },
|
||||
};
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import type React from "react";
|
||||
|
||||
export const inputGroupStyle: React.CSSProperties = { display: "flex", flexDirection: "column", gap: "4px" };
|
||||
export const labelStyle: React.CSSProperties = { fontSize: 10, fontWeight: 600, color: "var(--text-muted)", textTransform: "uppercase", letterSpacing: "0.05em" };
|
||||
export const inputStyle: React.CSSProperties = { background: "var(--bg-tertiary)", border: "1px solid var(--border-subtle)", color: "var(--text-primary)", padding: "var(--space-xs) var(--space-sm)", borderRadius: "var(--radius-sm)", fontSize: 12, outline: "none" };
|
||||
export const loadButtonStyle = (disabled: boolean): React.CSSProperties => ({ background: "var(--accent-cyan)", color: "var(--bg-primary)", border: "none", borderRadius: "var(--radius-sm)", padding: "0 var(--space-md)", fontSize: 12, fontWeight: 500, cursor: disabled ? "not-allowed" : "pointer", opacity: disabled ? 0.5 : 1, transition: "all 0.2s ease" });
|
||||
export const sourceTabStyle = (active: boolean): React.CSSProperties => ({ flex: 1, display: "flex", flexDirection: "column", alignItems: "center", gap: "4px", padding: "8px", borderRadius: "var(--radius-md)", background: active ? "var(--accent-cyan-subtle)" : "var(--bg-tertiary)", border: active ? "1px solid var(--accent-cyan)" : "1px solid var(--border-subtle)", cursor: "pointer", color: active ? "var(--accent-cyan)" : "var(--text-secondary)", transition: "all 0.2s ease" });
|
||||
@@ -1,128 +0,0 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import {
|
||||
computeFrustumEdges,
|
||||
cardinalToHeading,
|
||||
FRUSTUM_DEFAULTS,
|
||||
type FrustumParams,
|
||||
} from "./frustumGeometry";
|
||||
|
||||
// ─── computeFrustumEdges ─────────────────────────────────────
|
||||
|
||||
describe("computeFrustumEdges", () => {
|
||||
const baseParams: FrustumParams = {
|
||||
lat: 40.0,
|
||||
lon: -83.0,
|
||||
alt: 8,
|
||||
headingDeg: 0,
|
||||
pitchDeg: 0,
|
||||
hFovDeg: 50,
|
||||
vFovDeg: 35,
|
||||
rangeMtrs: 200,
|
||||
};
|
||||
|
||||
it("returns apex at the camera position", () => {
|
||||
const edges = computeFrustumEdges(baseParams);
|
||||
expect(edges.apex.lat).toBe(40.0);
|
||||
expect(edges.apex.lon).toBe(-83.0);
|
||||
expect(edges.apex.alt).toBe(8);
|
||||
});
|
||||
|
||||
it("produces 4 distinct corner points", () => {
|
||||
const edges = computeFrustumEdges(baseParams);
|
||||
const corners = [edges.topLeft, edges.topRight, edges.bottomLeft, edges.bottomRight];
|
||||
|
||||
// All corners should differ from each other
|
||||
for (let i = 0; i < corners.length; i++) {
|
||||
for (let j = i + 1; j < corners.length; j++) {
|
||||
const same = corners[i].lat === corners[j].lat
|
||||
&& corners[i].lon === corners[j].lon
|
||||
&& corners[i].alt === corners[j].alt;
|
||||
expect(same).toBe(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it("corners are roughly at the expected range from apex", () => {
|
||||
const edges = computeFrustumEdges(baseParams);
|
||||
const corners = [edges.topLeft, edges.topRight, edges.bottomLeft, edges.bottomRight];
|
||||
|
||||
for (const c of corners) {
|
||||
const dLat = (c.lat - edges.apex.lat) * 111_320;
|
||||
const dLon = (c.lon - edges.apex.lon) * 111_320 * Math.cos(edges.apex.lat * Math.PI / 180);
|
||||
const dAlt = c.alt - edges.apex.alt;
|
||||
const dist = Math.sqrt(dLat * dLat + dLon * dLon + dAlt * dAlt);
|
||||
// Should be close to 200m (within 10% tolerance for spherical approx)
|
||||
expect(dist).toBeGreaterThan(150);
|
||||
expect(dist).toBeLessThan(250);
|
||||
}
|
||||
});
|
||||
|
||||
it("heading north means corners are north of the apex", () => {
|
||||
const edges = computeFrustumEdges({ ...baseParams, headingDeg: 0, pitchDeg: 0 });
|
||||
const corners = [edges.topLeft, edges.topRight, edges.bottomLeft, edges.bottomRight];
|
||||
for (const c of corners) {
|
||||
expect(c.lat).toBeGreaterThan(edges.apex.lat);
|
||||
}
|
||||
});
|
||||
|
||||
it("heading south means corners are south of the apex", () => {
|
||||
const edges = computeFrustumEdges({ ...baseParams, headingDeg: 180, pitchDeg: 0 });
|
||||
const corners = [edges.topLeft, edges.topRight, edges.bottomLeft, edges.bottomRight];
|
||||
for (const c of corners) {
|
||||
expect(c.lat).toBeLessThan(edges.apex.lat);
|
||||
}
|
||||
});
|
||||
|
||||
it("left corners are to the left of right corners (heading north)", () => {
|
||||
const edges = computeFrustumEdges({ ...baseParams, headingDeg: 0, pitchDeg: 0 });
|
||||
// Heading north: left = west (smaller lon), right = east (larger lon)
|
||||
expect(edges.topLeft.lon).toBeLessThan(edges.topRight.lon);
|
||||
expect(edges.bottomLeft.lon).toBeLessThan(edges.bottomRight.lon);
|
||||
});
|
||||
|
||||
it("zero range produces corners at the apex", () => {
|
||||
const edges = computeFrustumEdges({ ...baseParams, rangeMtrs: 0 });
|
||||
const corners = [edges.topLeft, edges.topRight, edges.bottomLeft, edges.bottomRight];
|
||||
for (const c of corners) {
|
||||
expect(c.lat).toBeCloseTo(edges.apex.lat, 6);
|
||||
expect(c.lon).toBeCloseTo(edges.apex.lon, 6);
|
||||
}
|
||||
});
|
||||
|
||||
it("corner altitudes clamp to 0 when pitch is steep enough", () => {
|
||||
const edges = computeFrustumEdges({ ...baseParams, pitchDeg: -80, alt: 5 });
|
||||
const corners = [edges.topLeft, edges.topRight, edges.bottomLeft, edges.bottomRight];
|
||||
for (const c of corners) {
|
||||
expect(c.alt).toBeGreaterThanOrEqual(0);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// ─── cardinalToHeading ───────────────────────────────────────
|
||||
|
||||
describe("cardinalToHeading", () => {
|
||||
it("parses cardinal directions", () => {
|
||||
expect(cardinalToHeading("N")).toBe(0);
|
||||
expect(cardinalToHeading("E")).toBe(90);
|
||||
expect(cardinalToHeading("S")).toBe(180);
|
||||
expect(cardinalToHeading("W")).toBe(270);
|
||||
});
|
||||
|
||||
it("parses abbreviations", () => {
|
||||
expect(cardinalToHeading("NB")).toBe(0);
|
||||
expect(cardinalToHeading("EB")).toBe(90);
|
||||
expect(cardinalToHeading("SB")).toBe(180);
|
||||
expect(cardinalToHeading("WB")).toBe(270);
|
||||
});
|
||||
|
||||
it("parses full names case-insensitively", () => {
|
||||
expect(cardinalToHeading("Northbound")).toBe(0);
|
||||
expect(cardinalToHeading("SOUTHEAST")).toBe(135);
|
||||
expect(cardinalToHeading(" west ")).toBe(270);
|
||||
});
|
||||
|
||||
it("returns undefined for unknown strings", () => {
|
||||
expect(cardinalToHeading("foo")).toBeUndefined();
|
||||
expect(cardinalToHeading("")).toBeUndefined();
|
||||
});
|
||||
});
|
||||
@@ -1,161 +0,0 @@
|
||||
import { Camera } from "lucide-react";
|
||||
import type {
|
||||
WorldPlugin, GeoEntity, TimeRange, PluginContext,
|
||||
LayerConfig, CesiumEntityOptions, FilterDefinition,
|
||||
} from "@worldwideview/wwv-plugin-sdk";
|
||||
import { CameraDetail } from "./CameraDetail";
|
||||
import { CameraSettings as CameraSettingsComponent } from "./CameraSettings";
|
||||
import { mapRawCamera, mapGeoJsonFeature } from "./cameraMapper";
|
||||
import { trackEvent } from "@/lib/analytics";
|
||||
|
||||
type CameraSettings = {
|
||||
sourceType: "default" | "traffic" | "url" | "file";
|
||||
action?: string;
|
||||
actionId?: number;
|
||||
loaded?: boolean;
|
||||
customUrl?: string;
|
||||
customData?: unknown[] | null;
|
||||
};
|
||||
|
||||
export class CameraPlugin implements WorldPlugin {
|
||||
id = "camera";
|
||||
name = "Cameras";
|
||||
description = "Public live cameras from across the globe";
|
||||
icon = Camera;
|
||||
category = "infrastructure" as const;
|
||||
version = "1.0.0";
|
||||
private context: PluginContext | null = null;
|
||||
private sourceBuckets: Record<string, GeoEntity[]> = {};
|
||||
private lastActionId: number | null = null;
|
||||
|
||||
async initialize(ctx: PluginContext): Promise<void> { this.context = ctx; }
|
||||
destroy(): void { this.context = null; }
|
||||
|
||||
requiresConfiguration(settingsRaw: unknown): boolean {
|
||||
const s = settingsRaw as { sourceType?: string; customUrl?: string; customData?: unknown } | null;
|
||||
const sourceType = s?.sourceType ?? "default";
|
||||
if (sourceType === "default" || sourceType === "traffic") return false;
|
||||
if (sourceType === "url" && !s?.customUrl) return true;
|
||||
if (sourceType === "file" && !s?.customData) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
private getAllEntities(): GeoEntity[] { return Object.values(this.sourceBuckets).flat(); }
|
||||
private pushUpdate(): void { this.context?.onDataUpdate(this.getAllEntities()); }
|
||||
|
||||
async fetch(_timeRange: TimeRange): Promise<GeoEntity[]> {
|
||||
// Use context instead of direct useStore access
|
||||
const rawSettings = this.context!.getPluginSettings<Record<string, unknown>>(this.id);
|
||||
const settings = {
|
||||
sourceType: "default" as "default" | "traffic" | "url" | "file",
|
||||
action: undefined as string | undefined,
|
||||
actionId: undefined as number | undefined,
|
||||
loaded: undefined as boolean | undefined,
|
||||
customUrl: undefined as string | undefined,
|
||||
customData: undefined as unknown[] | null | undefined,
|
||||
...((rawSettings as Record<string, unknown>) || {}),
|
||||
};
|
||||
|
||||
if (settings.action === "reset") {
|
||||
this.sourceBuckets = {};
|
||||
this.lastActionId = settings.actionId as number;
|
||||
return [];
|
||||
}
|
||||
|
||||
const isAutoDefault = (settings.sourceType === "default" || settings.sourceType === "traffic")
|
||||
&& !this.lastActionId && !this.sourceBuckets["default"];
|
||||
if (!isAutoDefault && (settings.action !== "load" || settings.actionId === this.lastActionId)) {
|
||||
return this.getAllEntities();
|
||||
}
|
||||
this.lastActionId = (settings.actionId as number) ?? -1;
|
||||
|
||||
try {
|
||||
if (settings.sourceType === "default") {
|
||||
await this.loadDefaultSource();
|
||||
} else if (settings.sourceType === "traffic") {
|
||||
await this.loadTrafficCameras();
|
||||
} else if (settings.sourceType === "url") {
|
||||
await this.loadUrlSource(settings);
|
||||
} else if (settings.sourceType === "file") {
|
||||
this.loadFileSource(settings);
|
||||
}
|
||||
trackEvent("camera-source-load", { sourceType: settings.sourceType });
|
||||
return this.getAllEntities();
|
||||
} catch (error) {
|
||||
console.error("[CameraPlugin] Fetch error:", error);
|
||||
this.context?.onError(error instanceof Error ? error : new Error(String(error)));
|
||||
return this.getAllEntities();
|
||||
}
|
||||
}
|
||||
|
||||
private async loadDefaultSource(): Promise<void> {
|
||||
const res = await fetch("/public-cameras.json");
|
||||
if (res.ok) {
|
||||
const geojson = await res.json();
|
||||
if (geojson && Array.isArray(geojson.features)) {
|
||||
this.sourceBuckets["default"] = geojson.features.map(
|
||||
(f: unknown, i: number) => mapGeoJsonFeature(f, i, "default"),
|
||||
);
|
||||
}
|
||||
}
|
||||
this.pushUpdate();
|
||||
}
|
||||
|
||||
private async loadTrafficCameras(): Promise<void> {
|
||||
try {
|
||||
const res = await fetch("/api/camera/traffic");
|
||||
if (!res.ok) throw new Error(`API returned ${res.status}`);
|
||||
const data = await res.json();
|
||||
if (data.cameras && Array.isArray(data.cameras)) {
|
||||
this.sourceBuckets["default"] = data.cameras.map(
|
||||
(f: unknown, i: number) => mapGeoJsonFeature(f, i, "traffic"),
|
||||
);
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn("[CameraPlugin] Traffic cameras API failed:", err);
|
||||
}
|
||||
this.pushUpdate();
|
||||
}
|
||||
|
||||
private async loadUrlSource(settings: Record<string, unknown>): Promise<void> {
|
||||
if (!settings.customUrl) return;
|
||||
let url = settings.customUrl as string;
|
||||
if (!/^https?:\/\//i.test(url)) url = `http://${url}`;
|
||||
const res = await fetch(url);
|
||||
if (res.ok) {
|
||||
const data = await res.json();
|
||||
if (Array.isArray(data)) {
|
||||
this.sourceBuckets["url"] = data.map((c, i) => mapRawCamera(c, i, "url"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private loadFileSource(settings: Record<string, unknown>): void {
|
||||
if (!settings.customData || !Array.isArray(settings.customData)) return;
|
||||
this.sourceBuckets["file"] = settings.customData.map((c: unknown, i: number) => mapRawCamera(c as Record<string, unknown>, i, "file"));
|
||||
}
|
||||
|
||||
getPollingInterval(): number { return 3600000; }
|
||||
getLayerConfig(): LayerConfig {
|
||||
return { color: "#60a5fa", clusterEnabled: true, clusterDistance: 50, maxEntities: 10000 };
|
||||
}
|
||||
|
||||
renderEntity(entity: GeoEntity): CesiumEntityOptions {
|
||||
return {
|
||||
type: "point", color: "#60a5fa", size: 6,
|
||||
outlineColor: "#ffffff", outlineWidth: 1.5,
|
||||
labelText: entity.label, labelFont: "11px Inter, system-ui, sans-serif",
|
||||
};
|
||||
}
|
||||
|
||||
getDetailComponent() { return CameraDetail; }
|
||||
getSettingsComponent() { return CameraSettingsComponent; }
|
||||
|
||||
getFilterDefinitions(): FilterDefinition[] {
|
||||
return [
|
||||
{ id: "country", label: "Country", type: "text", propertyKey: "country" },
|
||||
{ id: "city", label: "City", type: "text", propertyKey: "city" },
|
||||
{ id: "is_popular", label: "Popular Only", type: "boolean", propertyKey: "is_popular" },
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"outDir": "dist",
|
||||
"noEmit": false
|
||||
},
|
||||
"exclude": ["**/*.test.*"]
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "src",
|
||||
"noEmit": true
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
# @worldwideview/wwv-plugin-embassies
|
||||
|
||||
WorldWideView plugin — **Embassies & Consulates**.
|
||||
|
||||
## Data Source
|
||||
|
||||
- **Source:** OpenStreetMap via [Overpass Turbo](https://overpass-turbo.eu/)
|
||||
- **Tag:** `amenity=embassy`
|
||||
- **Format:** Static GeoJSON (17,266 features)
|
||||
- **License:** [ODbL](https://opendatacommons.org/licenses/odbl/) (OpenStreetMap)
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install @worldwideview/wwv-plugin-embassies
|
||||
```
|
||||
|
||||
## Peer Dependencies
|
||||
|
||||
- `@worldwideview/wwv-plugin-sdk`
|
||||
|
||||
## Changelog
|
||||
|
||||
- **v1.0.0** — Initial release with global diplomatic mission data from OSM.
|
||||
|
||||
## License
|
||||
|
||||
ISC
|
||||
@@ -1,30 +0,0 @@
|
||||
{
|
||||
"name": "@worldwideview/wwv-plugin-embassies",
|
||||
"version": "1.0.1",
|
||||
"description": "WorldWideView plugin — Global embassies, consulates, and diplomatic missions from OpenStreetMap",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
"files": [
|
||||
"src"
|
||||
],
|
||||
"keywords": [
|
||||
"worldwideview",
|
||||
"worldwideview-plugin",
|
||||
"wwv-plugin-embassies",
|
||||
"embassies"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/silvertakana/worldwideview.git",
|
||||
"directory": "packages/wwv-plugin-embassies"
|
||||
},
|
||||
"homepage": "https://github.com/silvertakana/worldwideview#readme",
|
||||
"bugs": {
|
||||
"url": "https://github.com/silvertakana/worldwideview/issues"
|
||||
},
|
||||
"license": "ISC",
|
||||
"author": "WorldWideView",
|
||||
"peerDependencies": {
|
||||
"@worldwideview/wwv-plugin-sdk": "*"
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
import { Landmark } from "lucide-react";
|
||||
import type {
|
||||
WorldPlugin, GeoEntity, TimeRange, PluginContext,
|
||||
LayerConfig, CesiumEntityOptions,
|
||||
} from "@worldwideview/wwv-plugin-sdk";
|
||||
|
||||
export class EmbassiesConsulatesPlugin implements WorldPlugin {
|
||||
id = "embassies";
|
||||
name = "Embassies & Consulates";
|
||||
description = "Global embassies, consulates, and diplomatic missions from OpenStreetMap";
|
||||
icon = Landmark;
|
||||
category = "custom" as const;
|
||||
version = "1.0.0";
|
||||
|
||||
async initialize(_ctx: PluginContext): Promise<void> { }
|
||||
destroy(): void { }
|
||||
async fetch(_tr: TimeRange): Promise<GeoEntity[]> { return []; }
|
||||
getPollingInterval(): number { return 0; }
|
||||
|
||||
getLayerConfig(): LayerConfig {
|
||||
return {
|
||||
color: "#a855f7",
|
||||
clusterEnabled: true,
|
||||
clusterDistance: 50,
|
||||
maxEntities: 1000,
|
||||
};
|
||||
}
|
||||
|
||||
renderEntity(_e: GeoEntity): CesiumEntityOptions {
|
||||
return { type: "point", color: "#a855f7", size: 8 };
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
# @worldwideview/wwv-plugin-maritime
|
||||
|
||||
[WorldWideView](https://github.com/silvertakana/worldwideview) plugin for **real-time vessel tracking** via AIS (Automatic Identification System) feeds.
|
||||
|
||||
## Features
|
||||
|
||||
- 🚢 Live vessel positions with heading and speed indicators
|
||||
- 🎨 Color-coded by vessel type (cargo, tanker, passenger, fishing, military, sailing, tug)
|
||||
- 🔍 Filters: vessel type, speed range
|
||||
- 📍 Clustered point rendering with vessel name labels
|
||||
- 🔄 Demo mode with realistic sample vessels when API is unavailable
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install @worldwideview/wwv-plugin-maritime
|
||||
```
|
||||
|
||||
### Peer Dependencies
|
||||
|
||||
- `@worldwideview/wwv-plugin-sdk`
|
||||
- `lucide-react` ≥ 0.576.0
|
||||
|
||||
## Usage
|
||||
|
||||
```ts
|
||||
import { MaritimePlugin } from "@worldwideview/wwv-plugin-maritime";
|
||||
|
||||
const plugin = new MaritimePlugin();
|
||||
```
|
||||
|
||||
Register the plugin with the WorldWideView plugin engine to start tracking vessels on the globe.
|
||||
|
||||
## Data Source
|
||||
|
||||
Vessel data is fetched from the `/api/maritime` endpoint. Falls back to demo data with 15 sample vessels when the API is unavailable.
|
||||
|
||||
## Vessel Colors
|
||||
|
||||
| Type | Color |
|
||||
|---|---|
|
||||
| Cargo | 🟡 `#f59e0b` |
|
||||
| Tanker | 🔴 `#ef4444` |
|
||||
| Passenger | 🔵 `#3b82f6` |
|
||||
| Fishing | 🔵 `#22d3ee` |
|
||||
| Military | 🟣 `#a78bfa` |
|
||||
| Sailing | 🟢 `#4ade80` |
|
||||
| Tug | 🟠 `#f97316` |
|
||||
|
||||
## Changelog
|
||||
|
||||
- **v1.0.3** — Added README with feature list and usage docs.
|
||||
- **v1.0.2** — Package metadata updates.
|
||||
- **v1.0.1** — Package configuration fixes.
|
||||
- **v1.0.0** — Initial release with AIS-based vessel tracking and ship-type filtering.
|
||||
|
||||
## License
|
||||
|
||||
ISC
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
import type { WorldPlugin, GeoEntity, TimeRange, PluginContext, LayerConfig, CesiumEntityOptions, FilterDefinition } from "@worldwideview/wwv-plugin-sdk";
|
||||
export declare class MaritimePlugin implements WorldPlugin {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
icon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
||||
category: "maritime";
|
||||
version: string;
|
||||
private context;
|
||||
initialize(ctx: PluginContext): Promise<void>;
|
||||
destroy(): void;
|
||||
fetch(_timeRange: TimeRange): Promise<GeoEntity[]>;
|
||||
getPollingInterval(): number;
|
||||
getLayerConfig(): LayerConfig;
|
||||
renderEntity(entity: GeoEntity): CesiumEntityOptions;
|
||||
getFilterDefinitions(): FilterDefinition[];
|
||||
}
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACR,WAAW,EACX,SAAS,EACT,SAAS,EACT,aAAa,EACb,WAAW,EACX,mBAAmB,EACnB,gBAAgB,EACnB,MAAM,+BAA+B,CAAC;AAqDvC,qBAAa,cAAe,YAAW,WAAW;IAC9C,EAAE,SAAc;IAChB,IAAI,SAAc;IAClB,WAAW,SAAmC;IAC9C,IAAI,4IAAQ;IACZ,QAAQ,EAAG,UAAU,CAAU;IAC/B,OAAO,SAAW;IAClB,OAAO,CAAC,OAAO,CAA8B;IAEvC,UAAU,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IACnD,OAAO,IAAI,IAAI;IAET,KAAK,CAAC,UAAU,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAYxD,kBAAkB,IAAI,MAAM;IAE5B,cAAc,IAAI,WAAW;IAI7B,YAAY,CAAC,MAAM,EAAE,SAAS,GAAG,mBAAmB;IASpD,oBAAoB,IAAI,gBAAgB,EAAE;CAc7C"}
|
||||
-171
@@ -1,171 +0,0 @@
|
||||
"use strict";
|
||||
var __assign = (this && this.__assign) || function () {
|
||||
__assign = Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
||||
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.MaritimePlugin = void 0;
|
||||
var lucide_react_1 = require("lucide-react");
|
||||
var VESSEL_COLORS = {
|
||||
cargo: "#f59e0b",
|
||||
tanker: "#ef4444",
|
||||
passenger: "#3b82f6",
|
||||
fishing: "#22d3ee",
|
||||
military: "#a78bfa",
|
||||
sailing: "#4ade80",
|
||||
tug: "#f97316",
|
||||
other: "#94a3b8",
|
||||
};
|
||||
function getVesselColor(type) {
|
||||
var lower = type.toLowerCase();
|
||||
for (var _i = 0, _a = Object.entries(VESSEL_COLORS); _i < _a.length; _i++) {
|
||||
var _b = _a[_i], key = _b[0], color = _b[1];
|
||||
if (lower.includes(key))
|
||||
return color;
|
||||
}
|
||||
return VESSEL_COLORS.other;
|
||||
}
|
||||
function generateDemoVessels() {
|
||||
var vessels = [
|
||||
{ name: "EVER GIVEN", mmsi: "353136000", type: "cargo", lat: 30.0, lon: 32.5, speed: 12.5, heading: 340 },
|
||||
{ name: "MAERSK SEALAND", mmsi: "220417000", type: "cargo", lat: 51.9, lon: 1.2, speed: 15.0, heading: 210 },
|
||||
{ name: "PACIFIC RUBY", mmsi: "538004561", type: "tanker", lat: 1.2, lon: 103.7, speed: 8.3, heading: 125 },
|
||||
{ name: "QUEEN MARY 2", mmsi: "310627000", type: "passenger", lat: 40.6, lon: -74.0, speed: 22.0, heading: 90 },
|
||||
{ name: "OCEAN EXPLORER", mmsi: "245390000", type: "fishing", lat: -33.8, lon: 18.4, speed: 4.2, heading: 180 },
|
||||
{ name: "ARCTIC SUNRISE", mmsi: "246585000", type: "other", lat: 69.0, lon: 18.0, speed: 6.0, heading: 45 },
|
||||
{ name: "BLUE MARLIN", mmsi: "244870698", type: "cargo", lat: 22.3, lon: 113.9, speed: 10.5, heading: 270 },
|
||||
{ name: "STENA BULK", mmsi: "265548750", type: "tanker", lat: 57.7, lon: 11.9, speed: 12.0, heading: 300 },
|
||||
{ name: "SPIRIT OF BRITAIN", mmsi: "235082198", type: "passenger", lat: 50.9, lon: 1.4, speed: 20.0, heading: 160 },
|
||||
{ name: "DEEP BLUE", mmsi: "538006050", type: "fishing", lat: -4.0, lon: 39.6, speed: 3.5, heading: 95 },
|
||||
{ name: "CRIMSON ACE", mmsi: "477558200", type: "tanker", lat: 26.2, lon: 56.3, speed: 14.0, heading: 200 },
|
||||
{ name: "SAGA HORIZON", mmsi: "311000596", type: "passenger", lat: 35.3, lon: 139.6, speed: 18.0, heading: 0 },
|
||||
{ name: "ATLANTIC GUARDIAN", mmsi: "219354000", type: "tug", lat: 56.1, lon: -3.2, speed: 7.5, heading: 245 },
|
||||
{ name: "JADE STAR", mmsi: "636092783", type: "cargo", lat: -12.0, lon: -77.0, speed: 11.0, heading: 320 },
|
||||
{ name: "NORTHERN SPIRIT", mmsi: "257038700", type: "fishing", lat: 62.4, lon: 6.1, speed: 5.0, heading: 170 },
|
||||
];
|
||||
return vessels.map(function (v) { return ({
|
||||
id: "maritime-".concat(v.mmsi),
|
||||
pluginId: "maritime",
|
||||
latitude: v.lat + (Math.random() - 0.5) * 0.1,
|
||||
longitude: v.lon + (Math.random() - 0.5) * 0.1,
|
||||
heading: v.heading,
|
||||
speed: v.speed,
|
||||
timestamp: new Date(),
|
||||
label: v.name,
|
||||
properties: { mmsi: v.mmsi, vesselName: v.name, vesselType: v.type, speed_knots: v.speed, heading: v.heading },
|
||||
}); });
|
||||
}
|
||||
var MaritimePlugin = /** @class */ (function () {
|
||||
function MaritimePlugin() {
|
||||
this.id = "maritime";
|
||||
this.name = "Maritime";
|
||||
this.description = "Vessel tracking via AIS feeds";
|
||||
this.icon = lucide_react_1.Ship;
|
||||
this.category = "maritime";
|
||||
this.version = "1.0.0";
|
||||
this.context = null;
|
||||
}
|
||||
MaritimePlugin.prototype.initialize = function (ctx) {
|
||||
return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
|
||||
this.context = ctx;
|
||||
return [2 /*return*/];
|
||||
}); });
|
||||
};
|
||||
MaritimePlugin.prototype.destroy = function () { this.context = null; };
|
||||
MaritimePlugin.prototype.fetch = function (_timeRange) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var res, data, vessels, _a;
|
||||
return __generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
case 0:
|
||||
_b.trys.push([0, 3, , 4]);
|
||||
return [4 /*yield*/, fetch("/api/maritime")];
|
||||
case 1:
|
||||
res = _b.sent();
|
||||
if (!res.ok)
|
||||
throw new Error("Maritime API returned ".concat(res.status));
|
||||
return [4 /*yield*/, res.json()];
|
||||
case 2:
|
||||
data = _b.sent();
|
||||
vessels = data.vessels || generateDemoVessels();
|
||||
return [2 /*return*/, vessels.map(function (v) { return (__assign(__assign({}, v), { timestamp: new Date(v.timestamp) })); })];
|
||||
case 3:
|
||||
_a = _b.sent();
|
||||
return [2 /*return*/, generateDemoVessels()];
|
||||
case 4: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
MaritimePlugin.prototype.getPollingInterval = function () { return 60000; };
|
||||
MaritimePlugin.prototype.getLayerConfig = function () {
|
||||
return { color: "#f59e0b", clusterEnabled: true, clusterDistance: 50 };
|
||||
};
|
||||
MaritimePlugin.prototype.renderEntity = function (entity) {
|
||||
var vesselType = entity.properties.vesselType || "other";
|
||||
return {
|
||||
type: "point", color: getVesselColor(vesselType), size: 7,
|
||||
rotation: entity.heading, outlineColor: "#000000", outlineWidth: 1,
|
||||
labelText: entity.label || undefined, labelFont: "11px JetBrains Mono, monospace",
|
||||
};
|
||||
};
|
||||
MaritimePlugin.prototype.getFilterDefinitions = function () {
|
||||
return [
|
||||
{
|
||||
id: "vessel_type", label: "Vessel Type", type: "select", propertyKey: "vesselType",
|
||||
options: [
|
||||
{ value: "cargo", label: "Cargo" }, { value: "tanker", label: "Tanker" },
|
||||
{ value: "passenger", label: "Passenger" }, { value: "fishing", label: "Fishing" },
|
||||
{ value: "military", label: "Military" }, { value: "sailing", label: "Sailing" },
|
||||
{ value: "tug", label: "Tug" }, { value: "other", label: "Other" },
|
||||
],
|
||||
},
|
||||
{ id: "speed", label: "Speed (knots)", type: "range", propertyKey: "speed_knots", range: { min: 0, max: 30, step: 1 } },
|
||||
];
|
||||
};
|
||||
return MaritimePlugin;
|
||||
}());
|
||||
exports.MaritimePlugin = MaritimePlugin;
|
||||
@@ -1,36 +0,0 @@
|
||||
{
|
||||
"name": "@worldwideview/wwv-plugin-maritime",
|
||||
"version": "1.0.4",
|
||||
"description": "WorldWideView plugin for real-time vessel tracking via AIS feeds. Color-coded by vessel type with speed and heading indicators",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
"files": [
|
||||
"src"
|
||||
],
|
||||
"keywords": [
|
||||
"worldwideview",
|
||||
"worldwideview-plugin",
|
||||
"wwv-plugin-maritime",
|
||||
"maritime",
|
||||
"vessel-tracking",
|
||||
"ais",
|
||||
"ships",
|
||||
"cesium",
|
||||
"globe"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/silvertakana/worldwideview.git",
|
||||
"directory": "packages/wwv-plugin-maritime"
|
||||
},
|
||||
"homepage": "https://github.com/silvertakana/worldwideview#readme",
|
||||
"bugs": {
|
||||
"url": "https://github.com/silvertakana/worldwideview/issues"
|
||||
},
|
||||
"license": "ISC",
|
||||
"author": "WorldWideView",
|
||||
"peerDependencies": {
|
||||
"@worldwideview/wwv-plugin-sdk": "*",
|
||||
"lucide-react": ">=0.576.0"
|
||||
}
|
||||
}
|
||||
@@ -1,116 +0,0 @@
|
||||
import { Ship } from "lucide-react";
|
||||
import type {
|
||||
WorldPlugin,
|
||||
GeoEntity,
|
||||
TimeRange,
|
||||
PluginContext,
|
||||
LayerConfig,
|
||||
CesiumEntityOptions,
|
||||
FilterDefinition,
|
||||
} from "@worldwideview/wwv-plugin-sdk";
|
||||
|
||||
const VESSEL_COLORS: Record<string, string> = {
|
||||
cargo: "#f59e0b",
|
||||
tanker: "#ef4444",
|
||||
passenger: "#3b82f6",
|
||||
fishing: "#22d3ee",
|
||||
military: "#a78bfa",
|
||||
sailing: "#4ade80",
|
||||
tug: "#f97316",
|
||||
other: "#94a3b8",
|
||||
};
|
||||
|
||||
function getVesselColor(type: string): string {
|
||||
const lower = type.toLowerCase();
|
||||
for (const [key, color] of Object.entries(VESSEL_COLORS)) {
|
||||
if (lower.includes(key)) return color;
|
||||
}
|
||||
return VESSEL_COLORS.other;
|
||||
}
|
||||
|
||||
function generateDemoVessels(): GeoEntity[] {
|
||||
const vessels = [
|
||||
{ name: "EVER GIVEN", mmsi: "353136000", type: "cargo", lat: 30.0, lon: 32.5, speed: 12.5, heading: 340 },
|
||||
{ name: "MAERSK SEALAND", mmsi: "220417000", type: "cargo", lat: 51.9, lon: 1.2, speed: 15.0, heading: 210 },
|
||||
{ name: "PACIFIC RUBY", mmsi: "538004561", type: "tanker", lat: 1.2, lon: 103.7, speed: 8.3, heading: 125 },
|
||||
{ name: "QUEEN MARY 2", mmsi: "310627000", type: "passenger", lat: 40.6, lon: -74.0, speed: 22.0, heading: 90 },
|
||||
{ name: "OCEAN EXPLORER", mmsi: "245390000", type: "fishing", lat: -33.8, lon: 18.4, speed: 4.2, heading: 180 },
|
||||
{ name: "ARCTIC SUNRISE", mmsi: "246585000", type: "other", lat: 69.0, lon: 18.0, speed: 6.0, heading: 45 },
|
||||
{ name: "BLUE MARLIN", mmsi: "244870698", type: "cargo", lat: 22.3, lon: 113.9, speed: 10.5, heading: 270 },
|
||||
{ name: "STENA BULK", mmsi: "265548750", type: "tanker", lat: 57.7, lon: 11.9, speed: 12.0, heading: 300 },
|
||||
{ name: "SPIRIT OF BRITAIN", mmsi: "235082198", type: "passenger", lat: 50.9, lon: 1.4, speed: 20.0, heading: 160 },
|
||||
{ name: "DEEP BLUE", mmsi: "538006050", type: "fishing", lat: -4.0, lon: 39.6, speed: 3.5, heading: 95 },
|
||||
{ name: "CRIMSON ACE", mmsi: "477558200", type: "tanker", lat: 26.2, lon: 56.3, speed: 14.0, heading: 200 },
|
||||
{ name: "SAGA HORIZON", mmsi: "311000596", type: "passenger", lat: 35.3, lon: 139.6, speed: 18.0, heading: 0 },
|
||||
{ name: "ATLANTIC GUARDIAN", mmsi: "219354000", type: "tug", lat: 56.1, lon: -3.2, speed: 7.5, heading: 245 },
|
||||
{ name: "JADE STAR", mmsi: "636092783", type: "cargo", lat: -12.0, lon: -77.0, speed: 11.0, heading: 320 },
|
||||
{ name: "NORTHERN SPIRIT", mmsi: "257038700", type: "fishing", lat: 62.4, lon: 6.1, speed: 5.0, heading: 170 },
|
||||
];
|
||||
|
||||
return vessels.map((v) => ({
|
||||
id: `maritime-${v.mmsi}`,
|
||||
pluginId: "maritime",
|
||||
latitude: v.lat + (Math.random() - 0.5) * 0.1,
|
||||
longitude: v.lon + (Math.random() - 0.5) * 0.1,
|
||||
heading: v.heading,
|
||||
speed: v.speed,
|
||||
timestamp: new Date(),
|
||||
label: v.name,
|
||||
properties: { mmsi: v.mmsi, vesselName: v.name, vesselType: v.type, speed_knots: v.speed, heading: v.heading },
|
||||
}));
|
||||
}
|
||||
|
||||
export class MaritimePlugin implements WorldPlugin {
|
||||
id = "maritime";
|
||||
name = "Maritime";
|
||||
description = "Vessel tracking via AIS feeds";
|
||||
icon = Ship;
|
||||
category = "maritime" as const;
|
||||
version = "1.0.0";
|
||||
private context: PluginContext | null = null;
|
||||
|
||||
async initialize(ctx: PluginContext): Promise<void> { this.context = ctx; }
|
||||
destroy(): void { this.context = null; }
|
||||
|
||||
async fetch(_timeRange: TimeRange): Promise<GeoEntity[]> {
|
||||
try {
|
||||
const res = await fetch("/api/maritime");
|
||||
if (!res.ok) throw new Error(`Maritime API returned ${res.status}`);
|
||||
const data = await res.json();
|
||||
const vessels = data.vessels || generateDemoVessels();
|
||||
return vessels.map((v: GeoEntity) => ({ ...v, timestamp: new Date(v.timestamp) }));
|
||||
} catch {
|
||||
return generateDemoVessels();
|
||||
}
|
||||
}
|
||||
|
||||
getPollingInterval(): number { return 60000; }
|
||||
|
||||
getLayerConfig(): LayerConfig {
|
||||
return { color: "#f59e0b", clusterEnabled: true, clusterDistance: 50 };
|
||||
}
|
||||
|
||||
renderEntity(entity: GeoEntity): CesiumEntityOptions {
|
||||
const vesselType = (entity.properties.vesselType as string) || "other";
|
||||
return {
|
||||
type: "point", color: getVesselColor(vesselType), size: 7,
|
||||
rotation: entity.heading, outlineColor: "#000000", outlineWidth: 1,
|
||||
labelText: entity.label || undefined, labelFont: "11px JetBrains Mono, monospace",
|
||||
};
|
||||
}
|
||||
|
||||
getFilterDefinitions(): FilterDefinition[] {
|
||||
return [
|
||||
{
|
||||
id: "vessel_type", label: "Vessel Type", type: "select", propertyKey: "vesselType",
|
||||
options: [
|
||||
{ value: "cargo", label: "Cargo" }, { value: "tanker", label: "Tanker" },
|
||||
{ value: "passenger", label: "Passenger" }, { value: "fishing", label: "Fishing" },
|
||||
{ value: "military", label: "Military" }, { value: "sailing", label: "Sailing" },
|
||||
{ value: "tug", label: "Tug" }, { value: "other", label: "Other" },
|
||||
],
|
||||
},
|
||||
{ id: "speed", label: "Speed (knots)", type: "range", propertyKey: "speed_knots", range: { min: 0, max: 30, step: 1 } },
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"outDir": "dist",
|
||||
"noEmit": false
|
||||
},
|
||||
"exclude": ["**/*.test.*"]
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "src",
|
||||
"noEmit": true
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
# @worldwideview/wwv-plugin-military
|
||||
|
||||
[WorldWideView](https://github.com/silvertakana/worldwideview) plugin for **real-time military aircraft tracking** via [adsb.fi](https://adsb.fi/).
|
||||
|
||||
## Features
|
||||
|
||||
- 🛡️ Live military aircraft positions updated every 60 seconds
|
||||
- 🎨 Altitude-based coloring (green → orange → red → pink → yellow)
|
||||
- ✈️ 3D airplane model rendering with heading-oriented rotation
|
||||
- 📡 Flight trail rendering on entity selection
|
||||
- 🔍 Filters: aircraft type, callsign, registration, altitude range, on-ground status
|
||||
- 📋 Rich entity properties (hex, squawk, category, emergency status)
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install @worldwideview/wwv-plugin-military
|
||||
```
|
||||
|
||||
### Peer Dependencies
|
||||
|
||||
- `@worldwideview/wwv-plugin-sdk`
|
||||
- `lucide-react` ≥ 0.576.0
|
||||
|
||||
## Usage
|
||||
|
||||
```ts
|
||||
import { MilitaryPlugin } from "@worldwideview/wwv-plugin-military";
|
||||
|
||||
const plugin = new MilitaryPlugin();
|
||||
```
|
||||
|
||||
Register the plugin with the WorldWideView plugin engine to start tracking military aircraft on the globe.
|
||||
|
||||
## Data Source
|
||||
|
||||
Military aircraft data is fetched from [adsb.fi](https://adsb.fi/) via the `/api/military` endpoint. No authentication required.
|
||||
|
||||
## Changelog
|
||||
|
||||
- **v1.0.0** — Initial release. Renamed from wwv-plugin-military for clarity.
|
||||
|
||||
## License
|
||||
|
||||
ISC
|
||||
@@ -1,36 +0,0 @@
|
||||
{
|
||||
"name": "@worldwideview/wwv-plugin-military-aviation",
|
||||
"version": "1.0.1",
|
||||
"description": "WorldWideView plugin for real-time military aircraft tracking via adsb.fi. Features altitude-based coloring, flight trail rendering, and aircraft type filters",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
"files": [
|
||||
"src"
|
||||
],
|
||||
"keywords": [
|
||||
"worldwideview",
|
||||
"worldwideview-plugin",
|
||||
"wwv-plugin-military-aviation",
|
||||
"military",
|
||||
"military-aviation",
|
||||
"adsb",
|
||||
"aircraft-tracking",
|
||||
"cesium",
|
||||
"globe"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/silvertakana/worldwideview.git",
|
||||
"directory": "packages/wwv-plugin-military-aviation"
|
||||
},
|
||||
"homepage": "https://github.com/silvertakana/worldwideview#readme",
|
||||
"bugs": {
|
||||
"url": "https://github.com/silvertakana/worldwideview/issues"
|
||||
},
|
||||
"license": "ISC",
|
||||
"author": "WorldWideView",
|
||||
"peerDependencies": {
|
||||
"@worldwideview/wwv-plugin-sdk": "*",
|
||||
"lucide-react": ">=0.576.0"
|
||||
}
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
import { Shield } from "lucide-react";
|
||||
import type {
|
||||
WorldPlugin, GeoEntity, TimeRange, PluginContext,
|
||||
LayerConfig, CesiumEntityOptions, SelectionBehavior,
|
||||
ServerPluginConfig, FilterDefinition,
|
||||
} from "@worldwideview/wwv-plugin-sdk";
|
||||
|
||||
interface AdsbFiAircraft {
|
||||
hex: string; flight?: string; r?: string; t?: string;
|
||||
lat?: number; lon?: number; alt_baro?: number | "ground";
|
||||
alt_geom?: number; gs?: number; track?: number; squawk?: string;
|
||||
dbFlags?: number; category?: string; emergency?: string;
|
||||
seen?: number; seen_pos?: number;
|
||||
}
|
||||
|
||||
function militaryAltitudeToColor(altFeet: number | null): string {
|
||||
if (altFeet === null || altFeet <= 0) return "#39ff14";
|
||||
if (altFeet < 10000) return "#ff6f00";
|
||||
if (altFeet < 25000) return "#ff1744";
|
||||
if (altFeet < 40000) return "#ff4081";
|
||||
return "#ffea00";
|
||||
}
|
||||
|
||||
function feetToMeters(feet: number): number { return feet * 0.3048; }
|
||||
|
||||
export class MilitaryPlugin implements WorldPlugin {
|
||||
id = "military-aviation";
|
||||
name = "Military Aviation";
|
||||
description = "Real-time military aircraft tracking via adsb.fi";
|
||||
icon = Shield;
|
||||
category = "aviation" as const;
|
||||
version = "1.0.0";
|
||||
private context: PluginContext | null = null;
|
||||
|
||||
async initialize(ctx: PluginContext): Promise<void> { this.context = ctx; }
|
||||
destroy(): void { this.context = null; }
|
||||
|
||||
async fetch(_timeRange: TimeRange): Promise<GeoEntity[]> {
|
||||
try {
|
||||
const res = await fetch("/api/military");
|
||||
if (!res.ok) throw new Error(`Military API returned ${res.status}`);
|
||||
const data = await res.json();
|
||||
if (!data.ac || !Array.isArray(data.ac)) return [];
|
||||
|
||||
return data.ac
|
||||
.filter((ac: AdsbFiAircraft) => ac.lat != null && ac.lon != null)
|
||||
.map((ac: AdsbFiAircraft): GeoEntity => {
|
||||
const altFeet = typeof ac.alt_baro === "number" ? ac.alt_baro : null;
|
||||
const altMeters = altFeet !== null ? feetToMeters(altFeet) : null;
|
||||
const isOnGround = ac.alt_baro === "ground";
|
||||
return {
|
||||
id: `military-aviation-${ac.hex}`, pluginId: "military-aviation",
|
||||
latitude: ac.lat!, longitude: ac.lon!,
|
||||
altitude: altMeters !== null ? altMeters * 10 : 0,
|
||||
heading: ac.track ?? undefined, speed: ac.gs ?? undefined,
|
||||
timestamp: new Date(),
|
||||
label: ac.flight?.trim() || ac.r || ac.hex,
|
||||
properties: { hex: ac.hex, callsign: ac.flight?.trim() || null, registration: ac.r || null, aircraft_type: ac.t || null, altitude_ft: altFeet, altitude_m: altMeters, ground_speed_kts: ac.gs ?? null, heading: ac.track ?? null, squawk: ac.squawk || null, on_ground: isOnGround, category: ac.category || null, emergency: ac.emergency || null },
|
||||
};
|
||||
});
|
||||
} catch (err) {
|
||||
console.error("[MilitaryPlugin] Fetch error:", err);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
getPollingInterval(): number { return 60000; }
|
||||
getLayerConfig(): LayerConfig { return { color: "#ff6f00", clusterEnabled: true, clusterDistance: 40, maxEntities: 3000 }; }
|
||||
|
||||
renderEntity(entity: GeoEntity): CesiumEntityOptions {
|
||||
const altFeet = entity.properties.altitude_ft as number | null;
|
||||
const isAirborne = !entity.properties.on_ground;
|
||||
return {
|
||||
type: "model", iconUrl: "/military-plane-icon.svg", size: isAirborne ? 8 : 5,
|
||||
modelUrl: "/airplane/scene.gltf", modelScale: 75, modelMinPixelSize: 16, modelHeadingOffset: 180,
|
||||
color: militaryAltitudeToColor(altFeet), rotation: entity.heading,
|
||||
labelText: entity.label || undefined, labelFont: "11px JetBrains Mono, monospace",
|
||||
};
|
||||
}
|
||||
|
||||
getSelectionBehavior(entity: GeoEntity): SelectionBehavior | null {
|
||||
if (entity.properties.on_ground) return null;
|
||||
return { showTrail: true, trailDurationSec: 60, trailStepSec: 5, trailColor: "#ffea00", flyToOffsetMultiplier: 3, flyToBaseDistance: 30000 };
|
||||
}
|
||||
|
||||
getServerConfig(): ServerPluginConfig {
|
||||
return { apiBasePath: "/api/military", pollingIntervalMs: 60000, requiresAuth: false };
|
||||
}
|
||||
|
||||
getFilterDefinitions(): FilterDefinition[] {
|
||||
return [
|
||||
{ id: "aircraft_type", label: "Aircraft Type", type: "text", propertyKey: "aircraft_type" },
|
||||
{ id: "callsign", label: "Callsign", type: "text", propertyKey: "callsign" },
|
||||
{ id: "registration", label: "Registration", type: "text", propertyKey: "registration" },
|
||||
{ id: "altitude", label: "Altitude (ft)", type: "range", propertyKey: "altitude_ft", range: { min: 0, max: 60000, step: 1000 } },
|
||||
{ id: "on_ground", label: "On Ground", type: "boolean", propertyKey: "on_ground" },
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"outDir": "dist",
|
||||
"noEmit": false
|
||||
},
|
||||
"exclude": ["**/*.test.*"]
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "src",
|
||||
"noEmit": true
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
Loaded 100 of 476 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user