@tomaszjarosz/react-visualizers 0.4.9 → 0.4.11

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.js CHANGED
@@ -4438,7 +4438,7 @@ const DPVisualizerComponent = ({
4438
4438
  ] })
4439
4439
  ] })
4440
4440
  ] }),
4441
- currentI > 0 && currentW > 0 && /* @__PURE__ */ jsxs("div", { className: "mt-4 p-3 bg-white rounded-lg border-2 border-purple-300", children: [
4441
+ /* @__PURE__ */ jsx("div", { className: "mt-4 p-3 bg-white rounded-lg border-2 border-purple-300 min-h-[76px]", children: currentI > 0 && currentW > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
4442
4442
  /* @__PURE__ */ jsxs("div", { className: "text-sm font-semibold text-purple-800 mb-2", children: [
4443
4443
  "Current: dp[",
4444
4444
  currentI,
@@ -4460,7 +4460,7 @@ const DPVisualizerComponent = ({
4460
4460
  ] }),
4461
4461
  decision && /* @__PURE__ */ jsx("div", { className: `px-3 py-1 rounded-full font-bold ${decision === "take" ? "bg-green-100 text-green-700" : "bg-yellow-100 text-yellow-700"}`, children: decision === "take" ? "✓ TAKE" : "✗ SKIP" })
4462
4462
  ] })
4463
- ] })
4463
+ ] }) : /* @__PURE__ */ jsx("div", { className: "text-sm text-purple-400 italic text-center py-2", children: "Current cell calculation will appear here..." }) })
4464
4464
  ] }),
4465
4465
  /* @__PURE__ */ jsxs("div", { className: "flex gap-6", children: [
4466
4466
  /* @__PURE__ */ jsxs("div", { className: "w-40", children: [
@@ -7821,7 +7821,7 @@ const TreeSetInterviewVisualizerComponent = ({
7821
7821
  /* @__PURE__ */ jsx("code", { className: "bg-white px-2 py-0.5 rounded", children: "left < node < right" })
7822
7822
  ] }) }),
7823
7823
  /* @__PURE__ */ jsx("div", { className: "mb-4", children: /* @__PURE__ */ jsx("div", { className: "bg-gray-50 rounded-lg p-2 overflow-x-auto", children: tree ? /* @__PURE__ */ jsx("svg", { width: "300", height: "250", className: "mx-auto", children: renderTree(tree) }) : /* @__PURE__ */ jsx("div", { className: "h-32 flex items-center justify-center text-gray-400 text-sm", children: "Empty tree" }) }) }),
7824
- path.length > 0 && /* @__PURE__ */ jsx("div", { className: "mb-4 p-3 bg-gray-100 rounded-lg", children: /* @__PURE__ */ jsxs("div", { className: "text-xs text-gray-600", children: [
7824
+ /* @__PURE__ */ jsx("div", { className: "mb-4 p-3 bg-gray-100 rounded-lg min-h-[44px]", children: /* @__PURE__ */ jsx("div", { className: "text-xs text-gray-600", children: path.length > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
7825
7825
  /* @__PURE__ */ jsx("span", { className: "font-medium", children: "Path:" }),
7826
7826
  " ",
7827
7827
  path.map((v, idx) => /* @__PURE__ */ jsxs(React.Fragment, { children: [
@@ -7834,7 +7834,7 @@ const TreeSetInterviewVisualizerComponent = ({
7834
7834
  }
7835
7835
  )
7836
7836
  ] }, idx))
7837
- ] }) })
7837
+ ] }) : /* @__PURE__ */ jsx("span", { className: "text-gray-400 italic", children: "Path will appear here..." }) }) })
7838
7838
  ] });
7839
7839
  const sidePanel = mode === "interview" ? /* @__PURE__ */ jsx(
7840
7840
  InterviewModePanel,
@@ -8133,13 +8133,13 @@ const SortingInterviewVisualizerComponent = ({
8133
8133
  "]"
8134
8134
  ] })
8135
8135
  ] }, index)) }) }),
