@sanity/vision 6.20.0 → 6.21.0-next.103

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,7 +1,6 @@
1
1
  import { useEffect, useRef } from "react";
2
2
  import { c } from "react/compiler-runtime";
3
3
  import { useTheme_v2 } from "@sanity/ui";
4
- import { assignInlineVars } from "@vanilla-extract/dynamic";
5
4
  import { jsx } from "react/jsx-runtime";
6
5
  import { FileDiff } from "@pierre/diffs";
7
6
  /**
@@ -9,7 +8,7 @@ import { FileDiff } from "@pierre/diffs";
9
8
  * Only loaded through `lazy()` once a history entry's changes are expanded.
10
9
  */
11
10
  function CodeDiff(t0) {
12
- let $ = c(19), { previous, next, lang } = t0, { color, font } = useTheme_v2(), codeSize = font.code.sizes[1], wrapperRef = useRef(null), t1 = `diff.${lang}`, t2;
11
+ let $ = c(17), { previous, next, lang } = t0, { color, font } = useTheme_v2(), codeSize = font.code.sizes[1], wrapperRef = useRef(null), t1 = `diff.${lang}`, t2;
13
12
  $[0] !== lang || $[1] !== previous || $[2] !== t1 ? (t2 = {
14
13
  name: t1,
15
14
  contents: previous,
@@ -44,17 +43,19 @@ function CodeDiff(t0) {
44
43
  themeType
45
44
  ], $[8] = newFile, $[9] = oldFile, $[10] = themeType, $[11] = t5, $[12] = t6) : (t5 = $[11], t6 = $[12]), useEffect(t5, t6);
46
45
  let t7 = `${codeSize.fontSize}px`, t8 = `${codeSize.lineHeight}px`, t9;
47
- $[13] !== font.code.family || $[14] !== t7 || $[15] !== t8 ? (t9 = assignInlineVars({
48
- "--diffs-font-family": font.code.family,
49
- "--diffs-font-size": t7,
50
- "--diffs-line-height": t8
51
- }), $[13] = font.code.family, $[14] = t7, $[15] = t8, $[16] = t9) : t9 = $[16];
52
- let t10;
53
- return $[17] === t9 ? t10 = $[18] : (t10 = /* @__PURE__ */ jsx("div", {
54
- ref: wrapperRef,
55
- style: t9
56
- }), $[17] = t9, $[18] = t10), t10;
46
+ if ($[13] !== font.code.family || $[14] !== t7 || $[15] !== t8) {
47
+ let style = {
48
+ "--diffs-font-family": font.code.family,
49
+ "--diffs-font-size": t7,
50
+ "--diffs-line-height": t8
51
+ };
52
+ t9 = /* @__PURE__ */ jsx("div", {
53
+ ref: wrapperRef,
54
+ style
55
+ }), $[13] = font.code.family, $[14] = t7, $[15] = t8, $[16] = t9;
56
+ } else t9 = $[16];
57
+ return t9;
57
58
  }
58
59
  export { CodeDiff as default };
59
60
 
60
- //# sourceMappingURL=CodeDiff-Bj_o50Qy.js.map
61
+ //# sourceMappingURL=CodeDiff-MkS3Q87A.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CodeDiff-MkS3Q87A.js","names":["{previous, next, lang}: CodeDiffProps","{name: `diff.${lang}`, contents: previous, lang}","`diff.${lang}`","useMemo<FileContents>(\n () => ({name: `diff.${lang}`, contents: previous, lang}),\n [lang, previous],\n )","{name: `diff.${lang}`, contents: next, lang}","useMemo<FileContents>(\n () => ({name: `diff.${lang}`, contents: next, lang}),\n [lang, next],\n )","() => {\n const wrapper = wrapperRef.current\n if (!wrapper) return undefined\n const diff = new FileDiff({\n diffStyle: 'unified',\n // Thrown from `render` in this effect, a failure reaches the History panel's error\n // boundary and its Retry, rather than being drawn as a stack trace inside the diff\n disableErrorHandling: true,\n disableFileHeader: true,\n lineDiffType: 'word',\n overflow: 'wrap',\n themeType,\n })\n diff.render({containerWrapper: wrapper, newFile, oldFile})\n return () => diff.cleanUp()\n }","[newFile, oldFile, themeType]","<div ref={wrapperRef} style={style} />","family","`${codeSize.fontSize}px`","`${codeSize.lineHeight}px`","_c","useThemeV2"],"sources":["../src/vista/components/response/CodeDiff.tsx"],"sourcesContent":["import {type FileContents, FileDiff} from '@pierre/diffs'\nimport {useTheme_v2 as useThemeV2} from '@sanity/ui'\nimport {type CSSProperties, useEffect, useMemo, useRef} from 'react'\n\n/** The custom properties `@pierre/diffs` styles its markup with */\ninterface DiffsStyle extends CSSProperties {\n '--diffs-font-family': string\n '--diffs-font-size': string\n '--diffs-line-height': string\n}\n\nexport interface CodeDiffProps {\n previous: string\n next: string\n lang: 'json' | 'text'\n}\n\n/**\n * Line diff of two texts, rendered by `@pierre/diffs` (Shiki highlighting in a shadow root).\n * Only loaded through `lazy()` once a history entry's changes are expanded.\n */\nexport default function CodeDiff({previous, next, lang}: CodeDiffProps) {\n const {color, font} = useThemeV2()\n const codeSize = font.code.sizes[1]\n const wrapperRef = useRef<HTMLDivElement>(null)\n const oldFile = useMemo<FileContents>(\n () => ({name: `diff.${lang}`, contents: previous, lang}),\n [lang, previous],\n )\n const newFile = useMemo<FileContents>(\n () => ({name: `diff.${lang}`, contents: next, lang}),\n [lang, next],\n )\n const themeType = color._dark ? 'dark' : 'light'\n\n // The library's React components keep their container and hydrate whatever markup a previous\n // instance left in it, so after StrictMode detaches and re-attaches their ref they render\n // nothing. An instance per effect run with a container of its own (removed on clean up) has no\n // such markup to find\n useEffect(() => {\n const wrapper = wrapperRef.current\n if (!wrapper) return undefined\n const diff = new FileDiff({\n diffStyle: 'unified',\n // Thrown from `render` in this effect, a failure reaches the History panel's error\n // boundary and its Retry, rather than being drawn as a stack trace inside the diff\n disableErrorHandling: true,\n disableFileHeader: true,\n lineDiffType: 'word',\n overflow: 'wrap',\n themeType,\n })\n diff.render({containerWrapper: wrapper, newFile, oldFile})\n return () => diff.cleanUp()\n }, [newFile, oldFile, themeType])\n\n const style: DiffsStyle = {\n '--diffs-font-family': font.code.family,\n '--diffs-font-size': `${codeSize.fontSize}px`,\n '--diffs-line-height': `${codeSize.lineHeight}px`,\n }\n\n return <div ref={wrapperRef} style={style} />\n}\n"],"mappings":";;;;;;;;;AAqBA,SAAwB,SAAA,IAAgD;C,eAAvC,EAAC,UAAU,MAAM,SAAjBA,IACzB,EAAC,OAAO,SAAQa,YAAW,GAC3B,WAAW,KAAK,KAAK,MAAM,IAC3B,aAAa,OAAuB,IAAI,GAE9B,KAAA,QAAQ,QAAfZ;CAA2C,AAAA,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