Route Eve browser shell through Hermodr
This commit is contained in:
parent
f909b274fa
commit
6d685e3a70
4 changed files with 170 additions and 1482 deletions
69
web/fixtures/cultui-embedded-surface.json
Normal file
69
web/fixtures/cultui-embedded-surface.json
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
{
|
||||
"type": "surface-state",
|
||||
"schema": "gamecult.eve.surface.v1",
|
||||
"providerId": "gamecult.eve.embedded-demo",
|
||||
"providerKind": "surface.fixture",
|
||||
"title": "Embedded Surface Slots",
|
||||
"version": 1,
|
||||
"updatedAtUtc": "2026-06-29T00:00:00Z",
|
||||
"surface": {
|
||||
"id": "gamecult.eve.embedded-demo",
|
||||
"root": {
|
||||
"id": "gamecult.eve.embedded-demo.root",
|
||||
"kind": "surface",
|
||||
"props": {},
|
||||
"children": [
|
||||
{
|
||||
"id": "gamecult.eve.embedded-demo.summary",
|
||||
"kind": "card",
|
||||
"props": {
|
||||
"title": "Parent Surface"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"id": "gamecult.eve.embedded-demo.summary.text",
|
||||
"kind": "text",
|
||||
"props": {
|
||||
"value": "The parent owns layout while the child remains a separately synced CultMesh document."
|
||||
},
|
||||
"children": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "gamecult.eve.embedded-demo.child-slot",
|
||||
"kind": "surface.slot",
|
||||
"props": {
|
||||
"slotId": "inventory.dropdown",
|
||||
"documentId": "cultmesh://demo/inventory/dropdown",
|
||||
"schemaId": "gamecult.eve.surface.v1",
|
||||
"presentationKind": "inventory.dropdown"
|
||||
},
|
||||
"children": [],
|
||||
"embeddedDocuments": [
|
||||
{
|
||||
"slotId": "inventory.dropdown",
|
||||
"documentId": "cultmesh://demo/inventory/dropdown",
|
||||
"schemaId": "gamecult.eve.surface.v1",
|
||||
"presentationKind": "inventory.dropdown",
|
||||
"routeHint": {
|
||||
"kind": "Automatic",
|
||||
"description": "fixture"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"styles": {
|
||||
"tokens": {
|
||||
"colorBackground": "#071014",
|
||||
"colorPanel": "#111B22",
|
||||
"colorText": "#E9F5F7",
|
||||
"colorMuted": "#8CA9AE",
|
||||
"colorAccent": "#6EE7D8"
|
||||
}
|
||||
}
|
||||
},
|
||||
"commands": []
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Eve Surface Reference</title>
|
||||
<link rel="stylesheet" href="./styles.css" />
|
||||
<link rel="stylesheet" href="../packages/eve-browser-lowering/styles.css" />
|
||||
</head>
|
||||
<body>
|
||||
<header class="topbar">
|
||||
|
|
|
|||
703
web/styles.css
703
web/styles.css
|
|
@ -1,703 +0,0 @@
|
|||
@import url("https://fonts.googleapis.com/css2?family=M+PLUS+1:wght@100;300;400;500;700&family=Montserrat:wght@100;300;400;500;700&family=Ubuntu+Sans:wght@300;400;500;700&family=Zen+Kaku+Gothic+New:wght@300;400;500;700&display=swap");
|
||||
|
||||
:root {
|
||||
color-scheme: dark;
|
||||
--bg: #020909;
|
||||
--bg-top: var(--bg);
|
||||
--bg-mid: var(--bg);
|
||||
--bg-bottom: var(--bg);
|
||||
--shell-top: #010707;
|
||||
--shell-bottom: #010707;
|
||||
--panel: #071918;
|
||||
--panel-2: #0a2423;
|
||||
--line: rgba(103, 240, 228, 0.28);
|
||||
--line-deep: rgba(103, 240, 228, 0.18);
|
||||
--line-hot: rgba(142, 252, 255, 0.72);
|
||||
--text: #e7f1f1;
|
||||
--text-bright: var(--text);
|
||||
--quiet: #8ba5a3;
|
||||
--accent: #ffb84f;
|
||||
--accent-strong: var(--accent);
|
||||
--corner-accent: var(--accent);
|
||||
--cyan: #8efcff;
|
||||
--shadow: rgba(0, 0, 0, 0.35);
|
||||
--pixel-grid: rgba(142, 252, 255, 0.04);
|
||||
--border-width: 1px;
|
||||
--border-bottom-width: var(--border-width);
|
||||
--corner-accent-size: 0;
|
||||
--font-body: "M PLUS 1", "Ubuntu Sans", Ubuntu, "Noto Sans JP", system-ui, sans-serif;
|
||||
--font-title: "Montserrat", "Zen Kaku Gothic New", "M PLUS 1", "Ubuntu Sans", system-ui, sans-serif;
|
||||
--font-mono: "Ubuntu Sans Mono", "M PLUS 1 Code", "Cascadia Mono", Consolas, monospace;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
min-height: 100vh;
|
||||
background: linear-gradient(180deg, var(--bg-top), var(--bg-mid), var(--bg-bottom));
|
||||
color: var(--text);
|
||||
font-family: var(--font-body);
|
||||
}
|
||||
|
||||
.topbar {
|
||||
height: 84px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 10px 16px;
|
||||
border-bottom: 1px solid var(--line);
|
||||
background: linear-gradient(180deg, var(--shell-top), var(--shell-bottom));
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
font-size: 20px;
|
||||
letter-spacing: 0;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 4px 0 0;
|
||||
color: var(--quiet);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.hud {
|
||||
min-width: 168px;
|
||||
padding: 8px;
|
||||
border: 1px solid var(--line-hot);
|
||||
border-radius: 6px;
|
||||
background: rgba(7, 25, 24, 0.88);
|
||||
color: var(--accent);
|
||||
font-family: "Cascadia Mono", Consolas, monospace;
|
||||
font-size: 11px;
|
||||
display: grid;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.provider-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 10px 16px;
|
||||
border-bottom: 1px solid var(--line-deep);
|
||||
background: color-mix(in srgb, var(--panel) 70%, transparent);
|
||||
}
|
||||
|
||||
.provider-bar label {
|
||||
color: var(--quiet);
|
||||
font: 700 11px var(--font-mono);
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.provider-bar select {
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 6px;
|
||||
background: var(--panel);
|
||||
color: var(--text);
|
||||
padding: 8px 12px;
|
||||
font: 700 13px var(--font-mono);
|
||||
min-width: min(28rem, 52vw);
|
||||
}
|
||||
|
||||
.provider-meta {
|
||||
color: var(--quiet);
|
||||
font: 600 11px var(--font-mono);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.surface {
|
||||
padding: 10px 16px 16px;
|
||||
}
|
||||
|
||||
.cockpit {
|
||||
display: grid;
|
||||
grid-template-columns: 0.78fr 1.08fr 1.34fr;
|
||||
gap: 10px;
|
||||
min-height: calc(100vh - 138px);
|
||||
}
|
||||
|
||||
.ctb {
|
||||
grid-column: 1 / -1;
|
||||
min-height: 88px;
|
||||
overflow-x: auto;
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
|
||||
.pane {
|
||||
min-height: 0;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 6px;
|
||||
background: rgba(7, 25, 24, 0.92);
|
||||
padding: 12px;
|
||||
box-shadow: 0 12px 26px var(--shadow);
|
||||
}
|
||||
|
||||
.pane h2 {
|
||||
margin: 0 0 10px;
|
||||
color: var(--quiet);
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.card {
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 6px;
|
||||
background: rgba(10, 36, 35, 0.96);
|
||||
padding: 10px;
|
||||
box-shadow: 0 8px 20px var(--shadow);
|
||||
}
|
||||
|
||||
.cultui-card[data-command-id] {
|
||||
cursor: pointer;
|
||||
border-bottom-width: var(--border-bottom-width);
|
||||
}
|
||||
|
||||
.ctb .card {
|
||||
flex: 0 0 96px;
|
||||
min-height: 76px;
|
||||
padding: 6px;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
border-radius: 50%;
|
||||
border: 1px solid var(--line-hot);
|
||||
object-fit: cover;
|
||||
background: #123;
|
||||
}
|
||||
|
||||
.card-title {
|
||||
white-space: pre-line;
|
||||
margin-top: 4px;
|
||||
font: 700 11px var(--font-mono);
|
||||
}
|
||||
|
||||
.health {
|
||||
color: var(--accent);
|
||||
font: 700 10px var(--font-mono);
|
||||
}
|
||||
|
||||
.detail {
|
||||
white-space: pre-wrap;
|
||||
font: 600 12px var(--font-mono);
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.list {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.metrics {
|
||||
display: grid;
|
||||
gap: 9px;
|
||||
margin: 12px 0;
|
||||
}
|
||||
|
||||
.metric label {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
color: var(--quiet);
|
||||
font: 700 10px var(--font-mono);
|
||||
}
|
||||
|
||||
.bar {
|
||||
height: 7px;
|
||||
border-radius: 7px;
|
||||
background: #010707;
|
||||
border: 1px solid rgba(255, 255, 255, 0.12);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.bar span {
|
||||
display: block;
|
||||
height: 100%;
|
||||
background: linear-gradient(90deg, #bca8ff, #8efcff);
|
||||
}
|
||||
|
||||
.graph {
|
||||
position: relative;
|
||||
min-height: calc(100vh - 166px);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 6px;
|
||||
background:
|
||||
linear-gradient(var(--pixel-grid) 1px, transparent 1px),
|
||||
linear-gradient(90deg, var(--pixel-grid) 1px, transparent 1px),
|
||||
rgba(3, 15, 17, 0.94);
|
||||
background-size: 44px 44px;
|
||||
}
|
||||
|
||||
.node {
|
||||
position: absolute;
|
||||
transform: translate(-50%, -50%);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 7px;
|
||||
background: rgba(10, 36, 35, 0.95);
|
||||
padding: 10px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.node.selected {
|
||||
border-color: var(--line-hot);
|
||||
box-shadow: 0 0 0 1px rgba(142, 252, 255, 0.38);
|
||||
}
|
||||
|
||||
.node .detail {
|
||||
margin-top: 6px;
|
||||
color: var(--quiet);
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.cockpit {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
.cultui-vn-stage {
|
||||
position: relative;
|
||||
min-height: calc(100vh - 138px);
|
||||
overflow: hidden;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 6px;
|
||||
background: var(--bg);
|
||||
}
|
||||
|
||||
.cultui-grid {
|
||||
min-height: calc(100vh - 138px);
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
|
||||
gap: 10px;
|
||||
align-content: start;
|
||||
}
|
||||
|
||||
.cultui-surface-root {
|
||||
min-height: calc(100vh - 150px);
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
|
||||
gap: 12px;
|
||||
align-content: start;
|
||||
}
|
||||
|
||||
.cultui-surface-root[data-direction="vertical"] {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.cultui-surface-root[data-direction="horizontal"] {
|
||||
grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
|
||||
}
|
||||
|
||||
.cultui-pane {
|
||||
border-width: var(--border-width);
|
||||
border-bottom-width: var(--border-bottom-width);
|
||||
}
|
||||
|
||||
.cultui-partition {
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.cultui-partition.split-x {
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.cultui-partition.split-y,
|
||||
.cultui-partition.split-none {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.cultui-partition.split-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
|
||||
}
|
||||
|
||||
.cultui-partition[data-role="inspector.row"] {
|
||||
min-height: 34px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.06);
|
||||
border-radius: 4px;
|
||||
background: linear-gradient(180deg, rgba(32, 31, 43, 0.96), rgba(19, 20, 29, 0.96));
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 2px 8px rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
|
||||
.cultui-partition[data-role="inspector.label"] {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.cultui-label {
|
||||
color: var(--accent);
|
||||
font: 700 13px var(--font-mono);
|
||||
line-height: 1.15;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.cultui-slider {
|
||||
--cultui-slider-value: 0%;
|
||||
--part-bleed: 0px;
|
||||
position: relative;
|
||||
display: grid;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
min-height: 18px;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.cultui-slider-visual {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
overflow: visible;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.cultui-slider-input {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
opacity: 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.cultui-slider-part {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
display: block;
|
||||
transform: translateY(-50%);
|
||||
}
|
||||
|
||||
.cultui-slider-part.track {
|
||||
right: 0;
|
||||
left: 0;
|
||||
height: 6px;
|
||||
border-radius: 2px;
|
||||
background: rgba(0, 0, 0, 0.34);
|
||||
}
|
||||
|
||||
.cultui-slider-part.fill {
|
||||
left: 0;
|
||||
width: var(--cultui-slider-value);
|
||||
height: 6px;
|
||||
border-radius: 2px;
|
||||
background: var(--accent);
|
||||
}
|
||||
|
||||
.cultui-slider-part.thumb {
|
||||
left: var(--cultui-slider-value);
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
border-radius: 999px;
|
||||
background: var(--accent);
|
||||
transform: translate(-50%, -50%);
|
||||
box-shadow: 0 0 7px color-mix(in srgb, var(--accent) 45%, transparent);
|
||||
}
|
||||
|
||||
.cultui-slider-part[data-anchor-value="true"] {
|
||||
left: var(--cultui-slider-value);
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
@media (max-width: 520px) {
|
||||
.cultui-partition[data-role="inspector.row"] {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.cultui-partition[data-role="inspector.label"] {
|
||||
flex: 0 0 auto !important;
|
||||
}
|
||||
}
|
||||
|
||||
body[data-provider="repixelizer"] .surface {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
body[data-provider="repixelizer"] .surface::after {
|
||||
content: "";
|
||||
pointer-events: none;
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 4px);
|
||||
opacity: 0.28;
|
||||
mix-blend-mode: screen;
|
||||
}
|
||||
|
||||
body[data-pixel-art="true"] img,
|
||||
body[data-pixel-art="true"] .cultui-background {
|
||||
image-rendering: pixelated;
|
||||
}
|
||||
|
||||
.cultui-title {
|
||||
color: var(--accent);
|
||||
font: 100 18px var(--font-title);
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
.mono {
|
||||
color: var(--accent);
|
||||
font-family: var(--font-mono);
|
||||
}
|
||||
|
||||
.cultui-reactive-metric {
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.cultui-reactive-list {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.cultui-stream-item {
|
||||
border-left: 2px solid var(--line-hot);
|
||||
padding-left: 8px;
|
||||
}
|
||||
|
||||
.cultui-background {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
image-rendering: pixelated;
|
||||
opacity: 0.72;
|
||||
}
|
||||
|
||||
.cultui-graph {
|
||||
position: absolute;
|
||||
top: 18px;
|
||||
left: 18px;
|
||||
width: min(48rem, 46vw);
|
||||
height: min(29rem, 52vh);
|
||||
z-index: 4;
|
||||
}
|
||||
|
||||
.cultui-placed {
|
||||
position: absolute;
|
||||
transform-origin: center;
|
||||
}
|
||||
|
||||
.cultui-placed[data-placement-mode="keystone"],
|
||||
.cultui-placed[data-placement-mode="skew"],
|
||||
.cultui-placed[data-placement-mode="sprite-chromakey"] {
|
||||
box-shadow: 0 12px 26px rgba(0, 0, 0, 0.28);
|
||||
}
|
||||
|
||||
.cultui-placed[data-chroma-key] {
|
||||
outline: 1px dashed rgba(0, 255, 120, 0.45);
|
||||
}
|
||||
|
||||
.cultui-node {
|
||||
position: absolute;
|
||||
transform: translate(-50%, -50%);
|
||||
border: 2px solid var(--cyan);
|
||||
border-radius: 999px;
|
||||
background: rgba(7, 17, 26, 0.76);
|
||||
color: var(--text);
|
||||
min-width: 68px;
|
||||
min-height: 44px;
|
||||
padding: 8px 10px;
|
||||
font: 700 12px "Cascadia Mono", Consolas, monospace;
|
||||
}
|
||||
|
||||
.cultui-node.selected {
|
||||
border-color: var(--accent);
|
||||
box-shadow: 0 0 0 2px rgba(255, 184, 79, 0.28);
|
||||
}
|
||||
|
||||
.cultui-graph svg {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.cultui-graph line {
|
||||
stroke: rgba(142, 252, 255, 0.36);
|
||||
stroke-width: 0.006;
|
||||
stroke-linecap: round;
|
||||
}
|
||||
|
||||
.cultui-layer-embedded-surfaces {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
z-index: 5;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.cultui-layer-embedded-surfaces > * {
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
.cultui-tex {
|
||||
min-width: 12rem;
|
||||
min-height: 3.2rem;
|
||||
border: 1px solid rgba(142, 252, 255, 0.34);
|
||||
border-radius: 6px;
|
||||
background: rgba(7, 17, 26, 0.78);
|
||||
color: var(--text);
|
||||
padding: 10px 12px;
|
||||
}
|
||||
|
||||
.cultui-tex-label {
|
||||
color: var(--accent);
|
||||
font: 700 10px "Cascadia Mono", Consolas, monospace;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.cultui-tex-source {
|
||||
margin-top: 4px;
|
||||
font: 700 15px "Cambria Math", "STIX Two Math", Georgia, serif;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.cultui-layer-cards {
|
||||
position: absolute;
|
||||
top: 18px;
|
||||
right: 18px;
|
||||
left: calc(min(48rem, 46vw) + 36px);
|
||||
z-index: 3;
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.cultui-dialogue {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
z-index: 5;
|
||||
min-height: 128px;
|
||||
border-right: 0;
|
||||
border-bottom: 0;
|
||||
border-left: 0;
|
||||
border-radius: 0;
|
||||
background: rgba(5, 8, 13, 0.92);
|
||||
}
|
||||
|
||||
.cultui-rail-actions {
|
||||
position: absolute;
|
||||
right: 18px;
|
||||
bottom: 18px;
|
||||
z-index: 6;
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
width: min(28rem, 42vw);
|
||||
}
|
||||
|
||||
.cultui-button {
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 6px;
|
||||
background: rgba(10, 36, 35, 0.94);
|
||||
color: var(--text);
|
||||
padding: 9px 10px;
|
||||
text-align: left;
|
||||
font: 700 12px "Cascadia Mono", Consolas, monospace;
|
||||
}
|
||||
|
||||
.cultui-button:hover,
|
||||
.cultui-button:focus-visible {
|
||||
border-color: var(--line-hot);
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.cultui-image-preview {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.cultui-image-frame,
|
||||
.cultui-canvas-grid {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
min-height: 160px;
|
||||
border: 2px solid var(--panel-border);
|
||||
background:
|
||||
repeating-linear-gradient(45deg, rgba(247, 239, 216, 0.06) 0 8px, rgba(0, 0, 0, 0.18) 8px 16px),
|
||||
linear-gradient(180deg, #07172c, #0a2039);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.cultui-image-frame {
|
||||
aspect-ratio: 1 / 1;
|
||||
}
|
||||
|
||||
.cultui-image-frame img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.cultui-image-preview figcaption,
|
||||
.cultui-canvas-grid {
|
||||
color: var(--muted);
|
||||
font-size: 0.75rem;
|
||||
line-height: 1.25;
|
||||
}
|
||||
|
||||
.cultui-canvas-placeholder {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.cultui-canvas-placeholder.editor .cultui-canvas-grid {
|
||||
min-height: 280px;
|
||||
background:
|
||||
linear-gradient(45deg, rgba(255,255,255,0.08) 25%, transparent 25% 75%, rgba(255,255,255,0.08) 75%),
|
||||
linear-gradient(45deg, rgba(255,255,255,0.08) 25%, transparent 25% 75%, rgba(255,255,255,0.08) 75%),
|
||||
#142033;
|
||||
background-position: 0 0, 8px 8px;
|
||||
background-size: 16px 16px;
|
||||
}
|
||||
|
||||
.cultui-status-stage {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
padding: 12px;
|
||||
border: 2px solid var(--panel-border);
|
||||
background: rgba(6, 22, 39, 0.92);
|
||||
}
|
||||
|
||||
.cultui-field {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.cultui-field-value {
|
||||
display: block;
|
||||
border: 2px solid var(--panel-border);
|
||||
background: rgba(1, 4, 11, 0.58);
|
||||
padding: 6px 8px;
|
||||
}
|
||||
|
||||
.cultui-swatch {
|
||||
width: 36px;
|
||||
min-height: 36px;
|
||||
border: 2px solid var(--accent);
|
||||
box-shadow: inset 0 0 0 2px rgba(0,0,0,0.45);
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.cultui-graph {
|
||||
right: 12px;
|
||||
left: 12px;
|
||||
width: auto;
|
||||
height: min(18rem, 34vh);
|
||||
}
|
||||
|
||||
.cultui-layer-cards {
|
||||
top: calc(30px + min(18rem, 34vh));
|
||||
right: 12px;
|
||||
left: 12px;
|
||||
}
|
||||
|
||||
.cultui-rail-actions {
|
||||
left: 12px;
|
||||
width: auto;
|
||||
}
|
||||
}
|
||||
886
web/surface.js
886
web/surface.js
|
|
@ -1,3 +1,8 @@
|
|||
import {
|
||||
createEveCommandIntent,
|
||||
emptyState,
|
||||
renderEveSurface,
|
||||
} from "../packages/eve-browser-lowering/dist/index.js";
|
||||
import { compileEveDsl } from "./eve-dsl.js";
|
||||
|
||||
const statusEl = document.querySelector("#status");
|
||||
|
|
@ -7,48 +12,11 @@ const surfaceVersion = document.querySelector("#surface-version");
|
|||
const providerSelect = document.querySelector("#provider-select");
|
||||
const providerMeta = document.querySelector("#provider-meta");
|
||||
|
||||
let socket;
|
||||
let providers = [];
|
||||
let currentProvider;
|
||||
let currentSurfaceStyles = {};
|
||||
let activeFontStylesheet;
|
||||
|
||||
const defaultStyleTokens = {
|
||||
"--bg": "#020909",
|
||||
"--bg-top": "#020909",
|
||||
"--bg-mid": "#020909",
|
||||
"--bg-bottom": "#020909",
|
||||
"--shell-top": "#010707",
|
||||
"--shell-bottom": "#010707",
|
||||
"--panel": "#071918",
|
||||
"--panel-2": "#0a2423",
|
||||
"--line": "rgba(103, 240, 228, 0.28)",
|
||||
"--line-deep": "rgba(103, 240, 228, 0.18)",
|
||||
"--text": "#e7f1f1",
|
||||
"--text-bright": "#e7f1f1",
|
||||
"--quiet": "#8ba5a3",
|
||||
"--accent": "#ffb84f",
|
||||
"--accent-strong": "#ffb84f",
|
||||
"--corner-accent": "#ffb84f",
|
||||
"--cyan": "#8efcff",
|
||||
"--shadow": "rgba(0, 0, 0, 0.35)",
|
||||
"--pixel-grid": "rgba(142, 252, 255, 0.04)",
|
||||
"--border-width": "1px",
|
||||
"--border-bottom-width": "1px",
|
||||
"--corner-accent-size": "0",
|
||||
"--font-body": "\"M PLUS 1\", \"Ubuntu Sans\", Ubuntu, \"Noto Sans JP\", system-ui, sans-serif",
|
||||
"--font-title": "\"Montserrat\", \"Zen Kaku Gothic New\", \"M PLUS 1\", \"Ubuntu Sans\", system-ui, sans-serif",
|
||||
"--font-mono": "\"Ubuntu Sans Mono\", \"M PLUS 1 Code\", \"Cascadia Mono\", Consolas, monospace",
|
||||
};
|
||||
let liveHermodr = false;
|
||||
|
||||
const localProviders = [
|
||||
{
|
||||
providerId: "voidbot.swarm",
|
||||
title: "VoidBot Live",
|
||||
kind: "service.operator",
|
||||
freshness: { state: "live" },
|
||||
surfaces: [{ transport: "mimir-eve-deck", surfaceId: "voidbot.swarm" }],
|
||||
},
|
||||
{
|
||||
providerId: "repixelizer",
|
||||
title: "Repixelizer",
|
||||
|
|
@ -92,6 +60,13 @@ const localProviders = [
|
|||
freshness: { state: "fixture" },
|
||||
surfaces: [{ transport: "local-eve-dsl", surfaceId: "eve.cultui.inspector", url: "./fixtures/cultui-slider-inspector.eve" }],
|
||||
},
|
||||
{
|
||||
providerId: "gamecult.eve.embedded-demo",
|
||||
title: "Embedded Surface Slot",
|
||||
kind: "surface.fixture",
|
||||
freshness: { state: "fixture" },
|
||||
surfaces: [{ transport: "local-json", surfaceId: "gamecult.eve.embedded-demo", url: "./fixtures/cultui-embedded-surface.json" }],
|
||||
},
|
||||
];
|
||||
|
||||
providerSelect.addEventListener("change", () => {
|
||||
|
|
@ -102,7 +77,12 @@ providerSelect.addEventListener("change", () => {
|
|||
void bootProviders();
|
||||
|
||||
async function bootProviders() {
|
||||
providers = await Promise.all(localProviders.map(loadProviderAdvertisement));
|
||||
providers = await loadHermodrProviders();
|
||||
if (providers.length) {
|
||||
liveHermodr = true;
|
||||
} else {
|
||||
providers = await Promise.all(localProviders.map(loadProviderAdvertisement));
|
||||
}
|
||||
providerSelect.replaceChildren(...providers.map(provider => {
|
||||
const option = document.createElement("option");
|
||||
option.value = provider.providerId;
|
||||
|
|
@ -111,12 +91,45 @@ async function bootProviders() {
|
|||
}));
|
||||
const requestedProviderId = new URLSearchParams(location.search).get("provider");
|
||||
const firstProduct = providers.find(provider => provider.providerId === requestedProviderId || provider.aliases?.includes(requestedProviderId))
|
||||
|| providers.find(provider => provider.providerId === "aetheria.main_menu.root")
|
||||
|| providers.find(provider => provider.providerId === "aetheria.inventory.panel")
|
||||
|| providers.find(provider => provider.providerId === "repixelizer")
|
||||
|| providers[0];
|
||||
providerSelect.value = firstProduct.providerId;
|
||||
await openProvider(firstProduct);
|
||||
}
|
||||
|
||||
async function loadHermodrProviders() {
|
||||
try {
|
||||
const response = await fetch("/hermodr/verse/catalog", { cache: "no-store" });
|
||||
if (!response.ok) return [];
|
||||
const catalog = await response.json();
|
||||
const advertised = new Map();
|
||||
for (const provider of catalog.providers || []) {
|
||||
advertised.set(provider.id || provider.providerId, provider);
|
||||
}
|
||||
return (catalog.surfaces || [])
|
||||
.filter(surface => surface?.providerId && surface?.surface)
|
||||
.map(surface => {
|
||||
const provider = advertised.get(surface.providerId) || {};
|
||||
return {
|
||||
...provider,
|
||||
providerId: surface.providerId,
|
||||
title: surface.title || provider.title || surface.providerId,
|
||||
kind: provider.kind || "eve.surface",
|
||||
freshness: { state: "odin-visible-cultmesh" },
|
||||
surfaces: [{
|
||||
transport: "hermodr-surface",
|
||||
surfaceId: surface.providerId,
|
||||
url: `/hermodr/surface/${encodeURIComponent(surface.providerId)}`,
|
||||
}],
|
||||
};
|
||||
});
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
async function loadProviderAdvertisement(provider) {
|
||||
if (!provider.advertisement) return provider;
|
||||
const response = await fetch(provider.advertisement);
|
||||
|
|
@ -130,7 +143,6 @@ async function loadProviderAdvertisement(provider) {
|
|||
}
|
||||
|
||||
async function openProvider(provider) {
|
||||
closeSocket();
|
||||
currentProvider = provider;
|
||||
providerMeta.textContent = `${provider.kind || "provider"} | ${provider.providerId} | ${provider.freshness?.state || "unknown"}`;
|
||||
surfaceId.textContent = provider.providerId;
|
||||
|
|
@ -142,8 +154,9 @@ async function openProvider(provider) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (surface.transport === "mimir-eve-deck") {
|
||||
openVoidBot(provider);
|
||||
if (surface.transport === "hermodr-surface") {
|
||||
const response = await fetch(surface.url, { cache: "no-store" });
|
||||
renderSurface(await response.json(), "hermodr cultmesh");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -157,754 +170,63 @@ async function openProvider(provider) {
|
|||
renderSurface(await response.json(), "local fixture");
|
||||
}
|
||||
|
||||
function openVoidBot(provider) {
|
||||
const scheme = location.protocol === "https:" ? "wss:" : "ws:";
|
||||
const host = location.hostname || "127.0.0.1";
|
||||
const url = `${scheme}//${host}:8795/eve/deck`;
|
||||
statusEl.textContent = `connecting ${url}`;
|
||||
socket = new WebSocket(url);
|
||||
const activeSocket = socket;
|
||||
socket.addEventListener("open", () => {
|
||||
if (socket !== activeSocket) return;
|
||||
statusEl.textContent = "connected to Mimir Eve broker";
|
||||
activeSocket.send(JSON.stringify({ type: "open-provider", providerId: provider.providerId }));
|
||||
});
|
||||
socket.addEventListener("message", event => {
|
||||
if (socket !== activeSocket) return;
|
||||
const state = JSON.parse(event.data);
|
||||
if (state.providerId === "voidbot.swarm") {
|
||||
renderSurface(state, "live");
|
||||
}
|
||||
});
|
||||
socket.addEventListener("close", () => {
|
||||
if (socket !== activeSocket) return;
|
||||
statusEl.textContent = "Mimir broker disconnected";
|
||||
});
|
||||
socket.addEventListener("error", () => {
|
||||
if (socket !== activeSocket) return;
|
||||
statusEl.textContent = "Mimir broker error; is port 8795 running?";
|
||||
});
|
||||
}
|
||||
|
||||
function closeSocket() {
|
||||
if (socket) {
|
||||
socket.close();
|
||||
socket = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function renderSurface(state, source) {
|
||||
window.__eveCurrentMesh = state.mesh;
|
||||
currentSurfaceStyles = state.surface?.styles || {};
|
||||
surfaceId.textContent = state.providerId || "surface unknown";
|
||||
surfaceVersion.textContent = `v${state.version ?? "?"}`;
|
||||
statusEl.textContent = `${state.title || "surface"} (${source})`;
|
||||
applySurfaceStyles(state.surface?.styles);
|
||||
document.body.dataset.provider = state.providerId || currentProvider?.providerId || "";
|
||||
if (state.surface?.root) {
|
||||
app.replaceChildren(renderCultComponent(state.surface.root));
|
||||
} else if (state.providerId === "voidbot.swarm") {
|
||||
renderVoidBot(state);
|
||||
} else {
|
||||
renderGraphSurface(state);
|
||||
}
|
||||
}
|
||||
|
||||
function applySurfaceStyles(styles) {
|
||||
const tokens = styles?.tokens || {};
|
||||
const root = document.documentElement.style;
|
||||
loadFontStylesheet(styles?.assets?.fontCss);
|
||||
for (const [variable, value] of Object.entries(defaultStyleTokens)) {
|
||||
root.setProperty(variable, value);
|
||||
}
|
||||
const map = {
|
||||
colorBackground: "--bg",
|
||||
colorBackgroundTop: "--bg-top",
|
||||
colorBackgroundMid: "--bg-mid",
|
||||
colorBackgroundBottom: "--bg-bottom",
|
||||
colorShellSurfaceTop: "--shell-top",
|
||||
colorShellSurfaceBottom: "--shell-bottom",
|
||||
colorPanel: "--panel",
|
||||
colorPanelAlt: "--panel-2",
|
||||
colorPanelBorder: "--line",
|
||||
colorPanelBorderDeep: "--line-deep",
|
||||
colorText: "--text",
|
||||
colorTextBright: "--text-bright",
|
||||
colorMuted: "--quiet",
|
||||
colorAccent: "--accent",
|
||||
colorAccentStrong: "--accent-strong",
|
||||
colorCornerAccent: "--corner-accent",
|
||||
colorLink: "--cyan",
|
||||
colorShadow: "--shadow",
|
||||
colorPixelGrid: "--pixel-grid",
|
||||
};
|
||||
for (const [token, variable] of Object.entries(map)) {
|
||||
if (tokens[token]) root.setProperty(variable, tokens[token]);
|
||||
}
|
||||
if (tokens.fontBody) root.setProperty("--font-body", withJapaneseGuiFallback(tokens.fontBody));
|
||||
if (tokens.fontDisplay) root.setProperty("--font-title", withJapaneseGuiFallback(tokens.fontDisplay));
|
||||
if (tokens.fontTitle) root.setProperty("--font-title", withJapaneseGuiFallback(tokens.fontTitle));
|
||||
if (tokens.fontMono) root.setProperty("--font-mono", withJapaneseGuiFallback(tokens.fontMono));
|
||||
if (tokens.borderWidthPx) root.setProperty("--border-width", `${tokens.borderWidthPx}px`);
|
||||
if (tokens.borderBottomWidthPx) root.setProperty("--border-bottom-width", `${tokens.borderBottomWidthPx}px`);
|
||||
if (tokens.cornerAccentPx) root.setProperty("--corner-accent-size", `${tokens.cornerAccentPx}px`);
|
||||
document.body.dataset.pixelArt = tokens.pixelArt || tokens.imageRendering === "pixelated" ? "true" : "false";
|
||||
document.body.dataset.scanlines = tokens.scanlineOverlay ? "true" : "false";
|
||||
}
|
||||
|
||||
function loadFontStylesheet(href) {
|
||||
const normalized = typeof href === "string" ? href.trim() : "";
|
||||
if (activeFontStylesheet?.dataset.href === normalized) return;
|
||||
activeFontStylesheet?.remove();
|
||||
activeFontStylesheet = undefined;
|
||||
if (!normalized) return;
|
||||
const link = document.createElement("link");
|
||||
link.rel = "stylesheet";
|
||||
link.href = normalized;
|
||||
link.dataset.href = normalized;
|
||||
document.head.append(link);
|
||||
activeFontStylesheet = link;
|
||||
}
|
||||
|
||||
function withJapaneseGuiFallback(stack) {
|
||||
if (typeof stack !== "string" || stack.includes("Zen Kaku Gothic New") || stack.includes("M PLUS 1")) return stack;
|
||||
if (stack.includes("Montserrat")) {
|
||||
return `${stack}, "Zen Kaku Gothic New", "M PLUS 1", "Noto Sans JP", "Hiragino Sans", "Yu Gothic", sans-serif`;
|
||||
}
|
||||
if (stack.includes("Ubuntu")) {
|
||||
return `${stack}, "M PLUS 1", "Noto Sans JP", "Hiragino Sans", "Yu Gothic", sans-serif`;
|
||||
}
|
||||
return `${stack}, "Noto Sans JP", "Hiragino Sans", "Yu Gothic", sans-serif`;
|
||||
}
|
||||
|
||||
function renderCultComponent(node) {
|
||||
const kind = node.kind || "panel";
|
||||
const props = node.props || {};
|
||||
const layout = node.layout || {};
|
||||
const children = node.children || [];
|
||||
let rendered;
|
||||
|
||||
if (kind === "vn.stage") {
|
||||
const stage = el("section", "cultui-vn-stage");
|
||||
for (const child of children) stage.append(renderCultComponent(child));
|
||||
return stage;
|
||||
}
|
||||
|
||||
if (kind === "grid") {
|
||||
const grid = el("section", "cultui-grid");
|
||||
if (props.columns) grid.style.gridTemplateColumns = props.columns;
|
||||
for (const child of children) grid.append(renderCultComponent(child));
|
||||
return grid;
|
||||
}
|
||||
|
||||
if (kind === "partition") {
|
||||
const partition = el("section", `cultui-partition split-${props.split || "none"}`);
|
||||
applyBoxProps(partition, props);
|
||||
if (props.role) partition.dataset.role = props.role;
|
||||
for (const child of children) partition.append(renderCultComponent(child));
|
||||
return partition;
|
||||
}
|
||||
|
||||
if (kind === "image.background") {
|
||||
const view = el("div", "cultui-background");
|
||||
if (props.src) view.style.backgroundImage = `url("${props.src}")`;
|
||||
view.setAttribute("aria-label", props.label || "background");
|
||||
return placeComponent(view, props.placement);
|
||||
}
|
||||
|
||||
if (kind === "graph" || kind === "embed.norn") {
|
||||
return placeComponent(renderCultGraph(props), props.placement);
|
||||
}
|
||||
|
||||
if (kind === "embed.tex") {
|
||||
return placeComponent(renderCultTex(props), props.placement);
|
||||
}
|
||||
|
||||
if (
|
||||
kind === "layer.sprites" ||
|
||||
kind === "layer.cards" ||
|
||||
kind === "layer.embedded-surfaces" ||
|
||||
kind === "rail.actions"
|
||||
) {
|
||||
const layer = el("div", `cultui-${kind.replace(".", "-")}`);
|
||||
for (const child of children) layer.append(renderCultComponent(child));
|
||||
return layer;
|
||||
}
|
||||
|
||||
if (kind === "image.sprite") {
|
||||
const figure = el("figure", `cultui-sprite ${props.slot || "center"}`);
|
||||
if (props.src) {
|
||||
const image = el("img");
|
||||
image.src = props.src;
|
||||
image.alt = props.alt || props.actor || "";
|
||||
figure.append(image);
|
||||
}
|
||||
return figure;
|
||||
}
|
||||
|
||||
if (kind === "card.external") {
|
||||
const card = el("article", "card cultui-card");
|
||||
card.append(el("div", "card-title", props.title || props.key || "card"));
|
||||
card.append(el("div", "detail", props.selector || props.htmlRef || "provider-owned fragment"));
|
||||
return card;
|
||||
}
|
||||
|
||||
if (kind === "surface") {
|
||||
const surface = el("section", "cultui-surface-root");
|
||||
if (layout.direction) surface.dataset.direction = layout.direction;
|
||||
for (const child of children) surface.append(renderCultComponent(child));
|
||||
return surface;
|
||||
}
|
||||
|
||||
if (kind === "pane" || kind === "panel") {
|
||||
const pane = el("section", "pane cultui-pane");
|
||||
if (props.title || node.text) pane.append(el("h2", "", props.title || node.text));
|
||||
for (const child of children) pane.append(renderCultComponent(child));
|
||||
return pane;
|
||||
}
|
||||
|
||||
if (kind === "card") {
|
||||
const card = el("article", "card cultui-card");
|
||||
if (props.title || node.text) card.append(el("div", "card-title", props.title || node.text));
|
||||
for (const child of children) card.append(renderCultComponent(child));
|
||||
if (props.commandId || node.commandId) {
|
||||
card.dataset.commandId = props.commandId || node.commandId;
|
||||
card.tabIndex = 0;
|
||||
card.addEventListener("click", () => publishCommandIntent(card.dataset.commandId, props));
|
||||
card.addEventListener("keydown", event => {
|
||||
if (event.key === "Enter" || event.key === " ") {
|
||||
event.preventDefault();
|
||||
publishCommandIntent(card.dataset.commandId, props);
|
||||
}
|
||||
});
|
||||
}
|
||||
return card;
|
||||
}
|
||||
|
||||
if (kind === "panel.dialogue") {
|
||||
const panel = el("section", "cultui-dialogue pane");
|
||||
panel.append(el("h2", "", props.speaker || "Speaker"));
|
||||
panel.append(el("div", "detail", props.text || ""));
|
||||
for (const child of children) {
|
||||
if (child.kind !== "text.dialogue") panel.append(renderCultComponent(child));
|
||||
}
|
||||
return panel;
|
||||
}
|
||||
|
||||
if (kind === "avatar") {
|
||||
const image = el("img", "avatar");
|
||||
image.src = props.src || "";
|
||||
image.alt = props.label || "";
|
||||
return image;
|
||||
}
|
||||
|
||||
if (kind === "text.dialogue" || kind === "text" || kind === "text.title" || kind === "label") {
|
||||
const text = el("div", textClassName(kind, props), props.text || node.text || "");
|
||||
bindText(text, props);
|
||||
return text;
|
||||
}
|
||||
|
||||
if (kind === "metric") {
|
||||
return renderCultMetric(props);
|
||||
}
|
||||
|
||||
if (kind === "image.preview") {
|
||||
const figure = el("figure", "cultui-image-preview");
|
||||
const frame = el("div", "cultui-image-frame");
|
||||
if (props.src) {
|
||||
const image = el("img");
|
||||
image.src = props.src;
|
||||
image.alt = props.label || "";
|
||||
image.style.imageRendering = props.imageRendering || "auto";
|
||||
if (props.zoom) {
|
||||
image.style.transform = `scale(${props.zoom})`;
|
||||
image.style.transformOrigin = props.crop || "50% 50%";
|
||||
}
|
||||
frame.append(image);
|
||||
} else {
|
||||
frame.append(el("span", "", props.label || "image"));
|
||||
}
|
||||
figure.append(frame);
|
||||
if (props.label) figure.append(el("figcaption", "", props.label));
|
||||
return figure;
|
||||
}
|
||||
|
||||
if (kind === "canvas.preview" || kind === "canvas.editor") {
|
||||
const panel = el("div", `cultui-canvas-placeholder ${kind === "canvas.editor" ? "editor" : "preview"}`);
|
||||
panel.append(el("div", "viz-label", props.label || "Canvas"));
|
||||
panel.append(el("div", "cultui-canvas-grid", props.state === "empty" ? "waiting for pixels" : props.state || ""));
|
||||
return panel;
|
||||
}
|
||||
|
||||
if (kind === "status.stage") {
|
||||
const panel = el("section", "cultui-status-stage");
|
||||
panel.append(el("span", "status-badge", props.label || "Status"));
|
||||
panel.append(el("p", "status-stage", props.stage || ""));
|
||||
panel.append(el("p", "status-text", props.detail || ""));
|
||||
return panel;
|
||||
}
|
||||
|
||||
if (kind === "input.file" || kind === "dropzone") {
|
||||
const control = el("button", kind === "dropzone" ? "dropzone cultui-dropzone" : "cultui-button button-secondary", props.label || "Choose File");
|
||||
control.type = "button";
|
||||
return control;
|
||||
}
|
||||
|
||||
if (kind === "input.number" || kind === "input.select" || kind === "control.range") {
|
||||
const field = el("label", "field cultui-field");
|
||||
field.append(el("span", "field-label", props.label || ""));
|
||||
field.append(el("span", "field-control cultui-field-value", props.value === undefined ? "" : String(props.value)));
|
||||
return field;
|
||||
}
|
||||
|
||||
if (kind === "control.toggle") {
|
||||
const toggle = el("label", "toggle-row cultui-toggle");
|
||||
toggle.append(el("span", "field-control", props.value ? "on" : "off"));
|
||||
toggle.append(el("span", "toggle-copy", props.label || "Toggle"));
|
||||
return toggle;
|
||||
}
|
||||
|
||||
if (kind === "color.swatch") {
|
||||
const swatch = el("div", "paint-swatch cultui-swatch");
|
||||
swatch.style.background = props.value || props.color || "currentColor";
|
||||
swatch.title = props.label || "Color";
|
||||
return swatch;
|
||||
}
|
||||
|
||||
if (kind === "list") {
|
||||
return renderCultList(props);
|
||||
}
|
||||
|
||||
if (kind === "control.button") {
|
||||
const button = el("button", "cultui-button", props.label || "Action");
|
||||
button.type = "button";
|
||||
button.addEventListener("click", () => {
|
||||
currentMesh()?.applyAction(props.action);
|
||||
statusEl.textContent = props.action
|
||||
? `command ${props.action.type} ${props.action.target || ""}`
|
||||
: `command ${props.action?.command || "invoke"} ${JSON.stringify(props.action?.payload || {})}`;
|
||||
});
|
||||
return button;
|
||||
}
|
||||
|
||||
if (kind === "control.slider") {
|
||||
return renderCultSlider(props, children);
|
||||
}
|
||||
|
||||
if (kind === "inspector.kv") {
|
||||
const panel = el("section", "pane");
|
||||
panel.append(el("h2", "", props.title || "Inspector"));
|
||||
for (const item of props.items || []) {
|
||||
panel.append(el("div", "detail", `${item.key}: ${item.value}`));
|
||||
}
|
||||
return panel;
|
||||
}
|
||||
|
||||
const fallback = el("section", "pane");
|
||||
fallback.append(el("h2", "", kind));
|
||||
for (const child of children) fallback.append(renderCultComponent(child));
|
||||
rendered = fallback;
|
||||
return placeComponent(rendered, props.placement);
|
||||
}
|
||||
|
||||
function placeComponent(element, placement) {
|
||||
if (!placement || placement.space !== "scene") return element;
|
||||
element.classList.add("cultui-placed");
|
||||
element.dataset.placementMode = placement.mode || "overlay";
|
||||
element.dataset.placementAnchor = placement.anchor || "";
|
||||
if (placement.zIndex !== undefined) element.style.zIndex = placement.zIndex;
|
||||
if (placement.opacity !== undefined) element.style.opacity = placement.opacity;
|
||||
|
||||
const quad = placement.quad;
|
||||
if (Array.isArray(quad) && quad.length >= 4) {
|
||||
const xs = quad.map(point => point[0]);
|
||||
const ys = quad.map(point => point[1]);
|
||||
const minX = Math.min(...xs);
|
||||
const maxX = Math.max(...xs);
|
||||
const minY = Math.min(...ys);
|
||||
const maxY = Math.max(...ys);
|
||||
element.style.left = `${minX * 100}%`;
|
||||
element.style.top = `${minY * 100}%`;
|
||||
element.style.width = `${Math.max(0.02, maxX - minX) * 100}%`;
|
||||
element.style.height = `${Math.max(0.02, maxY - minY) * 100}%`;
|
||||
const skewX = ((quad[1][1] - quad[0][1]) + (quad[2][1] - quad[3][1])) * 18;
|
||||
const skewY = ((quad[3][0] - quad[0][0]) + (quad[2][0] - quad[1][0])) * -18;
|
||||
element.style.transform = `skew(${skewX}deg, ${skewY}deg)`;
|
||||
}
|
||||
|
||||
if (placement.chromaKey) {
|
||||
element.dataset.chromaKey = placement.chromaKey.color || "enabled";
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
function bindText(element, props) {
|
||||
if (!props.bind) return;
|
||||
currentMesh()?.var(props.bind).subscribe(value => {
|
||||
element.textContent = `${props.prefix || ""}${value ?? ""}${props.suffix || ""}`;
|
||||
renderEveSurface(state, app, {
|
||||
body: document.body,
|
||||
clientId: liveHermodr ? "hermodr.browser" : "browser.reference",
|
||||
commandSink: publishCommandIntent,
|
||||
documentResolver: liveHermodr ? resolveHermodrDocument : undefined,
|
||||
assetUrlResolver: liveHermodr ? resolveHermodrAssetUrl : undefined,
|
||||
provider: currentProvider,
|
||||
source,
|
||||
statusElement: statusEl,
|
||||
});
|
||||
}
|
||||
|
||||
function renderCultMetric(props) {
|
||||
const metric = el("div", "metric cultui-reactive-metric");
|
||||
const label = el("label", "", props.label || "Metric");
|
||||
const valueEl = el("span", "metric-value", "");
|
||||
label.append(valueEl);
|
||||
const bar = el("div", "bar");
|
||||
const fill = el("span");
|
||||
bar.append(fill);
|
||||
metric.append(label, bar);
|
||||
if (props.bind) {
|
||||
currentMesh()?.var(props.bind).subscribe(value => {
|
||||
const number = Number(value) || 0;
|
||||
valueEl.textContent = props.format === "percent" ? `${Math.round(number * 100)}%` : String(value ?? "");
|
||||
fill.style.width = `${Math.max(0, Math.min(100, Math.round(number * 100)))}%`;
|
||||
async function resolveHermodrDocument(request) {
|
||||
const providerId = currentProvider?.providerId || "";
|
||||
const params = new URLSearchParams();
|
||||
params.set("documentId", request.documentId);
|
||||
if (request.schemaId) params.set("schemaId", request.schemaId);
|
||||
if (request.slotId) params.set("slotId", request.slotId);
|
||||
const response = await fetch(`/hermodr/document/${encodeURIComponent(providerId)}?${params.toString()}`, { cache: "no-store" });
|
||||
if (!response.ok) throw new Error(await response.text());
|
||||
return response.json();
|
||||
}
|
||||
|
||||
function resolveHermodrAssetUrl(uri) {
|
||||
if (/^(cultmesh:\/\/|resources:\/\/)/i.test(uri)) {
|
||||
return `/cultmesh-cdn/${encodeURIComponent(uri)}`;
|
||||
}
|
||||
return uri;
|
||||
}
|
||||
|
||||
async function publishCommandIntent(intent, component) {
|
||||
const props = component?.props || {};
|
||||
const command = intent.command
|
||||
? intent
|
||||
: createEveCommandIntent(props.command || props.commandId || "invoke", props, {
|
||||
clientId: "browser.reference",
|
||||
provider: currentProvider,
|
||||
});
|
||||
}
|
||||
return metric;
|
||||
}
|
||||
|
||||
function renderCultList(props) {
|
||||
const panel = el("section", "cultui-reactive-list");
|
||||
panel.append(el("div", "card-title", props.title || "List"));
|
||||
const list = el("div", "list");
|
||||
panel.append(list);
|
||||
if (props.bind) {
|
||||
currentMesh()?.collection(props.bind).subscribe(items => {
|
||||
list.replaceChildren(...items.map(item => el("div", "detail cultui-stream-item", String(item))));
|
||||
});
|
||||
}
|
||||
return panel;
|
||||
}
|
||||
|
||||
function renderCultSlider(props, children) {
|
||||
const anatomy = resolveSliderAnatomy(props, children);
|
||||
const box = anatomy.find(part => part.kind === "control.box")?.props || {};
|
||||
const parts = anatomy.filter(part => part.kind === "control.part");
|
||||
const hitArea = anatomy.find(part => part.kind === "control.hitArea")?.props || {};
|
||||
const min = Number(props.min ?? 0);
|
||||
const max = Number(props.max ?? 1);
|
||||
const step = Number(props.step ?? 0.01);
|
||||
const slider = el("div", "cultui-slider");
|
||||
slider.dataset.skin = props.skin || "default";
|
||||
applyControlBoxProps(slider, box);
|
||||
|
||||
const visual = el("div", "cultui-slider-visual");
|
||||
const input = el("input", "cultui-slider-input");
|
||||
input.type = "range";
|
||||
input.min = String(min);
|
||||
input.max = String(max);
|
||||
input.step = String(step);
|
||||
input.setAttribute("aria-label", props.bind || "slider");
|
||||
|
||||
for (const part of parts) {
|
||||
const partEl = el("span", `cultui-slider-part ${part.props?.name || "part"}`);
|
||||
applySliderPartProps(partEl, part.props || {});
|
||||
visual.append(partEl);
|
||||
}
|
||||
|
||||
if (!parts.some(part => part.props?.name === "track")) visual.append(el("span", "cultui-slider-part track"));
|
||||
if (!parts.some(part => part.props?.name === "fill")) visual.append(el("span", "cultui-slider-part fill"));
|
||||
if (!parts.some(part => part.props?.name === "thumb")) visual.append(el("span", "cultui-slider-part thumb"));
|
||||
|
||||
applyHitAreaProps(input, hitArea);
|
||||
slider.append(visual, input);
|
||||
|
||||
const setVisualValue = (value) => {
|
||||
const number = Number(value ?? min);
|
||||
const bounded = Math.max(min, Math.min(max, Number.isFinite(number) ? number : min));
|
||||
const percent = max === min ? 0 : ((bounded - min) / (max - min)) * 100;
|
||||
input.value = String(bounded);
|
||||
slider.style.setProperty("--cultui-slider-value", `${percent}%`);
|
||||
slider.dataset.value = String(bounded);
|
||||
};
|
||||
|
||||
if (props.bind) {
|
||||
currentMesh()?.var(props.bind).subscribe(setVisualValue);
|
||||
input.addEventListener("input", () => currentMesh()?.var(props.bind).set(Number(input.value)));
|
||||
} else {
|
||||
setVisualValue(props.value ?? min);
|
||||
}
|
||||
|
||||
return slider;
|
||||
}
|
||||
|
||||
function resolveSliderAnatomy(props, children) {
|
||||
const skin = props.skin ? currentSurfaceStyles.controlSkins?.[props.skin] : undefined;
|
||||
const skinChildren = skin?.children || [];
|
||||
const anatomy = [...skinChildren, ...children];
|
||||
if (anatomy.length) return anatomy;
|
||||
return [
|
||||
{ kind: "control.box", props: { height: 18, overflow: "visible" } },
|
||||
{ kind: "control.part", props: { name: "track", anchor: "center", size: ["100%", 6], radius: 2, fill: "color.panelInset" } },
|
||||
{ kind: "control.part", props: { name: "fill", anchor: ["left", "center"], size: ["value%", 6], radius: 2, fill: "color.accent" } },
|
||||
{ kind: "control.part", props: { name: "thumb", anchor: ["value", "center"], size: [12, 12], bleed: 3, radius: 999, fill: "color.accent" } },
|
||||
{ kind: "control.hitArea", props: { size: ["100%", 18] } },
|
||||
];
|
||||
}
|
||||
|
||||
function applyControlBoxProps(element, props) {
|
||||
if (props.height !== undefined) element.style.minHeight = cssSize(props.height);
|
||||
if (props.width !== undefined) element.style.width = cssSize(props.width);
|
||||
if (props.overflow) element.style.overflow = props.overflow;
|
||||
}
|
||||
|
||||
function applySliderPartProps(element, props) {
|
||||
const [width, height] = Array.isArray(props.size) ? props.size : [props.size, undefined];
|
||||
if (width !== undefined && width !== "value%") element.style.width = cssSize(width);
|
||||
if (height !== undefined) element.style.height = cssSize(height);
|
||||
if (props.radius !== undefined) element.style.borderRadius = cssSize(props.radius);
|
||||
if (props.fill !== undefined) element.style.background = tokenColor(props.fill);
|
||||
if (props.bleed !== undefined) element.style.setProperty("--part-bleed", cssSize(props.bleed));
|
||||
if (props.shadow) element.style.boxShadow = sliderShadow(props.shadow);
|
||||
const anchor = Array.isArray(props.anchor) ? props.anchor : [props.anchor];
|
||||
if (anchor.includes("value")) element.dataset.anchorValue = "true";
|
||||
}
|
||||
|
||||
function applyHitAreaProps(element, props) {
|
||||
const [width, height] = Array.isArray(props.size) ? props.size : [props.size, undefined];
|
||||
if (width !== undefined) element.style.width = cssSize(width);
|
||||
if (height !== undefined) element.style.height = cssSize(height);
|
||||
}
|
||||
|
||||
function applyBoxProps(element, props) {
|
||||
if (props.gap !== undefined) element.style.gap = cssSize(props.gap);
|
||||
if (props.padding !== undefined) element.style.padding = cssSize(props.padding);
|
||||
if (props.size !== undefined) element.style.flex = flexSize(props.size);
|
||||
if (props.min !== undefined) element.style.minWidth = cssSize(props.min);
|
||||
if (props.max !== undefined) element.style.maxWidth = cssSize(props.max);
|
||||
if (props.align !== undefined) element.style.alignItems = alignValue(props.align);
|
||||
if (props.clip === "true" || props.clip === true) element.style.overflow = "hidden";
|
||||
if (props.scroll === "y") element.style.overflowY = "auto";
|
||||
if (props.scroll === "x") element.style.overflowX = "auto";
|
||||
}
|
||||
|
||||
function flexSize(value) {
|
||||
if (typeof value === "string" && value.endsWith("fr")) {
|
||||
return `${Number(value.slice(0, -2)) || 1} 1 0`;
|
||||
}
|
||||
if (value === "auto" || value === "content") return "0 0 auto";
|
||||
return `0 0 ${cssSize(value)}`;
|
||||
}
|
||||
|
||||
function cssSize(value) {
|
||||
if (Array.isArray(value)) return value.map(cssSize).join(" ");
|
||||
if (typeof value === "number") return `${value}px`;
|
||||
if (typeof value === "string" && /^-?\d+(\.\d+)?$/.test(value)) return `${value}px`;
|
||||
return String(value ?? "");
|
||||
}
|
||||
|
||||
function alignValue(value) {
|
||||
if (value === "center") return "center";
|
||||
if (value === "end") return "flex-end";
|
||||
return String(value);
|
||||
}
|
||||
|
||||
function tokenColor(value) {
|
||||
const map = {
|
||||
"color.accent": "var(--accent)",
|
||||
"color.panelInset": "rgba(0, 0, 0, 0.34)",
|
||||
"color.panel": "var(--panel)",
|
||||
"color.text": "var(--text)",
|
||||
};
|
||||
return map[value] || value;
|
||||
}
|
||||
|
||||
function sliderShadow(value) {
|
||||
const parts = Array.isArray(value) ? value : [value];
|
||||
if (parts[0] !== "glow") return parts.join(" ");
|
||||
const color = tokenColor(parts[1] || "color.accent");
|
||||
const alpha = Number(parts[2] ?? 0.35);
|
||||
const radius = cssSize(parts[4] ?? parts[3] ?? 6);
|
||||
return `0 0 ${radius} color-mix(in srgb, ${color} ${Math.round(alpha * 100)}%, transparent)`;
|
||||
}
|
||||
|
||||
function currentMesh() {
|
||||
return window.__eveCurrentMesh;
|
||||
}
|
||||
|
||||
function textClassName(kind, props) {
|
||||
if (kind === "text.title" || props.role === "title") return "cultui-title";
|
||||
if (kind === "label") return "cultui-label";
|
||||
if (props.role === "mono") return "detail mono";
|
||||
return "detail";
|
||||
}
|
||||
|
||||
function emptyState(message) {
|
||||
const pane = el("section", "pane");
|
||||
pane.append(el("h2", "", "No Surface"));
|
||||
pane.append(el("div", "detail", message));
|
||||
return pane;
|
||||
}
|
||||
|
||||
function publishCommandIntent(commandId, props = {}) {
|
||||
const command = {
|
||||
type: "surface-command",
|
||||
schema: "gamecult.eve.command.v1",
|
||||
providerId: currentProvider?.providerId || surfaceId.textContent,
|
||||
surfaceId: currentProvider?.surfaces?.[0]?.surfaceId || surfaceId.textContent,
|
||||
command: commandId || "invoke",
|
||||
payload: {
|
||||
transport: props.transport || null,
|
||||
},
|
||||
issuedAt: new Date().toISOString(),
|
||||
clientId: "browser.reference",
|
||||
};
|
||||
statusEl.textContent = `command ${command.command}`;
|
||||
console.info("Eve command intent", command);
|
||||
}
|
||||
|
||||
function renderCultGraph(props) {
|
||||
const graph = el("section", "cultui-graph");
|
||||
graph.dataset.engine = props.engine?.id || "graph";
|
||||
graph.dataset.contract = props.engine?.contract || "";
|
||||
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
||||
svg.setAttribute("viewBox", "0 0 1 1");
|
||||
svg.setAttribute("preserveAspectRatio", "none");
|
||||
const graphState = props.graph || props;
|
||||
const nodes = graphState.nodes || [];
|
||||
for (const edge of graphState.edges || []) {
|
||||
const source = nodes.find(node => node.id === edge.source);
|
||||
const target = nodes.find(node => node.id === edge.target);
|
||||
if (!source || !target) continue;
|
||||
const line = document.createElementNS("http://www.w3.org/2000/svg", "line");
|
||||
line.setAttribute("x1", source.x ?? 0);
|
||||
line.setAttribute("y1", source.y ?? 0);
|
||||
line.setAttribute("x2", target.x ?? 0);
|
||||
line.setAttribute("y2", target.y ?? 0);
|
||||
svg.append(line);
|
||||
if (!liveHermodr) {
|
||||
console.info("Eve command intent", command);
|
||||
return;
|
||||
}
|
||||
graph.append(svg);
|
||||
for (const node of nodes) {
|
||||
const button = el("button", `cultui-node ${node.current ? "selected" : ""}`, node.label || node.id);
|
||||
button.type = "button";
|
||||
button.style.left = `${node.x * 100}%`;
|
||||
button.style.top = `${node.y * 100}%`;
|
||||
button.addEventListener("click", () => {
|
||||
statusEl.textContent = `command story.jump {"targetPath":"${node.target || node.id}"}`;
|
||||
});
|
||||
graph.append(button);
|
||||
const response = await fetch("/hermodr/commands/eve", {
|
||||
method: "POST",
|
||||
headers: { "content-type": "application/json" },
|
||||
body: JSON.stringify(command),
|
||||
});
|
||||
const receipt = await response.json().catch(() => ({}));
|
||||
if (!response.ok || receipt.ok === false) {
|
||||
statusEl.textContent = `command failed ${command.command}`;
|
||||
console.error("Eve command failed", receipt);
|
||||
return;
|
||||
}
|
||||
return graph;
|
||||
}
|
||||
|
||||
function renderCultTex(props) {
|
||||
const panel = el("section", "cultui-tex");
|
||||
panel.dataset.renderer = props.renderer?.web || "tex";
|
||||
if (props.label) panel.append(el("div", "cultui-tex-label", props.label));
|
||||
panel.append(el("div", "cultui-tex-source", props.source || props.sourceUri || ""));
|
||||
return panel;
|
||||
}
|
||||
|
||||
function renderVoidBot(state) {
|
||||
const nodes = state.nodes || [];
|
||||
const ctb = nodes.filter(n => n.kind === "ctb-turn");
|
||||
const leaves = nodes.filter(n => n.kind === "state-leaf");
|
||||
const summary = nodeById(nodes, "voidbot-summary");
|
||||
const agent = nodeById(nodes, "agent-detail");
|
||||
const detail = nodeById(nodes, state.selectedNodeId) || nodeById(nodes, "state-detail") || agent || summary;
|
||||
|
||||
app.innerHTML = "";
|
||||
const root = el("section", "cockpit");
|
||||
const rail = el("div", "ctb");
|
||||
for (const turn of ctb) {
|
||||
const card = el("button", "card");
|
||||
card.type = "button";
|
||||
if (turn.avatarUrl) {
|
||||
const img = el("img", "avatar");
|
||||
img.src = turn.avatarUrl;
|
||||
img.alt = "";
|
||||
card.append(img);
|
||||
}
|
||||
card.append(el("div", "card-title", turn.label || turn.id));
|
||||
card.append(el("div", "health", turn.health || ""));
|
||||
rail.append(card);
|
||||
}
|
||||
|
||||
const left = el("section", "pane");
|
||||
left.append(el("h2", "", "Controls / Selected Persona"));
|
||||
left.append(el("div", "detail", `${summary?.label || "VoidBot Swarm"}\n${summary?.detail || ""}`));
|
||||
left.append(metricStack());
|
||||
left.append(el("div", "detail", agent?.detail || "No selected Persona detail."));
|
||||
|
||||
const middle = el("section", "pane");
|
||||
middle.append(el("h2", "", "State Graph"));
|
||||
const list = el("div", "list");
|
||||
for (const leaf of leaves) {
|
||||
const card = el("div", `card ${leaf.id === state.selectedNodeId ? "selected" : ""}`);
|
||||
card.append(el("div", "card-title", leaf.label || leaf.id));
|
||||
card.append(el("div", "health", leaf.health || leaf.statePath || ""));
|
||||
list.append(card);
|
||||
}
|
||||
middle.append(list);
|
||||
|
||||
const right = el("section", "pane");
|
||||
right.append(el("h2", "", "State Detail"));
|
||||
right.append(el("div", "detail", `${detail?.label || "detail"}\n\n${detail?.detail || ""}`));
|
||||
|
||||
root.append(rail, left, middle, right);
|
||||
app.append(root);
|
||||
}
|
||||
|
||||
function renderGraphSurface(state) {
|
||||
app.innerHTML = "";
|
||||
const graph = el("section", "graph");
|
||||
for (const node of state.nodes || []) {
|
||||
const view = el("article", `node ${node.id === state.selectedNodeId ? "selected" : ""}`);
|
||||
const width = Math.max(160, graphWidth(node.width));
|
||||
const height = Math.max(92, graphHeight(node.height));
|
||||
view.style.width = `${width}px`;
|
||||
view.style.minHeight = `${height}px`;
|
||||
view.style.left = `${((node.x ?? 0) + 1) * 50}%`;
|
||||
view.style.top = `${((node.y ?? 0) + 1) * 50}%`;
|
||||
view.append(el("div", "card-title", node.label || node.id));
|
||||
view.append(el("div", "health", `${node.kind || "node"} ${node.health || ""}`));
|
||||
if (node.detail) {
|
||||
view.append(el("div", "detail", node.detail));
|
||||
}
|
||||
graph.append(view);
|
||||
}
|
||||
app.append(graph);
|
||||
}
|
||||
|
||||
function graphWidth(value) {
|
||||
return Math.round((value || 0.25) * Math.max(900, window.innerWidth - 32));
|
||||
}
|
||||
|
||||
function graphHeight(value) {
|
||||
return Math.round((value || 0.16) * Math.max(520, window.innerHeight - 150));
|
||||
}
|
||||
|
||||
function metricStack() {
|
||||
const wrapper = el("div", "metrics");
|
||||
const metrics = [
|
||||
["TURN", 0.96],
|
||||
["MEMORY", 0.70],
|
||||
["PRESSURE", 0.42],
|
||||
["HEAT", 0.34],
|
||||
["LOAD", 0.99],
|
||||
["SPEED", 0.88],
|
||||
];
|
||||
for (const [label, value] of metrics) {
|
||||
const metric = el("div", "metric");
|
||||
metric.append(el("label", "", `${label} ${Math.round(value * 100)}%`));
|
||||
const bar = el("div", "bar");
|
||||
const fill = el("span");
|
||||
fill.style.width = `${Math.round(value * 100)}%`;
|
||||
bar.append(fill);
|
||||
metric.append(bar);
|
||||
wrapper.append(metric);
|
||||
}
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
function nodeById(nodes, id) {
|
||||
return nodes.find(node => node.id === id);
|
||||
}
|
||||
|
||||
function el(tag, className = "", text = "") {
|
||||
const element = document.createElement(tag);
|
||||
if (className) element.className = className;
|
||||
if (text) element.textContent = text;
|
||||
return element;
|
||||
statusEl.textContent = `command accepted ${command.command}`;
|
||||
console.info("Eve command receipt", receipt);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue