Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sanity/presentation

Package Overview
Dependencies
Maintainers
62
Versions
233
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sanity/presentation - npm Package Compare versions

Comparing version 1.17.8-release.4 to 1.17.8

src/RevisionSwitcher.tsx

2

dist/_chunks-es/index.js

@@ -11,3 +11,3 @@ import { jsx, jsxs, Fragment } from "react/jsx-runtime";

import { uuid } from "@sanity/uuid";
const DEFAULT_TOOL_ICON = ComposeIcon, DEFAULT_TOOL_NAME = "presentation", DEFAULT_TOOL_TITLE = "Presentation", COMMENTS_INSPECTOR_NAME = "sanity/structure/comments", EDIT_INTENT_MODE = "presentation", MAX_TIME_TO_OVERLAYS_CONNECTION = 3e3, API_VERSION = "vX", MIN_LOADER_QUERY_LISTEN_HEARTBEAT_INTERVAL = 1e3, LIVE_QUERY_CACHE_BATCH_SIZE = 100, LIVE_QUERY_CACHE_SIZE = 2048;
const DEFAULT_TOOL_ICON = ComposeIcon, DEFAULT_TOOL_NAME = "presentation", DEFAULT_TOOL_TITLE = "Presentation", COMMENTS_INSPECTOR_NAME = "sanity/structure/comments", EDIT_INTENT_MODE = "presentation", MAX_TIME_TO_OVERLAYS_CONNECTION = 3e3, API_VERSION = "2023-10-16", MIN_LOADER_QUERY_LISTEN_HEARTBEAT_INTERVAL = 1e3, LIVE_QUERY_CACHE_BATCH_SIZE = 100, LIVE_QUERY_CACHE_SIZE = 2048;
function keysOf(value) {

@@ -14,0 +14,0 @@ return Object.keys(value);

@@ -12,3 +12,2 @@ import { jsx, Fragment } from "react/jsx-runtime";

import { MIN_LOADER_QUERY_LISTEN_HEARTBEAT_INTERVAL } from "./index.js";
import { getBundlePerspective } from "./utils.js";
function LoaderQueries(props) {

@@ -20,3 +19,2 @@ const {

onLoadersConnection,
bundlesPerspective,
onDocumentsOnPage

@@ -81,3 +79,3 @@ } = props, [comlink, setComlink] = useState(), [liveQueries, setLiveQueries] = useState({}), projectId = useProjectId(), dataset = useDataset();

}, [controller, dataset, onDocumentsOnPage, onLoadersConnection, projectId]);
const [syncTagsInUse] = useState(() => /* @__PURE__ */ new Set()), [lastLiveEventId, setLastLiveEventId] = useState(null), studioClient = useClient({ apiVersion: "vX" }), clientConfig = useMemo(() => studioClient.config(), [studioClient]), client = useMemo(
const [syncTagsInUse] = useState(() => /* @__PURE__ */ new Set()), [lastLiveEventId, setLastLiveEventId] = useState(null), studioClient = useClient({ apiVersion: "2023-10-16" }), clientConfig = useMemo(() => studioClient.config(), [studioClient]), client = useMemo(
() => studioClient.withConfig({

@@ -96,8 +94,7 @@ resultSourceMap: "withKeyArraySelector"

dataset: dataset2,
perspective: activePerspective,
bundlePerspective: bundlesPerspective
perspective: activePerspective
}
});
}
}, [comlink, clientConfig, activePerspective, bundlesPerspective]);
}, [comlink, clientConfig, activePerspective]);
const handleSyncTags = useEffectEvent((event) => {

@@ -126,3 +123,2 @@ const flattenedSyncTags = Array.from(syncTagsInUse).flat();

dataset: clientConfig.dataset,
bundlesPerspective,
perspective,

@@ -144,3 +140,2 @@ query,

dataset,
bundlesPerspective,
perspective,

@@ -161,3 +156,2 @@ query,

params,
bundlesPerspective,
perspective,

@@ -203,3 +197,3 @@ query,

function useQuerySubscription(props) {
const { liveDocument, client, query, params, perspective, lastLiveEventId, bundlesPerspective } = props, [snapshot, setSnapshot] = useState(null), [error, setError] = useState(null);
const { liveDocument, client, query, params, perspective, lastLiveEventId } = props, [snapshot, setSnapshot] = useState(null), [error, setError] = useState(null);
if (error) throw error;

@@ -222,4 +216,3 @@ const [revalidate, startRefresh] = useRevalidate({

signal,
perspective: void 0,
bundlePerspective: getBundlePerspective(perspective, bundlesPerspective),
perspective,
filterResponse: !1,

@@ -241,12 +234,3 @@ returnQuery: !1

};
}, [
client,
lastLiveEventId,
params,
perspective,
query,
shouldRefetch,
startRefresh,
bundlesPerspective
]);
}, [client, lastLiveEventId, params, perspective, query, shouldRefetch, startRefresh]);
const { result, resultSourceMap, syncTags } = snapshot ?? {};

