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

@sanity/presentation

Package Overview
Dependencies
Maintainers
64
Versions
263
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.18.4 to 1.18.5

src/usePopups.ts

3

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 = "2023-10-16", 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, POPUP_CHECK_INTERVAL = 1e3;
function keysOf(value) {

@@ -798,2 +798,3 @@ return Object.keys(value);

MIN_LOADER_QUERY_LISTEN_HEARTBEAT_INTERVAL,
POPUP_CHECK_INTERVAL,
PresentationContext,

@@ -800,0 +801,0 @@ PresentationNavigateContext,

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

@@ -58,3 +58,3 @@ "bugs": {

"use-effect-event": "^1.0.2",
"@sanity/comlink": "1.1.3",
"@sanity/comlink": "1.1.4",
"@sanity/preview-url-secret": "2.0.4"

@@ -70,10 +70,10 @@ },

"react-dom": "^18.3.1",
"sanity": "^3.64.1",
"sanity": "^3.64.2",
"styled-components": "6.1.13",
"typescript": "5.6.3",
"vitest": "^2.1.5",
"@repo/eslint-config": "0.0.0",
"@repo/package.config": "0.0.0",
"@repo/visual-editing-helpers": "0.7.3",
"@repo/prettier-config": "0.0.0"
"@repo/prettier-config": "0.0.0",
"@repo/visual-editing-helpers": "0.7.4",
"@repo/eslint-config": "0.0.0"
},

@@ -80,0 +80,0 @@ "peerDependencies": {

@@ -27,2 +27,5 @@ import {ComposeIcon} from '@sanity/icons'

// The interval at which we check if existing popups have been closed
export const POPUP_CHECK_INTERVAL = 1000 // ms
declare global {

@@ -29,0 +32,0 @@ const PRESENTATION_ENABLE_LIVE_DRAFT_EVENTS: unknown

import type {Status, StatusEvent} from '@sanity/comlink'
import {useCallback, useMemo, useState} from 'react'
/**
* A hook that manages and returns the connection status of multiple channels
*
* @returns {[string, (event: StatusEvent) => void]} - An array containing the
* current status and a function to update the status based on incoming events
*
* The status can be one of the following:
* - 'connected': If any channel is connected
* - 'connecting': If the first connection is being established
* - 'reconnecting': If a reconnection is in progress
* - 'idle': If no connections have been made yet
*
* The function to update the status takes a `StatusEvent` object which includes
* the channel and the status
*/
export function useStatus(): [string, (event: StatusEvent) => void] {
// State to keep track of the status of each channel
const [statusMap, setStatusMap] = useState(

@@ -9,4 +25,10 @@ new Map<string, {status: Status; hasConnected: boolean}>(),

// Memoized computation of the overall status based on the status of individual channels
const status = useMemo(() => {
const values = Array.from(statusMap.values())
// If any channel is connected, return the `connected` status
if (values.find(({status}) => status === 'connected')) {
return 'connected'
}
// If the initial connection is being established, return `connecting` status
const handshaking = values.filter(({status}) => status === 'handshaking')

@@ -16,8 +38,7 @@ if (handshaking.length) {

}
if (values.find(({status}) => status === 'connected')) {
return 'connected'
}
// If nothing has happened yet, return `idle` status
return 'idle'
}, [statusMap])
// Callback to update the status map based on the received event
const setStatusFromEvent = useCallback((event: StatusEvent) => {

@@ -27,4 +48,6 @@ setStatusMap((prev) => {

if (event.status === 'disconnected') {
// Remove the channel from the map if a disconnect event is received
next.delete(event.channel)
} else {
// Update the status and connection flag for the channel
const hasConnected = next.get(event.channel)?.hasConnected || event.status === 'connected'

@@ -37,3 +60,4 @@ next.set(event.channel, {status: event.status, hasConnected})

// Return the overall status and the function to update the status
return [status, setStatusFromEvent]
}

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 too big to display

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