Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
544c8e26f0 | ||
|
|
d5e4003dde |
No files matched your search
@@ -72,6 +72,23 @@ mapWebsocketPayload(payload: any, existingEntities: GeoEntity[]): GeoEntity[]
|
||||
- `existingEntities` — current entities in the store for this plugin (use for incremental updates)
|
||||
- Must return a **complete replacement** `GeoEntity[]` (not a diff)
|
||||
|
||||
### Property Tag Helpers
|
||||
|
||||
Always wrap typed property values with the SDK helpers so the Intel panel renders them richly:
|
||||
|
||||
```ts
|
||||
import { dtProp, urlProp, imageProp, videoProp } from "@worldwideview/wwv-plugin-sdk";
|
||||
|
||||
properties: {
|
||||
updated: dtProp(item.updated_at ?? null), // renders as expandable datetime row
|
||||
source: urlProp(item.source_url ?? null), // renders as clickable link
|
||||
preview: imageProp(item.image ?? null), // renders as inline thumbnail
|
||||
stream: videoProp(item.video_url ?? null), // renders as "Watch" link
|
||||
}
|
||||
```
|
||||
|
||||
All helpers are null-safe and return `null` for empty input. Plain string/number values that don't need rich rendering need no wrapper.
|
||||
|
||||
---
|
||||
|
||||
## Plugin Architectures (Manifest Formats)
|
||||
|
||||
@@ -202,7 +202,40 @@ import { Plane } from "lucide-react";
|
||||
const iconUrl = createSvgIconUrl(Plane, { color: "#3b82f6" });
|
||||
```
|
||||
|
||||
### 1.5 Registration (3 Paths)
|
||||
### 1.5 Property Tag Helpers
|
||||
|
||||
Use these SDK helpers to wrap property values so the Intel panel renders them richly. Without the tag prefix, the panel falls back to plain text.
|
||||
|
||||
```ts
|
||||
import { dtProp, urlProp, imageProp, videoProp } from "@worldwideview/wwv-plugin-sdk";
|
||||
```
|
||||
|
||||
| Helper | Tag format stored | Panel renders as |
|
||||
|---|---|---|
|
||||
| `dtProp(iso)` | `"datetime:2026-06-01T05:00:00Z"` | Expandable row: local time (collapsed), UTC + relative (expanded) |
|
||||
| `urlProp(href)` | `"url:https://..."` | Clickable link with external icon |
|
||||
| `imageProp(src)` | `"image:https://..."` | Inline thumbnail |
|
||||
| `videoProp(href)` | `"video:https://..."` | "Watch" link with play icon |
|
||||
|
||||
All four helpers return `null` for empty, `null`, or `undefined` input — safe to call unconditionally.
|
||||
|
||||
**Usage pattern:**
|
||||
```ts
|
||||
properties: {
|
||||
// dates — pass ISO 8601 strings
|
||||
updated_at: dtProp(item.updated_at ?? null),
|
||||
// URLs
|
||||
source_url: urlProp(item.url ?? null),
|
||||
// images and video
|
||||
preview: imageProp(item.image_url ?? null),
|
||||
stream: videoProp(item.video_url ?? null),
|
||||
// plain values — no helper needed
|
||||
name: item.name,
|
||||
count: item.count,
|
||||
}
|
||||
```
|
||||
|
||||
### 1.6 Registration (3 Paths)
|
||||
|
||||
**A. Built-in (monorepo package):**
|
||||
|
||||
@@ -224,7 +257,7 @@ await pluginManager.registerPlugin(plugin);
|
||||
**C. Dynamic import (runtime):**
|
||||
For user-imported GeoJSON layers, call `pluginManager.loadFromManifest(manifest)` directly.
|
||||
|
||||
### 1.6 Build Configuration (Core Monorepo Packages Only)
|
||||
### 1.7 Build Configuration (Core Monorepo Packages Only)
|
||||
|
||||
If you decide to manually move a plugin from the local sandbox into the core `packages/` directory, you must manually add it to the build pipeline:
|
||||
|
||||
@@ -652,6 +685,10 @@ Categories are **lowercase**: `"aviation"` not `"Aviation"`, `"natural-disaster"
|
||||
- [ ] **Frontend:** Added path alias in `tsconfig.json`
|
||||
- [ ] **Frontend:** Registered via `pluginRegistry` + `pluginManager` in `AppShell.tsx`
|
||||
- [ ] **Frontend:** `renderEntity()` doesn't mix point/billboard properties
|
||||
- [ ] **Frontend:** Date/time fields wrapped with `dtProp()`
|
||||
- [ ] **Frontend:** External links wrapped with `urlProp()`
|
||||
- [ ] **Frontend:** Image URLs wrapped with `imageProp()`
|
||||
- [ ] **Frontend:** Video/stream URLs wrapped with `videoProp()`
|
||||
- [ ] **Engine:** Seeder file in `wwv-seeders/src/seeders/<name>.ts` (or private repo)
|
||||
- [ ] **Engine:** `registerSeeder({ name })` matches frontend plugin `id`
|
||||
- [ ] **Engine:** Calls `setLiveSnapshot()` with correct plugin ID key
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "worldwideview",
|
||||
"version": "2.24.5",
|
||||
"version": "2.25.1",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"packageManager": "[email protected]",
|
||||
|
||||
@@ -52,6 +52,38 @@ export class MyPlugin implements WorldPlugin {
|
||||
}
|
||||
```
|
||||
|
||||
## Property Tag Helpers
|
||||
|
||||
Wrap entity property values with these helpers so the WorldWideView Intel panel renders them as rich UI elements instead of plain text.
|
||||
|
||||
```ts
|
||||
import { dtProp, urlProp, imageProp, videoProp } from "@worldwideview/wwv-plugin-sdk";
|
||||
```
|
||||
|
||||
| Helper | Wraps | Panel renders as |
|
||||
|---|---|---|
|
||||
| `dtProp(iso: string \| null)` | ISO 8601 date string | Expandable datetime row — local time collapsed, UTC + relative time expanded |
|
||||
| `urlProp(href: string \| null)` | Any URL | Clickable link with external-link icon |
|
||||
| `imageProp(src: string \| null)` | Image URL | Inline thumbnail |
|
||||
| `videoProp(href: string \| null)` | Video/stream URL | "Watch" link with play icon |
|
||||
|
||||
All helpers are **null-safe**: passing `null`, `undefined`, or `""` returns `null`, which the panel skips cleanly.
|
||||
|
||||
```ts
|
||||
// In your entity mapper:
|
||||
properties: {
|
||||
last_seen: dtProp(item.timestamp ?? null),
|
||||
source_url: urlProp(item.url ?? null),
|
||||
preview: imageProp(item.image_url ?? null),
|
||||
live_stream: videoProp(item.stream ?? null),
|
||||
// Plain values need no wrapper
|
||||
name: item.name,
|
||||
severity: item.severity,
|
||||
}
|
||||
```
|
||||
|
||||
Values without a tag prefix fall back to plain-text rendering, so existing plugins continue to work unchanged.
|
||||
|
||||
## Changelog
|
||||
|
||||
- **v1.0.3** — Added README with core interfaces and usage docs.
|
||||
|
||||
@@ -313,3 +313,45 @@ export * from "./viteGlobals";
|
||||
|
||||
// ─── Auth Contracts ──────────────────────────────────────────
|
||||
export * from "./auth-contracts";
|
||||
|
||||
// ─── Tagged Property Helpers ─────────────────────────────────
|
||||
/**
|
||||
* Wraps an ISO 8601 date string for rich rendering in the Intel panel.
|
||||
* The panel displays local time (collapsed) and UTC + relative time (expanded).
|
||||
* @param iso - ISO 8601 string (e.g. "2026-06-01T05:00:00Z"), or null/undefined
|
||||
* @returns Tagged string `"datetime:{iso}"`, or `null` if input is empty
|
||||
*/
|
||||
export function dtProp(iso: string | undefined | null): string | null {
|
||||
if (!iso) return null;
|
||||
return `datetime:${iso}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps a URL for rich rendering in the Intel panel as a clickable external link.
|
||||
* @param href - Any URL string, or null/undefined
|
||||
* @returns Tagged string `"url:{href}"`, or `null` if input is empty
|
||||
*/
|
||||
export function urlProp(href: string | undefined | null): string | null {
|
||||
if (!href) return null;
|
||||
return `url:${href}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps an image URL for rich rendering in the Intel panel as an inline thumbnail.
|
||||
* @param src - Image URL string, or null/undefined
|
||||
* @returns Tagged string `"image:{src}"`, or `null` if input is empty
|
||||
*/
|
||||
export function imageProp(src: string | undefined | null): string | null {
|
||||
if (!src) return null;
|
||||
return `image:${src}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps a video or stream URL for rich rendering in the Intel panel as a "Watch" link.
|
||||
* @param href - Video or stream URL string, or null/undefined
|
||||
* @returns Tagged string `"video:{href}"`, or `null` if input is empty
|
||||
*/
|
||||
export function videoProp(href: string | undefined | null): string | null {
|
||||
if (!href) return null;
|
||||
return `video:${href}`;
|
||||
}
|
||||
Generated
+1149
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,66 @@
|
||||
import { useState } from "react";
|
||||
import { IntelPropertyRow } from "./IntelPropertyRow";
|
||||
|
||||
function formatLocal(iso: string): string {
|
||||
return new Date(iso).toLocaleString(undefined, {
|
||||
day: "numeric", month: "2-digit", year: "numeric",
|
||||
hour: "numeric", minute: "2-digit", hour12: true, timeZoneName: "short",
|
||||
});
|
||||
}
|
||||
|
||||
function formatUtc(iso: string): string {
|
||||
return new Date(iso).toISOString().slice(0, 16).replace("T", " ") + " UTC";
|
||||
}
|
||||
|
||||
function formatRelative(iso: string): string {
|
||||
const diff = new Date(iso).getTime() - Date.now();
|
||||
const abs = Math.abs(diff);
|
||||
const future = diff > 0;
|
||||
if (abs < 60_000) return "just now";
|
||||
if (abs < 3_600_000) {
|
||||
const n = Math.round(abs / 60_000);
|
||||
return future ? `in ${n}m` : `${n}m ago`;
|
||||
}
|
||||
if (abs < 86_400_000) {
|
||||
const n = Math.round(abs / 3_600_000);
|
||||
return future ? `in ${n}h` : `${n}h ago`;
|
||||
}
|
||||
const n = Math.round(abs / 86_400_000);
|
||||
return future ? `in ${n}d` : `${n}d ago`;
|
||||
}
|
||||
|
||||
interface DatetimePropertyRowProps {
|
||||
label: string;
|
||||
iso: string;
|
||||
classNamePrefix?: string;
|
||||
}
|
||||
|
||||
export function DatetimePropertyRow({ label, iso, classNamePrefix = "intel-panel" }: DatetimePropertyRowProps) {
|
||||
const [expanded, setExpanded] = useState(false);
|
||||
|
||||
if (expanded) {
|
||||
return (
|
||||
<IntelPropertyRow label={label} isColumn classNamePrefix={classNamePrefix}>
|
||||
<span
|
||||
style={{ cursor: "pointer", fontWeight: 600 }}
|
||||
onClick={() => setExpanded(false)}
|
||||
>
|
||||
{formatLocal(iso)}
|
||||
</span>
|
||||
<span style={{ opacity: 0.6, fontSize: "0.85em" }}>{formatUtc(iso)}</span>
|
||||
<span style={{ opacity: 0.6, fontSize: "0.85em" }}>{formatRelative(iso)}</span>
|
||||
</IntelPropertyRow>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<IntelPropertyRow label={label} classNamePrefix={classNamePrefix}>
|
||||
<span
|
||||
style={{ cursor: "pointer", textDecoration: "underline dotted" }}
|
||||
onClick={() => setExpanded(true)}
|
||||
>
|
||||
{formatLocal(iso)}
|
||||
</span>
|
||||
</IntelPropertyRow>
|
||||
);
|
||||
}
|
||||
@@ -11,6 +11,8 @@ import { ImageProperty } from './ImageProperty';
|
||||
import { UrlProperty } from './UrlProperty';
|
||||
import { LongTextProperty } from './LongTextProperty';
|
||||
import { IntelPropertyRow } from './IntelPropertyRow';
|
||||
import { DatetimePropertyRow } from "./DatetimePropertyRow";
|
||||
import { VideoProperty } from "./VideoProperty";
|
||||
|
||||
/**
|
||||
* @interface DynamicPropertiesRenderProps
|
||||
@@ -37,6 +39,52 @@ export function DynamicPropertiesRender({ entity, classNamePrefix = "intel-panel
|
||||
const label = key.replace(/_/g, " ");
|
||||
const stringValue = String(value);
|
||||
|
||||
// Tagged dispatch - explicit type prefix, checked before heuristics
|
||||
if (typeof value === "string") {
|
||||
if (value.startsWith("datetime:")) {
|
||||
return (
|
||||
<DatetimePropertyRow
|
||||
key={key}
|
||||
label={label}
|
||||
iso={value.slice(9)}
|
||||
classNamePrefix={classNamePrefix}
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (value.startsWith("url:")) {
|
||||
return (
|
||||
<UrlProperty
|
||||
key={key}
|
||||
label={label}
|
||||
url={value.slice(4)}
|
||||
classNamePrefix={classNamePrefix}
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (value.startsWith("image:")) {
|
||||
return (
|
||||
<ImageProperty
|
||||
key={key}
|
||||
label={label}
|
||||
imageUrl={value.slice(6)}
|
||||
entityId={entity.id}
|
||||
entityLabel={entity.label ?? ""}
|
||||
classNamePrefix={classNamePrefix}
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (value.startsWith("video:")) {
|
||||
return (
|
||||
<VideoProperty
|
||||
key={key}
|
||||
label={label}
|
||||
href={value.slice(6)}
|
||||
classNamePrefix={classNamePrefix}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Identify property type
|
||||
const isImage = typeof value === "string" && key.toLowerCase().includes("image") && /^https?:\/\//i.test(value);
|
||||
const isUrl = !isImage && typeof value === "string" && /^https?:\/\//i.test(value);
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
import { PlayCircle } from "lucide-react";
|
||||
import { IntelPropertyRow } from "./IntelPropertyRow";
|
||||
|
||||
interface VideoPropertyProps {
|
||||
label: string;
|
||||
href: string;
|
||||
classNamePrefix?: string;
|
||||
}
|
||||
|
||||
export function VideoProperty({ label, href, classNamePrefix = "intel-panel" }: VideoPropertyProps) {
|
||||
return (
|
||||
<IntelPropertyRow label={label} classNamePrefix={classNamePrefix}>
|
||||
<a
|
||||
href={href}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
style={{ display: "flex", alignItems: "center", gap: 4, color: "var(--accent-cyan)" }}
|
||||
>
|
||||
<PlayCircle size={14} />
|
||||
Watch
|
||||
</a>
|
||||
</IntelPropertyRow>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user