tokensafe-ui 0.1.8 → 0.1.9

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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createTokensafeMcpServer
3
- } from "./chunk-W4DCPVD6.js";
3
+ } from "./chunk-GVVBOP4E.js";
4
4
 
5
5
  // src/mcp.ts
6
6
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  activeInstances
3
- } from "./chunk-JQRAF2JG.js";
3
+ } from "./chunk-GBP5S5VP.js";
4
4
 
5
5
  // ../observer/dist/index.js
6
6
  import fs from "fs";
@@ -837,8 +837,14 @@ var SVG_TAGS = /* @__PURE__ */ new Set([
837
837
  ]);
838
838
  function h(type, props, ...children) {
839
839
  const normalizedProps = props || {};
840
- const flatChildren = children.flat().filter((c) => c !== null && c !== void 0);
841
- if (flatChildren.length > 0 && !normalizedProps.children) {
840
+ let flatChildren = children.flat().filter((c) => c !== null && c !== void 0);
841
+ if (flatChildren.length === 0 && normalizedProps.children) {
842
+ if (Array.isArray(normalizedProps.children)) {
843
+ flatChildren = normalizedProps.children.flat().filter((c) => c !== null && c !== void 0);
844
+ } else {
845
+ flatChildren = [normalizedProps.children];
846
+ }
847
+ } else if (flatChildren.length > 0 && !normalizedProps.children) {
842
848
  normalizedProps.children = flatChildren.length === 1 ? flatChildren[0] : flatChildren;
843
849
  }
844
850
  return {
@@ -1050,7 +1056,6 @@ function convertReactNode(rn) {
1050
1056
  if ("props" in rn && "type" in rn) {
1051
1057
  const props = { ...rn.props || {} };
1052
1058
  const rawChildren = props.children;
1053
- delete props.children;
1054
1059
  let children = [];
1055
1060
  if (Array.isArray(rawChildren)) {
1056
1061
  children = rawChildren.flat().filter((c) => c !== null && c !== void 0).map(convertReactNode);
@@ -1106,20 +1111,26 @@ function renderVNode(node, instance) {
1106
1111
  }
1107
1112
  return root;
1108
1113
  }
1109
- let targetType = node.type;
1114
+ let vnode = node;
1115
+ if ("props" in vnode && (!("children" in vnode) || !Array.isArray(vnode.children) || "$$typeof" in vnode)) {
1116
+ vnode = convertReactNode(vnode);
1117
+ }
1118
+ let targetType = vnode.type;
1110
1119
  if (typeof targetType === "object" && targetType !== null) {
1111
1120
  if (targetType.$$typeof && targetType.type) {
1112
1121
  targetType = targetType.type;
1113
1122
  }
1114
1123
  if (typeof targetType.render === "function") {
1115
- const rendered = targetType.render(node.props, node.props?.ref || null);
1124
+ const rendered = targetType.render(vnode.props, vnode.props?.ref || null);
1116
1125
  return renderVNode(convertReactNode(rendered), instance);
1117
1126
  }
1118
1127
  }
1128
+ const rawChildren = vnode.children ?? vnode.props?.children;
1129
+ const childrenList = Array.isArray(rawChildren) ? rawChildren : rawChildren !== null && rawChildren !== void 0 ? [rawChildren] : [];
1119
1130
  if (typeof targetType === "function") {
1120
1131
  if (targetType === Fragment) {
1121
1132
  const fragment = document.createDocumentFragment();
1122
- for (const child of node.children) {
1133
+ for (const child of childrenList) {
1123
1134
  fragment.appendChild(renderVNode(child, instance));
1124
1135
  }
1125
1136
  return fragment;
@@ -1133,7 +1144,7 @@ function renderVNode(node, instance) {
1133
1144
  let currentNodes = [];
1134
1145
  let currentScope = null;
1135
1146
  effect(() => {
1136
- const whenVal = typeof node.props.when === "function" ? node.props.when() : node.props.when;
1147
+ const whenVal = typeof vnode.props.when === "function" ? vnode.props.when() : vnode.props.when;
1137
1148
  if (currentScope) {
1138
1149
  currentScope.dispose();
1139
1150
  currentScope = null;
@@ -1145,7 +1156,7 @@ function renderVNode(node, instance) {
1145
1156
  if (whenVal) {
1146
1157
  const { result: rendered, scope: branchScope } = createScope(() => {
1147
1158
  const branch = untrack(
1148
- () => typeof node.props.children === "function" ? node.props.children(whenVal) : node.props.children
1159
+ () => typeof vnode.props.children === "function" ? vnode.props.children(whenVal) : vnode.props.children
1149
1160
  );
1150
1161
  return untrack(() => branch ? renderVNode(branch, instance) : null);
1151
1162
  });
@@ -1155,9 +1166,9 @@ function renderVNode(node, instance) {
1155
1166
  parent.insertBefore(rendered, endAnchor);
1156
1167
  currentNodes.push(rendered);
1157
1168
  }
1158
- } else if (node.props.fallback) {
1169
+ } else if (vnode.props.fallback) {
1159
1170
  const { result: rendered, scope: branchScope } = createScope(() => {
1160
- return untrack(() => renderVNode(node.props.fallback, instance));
1171
+ return untrack(() => renderVNode(vnode.props.fallback, instance));
1161
1172
  });
1162
1173
  currentScope = branchScope;
1163
1174
  if (rendered) {
@@ -1172,7 +1183,7 @@ function renderVNode(node, instance) {
1172
1183
  });
1173
1184
  return container;
1174
1185
  }
1175
- if (node.type === For) {
1186
+ if (vnode.type === For) {
1176
1187
  const container = document.createDocumentFragment();
1177
1188
  const startAnchor = document.createComment("agent-dom:for-start");
1178
1189
  const endAnchor = document.createComment("agent-dom:for-end");
@@ -1180,16 +1191,16 @@ function renderVNode(node, instance) {
1180
1191
  container.appendChild(endAnchor);
1181
1192
  let currentMap = /* @__PURE__ */ new Map();
1182
1193
  effect(() => {
1183
- const rawItems = typeof node.props.each === "function" ? node.props.each() : node.props.each || [];
1194
+ const rawItems = typeof vnode.props.each === "function" ? vnode.props.each() : vnode.props.each || [];
1184
1195
  const items = Array.isArray(rawItems) ? rawItems : [];
1185
1196
  const newMap = /* @__PURE__ */ new Map();
1186
1197
  const parent = endAnchor.parentNode || container;
1187
1198
  items.forEach((item, idx) => {
1188
1199
  let itemKey;
1189
- if (typeof node.props.key === "function") {
1190
- itemKey = node.props.key(item, idx);
1191
- } else if (node.props.key && typeof item === "object") {
1192
- itemKey = item[node.props.key];
1200
+ if (typeof vnode.props.key === "function") {
1201
+ itemKey = vnode.props.key(item, idx);
1202
+ } else if (vnode.props.key && typeof item === "object") {
1203
+ itemKey = item[vnode.props.key];
1193
1204
  } else {
1194
1205
  itemKey = item?.id ?? item?.key ?? (typeof item === "string" ? item : idx);
1195
1206
  }
@@ -1202,7 +1213,7 @@ function renderVNode(node, instance) {
1202
1213
  } else {
1203
1214
  const indexSignal = signal(idx);
1204
1215
  const { result: rendered, scope: itemScope } = createScope(() => {
1205
- const childVNode2 = untrack(() => node.props.children(item, () => indexSignal.value));
1216
+ const childVNode2 = untrack(() => vnode.props.children(item, () => indexSignal.value));
1206
1217
  return untrack(() => renderVNode(childVNode2, instance));
1207
1218
  });
1208
1219
  existing = { key: itemKey, node: rendered, indexSignal, scope: itemScope };
@@ -1227,7 +1238,7 @@ function renderVNode(node, instance) {
1227
1238
  }
1228
1239
  if (targetType === ErrorBoundary) {
1229
1240
  try {
1230
- return renderVNode(node.props.children, instance);
1241
+ return renderVNode(vnode.props.children, instance);
1231
1242
  } catch (err) {
1232
1243
  if (instance?.runtimeLog) {
1233
1244
  instance.runtimeLog.push({
@@ -1236,20 +1247,20 @@ function renderVNode(node, instance) {
1236
1247
  error: `ErrorBoundary: ${err.message}`
1237
1248
  });
1238
1249
  }
1239
- return renderVNode(node.props.fallback(err), instance);
1250
+ return renderVNode(vnode.props.fallback(err), instance);
1240
1251
  }
1241
1252
  }
1242
- let childVNode = targetType(node.props);
1253
+ let childVNode = targetType(vnode.props);
1243
1254
  if (typeof childVNode === "function") {
1244
1255
  childVNode = childVNode();
1245
1256
  }
1246
1257
  return renderVNode(childVNode, instance);
1247
1258
  }
1248
- const tagName = typeof node.type === "string" ? node.type : String(node.type);
1259
+ const tagName = typeof vnode.type === "string" ? vnode.type : String(vnode.type);
1249
1260
  const isSvg = SVG_TAGS.has(tagName.toLowerCase());
1250
1261
  const el = isSvg ? document.createElementNS(SVG_NS, tagName) : document.createElement(tagName);
1251
1262
  const cleanups = instance?._cleanups;
1252
- for (const [key, value] of Object.entries(node.props)) {
1263
+ for (const [key, value] of Object.entries(vnode.props || {})) {
1253
1264
  if (key === "children") continue;
1254
1265
  if (key === "ref") {
1255
1266
  if (typeof value === "function") {
@@ -1280,7 +1291,7 @@ function renderVNode(node, instance) {
1280
1291
  if (key.startsWith("on") && typeof value === "function") {
1281
1292
  const eventName = key.slice(2).toLowerCase();
1282
1293
  el.addEventListener(eventName, value);
1283
- if (value?._actionName && !node.props["data-agent-action"]) {
1294
+ if (value?._actionName && !vnode.props["data-agent-action"]) {
1284
1295
  el.setAttribute("data-agent-action", value._actionName);
1285
1296
  }
1286
1297
  } else if (key === "class" || key === "className") {
@@ -1334,7 +1345,7 @@ function renderVNode(node, instance) {
1334
1345
  el.setAttribute(key, value === true ? "" : String(value));
1335
1346
  }
1336
1347
  }
1337
- for (const child of node.children) {
1348
+ for (const child of childrenList) {
1338
1349
  if (typeof child === "function") {
1339
1350
  const parentAgentId = el.getAttribute("data-agent-id") || el.tagName.toLowerCase();
1340
1351
  const startAnchor = document.createComment(`tokensafe:dyn-start`);
@@ -1432,44 +1443,50 @@ function vnodeToString(node) {
1432
1443
  if (Array.isArray(node)) {
1433
1444
  return node.map(vnodeToString).join("");
1434
1445
  }
1435
- let targetType = node.type;
1446
+ let vnode = node;
1447
+ if ("props" in vnode && (!("children" in vnode) || !Array.isArray(vnode.children) || "$$typeof" in vnode)) {
1448
+ vnode = convertReactNode(vnode);
1449
+ }
1450
+ let targetType = vnode.type;
1436
1451
  if (typeof targetType === "object" && targetType !== null) {
1437
1452
  if (targetType.$$typeof && targetType.type) {
1438
1453
  targetType = targetType.type;
1439
1454
  }
1440
1455
  if (typeof targetType.render === "function") {
1441
- const rendered = targetType.render(node.props, node.props?.ref || null);
1456
+ const rendered = targetType.render(vnode.props, vnode.props?.ref || null);
1442
1457
  return vnodeToString(convertReactNode(rendered));
1443
1458
  }
1444
1459
  }
1460
+ const rawChildren = vnode.children ?? vnode.props?.children;
1461
+ const childrenList = Array.isArray(rawChildren) ? rawChildren : rawChildren !== null && rawChildren !== void 0 ? [rawChildren] : [];
1445
1462
  if (typeof targetType === "function") {
1446
1463
  if (targetType === Fragment) {
1447
- return (node.children || []).map(vnodeToString).join("");
1464
+ return childrenList.map(vnodeToString).join("");
1448
1465
  }
1449
1466
  if (targetType === Show) {
1450
- const whenVal = typeof node.props.when === "function" ? node.props.when() : node.props.when;
1451
- const branch = whenVal ? typeof node.props.children === "function" ? node.props.children(whenVal) : node.props.children : node.props.fallback;
1467
+ const whenVal = typeof vnode.props.when === "function" ? vnode.props.when() : vnode.props.when;
1468
+ const branch = whenVal ? typeof vnode.props.children === "function" ? vnode.props.children(whenVal) : vnode.props.children : vnode.props.fallback;
1452
1469
  return branch ? vnodeToString(branch) : "";
1453
1470
  }
1454
1471
  if (targetType === For) {
1455
- const rawItems = typeof node.props.each === "function" ? node.props.each() : node.props.each || [];
1472
+ const rawItems = typeof vnode.props.each === "function" ? vnode.props.each() : vnode.props.each || [];
1456
1473
  const items = Array.isArray(rawItems) ? rawItems : [];
1457
1474
  return items.map((item, idx) => {
1458
- const childNode = node.props.children(item, () => idx);
1475
+ const childNode = vnode.props.children(item, () => idx);
1459
1476
  return vnodeToString(childNode);
1460
1477
  }).join("");
1461
1478
  }
1462
1479
  if (targetType === ErrorBoundary) {
1463
1480
  try {
1464
- return vnodeToString(node.props.children);
1481
+ return vnodeToString(vnode.props.children);
1465
1482
  } catch (err) {
1466
- return vnodeToString(node.props.fallback(err));
1483
+ return vnodeToString(vnode.props.fallback(err));
1467
1484
  }
1468
1485
  }
1469
- return vnodeToString(targetType(node.props));
1486
+ return vnodeToString(targetType(vnode.props));
1470
1487
  }
1471
1488
  const attrs = [];
1472
- for (let [key, value] of Object.entries(node.props)) {
1489
+ for (let [key, value] of Object.entries(vnode.props || {})) {
1473
1490
  if (key === "children" || key.startsWith("on")) continue;
1474
1491
  if (typeof value === "function") {
1475
1492
  try {
@@ -1487,15 +1504,15 @@ function vnodeToString(node) {
1487
1504
  }
1488
1505
  }
1489
1506
  const attrStr = attrs.length > 0 ? " " + attrs.join(" ") : "";
1490
- if (node.props?.dangerouslySetInnerHTML?.__html) {
1491
- return `<${node.type}${attrStr}>${node.props.dangerouslySetInnerHTML.__html}</${node.type}>`;
1507
+ if (vnode.props?.dangerouslySetInnerHTML?.__html) {
1508
+ return `<${vnode.type}${attrStr}>${vnode.props.dangerouslySetInnerHTML.__html}</${vnode.type}>`;
1492
1509
  }
1493
- if (node.props?.innerHTML) {
1494
- const raw = typeof node.props.innerHTML === "function" ? node.props.innerHTML() : node.props.innerHTML;
1495
- return `<${node.type}${attrStr}>${raw}</${node.type}>`;
1510
+ if (vnode.props?.innerHTML) {
1511
+ const raw = typeof vnode.props.innerHTML === "function" ? vnode.props.innerHTML() : vnode.props.innerHTML;
1512
+ return `<${vnode.type}${attrStr}>${raw}</${vnode.type}>`;
1496
1513
  }
1497
- const childrenStr = node.children.map(vnodeToString).join("");
1498
- return `<${node.type}${attrStr}>${childrenStr}</${node.type}>`;
1514
+ const childrenStr = childrenList.map(vnodeToString).join("");
1515
+ return `<${vnode.type}${attrStr}>${childrenStr}</${vnode.type}>`;
1499
1516
  }
1500
1517
  function escapeHtml(str) {
1501
1518
  return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  buildDependencyGraph,
3
3
  observeDiff
4
- } from "./chunk-GJWCBVCA.js";
4
+ } from "./chunk-4PIOAQC3.js";
5
5
  import {
6
6
  applyPatch
7
7
  } from "./chunk-N7XIVYCL.js";
@@ -9,7 +9,7 @@ import {
9
9
  activeInstances,
10
10
  testAction,
11
11
  testEffect
12
- } from "./chunk-JQRAF2JG.js";
12
+ } from "./chunk-GBP5S5VP.js";
13
13
 
14
14
  // ../mcp/dist/index.js
15
15
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  atomicApplySourceEdit,
3
3
  validateWorkspacePath
4
- } from "./chunk-W4DCPVD6.js";
4
+ } from "./chunk-GVVBOP4E.js";
5
5
  import {
6
6
  buildDependencyGraph,
7
7
  observe
8
- } from "./chunk-GJWCBVCA.js";
8
+ } from "./chunk-4PIOAQC3.js";
9
9
  import {
10
10
  testAction
11
- } from "./chunk-JQRAF2JG.js";
11
+ } from "./chunk-GBP5S5VP.js";
12
12
 
13
13
  // ../oumv/dist/chunk-ONAJHNWR.js
14
14
  import fs from "fs";
package/dist/cli.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  startMcpServer
3
- } from "./chunk-UXZDGOF5.js";
4
- import "./chunk-W4DCPVD6.js";
5
- import "./chunk-GJWCBVCA.js";
3
+ } from "./chunk-2YH7IQ3P.js";
4
+ import "./chunk-GVVBOP4E.js";
5
+ import "./chunk-4PIOAQC3.js";
6
6
  import "./chunk-N7XIVYCL.js";
7
- import "./chunk-JQRAF2JG.js";
7
+ import "./chunk-GBP5S5VP.js";
8
8
 
9
9
  // src/cli.ts
10
10
  function parseCliArgs(argv) {
package/dist/index.cjs CHANGED
@@ -897,8 +897,14 @@ var SVG_TAGS = /* @__PURE__ */ new Set([
897
897
  ]);
898
898
  function h(type, props, ...children) {
899
899
  const normalizedProps = props || {};
900
- const flatChildren = children.flat().filter((c) => c !== null && c !== void 0);
901
- if (flatChildren.length > 0 && !normalizedProps.children) {
900
+ let flatChildren = children.flat().filter((c) => c !== null && c !== void 0);
901
+ if (flatChildren.length === 0 && normalizedProps.children) {
902
+ if (Array.isArray(normalizedProps.children)) {
903
+ flatChildren = normalizedProps.children.flat().filter((c) => c !== null && c !== void 0);
904
+ } else {
905
+ flatChildren = [normalizedProps.children];
906
+ }
907
+ } else if (flatChildren.length > 0 && !normalizedProps.children) {
902
908
  normalizedProps.children = flatChildren.length === 1 ? flatChildren[0] : flatChildren;
903
909
  }
904
910
  return {
@@ -1110,7 +1116,6 @@ function convertReactNode(rn) {
1110
1116
  if ("props" in rn && "type" in rn) {
1111
1117
  const props = { ...rn.props || {} };
1112
1118
  const rawChildren = props.children;
1113
- delete props.children;
1114
1119
  let children = [];
1115
1120
  if (Array.isArray(rawChildren)) {
1116
1121
  children = rawChildren.flat().filter((c) => c !== null && c !== void 0).map(convertReactNode);
@@ -1166,20 +1171,26 @@ function renderVNode(node, instance) {
1166
1171
  }
1167
1172
  return root;
1168
1173
  }
1169
- let targetType = node.type;
1174
+ let vnode = node;
1175
+ if ("props" in vnode && (!("children" in vnode) || !Array.isArray(vnode.children) || "$$typeof" in vnode)) {
1176
+ vnode = convertReactNode(vnode);
1177
+ }
1178
+ let targetType = vnode.type;
1170
1179
  if (typeof targetType === "object" && targetType !== null) {
1171
1180
  if (targetType.$$typeof && targetType.type) {
1172
1181
  targetType = targetType.type;
1173
1182
  }
1174
1183
  if (typeof targetType.render === "function") {
1175
- const rendered = targetType.render(node.props, node.props?.ref || null);
1184
+ const rendered = targetType.render(vnode.props, vnode.props?.ref || null);
1176
1185
  return renderVNode(convertReactNode(rendered), instance);
1177
1186
  }
1178
1187
  }
1188
+ const rawChildren = vnode.children ?? vnode.props?.children;
1189
+ const childrenList = Array.isArray(rawChildren) ? rawChildren : rawChildren !== null && rawChildren !== void 0 ? [rawChildren] : [];
1179
1190
  if (typeof targetType === "function") {
1180
1191
  if (targetType === Fragment) {
1181
1192
  const fragment = document.createDocumentFragment();
1182
- for (const child of node.children) {
1193
+ for (const child of childrenList) {
1183
1194
  fragment.appendChild(renderVNode(child, instance));
1184
1195
  }
1185
1196
  return fragment;
@@ -1193,7 +1204,7 @@ function renderVNode(node, instance) {
1193
1204
  let currentNodes = [];
1194
1205
  let currentScope = null;
1195
1206
  effect(() => {
1196
- const whenVal = typeof node.props.when === "function" ? node.props.when() : node.props.when;
1207
+ const whenVal = typeof vnode.props.when === "function" ? vnode.props.when() : vnode.props.when;
1197
1208
  if (currentScope) {
1198
1209
  currentScope.dispose();
1199
1210
  currentScope = null;
@@ -1205,7 +1216,7 @@ function renderVNode(node, instance) {
1205
1216
  if (whenVal) {
1206
1217
  const { result: rendered, scope: branchScope } = createScope(() => {
1207
1218
  const branch = untrack(
1208
- () => typeof node.props.children === "function" ? node.props.children(whenVal) : node.props.children
1219
+ () => typeof vnode.props.children === "function" ? vnode.props.children(whenVal) : vnode.props.children
1209
1220
  );
1210
1221
  return untrack(() => branch ? renderVNode(branch, instance) : null);
1211
1222
  });
@@ -1215,9 +1226,9 @@ function renderVNode(node, instance) {
1215
1226
  parent.insertBefore(rendered, endAnchor);
1216
1227
  currentNodes.push(rendered);
1217
1228
  }
1218
- } else if (node.props.fallback) {
1229
+ } else if (vnode.props.fallback) {
1219
1230
  const { result: rendered, scope: branchScope } = createScope(() => {
1220
- return untrack(() => renderVNode(node.props.fallback, instance));
1231
+ return untrack(() => renderVNode(vnode.props.fallback, instance));
1221
1232
  });
1222
1233
  currentScope = branchScope;
1223
1234
  if (rendered) {
@@ -1232,7 +1243,7 @@ function renderVNode(node, instance) {
1232
1243
  });
1233
1244
  return container;
1234
1245
  }
1235
- if (node.type === For) {
1246
+ if (vnode.type === For) {
1236
1247
  const container = document.createDocumentFragment();
1237
1248
  const startAnchor = document.createComment("agent-dom:for-start");
1238
1249
  const endAnchor = document.createComment("agent-dom:for-end");
@@ -1240,16 +1251,16 @@ function renderVNode(node, instance) {
1240
1251
  container.appendChild(endAnchor);
1241
1252
  let currentMap = /* @__PURE__ */ new Map();
1242
1253
  effect(() => {
1243
- const rawItems = typeof node.props.each === "function" ? node.props.each() : node.props.each || [];
1254
+ const rawItems = typeof vnode.props.each === "function" ? vnode.props.each() : vnode.props.each || [];
1244
1255
  const items = Array.isArray(rawItems) ? rawItems : [];
1245
1256
  const newMap = /* @__PURE__ */ new Map();
1246
1257
  const parent = endAnchor.parentNode || container;
1247
1258
  items.forEach((item, idx) => {
1248
1259
  let itemKey;
1249
- if (typeof node.props.key === "function") {
1250
- itemKey = node.props.key(item, idx);
1251
- } else if (node.props.key && typeof item === "object") {
1252
- itemKey = item[node.props.key];
1260
+ if (typeof vnode.props.key === "function") {
1261
+ itemKey = vnode.props.key(item, idx);
1262
+ } else if (vnode.props.key && typeof item === "object") {
1263
+ itemKey = item[vnode.props.key];
1253
1264
  } else {
1254
1265
  itemKey = item?.id ?? item?.key ?? (typeof item === "string" ? item : idx);
1255
1266
  }
@@ -1262,7 +1273,7 @@ function renderVNode(node, instance) {
1262
1273
  } else {
1263
1274
  const indexSignal = signal(idx);
1264
1275
  const { result: rendered, scope: itemScope } = createScope(() => {
1265
- const childVNode2 = untrack(() => node.props.children(item, () => indexSignal.value));
1276
+ const childVNode2 = untrack(() => vnode.props.children(item, () => indexSignal.value));
1266
1277
  return untrack(() => renderVNode(childVNode2, instance));
1267
1278
  });
1268
1279
  existing = { key: itemKey, node: rendered, indexSignal, scope: itemScope };
@@ -1287,7 +1298,7 @@ function renderVNode(node, instance) {
1287
1298
  }
1288
1299
  if (targetType === ErrorBoundary) {
1289
1300
  try {
1290
- return renderVNode(node.props.children, instance);
1301
+ return renderVNode(vnode.props.children, instance);
1291
1302
  } catch (err) {
1292
1303
  if (instance?.runtimeLog) {
1293
1304
  instance.runtimeLog.push({
@@ -1296,20 +1307,20 @@ function renderVNode(node, instance) {
1296
1307
  error: `ErrorBoundary: ${err.message}`
1297
1308
  });
1298
1309
  }
1299
- return renderVNode(node.props.fallback(err), instance);
1310
+ return renderVNode(vnode.props.fallback(err), instance);
1300
1311
  }
1301
1312
  }
1302
- let childVNode = targetType(node.props);
1313
+ let childVNode = targetType(vnode.props);
1303
1314
  if (typeof childVNode === "function") {
1304
1315
  childVNode = childVNode();
1305
1316
  }
1306
1317
  return renderVNode(childVNode, instance);
1307
1318
  }
1308
- const tagName = typeof node.type === "string" ? node.type : String(node.type);
1319
+ const tagName = typeof vnode.type === "string" ? vnode.type : String(vnode.type);
1309
1320
  const isSvg = SVG_TAGS.has(tagName.toLowerCase());
1310
1321
  const el = isSvg ? document.createElementNS(SVG_NS, tagName) : document.createElement(tagName);
1311
1322
  const cleanups = instance?._cleanups;
1312
- for (const [key, value] of Object.entries(node.props)) {
1323
+ for (const [key, value] of Object.entries(vnode.props || {})) {
1313
1324
  if (key === "children") continue;
1314
1325
  if (key === "ref") {
1315
1326
  if (typeof value === "function") {
@@ -1340,7 +1351,7 @@ function renderVNode(node, instance) {
1340
1351
  if (key.startsWith("on") && typeof value === "function") {
1341
1352
  const eventName = key.slice(2).toLowerCase();
1342
1353
  el.addEventListener(eventName, value);
1343
- if (value?._actionName && !node.props["data-agent-action"]) {
1354
+ if (value?._actionName && !vnode.props["data-agent-action"]) {
1344
1355
  el.setAttribute("data-agent-action", value._actionName);
1345
1356
  }
1346
1357
  } else if (key === "class" || key === "className") {
@@ -1394,7 +1405,7 @@ function renderVNode(node, instance) {
1394
1405
  el.setAttribute(key, value === true ? "" : String(value));
1395
1406
  }
1396
1407
  }
1397
- for (const child of node.children) {
1408
+ for (const child of childrenList) {
1398
1409
  if (typeof child === "function") {
1399
1410
  const parentAgentId = el.getAttribute("data-agent-id") || el.tagName.toLowerCase();
1400
1411
  const startAnchor = document.createComment(`tokensafe:dyn-start`);
@@ -1492,44 +1503,50 @@ function vnodeToString(node) {
1492
1503
  if (Array.isArray(node)) {
1493
1504
  return node.map(vnodeToString).join("");
1494
1505
  }
1495
- let targetType = node.type;
1506
+ let vnode = node;
1507
+ if ("props" in vnode && (!("children" in vnode) || !Array.isArray(vnode.children) || "$$typeof" in vnode)) {
1508
+ vnode = convertReactNode(vnode);
1509
+ }
1510
+ let targetType = vnode.type;
1496
1511
  if (typeof targetType === "object" && targetType !== null) {
1497
1512
  if (targetType.$$typeof && targetType.type) {
1498
1513
  targetType = targetType.type;
1499
1514
  }
1500
1515
  if (typeof targetType.render === "function") {
1501
- const rendered = targetType.render(node.props, node.props?.ref || null);
1516
+ const rendered = targetType.render(vnode.props, vnode.props?.ref || null);
1502
1517
  return vnodeToString(convertReactNode(rendered));
1503
1518
  }
1504
1519
  }
1520
+ const rawChildren = vnode.children ?? vnode.props?.children;
1521
+ const childrenList = Array.isArray(rawChildren) ? rawChildren : rawChildren !== null && rawChildren !== void 0 ? [rawChildren] : [];
1505
1522
  if (typeof targetType === "function") {
1506
1523
  if (targetType === Fragment) {
1507
- return (node.children || []).map(vnodeToString).join("");
1524
+ return childrenList.map(vnodeToString).join("");
1508
1525
  }
1509
1526
  if (targetType === Show) {
1510
- const whenVal = typeof node.props.when === "function" ? node.props.when() : node.props.when;
1511
- const branch = whenVal ? typeof node.props.children === "function" ? node.props.children(whenVal) : node.props.children : node.props.fallback;
1527
+ const whenVal = typeof vnode.props.when === "function" ? vnode.props.when() : vnode.props.when;
1528
+ const branch = whenVal ? typeof vnode.props.children === "function" ? vnode.props.children(whenVal) : vnode.props.children : vnode.props.fallback;
1512
1529
  return branch ? vnodeToString(branch) : "";
1513
1530
  }
1514
1531
  if (targetType === For) {
1515
- const rawItems = typeof node.props.each === "function" ? node.props.each() : node.props.each || [];
1532
+ const rawItems = typeof vnode.props.each === "function" ? vnode.props.each() : vnode.props.each || [];
1516
1533
  const items = Array.isArray(rawItems) ? rawItems : [];
1517
1534
  return items.map((item, idx) => {
1518
- const childNode = node.props.children(item, () => idx);
1535
+ const childNode = vnode.props.children(item, () => idx);
1519
1536
  return vnodeToString(childNode);
1520
1537
  }).join("");
1521
1538
  }
1522
1539
  if (targetType === ErrorBoundary) {
1523
1540
  try {
1524
- return vnodeToString(node.props.children);
1541
+ return vnodeToString(vnode.props.children);
1525
1542
  } catch (err) {
1526
- return vnodeToString(node.props.fallback(err));
1543
+ return vnodeToString(vnode.props.fallback(err));
1527
1544
  }
1528
1545
  }
1529
- return vnodeToString(targetType(node.props));
1546
+ return vnodeToString(targetType(vnode.props));
1530
1547
  }
1531
1548
  const attrs = [];
1532
- for (let [key, value] of Object.entries(node.props)) {
1549
+ for (let [key, value] of Object.entries(vnode.props || {})) {
1533
1550
  if (key === "children" || key.startsWith("on")) continue;
1534
1551
  if (typeof value === "function") {
1535
1552
  try {
@@ -1547,15 +1564,15 @@ function vnodeToString(node) {
1547
1564
  }
1548
1565
  }
1549
1566
  const attrStr = attrs.length > 0 ? " " + attrs.join(" ") : "";
1550
- if (node.props?.dangerouslySetInnerHTML?.__html) {
1551
- return `<${node.type}${attrStr}>${node.props.dangerouslySetInnerHTML.__html}</${node.type}>`;
1567
+ if (vnode.props?.dangerouslySetInnerHTML?.__html) {
1568
+ return `<${vnode.type}${attrStr}>${vnode.props.dangerouslySetInnerHTML.__html}</${vnode.type}>`;
1552
1569
  }
1553
- if (node.props?.innerHTML) {
1554
- const raw = typeof node.props.innerHTML === "function" ? node.props.innerHTML() : node.props.innerHTML;
1555
- return `<${node.type}${attrStr}>${raw}</${node.type}>`;
1570
+ if (vnode.props?.innerHTML) {
1571
+ const raw = typeof vnode.props.innerHTML === "function" ? vnode.props.innerHTML() : vnode.props.innerHTML;
1572
+ return `<${vnode.type}${attrStr}>${raw}</${vnode.type}>`;
1556
1573
  }
1557
- const childrenStr = node.children.map(vnodeToString).join("");
1558
- return `<${node.type}${attrStr}>${childrenStr}</${node.type}>`;
1574
+ const childrenStr = childrenList.map(vnodeToString).join("");
1575
+ return `<${vnode.type}${attrStr}>${childrenStr}</${vnode.type}>`;
1559
1576
  }
1560
1577
  function escapeHtml(str) {
1561
1578
  return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
package/dist/index.js CHANGED
@@ -34,7 +34,7 @@ import {
34
34
  unmount,
35
35
  untrack,
36
36
  z3
37
- } from "./chunk-JQRAF2JG.js";
37
+ } from "./chunk-GBP5S5VP.js";
38
38
  export {
39
39
  EffectRunner,
40
40
  ErrorBoundary,
package/dist/mcp.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  startMcpServer
3
- } from "./chunk-UXZDGOF5.js";
3
+ } from "./chunk-2YH7IQ3P.js";
4
4
  import {
5
5
  MCP_SERVER_VERSION,
6
6
  atomicApplySourceEdit,
@@ -10,10 +10,10 @@ import {
10
10
  inspectComponentContract,
11
11
  validateSourceSyntaxAndTypes,
12
12
  validateWorkspacePath
13
- } from "./chunk-W4DCPVD6.js";
14
- import "./chunk-GJWCBVCA.js";
13
+ } from "./chunk-GVVBOP4E.js";
14
+ import "./chunk-4PIOAQC3.js";
15
15
  import "./chunk-N7XIVYCL.js";
16
- import "./chunk-JQRAF2JG.js";
16
+ import "./chunk-GBP5S5VP.js";
17
17
  export {
18
18
  MCP_SERVER_VERSION,
19
19
  atomicApplySourceEdit,
package/dist/observer.js CHANGED
@@ -4,8 +4,8 @@ import {
4
4
  getSemanticSnapshot,
5
5
  observe,
6
6
  observeDiff
7
- } from "./chunk-GJWCBVCA.js";
8
- import "./chunk-JQRAF2JG.js";
7
+ } from "./chunk-4PIOAQC3.js";
8
+ import "./chunk-GBP5S5VP.js";
9
9
  export {
10
10
  OBSERVER_VERSION,
11
11
  buildDependencyGraph,
package/dist/oumv.js CHANGED
@@ -9,11 +9,11 @@ import {
9
9
  isReducerLike,
10
10
  isReduxStore,
11
11
  isZustandStore
12
- } from "./chunk-OE2N2PMS.js";
13
- import "./chunk-W4DCPVD6.js";
14
- import "./chunk-GJWCBVCA.js";
12
+ } from "./chunk-LFFVZCNL.js";
13
+ import "./chunk-GVVBOP4E.js";
14
+ import "./chunk-4PIOAQC3.js";
15
15
  import "./chunk-N7XIVYCL.js";
16
- import "./chunk-JQRAF2JG.js";
16
+ import "./chunk-GBP5S5VP.js";
17
17
  export {
18
18
  connectContext,
19
19
  connectReducer,
package/dist/react.js CHANGED
@@ -7,11 +7,11 @@ import {
7
7
  isReducerLike,
8
8
  isReduxStore,
9
9
  isZustandStore
10
- } from "./chunk-OE2N2PMS.js";
11
- import "./chunk-W4DCPVD6.js";
12
- import "./chunk-GJWCBVCA.js";
10
+ } from "./chunk-LFFVZCNL.js";
11
+ import "./chunk-GVVBOP4E.js";
12
+ import "./chunk-4PIOAQC3.js";
13
13
  import "./chunk-N7XIVYCL.js";
14
- import "./chunk-JQRAF2JG.js";
14
+ import "./chunk-GBP5S5VP.js";
15
15
  export {
16
16
  connectContext,
17
17
  connectReducer,
package/dist/testing.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  testAction
3
- } from "./chunk-JQRAF2JG.js";
3
+ } from "./chunk-GBP5S5VP.js";
4
4
  export {
5
5
  testAction
6
6
  };
package/dist/vite.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  hotReloadComponent,
7
7
  testAction,
8
8
  testEffect
9
- } from "./chunk-JQRAF2JG.js";
9
+ } from "./chunk-GBP5S5VP.js";
10
10
 
11
11
  // ../vite/dist/index.js
12
12
  import * as parser from "@babel/parser";
package/dist/vue.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  createVueAdapter
3
- } from "./chunk-OE2N2PMS.js";
4
- import "./chunk-W4DCPVD6.js";
5
- import "./chunk-GJWCBVCA.js";
3
+ } from "./chunk-LFFVZCNL.js";
4
+ import "./chunk-GVVBOP4E.js";
5
+ import "./chunk-4PIOAQC3.js";
6
6
  import "./chunk-N7XIVYCL.js";
7
- import "./chunk-JQRAF2JG.js";
7
+ import "./chunk-GBP5S5VP.js";
8
8
  export {
9
9
  createVueAdapter
10
10
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tokensafe-ui",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "Deterministic, token-efficient frontend reactive micro-framework for AI coding agents",
5
5
  "type": "module",
6
6
  "files": [