8136
- pivot !== void 0 && /* @__PURE__ */ jsx("div", { className: "mb-4 p-3 bg-purple-50 rounded-lg border border-purple-200", children: /* @__PURE__ */ jsxs("div", { className: "text-sm text-purple-800", children: [
8136
+ /* @__PURE__ */ jsx("div", { className: "mb-4 p-3 bg-purple-50 rounded-lg border border-purple-200 min-h-[44px]", children: /* @__PURE__ */ jsx("div", { className: "text-sm text-purple-800", children: pivot !== void 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
8137
8137
  /* @__PURE__ */ jsx("span", { className: "font-medium", children: "Pivot:" }),
8138
8138
  " ",
8139
8139
  array[pivot],
8140
8140
  " at index ",
8141
8141
  pivot
8142
- ] }) })
8142
+ ] }) : /* @__PURE__ */ jsx("span", { className: "text-purple-400 italic", children: "Pivot will be selected..." }) }) })
8143
8143
  ] });
8144
8144
  const modeToggle = /* @__PURE__ */ jsxs("div", { className: "flex gap-1 bg-gray-200 rounded-lg p-0.5", children: [
8145
8145
  /* @__PURE__ */ jsx(
@@ -8938,15 +8938,15 @@ const BloomFilterInterviewVisualizerComponent = ({
8938
8938
  );
8939
8939
  }) })
8940
8940
  ] }),
8941
- result && /* @__PURE__ */ jsx(
8941
+ /* @__PURE__ */ jsx(
8942
8942
  "div",
8943
8943
  {
8944
- className: `mb-4 p-3 rounded-lg border ${result === "probably_yes" ? "bg-amber-50 border-amber-200" : "bg-green-50 border-green-200"}`,
8944
+ className: `mb-4 p-3 rounded-lg border min-h-[44px] ${result === "probably_yes" ? "bg-amber-50 border-amber-200" : result === "definitely_no" ? "bg-green-50 border-green-200" : "bg-gray-50 border-gray-200"}`,
8945
8945
  children: /* @__PURE__ */ jsx(
8946
8946
  "div",
8947
8947
  {
8948
- className: `text-sm font-medium text-center ${result === "probably_yes" ? "text-amber-800" : "text-green-800"}`,
8949
- children: result === "probably_yes" ? "⚠️ Probably in set (could be false positive)" : "✓ Definitely NOT in set"
8948
+ className: `text-sm font-medium text-center ${result === "probably_yes" ? "text-amber-800" : result === "definitely_no" ? "text-green-800" : "text-gray-400 italic"}`,
8949
+ children: result === "probably_yes" ? "⚠️ Probably in set (could be false positive)" : result === "definitely_no" ? "✓ Definitely NOT in set" : "Query result will appear here..."
8950
8950
  }
8951
8951
  )
8952
8952
  }
@@ -10189,7 +10189,7 @@ const DPInterviewVisualizerComponent = ({
10189
10189
  row.map((cell, w) => /* @__PURE__ */ jsx("td", { className: `p-1 text-center rounded ${getCellStyle(i, w)}`, children: cell }, w))
10190
10190
  ] }, i)) })
10191
10191
  ] }) }),
10192
- currentI > 0 && currentW > 0 && decision && /* @__PURE__ */ jsx("div", { className: "mb-4 text-center", children: /* @__PURE__ */ jsx("span", { className: `px-3 py-1 rounded-full font-bold text-sm ${decision === "take" ? "bg-green-100 text-green-700" : "bg-amber-100 text-amber-700"}`, children: decision === "take" ? "✓ TAKE" : "✗ SKIP" }) })
10192
+ /* @__PURE__ */ jsx("div", { className: "mb-4 text-center min-h-[32px] flex items-center justify-center", children: currentI > 0 && currentW > 0 && decision ? /* @__PURE__ */ jsx("span", { className: `px-3 py-1 rounded-full font-bold text-sm ${decision === "take" ? "bg-green-100 text-green-700" : "bg-amber-100 text-amber-700"}`, children: decision === "take" ? "✓ TAKE" : "✗ SKIP" }) : /* @__PURE__ */ jsx("span", { className: "text-gray-400 text-xs italic", children: "Decision will appear here..." }) })
10193
10193
  ] });
