@ramme-io/kernel 1.4.5 → 2.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -12021,15 +12021,15 @@ const ko = (o) => (l) => {
12021
12021
  },
12022
12022
  clearKeys: () => o({ geminiApiKey: null }),
12023
12023
  hasKey: () => !!l().geminiApiKey,
12024
- // UI Actions (The Remote Control)
12024
+ // UI Actions (The Remote Control)
12025
12025
  toggleSettings: (s) => o((a) => ({
12026
12026
  isSettingsOpen: s ?? !a.isSettingsOpen
12027
12027
  }))
12028
12028
  }),
12029
12029
  {
12030
- name: "ramme-vault-storage",
12030
+ name: "ramme_db_vault",
12031
12031
  storage: ru(() => localStorage),
12032
- // ⚠️ IMPORTANT: Don't save "isSettingsOpen" to localStorage.
12032
+ // IMPORTANT: Don't save "isSettingsOpen" to localStorage.
12033
12033
  // We don't want the modal to pop up every time you refresh the page.
12034
12034
  partialize: (o) => ({ geminiApiKey: o.geminiApiKey })
12035
12035
  }
package/dist/index.umd.js CHANGED
@@ -99,7 +99,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
99
99
  *
100
100
  * This source code is licensed under the ISC license.
101
101
  * See the LICENSE file in the root directory of this source tree.
