@tangle-network/sandbox-ui 0.113.0 → 0.113.1

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.
@@ -7242,7 +7242,7 @@ function CodeView({
7242
7242
 
7243
7243
  // src/workbench/diff-view.tsx
7244
7244
  import * as React7 from "react";
7245
- import { PatchDiff } from "@pierre/diffs/react";
7245
+ import { FileDiff, getSingularPatch } from "@pierre/diffs";
7246
7246
 
7247
7247
  // src/workbench/diff-utils.ts
7248
7248
  import { createTwoFilesPatch, diffLines } from "diff";
@@ -7280,19 +7280,40 @@ var DIFF_OPTIONS = {
7280
7280
  themeType: "dark",
7281
7281
  stickyHeader: true
7282
7282
  };
7283
+ var DIFF_CONTAINER_TAG = "diffs-container";
7283
7284
  function DiffView({ filename, baseline, current, showFileHeader = true, className }) {
7284
7285
  const patch = React7.useMemo(
7285
7286
  () => buildUnifiedPatch(filename, baseline, current),
7286
7287
  [filename, baseline, current]
7287
7288
  );
7288
- const options = React7.useMemo(
7289
- () => showFileHeader ? DIFF_OPTIONS : { ...DIFF_OPTIONS, disableFileHeader: true },
7290
- [showFileHeader]
7291
- );
7289
+ const hostRef = React7.useRef(null);
7290
+ React7.useLayoutEffect(() => {
7291
+ const host = hostRef.current;
7292
+ if (host == null || !patch) return;
7293
+ const container = document.createElement(DIFF_CONTAINER_TAG);
7294
+ host.appendChild(container);
7295
+ const instance = new FileDiff(
7296
+ showFileHeader ? DIFF_OPTIONS : { ...DIFF_OPTIONS, disableFileHeader: true },
7297
+ void 0,
7298
+ false
7299
+ );
7300
+ instance.hydrate({ fileDiff: getSingularPatch(patch), fileContainer: container });
7301
+ return () => {
7302
+ instance.cleanUp();
7303
+ container.remove();
7304
+ };
7305
+ }, [patch, showFileHeader]);
7292
7306
  if (!patch) {
7293
7307
  return /* @__PURE__ */ jsx7("div", { className: cn("flex h-full items-center justify-center bg-surface-container", className), children: /* @__PURE__ */ jsx7("p", { className: "text-sm text-muted-foreground", children: "No changes \u2014 baseline and working copy are identical." }) });
7294
7308
  }
7295
- return /* @__PURE__ */ jsx7("div", { className: cn("h-full min-h-0 overflow-auto bg-surface-container text-[13px]", className), children: /* @__PURE__ */ jsx7(PatchDiff, { patch, options }) });
7309
+ return /* @__PURE__ */ jsx7(
7310
+ "div",
7311
+ {
7312
+ ref: hostRef,
7313
+ "data-testid": "diff-view",
7314
+ className: cn("h-full min-h-0 overflow-auto bg-surface-container text-[13px]", className)
7315
+ }
7316
+ );
7296
7317
  }
7297
7318
 
7298
7319
  // src/workbench/preview-view.tsx
package/dist/index.js CHANGED
@@ -150,7 +150,7 @@ import {
150
150
  buildUnifiedPatch,
151
151
  computeDiffStats,
152
152
  resolveLanguage
153
- } from "./chunk-ISTJTUHJ.js";
153
+ } from "./chunk-VEK3EZIW.js";
154
154
  import {
155
155
  FileArtifactPane,
156
156
  FilePreview,
@@ -252,9 +252,18 @@ interface DiffViewProps {
252
252
  className?: string;
253
253
  }
254
254
  /**
255
- * Word-level unified diff via `@pierre/diffs`' `PatchDiff`. The patch is built
256
- * with jsdiff's `createTwoFilesPatch` (baseline → current); the renderer owns
257
- * hunking, intra-line word diffing, gutters, and syntax highlighting.
255
+ * Word-level unified diff via `@pierre/diffs`' core `FileDiff` renderer. The
256
+ * patch is built with jsdiff's `createTwoFilesPatch` (baseline → current); the
257
+ * renderer owns hunking, intra-line word diffing, gutters, and highlighting.
258
+ *
259
+ * The renderer is driven from an effect on a host element this component
260
+ * creates for every mount, not through the library's React wrapper. The
261
+ * wrapper hydrates the element React hands it and treats an existing shadow
262
+ * `<pre>` as prerendered content; React StrictMode attaches, detaches, and
263
+ * re-attaches that element on mount, so the second hydrate finds the first
264
+ * mount's `<pre>` and renders nothing. A fresh element per effect run has no
265
+ * such history, and the cleanup removes it (the instance is not
266
+ * container-managed).
258
267
  */
259
268
  declare function DiffView({ filename, baseline, current, showFileHeader, className }: DiffViewProps): React.JSX.Element;
260
269
 
package/dist/workbench.js CHANGED
@@ -14,7 +14,7 @@ import {
14
14
  buildUnifiedPatch,
15
15
  computeDiffStats,
16
16
  resolveLanguage
17
- } from "./chunk-ISTJTUHJ.js";
17
+ } from "./chunk-VEK3EZIW.js";
18
18
  import "./chunk-PZVUIUUW.js";
19
19
  import "./chunk-K4Q4E7D7.js";
20
20
  import "./chunk-OMUIPJQZ.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/sandbox-ui",
3
- "version": "0.113.0",
3
+ "version": "0.113.1",
4
4
  "description": "Unified UI component library for Tangle Sandbox — primitives, chat, dashboard, terminal, editor, and workspace components",
5
5
  "repository": {
6
6
  "type": "git",