10194
10194
  const modeToggle = /* @__PURE__ */ jsxs("div", { className: "flex gap-1 bg-gray-200 rounded-lg p-0.5", children: [
10195
10195
  /* @__PURE__ */ jsx(
@@ -10616,13 +10616,13 @@ const ConsistentHashingInterviewVisualizerComponent = ({
10616
10616
  },
10617
10617
  server
10618
10618
  )) }),
10619
- dataKeys.length > 0 && /* @__PURE__ */ jsx("div", { className: "mb-4 overflow-x-auto", children: /* @__PURE__ */ jsxs("table", { className: "w-full text-xs", children: [
10619
+ /* @__PURE__ */ jsx("div", { className: "mb-4 overflow-x-auto min-h-[100px]", children: /* @__PURE__ */ jsxs("table", { className: "w-full text-xs", children: [
10620
10620
  /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { className: "bg-gray-100", children: [
10621
10621
  /* @__PURE__ */ jsx("th", { className: "px-2 py-1 text-left", children: "Key" }),
10622
10622
  /* @__PURE__ */ jsx("th", { className: "px-2 py-1 text-left", children: "Hash" }),
10623
10623
  /* @__PURE__ */ jsx("th", { className: "px-2 py-1 text-left", children: "Server" })
10624
10624
  ] }) }),
10625
- /* @__PURE__ */ jsx("tbody", { children: dataKeys.map((key) => /* @__PURE__ */ jsxs(
10625
+ /* @__PURE__ */ jsx("tbody", { children: dataKeys.length > 0 ? dataKeys.map((key) => /* @__PURE__ */ jsxs(
10626
10626
  "tr",
10627
10627
  {
10628
10628
  className: `${highlightKey === key.key ? "bg-yellow-100" : ""} ${(movingKeys == null ? void 0 : movingKeys.includes(key.key)) ? "bg-red-100" : ""}`,
@@ -10636,7 +10636,7 @@ const ConsistentHashingInterviewVisualizerComponent = ({
10636
10636
  ]
10637
10637
  },
10638
10638
  key.key
10639
- )) })
10639
+ )) : /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { colSpan: 3, className: "px-2 py-4 text-center text-gray-400 italic", children: "Keys will be added here..." }) }) })
10640
10640
  ] }) })
10641
10641
  ] });
10642
10642
  const modeToggle = /* @__PURE__ */ jsxs("div", { className: "flex gap-1 bg-gray-200 rounded-lg p-0.5", children: [
@@ -11066,10 +11066,10 @@ const RaftInterviewVisualizerComponent = ({
11066
11066
  ] }, node.id);
11067
11067
  })
11068
11068
  ] }) }),
11069
- stepData.messageType && /* @__PURE__ */ jsx("div", { className: "mb-4 text-center", children: /* @__PURE__ */ jsxs("span", { className: "px-3 py-1 bg-purple-100 text-purple-700 rounded-full text-sm font-medium", children: [
11069
+ /* @__PURE__ */ jsx("div", { className: "mb-4 text-center min-h-[32px] flex items-center justify-center", children: stepData.messageType ? /* @__PURE__ */ jsxs("span", { className: "px-3 py-1 bg-purple-100 text-purple-700 rounded-full text-sm font-medium", children: [
11070
11070
  "📨 ",
11071
11071
  stepData.messageType
11072
- ] }) }),
11072
+ ] }) : /* @__PURE__ */ jsx("span", { className: "text-gray-400 text-xs italic", children: "Message type will appear here..." }) }),
11073
11073
  /* @__PURE__ */ jsx("div", { className: "mb-4 overflow-x-auto", children: /* @__PURE__ */ jsxs("table", { className: "w-full text-xs", children: [
11074
11074
  /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { className: "bg-gray-100", children: [
11075
11075
  /* @__PURE__ */ jsx("th", { className: "px-2 py-1 text-left", children: "Node" }),
@@ -11559,11 +11559,11 @@ const TrieInterviewVisualizerComponent = ({
11559
11559
  depth: 0
11560
11560
  }
11561
11561
  ) }),
11562
- stepData.matchedWords && stepData.matchedWords.length > 0 && stepData.operation !== "done" && /* @__PURE__ */ jsx("div", { className: "mt-2 p-2 bg-purple-50 rounded border border-purple-200", children: /* @__PURE__ */ jsxs("div", { className: "text-xs text-purple-700", children: [
11562
+ /* @__PURE__ */ jsx("div", { className: "mt-2 p-2 rounded border min-h-[36px] flex items-center justify-center bg-purple-50 border-purple-200", children: stepData.matchedWords && stepData.matchedWords.length > 0 && stepData.operation !== "done" ? /* @__PURE__ */ jsxs("div", { className: "text-xs text-purple-700", children: [
11563
11563
  /* @__PURE__ */ jsx("span", { className: "font-medium", children: "Found:" }),
11564
11564
  " ",
11565
11565
  stepData.matchedWords.join(", ")
11566
- ] }) })
11566
+ ] }) : /* @__PURE__ */ jsx("span", { className: "text-purple-400 text-xs italic", children: "Matched words will appear here..." }) })
11567
11567
  ] });
11568
11568
  const modeToggle = /* @__PURE__ */ jsxs("div", { className: "flex gap-1 bg-gray-200 rounded-lg p-0.5", children: [
11569
11569
  /* @__PURE__ */ jsx(
@@ -18025,7 +18025,7 @@ const BloomFilterVisualizerComponent = ({
18025
18025
  "]"
18026
18026
  ] }, idx)) })
18027
18027
  ] }),