102
- */const Gf=tr("Wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]),Cl={SmartTable:Po,DataTable:Po,StatCard:qe.StatCard,DeviceCard:qe.DeviceCard,BarChart:qe.BarChart,LineChart:qe.LineChart,Button:qe.Button,Unknown:({type:o})=>Ie.jsxs("div",{className:"h-24 w-full border-2 border-dashed border-amber-300 bg-amber-50 rounded-lg flex flex-col items-center justify-center text-amber-700 text-sm",children:[Ie.jsx(qf,{className:"mb-2 opacity-50",size:20}),Ie.jsxs("span",{children:["Unknown Component: ",Ie.jsx("strong",{children:o})]})]})},Yf=o=>Cl[o]||Cl.Unknown;class Qf extends Oe.Component{constructor(l){super(l),this.state={hasError:!1,error:""}}static getDerivedStateFromError(l){return{hasError:!0,error:l.message}}render(){return this.state.hasError?Ie.jsxs("div",{className:"h-full min-h-[100px] p-4 border-2 border-dashed border-red-300 bg-red-50/50 rounded-lg flex flex-col items-center justify-center text-red-600 text-xs",children:[Ie.jsx(zf,{size:16,className:"mb-2 opacity-80"}),Ie.jsx("span",{className:"font-bold",children:"Render Error"}),Ie.jsx("span",{className:"opacity-75 text-center truncate max-w-[200px]",children:this.state.error})]}):this.props.children}}const Jf=({block:o,manifest:l})=>{var e,i,c,h,d;const s=Yf(o.type),a=(e=o.props.dataId)==null?void 0:e.toLowerCase(),u=Oe.useMemo(()=>{var y;return(y=l.resources)==null?void 0:y.find(b=>b.id.toLowerCase()===a)},[l,a]),t=To(a,u),r=(c=(i=t==null?void 0:t[0])==null?void 0:i.id)==null?void 0:c.toString().startsWith("jit_"),n=Oe.useMemo(()=>{if(a&&o.type==="SmartTable"&&!o.props.columnDefs&&u)return u.fields.map(y=>({field:y.key,headerName:y.label,filter:!0,flex:1,cellRenderer:y.type==="status"?b=>Ie.jsx(qe.Badge,{variant:"secondary",children:b.value}):void 0}))},[a,o.type,u,o.props.columnDefs]);return Ie.jsx("div",{style:{gridColumn:`span ${((h=o.layout)==null?void 0:h.colSpan)||1}`,gridRow:`span ${((d=o.layout)==null?void 0:d.rowSpan)||1}`},className:"relative group",children:Ie.jsxs(Qf,{children:[Ie.jsx("div",{className:"absolute -top-3 right-0 opacity-0 group-hover:opacity-100 transition-opacity z-20 pointer-events-none translate-y-2 group-hover:translate-y-0 duration-200",children:Ie.jsxs("div",{className:`text-[10px] px-2 py-1 rounded-md shadow-lg border border-white/10 flex items-center gap-1.5 font-mono ${r?"bg-amber-600 text-white":"bg-slate-800 text-slate-200"}`,children:[Ie.jsx("span",{className:"font-bold",children:o.type}),a&&Ie.jsxs(Ie.Fragment,{children:[" ",Ie.jsx("span",{className:"opacity-40",children:"|"})," ",r?Ie.jsx(Kf,{size:10,className:"animate-pulse"}):Ie.jsx($f,{size:10})," ",a]})]})}),Ie.jsx(s,{...o.props,rowData:o.type==="SmartTable"?void 0:t,columnDefs:o.props.columnDefs||n,className:"w-full h-full"})]})})},jl=({pageId:o})=>{var r;const l=Ht(),a=dn()==="live",u=Oe.useMemo(()=>{var n;return(n=l.pages)==null?void 0:n.find(e=>e.id===o)},[l,o]);if(!u)return Ie.jsxs("div",{className:"p-8 space-y-4 flex flex-col items-center justify-center h-[50vh]",children:[Ie.jsx(Vf,{className:"animate-spin text-primary mb-4",size:32}),Ie.jsx("p",{className:"text-muted-foreground",children:"Loading Blueprint..."})]});const t=Ie.jsxs("div",{className:`flex items-center gap-2 px-3 py-1.5 rounded-full text-xs font-bold border transition-colors duration-300 ${a?"bg-green-100 text-green-700 border-green-200":"bg-slate-100 text-slate-500 border-slate-200"}`,children:[a?Ie.jsx(Gf,{size:14,className:"text-green-600 animate-pulse"}):Ie.jsx(Hf,{size:14}),a?"LIVE BRIDGE":"STATIC MODE"]});return Ie.jsxs("div",{className:"p-6 md:p-8 max-w-7xl mx-auto w-full space-y-8",children:[Ie.jsxs("header",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4 border-b border-border/40 pb-6",children:[Ie.jsxs("div",{className:"space-y-1",children:[Ie.jsx("h1",{className:"text-3xl font-bold tracking-tight text-foreground",children:u.title}),u.description&&Ie.jsx("p",{className:"text-muted-foreground",children:u.description})]}),Ie.jsx("div",{className:"flex items-center gap-2",children:t})]}),Ie.jsx("div",{className:"grid gap-8 pb-20",children:(r=u.sections)==null?void 0:r.map(n=>{var e;return Ie.jsxs("section",{className:"space-y-6",children:[n.title&&Ie.jsx("div",{className:"flex items-center gap-2 pb-2 border-b border-border/60",children:Ie.jsx("h3",{className:"text-sm font-bold uppercase tracking-wider text-muted-foreground/80",children:n.title})}),Ie.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${((e=n.layout)==null?void 0:e.columns)||1}, minmax(0, 1fr))`},children:n.blocks.map(i=>Ie.jsx(Jf,{block:i,manifest:l},i.id))})]},n.id)})})]})},Xf=o=>{const l=Ht(),a=dn()==="live";return Oe.useMemo(()=>{const u=(l.pages||[]).map(n=>({id:n.id,path:n.slug,title:n.title,icon:n.icon||"layout",component:()=>Ie.jsx(jl,{pageId:n.id})}));if(a&&u.length>0)return u;const t=new Set(o.map(n=>n.id)),r=u.filter(n=>!t.has(n.id));return[...o,...r]},[l,o,a])},Zf={name:"loading",version:"0.0.0",capabilities:[],navigation:[]};function eh(){const[o,l]=Oe.useState(Zf),{lastMessage:s,isConnected:a}=Oo();return Oe.useEffect(()=>{if(s&&s.topic==="ramme/manifest/update")try{const u=JSON.parse(s.payload.toString());l(u)}catch(u){console.error("Failed to parse manifest update",u)}},[s]),{manifest:o,isLive:a}}const Rl=o=>{let l;const s=new Set,a=(i,c)=>{const h=typeof i=="function"?i(l):i;if(!Object.is(h,l)){const d=l;l=c??(typeof h!="object"||h===null)?h:Object.assign({},l,h),s.forEach(y=>y(l,d))}},u=()=>l,n={setState:a,getState:u,getInitialState:()=>e,subscribe:i=>(s.add(i),()=>s.delete(i))},e=l=o(a,u,n);return n},th=o=>o?Rl(o):Rl,rh=o=>o;function nh(o,l=rh){const s=Oe.useSyncExternalStore(o.subscribe,Oe.useCallback(()=>l(o.getState()),[o,l]),Oe.useCallback(()=>l(o.getInitialState()),[o,l]));return Oe.useDebugValue(s),s}const Ml=o=>{const l=th(o),s=a=>nh(l,a);return Object.assign(s,l),s},Co=o=>o?Ml(o):Ml,ih={living_room_ac:{value:72,timestamp:Date.now()},living_room_hum:{value:45,timestamp:Date.now()},server_01:{value:42,timestamp:Date.now()},front_door_lock:{value:"LOCKED",timestamp:Date.now()}},on=Co(o=>({signals:ih,updateSignal:(l,s)=>o(a=>({signals:{...a.signals,[l]:{value:s,timestamp:Date.now()}}})),updateSignals:l=>o(s=>{const a={...s.signals};return Object.entries(l).forEach(([u,t])=>{a[u]={value:t,timestamp:Date.now()}}),{signals:a}})})),Nl=()=>on(o=>o.signals),oh=(o=!0)=>{const{updateSignals:l}=on();Oe.useEffect(()=>{if(!o)return;console.log("[System] Simulation Mode: ON 🎲");const s=setInterval(()=>{const a={};a.living_room_ac=Number((72+(Math.random()*4-2)).toFixed(1)),a.living_room_hum=Number((45+(Math.random()*6-3)).toFixed(1)),a.server_01=Math.floor(Math.random()*100),Math.random()>.99&&(a.front_door_lock=Math.random()>.5?"LOCKED":"UNLOCKED"),l(a)},2e3);return()=>clearInterval(s)},[o,l])},sh=o=>{const l=on(r=>r.signals[o]),s=Ht(),a=Oe.useMemo(()=>s.domain.signals.find(r=>r.id===o),[o,s]),u=(l==null?void 0:l.value)??(a==null?void 0:a.defaultValue)??0,t=l?Date.now()-l.timestamp>1e4:!0;return{id:o,value:u,unit:a==null?void 0:a.unit,min:a==null?void 0:a.min,max:a==null?void 0:a.max,timestamp:l==null?void 0:l.timestamp,status:t?"stale":"fresh"}},ah="ramme_db_",lh=o=>{if(!(typeof window>"u")){if(!o){console.warn("⚠️ [Data Lake] No registry provided to seeder. Skipping initialization.");return}console.groupCollapsed("🌊 [Data Lake] Initialization"),Object.entries(o).forEach(([l,s])=>{const a=`${ah}${l}`;localStorage.getItem(a)||(console.log(`✨ Seeding collection: ${l}`),localStorage.setItem(a,JSON.stringify(s)))}),console.groupEnd()}};function Bl(o,l){let s;try{s=o()}catch{return}return{getItem:u=>{var t;const r=e=>e===null?null:JSON.parse(e,void 0),n=(t=s.getItem(u))!=null?t:null;return n instanceof Promise?n.then(r):r(n)},setItem:(u,t)=>s.setItem(u,JSON.stringify(t,void 0)),removeItem:u=>s.removeItem(u)}}const jo=o=>l=>{try{const s=o(l);return s instanceof Promise?s:{then(a){return jo(a)(s)},catch(a){return this}}}catch(s){return{then(a){return this},catch(a){return jo(a)(s)}}}},uh=(o,l)=>(s,a,u)=>{let t={storage:Bl(()=>localStorage),partialize:w=>w,version:0,merge:(w,S)=>({...S,...w}),...l},r=!1;const n=new Set,e=new Set;let i=t.storage;if(!i)return o((...w)=>{console.warn(`[zustand persist middleware] Unable to update item '${t.name}', the given storage is currently unavailable.`),s(...w)},a,u);const c=()=>{const w=t.partialize({...a()});return i.setItem(t.name,{state:w,version:t.version})},h=u.setState;u.setState=(w,S)=>(h(w,S),c());const d=o((...w)=>(s(...w),c()),a,u);u.getInitialState=()=>d;let y;const b=()=>{var w,S;if(!i)return;r=!1,n.forEach(g=>{var _;return g((_=a())!=null?_:d)});const A=((S=t.onRehydrateStorage)==null?void 0:S.call(t,(w=a())!=null?w:d))||void 0;return jo(i.getItem.bind(i))(t.name).then(g=>{if(g)if(typeof g.version=="number"&&g.version!==t.version){if(t.migrate){const _=t.migrate(g.state,g.version);return _ instanceof Promise?_.then(E=>[!0,E]):[!0,_]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,g.state];return[!1,void 0]}).then(g=>{var _;const[E,v]=g;if(y=t.merge(v,(_=a())!=null?_:d),s(y,!0),E)return c()}).then(()=>{A==null||A(y,void 0),y=a(),r=!0,e.forEach(g=>g(y))}).catch(g=>{A==null||A(void 0,g)})};return u.persist={setOptions:w=>{t={...t,...w},w.storage&&(i=w.storage)},clearStorage:()=>{i==null||i.removeItem(t.name)},getOptions:()=>t,rehydrate:()=>b(),hasHydrated:()=>r,onHydrate:w=>(n.add(w),()=>{n.delete(w)}),onFinishHydration:w=>(e.add(w),()=>{e.delete(w)})},t.skipHydration||b(),y||d},Ro=Co()(uh((o,l)=>({geminiApiKey:null,isSettingsOpen:!1,setGeminiApiKey:s=>{s&&o({geminiApiKey:s.trim()})},clearKeys:()=>o({geminiApiKey:null}),hasKey:()=>!!l().geminiApiKey,toggleSettings:s=>o(a=>({isSettingsOpen:s??!a.isSettingsOpen}))}),{name:"ramme-vault-storage",storage:Bl(()=>localStorage),partialize:o=>({geminiApiKey:o.geminiApiKey})})),ch=()=>{const{geminiApiKey:o}=Ro();return Oe.useEffect(()=>{console.log(o?"🧠 [Kernel] Workflow Engine: Online":"🧠 [Kernel] Workflow Engine: Standby (No Key)")},[o]),{isReady:!!o,status:o?"active":"idle"}},Mo=o=>`${o}_${Date.now()}`,fh={meta:{name:"My Ramme App",version:"0.0.1"},config:{theme:"system",mockMode:!0},domain:{signals:[],entities:[],workflows:[]},modules:[],resources:[],pages:[{id:"home",title:"Home",slug:"/",sections:[{id:"main_section",title:"Main Content",layout:{columns:1},blocks:[]}]}]},hh=Co(o=>({manifest:fh,activePageId:"home",selectedBlockId:null,setManifest:l=>o({manifest:l}),setActivePage:l=>o({activePageId:l}),selectBlock:l=>o({selectedBlockId:l}),addPage:l=>o(s=>{const a={id:Mo("page"),title:l,slug:l.toLowerCase().replace(/\s+/g,"-"),sections:[{id:Mo("sect"),title:"Main",layout:{columns:1},blocks:[]}]};return{manifest:{...s.manifest,pages:[...s.manifest.pages||[],a]}}}),updatePage:(l,s)=>o(a=>{var u;return{manifest:{...a.manifest,pages:(u=a.manifest.pages)==null?void 0:u.map(t=>t.id===l?{...t,...s}:t)}}}),deletePage:l=>o(s=>{var t,r;const a=((t=s.manifest.pages)==null?void 0:t.filter(n=>n.id!==l))||[],u=s.activePageId===l?((r=a[0])==null?void 0:r.id)||null:s.activePageId;return{manifest:{...s.manifest,pages:a},activePageId:u}}),addBlock:(l,s,a,u={})=>o(t=>{var n;const r={id:Mo("blk"),type:a,props:u};return{manifest:{...t.manifest,pages:(n=t.manifest.pages)==null?void 0:n.map(e=>e.id!==l?e:{...e,sections:e.sections.map(i=>i.id!==s?i:{...i,blocks:[...i.blocks,r]})})}}}),updateBlock:(l,s,a)=>o(u=>{var t;return{manifest:{...u.manifest,pages:(t=u.manifest.pages)==null?void 0:t.map(r=>r.id!==l?r:{...r,sections:r.sections.map(n=>n.blocks.some(e=>e.id===s)?{...n,blocks:n.blocks.map(e=>e.id===s?{...e,props:{...e.props,...a}}:e)}:n)})}}}),deleteBlock:(l,s)=>o(a=>{var u;return{manifest:{...a.manifest,pages:(u=a.manifest.pages)==null?void 0:u.map(t=>t.id!==l?t:{...t,sections:t.sections.map(r=>({...r,blocks:r.blocks.filter(n=>n.id!==s)}))})}}})})),Ll=Se.z.object({key:Se.z.string(),label:Se.z.string(),type:Se.z.enum(["text","number","currency","date","boolean","status","email","image","textarea"]),required:Se.z.boolean().optional(),description:Se.z.string().optional(),defaultValue:Se.z.any().optional()}),Ul=Se.z.object({id:Se.z.string(),name:Se.z.string(),fields:Se.z.array(Ll),defaultView:Se.z.enum(["table","grid","list"]).optional(),features:Se.z.object({searchable:Se.z.boolean().optional(),creatable:Se.z.boolean().optional(),editable:Se.z.boolean().optional(),deletable:Se.z.boolean().optional(),exportable:Se.z.boolean().optional()}).optional()}),Dl=Se.z.object({id:Se.z.string().min(1,"Signal ID is required"),label:Se.z.string(),description:Se.z.string().optional(),kind:Se.z.enum(["sensor","actuator","setpoint","metric","status","kpi"]),source:Se.z.enum(["mock","mqtt","http","derived","local"]),topic:Se.z.string().optional(),endpoint:Se.z.string().optional(),jsonPath:Se.z.string().optional(),refreshRate:Se.z.number().optional().default(1e3),defaultValue:Se.z.any().optional(),unit:Se.z.string().optional(),min:Se.z.number().optional(),max:Se.z.number().optional()}),Fl=Se.z.object({id:Se.z.string(),name:Se.z.string(),description:Se.z.string().optional(),type:Se.z.string(),category:Se.z.string().default("logical"),signals:Se.z.array(Se.z.string()),ui:Se.z.object({icon:Se.z.string().optional(),color:Se.z.string().optional(),dashboardComponent:Se.z.string().optional()}).optional()}),Wl=Se.z.object({id:Se.z.string(),type:Se.z.enum(["signal_change","manual_action","schedule","webhook"]),config:Se.z.record(Se.z.string(),Se.z.any())}),$l=Se.z.object({id:Se.z.string(),type:Se.z.enum(["update_resource","send_notification","mqtt_publish","api_call","navigate","agent_task"]),config:Se.z.record(Se.z.string(),Se.z.any())}),ql=Se.z.object({id:Se.z.string(),name:Se.z.string(),active:Se.z.boolean().default(!0),trigger:Wl,actions:Se.z.array($l)}),Vl=Se.z.object({id:Se.z.string(),type:Se.z.string(),props:Se.z.record(Se.z.string(),Se.z.any()),layout:Se.z.object({colSpan:Se.z.number().optional(),rowSpan:Se.z.number().optional()}).optional()}),zl=Se.z.object({id:Se.z.string(),title:Se.z.string().optional(),description:Se.z.string().optional(),layout:Se.z.object({columns:Se.z.number().optional(),variant:Se.z.enum(["grid","stack","split"]).optional()}).optional(),blocks:Se.z.array(Vl)}),Kl=Se.z.object({id:Se.z.string(),slug:Se.z.string(),title:Se.z.string(),description:Se.z.string().optional(),icon:Se.z.string().optional(),sections:Se.z.array(zl)}),ph=Se.z.object({meta:Se.z.object({name:Se.z.string(),version:Se.z.string(),description:Se.z.string().optional(),author:Se.z.string().optional(),createdAt:Se.z.string().optional()}),config:Se.z.object({theme:Se.z.enum(["light","dark","system","corporate","midnight","blueprint"]).default("system"),mockMode:Se.z.boolean().default(!0),brokerUrl:Se.z.string().optional()}),modules:Se.z.array(Se.z.string()).optional(),resources:Se.z.array(Ul).optional(),domain:Se.z.object({signals:Se.z.array(Dl),entities:Se.z.array(Fl),workflows:Se.z.array(ql).optional()}),pages:Se.z.array(Kl).optional()}),Hl=o=>{switch(o){case"fresh":return"online";case"stale":return"warning";case"disconnected":return"offline";case"error":return"error";default:return"offline"}},dh=({block:o,getComponent:l,getMockData:s})=>{const a=l(o.type),u=Nl(),{signalId:t,dataId:r,...n}=o.props,e={...n,dataId:r,signalId:t};if(r){const i=s(r);e.data=i||[],e.rowData=i||[]}if(t&&u&&t in u){const i=u[t];if(i){const c=typeof i=="object"&&i!==null,h=c&&"value"in i?i.value:i,d=c&&"status"in i?i.status:"fresh";e.value=typeof h=="number"?h:String(h),e.status=Hl(String(d))}else e.status=Hl("disconnected")}return Ie.jsx(a,{...e},o.id)};/**
102
+ */const Gf=tr("Wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]),Cl={SmartTable:Po,DataTable:Po,StatCard:qe.StatCard,DeviceCard:qe.DeviceCard,BarChart:qe.BarChart,LineChart:qe.LineChart,Button:qe.Button,Unknown:({type:o})=>Ie.jsxs("div",{className:"h-24 w-full border-2 border-dashed border-amber-300 bg-amber-50 rounded-lg flex flex-col items-center justify-center text-amber-700 text-sm",children:[Ie.jsx(qf,{className:"mb-2 opacity-50",size:20}),Ie.jsxs("span",{children:["Unknown Component: ",Ie.jsx("strong",{children:o})]})]})},Yf=o=>Cl[o]||Cl.Unknown;class Qf extends Oe.Component{constructor(l){super(l),this.state={hasError:!1,error:""}}static getDerivedStateFromError(l){return{hasError:!0,error:l.message}}render(){return this.state.hasError?Ie.jsxs("div",{className:"h-full min-h-[100px] p-4 border-2 border-dashed border-red-300 bg-red-50/50 rounded-lg flex flex-col items-center justify-center text-red-600 text-xs",children:[Ie.jsx(zf,{size:16,className:"mb-2 opacity-80"}),Ie.jsx("span",{className:"font-bold",children:"Render Error"}),Ie.jsx("span",{className:"opacity-75 text-center truncate max-w-[200px]",children:this.state.error})]}):this.props.children}}const Jf=({block:o,manifest:l})=>{var e,i,c,h,d;const s=Yf(o.type),a=(e=o.props.dataId)==null?void 0:e.toLowerCase(),u=Oe.useMemo(()=>{var y;return(y=l.resources)==null?void 0:y.find(b=>b.id.toLowerCase()===a)},[l,a]),t=To(a,u),r=(c=(i=t==null?void 0:t[0])==null?void 0:i.id)==null?void 0:c.toString().startsWith("jit_"),n=Oe.useMemo(()=>{if(a&&o.type==="SmartTable"&&!o.props.columnDefs&&u)return u.fields.map(y=>({field:y.key,headerName:y.label,filter:!0,flex:1,cellRenderer:y.type==="status"?b=>Ie.jsx(qe.Badge,{variant:"secondary",children:b.value}):void 0}))},[a,o.type,u,o.props.columnDefs]);return Ie.jsx("div",{style:{gridColumn:`span ${((h=o.layout)==null?void 0:h.colSpan)||1}`,gridRow:`span ${((d=o.layout)==null?void 0:d.rowSpan)||1}`},className:"relative group",children:Ie.jsxs(Qf,{children:[Ie.jsx("div",{className:"absolute -top-3 right-0 opacity-0 group-hover:opacity-100 transition-opacity z-20 pointer-events-none translate-y-2 group-hover:translate-y-0 duration-200",children:Ie.jsxs("div",{className:`text-[10px] px-2 py-1 rounded-md shadow-lg border border-white/10 flex items-center gap-1.5 font-mono ${r?"bg-amber-600 text-white":"bg-slate-800 text-slate-200"}`,children:[Ie.jsx("span",{className:"font-bold",children:o.type}),a&&Ie.jsxs(Ie.Fragment,{children:[" ",Ie.jsx("span",{className:"opacity-40",children:"|"})," ",r?Ie.jsx(Kf,{size:10,className:"animate-pulse"}):Ie.jsx($f,{size:10})," ",a]})]})}),Ie.jsx(s,{...o.props,rowData:o.type==="SmartTable"?void 0:t,columnDefs:o.props.columnDefs||n,className:"w-full h-full"})]})})},jl=({pageId:o})=>{var r;const l=Ht(),a=dn()==="live",u=Oe.useMemo(()=>{var n;return(n=l.pages)==null?void 0:n.find(e=>e.id===o)},[l,o]);if(!u)return Ie.jsxs("div",{className:"p-8 space-y-4 flex flex-col items-center justify-center h-[50vh]",children:[Ie.jsx(Vf,{className:"animate-spin text-primary mb-4",size:32}),Ie.jsx("p",{className:"text-muted-foreground",children:"Loading Blueprint..."})]});const t=Ie.jsxs("div",{className:`flex items-center gap-2 px-3 py-1.5 rounded-full text-xs font-bold border transition-colors duration-300 ${a?"bg-green-100 text-green-700 border-green-200":"bg-slate-100 text-slate-500 border-slate-200"}`,children:[a?Ie.jsx(Gf,{size:14,className:"text-green-600 animate-pulse"}):Ie.jsx(Hf,{size:14}),a?"LIVE BRIDGE":"STATIC MODE"]});return Ie.jsxs("div",{className:"p-6 md:p-8 max-w-7xl mx-auto w-full space-y-8",children:[Ie.jsxs("header",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4 border-b border-border/40 pb-6",children:[Ie.jsxs("div",{className:"space-y-1",children:[Ie.jsx("h1",{className:"text-3xl font-bold tracking-tight text-foreground",children:u.title}),u.description&&Ie.jsx("p",{className:"text-muted-foreground",children:u.description})]}),Ie.jsx("div",{className:"flex items-center gap-2",children:t})]}),Ie.jsx("div",{className:"grid gap-8 pb-20",children:(r=u.sections)==null?void 0:r.map(n=>{var e;return Ie.jsxs("section",{className:"space-y-6",children:[n.title&&Ie.jsx("div",{className:"flex items-center gap-2 pb-2 border-b border-border/60",children:Ie.jsx("h3",{className:"text-sm font-bold uppercase tracking-wider text-muted-foreground/80",children:n.title})}),Ie.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${((e=n.layout)==null?void 0:e.columns)||1}, minmax(0, 1fr))`},children:n.blocks.map(i=>Ie.jsx(Jf,{block:i,manifest:l},i.id))})]},n.id)})})]})},Xf=o=>{const l=Ht(),a=dn()==="live";return Oe.useMemo(()=>{const u=(l.pages||[]).map(n=>({id:n.id,path:n.slug,title:n.title,icon:n.icon||"layout",component:()=>Ie.jsx(jl,{pageId:n.id})}));if(a&&u.length>0)return u;const t=new Set(o.map(n=>n.id)),r=u.filter(n=>!t.has(n.id));return[...o,...r]},[l,o,a])},Zf={name:"loading",version:"0.0.0",capabilities:[],navigation:[]};function eh(){const[o,l]=Oe.useState(Zf),{lastMessage:s,isConnected:a}=Oo();return Oe.useEffect(()=>{if(s&&s.topic==="ramme/manifest/update")try{const u=JSON.parse(s.payload.toString());l(u)}catch(u){console.error("Failed to parse manifest update",u)}},[s]),{manifest:o,isLive:a}}const Rl=o=>{let l;const s=new Set,a=(i,c)=>{const h=typeof i=="function"?i(l):i;if(!Object.is(h,l)){const d=l;l=c??(typeof h!="object"||h===null)?h:Object.assign({},l,h),s.forEach(y=>y(l,d))}},u=()=>l,n={setState:a,getState:u,getInitialState:()=>e,subscribe:i=>(s.add(i),()=>s.delete(i))},e=l=o(a,u,n);return n},th=o=>o?Rl(o):Rl,rh=o=>o;function nh(o,l=rh){const s=Oe.useSyncExternalStore(o.subscribe,Oe.useCallback(()=>l(o.getState()),[o,l]),Oe.useCallback(()=>l(o.getInitialState()),[o,l]));return Oe.useDebugValue(s),s}const Ml=o=>{const l=th(o),s=a=>nh(l,a);return Object.assign(s,l),s},Co=o=>o?Ml(o):Ml,ih={living_room_ac:{value:72,timestamp:Date.now()},living_room_hum:{value:45,timestamp:Date.now()},server_01:{value:42,timestamp:Date.now()},front_door_lock:{value:"LOCKED",timestamp:Date.now()}},on=Co(o=>({signals:ih,updateSignal:(l,s)=>o(a=>({signals:{...a.signals,[l]:{value:s,timestamp:Date.now()}}})),updateSignals:l=>o(s=>{const a={...s.signals};return Object.entries(l).forEach(([u,t])=>{a[u]={value:t,timestamp:Date.now()}}),{signals:a}})})),Nl=()=>on(o=>o.signals),oh=(o=!0)=>{const{updateSignals:l}=on();Oe.useEffect(()=>{if(!o)return;console.log("[System] Simulation Mode: ON 🎲");const s=setInterval(()=>{const a={};a.living_room_ac=Number((72+(Math.random()*4-2)).toFixed(1)),a.living_room_hum=Number((45+(Math.random()*6-3)).toFixed(1)),a.server_01=Math.floor(Math.random()*100),Math.random()>.99&&(a.front_door_lock=Math.random()>.5?"LOCKED":"UNLOCKED"),l(a)},2e3);return()=>clearInterval(s)},[o,l])},sh=o=>{const l=on(r=>r.signals[o]),s=Ht(),a=Oe.useMemo(()=>s.domain.signals.find(r=>r.id===o),[o,s]),u=(l==null?void 0:l.value)??(a==null?void 0:a.defaultValue)??0,t=l?Date.now()-l.timestamp>1e4:!0;return{id:o,value:u,unit:a==null?void 0:a.unit,min:a==null?void 0:a.min,max:a==null?void 0:a.max,timestamp:l==null?void 0:l.timestamp,status:t?"stale":"fresh"}},ah="ramme_db_",lh=o=>{if(!(typeof window>"u")){if(!o){console.warn("⚠️ [Data Lake] No registry provided to seeder. Skipping initialization.");return}console.groupCollapsed("🌊 [Data Lake] Initialization"),Object.entries(o).forEach(([l,s])=>{const a=`${ah}${l}`;localStorage.getItem(a)||(console.log(`✨ Seeding collection: ${l}`),localStorage.setItem(a,JSON.stringify(s)))}),console.groupEnd()}};function Bl(o,l){let s;try{s=o()}catch{return}return{getItem:u=>{var t;const r=e=>e===null?null:JSON.parse(e,void 0),n=(t=s.getItem(u))!=null?t:null;return n instanceof Promise?n.then(r):r(n)},setItem:(u,t)=>s.setItem(u,JSON.stringify(t,void 0)),removeItem:u=>s.removeItem(u)}}const jo=o=>l=>{try{const s=o(l);return s instanceof Promise?s:{then(a){return jo(a)(s)},catch(a){return this}}}catch(s){return{then(a){return this},catch(a){return jo(a)(s)}}}},uh=(o,l)=>(s,a,u)=>{let t={storage:Bl(()=>localStorage),partialize:w=>w,version:0,merge:(w,S)=>({...S,...w}),...l},r=!1;const n=new Set,e=new Set;let i=t.storage;if(!i)return o((...w)=>{console.warn(`[zustand persist middleware] Unable to update item '${t.name}', the given storage is currently unavailable.`),s(...w)},a,u);const c=()=>{const w=t.partialize({...a()});return i.setItem(t.name,{state:w,version:t.version})},h=u.setState;u.setState=(w,S)=>(h(w,S),c());const d=o((...w)=>(s(...w),c()),a,u);u.getInitialState=()=>d;let y;const b=()=>{var w,S;if(!i)return;r=!1,n.forEach(g=>{var _;return g((_=a())!=null?_:d)});const A=((S=t.onRehydrateStorage)==null?void 0:S.call(t,(w=a())!=null?w:d))||void 0;return jo(i.getItem.bind(i))(t.name).then(g=>{if(g)if(typeof g.version=="number"&&g.version!==t.version){if(t.migrate){const _=t.migrate(g.state,g.version);return _ instanceof Promise?_.then(E=>[!0,E]):[!0,_]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,g.state];return[!1,void 0]}).then(g=>{var _;const[E,v]=g;if(y=t.merge(v,(_=a())!=null?_:d),s(y,!0),E)return c()}).then(()=>{A==null||A(y,void 0),y=a(),r=!0,e.forEach(g=>g(y))}).catch(g=>{A==null||A(void 0,g)})};return u.persist={setOptions:w=>{t={...t,...w},w.storage&&(i=w.storage)},clearStorage:()=>{i==null||i.removeItem(t.name)},getOptions:()=>t,rehydrate:()=>b(),hasHydrated:()=>r,onHydrate:w=>(n.add(w),()=>{n.delete(w)}),onFinishHydration:w=>(e.add(w),()=>{e.delete(w)})},t.skipHydration||b(),y||d},Ro=Co()(uh((o,l)=>({geminiApiKey:null,isSettingsOpen:!1,setGeminiApiKey:s=>{s&&o({geminiApiKey:s.trim()})},clearKeys:()=>o({geminiApiKey:null}),hasKey:()=>!!l().geminiApiKey,toggleSettings:s=>o(a=>({isSettingsOpen:s??!a.isSettingsOpen}))}),{name:"ramme_db_vault",storage:Bl(()=>localStorage),partialize:o=>({geminiApiKey:o.geminiApiKey})})),ch=()=>{const{geminiApiKey:o}=Ro();return Oe.useEffect(()=>{console.log(o?"🧠 [Kernel] Workflow Engine: Online":"🧠 [Kernel] Workflow Engine: Standby (No Key)")},[o]),{isReady:!!o,status:o?"active":"idle"}},Mo=o=>`${o}_${Date.now()}`,fh={meta:{name:"My Ramme App",version:"0.0.1"},config:{theme:"system",mockMode:!0},domain:{signals:[],entities:[],workflows:[]},modules:[],resources:[],pages:[{id:"home",title:"Home",slug:"/",sections:[{id:"main_section",title:"Main Content",layout:{columns:1},blocks:[]}]}]},hh=Co(o=>({manifest:fh,activePageId:"home",selectedBlockId:null,setManifest:l=>o({manifest:l}),setActivePage:l=>o({activePageId:l}),selectBlock:l=>o({selectedBlockId:l}),addPage:l=>o(s=>{const a={id:Mo("page"),title:l,slug:l.toLowerCase().replace(/\s+/g,"-"),sections:[{id:Mo("sect"),title:"Main",layout:{columns:1},blocks:[]}]};return{manifest:{...s.manifest,pages:[...s.manifest.pages||[],a]}}}),updatePage:(l,s)=>o(a=>{var u;return{manifest:{...a.manifest,pages:(u=a.manifest.pages)==null?void 0:u.map(t=>t.id===l?{...t,...s}:t)}}}),deletePage:l=>o(s=>{var t,r;const a=((t=s.manifest.pages)==null?void 0:t.filter(n=>n.id!==l))||[],u=s.activePageId===l?((r=a[0])==null?void 0:r.id)||null:s.activePageId;return{manifest:{...s.manifest,pages:a},activePageId:u}}),addBlock:(l,s,a,u={})=>o(t=>{var n;const r={id:Mo("blk"),type:a,props:u};return{manifest:{...t.manifest,pages:(n=t.manifest.pages)==null?void 0:n.map(e=>e.id!==l?e:{...e,sections:e.sections.map(i=>i.id!==s?i:{...i,blocks:[...i.blocks,r]})})}}}),updateBlock:(l,s,a)=>o(u=>{var t;return{manifest:{...u.manifest,pages:(t=u.manifest.pages)==null?void 0:t.map(r=>r.id!==l?r:{...r,sections:r.sections.map(n=>n.blocks.some(e=>e.id===s)?{...n,blocks:n.blocks.map(e=>e.id===s?{...e,props:{...e.props,...a}}:e)}:n)})}}}),deleteBlock:(l,s)=>o(a=>{var u;return{manifest:{...a.manifest,pages:(u=a.manifest.pages)==null?void 0:u.map(t=>t.id!==l?t:{...t,sections:t.sections.map(r=>({...r,blocks:r.blocks.filter(n=>n.id!==s)}))})}}})})),Ll=Se.z.object({key:Se.z.string(),label:Se.z.string(),type:Se.z.enum(["text","number","currency","date","boolean","status","email","image","textarea"]),required:Se.z.boolean().optional(),description:Se.z.string().optional(),defaultValue:Se.z.any().optional()}),Ul=Se.z.object({id:Se.z.string(),name:Se.z.string(),fields:Se.z.array(Ll),defaultView:Se.z.enum(["table","grid","list"]).optional(),features:Se.z.object({searchable:Se.z.boolean().optional(),creatable:Se.z.boolean().optional(),editable:Se.z.boolean().optional(),deletable:Se.z.boolean().optional(),exportable:Se.z.boolean().optional()}).optional()}),Dl=Se.z.object({id:Se.z.string().min(1,"Signal ID is required"),label:Se.z.string(),description:Se.z.string().optional(),kind:Se.z.enum(["sensor","actuator","setpoint","metric","status","kpi"]),source:Se.z.enum(["mock","mqtt","http","derived","local"]),topic:Se.z.string().optional(),endpoint:Se.z.string().optional(),jsonPath:Se.z.string().optional(),refreshRate:Se.z.number().optional().default(1e3),defaultValue:Se.z.any().optional(),unit:Se.z.string().optional(),min:Se.z.number().optional(),max:Se.z.number().optional()}),Fl=Se.z.object({id:Se.z.string(),name:Se.z.string(),description:Se.z.string().optional(),type:Se.z.string(),category:Se.z.string().default("logical"),signals:Se.z.array(Se.z.string()),ui:Se.z.object({icon:Se.z.string().optional(),color:Se.z.string().optional(),dashboardComponent:Se.z.string().optional()}).optional()}),Wl=Se.z.object({id:Se.z.string(),type:Se.z.enum(["signal_change","manual_action","schedule","webhook"]),config:Se.z.record(Se.z.string(),Se.z.any())}),$l=Se.z.object({id:Se.z.string(),type:Se.z.enum(["update_resource","send_notification","mqtt_publish","api_call","navigate","agent_task"]),config:Se.z.record(Se.z.string(),Se.z.any())}),ql=Se.z.object({id:Se.z.string(),name:Se.z.string(),active:Se.z.boolean().default(!0),trigger:Wl,actions:Se.z.array($l)}),Vl=Se.z.object({id:Se.z.string(),type:Se.z.string(),props:Se.z.record(Se.z.string(),Se.z.any()),layout:Se.z.object({colSpan:Se.z.number().optional(),rowSpan:Se.z.number().optional()}).optional()}),zl=Se.z.object({id:Se.z.string(),title:Se.z.string().optional(),description:Se.z.string().optional(),layout:Se.z.object({columns:Se.z.number().optional(),variant:Se.z.enum(["grid","stack","split"]).optional()}).optional(),blocks:Se.z.array(Vl)}),Kl=Se.z.object({id:Se.z.string(),slug:Se.z.string(),title:Se.z.string(),description:Se.z.string().optional(),icon:Se.z.string().optional(),sections:Se.z.array(zl)}),ph=Se.z.object({meta:Se.z.object({name:Se.z.string(),version:Se.z.string(),description:Se.z.string().optional(),author:Se.z.string().optional(),createdAt:Se.z.string().optional()}),config:Se.z.object({theme:Se.z.enum(["light","dark","system","corporate","midnight","blueprint"]).default("system"),mockMode:Se.z.boolean().default(!0),brokerUrl:Se.z.string().optional()}),modules:Se.z.array(Se.z.string()).optional(),resources:Se.z.array(Ul).optional(),domain:Se.z.object({signals:Se.z.array(Dl),entities:Se.z.array(Fl),workflows:Se.z.array(ql).optional()}),pages:Se.z.array(Kl).optional()}),Hl=o=>{switch(o){case"fresh":return"online";case"stale":return"warning";case"disconnected":return"offline";case"error":return"error";default:return"offline"}},dh=({block:o,getComponent:l,getMockData:s})=>{const a=l(o.type),u=Nl(),{signalId:t,dataId:r,...n}=o.props,e={...n,dataId:r,signalId:t};if(r){const i=s(r);e.data=i||[],e.rowData=i||[]}if(t&&u&&t in u){const i=u[t];if(i){const c=typeof i=="object"&&i!==null,h=c&&"value"in i?i.value:i,d=c&&"status"in i?i.status:"fresh";e.value=typeof h=="number"?h:String(h),e.status=Hl(String(d))}else e.status=Hl("disconnected")}return Ie.jsx(a,{...e},o.id)};/**
103
103
  * @remix-run/router v1.23.2
104
104
  *
105
105
  * Copyright (c) Remix Software Inc.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ramme-io/kernel",
3
- "version": "1.4.5",
3
+ "version": "2.0.0-alpha.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.umd.js",
@@ -32,5 +32,11 @@
32
32
  "vite": "^5.3.1",
33
33
  "vite-plugin-dts": "^3.9.1",
34
34
  "zod": "^3.23.8"
35
+ },
36
+ "dependencies": {
37
+ "@types/react-syntax-highlighter": "^15.5.13",
38
+ "react-markdown": "^10.1.0",
39
+ "react-syntax-highlighter": "^16.1.1",
40
+ "remark-gfm": "^4.0.1"
35
41
  }
36
42
  }