@@ -274,4 +258,3 @@ return useMemo(() => liveDocument && resultSourceMap ? {

(changedValue, { previousValue }) => typeof changedValue == "number" && typeof previousValue == "string" ? `${changedValue}` : changedValue,
// TODO: Update applySourceDocuments to support bundlePerspective.
perspective.startsWith("bundle.") ? "previewDrafts" : perspective
perspective
);

@@ -278,0 +261,0 @@ }

@@ -11,3 +11,2 @@ import { jsxs, Fragment, jsx } from "react/jsx-runtime";

import { MIN_LOADER_QUERY_LISTEN_HEARTBEAT_INTERVAL, LIVE_QUERY_CACHE_SIZE, LIVE_QUERY_CACHE_BATCH_SIZE } from "./index.js";
import { getBundlePerspective } from "./utils.js";
function LoaderQueries(props) {

@@ -18,3 +17,2 @@ const {

perspective: activePerspective,
bundlesPerspective,
documentsOnPage,

@@ -81,3 +79,3 @@ onLoadersConnection,

}, [controller, dataset, onDocumentsOnPage, onLoadersConnection, projectId]);
const [cache] = useState(() => new LRUCache(LIVE_QUERY_CACHE_SIZE)), studioClient = useClient({ apiVersion: "vX" }), clientConfig = useMemo(() => studioClient.config(), [studioClient]), client = useMemo(
const [cache] = useState(() => new LRUCache(LIVE_QUERY_CACHE_SIZE)), studioClient = useClient({ apiVersion: "2023-10-16" }), clientConfig = useMemo(() => studioClient.config(), [studioClient]), client = useMemo(
() => studioClient.withConfig({

@@ -96,8 +94,7 @@ resultSourceMap: "withKeyArraySelector"

dataset: dataset2,
perspective: activePerspective,
bundlePerspective: bundlesPerspective
perspective: activePerspective
}
});
}
}, [comlink, clientConfig, activePerspective, bundlesPerspective]);
}, [comlink, clientConfig, activePerspective]);
const turboIds = useMemo(() => {

@@ -123,3 +120,2 @@ const documentsActuallyInUse = documentsOnPage.map(({ _id }) => _id), ids = [...new Set(documentsActuallyInUse)], max = cache.capacity;

dataset: clientConfig.dataset,
bundlesPerspective,
perspective,

@@ -195,3 +191,2 @@ query,

perspective,
bundlesPerspective,
query,

@@ -208,3 +203,2 @@ client,

params,
bundlesPerspective,
perspective,

@@ -239,3 +233,2 @@ query,

params,
bundlesPerspective,
perspective,

@@ -260,4 +253,3 @@ documentsCacheLastUpdated

signal,
perspective: void 0,
bundlePerspective: getBundlePerspective(perspective, bundlesPerspective),
perspective,
filterResponse: !1

@@ -279,3 +271,2 @@ });

perspective,
bundlesPerspective,
projectId,

@@ -315,4 +306,3 @@ query,

(changedValue, { previousValue }) => typeof changedValue == "number" && typeof previousValue == "string" ? `${changedValue}` : changedValue,
// TODO: Update applySourceDocuments to support bundlePerspective.
perspective.startsWith("bundle.") ? "previewDrafts" : perspective
perspective
);

@@ -319,0 +309,0 @@ }