18028
- stepData.element && /* @__PURE__ */ jsx("div", { className: "mb-4 p-3 bg-gray-50 rounded-lg border border-gray-200", children: /* @__PURE__ */ jsxs("div", { className: "text-sm", children: [
18028
+ /* @__PURE__ */ jsx("div", { className: "mb-4 p-3 bg-gray-50 rounded-lg border border-gray-200 min-h-[44px]", children: stepData.element ? /* @__PURE__ */ jsxs("div", { className: "text-sm", children: [
18029
18029
  /* @__PURE__ */ jsx("span", { className: "text-gray-500", children: "Element: " }),
18030
18030
  /* @__PURE__ */ jsxs("span", { className: "font-mono font-bold text-purple-600", children: [
18031
18031
  '"',
@@ -18040,8 +18040,8 @@ const BloomFilterVisualizerComponent = ({
18040
18040
  ] }),
18041
18041
  /* @__PURE__ */ jsx("span", { className: "font-mono font-bold text-pink-600", children: stepData.hashIndex })
18042
18042
  ] })
18043
- ] }) }),
18044
- stepData.operation === "init" && /* @__PURE__ */ jsxs("div", { className: "mb-4 p-3 bg-indigo-50 rounded-lg border border-indigo-200", children: [
18043
+ ] }) : /* @__PURE__ */ jsx("div", { className: "text-sm text-gray-400 italic", children: "Current operation will appear here..." }) }),
18044
+ /* @__PURE__ */ jsxs("div", { className: "mb-4 p-3 bg-indigo-50 rounded-lg border border-indigo-200 min-h-[76px]", children: [
18045
18045
  /* @__PURE__ */ jsxs("div", { className: "text-xs font-medium text-indigo-800 mb-2", children: [
18046
18046
  "Hash Functions (k=",
18047
18047
  NUM_HASH_FUNCTIONS,
@@ -21450,7 +21450,7 @@ function generateGCSteps() {
21450
21450
  variables: { edenUsed: eden.length },
21451
21451
  activeSurvivor
21452
21452
  });
21453
- for (let gc = 0; gc < 2; gc++) {
21453
+ for (let gc = 0; gc < 4; gc++) {
21454
21454
  steps.push({
21455
21455
  operation: "minor_gc",
21456
21456
  objects: objects.map((o) => ({ ...o })),
@@ -21515,12 +21515,27 @@ function generateGCSteps() {
21515
21515
  activeSurvivor: activeSurvivor === 0 ? 1 : 0
21516
21516
  });
21517
21517
  activeSurvivor = activeSurvivor === 0 ? 1 : 0;
21518
- if (gc < 1) {
21518
+ if (gc < 3) {
21519
+ const newObjs = [];
21519
21520
  for (let i = 0; i < 3; i++) {
21520
- const obj = createObject(true);
21521
+ const obj = createObject(gc < 2 ? true : i === 0);
21521
21522
  objects.push(obj);
21522
21523
  eden.push(obj.id);
21524
+ newObjs.push(obj);
21523
21525
  }
21526
+ steps.push({
21527
+ operation: "allocate",
21528
+ objects: objects.map((o) => ({ ...o })),
21529
+ eden: [...eden],
21530
+ survivor0: [...survivor0],
21531
+ survivor1: [...survivor1],
21532
+ old: [...old],
21533
+ description: `Allocated ${newObjs.length} new objects in Eden.`,
21534
+ codeLine: 3,
21535
+ variables: { edenUsed: eden.length },
21536
+ highlightObjects: newObjs.map((o) => o.id),
21537
+ activeSurvivor
21538
+ });
21524
21539
  }
21525
21540
  }
21526
21541
  const oldObjs = objects.filter((o) => old.includes(o.id));