@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 {
|
|
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
|
|
7289
|
-
|
|
7290
|
-
|
|
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(
|
|
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
package/dist/workbench.d.ts
CHANGED
|
@@ -252,9 +252,18 @@ interface DiffViewProps {
|
|
|
252
252
|
className?: string;
|
|
253
253
|
}
|
|
254
254
|
/**
|
|
255
|
-
* Word-level unified diff via `@pierre/diffs`' `
|
|
256
|
-
* with jsdiff's `createTwoFilesPatch` (baseline → current); the
|
|
257
|
-
* hunking, intra-line word diffing, gutters, and
|
|
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
package/package.json
CHANGED