sanity-plugin-graph-view 3.2.5 → 4.0.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sanity-plugin-graph-view",
3
- "version": "3.2.5",
3
+ "version": "4.0.0",
4
4
  "description": "",
5
5
  "homepage": "https://github.com/sanity-io/plugins/tree/main/plugins/sanity-plugin-graph-view#readme",
6
6
  "bugs": {
@@ -15,11 +15,7 @@
15
15
  "author": "Sanity.io <hello@sanity.io>",
16
16
  "type": "module",
17
17
  "exports": {
18
- ".": {
19
- "import": "./dist/index.js",
20
- "require": "./dist/index.cjs",
21
- "default": "./dist/index.js"
22
- },
18
+ ".": "./dist/index.js",
23
19
  "./package.json": "./package.json"
24
20
  },
25
21
  "types": "./dist/index.d.ts",
@@ -37,18 +33,18 @@
37
33
  "uuid": "^13.0.0"
38
34
  },
39
35
  "devDependencies": {
40
- "@sanity/pkg-utils": "^10.1.2",
36
+ "@sanity/pkg-utils": "^10.1.3",
41
37
  "@types/deep-equal": "^1.0.4",
42
38
  "@types/react": "^19.2.7",
43
- "@typescript/native-preview": "7.0.0-dev.20251207.1",
39
+ "@typescript/native-preview": "7.0.0-dev.20251209.1",
44
40
  "babel-plugin-react-compiler": "^1.0.0",
45
41
  "babel-plugin-styled-components": "^2.1.4",
46
42
  "eslint": "^9.39.1",
47
- "react": "^19.2.1",
48
- "sanity": "^4.21.0",
43
+ "react": "^19.2.3",
44
+ "sanity": "^4.21.1",
49
45
  "styled-components": "^6.1.19",
50
46
  "typescript": "5.9.3",
51
- "@repo/eslint-config": "0.0.5",
47
+ "@repo/eslint-config": "0.0.6",
52
48
  "@repo/tsconfig": "1.0.0",
53
49
  "@repo/package.config": "0.0.0"
54
50
  },
@@ -1,294 +0,0 @@
1
- "use strict";
2
- var jsxRuntime = require("react/jsx-runtime"), color = require("@sanity/color"), ui = require("@sanity/ui"), BezierEasing = require("bezier-easing"), deepEqual = require("deep-equal"), polished = require("polished"), react = require("react"), reactForceGraph = require("react-force-graph"), sanity = require("sanity"), router = require("sanity/router"), uuid = require("uuid"), styledComponents = require("styled-components");
3
- function _interopDefaultCompat(e) {
4
- return e && typeof e == "object" && "default" in e ? e : { default: e };
5
- }
6
- var BezierEasing__default = /* @__PURE__ */ _interopDefaultCompat(BezierEasing), deepEqual__default = /* @__PURE__ */ _interopDefaultCompat(deepEqual);
7
- const GraphRoot = styledComponents.styled.div.withConfig({
8
- displayName: "GraphRoot",
9
- componentId: "sc-vxc9wk-0"
10
- })`font-family:${({
11
- theme
12
- }) => theme.fonts.text.family};position:absolute;top:0;left:0;width:100%;height:100%;background:${color.black.hex};`, GraphWrapper = styledComponents.styled.div.withConfig({
13
- displayName: "GraphWrapper",
14
- componentId: "sc-vxc9wk-1"
15
- })`position:relative;width:100%;height:100%;`, HoverNode = styledComponents.styled.div.withConfig({
16
- displayName: "HoverNode",
17
- componentId: "sc-vxc9wk-2"
18
- })`font-family:${({
19
- theme
20
- }) => theme.fonts.text.family};display:none;position:absolute;bottom:${({
21
- theme
22
- }) => theme.space[0]}px;left:50%;transform:translate3d(-50%,0,0);background:var(--component-bg);border-radius:${({
23
- theme
24
- }) => theme.radius[2]}px;padding:${({
25
- theme
26
- }) => theme.space[2]}px;z-index:1000;&:empty{display:none;}`, Legend = styledComponents.styled.div.withConfig({
27
- displayName: "Legend",
28
- componentId: "sc-vxc9wk-3"
29
- })`color:#ccc;position:absolute;top:${({
30
- theme
31
- }) => theme.space[4]}px;left:${({
32
- theme
33
- }) => theme.space[4]}px;& > div{margin:5px 0;}`, LegendRow = styledComponents.styled.div.withConfig({
34
- displayName: "LegendRow",
35
- componentId: "sc-vxc9wk-4"
36
- })`display:flex;`, LegendBadge = styledComponents.styled.div.withConfig({
37
- displayName: "LegendBadge",
38
- componentId: "sc-vxc9wk-5"
39
- })`width:1.25em;height:1.25em;background:currentColor;border-radius:50%;margin-right:${({
40
- theme
41
- }) => theme.space[2]}px;`;
42
- function sizeOf(value) {
43
- return value === null ? 0 : typeof value == "object" ? Object.entries(value).reduce((total, [k, v]) => total + sizeOf(k) + sizeOf(v), 0) : Array.isArray(value) ? Object.entries(value).reduce((total, v) => total + sizeOf(v), 0) : typeof value == "string" ? value.length : 1;
44
- }
45
- function loadImage(url, w, h) {
46
- return new Promise((resolve) => {
47
- const img = new Image(w, h);
48
- img.onload = () => {
49
- resolve(img);
50
- }, img.onerror = (event) => {
51
- console.error("Image error", event), resolve(null);
52
- }, img.src = url;
53
- });
54
- }
55
- function sortBy(array, f) {
56
- return array.sort((a, b) => {
57
- const va = f(a), vb = f(b);
58
- return va < vb ? -1 : va > vb ? 1 : 0;
59
- });
60
- }
61
- function truncate(s, limit) {
62
- return s.length > limit ? `${s.substring(0, limit)}\u2026` : s;
63
- }
64
- const DEFAULT_QUERY = `
65
- *[
66
- !(_id in path("_.*")) &&
67
- !(_type match "system.*") &&
68
- !(_type match "sanity.*")
69
- ]
70
- `, fadeEasing = BezierEasing__default.default(0, 0.9, 1, 1), softEasing = BezierEasing__default.default(0.25, 0.1, 0, 1), idleTimeout = 1e4, imageSize = 40;
71
- function getTopDocTypes(counts) {
72
- return sortBy(Object.keys(counts), (docType) => counts[docType] || 0).reverse().slice(0, 10);
73
- }
74
- function formatDocType(docType) {
75
- return (docType.substring(0, 1).toUpperCase() + docType.substring(1)).replace(/\./g, " ").replace(/[A-Z]/g, " $&").trim();
76
- }
77
- function getDocTypeCounts(docs) {
78
- const types = {};
79
- for (const doc of docs)
80
- types[doc._type] = (types[doc._type] || 0) + 1;
81
- return types;
82
- }
83
- function labelFor(doc) {
84
- return `${doc.title || doc.name || doc._id}`.trim();
85
- }
86
- function valueFor(doc, maxSize) {
87
- return 5 + 100 * (sizeOf(doc) / maxSize);
88
- }
89
- function findRefs(obj, dest = []) {
90
- if (obj !== null) {
91
- if (typeof obj == "object")
92
- for (const [k, v] of Object.entries(obj))
93
- k === "_ref" && typeof v == "string" && v.length > 0 && dest.push(stripDraftId(v)), findRefs(v, dest);
94
- else if (Array.isArray(obj))
95
- for (const v of obj)
96
- findRefs(v, dest);
97
- }
98
- return dest;
99
- }
100
- function stripDraftId(id) {
101
- return id.replace(/^drafts\./, "");
102
- }
103
- function deduplicateDrafts(docs) {
104
- const deduped = {};
105
- for (const doc of docs)
106
- doc._id.startsWith("drafts.") || (deduped[doc._id] = doc);
107
- for (const doc of docs)
108
- if (doc._id.startsWith("drafts.")) {
109
- const id = stripDraftId(doc._id);
110
- deduped[id] = Object.assign(doc, {
111
- _id: id
112
- });
113
- }
114
- return Object.values(deduped);
115
- }
116
- class Users {
117
- _users = [];
118
- async getById(id, client) {
119
- let user = this._users.find((u) => u._id === id);
120
- return user || (user = await client.users.getById(id), this._users.push(user), user.image = await loadImage(user.imageUrl || "https://raw.githubusercontent.com/sanity-io/sanity-plugin-graph-view/main/assets/head-silhouette.jpg", imageSize, imageSize)), user;
121
- }
122
- }
123
- class Session {
124
- id = null;
125
- user = null;
126
- doc = null;
127
- lastActive = 0;
128
- startTime = 0;
129
- angle = 0;
130
- }
131
- class GraphData {
132
- sessions = [];
133
- constructor(docs = []) {
134
- const docsById = {};
135
- for (const doc of docs)
136
- docsById[doc._id] = doc;
137
- this.data = {
138
- nodes: docs.map((d) => Object.assign({
139
- id: d._id,
140
- type: "document",
141
- doc: d
142
- })),
143
- links: docs.flatMap((doc) => findRefs(doc).map((ref) => ({
144
- source: doc._id,
145
- target: ref
146
- }))).filter((link) => docsById[link.source] && docsById[link.target])
147
- };
148
- }
149
- setSession(user, docNode) {
150
- let session = this.sessions.find((s) => s.user.id === user.id && s.doc?._id === docNode.doc._id);
151
- session || (session = new Session(), session.id = uuid.v4(), session.user = user, session.startTime = Date.now(), session.doc = docNode.doc, session.angle = Math.random() * 2 * Math.PI, this.sessions.push(session)), session.lastActive = Date.now();
152
- }
153
- reapSessions() {
154
- for (let i = 0; i < this.sessions.length; i++) {
155
- const session = this.sessions[i];
156
- Date.now() - session.lastActive > idleTimeout && (this.sessions = [...this.sessions.slice(0, i), ...this.sessions.slice(i + 1)], i--);
157
- }
158
- }
159
- clone() {
160
- const copy = new GraphData();
161
- return Object.assign(copy, this), copy.data = {
162
- nodes: [...this.data.nodes],
163
- links: [...this.data.links]
164
- }, copy;
165
- }
166
- }
167
- const users = new Users();
168
- function GraphView({
169
- tool: {
170
- options: props
171
- }
172
- }) {
173
- const query = props.query || DEFAULT_QUERY, apiVersion = props.apiVersion ?? "2022-09-01", userColorManager = sanity.useUserColorManager(), [maxSize, setMaxSize] = react.useState(0), [hoverNode, setHoverNode] = react.useState(null), [documents, setDocuments] = react.useState([]), [docTypes, setDocTypes] = react.useState({}), [graph, setGraph] = react.useState(() => new GraphData()), router$1 = router.useRouter(), client = sanity.useClient({
174
- apiVersion
175
- });
176
- react.useEffect(() => {
177
- client.fetch(query).then((_docs) => {
178
- const docs = deduplicateDrafts(_docs);
179
- setMaxSize(Math.max(...docs.map(sizeOf))), setDocuments(docs), setDocTypes(getDocTypeCounts(docs)), setGraph(new GraphData(docs));
180
- });
181
- }, [client, query]), react.useEffect(() => {
182
- const subscription = client.listen(query, {}, {}).subscribe(async (update) => {
183
- if (update.type !== "mutation") return;
184
- const doc = update.result;
185
- if (doc) {
186
- doc._id = stripDraftId(doc._id);
187
- const docsById = {};
188
- for (const d of documents)
189
- docsById[d._id] = d;
190
- let oldDoc;
191
- const docs_0 = [...documents], idx = documents.findIndex((d_0) => d_0._id === doc._id);
192
- idx >= 0 ? (oldDoc = docs_0[idx], docs_0[idx] = doc) : docs_0.push(doc), setDocuments(docs_0), setDocTypes(getDocTypeCounts(docs_0)), setMaxSize(Math.max(...docs_0.map(sizeOf)));
193
- const newGraph = graph.clone(), oldRefs = findRefs(oldDoc || {}).filter((id) => id === doc._id || docsById[id] !== null), newRefs = findRefs(doc).filter((id_0) => id_0 === doc._id || docsById[id_0] !== null);
194
- let graphChanged = !deepEqual__default.default(oldRefs, newRefs);
195
- graphChanged && (newGraph.data.links = newGraph.data.links.filter((l) => l.source.id !== doc._id).concat(newRefs.map((ref) => ({
196
- source: doc._id,
197
- target: ref
198
- }))));
199
- let docNode;
200
- const nodeIdx = graph.data.nodes.findIndex((n) => n.doc && n.doc._id === doc._id);
201
- nodeIdx >= 0 ? (docNode = graph.data.nodes[nodeIdx], docNode.doc = doc) : (docNode = {
202
- id: doc._id,
203
- type: "document",
204
- doc
205
- }, newGraph.data.nodes.push(docNode), graphChanged = !0), graphChanged && setGraph(newGraph);
206
- const user = await users.getById(update.identity, client);
207
- graph.setSession(user, docNode);
208
- } else if (update.transition === "disappear") {
209
- const docId = stripDraftId(update.documentId), docs_1 = documents.filter((d_1) => d_1._id !== docId);
210
- setDocuments(docs_1), setDocTypes(getDocTypeCounts(docs_1)), setMaxSize(Math.max(...docs_1.map(sizeOf)));
211
- const newGraph_0 = graph.clone();
212
- newGraph_0.data.links = newGraph_0.data.links.filter((l_0) => l_0.source.id !== docId && l_0.target.id !== docId), newGraph_0.data.nodes = newGraph_0.data.nodes.filter((n_0) => n_0.id !== docId), setGraph(newGraph_0);
213
- }
214
- });
215
- return () => {
216
- subscription.unsubscribe();
217
- };
218
- }, [client, query, documents, graph]), react.useEffect(() => {
219
- const interval = setInterval(() => graph.reapSessions(), 1e3);
220
- return () => clearInterval(interval);
221
- }, [graph]);
222
- const theme = ui.useTheme().sanity;
223
- return /* @__PURE__ */ jsxRuntime.jsx(GraphWrapper, { theme, children: /* @__PURE__ */ jsxRuntime.jsxs(GraphRoot, { theme, children: [
224
- /* @__PURE__ */ jsxRuntime.jsx(Legend, { theme, children: getTopDocTypes(docTypes).map((docType) => /* @__PURE__ */ jsxRuntime.jsxs(LegendRow, { className: "legend__row", style: {
225
- color: getDocTypeColor(docType).fill
226
- }, children: [
227
- /* @__PURE__ */ jsxRuntime.jsx(LegendBadge, { theme }),
228
- /* @__PURE__ */ jsxRuntime.jsx("div", { children: formatDocType(docType) })
229
- ] }, docType)) }),
230
- hoverNode && /* @__PURE__ */ jsxRuntime.jsx(HoverNode, { theme, children: labelFor(hoverNode.doc) }),
231
- /* @__PURE__ */ jsxRuntime.jsx(reactForceGraph.ForceGraph2D, { graphData: graph.data, nodeAutoColorBy: "group", enableNodeDrag: !1, onNodeHover: (node) => setHoverNode(node), onNodeClick: (node_0) => {
232
- router$1.navigateIntent("edit", {
233
- id: node_0.doc._id,
234
- documentType: node_0.doc._type
235
- });
236
- }, linkColor: () => polished.rgba(color.gray[500].hex, 0.25), nodeLabel: () => "", nodeRelSize: 1, nodeVal: (node_1) => valueFor(node_1.doc, maxSize), onRenderFramePost: (ctx, globalScale) => {
237
- for (const session of graph.sessions) {
238
- const node_2 = graph.data.nodes.find((n_1) => n_1.doc && n_1.doc._id === session?.doc?._id);
239
- if (node_2) {
240
- const idleFactorRange = idleTimeout, angle = session.angle, radius = Math.sqrt(valueFor(node_2.doc, maxSize)), image = session.user.image, userColor = userColorManager.get(session.user.displayName).tints[400].hex, distance = radius * globalScale + 40, imgW = image ? image.width : 0, imgH = image ? image.height : 0, x = node_2.x + Math.sin(angle) * distance / globalScale, y = node_2.y + Math.cos(angle) * distance / globalScale;
241
- ctx.save();
242
- try {
243
- if (ctx.globalAlpha = fadeEasing(1 - Math.min(idleFactorRange, Date.now() - session.lastActive) / idleFactorRange), ctx.font = `bold ${Math.round(12 / globalScale)}px sans-serif`, ctx.beginPath(), ctx.strokeStyle = polished.rgba(color.white.hex, 1), ctx.lineWidth = 2 / globalScale, ctx.moveTo(node_2.x + Math.sin(angle) * (distance - imgW / 2) / globalScale, node_2.y + Math.cos(angle) * (distance - imgH / 2) / globalScale), ctx.lineTo(node_2.x + Math.sin(angle) * radius, node_2.y + Math.cos(angle) * radius), ctx.stroke(), ctx.beginPath(), ctx.strokeStyle = polished.rgba(color.white.hex, 1), ctx.lineWidth = 2 / globalScale, ctx.arc(node_2.x, node_2.y, radius, 0, 2 * Math.PI, !1), ctx.stroke(), image) {
244
- ctx.save();
245
- try {
246
- const f = softEasing(Math.max(0, (700 - (Date.now() - session.startTime)) / 700));
247
- f > 0 && (ctx.beginPath(), ctx.fillStyle = polished.rgba(userColor, f), ctx.arc(x, y, (imgW / 2 + 10) / globalScale, 0, 2 * Math.PI, !1), ctx.fill()), ctx.beginPath(), ctx.fillStyle = polished.rgba(color.white.hex, 1), ctx.arc(x, y, imgW / globalScale / 2, 0, 2 * Math.PI, !1), ctx.clip(), ctx.drawImage(image, x - imgW / globalScale / 2, y - imgH / globalScale / 2, imgW / globalScale, imgH / globalScale), ctx.strokeStyle = color.black.hex, ctx.lineWidth = 6 / globalScale, ctx.stroke(), ctx.strokeStyle = userColor, ctx.lineWidth = 4 / globalScale, ctx.stroke();
248
- } finally {
249
- ctx.restore();
250
- }
251
- }
252
- ctx.beginPath(), ctx.strokeStyle = polished.rgba(color.black.hex, 1), ctx.lineWidth = 0.5 / globalScale, ctx.arc(x, y, imgW / globalScale / 2, 0, 2 * Math.PI, !1), ctx.stroke();
253
- const above = angle >= Math.PI / 2 && angle < Math.PI * 1.5, textY = above ? y - (imgH / 2 + 5) / globalScale : y + (imgH / 2 + 5) / globalScale;
254
- ctx.fillStyle = polished.rgba(color.white.hex, 1), ctx.textAlign = "center", ctx.textBaseline = above ? "bottom" : "top", ctx.fillText(session.user.displayName, x, textY);
255
- } finally {
256
- ctx.restore();
257
- }
258
- }
259
- }
260
- }, nodeCanvasObject: (node_3, ctx_0, globalScale_0) => {
261
- switch (node_3.type) {
262
- case "document": {
263
- const nodeColor = getDocTypeColor(node_3.doc._type), radius_0 = Math.sqrt(valueFor(node_3.doc, maxSize)), fontSize = Math.min(100, 10 / globalScale_0);
264
- if (ctx_0.beginPath(), ctx_0.fillStyle = hoverNode !== null && node_3.doc._id === hoverNode.doc._id ? polished.rgba(color.gray[500].hex, 0.8) : nodeColor.fill, ctx_0.strokeStyle = nodeColor.border, ctx_0.lineWidth = 0.5, ctx_0.arc(node_3.x, node_3.y, radius_0, 0, 2 * Math.PI, !1), ctx_0.stroke(), ctx_0.fill(), radius_0 * globalScale_0 > 10) {
265
- ctx_0.font = `${fontSize}px sans-serif`;
266
- const w = radius_0 * 2 + 30 / globalScale_0;
267
- for (let len = 50; len >= 5; len /= 1.2) {
268
- const label = truncate(labelFor(node_3.doc), Math.round(len));
269
- if (ctx_0.measureText(label).width < w) {
270
- ctx_0.textAlign = "center", ctx_0.textBaseline = "top", ctx_0.strokeStyle = polished.rgba(color.black.hex, 0.5), ctx_0.lineWidth = 2 / globalScale_0, ctx_0.strokeText(label, node_3.x, node_3.y + radius_0 + 5 / globalScale_0), ctx_0.fillText(label, node_3.x, node_3.y + radius_0 + 5 / globalScale_0);
271
- break;
272
- }
273
- }
274
- }
275
- }
276
- }
277
- }, linkCanvasObject: (link, ctx_1, globalScale_1) => {
278
- ctx_1.beginPath(), ctx_1.strokeStyle = polished.rgba(color.gray[500].hex, 0.125), ctx_1.lineWidth = 2 / globalScale_1, ctx_1.moveTo(link.source.x, link.source.y), ctx_1.lineTo(link.target.x, link.target.y), ctx_1.stroke();
279
- } })
280
- ] }) });
281
- }
282
- const colorCache = {};
283
- let typeColorNum = 0;
284
- function getDocTypeColor(docType) {
285
- if (colorCache[docType])
286
- return colorCache[docType];
287
- const hue = color.COLOR_HUES[typeColorNum % color.COLOR_HUES.length];
288
- return typeColorNum += 1, colorCache[docType] = {
289
- fill: color.hues[hue][400].hex,
290
- border: polished.rgba(color.black.hex, 0.5)
291
- }, colorCache[docType];
292
- }
293
- exports.default = GraphView;
294
- //# sourceMappingURL=GraphView.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"GraphView.cjs","sources":["../../src/tool/GraphViewStyle.tsx","../../src/tool/utils.ts","../../src/tool/GraphView.tsx"],"sourcesContent":["import type {Theme} from '@sanity/ui'\n\nimport {black} from '@sanity/color'\nimport {type PropsWithChildren} from 'react'\nimport {styled} from 'styled-components'\n\ntype Style = PropsWithChildren<{theme: SanityTheme}>\ntype SanityTheme = Theme['sanity']\n\nexport const GraphRoot: React.FC<Style> = styled.div`\n font-family: ${({theme}: Style) => theme.fonts.text.family};\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: ${black.hex};\n`\n\nexport const GraphWrapper: React.FC<Style> = styled.div`\n position: relative;\n width: 100%;\n height: 100%;\n` as React.FC<Style>\n\nexport const HoverNode: React.FC<Style> = styled.div`\n font-family: ${({theme}: Style) => theme.fonts.text.family};\n display: none;\n position: absolute;\n bottom: ${({theme}: Style) => theme.space[0]}px;\n left: 50%;\n transform: translate3d(-50%, 0, 0);\n background: var(--component-bg);\n border-radius: ${({theme}: Style) => theme.radius[2]}px;\n padding: ${({theme}: Style) => theme.space[2]}px;\n z-index: 1000;\n\n &:empty {\n display: none;\n }\n`\n\nexport const Legend: React.FC<Style> = styled.div`\n color: #ccc;\n position: absolute;\n top: ${({theme}: Style) => theme.space[4]}px;\n left: ${({theme}: Style) => theme.space[4]}px;\n\n & > div {\n margin: 5px 0;\n }\n`\n\nexport const LegendRow: React.FC<\n PropsWithChildren<{className?: string; style?: React.CSSProperties}>\n> = styled.div`\n display: flex;\n`\n\nexport const LegendBadge: React.FC<Style> = styled.div`\n width: 1.25em;\n height: 1.25em;\n background: currentColor;\n border-radius: 50%;\n margin-right: ${({theme}: Style) => theme.space[2]}px;\n`\n","export function sizeOf(value: any): number {\n if (value === null) {\n return 0\n }\n\n if (typeof value === 'object') {\n return Object.entries(value).reduce((total, [k, v]) => total + sizeOf(k) + sizeOf(v), 0)\n }\n\n if (Array.isArray(value)) {\n return Object.entries(value).reduce((total, v) => total + sizeOf(v), 0)\n }\n\n if (typeof value === 'string') {\n return value.length\n }\n\n return 1\n}\n\nexport function loadImage(url: string, w: number, h: number): Promise<HTMLImageElement | null> {\n return new Promise((resolve) => {\n const img = new Image(w, h)\n // oxlint-disable-next-line prefer-add-event-listener\n img.onload = () => {\n resolve(img)\n }\n // oxlint-disable-next-line prefer-add-event-listener\n img.onerror = (event) => {\n console.error('Image error', event)\n resolve(null)\n }\n img.src = url\n })\n}\n\nexport function sortBy<T>(array: T[], f: (t: T) => number): T[] {\n return array.sort((a, b) => {\n const va = f(a)\n const vb = f(b)\n return va < vb ? -1 : va > vb ? 1 : 0\n })\n}\n\nexport function truncate(s: string, limit: number): string {\n if (s.length > limit) {\n return `${s.substring(0, limit)}…`\n }\n return s\n}\n","import {black, COLOR_HUES, gray, white, hues} from '@sanity/color'\nimport {useTheme} from '@sanity/ui'\nimport BezierEasing from 'bezier-easing'\nimport deepEqual from 'deep-equal'\nimport {rgba} from 'polished'\nimport {useEffect, useState} from 'react'\nimport {ForceGraph2D} from 'react-force-graph'\nimport {useClient, useUserColorManager, type SanityClient, type SanityDocument} from 'sanity'\nimport {useRouter} from 'sanity/router'\nimport {v4 as uuidv4} from 'uuid'\n\nimport {GraphRoot, GraphWrapper, HoverNode, Legend, LegendBadge, LegendRow} from './GraphViewStyle'\nimport {sortBy, loadImage, sizeOf, truncate} from './utils'\n\nconst DEFAULT_QUERY = `\n *[\n !(_id in path(\"_.*\")) &&\n !(_type match \"system.*\") &&\n !(_type match \"sanity.*\")\n ]\n`\n\nconst fadeEasing = BezierEasing(0, 0.9, 1, 1)\nconst softEasing = BezierEasing(0.25, 0.1, 0.0, 1.0)\nconst idleTimeout = 10000\nconst imageSize = 40\n\nfunction getTopDocTypes(counts: Record<string, number>) {\n return sortBy(Object.keys(counts), (docType) => counts[docType] || 0)\n .reverse()\n .slice(0, 10)\n}\n\nfunction formatDocType(docType: string) {\n return (docType.substring(0, 1).toUpperCase() + docType.substring(1))\n .replace(/\\./g, ' ')\n .replace(/[A-Z]/g, ' $&')\n .trim()\n}\n\nfunction getDocTypeCounts(docs: SanityDocument[]) {\n const types: Record<string, number> = {}\n for (const doc of docs) {\n types[doc._type] = (types[doc._type] || 0) + 1\n }\n return types\n}\n\nfunction labelFor(doc: SanityDocument) {\n // oxlint-disable-next-line restrict-template-expressions,no-base-to-string\n return `${doc.title || doc.name || doc._id}`.trim()\n}\n\nfunction valueFor(doc: any, maxSize: number) {\n return 5 + 100 * (sizeOf(doc) / maxSize)\n}\n\nfunction findRefs(obj: any, dest: any[] = []) {\n if (obj !== null) {\n if (typeof obj === 'object') {\n for (const [k, v] of Object.entries(obj)) {\n if (k === '_ref' && typeof v === 'string' && v.length > 0) {\n dest.push(stripDraftId(v))\n }\n findRefs(v, dest)\n }\n } else if (Array.isArray(obj)) {\n for (const v of obj) {\n findRefs(v, dest)\n }\n }\n }\n return dest\n}\n\nfunction stripDraftId(id: string) {\n return id.replace(/^drafts\\./, '')\n}\n\nfunction deduplicateDrafts(docs: SanityDocument[]) {\n const deduped: Record<string, SanityDocument> = {}\n for (const doc of docs) {\n if (!doc._id.startsWith('drafts.')) {\n deduped[doc._id] = doc\n }\n }\n for (const doc of docs) {\n if (doc._id.startsWith('drafts.')) {\n const id = stripDraftId(doc._id)\n deduped[id] = Object.assign(doc, {_id: id})\n }\n }\n return Object.values(deduped)\n}\n\nclass Users {\n _users: any[] = []\n\n async getById(id: string, client: SanityClient) {\n let user = this._users.find((u) => u._id === id)\n if (!user) {\n user = await client.users.getById(id)\n this._users.push(user)\n user.image = await loadImage(\n user.imageUrl ||\n 'https://raw.githubusercontent.com/sanity-io/sanity-plugin-graph-view/main/assets/head-silhouette.jpg',\n imageSize,\n imageSize,\n )\n }\n return user\n }\n}\n\nclass Session {\n id: string | null = null\n user: any = null\n doc: SanityDocument | null = null\n lastActive: number = 0\n startTime: number = 0\n angle: number = 0\n}\n\nclass GraphData {\n sessions: Session[] = []\n data: any\n\n constructor(docs: SanityDocument[] = []) {\n const docsById: Record<string, SanityDocument> = {}\n for (const doc of docs) {\n docsById[doc._id] = doc\n }\n\n this.data = {\n nodes: docs.map((d) => Object.assign({id: d._id, type: 'document', doc: d})),\n links: docs\n .flatMap((doc) => findRefs(doc).map((ref) => ({source: doc._id, target: ref})))\n .filter((link) => docsById[link.source] && docsById[link.target]),\n }\n }\n\n setSession(user: any, docNode: any) {\n let session = this.sessions.find((s) => s.user.id === user.id && s.doc?._id === docNode.doc._id)\n if (!session) {\n session = new Session()\n session.id = uuidv4()\n session.user = user\n session.startTime = Date.now()\n session.doc = docNode.doc\n session.angle = Math.random() * 2 * Math.PI\n this.sessions.push(session)\n }\n session.lastActive = Date.now()\n }\n\n reapSessions() {\n for (let i = 0; i < this.sessions.length; i++) {\n const session = this.sessions[i]\n if (Date.now() - session.lastActive > idleTimeout) {\n this.sessions = [...this.sessions.slice(0, i), ...this.sessions.slice(i + 1)]\n i--\n }\n }\n }\n\n clone() {\n const copy = new GraphData()\n Object.assign(copy, this)\n copy.data = {\n nodes: [...this.data.nodes],\n links: [...this.data.links],\n }\n return copy\n }\n}\n\nconst users = new Users()\n\ninterface GraphViewConfig {\n query?: string\n /** default: '2022-09-01' */\n apiVersion?: string\n}\n\nexport default function GraphView({\n tool: {options: props},\n}: {\n tool: {options: GraphViewConfig}\n}): React.JSX.Element {\n const query = props.query || DEFAULT_QUERY\n const apiVersion = props.apiVersion ?? '2022-09-01'\n\n const userColorManager = useUserColorManager()\n const [maxSize, setMaxSize] = useState(0)\n const [hoverNode, setHoverNode] = useState<any>(null)\n const [documents, setDocuments] = useState<SanityDocument[]>([])\n const [docTypes, setDocTypes] = useState<Record<string, number>>({})\n const [graph, setGraph] = useState(() => new GraphData())\n const router = useRouter()\n const client = useClient({apiVersion})\n\n useEffect(() => {\n void client.fetch(query).then((_docs) => {\n const docs = deduplicateDrafts(_docs)\n setMaxSize(Math.max(...docs.map(sizeOf)))\n setDocuments(docs)\n setDocTypes(getDocTypeCounts(docs))\n setGraph(new GraphData(docs))\n return undefined\n })\n }, [client, query])\n\n useEffect(() => {\n const subscription = client.listen(query, {}, {}).subscribe(async (update) => {\n if (update.type !== 'mutation') return\n const doc = update.result\n if (doc) {\n doc._id = stripDraftId(doc._id)\n\n const docsById: Record<string, SanityDocument> = {}\n for (const d of documents) {\n docsById[d._id] = d\n }\n\n let oldDoc\n const docs = [...documents]\n const idx = documents.findIndex((d) => d._id === doc._id)\n if (idx >= 0) {\n oldDoc = docs[idx]\n docs[idx] = doc\n } else {\n docs.push(doc)\n }\n setDocuments(docs)\n setDocTypes(getDocTypeCounts(docs))\n setMaxSize(Math.max(...docs.map(sizeOf)))\n\n const newGraph = graph.clone()\n\n const oldRefs = findRefs(oldDoc || {}).filter(\n (id) => id === doc._id || docsById[id] !== null,\n )\n const newRefs = findRefs(doc).filter((id) => id === doc._id || docsById[id] !== null)\n\n let graphChanged = !deepEqual(oldRefs, newRefs)\n if (graphChanged) {\n newGraph.data.links = newGraph.data.links\n .filter((l: any) => l.source.id !== doc._id)\n .concat(newRefs.map((ref) => ({source: doc._id, target: ref})))\n }\n\n let docNode\n const nodeIdx = graph.data.nodes.findIndex((n: any) => n.doc && n.doc._id === doc._id)\n if (nodeIdx >= 0) {\n docNode = graph.data.nodes[nodeIdx]\n docNode.doc = doc\n } else {\n docNode = {id: doc._id, type: 'document', doc: doc}\n newGraph.data.nodes.push(docNode)\n graphChanged = true\n }\n if (graphChanged) {\n setGraph(newGraph)\n }\n\n const user = await users.getById(update.identity, client)\n graph.setSession(user, docNode)\n } else if (update.transition === 'disappear') {\n const docId = stripDraftId(update.documentId)\n\n const docs = documents.filter((d) => d._id !== docId)\n setDocuments(docs)\n setDocTypes(getDocTypeCounts(docs))\n setMaxSize(Math.max(...docs.map(sizeOf)))\n\n const newGraph = graph.clone()\n newGraph.data.links = newGraph.data.links.filter(\n (l: any) => l.source.id !== docId && l.target.id !== docId,\n )\n newGraph.data.nodes = newGraph.data.nodes.filter((n: any) => n.id !== docId)\n setGraph(newGraph)\n }\n })\n return () => {\n subscription.unsubscribe()\n }\n }, [client, query, documents, graph])\n\n useEffect(() => {\n const interval = setInterval(() => graph.reapSessions(), 1000)\n return () => clearInterval(interval)\n }, [graph])\n\n const theme = useTheme().sanity\n\n return (\n <GraphWrapper theme={theme}>\n <GraphRoot theme={theme}>\n <Legend theme={theme}>\n {getTopDocTypes(docTypes).map((docType) => (\n <LegendRow\n className={'legend__row'}\n key={docType}\n style={{color: getDocTypeColor(docType).fill}}\n >\n <LegendBadge theme={theme} />\n <div>{formatDocType(docType)}</div>\n </LegendRow>\n ))}\n </Legend>\n {hoverNode && <HoverNode theme={theme}>{labelFor(hoverNode.doc)}</HoverNode>}\n <ForceGraph2D\n graphData={graph.data}\n nodeAutoColorBy=\"group\"\n enableNodeDrag={false}\n onNodeHover={(node: any) => setHoverNode(node)}\n onNodeClick={(node: any) => {\n router.navigateIntent('edit', {id: node.doc._id, documentType: node.doc._type})\n }}\n linkColor={() => rgba(gray[500].hex, 0.25)}\n nodeLabel={() => ''}\n nodeRelSize={1}\n nodeVal={(node: any) => valueFor(node.doc, maxSize)}\n onRenderFramePost={(ctx, globalScale) => {\n for (const session of graph.sessions) {\n const node = graph.data.nodes.find(\n (n: any) => n.doc && n.doc._id === session?.doc?._id,\n )\n if (node) {\n const idleFactorRange = idleTimeout\n const angle = session.angle\n const radius = Math.sqrt(valueFor(node.doc, maxSize))\n const image = session.user.image\n const userColor = userColorManager.get(session.user.displayName).tints[400].hex\n const distance = radius * globalScale + 40\n const imgW = image ? image.width : 0\n const imgH = image ? image.height : 0\n const x = node.x + (Math.sin(angle) * distance) / globalScale\n const y = node.y + (Math.cos(angle) * distance) / globalScale\n\n ctx.save()\n // eslint-disable-next-line react-hooks/todo\n try {\n ctx.globalAlpha = fadeEasing(\n 1 -\n Math.min(idleFactorRange, Date.now() - session.lastActive) / idleFactorRange,\n )\n ctx.font = `bold ${Math.round(12 / globalScale)}px sans-serif`\n\n ctx.beginPath()\n ctx.strokeStyle = rgba(white.hex, 1.0)\n ctx.lineWidth = 2 / globalScale\n ctx.moveTo(\n node.x + (Math.sin(angle) * (distance - imgW / 2)) / globalScale,\n node.y + (Math.cos(angle) * (distance - imgH / 2)) / globalScale,\n )\n ctx.lineTo(node.x + Math.sin(angle) * radius, node.y + Math.cos(angle) * radius)\n ctx.stroke()\n\n ctx.beginPath()\n ctx.strokeStyle = rgba(white.hex, 1.0)\n ctx.lineWidth = 2 / globalScale\n ctx.arc(node.x, node.y, radius, 0, 2 * Math.PI, false)\n ctx.stroke()\n\n if (image) {\n ctx.save()\n try {\n const dur = 700\n const f = softEasing(\n Math.max(0, (dur - (Date.now() - session.startTime)) / dur),\n )\n if (f > 0) {\n ctx.beginPath()\n ctx.fillStyle = rgba(userColor, f)\n ctx.arc(x, y, (imgW / 2 + 10) / globalScale, 0, 2 * Math.PI, false)\n ctx.fill()\n }\n\n ctx.beginPath()\n ctx.fillStyle = rgba(white.hex, 1.0)\n ctx.arc(x, y, imgW / globalScale / 2, 0, 2 * Math.PI, false)\n ctx.clip()\n\n ctx.drawImage(\n image,\n x - imgW / globalScale / 2,\n y - imgH / globalScale / 2,\n imgW / globalScale,\n imgH / globalScale,\n )\n\n ctx.strokeStyle = black.hex\n ctx.lineWidth = 6 / globalScale\n ctx.stroke()\n\n ctx.strokeStyle = userColor\n ctx.lineWidth = 4 / globalScale\n ctx.stroke()\n } finally {\n ctx.restore()\n }\n }\n\n ctx.beginPath()\n ctx.strokeStyle = rgba(black.hex, 1)\n ctx.lineWidth = 0.5 / globalScale\n ctx.arc(x, y, imgW / globalScale / 2, 0, 2 * Math.PI, false)\n ctx.stroke()\n\n const above = angle >= Math.PI / 2 && angle < Math.PI * 1.5\n const textY = above\n ? y - (imgH / 2 + 5) / globalScale\n : y + (imgH / 2 + 5) / globalScale\n ctx.fillStyle = rgba(white.hex, 1.0)\n ctx.textAlign = 'center'\n ctx.textBaseline = above ? 'bottom' : 'top'\n ctx.fillText(session.user.displayName, x, textY)\n } finally {\n ctx.restore()\n }\n }\n }\n }}\n nodeCanvasObject={(node: any, ctx, globalScale) => {\n switch (node.type) {\n case 'document': {\n const nodeColor = getDocTypeColor(node.doc._type)\n const radius = Math.sqrt(valueFor(node.doc, maxSize))\n const fontSize = Math.min(100, 10.0 / globalScale)\n\n ctx.beginPath()\n ctx.fillStyle =\n hoverNode !== null && node.doc._id === hoverNode.doc._id\n ? rgba(gray[500].hex, 0.8)\n : nodeColor.fill\n ctx.strokeStyle = nodeColor.border\n ctx.lineWidth = 0.5\n ctx.arc(node.x, node.y, radius, 0, 2 * Math.PI, false)\n ctx.stroke()\n ctx.fill()\n\n if (radius * globalScale > 10) {\n ctx.font = `${fontSize}px sans-serif`\n const w = radius * 2 + 30 / globalScale\n for (let len = 50; len >= 5; len /= 1.2) {\n const label = truncate(labelFor(node.doc), Math.round(len))\n const textMetrics = ctx.measureText(label)\n if (textMetrics.width < w) {\n // ctx.fillStyle = rgba(color.white.hex, 1.0)\n ctx.textAlign = 'center'\n ctx.textBaseline = 'top'\n\n ctx.strokeStyle = rgba(black.hex, 0.5)\n ctx.lineWidth = 2 / globalScale\n ctx.strokeText(label, node.x, node.y + radius + 5 / globalScale)\n\n ctx.fillText(label, node.x, node.y + radius + 5 / globalScale)\n break\n }\n }\n }\n }\n }\n }}\n linkCanvasObject={(link: any, ctx, globalScale) => {\n ctx.beginPath()\n ctx.strokeStyle = rgba(gray[500].hex, 0.125)\n ctx.lineWidth = 2 / globalScale\n ctx.moveTo(link.source.x, link.source.y)\n ctx.lineTo(link.target.x, link.target.y)\n ctx.stroke()\n }}\n />\n </GraphRoot>\n </GraphWrapper>\n )\n}\n\nconst colorCache: Record<string, {fill: string; border: string}> = {}\nlet typeColorNum = 0\n\nfunction getDocTypeColor(docType: any) {\n if (colorCache[docType]) {\n return colorCache[docType]\n }\n\n const hue = COLOR_HUES[typeColorNum % COLOR_HUES.length]\n\n typeColorNum += 1\n\n colorCache[docType] = {\n fill: hues[hue][400].hex,\n border: rgba(black.hex, 0.5),\n }\n\n return colorCache[docType]\n}\n"],"names":["GraphRoot","styled","div","withConfig","displayName","componentId","theme","fonts","text","family","black","hex","GraphWrapper","HoverNode","space","radius","Legend","LegendRow","LegendBadge","sizeOf","value","Object","entries","reduce","total","k","v","Array","isArray","length","loadImage","url","w","h","Promise","resolve","img","Image","onload","onerror","event","console","error","src","sortBy","array","f","sort","a","b","va","vb","truncate","s","limit","substring","DEFAULT_QUERY","fadeEasing","BezierEasing","softEasing","idleTimeout","imageSize","getTopDocTypes","counts","keys","docType","reverse","slice","formatDocType","toUpperCase","replace","trim","getDocTypeCounts","docs","types","doc","_type","labelFor","title","name","_id","valueFor","maxSize","findRefs","obj","dest","push","stripDraftId","id","deduplicateDrafts","deduped","startsWith","assign","values","Users","_users","getById","client","user","find","u","users","image","imageUrl","Session","lastActive","startTime","angle","GraphData","sessions","constructor","docsById","data","nodes","map","d","type","links","flatMap","ref","source","target","filter","link","setSession","docNode","session","uuidv4","Date","now","Math","random","PI","reapSessions","i","clone","copy","GraphView","tool","options","props","query","apiVersion","userColorManager","useUserColorManager","setMaxSize","useState","hoverNode","setHoverNode","documents","setDocuments","docTypes","setDocTypes","graph","setGraph","router","useRouter","useClient","useEffect","fetch","then","_docs","max","subscription","listen","subscribe","update","result","oldDoc","idx","findIndex","newGraph","oldRefs","newRefs","graphChanged","deepEqual","l","concat","nodeIdx","n","identity","transition","docId","documentId","unsubscribe","interval","setInterval","clearInterval","useTheme","sanity","jsx","jsxs","color","getDocTypeColor","fill","ForceGraph2D","node","navigateIntent","documentType","rgba","gray","ctx","globalScale","idleFactorRange","sqrt","userColor","get","tints","distance","imgW","width","imgH","height","x","sin","y","cos","save","globalAlpha","min","font","round","beginPath","strokeStyle","white","lineWidth","moveTo","lineTo","stroke","arc","dur","fillStyle","clip","drawImage","restore","above","textY","textAlign","textBaseline","fillText","nodeColor","fontSize","border","len","label","measureText","strokeText","colorCache","typeColorNum","hue","COLOR_HUES","hues"],"mappings":";;;;;;AASO,MAAMA,YAA6BC,iBAAAA,OAAOC,IAAGC,WAAA;AAAA,EAAAC,aAAA;AAAA,EAAAC,aAAA;AAAA,CAAA,gBACnC,CAAC;AAAA,EAACC;AAAY,MAAMA,MAAMC,MAAMC,KAAKC,MAAM,qEAM5CC,MAAAA,MAAMC,GAAG,KAGZC,eAAgCX,iBAAAA,OAAOC,IAAGC,WAAA;AAAA,EAAAC,aAAA;AAAA,EAAAC,aAAA;AA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GACrC8L,MAAIwB,YAAY,IAAIvB,eACpBD,MAAI6C,WAAWF,OAAOhD,OAAKiB,GAAGjB,OAAKmB,IAAIxM,WAAS,IAAI2L,aAAW,GAE/DD,MAAIsC,SAASK,OAAOhD,OAAKiB,GAAGjB,OAAKmB,IAAIxM,WAAS,IAAI2L,aAAW;AAC7D;AAAA,cACF;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,MAAA;AAAA,IAEJ,GACA,kBAAkB,CAAC/E,MAAW8E,OAAKC,kBAAgB;AACjDD,YAAIqB,UAAAA,GACJrB,MAAIsB,cAAcxB,SAAAA,KAAKC,MAAAA,KAAK,GAAG,EAAE7L,KAAK,KAAK,GAC3C8L,MAAIwB,YAAY,IAAIvB,eACpBD,MAAIyB,OAAOvG,KAAKH,OAAO6F,GAAG1F,KAAKH,OAAO+F,CAAC,GACvCd,MAAI0B,OAAOxG,KAAKF,OAAO4F,GAAG1F,KAAKF,OAAO8F,CAAC,GACvCd,MAAI2B,OAAAA;AAAAA,IACN,EAAA,CAAE;AAAA,EAAA,EAAA,CAEN,EAAA,CACF;AAEJ;AAEA,MAAMmB,aAA6D,CAAA;AACnE,IAAIC,eAAe;AAEnB,SAASvD,gBAAgBhI,SAAc;AACrC,MAAIsL,WAAWtL,OAAO;AACpB,WAAOsL,WAAWtL,OAAO;AAG3B,QAAMwL,MAAMC,MAAAA,WAAWF,eAAeE,MAAAA,WAAW7N,MAAM;AAEvD2N,SAAAA,gBAAgB,GAEhBD,WAAWtL,OAAO,IAAI;AAAA,IACpBiI,MAAMyD,MAAAA,KAAKF,GAAG,EAAE,GAAG,EAAE9O;AAAAA,IACrBuO,QAAQ3C,SAAAA,KAAK7L,YAAMC,KAAK,GAAG;AAAA,EAAA,GAGtB4O,WAAWtL,OAAO;AAC3B;;"}
package/dist/index.cjs DELETED
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: !0 });
3
- var react = require("react"), sanity = require("sanity"), router = require("sanity/router"), jsxRuntime = require("react/jsx-runtime"), reactCompilerRuntime = require("react-compiler-runtime");
4
- function GraphViewIcon() {
5
- const $ = reactCompilerRuntime.c(1);
6
- let t0;
7
- return $[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", viewBox: "0 0 46.063 46.063", children: /* @__PURE__ */ jsxRuntime.jsx("path", { fill: "currentColor", d: "M18.022 38.676v2.813h-1.21q-4.864 0-6.525-1.447-1.64-1.445-1.64-5.762v-4.666q0-2.95-1.055-4.083-1.055-1.13-3.828-1.13h-1.19v-2.794h1.19q2.793 0 3.828-1.114 1.055-1.132 1.055-4.043V11.76q0-4.316 1.64-5.742 1.66-1.446 6.524-1.446h1.212v2.793h-1.328q-2.754 0-3.594.86-.84.86-.84 3.613v4.844q0 3.066-.898 4.453-.88 1.387-3.028 1.875 2.168.527 3.047 1.914.88 1.387.88 4.434v4.843q0 2.754.84 3.614.84.86 3.594.86h1.328zM28.04 38.676h1.368q2.735 0 3.555-.84.84-.84.84-3.633V29.36q0-3.047.88-4.434.878-1.387 3.046-1.914-2.17-.488-3.048-1.875-.88-1.387-.88-4.453V11.84q0-2.773-.84-3.613-.82-.86-3.554-.86H28.04V4.574h1.232q4.863 0 6.484 1.446 1.64 1.426 1.64 5.742v4.687q0 2.91 1.055 4.042 1.056 1.114 3.83 1.114h1.21V24.4h-1.21q-2.774 0-3.83 1.13-1.053 1.134-1.053 4.084v4.667q0 4.318-1.64 5.763-1.622 1.446-6.485 1.446h-1.23v-2.814z" }) }), $[0] = t0) : t0 = $[0], t0;
8
- }
9
- const GraphView = react.lazy(() => Promise.resolve().then(function() {
10
- return require("./_chunks-cjs/GraphView.cjs");
11
- })), contentGraphView = sanity.definePlugin((config = {}) => ({
12
- name: "@sanity/content-graph-view",
13
- tools: [{
14
- name: "graph-your-content",
15
- title: "Graph",
16
- icon: GraphViewIcon,
17
- component: GraphView,
18
- options: config,
19
- router: router.route.create("/:selectedDocumentId")
20
- }]
21
- }));
22
- exports.contentGraphView = contentGraphView;
23
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/tool/GraphViewIcon.tsx","../src/plugin.tsx"],"sourcesContent":["/**\n * Couple of things to note:\n * - width and height is set to 1em\n * - fill is `currentColor` - this will ensure that the icon looks uniform and\n * that the hover/active state works. You can of course render anything you\n * would like here, but for plugins that are to be used in more than one\n * studio, we suggest these rules are followed\n **/\nexport function GraphViewIcon(): React.JSX.Element {\n return (\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"1em\" height=\"1em\" viewBox=\"0 0 46.063 46.063\">\n <path\n fill=\"currentColor\"\n d=\"M18.022 38.676v2.813h-1.21q-4.864 0-6.525-1.447-1.64-1.445-1.64-5.762v-4.666q0-2.95-1.055-4.083-1.055-1.13-3.828-1.13h-1.19v-2.794h1.19q2.793 0 3.828-1.114 1.055-1.132 1.055-4.043V11.76q0-4.316 1.64-5.742 1.66-1.446 6.524-1.446h1.212v2.793h-1.328q-2.754 0-3.594.86-.84.86-.84 3.613v4.844q0 3.066-.898 4.453-.88 1.387-3.028 1.875 2.168.527 3.047 1.914.88 1.387.88 4.434v4.843q0 2.754.84 3.614.84.86 3.594.86h1.328zM28.04 38.676h1.368q2.735 0 3.555-.84.84-.84.84-3.633V29.36q0-3.047.88-4.434.878-1.387 3.046-1.914-2.17-.488-3.048-1.875-.88-1.387-.88-4.453V11.84q0-2.773-.84-3.613-.82-.86-3.554-.86H28.04V4.574h1.232q4.863 0 6.484 1.446 1.64 1.426 1.64 5.742v4.687q0 2.91 1.055 4.042 1.056 1.114 3.83 1.114h1.21V24.4h-1.21q-2.774 0-3.83 1.13-1.053 1.134-1.053 4.084v4.667q0 4.318-1.64 5.763-1.622 1.446-6.485 1.446h-1.23v-2.814z\"\n />\n </svg>\n )\n}\n","import {lazy} from 'react'\nimport {definePlugin} from 'sanity'\nimport {route} from 'sanity/router'\n\nimport {GraphViewIcon} from './tool/GraphViewIcon'\n\nexport interface GraphViewConfig {\n query?: string\n}\n\nconst GraphView = lazy(() => import('./tool/GraphView'))\n\nexport const contentGraphView = definePlugin<void | GraphViewConfig>(\n (config: GraphViewConfig = {}) => {\n return {\n name: '@sanity/content-graph-view',\n\n tools: [\n {\n name: 'graph-your-content',\n title: 'Graph',\n icon: GraphViewIcon,\n component: GraphView,\n options: config,\n router: route.create('/:selectedDocumentId'),\n },\n ],\n }\n },\n)\n"],"names":["GraphViewIcon","$","_c","t0","Symbol","for","jsx","GraphView","lazy","contentGraphView","definePlugin","config","name","tools","title","icon","component","options","router","route","create"],"mappings":";;;AAQO,SAAAA,gBAAA;AAAA,QAAAC,IAAAC,qBAAAA,EAAA,CAAA;AAAA,MAAAC;AAAA,SAAAF,EAAA,CAAA,MAAAG,uBAAAC,IAAA,2BAAA,KAEHF,KAAAG,2BAAAA,IAAA,OAAA,EAAW,OAAA,8BAAmC,OAAA,OAAa,QAAA,OAAc,SAAA,qBACvE,UAAAA,2BAAAA,IAAA,QAAA,EACO,MAAA,gBACH,GAAA,4zBAAA,CAA2zB,EAAA,CAEj0B,GAAML,OAAAE,MAAAA,KAAAF,EAAA,CAAA,GALNE;AAKM;ACLV,MAAMI,YAAYC,MAAAA,KAAK,MAAM,QAAA,QAAA,EAAA,KAAA,WAAA;AAAA,SAAA,QAAO,6BAAkB;EAAC,GAE1CC,mBAAmBC,OAAAA,aAC9B,CAACC,SAA0B,QAClB;AAAA,EACLC,MAAM;AAAA,EAENC,OAAO,CACL;AAAA,IACED,MAAM;AAAA,IACNE,OAAO;AAAA,IACPC,MAAMf;AAAAA,IACNgB,WAAWT;AAAAA,IACXU,SAASN;AAAAA,IACTO,QAAQC,OAAAA,MAAMC,OAAO,sBAAsB;AAAA,EAAA,CAC5C;AAEL,EAEJ;;"}
package/dist/index.d.cts DELETED
@@ -1,7 +0,0 @@
1
- import * as sanity0 from "sanity";
2
- interface GraphViewConfig {
3
- query?: string;
4
- }
5
- declare const contentGraphView: sanity0.Plugin<void | GraphViewConfig>;
6
- export { type GraphViewConfig, contentGraphView };
7
- //# sourceMappingURL=index.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.cts","names":["GraphViewConfig","contentGraphView","sanity0","Plugin"],"sources":["../src/plugin.d.ts"],"sourcesContent":["export interface GraphViewConfig {\n query?: string;\n}\nexport declare const contentGraphView: import(\"sanity\").Plugin<void | GraphViewConfig>;\n//# sourceMappingURL=plugin.d.ts.map"],"mappings":";UAAiBA,eAAAA;;AAAjB;AAGqBC,cAAAA,gBAAiDD,EAAeE,OAAAA,CAA7BC,MAAAA,CAAAA,IAAM,GAAQH,eAAR,CAAA"}