@sanity/next-loader
Advanced tools
Comparing version 0.0.1-canary.45 to 0.0.1-canary.46
@@ -13,2 +13,3 @@ import { useRouter } from 'next/navigation.js'; | ||
if (now > nextFocusRevalidatedAt && document.visibilityState !== "hidden") { | ||
console.log("refreshing on focus"); | ||
router.refresh(); | ||
@@ -15,0 +16,0 @@ nextFocusRevalidatedAt = now + focusThrottleInterval; |
@@ -9,4 +9,5 @@ import { useRouter } from 'next/navigation.js'; | ||
if (!mounted) { | ||
mount(); | ||
console.log("refreshing on mount"); | ||
router.refresh(); | ||
mount(); | ||
} | ||
@@ -13,0 +14,0 @@ }, [mounted, router]); |
@@ -12,2 +12,3 @@ import { useRouter } from 'next/navigation.js'; | ||
() => { | ||
console.log("refreshing on reconnect"); | ||
router.refresh(); | ||
@@ -14,0 +15,0 @@ }, |
"use client" | ||
import { jsxs, Fragment, jsx } from 'react/jsx-runtime'; | ||
import { jsx, Fragment, jsxs } from 'react/jsx-runtime'; | ||
import { createClient } from '@sanity/client'; | ||
import { revalidateSyncTags } from '@sanity/next-loader/server-actions'; | ||
import dynamic from 'next/dynamic'; | ||
import { useState, useEffect, useMemo } from 'react'; | ||
import { setPerspective, setEnvironment } from '../_chunks-es/context.js'; | ||
import { useState, useEffect, useMemo, useRef } from 'react'; | ||
import { setPerspective, setEnvironment, environment } from '../_chunks-es/context.js'; | ||
@@ -137,3 +137,3 @@ const PresentationComlink = dynamic(() => import('../_chunks-es/PresentationComlink.js'), { ssr: false }); | ||
({ data }) => { | ||
if (data && typeof data === "object" && "domain" in data && data.domain === "sanity/channels" && "from" in data && data.from === "presentation" && "to" in data && data.to === "loaders" && "type" in data && data.type === "handshake/syn") { | ||
if (data && typeof data === "object" && "domain" in data && data.domain === "sanity/channels" && "from" in data && data.from === "presentation") { | ||
setLoadComlink(true); | ||
@@ -147,13 +147,24 @@ controller.abort(); | ||
}, []); | ||
return /* @__PURE__ */ jsxs(Fragment, { children: [ | ||
draftModeEnabled && loadComlink && /* @__PURE__ */ jsx( | ||
PresentationComlink, | ||
{ | ||
draftModeEnabled | ||
} | ||
), | ||
const draftModeEnabledWarnRef = useRef(void 0); | ||
useEffect(() => { | ||
clearTimeout(draftModeEnabledWarnRef.current); | ||
if (draftModeEnabled) return; | ||
return () => { | ||
draftModeEnabledWarnRef.current = setTimeout(() => { | ||
console.warn("Sanity Live: Draft mode was enabled, but is now being disabled", { | ||
environment | ||
}); | ||
}); | ||
}; | ||
}, [draftModeEnabled]); | ||
return /* @__PURE__ */ jsx(Fragment, { children: draftModeEnabled && loadComlink ? /* @__PURE__ */ jsx( | ||
PresentationComlink, | ||
{ | ||
draftModeEnabled | ||
} | ||
) : /* @__PURE__ */ jsxs(Fragment, { children: [ | ||
refreshOnMount && /* @__PURE__ */ jsx(RefreshOnMount, {}), | ||
refreshOnFocus && /* @__PURE__ */ jsx(RefreshOnFocus, {}), | ||
refreshOnReconnect && /* @__PURE__ */ jsx(RefreshOnReconnect, {}) | ||
] }); | ||
] }) }); | ||
} | ||
@@ -160,0 +171,0 @@ SanityLive.displayName = "SanityLive"; |
{ | ||
"name": "@sanity/next-loader", | ||
"version": "0.0.1-canary.45", | ||
"version": "0.0.1-canary.46", | ||
"homepage": "https://github.com/sanity-io/visual-editing/tree/main/packages/next-loader#readme", | ||
@@ -85,3 +85,3 @@ "bugs": { | ||
"use-effect-event": "^1.0.2", | ||
"@sanity/comlink": "0.0.2-canary.59" | ||
"@sanity/comlink": "0.0.2-canary.60" | ||
}, | ||
@@ -98,6 +98,6 @@ "devDependencies": { | ||
"vitest": "^2.1.3", | ||
"@repo/eslint-config": "0.0.0", | ||
"@repo/prettier-config": "0.0.0", | ||
"@repo/package.config": "0.0.0", | ||
"@repo/eslint-config": "0.0.0", | ||
"@repo/visual-editing-helpers": "0.6.21", | ||
"@repo/prettier-config": "0.0.0" | ||
"@repo/visual-editing-helpers": "0.6.21" | ||
}, | ||
@@ -104,0 +104,0 @@ "peerDependencies": { |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
756149
6682
+ Added@sanity/comlink@0.0.2-canary.60(transitive)
- Removed@sanity/comlink@0.0.2-canary.59(transitive)