Compare commits
12
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
188eb4c949 | ||
|
|
758f04d2a1 | ||
|
|
6632174b22 | ||
|
|
8af0b99294 | ||
|
|
f3e30cecc5 | ||
|
|
b47835b4b2 | ||
|
|
40aa245468 | ||
|
|
ef1a0cfa9f | ||
|
|
2874d468d9 | ||
|
|
6c2c58a6cf | ||
|
|
5055d2c110 | ||
|
|
44bacbaffd |
No files matched your search
@@ -104,10 +104,10 @@ Visibility Toggle → DataBusSubscriber subscribes to layer via WsClient
|
|||||||
Four plugin architectures exist (All-Bundle Model):
|
Four plugin architectures exist (All-Bundle Model):
|
||||||
1. **Data Engine Seeder** — Standalone Fastify container with SQLite microservice or unified seeders (e.g., `iranwarlive-backend`).
|
1. **Data Engine Seeder** — Standalone Fastify container with SQLite microservice or unified seeders (e.g., `iranwarlive-backend`).
|
||||||
2. **Dynamic CDN Loaded (Bundle)** — Externally developed plugins dynamically imported at runtime via ES module CDNs (e.g., `unpkg.com` version-pinned URLs).
|
2. **Dynamic CDN Loaded (Bundle)** — Externally developed plugins dynamically imported at runtime via ES module CDNs (e.g., `unpkg.com` version-pinned URLs).
|
||||||
3. **Static Compiled (Bundle)** — Static GeoJSON data wrapped into JS bundles via `wwvStaticCompiler` during build/sync (previously `StaticDataPlugin`).
|
3. **WWV CLI Unpacked (Dev)** — Developed externally using `@worldwideview/cli dev`, which spins up a local Vite server and hot-reloads via WebSocket injection directly into the running platform.
|
||||||
4. **Active Proxied (Bundle)** — Next.js API routes bundled to provide frontend interactions (previously `DeclarativePlugin`).
|
4. **Marketplace Package (.wwvpkg)** — Built via `@worldwideview/cli publish` and distributed through the WorldWideView Marketplace.
|
||||||
|
|
||||||
All plugins are now dynamically imported at runtime as ES module bundles via `loadPluginFromManifest` utilizing `import(/* webpackIgnore: true */ entry)`. The legacy `StaticDataPlugin` and `DeclarativePlugin` runtimes are fully deprecated.
|
All plugins are now dynamically imported at runtime as ES module bundles via `loadPluginFromManifest` utilizing `import(/* webpackIgnore: true */ entry)`. The plugin passport is defined in `wwv-manifest.json` which governs its trust tier (`developer`, `unverified`, `verified`, `built-in`) and capabilities.
|
||||||
|
|
||||||
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`**.
|
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`**.
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "worldwideview",
|
"name": "worldwideview",
|
||||||
"version": "1.19.7",
|
"version": "1.20.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"setup": "node scripts/setup.mjs",
|
"setup": "node scripts/setup.mjs",
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
require('../dist/index.js');
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"name": "@worldwideview/cli",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"bin": {
|
||||||
|
"wwv": "./bin/wwv.js"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"build": "tsc",
|
||||||
|
"test": "vitest run"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"archiver": "^7.0.1",
|
||||||
|
"commander": "^11.1.0",
|
||||||
|
"vite": "^8.0.8",
|
||||||
|
"ws": "^8.20.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/archiver": "^7.0.0",
|
||||||
|
"@types/node": "^20.0.0",
|
||||||
|
"@types/ws": "^8.18.1",
|
||||||
|
"typescript": "^5.0.0",
|
||||||
|
"vitest": "^1.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
import fs from "fs";
|
||||||
|
import path from "path";
|
||||||
|
|
||||||
|
export async function createPlugin(name: string, basePath: string = process.cwd()) {
|
||||||
|
const targetDir = path.join(basePath, name);
|
||||||
|
if (fs.existsSync(targetDir)) {
|
||||||
|
throw new Error(`Directory ${name} already exists`);
|
||||||
|
}
|
||||||
|
|
||||||
|
fs.mkdirSync(targetDir, { recursive: true });
|
||||||
|
fs.mkdirSync(path.join(targetDir, "src"), { recursive: true });
|
||||||
|
|
||||||
|
const manifest = {
|
||||||
|
manifest_version: 1,
|
||||||
|
id: name,
|
||||||
|
name: name,
|
||||||
|
version: "1.0.0",
|
||||||
|
description: "A WorldWideView plugin",
|
||||||
|
type: "data-layer",
|
||||||
|
category: "custom",
|
||||||
|
icon: "Box",
|
||||||
|
capabilities: ["data:own"],
|
||||||
|
entry: "dist/frontend.mjs",
|
||||||
|
dev_entry: "src/index.ts"
|
||||||
|
};
|
||||||
|
|
||||||
|
fs.writeFileSync(
|
||||||
|
path.join(targetDir, "wwv-manifest.json"),
|
||||||
|
JSON.stringify(manifest, null, 2)
|
||||||
|
);
|
||||||
|
|
||||||
|
const indexContent = `export default class MyPlugin {
|
||||||
|
id = "${name}";
|
||||||
|
name = "${name}";
|
||||||
|
version = "1.0.0";
|
||||||
|
category = "custom";
|
||||||
|
icon = "Box";
|
||||||
|
|
||||||
|
async initialize(ctx) {
|
||||||
|
console.log("Initialized", this.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
destroy() {}
|
||||||
|
|
||||||
|
async fetch(timeRange) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
getPollingInterval() {
|
||||||
|
return 5000;
|
||||||
|
}
|
||||||
|
|
||||||
|
getLayerConfig() {
|
||||||
|
return { color: "#3b82f6", clusterEnabled: true, clusterDistance: 50 };
|
||||||
|
}
|
||||||
|
|
||||||
|
renderEntity(entity) {
|
||||||
|
return { type: "point", color: "#3b82f6", size: 6 };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
fs.writeFileSync(path.join(targetDir, "src", "index.ts"), indexContent);
|
||||||
|
console.log(`Plugin ${name} scaffolded successfully in ./${name}`);
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
import fs from "fs";
|
||||||
|
import path from "path";
|
||||||
|
import { createServer } from "vite";
|
||||||
|
import { WebSocketServer } from "ws";
|
||||||
|
|
||||||
|
export async function startDevServer(targetUrl: string = "http://localhost:3000") {
|
||||||
|
const cwd = process.cwd();
|
||||||
|
const manifestPath = path.join(cwd, "wwv-manifest.json");
|
||||||
|
|
||||||
|
if (!fs.existsSync(manifestPath)) {
|
||||||
|
throw new Error("No wwv-manifest.json found in current directory");
|
||||||
|
}
|
||||||
|
|
||||||
|
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf-8"));
|
||||||
|
const port = 24601;
|
||||||
|
|
||||||
|
// Start Vite Dev Server
|
||||||
|
const vite = await createServer({
|
||||||
|
root: cwd,
|
||||||
|
server: { port, cors: true, hmr: false }, // We handle HMR via custom WS
|
||||||
|
plugins: [{
|
||||||
|
name: 'wwv-hmr',
|
||||||
|
handleHotUpdate({ server }: any) {
|
||||||
|
// When Vite detects file changes, broadcast to our custom WS
|
||||||
|
wss.clients.forEach(client => {
|
||||||
|
client.send(JSON.stringify({ type: "plugin:updated", pluginId: manifest.id }));
|
||||||
|
});
|
||||||
|
return []; // Prevent default Vite HMR
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
});
|
||||||
|
|
||||||
|
await vite.listen();
|
||||||
|
|
||||||
|
// Attach custom WebSocket server for WWV DevModeSubscriber
|
||||||
|
const wss = new WebSocketServer({ server: vite.httpServer as any, path: "/__wwv_dev__" });
|
||||||
|
|
||||||
|
wss.on("connection", (ws) => {
|
||||||
|
console.log(`[WWV CLI] Connected to WorldWideView instance`);
|
||||||
|
ws.send(JSON.stringify({ type: "plugin:added", manifest }));
|
||||||
|
});
|
||||||
|
|
||||||
|
// Notify WorldWideView via API
|
||||||
|
try {
|
||||||
|
await fetch(`${targetUrl}/api/dev/load-unpacked`, {
|
||||||
|
method: "POST",
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
body: JSON.stringify({
|
||||||
|
...manifest,
|
||||||
|
entry: `http://localhost:${port}/${manifest.dev_entry || "src/index.ts"}`
|
||||||
|
})
|
||||||
|
});
|
||||||
|
console.log(`[WWV CLI] Registered with WorldWideView at ${targetUrl}`);
|
||||||
|
} catch (err: any) {
|
||||||
|
console.error(`[WWV CLI] Failed to connect to ${targetUrl}: ${err.message}`);
|
||||||
|
console.log(`Waiting for WorldWideView to connect via WebSocket...`);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`\n🚀 Dev server running on http://localhost:${port}`);
|
||||||
|
console.log(`Watching for file changes in ${cwd}...\n`);
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
import fs from "fs";
|
||||||
|
import path from "path";
|
||||||
|
import { build } from "vite";
|
||||||
|
import archiver from "archiver";
|
||||||
|
|
||||||
|
export async function packagePlugin() {
|
||||||
|
const cwd = process.cwd();
|
||||||
|
const manifestPath = path.join(cwd, "wwv-manifest.json");
|
||||||
|
|
||||||
|
if (!fs.existsSync(manifestPath)) {
|
||||||
|
throw new Error("No wwv-manifest.json found in current directory");
|
||||||
|
}
|
||||||
|
|
||||||
|
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf-8"));
|
||||||
|
|
||||||
|
console.log(`[WWV CLI] Building production bundle...`);
|
||||||
|
await build({
|
||||||
|
root: cwd,
|
||||||
|
build: {
|
||||||
|
lib: {
|
||||||
|
entry: path.resolve(cwd, manifest.dev_entry || "src/index.ts"),
|
||||||
|
name: 'WWVPlugin',
|
||||||
|
formats: ['es'],
|
||||||
|
fileName: () => 'frontend.mjs'
|
||||||
|
},
|
||||||
|
outDir: 'dist',
|
||||||
|
emptyOutDir: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const pkgName = `${manifest.id}-${manifest.version}.wwvpkg`;
|
||||||
|
const outputPath = path.join(cwd, pkgName);
|
||||||
|
|
||||||
|
console.log(`[WWV CLI] Creating archive ${pkgName}...`);
|
||||||
|
|
||||||
|
await new Promise<void>((resolve, reject) => {
|
||||||
|
const output = fs.createWriteStream(outputPath);
|
||||||
|
const archive = archiver("zip", { zlib: { level: 9 } });
|
||||||
|
|
||||||
|
output.on("close", () => resolve());
|
||||||
|
archive.on("error", (err) => reject(err));
|
||||||
|
|
||||||
|
archive.pipe(output);
|
||||||
|
|
||||||
|
archive.file(manifestPath, { name: "wwv-manifest.json" });
|
||||||
|
archive.directory(path.join(cwd, "dist"), "dist");
|
||||||
|
|
||||||
|
if (fs.existsSync(path.join(cwd, "data"))) {
|
||||||
|
archive.directory(path.join(cwd, "data"), "data");
|
||||||
|
}
|
||||||
|
|
||||||
|
archive.finalize();
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(`\n🎉 Success! Package created at ${outputPath}`);
|
||||||
|
console.log(`You can use this file to sideload the plugin into your WWV instance.`);
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
import fs from "fs";
|
||||||
|
import path from "path";
|
||||||
|
import { build } from "vite";
|
||||||
|
import { execSync } from "child_process";
|
||||||
|
|
||||||
|
export async function publishToNpm() {
|
||||||
|
const cwd = process.cwd();
|
||||||
|
const manifestPath = path.join(cwd, "wwv-manifest.json");
|
||||||
|
|
||||||
|
if (!fs.existsSync(manifestPath)) {
|
||||||
|
throw new Error("No wwv-manifest.json found in current directory");
|
||||||
|
}
|
||||||
|
|
||||||
|
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf-8"));
|
||||||
|
|
||||||
|
console.log(`[WWV CLI] Compiling bundle for NPM...`);
|
||||||
|
await build({
|
||||||
|
root: cwd,
|
||||||
|
build: {
|
||||||
|
lib: {
|
||||||
|
entry: path.resolve(cwd, manifest.dev_entry || "src/index.ts"),
|
||||||
|
name: 'WWVPlugin',
|
||||||
|
formats: ['es'],
|
||||||
|
fileName: () => 'frontend.mjs'
|
||||||
|
},
|
||||||
|
outDir: 'dist',
|
||||||
|
emptyOutDir: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(`[WWV CLI] Generating package.json...`);
|
||||||
|
// Create a temporary package.json required for NPM publish
|
||||||
|
const packageJsonPath = path.join(cwd, "package.json");
|
||||||
|
const packageJson = {
|
||||||
|
name: manifest.id, // e.g. @username/my-plugin
|
||||||
|
version: manifest.version,
|
||||||
|
description: manifest.description,
|
||||||
|
main: "dist/frontend.mjs",
|
||||||
|
type: "module",
|
||||||
|
files: ["dist", "wwv-manifest.json", "data"],
|
||||||
|
keywords: ["worldwideview", "plugin", manifest.category],
|
||||||
|
author: manifest.author || ""
|
||||||
|
};
|
||||||
|
|
||||||
|
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
||||||
|
|
||||||
|
console.log(`[WWV CLI] Publishing to NPM...`);
|
||||||
|
try {
|
||||||
|
execSync(`npm publish --access public`, { stdio: "inherit", cwd });
|
||||||
|
} catch (err) {
|
||||||
|
console.error(`[WWV CLI] NPM publish failed. Please ensure you are logged in via 'npm login'.`);
|
||||||
|
throw err;
|
||||||
|
} finally {
|
||||||
|
// Clean up the generated package.json so it doesn't clutter the dev's repo
|
||||||
|
fs.unlinkSync(packageJsonPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`[WWV CLI] Notifying WorldWideView Marketplace...`);
|
||||||
|
try {
|
||||||
|
const targetUrl = process.env.WWV_MARKETPLACE_URL || "https://marketplace.worldwideview.dev";
|
||||||
|
await fetch(`${targetUrl}/api/webhooks/npm-publish`, {
|
||||||
|
method: "POST",
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
body: JSON.stringify({ pluginId: manifest.id, version: manifest.version })
|
||||||
|
});
|
||||||
|
console.log(`[WWV CLI] Marketplace notified.`);
|
||||||
|
} catch (err: any) {
|
||||||
|
console.warn(`[WWV CLI] Could not notify marketplace: ${err.message}. It will be indexed on the next sweep.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`\n🚀 Success! Version ${manifest.version} published globally to NPM.`);
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
import { Command } from "commander";
|
||||||
|
|
||||||
|
import { createPlugin } from "./commands/create";
|
||||||
|
|
||||||
|
const program = new Command();
|
||||||
|
|
||||||
|
program
|
||||||
|
.name("wwv")
|
||||||
|
.description("WorldWideView Plugin CLI")
|
||||||
|
.version("1.0.0");
|
||||||
|
|
||||||
|
program
|
||||||
|
.command("create <name>")
|
||||||
|
.description("Scaffold a new WorldWideView plugin")
|
||||||
|
.action(async (name) => {
|
||||||
|
try {
|
||||||
|
await createPlugin(name);
|
||||||
|
} catch (err: any) {
|
||||||
|
console.error("Error:", err.message);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
import { startDevServer } from "./commands/dev";
|
||||||
|
|
||||||
|
program
|
||||||
|
.command("dev")
|
||||||
|
.description("Start the plugin development server with hot-reload")
|
||||||
|
.option("-t, --target <url>", "Target WorldWideView URL", "http://localhost:3000")
|
||||||
|
.action(async (options) => {
|
||||||
|
try {
|
||||||
|
await startDevServer(options.target);
|
||||||
|
} catch (err: any) {
|
||||||
|
console.error("Error:", err.message);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
import { packagePlugin } from "./commands/package";
|
||||||
|
import { publishToNpm } from "./commands/publish";
|
||||||
|
|
||||||
|
program
|
||||||
|
.command("package")
|
||||||
|
.description("Build and package the plugin into a .wwvpkg file for sideloading")
|
||||||
|
.action(async () => {
|
||||||
|
try {
|
||||||
|
await packagePlugin();
|
||||||
|
} catch (err: any) {
|
||||||
|
console.error("Error:", err.message);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
program
|
||||||
|
.command("publish")
|
||||||
|
.description("Publish the plugin to NPM and notify the WWV Marketplace")
|
||||||
|
.action(async () => {
|
||||||
|
try {
|
||||||
|
await publishToNpm();
|
||||||
|
} catch (err: any) {
|
||||||
|
console.error("Error:", err.message);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
program.parse();
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import { describe, it, expect, afterEach } from "vitest";
|
||||||
|
import { createPlugin } from "../src/commands/create";
|
||||||
|
import fs from "fs";
|
||||||
|
import path from "path";
|
||||||
|
|
||||||
|
describe("create command", () => {
|
||||||
|
const testDir = path.join(__dirname, "test-plugin");
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
if (fs.existsSync(testDir)) fs.rmSync(testDir, { recursive: true, force: true });
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should scaffold a new plugin folder with manifest and index.ts", async () => {
|
||||||
|
await createPlugin("test-plugin", __dirname);
|
||||||
|
expect(fs.existsSync(path.join(testDir, "wwv-manifest.json"))).toBe(true);
|
||||||
|
expect(fs.existsSync(path.join(testDir, "src", "index.ts"))).toBe(true);
|
||||||
|
|
||||||
|
const manifest = JSON.parse(fs.readFileSync(path.join(testDir, "wwv-manifest.json"), "utf-8"));
|
||||||
|
expect(manifest.id).toBe("test-plugin");
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import { describe, it, expect, vi } from "vitest";
|
||||||
|
import { startDevServer } from "../src/commands/dev";
|
||||||
|
|
||||||
|
// Mock vite and ws
|
||||||
|
vi.mock("vite", () => ({
|
||||||
|
createServer: vi.fn().mockResolvedValue({
|
||||||
|
listen: vi.fn(),
|
||||||
|
httpServer: { on: vi.fn() },
|
||||||
|
ws: { on: vi.fn() }
|
||||||
|
})
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe("dev command", () => {
|
||||||
|
it("should export startDevServer function", () => {
|
||||||
|
expect(typeof startDevServer).toBe("function");
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import { describe, it, expect } from "vitest";
|
||||||
|
import { execSync } from "child_process";
|
||||||
|
import path from "path";
|
||||||
|
|
||||||
|
describe("wwv cli", () => {
|
||||||
|
it("should print help information", () => {
|
||||||
|
const binPath = path.resolve(__dirname, "../bin/wwv.js");
|
||||||
|
const output = execSync(`node ${binPath} --help`).toString();
|
||||||
|
expect(output).toContain("Usage: wwv [options]");
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import { describe, it, expect } from "vitest";
|
||||||
|
import { packagePlugin } from "../src/commands/package";
|
||||||
|
|
||||||
|
describe("package command", () => {
|
||||||
|
it("should export packagePlugin function", () => {
|
||||||
|
expect(typeof packagePlugin).toBe("function");
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import { describe, it, expect, vi } from "vitest";
|
||||||
|
import { publishToNpm } from "../src/commands/publish";
|
||||||
|
|
||||||
|
vi.mock("child_process", () => ({
|
||||||
|
execSync: vi.fn()
|
||||||
|
}));
|
||||||
|
vi.mock("vite", () => ({
|
||||||
|
build: vi.fn().mockResolvedValue({})
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe("publish command", () => {
|
||||||
|
it("should export publishToNpm function", () => {
|
||||||
|
expect(typeof publishToNpm).toBe("function");
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ES2022",
|
||||||
|
"module": "NodeNext",
|
||||||
|
"outDir": "./dist",
|
||||||
|
"rootDir": "./src",
|
||||||
|
"strict": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"moduleResolution": "NodeNext",
|
||||||
|
"forceConsistentCasingInFileNames": true
|
||||||
|
},
|
||||||
|
"include": ["src/**/*"]
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import { defineConfig } from "vitest/config";
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
test: {
|
||||||
|
environment: "node",
|
||||||
|
globals: true
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -6,7 +6,7 @@ import type { PluginCategory } from "./index";
|
|||||||
|
|
||||||
export type PluginFormat = "declarative" | "static" | "bundle";
|
export type PluginFormat = "declarative" | "static" | "bundle";
|
||||||
export type PluginType = "data-layer" | "extension";
|
export type PluginType = "data-layer" | "extension";
|
||||||
export type TrustTier = "built-in" | "verified" | "unverified";
|
export type TrustTier = "built-in" | "verified" | "unverified" | "developer";
|
||||||
|
|
||||||
export type PluginCapability =
|
export type PluginCapability =
|
||||||
| "data:own"
|
| "data:own"
|
||||||
|
|||||||
Generated
+1057
-560
File diff suppressed because it is too large.
Load diff
+9
-4
@@ -1250,6 +1250,11 @@ html, body {
|
|||||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
body.is-resizing-sidebar .panel-toggle-btn,
|
||||||
|
body.is-resizing-sidebar .sidebar {
|
||||||
|
transition: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
/* Invisible pseudo-element to expand the effective touch/click trigger area */
|
/* Invisible pseudo-element to expand the effective touch/click trigger area */
|
||||||
.panel-toggle-btn::after {
|
.panel-toggle-btn::after {
|
||||||
content: "";
|
content: "";
|
||||||
@@ -1292,8 +1297,8 @@ html, body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.panel-toggle-btn--left.panel-toggle-btn--open {
|
.panel-toggle-btn--left.panel-toggle-btn--open {
|
||||||
/* Attach to the right edge of the left panel (width 280px + left padding 24px) */
|
/* Attach to the right edge of the left panel */
|
||||||
left: calc(280px + var(--space-lg));
|
left: calc(var(--left-sidebar-width, 280px) + var(--space-lg));
|
||||||
border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
|
border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
|
||||||
border-left: none;
|
border-left: none;
|
||||||
/* Stay slightly hidden under the panel to look attached, poke out 24px */
|
/* Stay slightly hidden under the panel to look attached, poke out 24px */
|
||||||
@@ -1320,8 +1325,8 @@ html, body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.panel-toggle-btn--right.panel-toggle-btn--open {
|
.panel-toggle-btn--right.panel-toggle-btn--open {
|
||||||
/* Attach to the left edge of the right panel (width 320px + right padding 24px) */
|
/* Attach to the left edge of the right panel */
|
||||||
right: calc(320px + var(--space-lg) + var(--ad-strip-inset, 0px));
|
right: calc(var(--right-sidebar-width, 320px) + var(--space-lg) + var(--ad-strip-inset, 0px));
|
||||||
border-radius: var(--radius-sm) 0 0 var(--radius-sm);
|
border-radius: var(--radius-sm) 0 0 var(--radius-sm);
|
||||||
border-right: none;
|
border-right: none;
|
||||||
/* Stay slightly hidden under the panel to look attached, poke out 24px */
|
/* Stay slightly hidden under the panel to look attached, poke out 24px */
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import { useBootSequence } from "@/core/hooks/useBootSequence";
|
|||||||
import { useIsMobile } from "@/core/hooks/useIsMobile";
|
import { useIsMobile } from "@/core/hooks/useIsMobile";
|
||||||
import { useMarketplaceSync } from "@/core/hooks/useMarketplaceSync";
|
import { useMarketplaceSync } from "@/core/hooks/useMarketplaceSync";
|
||||||
import { DataBusSubscriber } from "./DataBusSubscriber";
|
import { DataBusSubscriber } from "./DataBusSubscriber";
|
||||||
|
import { DevModeSubscriber } from "./DevModeSubscriber";
|
||||||
import { MobileHudBar } from "./MobileHudBar";
|
import { MobileHudBar } from "./MobileHudBar";
|
||||||
import { MobileCameraStats } from "./MobileCameraStats";
|
import { MobileCameraStats } from "./MobileCameraStats";
|
||||||
import dynamic from "next/dynamic";
|
import dynamic from "next/dynamic";
|
||||||
@@ -137,6 +138,7 @@ export function AppShell() {
|
|||||||
|
|
||||||
<TimelineSync />
|
<TimelineSync />
|
||||||
<DataBusSubscriber />
|
<DataBusSubscriber />
|
||||||
|
<DevModeSubscriber />
|
||||||
|
|
||||||
<Header />
|
<Header />
|
||||||
{isMobile && <MobileHudBar />}
|
{isMobile && <MobileHudBar />}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { useStore } from "@/core/state/store";
|
|||||||
import { FilterSection } from "@/components/panels/FilterPanel";
|
import { FilterSection } from "@/components/panels/FilterPanel";
|
||||||
import { Info, Key, MessageSquare } from "lucide-react";
|
import { Info, Key, MessageSquare } from "lucide-react";
|
||||||
import { useIsMobile } from "@/core/hooks/useIsMobile";
|
import { useIsMobile } from "@/core/hooks/useIsMobile";
|
||||||
|
import { useResizablePanel } from "@/core/hooks/useResizablePanel";
|
||||||
|
|
||||||
import { IntelTab } from "./IntelTab";
|
import { IntelTab } from "./IntelTab";
|
||||||
import { CacheTab } from "./CacheTab";
|
import { CacheTab } from "./CacheTab";
|
||||||
@@ -11,6 +12,7 @@ import { sectionHeaderStyle } from "./sharedStyles";
|
|||||||
|
|
||||||
export function DataConfigPanel() {
|
export function DataConfigPanel() {
|
||||||
const isMobile = useIsMobile();
|
const isMobile = useIsMobile();
|
||||||
|
const { width, startResizing } = useResizablePanel(320, 260, 800, 'right');
|
||||||
const configPanelOpen = useStore((s) => s.configPanelOpen);
|
const configPanelOpen = useStore((s) => s.configPanelOpen);
|
||||||
const openMobilePanel = useStore((s) => s.openMobilePanel);
|
const openMobilePanel = useStore((s) => s.openMobilePanel);
|
||||||
const selectedEntity = useStore((s) => s.selectedEntity);
|
const selectedEntity = useStore((s) => s.selectedEntity);
|
||||||
@@ -22,8 +24,24 @@ export function DataConfigPanel() {
|
|||||||
return (
|
return (
|
||||||
<aside
|
<aside
|
||||||
className={`sidebar sidebar--right glass-panel ${isMobile ? "sidebar--mobile" : ""} ${(isMobile ? openMobilePanel === "right" : configPanelOpen) ? "" : "sidebar--closed"}`}
|
className={`sidebar sidebar--right glass-panel ${isMobile ? "sidebar--mobile" : ""} ${(isMobile ? openMobilePanel === "right" : configPanelOpen) ? "" : "sidebar--closed"}`}
|
||||||
style={{ width: isMobile ? undefined : 320, padding: "var(--space-xl)", zIndex: 101, borderLeft: "var(--glass-border)" }}
|
style={{ width: isMobile ? undefined : width, padding: "var(--space-xl)", zIndex: 101, borderLeft: "var(--glass-border)" }}
|
||||||
>
|
>
|
||||||
|
{/* Drag Handle */}
|
||||||
|
{!isMobile && (
|
||||||
|
<div
|
||||||
|
onMouseDown={startResizing}
|
||||||
|
style={{
|
||||||
|
position: 'absolute',
|
||||||
|
top: 0,
|
||||||
|
left: -4,
|
||||||
|
width: 8,
|
||||||
|
height: '100%',
|
||||||
|
cursor: 'col-resize',
|
||||||
|
zIndex: 10,
|
||||||
|
backgroundColor: 'transparent'
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<div className="sidebar__title" style={{ marginBottom: "var(--space-md)", color: "var(--text-primary)", fontSize: "14px", fontWeight: 600 }}>
|
<div className="sidebar__title" style={{ marginBottom: "var(--space-md)", color: "var(--text-primary)", fontSize: "14px", fontWeight: 600 }}>
|
||||||
Data Configuration
|
Data Configuration
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import { Search } from "lucide-react";
|
||||||
|
|
||||||
import { useStore } from "@/core/state/store";
|
import { useStore } from "@/core/state/store";
|
||||||
import { useIsMobile } from "@/core/hooks/useIsMobile";
|
import { useIsMobile } from "@/core/hooks/useIsMobile";
|
||||||
|
import { useResizablePanel } from "@/core/hooks/useResizablePanel";
|
||||||
import { pluginManager } from "@/core/plugins/PluginManager";
|
import { pluginManager } from "@/core/plugins/PluginManager";
|
||||||
import { ImageryPicker } from "./ImageryPicker";
|
import { ImageryPicker } from "./ImageryPicker";
|
||||||
import { LayerItem } from "./LayerItem";
|
import { LayerItem } from "./LayerItem";
|
||||||
@@ -17,6 +19,7 @@ import { trackEvent } from "@/lib/analytics";
|
|||||||
|
|
||||||
export function LayerPanel() {
|
export function LayerPanel() {
|
||||||
const isMobile = useIsMobile();
|
const isMobile = useIsMobile();
|
||||||
|
const { width, startResizing } = useResizablePanel(280, 260, 800, 'left');
|
||||||
const leftSidebarOpen = useStore((s) => s.leftSidebarOpen);
|
const leftSidebarOpen = useStore((s) => s.leftSidebarOpen);
|
||||||
const openMobilePanel = useStore((s) => s.openMobilePanel);
|
const openMobilePanel = useStore((s) => s.openMobilePanel);
|
||||||
const layers = useStore((s) => s.layers);
|
const layers = useStore((s) => s.layers);
|
||||||
@@ -28,13 +31,23 @@ export function LayerPanel() {
|
|||||||
const setSelectedEntity = useStore((s) => s.setSelectedEntity);
|
const setSelectedEntity = useStore((s) => s.setSelectedEntity);
|
||||||
|
|
||||||
const allPlugins = pluginManager.getAllPlugins();
|
const allPlugins = pluginManager.getAllPlugins();
|
||||||
|
const [searchQuery, setSearchQuery] = useState("");
|
||||||
|
|
||||||
// Group by category
|
// Group by category
|
||||||
const grouped: Record<string, typeof allPlugins> = {};
|
const grouped: Record<string, typeof allPlugins> = {};
|
||||||
|
const query = searchQuery.toLowerCase();
|
||||||
|
|
||||||
allPlugins.forEach((managed) => {
|
allPlugins.forEach((managed) => {
|
||||||
const cat = managed.plugin.category;
|
if (
|
||||||
if (!grouped[cat]) grouped[cat] = [];
|
!query ||
|
||||||
grouped[cat].push(managed);
|
managed.plugin.name.toLowerCase().includes(query) ||
|
||||||
|
managed.plugin.description?.toLowerCase().includes(query) ||
|
||||||
|
managed.plugin.id.toLowerCase().includes(query)
|
||||||
|
) {
|
||||||
|
const cat = managed.plugin.category;
|
||||||
|
if (!grouped[cat]) grouped[cat] = [];
|
||||||
|
grouped[cat].push(managed);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const categoryLabels: Record<string, string> = {
|
const categoryLabels: Record<string, string> = {
|
||||||
@@ -87,7 +100,24 @@ export function LayerPanel() {
|
|||||||
return (
|
return (
|
||||||
<aside
|
<aside
|
||||||
className={`sidebar sidebar--left glass-panel ${isMobile ? "sidebar--mobile" : ""} ${(isMobile ? openMobilePanel === "left" : leftSidebarOpen) ? "" : "sidebar--closed"}`}
|
className={`sidebar sidebar--left glass-panel ${isMobile ? "sidebar--mobile" : ""} ${(isMobile ? openMobilePanel === "left" : leftSidebarOpen) ? "" : "sidebar--closed"}`}
|
||||||
|
style={{ width: isMobile ? undefined : width }}
|
||||||
>
|
>
|
||||||
|
{/* Drag Handle */}
|
||||||
|
{!isMobile && (
|
||||||
|
<div
|
||||||
|
onMouseDown={startResizing}
|
||||||
|
style={{
|
||||||
|
position: 'absolute',
|
||||||
|
top: 0,
|
||||||
|
right: -4,
|
||||||
|
width: 8,
|
||||||
|
height: '100%',
|
||||||
|
cursor: 'col-resize',
|
||||||
|
zIndex: 10,
|
||||||
|
backgroundColor: 'transparent'
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<div className="sidebar__title">Data Sources</div>
|
<div className="sidebar__title">Data Sources</div>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
@@ -130,6 +160,33 @@ export function LayerPanel() {
|
|||||||
|
|
||||||
{activeTab === "layers" && (
|
{activeTab === "layers" && (
|
||||||
<div className="layers-tab-content">
|
<div className="layers-tab-content">
|
||||||
|
<div style={{ padding: "0 var(--space-md) var(--space-md) var(--space-md)" }}>
|
||||||
|
<div style={{
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
background: "var(--bg-layer-2)",
|
||||||
|
border: "1px solid var(--border-subtle)",
|
||||||
|
borderRadius: "var(--radius-sm)",
|
||||||
|
padding: "0 var(--space-sm)",
|
||||||
|
}}>
|
||||||
|
<Search size={14} style={{ color: "var(--text-muted)", marginRight: 8 }} />
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
placeholder="Search layers..."
|
||||||
|
value={searchQuery}
|
||||||
|
onChange={(e) => setSearchQuery(e.target.value)}
|
||||||
|
style={{
|
||||||
|
flex: 1,
|
||||||
|
background: "transparent",
|
||||||
|
border: "none",
|
||||||
|
color: "var(--text-primary)",
|
||||||
|
fontSize: "13px",
|
||||||
|
padding: "var(--space-sm) 0",
|
||||||
|
outline: "none"
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div className="layers-tab-content__list">
|
<div className="layers-tab-content__list">
|
||||||
{Object.entries(grouped).map(([category, plugins]) => (
|
{Object.entries(grouped).map(([category, plugins]) => (
|
||||||
<div key={category} style={{ marginBottom: "var(--space-lg)" }}>
|
<div key={category} style={{ marginBottom: "var(--space-lg)" }}>
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
import { useState, useRef, useEffect } from "react";
|
||||||
|
|
||||||
|
export function useResizablePanel(initialWidth: number, minWidth: number, maxWidth: number, direction: 'left' | 'right') {
|
||||||
|
const [width, setWidth] = useState(initialWidth);
|
||||||
|
const isResizing = useRef(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
document.documentElement.style.setProperty(`--${direction}-sidebar-width`, `${initialWidth}px`);
|
||||||
|
}, [initialWidth, direction]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const handleMouseMove = (e: MouseEvent) => {
|
||||||
|
if (!isResizing.current) return;
|
||||||
|
|
||||||
|
let newWidth = direction === 'left' ? e.clientX : window.innerWidth - e.clientX;
|
||||||
|
|
||||||
|
if (newWidth < minWidth) newWidth = minWidth;
|
||||||
|
if (newWidth > maxWidth) newWidth = maxWidth;
|
||||||
|
|
||||||
|
setWidth(newWidth);
|
||||||
|
document.documentElement.style.setProperty(`--${direction}-sidebar-width`, `${newWidth}px`);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleMouseUp = () => {
|
||||||
|
if (isResizing.current) {
|
||||||
|
isResizing.current = false;
|
||||||
|
document.body.style.cursor = 'default';
|
||||||
|
document.body.style.userSelect = 'auto';
|
||||||
|
document.body.classList.remove('is-resizing-sidebar');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
document.addEventListener('mousemove', handleMouseMove);
|
||||||
|
document.addEventListener('mouseup', handleMouseUp);
|
||||||
|
return () => {
|
||||||
|
document.removeEventListener('mousemove', handleMouseMove);
|
||||||
|
document.removeEventListener('mouseup', handleMouseUp);
|
||||||
|
};
|
||||||
|
}, [direction, minWidth, maxWidth]);
|
||||||
|
|
||||||
|
const startResizing = (e: React.MouseEvent) => {
|
||||||
|
e.preventDefault();
|
||||||
|
isResizing.current = true;
|
||||||
|
document.body.style.cursor = 'col-resize';
|
||||||
|
document.body.style.userSelect = 'none';
|
||||||
|
document.body.classList.add('is-resizing-sidebar');
|
||||||
|
};
|
||||||
|
|
||||||
|
return { width, startResizing };
|
||||||
|
}
|
||||||
@@ -222,6 +222,47 @@ class PluginManager {
|
|||||||
return this.loadedManifests.get(pluginId);
|
return this.loadedManifests.get(pluginId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hot-reloads a plugin (destroys, cache-busts entry, re-registers).
|
||||||
|
* Used exclusively during developer mode when files change on disk.
|
||||||
|
*/
|
||||||
|
async hotReload(pluginId: string): Promise<void> {
|
||||||
|
const managed = this.plugins.get(pluginId);
|
||||||
|
if (!managed) return;
|
||||||
|
|
||||||
|
const wasEnabled = managed.enabled;
|
||||||
|
const manifest = this.loadedManifests.get(pluginId);
|
||||||
|
if (!manifest) return;
|
||||||
|
|
||||||
|
// 1. Destroy old instance
|
||||||
|
try { managed.plugin.destroy(); } catch {}
|
||||||
|
pollingManager.stop(pluginId);
|
||||||
|
this.plugins.delete(pluginId);
|
||||||
|
|
||||||
|
// 2. Cache-bust and re-import
|
||||||
|
const bustEntry = `${manifest.entry}?t=${Date.now()}`;
|
||||||
|
const newManifest = { ...manifest, entry: bustEntry };
|
||||||
|
|
||||||
|
// 3. Re-register
|
||||||
|
try {
|
||||||
|
const plugin = await loadPluginFromManifest(newManifest);
|
||||||
|
if (manifest.id && plugin.id !== manifest.id) {
|
||||||
|
plugin.id = manifest.id;
|
||||||
|
}
|
||||||
|
this.loadedManifests.set(manifest.id, newManifest);
|
||||||
|
await this.registerPlugin(plugin);
|
||||||
|
|
||||||
|
// 4. Restore state
|
||||||
|
if (wasEnabled) {
|
||||||
|
await this.enablePlugin(pluginId);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`[PluginManager] 🔄 Hot-reloaded "${pluginId}"`);
|
||||||
|
} catch (err) {
|
||||||
|
console.error(`[PluginManager] ❌ Failed to hot-reload "${pluginId}":`, err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
destroy(): void {
|
destroy(): void {
|
||||||
pollingManager.stopAll();
|
pollingManager.stopAll();
|
||||||
this.plugins.forEach((managed) => {
|
this.plugins.forEach((managed) => {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export interface ValidationResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const VALID_TYPES = ["data-layer", "extension"] as const;
|
const VALID_TYPES = ["data-layer", "extension"] as const;
|
||||||
const VALID_TRUSTS = ["built-in", "verified", "unverified"] as const;
|
const VALID_TRUSTS = ["built-in", "verified", "unverified", "developer"] as const;
|
||||||
|
|
||||||
export function validateManifest(
|
export function validateManifest(
|
||||||
manifest: Partial<PluginManifest>,
|
manifest: Partial<PluginManifest>,
|
||||||
|
|||||||
@@ -82,11 +82,11 @@ export const createUISlice: StateCreator<AppStore, [], [], UISlice> = (set) => (
|
|||||||
}
|
}
|
||||||
set((state) => ({
|
set((state) => ({
|
||||||
selectedEntity: entity,
|
selectedEntity: entity,
|
||||||
rightSidebarOpen: entity !== null,
|
rightSidebarOpen: entity !== null ? true : state.rightSidebarOpen,
|
||||||
configPanelOpen: entity !== null,
|
configPanelOpen: entity !== null ? true : state.configPanelOpen,
|
||||||
openMobilePanel: entity !== null ? state.openMobilePanel : null,
|
openMobilePanel: entity !== null ? state.openMobilePanel : null,
|
||||||
mobileRightPanelGlow: entity !== null,
|
mobileRightPanelGlow: entity !== null,
|
||||||
activeConfigTab: entity !== null ? "intel" : "filters"
|
activeConfigTab: entity !== null ? "intel" : state.activeConfigTab
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
setHoveredEntity: (entity, screenPos) =>
|
setHoveredEntity: (entity, screenPos) =>
|
||||||
|
|||||||
Reference in new issue
Block a user