@@ -47,8 +47,5 @@ import { memo, useEffect } from "react";

};
}, [client, comlink]), useEffect(() => comlink.on("visual-editing/fetch-snapshot", async (data) => {
const cleanId = data.documentId.includes("versions.") && data.documentId.startsWith("drafts.") ? data.documentId.replace("drafts.", "") : data.documentId;
return { snapshot: await client.getDocument(cleanId, {
tag: "document.snapshots"
}) };
}), [client, comlink]), useEffect(() => comlink.on("visual-editing/mutate", async (data) => client.dataRequest("mutate", data, {
}, [client, comlink]), useEffect(() => comlink.on("visual-editing/fetch-snapshot", async (data) => ({ snapshot: await client.getDocument(data.documentId, {
tag: "document.snapshots"
}) })), [client, comlink]), useEffect(() => comlink.on("visual-editing/mutate", async (data) => client.dataRequest("mutate", data, {
visibility: "async",

@@ -55,0 +52,0 @@ returnDocuments: !0

import { memo, useEffect } from "react";
const PostMessagePerspective = (props) => {
const { comlink, perspective, bundlesPerspective } = props;
const { comlink, perspective } = props;
return useEffect(() => comlink.on("visual-editing/fetch-perspective", () => ({
perspective,
bundlesPerspective
})), [comlink, perspective, bundlesPerspective]), useEffect(() => {
perspective
})), [comlink, perspective]), useEffect(() => {
comlink.post({
type: "presentation/perspective",
data: { perspective, bundlesPerspective }
data: { perspective }
});
}, [comlink, perspective, bundlesPerspective]), null;
}, [comlink, perspective]), null;
};

@@ -14,0 +13,0 @@ var PostMessagePerspective$1 = memo(PostMessagePerspective);

import { memo, useMemo, useEffect } from "react";
import { Subject, switchMap, combineLatest, share, skipWhile, NEVER, merge, takeUntil, debounceTime } from "rxjs";
import { Subject, switchMap, combineLatest, share, skipWhile, NEVER, merge, takeUntil, filter, map, debounceTime } from "rxjs";
import { useDocumentPreviewStore, useSchema, getDraftId, getPublishedId } from "sanity";

@@ -20,3 +20,15 @@ const PostMessagePreviews = (props) => {

);
return merge(published$.pipe(takeUntil(draft$)), draft$);
return merge(published$.pipe(takeUntil(draft$)), draft$).pipe(
filter((p) => !!p.snapshot),
map((p) => {
const snapshot = p.snapshot;
return {
_id: getPublishedId(snapshot._id),
title: snapshot.title,
subtitle: snapshot.subtitle,
description: snapshot.description,
imageUrl: snapshot.imageUrl
};
})
);
})

@@ -30,8 +42,3 @@ )),

type: "presentation/preview-snapshots",
data: {
snapshots: snapshots.filter((s) => s.snapshot).map((s) => {
const snapshot = s.snapshot;
return { ...snapshot, _id: getPublishedId(snapshot._id) };
})
}
data: { snapshots }
});

@@ -38,0 +45,0 @@ });

import { ThemeProvider, useRootTheme } from "@sanity/ui";
import { createElement, memo, useEffect } from "react";
import { API_VERSION } from "./index.js";
import { useWorkspace, useClient, getPublishedId } from "sanity";
import { getBundlePerspective } from "./utils.js";
import { useWorkspace, useClient } from "sanity";
import { renderToString } from "react-dom/server";

@@ -423,3 +422,3 @@ import { jsx } from "react/jsx-runtime";

function PostMessageSchema(props) {
const { comlink, perspective, bundlesPerspective } = props, workspace = useWorkspace(), theme = useRootTheme();
const { comlink, perspective } = props, workspace = useWorkspace(), theme = useRootTheme();
useEffect(() => {

@@ -433,11 +432,3 @@ const schema = extractSchema(workspace, theme);

documentPathArray.map(async ([id, paths]) => {
const arr = Array.from(paths), query = `*[_id == $id][0]{${arr.map((path, i) => `"${i}": ${path}[0]._type`).join(",")}}`, result = await client.fetch(
query,
{ id: getPublishedId(id) },
{
tag: "presentation-schema",
perspective: void 0,
bundlePerspective: getBundlePerspective(perspective, bundlesPerspective)
}
), mapped = arr.map((path, i) => ({ path, type: result[i] }));
const arr = Array.from(paths), query = `*[_id == $id][0]{${arr.map((path, i) => `"${i}": ${path}[0]._type`).join(",")}}`, result = await client.fetch(query, { id }, { perspective, tag: "presentation-schema" }), mapped = arr.map((path, i) => ({ path, type: result[i] }));
return { id, paths: mapped };

@@ -449,3 +440,3 @@ })

}), { types: newState };
}), [comlink, client, perspective, bundlesPerspective]), null;
}), [comlink, client, perspective]), null;
}

@@ -452,0 +443,0 @@ var PostMessageSchema$1 = memo(PostMessageSchema);

{
"name": "@sanity/presentation",
"version": "1.17.8-release.4",
"version": "1.17.8",
"homepage": "https://github.com/sanity-io/visual-editing/tree/main/packages/presentation#readme",

@@ -43,5 +43,5 @@ "bugs": {

"dependencies": {
"@sanity/icons": "3.5.0-corel.0",
"@sanity/icons": "^3.4.0",
"@sanity/logos": "^2.1.13",
"@sanity/ui": "2.10.0-corel.0",
"@sanity/ui": "^2.8.10",
"@sanity/uuid": "3.0.2",

@@ -59,7 +59,7 @@ "@types/lodash.isequal": "^4.5.8",

"use-effect-event": "^1.0.2",
"@sanity/comlink": "1.1.2-release.4",
"@sanity/preview-url-secret": "2.0.1-release.4"
"@sanity/comlink": "1.1.1",
"@sanity/preview-url-secret": "2.0.0"
},
"devDependencies": {
"@sanity/client": "6.22.2-bundle-perspective-2",
"@sanity/client": "^6.22.2",
"@sanity/pkg-utils": "6.11.6",

@@ -71,3 +71,3 @@ "@types/lodash.get": "^4.4.9",

"react-dom": "^18.3.1",
"sanity": "3.59.2-corel.333",
"sanity": "^3.62.2",
"styled-components": "6.1.13",

@@ -77,8 +77,8 @@ "typescript": "5.6.3",

"@repo/eslint-config": "0.0.0",
"@repo/package.config": "0.0.0",
"@repo/prettier-config": "0.0.0",
"@repo/package.config": "0.0.0",
"@repo/visual-editing-helpers": "0.6.28"
"@repo/visual-editing-helpers": "0.6.29"
},
"peerDependencies": {
"@sanity/client": "6.22.2-bundle-perspective-2"
"@sanity/client": "^6.22.2"
},

@@ -85,0 +85,0 @@ "engines": {

@@ -16,3 +16,3 @@ import {ComposeIcon} from '@sanity/icons'

// The API version to use when using `@sanity/client`
export const API_VERSION = 'vX'
export const API_VERSION = '2023-10-16'

@@ -19,0 +19,0 @@ // Heartbeats shouldn't fire on intervals that are so short it causes performance issues

@@ -17,12 +17,1 @@ import type {ClientPerspective, QueryParams} from '@sanity/client'

}
// This is a small hack, perspective=published is returning incorrect results, using it through bundlePerspective works fine.
export function getBundlePerspective(
perspective: ClientPerspective | `bundle.${string}`,
bundlesPerspectives: string[],
): string[] {
if (perspective === 'published') return ['published']
if (perspective === 'previewDrafts') return ['drafts']
if (perspective.startsWith('bundle.')) return bundlesPerspectives
throw new Error(`Invalid perspective: ${perspective}`)
}

@@ -232,5 +232,3 @@ import type {

export type PresentationPerspective =
| Extract<'published' | 'previewDrafts', ClientPerspective>
| `bundle.${string}`
export type PresentationPerspective = Extract<'published' | 'previewDrafts', ClientPerspective>

@@ -246,3 +244,3 @@ export type PresentationViewport = 'desktop' | 'mobile'

params: QueryParams
perspective: ClientPerspective | `bundle.${string}`
perspective: ClientPerspective
receivedAt: number

@@ -249,0 +247,0 @@ /**

@@ -0,1 +1,2 @@

import type {ClientPerspective} from '@sanity/client'
import isEqual from 'fast-deep-equal'

@@ -22,7 +23,3 @@ import {useCallback, useMemo, useRef, useState, type MutableRefObject} from 'react'

] {
if (
perspective !== 'published' &&
perspective !== 'previewDrafts' &&
!perspective.startsWith('bundle.')
) {
if (perspective !== 'published' && perspective !== 'previewDrafts') {
throw new Error(`Invalid perspective: ${perspective}`)

@@ -39,3 +36,3 @@ }

const setDocumentsOnPage = useCallback(
(key: string, perspective: PresentationPerspective, sourceDocuments: DocumentOnPage[] = []) => {
(key: string, perspective: ClientPerspective, sourceDocuments: DocumentOnPage[] = []) => {
const documents = sourceDocuments.filter((sourceDocument) => {

@@ -42,0 +39,0 @@ if ('_projectId' in sourceDocument && sourceDocument._projectId) {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc