sanity 5.0.0-next-major.14 → 5.0.0-next-major.20251210134624

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.
Files changed (65) hide show
  1. package/bin/sanity +2 -1
  2. package/lib/_chunks-es/LiveQueries.js +1 -1
  3. package/lib/_chunks-es/LiveQueries.js.map +1 -1
  4. package/lib/_chunks-es/MenuGroup.js +3 -3
  5. package/lib/_chunks-es/MenuGroup.js.map +1 -1
  6. package/lib/_chunks-es/PostMessagePreviewSnapshots.js +2 -2
  7. package/lib/_chunks-es/PostMessagePreviewSnapshots.js.map +1 -1
  8. package/lib/_chunks-es/PresentationToolGrantsCheck.js +54 -54
  9. package/lib/_chunks-es/PresentationToolGrantsCheck.js.map +1 -1
  10. package/lib/_chunks-es/QRCodeSVG.js +1 -1
  11. package/lib/_chunks-es/QRCodeSVG.js.map +1 -1
  12. package/lib/_chunks-es/StructureToolProvider.js +1 -1
  13. package/lib/_chunks-es/StructureToolProvider.js.map +1 -1
  14. package/lib/_chunks-es/VideoPlayer.js +1 -1
  15. package/lib/_chunks-es/VideoPlayer.js.map +1 -1
  16. package/lib/_chunks-es/ViteDevServerStopped.js +6 -6
  17. package/lib/_chunks-es/ViteDevServerStopped.js.map +1 -1
  18. package/lib/_chunks-es/_internal.js +1 -1
  19. package/lib/_chunks-es/_internal.js.map +1 -1
  20. package/lib/_chunks-es/deployApiAction.js +1 -1
  21. package/lib/_chunks-es/deployApiAction.js.map +1 -1
  22. package/lib/_chunks-es/execScript.js +2 -1
  23. package/lib/_chunks-es/execScript.js.map +1 -1
  24. package/lib/_chunks-es/exportAssetsAction.js +1 -1
  25. package/lib/_chunks-es/exportAssetsAction.js.map +1 -1
  26. package/lib/_chunks-es/extractAction.js +2 -1
  27. package/lib/_chunks-es/extractAction.js.map +1 -1
  28. package/lib/_chunks-es/extractManifestAction.js +2 -1
  29. package/lib/_chunks-es/extractManifestAction.js.map +1 -1
  30. package/lib/_chunks-es/generate-help-url.esm.js +1 -1
  31. package/lib/_chunks-es/generate-help-url.esm.js.map +1 -1
  32. package/lib/_chunks-es/getGraphQLAPIs.js +2 -1
  33. package/lib/_chunks-es/getGraphQLAPIs.js.map +1 -1
  34. package/lib/_chunks-es/helpers.js +2 -1
  35. package/lib/_chunks-es/helpers.js.map +1 -1
  36. package/lib/_chunks-es/index2.js +1 -1
  37. package/lib/_chunks-es/index2.js.map +1 -1
  38. package/lib/_chunks-es/index3.js +8 -8
  39. package/lib/_chunks-es/index3.js.map +1 -1
  40. package/lib/_chunks-es/package.js +1 -1
  41. package/lib/_chunks-es/pane.js +140 -140
  42. package/lib/_chunks-es/pane.js.map +1 -1
  43. package/lib/_chunks-es/presentation.js +4 -4
  44. package/lib/_chunks-es/presentation.js.map +1 -1
  45. package/lib/_chunks-es/previewServer.js +2 -1
  46. package/lib/_chunks-es/previewServer.js.map +1 -1
  47. package/lib/_chunks-es/runtime.js +14 -13
  48. package/lib/_chunks-es/runtime.js.map +1 -1
  49. package/lib/_chunks-es/validateAction.js +2 -1
  50. package/lib/_chunks-es/validateAction.js.map +1 -1
  51. package/lib/_chunks-es/validateAction2.js +2 -1
  52. package/lib/_chunks-es/validateAction2.js.map +1 -1
  53. package/lib/_chunks-es/version.js +1 -1
  54. package/lib/_internal/cli/threads/validateDocuments.cjs +1 -1
  55. package/lib/_internal/cli/threads/validateDocuments.cjs.map +1 -1
  56. package/lib/_singletons.d.ts +82 -2
  57. package/lib/_singletons.js +6 -2
  58. package/lib/_singletons.js.map +1 -1
  59. package/lib/desk.d.ts +28 -2
  60. package/lib/index.d.ts +30 -1
  61. package/lib/index.js +3739 -3306
  62. package/lib/index.js.map +1 -1
  63. package/lib/presentation.d.ts +14 -1
  64. package/lib/structure.d.ts +14 -1
  65. package/package.json +34 -34
@@ -166,7 +166,7 @@ function LocationsBanner(props) {
166
166
  if (!resolvers || status === "empty")
167
167
  return null;
168
168
  let t3;
169
- $[12] === Symbol.for("react.memo_cache_sentinel") ? (t3 = {
169
+ $[12] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t3 = {
170
170
  margin: -1
171
171
  }, $[12] = t3) : t3 = $[12];
172
172
  let t4;
@@ -248,7 +248,7 @@ function LocationItem(props) {
248
248
  $[10] !== isCurrentTool || $[11] !== presentationLinkProps ? (t3 = isCurrentTool ? {} : presentationLinkProps, $[10] = isCurrentTool, $[11] = presentationLinkProps, $[12] = t3) : t3 = $[12];
249
249
  const t4 = isCurrentTool ? handleCurrentToolClick : presentationLinkProps.onClick;
250
250
  let t5;
251
- $[13] === Symbol.for("react.memo_cache_sentinel") ? (t5 = /* @__PURE__ */ jsx(Box, { flex: "none", children: /* @__PURE__ */ jsx(Text, { size: 1, children: /* @__PURE__ */ jsx(DesktopIcon, {}) }) }), $[13] = t5) : t5 = $[13];
251
+ $[13] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t5 = /* @__PURE__ */ jsx(Box, { flex: "none", children: /* @__PURE__ */ jsx(Text, { size: 1, children: /* @__PURE__ */ jsx(DesktopIcon, {}) }) }), $[13] = t5) : t5 = $[13];
252
252
  let t6;
253
253
  $[14] !== node.title ? (t6 = /* @__PURE__ */ jsx(Text, { size: 1, weight: "medium", children: node.title }), $[14] = node.title, $[15] = t6) : t6 = $[15];
254
254
  let t7;
@@ -425,7 +425,7 @@ function getIntentState(intent, params, routerState, payload) {
425
425
  function PresentationSpinner() {
426
426
  const $ = c(1);
427
427
  let t0;
428
- return $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsx(Flex, { align: "center", direction: "column", height: "fill", justify: "center", style: {
428
+ return $[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsx(Flex, { align: "center", direction: "column", height: "fill", justify: "center", style: {
429
429
  width: "100%"
430
430
  }, children: /* @__PURE__ */ jsx(Spinner, {}) }), $[0] = t0) : t0 = $[0], t0;
431
431
  }
@@ -454,7 +454,7 @@ const presentationTool = definePlugin((options) => {
454
454
  let t22;
455
455
  $[4] !== documentId || $[5] !== documentVersion || $[6] !== props.schemaType ? (t22 = hasLocationsResolver && documentId && /* @__PURE__ */ jsx(PresentationDocumentHeader, { documentId, version: documentVersion, options, schemaType: props.schemaType }), $[4] = documentId, $[5] = documentVersion, $[6] = props.schemaType, $[7] = t22) : t22 = $[7];
456
456
  let t3;
457
- $[8] === Symbol.for("react.memo_cache_sentinel") ? (t3 = /* @__PURE__ */ jsx(PresentationSpinner, {}), $[8] = t3) : t3 = $[8];
457
+ $[8] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t3 = /* @__PURE__ */ jsx(PresentationSpinner, {}), $[8] = t3) : t3 = $[8];
458
458
  let t4;
459
459
  $[9] !== props ? (t4 = props.renderDefault(props), $[9] = props, $[10] = t4) : t4 = $[10];
460
460
  let t5;
@@ -1 +1 @@
1
- {"version":3,"file":"presentation.js","sources":["../../src/presentation/overlays/useSharedState.ts","../../src/presentation/constants.ts","../../src/presentation/i18n/index.ts","../../src/presentation/usePresentationPerspectiveStack.ts","../../src/presentation/useDocumentLocations.ts","../../src/presentation/usePresentationTool.ts","../../src/presentation/document/useCurrentPresentationToolName.ts","../../src/presentation/document/LocationsBanner.tsx","../../src/presentation/document/PresentationDocumentHeader.tsx","../../src/presentation/document/PresentationDocumentProvider.tsx","../../src/presentation/fieldActions/openInStructure.ts","../../src/presentation/getIntentState.ts","../../src/presentation/PresentationSpinner.tsx","../../src/presentation/router.ts","../../src/presentation/plugin.tsx","../../src/presentation/usePresentationNavigate.ts","../../src/presentation/usePresentationParams.ts"],"sourcesContent":["import {type Serializable} from '@sanity/presentation-comlink'\nimport {useContext, useEffect} from 'react'\nimport {PresentationSharedStateContext} from 'sanity/_singletons'\n\n/** @public */\nexport const useSharedState = (key: string, value: Serializable): undefined => {\n const context = useContext(PresentationSharedStateContext)\n\n if (!context) {\n throw new Error('Preview Snapshots context is missing')\n }\n\n const {setValue} = context\n\n useEffect(() => {\n setValue(key, value)\n }, [key, value, setValue])\n\n return undefined\n}\n","import {ComposeIcon} from '@sanity/icons'\nimport {apiVersion} from '@sanity/preview-url-secret/constants'\n\nexport const DEFAULT_TOOL_ICON = ComposeIcon\nexport const DEFAULT_TOOL_NAME = 'presentation'\nexport const DEFAULT_TOOL_TITLE = 'Presentation'\n\nexport const EDIT_INTENT_MODE = 'presentation'\n\n// How long we wait until an iframe is loaded until we consider it to be slow and possibly failed\nexport const MAX_TIME_TO_OVERLAYS_CONNECTION = 3_000 // ms\n\n// The API version to use when using `@sanity/client`\nexport const API_VERSION = apiVersion\n\n// Heartbeats shouldn't fire on intervals that are so short it causes performance issues\nexport const MIN_LOADER_QUERY_LISTEN_HEARTBEAT_INTERVAL = 1000 // ms\n\n// How often the list over loader queries should be garbage collected\nexport const LOADER_QUERY_GC_INTERVAL = 30_000 // ms\n\n// The interval at which we check if existing popups have been closed\nexport const POPUP_CHECK_INTERVAL = 1000 // ms\n","import {defineLocaleResourceBundle} from 'sanity'\n\n/**\n * The locale namespace for the presentation tool\n *\n * @public\n */\nexport const presentationLocaleNamespace = 'presentation' as const\n\n/**\n * The default locale bundle for the presentation tool, which is US English.\n *\n * @internal\n */\nexport const presentationUsEnglishLocaleBundle = defineLocaleResourceBundle({\n locale: 'en-US',\n namespace: presentationLocaleNamespace,\n resources: () => import('./resources'),\n})\n","import {useContext} from 'react'\nimport {usePerspective} from 'sanity'\nimport {PaneRouterContext} from 'sanity/structure'\n\nexport function usePresentationPerspectiveStack() {\n const {perspectiveStack} = usePerspective()\n const paneRouter = useContext(PaneRouterContext)\n if (!paneRouter) {\n throw new Error('PaneRouter not found')\n }\n const scheduledDraftPerspective = paneRouter.params?.scheduledDraft\n\n if (scheduledDraftPerspective) {\n return [scheduledDraftPerspective, ...perspectiveStack]\n }\n return perspectiveStack\n}\n","import {useEffect, useMemo, useState} from 'react'\nimport {isObservable, map, of} from 'rxjs'\nimport {\n type ObjectSchemaType,\n type PreviewableType,\n useDocumentPreviewStore,\n useDocumentStore,\n} from 'sanity'\n\nimport {\n type DocumentLocationResolver,\n type DocumentLocationResolvers,\n type DocumentLocationsState,\n type DocumentLocationsStatus,\n} from './types'\nimport {usePresentationPerspectiveStack} from './usePresentationPerspectiveStack'\n\nconst INITIAL_STATE: DocumentLocationsState = {locations: []}\n\nexport function useDocumentLocations(props: {\n id: string\n version: string | undefined\n resolvers?: DocumentLocationResolver | DocumentLocationResolvers\n type: ObjectSchemaType\n}): {\n state: DocumentLocationsState\n status: DocumentLocationsStatus\n} {\n const {id, resolvers, type, version} = props\n const documentStore = useDocumentStore()\n const documentPreviewStore = useDocumentPreviewStore()\n\n const perspectiveStack = usePresentationPerspectiveStack()\n const [locationsState, setLocationsState] = useState<DocumentLocationsState>(INITIAL_STATE)\n\n const resolver = resolvers && (typeof resolvers === 'function' ? resolvers : resolvers[type.name])\n\n const [locationsStatus, setLocationsStatus] = useState<DocumentLocationsStatus>(\n resolver ? 'resolving' : 'empty',\n )\n\n const result = useMemo(() => {\n if (!resolver) return undefined\n\n // Original/advanced resolver which requires explicit use of Observables\n if (typeof resolver === 'function') {\n const params = {id, type: type.name, version, perspectiveStack}\n const context = {documentStore}\n const _result = resolver(params, context)\n return isObservable(_result) ? _result : of(_result)\n }\n\n // Simplified resolver pattern which abstracts away Observable logic\n if ('select' in resolver && 'resolve' in resolver) {\n const doc = {_type: 'reference', _ref: id}\n // Override the preview selection in the schema type to use the user\n // defined selection defined by the resolver\n const _type = {...type, preview: {select: resolver.select}} satisfies PreviewableType\n const options = {perspective: perspectiveStack}\n return documentPreviewStore\n .observeForPreview(doc, _type, options)\n .pipe(map((preview) => resolver.resolve(preview.snapshot || null)))\n }\n\n // Resolver is explicitly provided state\n return of(resolver)\n }, [documentStore, documentPreviewStore, id, resolver, type, version, perspectiveStack])\n\n useEffect(() => {\n const sub = result?.subscribe((state) => {\n setLocationsState(state || INITIAL_STATE)\n setLocationsStatus(state ? 'resolved' : 'empty')\n })\n\n return () => sub?.unsubscribe()\n }, [result])\n\n return {\n state: locationsState,\n status: locationsStatus,\n }\n}\n","import {useContext} from 'react'\nimport {PresentationContext} from 'sanity/_singletons'\n\nimport {type PresentationContextValue} from './types'\n\nexport function usePresentationTool(throwOnMissingContext?: true): PresentationContextValue\nexport function usePresentationTool(throwOnMissingContext: false): PresentationContextValue | null\nexport function usePresentationTool(throwOnMissingContext = true): PresentationContextValue | null {\n const presentation = useContext(PresentationContext)\n\n if (throwOnMissingContext && !presentation) {\n throw new Error('Presentation context is missing')\n }\n\n return presentation\n}\n","import {usePresentationTool} from '../usePresentationTool'\n\nexport function useCurrentPresentationToolName(): string | undefined {\n return usePresentationTool(false)?.name ?? undefined\n}\n","import {\n ChevronRightIcon,\n DesktopIcon,\n ErrorOutlineIcon,\n InfoOutlineIcon,\n WarningOutlineIcon,\n} from '@sanity/icons'\nimport {Box, Card, Flex, Spinner, Stack, Text} from '@sanity/ui'\nimport {type ComponentType, type ReactNode, useCallback, useContext, useState} from 'react'\nimport {type ObjectSchemaType, useTranslation} from 'sanity'\nimport {PresentationContext} from 'sanity/_singletons'\nimport {useIntentLink} from 'sanity/router'\nimport {usePaneRouter} from 'sanity/structure'\n\nimport {DEFAULT_TOOL_NAME, DEFAULT_TOOL_TITLE} from '../constants'\nimport {presentationLocaleNamespace} from '../i18n'\nimport {\n type DocumentLocation,\n type DocumentLocationResolver,\n type DocumentLocationResolvers,\n type PresentationPluginOptions,\n} from '../types'\nimport {useDocumentLocations} from '../useDocumentLocations'\nimport {useCurrentPresentationToolName} from './useCurrentPresentationToolName'\n\nconst TONE_ICONS: Record<'positive' | 'caution' | 'critical', ComponentType> = {\n positive: InfoOutlineIcon,\n caution: WarningOutlineIcon,\n critical: ErrorOutlineIcon,\n}\n\nexport function LocationsBanner(props: {\n documentId: string\n options: PresentationPluginOptions\n resolvers?: DocumentLocationResolver | DocumentLocationResolvers\n schemaType: ObjectSchemaType\n showPresentationTitle: boolean\n version: string | undefined\n}): ReactNode {\n const {documentId, options, resolvers, schemaType, showPresentationTitle, version} = props\n\n const {state, status} = useDocumentLocations({\n id: documentId,\n version,\n resolvers,\n type: schemaType,\n })\n\n const isResolving = status === 'resolving'\n\n const {locations, message, tone} = state\n const locationsCount = locations?.length || 0\n\n const {t} = useTranslation(presentationLocaleNamespace)\n const presentation = useContext(PresentationContext)\n const presentationName = presentation?.name\n const [expanded, setExpanded] = useState(false)\n const toggle = useCallback(() => {\n if (!locationsCount) return\n setExpanded((v) => !v)\n }, [locationsCount])\n\n const title = isResolving\n ? t('locations-banner.resolving.text')\n : message || t('locations-banner.locations-count', {count: locationsCount})\n\n const ToneIcon = tone ? TONE_ICONS[tone] : undefined\n\n if (!resolvers || status === 'empty') return null\n return (\n <Card padding={1} radius={2} border tone={tone}>\n <div style={{margin: -1}}>\n {!locations && (\n <Flex align=\"flex-start\" gap={3} padding={3}>\n {tone && ToneIcon && (\n <Box flex=\"none\">\n <Text size={1}>\n <ToneIcon />\n </Text>\n </Box>\n )}\n <Box flex={1}>\n <Text size={1} weight=\"medium\">\n {showPresentationTitle && <>{options.title || DEFAULT_TOOL_TITLE} &middot; </>}\n {title}\n </Text>\n </Box>\n </Flex>\n )}\n {locations && (\n <>\n <Card\n as={locationsCount ? 'button' : undefined}\n onClick={toggle}\n padding={3}\n radius={1}\n tone=\"inherit\"\n >\n <Flex gap={3}>\n <Box flex=\"none\">\n {isResolving ? (\n <Spinner size={1} />\n ) : (\n <Text size={1}>\n {locationsCount === 0 ? (\n <InfoOutlineIcon />\n ) : (\n <ChevronRightIcon\n style={{\n transform: `rotate(${expanded ? '90deg' : 0})`,\n transition: 'transform 100ms ease-in-out',\n }}\n />\n )}\n </Text>\n )}\n </Box>\n <Box flex={1}>\n <Text size={1} weight=\"medium\">\n {showPresentationTitle && <>{options.title || DEFAULT_TOOL_TITLE} &middot; </>}\n {title}\n </Text>\n </Box>\n </Flex>\n </Card>\n <Stack hidden={!expanded} marginTop={1} space={1}>\n {locations.map((l) => {\n let active = false\n if (\n (options.name || DEFAULT_TOOL_NAME) === presentationName &&\n presentation?.params.preview\n ) {\n active = areUrlsMatching(presentation.params.preview, l.href)\n }\n\n return (\n <LocationItem\n key={l.href}\n active={active}\n documentId={documentId}\n documentType={schemaType.name}\n node={l}\n toolName={options.name || DEFAULT_TOOL_NAME}\n />\n )\n })}\n </Stack>\n </>\n )}\n </div>\n </Card>\n )\n}\n\nfunction LocationItem(props: {\n active: boolean\n documentId: string\n documentType: string\n node: DocumentLocation\n toolName: string\n}) {\n const {documentId, documentType, node, active, toolName} = props\n const presentation = useContext(PresentationContext)\n const currentPresentationToolName = useCurrentPresentationToolName()\n const isCurrentTool = toolName === currentPresentationToolName\n const navigate = presentation?.navigate\n const {params: paneParams} = usePaneRouter()\n\n const presentationLinkProps = useIntentLink({\n intent: 'edit',\n params: {\n id: documentId,\n type: documentType,\n mode: 'presentation',\n presentation: toolName,\n ...presentation?.structureParams,\n ...paneParams,\n preview: node.href,\n },\n })\n\n const handleCurrentToolClick = useCallback(() => {\n navigate?.({params: {preview: node.href}})\n }, [node.href, navigate])\n\n return (\n <Card\n key={node.href}\n {...(isCurrentTool ? {} : presentationLinkProps)}\n as=\"a\"\n onClick={isCurrentTool ? handleCurrentToolClick : presentationLinkProps.onClick}\n padding={3}\n radius={1}\n pressed={active}\n tone=\"inherit\"\n >\n <Flex gap={3}>\n <Box flex=\"none\">\n <Text size={1}>\n <DesktopIcon />\n </Text>\n </Box>\n <Stack flex={1} space={2}>\n <Text size={1} weight=\"medium\">\n {node.title}\n </Text>\n <Text muted size={1} textOverflow=\"ellipsis\">\n {node.href}\n </Text>\n </Stack>\n </Flex>\n </Card>\n )\n}\n\n/**\n * Compares two URLs to determine if they match based on origin, pathname, and search parameters\n * The previewUrl should have all the search parameters that are in the locationUrl\n */\nfunction areUrlsMatching(previewUrlString: string, locationUrlString: string): boolean {\n try {\n const previewUrl = new URL(previewUrlString, location.origin)\n const locationUrl = new URL(locationUrlString, previewUrl.origin)\n\n // First compare origin and pathname\n if (previewUrl.origin !== locationUrl.origin || previewUrl.pathname !== locationUrl.pathname) {\n return false\n }\n\n // Then check search params\n // All search params in locationUrl must exist with the same values in previewUrl\n const locationParams = new URLSearchParams(locationUrl.search)\n const previewParams = new URLSearchParams(previewUrl.search)\n\n for (const [key, value] of locationParams.entries()) {\n if (previewParams.get(key) !== value) {\n return false\n }\n }\n\n return true\n } catch {\n // If URL parsing fails, URLs don't match\n return false\n }\n}\n","import {rem} from '@sanity/ui'\n// eslint-disable-next-line camelcase\nimport {getTheme_v2} from '@sanity/ui/theme'\nimport {type ReactNode, useContext} from 'react'\nimport {type ObjectSchemaType, type PublishedId} from 'sanity'\nimport {PresentationDocumentContext} from 'sanity/_singletons'\nimport {css, styled} from 'styled-components'\n\nimport {type PresentationPluginOptions} from '../types'\nimport {LocationsBanner} from './LocationsBanner'\n\nconst LocationStack = styled.div((props) => {\n const theme = getTheme_v2(props.theme)\n return css`\n display: flex;\n flex-direction: column;\n gap: ${rem(theme.space[2])};\n min-height: ${rem(42)};\n margin-bottom: ${rem(theme.space[5])};\n\n &:empty {\n display: none;\n }\n `\n})\n\nexport function PresentationDocumentHeader(props: {\n documentId: PublishedId\n version: string | undefined\n options: PresentationPluginOptions\n schemaType: ObjectSchemaType\n}): ReactNode {\n const {documentId, options, schemaType, version} = props\n const context = useContext(PresentationDocumentContext)\n\n const contextOptions = context?.options || []\n const resolvers = contextOptions.map((o) => o.resolve?.locations || o.locate)\n const hasResolvers = resolvers.some(Boolean)\n\n if ((context && context.options[0] !== options) || !hasResolvers) {\n return null\n }\n\n return (\n <LocationStack>\n {contextOptions.map((_options, idx) => (\n <LocationsBanner\n // oxlint-disable-next-line no-array-index-key\n key={idx}\n documentId={documentId}\n options={_options}\n resolvers={resolvers[idx]}\n schemaType={schemaType}\n showPresentationTitle={contextOptions.length > 1}\n version={version}\n />\n ))}\n </LocationStack>\n )\n}\n","import {type ReactNode, useCallback, useContext, useLayoutEffect, useMemo, useState} from 'react'\nimport {PresentationDocumentContext} from 'sanity/_singletons'\nimport {useEffectEvent} from 'use-effect-event'\n\nimport {type PresentationPluginOptions} from '../types'\nimport {type PresentationDocumentContextValue} from './types'\n\n/** @internal */\nexport function PresentationDocumentProvider(props: {\n children?: ReactNode\n options: PresentationPluginOptions\n}): React.JSX.Element {\n const {children, options} = props\n const parent = useContext(PresentationDocumentContext)\n const parentRegister = parent?.register\n\n const [optionsArray, setOptionsArray] = useState<PresentationPluginOptions[]>(() => [])\n\n const register = useCallback(\n // eslint-disable-next-line @typescript-eslint/no-shadow\n (options: PresentationPluginOptions) => {\n if (parentRegister) {\n return parentRegister(options)\n }\n\n setOptionsArray((prev) => [options].concat(prev))\n\n return () => {\n setOptionsArray((prev) => prev.filter((o) => o !== options))\n }\n },\n [parentRegister],\n )\n\n const context: PresentationDocumentContextValue = useMemo(\n () => ({\n options: parent?.options || optionsArray,\n register,\n }),\n [optionsArray, parent, register],\n )\n\n // eslint-disable-next-line @typescript-eslint/no-shadow\n const registerEffectEvent = useEffectEvent((options: PresentationPluginOptions) =>\n register(options),\n )\n useLayoutEffect(() => registerEffectEvent(options), [options])\n\n return (\n <PresentationDocumentContext.Provider value={context}>\n {children}\n </PresentationDocumentContext.Provider>\n )\n}\n","import {MasterDetailIcon} from '@sanity/icons'\nimport {useContext, useMemo} from 'react'\nimport {\n defineDocumentFieldAction,\n type DocumentFieldActionGroup,\n type DocumentFieldActionItem,\n type DocumentFieldActionProps,\n isRecord,\n pathToString,\n type Tool,\n useWorkspace,\n} from 'sanity'\nimport {PresentationContext} from 'sanity/_singletons'\nimport {useRouter} from 'sanity/router'\n\nimport {DEFAULT_TOOL_NAME} from '../constants'\n\nfunction useOpenInStructureAction(\n props: DocumentFieldActionProps,\n): DocumentFieldActionItem | DocumentFieldActionGroup {\n const {documentId, documentType, path} = props\n const workspace = useWorkspace()\n const {navigateIntent} = useRouter()\n const presentation = useContext(PresentationContext)\n\n const defaultStructureTool = useMemo(\n () =>\n findStructureTool(\n workspace.tools,\n documentId,\n documentType,\n presentation?.name || DEFAULT_TOOL_NAME,\n ),\n [documentId, documentType, workspace.tools, presentation],\n )\n\n return {\n type: 'action',\n hidden: !presentation || path.length > 0 || !defaultStructureTool,\n icon: defaultStructureTool?.icon || MasterDetailIcon,\n title: `Open in ${defaultStructureTool?.title || 'Structure'}`,\n onAction() {\n navigateIntent('edit', {\n id: documentId,\n type: documentType,\n mode: 'structure',\n path: pathToString(path),\n })\n },\n renderAsButton: true,\n }\n}\n\nexport const openInStructure = defineDocumentFieldAction({\n name: 'presentation/openInStructure',\n useAction: useOpenInStructureAction,\n})\n\nfunction findStructureTool(\n tools: Tool[],\n documentId: string,\n documentType: string,\n presentationToolName?: string,\n): Tool | undefined {\n const results = tools\n .filter((t) => t.name !== presentationToolName)\n .map((t) => {\n const match = t.canHandleIntent?.(\n 'edit',\n {\n id: documentId,\n type: documentType,\n mode: 'structure',\n },\n {},\n )\n\n return {tool: t, match}\n })\n\n const modeMatches = results.filter((t) => isRecord(t.match) && t.match.mode)\n\n if (modeMatches.length > 0) {\n return modeMatches[0].tool\n }\n\n const matches = results.filter((t) => t.match)\n\n return matches[0]?.tool\n}\n","import {uuid} from '@sanity/uuid'\nimport {getPublishedId} from 'sanity'\nimport {encodeJsonParams, type RouterState, type SearchParam} from 'sanity/router'\n\nimport {type PresentationSearchParams, type PresentationStateParams} from './types'\n\nconst preservedSearchParamKeys: Array<keyof PresentationSearchParams> = ['preview', 'viewport']\n\n/**\n * @internal\n */\nexport function getIntentState(\n intent: string,\n params: Record<string, string>,\n routerState: RouterState | undefined,\n payload: unknown,\n):\n | (PresentationStateParams & {_searchParams: SearchParam[]})\n | {intent: string; params: Record<string, string>; payload: unknown} {\n // oxlint-disable-next-line no-unused-vars\n const {id, mode, path, presentation, type, ...searchParams} = params\n\n const preservedSearchParams = (routerState?._searchParams || [])\n // @todo Casting https://github.com/microsoft/TypeScript/issues/14520\n .filter(([key]) => preservedSearchParamKeys.includes(key as keyof PresentationSearchParams))\n .reduce((acc, [key, value]) => ({...acc, [key]: value}), {} as Record<string, string>)\n\n const _searchParams = {\n ...preservedSearchParams,\n ...searchParams,\n }\n\n if (intent === 'edit' && id) {\n _searchParams.preview =\n _searchParams.preview || new URLSearchParams(window.location.search).get('preview') || '/'\n return {\n type: type || '*',\n id: getPublishedId(id),\n path,\n _searchParams: Object.entries(_searchParams),\n }\n }\n\n if (intent === 'create') {\n _searchParams.preview =\n _searchParams.preview || new URLSearchParams(window.location.search).get('preview') || '/'\n\n if (payload && typeof payload === 'object') {\n _searchParams.templateParams = encodeJsonParams(payload as Record<string, unknown>)\n }\n\n return {\n type: type || '*',\n id: id || uuid(),\n _searchParams: Object.entries(_searchParams),\n }\n }\n return {intent, params, payload}\n}\n","import {Flex, Spinner} from '@sanity/ui'\n\nexport function PresentationSpinner(): React.JSX.Element {\n return (\n <Flex align=\"center\" direction=\"column\" height=\"fill\" justify=\"center\" style={{width: '100%'}}>\n <Spinner />\n </Flex>\n )\n}\n","import {route} from 'sanity/router'\n\n// eslint-disable-next-line camelcase\nexport const router = route.create('/', {__unsafe_disableScopedSearchParams: true}, [\n route.intents('/intent'),\n route.create(':type', [route.create(':id', [route.create(':path')])]),\n])\n","import {type SanityDocument} from '@sanity/client'\nimport {lazy, Suspense} from 'react'\nimport {\n definePlugin,\n getPublishedId,\n getVersionFromId,\n type InputProps,\n isDocumentSchemaType,\n} from 'sanity'\n\nimport {DEFAULT_TOOL_ICON, DEFAULT_TOOL_NAME, EDIT_INTENT_MODE} from './constants'\nimport {PresentationDocumentHeader} from './document/PresentationDocumentHeader'\nimport {PresentationDocumentProvider} from './document/PresentationDocumentProvider'\nimport {openInStructure} from './fieldActions/openInStructure'\nimport {getIntentState} from './getIntentState'\nimport {presentationUsEnglishLocaleBundle} from './i18n'\nimport {PresentationSpinner} from './PresentationSpinner'\nimport {router} from './router'\nimport {\n type DocumentLocationResolverObject,\n type DocumentLocationsState,\n type DocumentResolver,\n type PresentationPluginOptions,\n} from './types'\n\nconst PresentationTool = lazy(() => import('./PresentationToolGrantsCheck'))\nconst BroadcastDisplayedDocument = lazy(() => import('./loader/BroadcastDisplayedDocument'))\n\n/**\n * Define locations for a given document type.\n * This function doesn't do anything itself, it is used to provide type information.\n * @param resolver - resolver that return locations for a document.\n * @public\n */\nexport function defineLocations<K extends string>(\n resolver: DocumentLocationResolverObject<K> | DocumentLocationsState,\n): typeof resolver {\n return resolver\n}\n\n/**\n * Define documents for a given location.\n * This function doesn't do anything itself, it is used to provide type information.\n * @param resolvers - resolvers that return documents.\n * @public\n */\nexport function defineDocuments(resolvers: DocumentResolver[]): typeof resolvers {\n return resolvers\n}\n\n/** @public */\nexport const presentationTool = definePlugin<PresentationPluginOptions>((options) => {\n const toolName = options.name || DEFAULT_TOOL_NAME\n\n if ('locate' in options) {\n console.warn('Presentation’s `locate` option is deprecated. Use `resolve.locations` instead.')\n }\n\n const hasLocationsResolver = !!(options.resolve?.locations || options.locate)\n\n function PresentationDocumentInput(props: InputProps) {\n const value = props.value as SanityDocument\n const documentId = value?._id ? getPublishedId(value?._id) : undefined\n const documentVersion = value?._id ? getVersionFromId(value._id) : undefined\n if (isDocumentSchemaType(props.schemaType)) {\n return (\n <PresentationDocumentProvider options={options}>\n {hasLocationsResolver && documentId && (\n <PresentationDocumentHeader\n documentId={documentId}\n version={documentVersion}\n options={options}\n schemaType={props.schemaType}\n />\n )}\n <Suspense fallback={<PresentationSpinner />}>{props.renderDefault(props)}</Suspense>\n <Suspense key=\"broadcast-displayed-document\">\n <BroadcastDisplayedDocument key={documentId} value={value} />\n </Suspense>\n </PresentationDocumentProvider>\n )\n }\n\n return props.renderDefault(props)\n }\n\n function canHandleCreateIntent(params: Record<string, unknown>) {\n // We can't handle create intents without a `type` parameter\n if (!('type' in params)) {\n return false\n }\n\n if ('presentation' in params && params.presentation !== toolName) {\n return false\n }\n\n return 'template' in params ? {template: true} : true\n }\n\n function canHandleEditIntent(params: Record<string, unknown>) {\n // We can't handle edit intents without `type` or `id` parameters\n if (!('type' in params) || !('id' in params)) {\n return false\n }\n\n if ('presentation' in params && params.presentation !== toolName) {\n return false\n }\n\n return 'mode' in params ? {mode: params.mode === EDIT_INTENT_MODE} : true\n }\n\n return {\n i18n: {\n bundles: [presentationUsEnglishLocaleBundle],\n },\n document: {\n unstable_fieldActions: (prev) => {\n return [\n ...prev.filter((a) => a.name !== openInStructure.name), // prevent duplication\n openInStructure,\n ]\n },\n },\n\n form: {\n components: {\n input: PresentationDocumentInput,\n },\n },\n\n tools: [\n {\n icon: options.icon || DEFAULT_TOOL_ICON,\n name: toolName,\n title: options.title,\n component: PresentationTool,\n options,\n canHandleIntent(intent, params) {\n if (intent === 'create') return canHandleCreateIntent(params)\n if (intent === 'edit') return canHandleEditIntent(params)\n return false\n },\n getIntentState,\n router,\n __internalApplicationType: 'sanity/presentation',\n },\n ],\n }\n})\n","import {useContext} from 'react'\nimport {PresentationNavigateContext} from 'sanity/_singletons'\n\nimport {type PresentationNavigateContextValue} from './types'\n\n/** @public */\nexport function usePresentationNavigate(): PresentationNavigateContextValue {\n const navigate = useContext(PresentationNavigateContext)\n\n if (!navigate) {\n throw new Error('Presentation navigate context is missing')\n }\n\n return navigate\n}\n\nexport type {PresentationNavigateContextValue}\n","import {useContext} from 'react'\nimport {PresentationParamsContext} from 'sanity/_singletons'\n\nimport {type PresentationParamsContextValue} from './types'\n\n/** @public */\nexport function usePresentationParams(throwOnMissingContext?: true): PresentationParamsContextValue\n/** @public */\nexport function usePresentationParams(\n throwOnMissingContext: false,\n): PresentationParamsContextValue | null\n/** @public */\nexport function usePresentationParams(\n throwOnMissingContext = true,\n): PresentationParamsContextValue | null {\n const params = useContext(PresentationParamsContext)\n\n if (throwOnMissingContext && !params) {\n throw new Error('Presentation params context is missing')\n }\n\n return params\n}\n"],"names":["useSharedState","key","value","$","_c","context","useContext","PresentationSharedStateContext","Error","setValue","t0","t1","useEffect","DEFAULT_TOOL_ICON","ComposeIcon","DEFAULT_TOOL_NAME","DEFAULT_TOOL_TITLE","EDIT_INTENT_MODE","MAX_TIME_TO_OVERLAYS_CONNECTION","API_VERSION","apiVersion","MIN_LOADER_QUERY_LISTEN_HEARTBEAT_INTERVAL","LOADER_QUERY_GC_INTERVAL","POPUP_CHECK_INTERVAL","presentationLocaleNamespace","presentationUsEnglishLocaleBundle","defineLocaleResourceBundle","locale","namespace","resources","usePresentationPerspectiveStack","perspectiveStack","usePerspective","paneRouter","PaneRouterContext","scheduledDraftPerspective","params","scheduledDraft","INITIAL_STATE","locations","useDocumentLocations","props","id","resolvers","type","version","documentStore","useDocumentStore","documentPreviewStore","useDocumentPreviewStore","locationsState","setLocationsState","useState","resolver","name","locationsStatus","setLocationsStatus","bb0","undefined","_result","isObservable","of","doc","_type","_ref","preview","select","options","perspective","t2","resolve","snapshot","observeForPreview","pipe","map","result","sub","subscribe","state","unsubscribe","t3","status","usePresentationTool","throwOnMissingContext","presentation","PresentationContext","useCurrentPresentationToolName","TONE_ICONS","positive","InfoOutlineIcon","caution","WarningOutlineIcon","critical","ErrorOutlineIcon","LocationsBanner","documentId","schemaType","showPresentationTitle","isResolving","message","tone","locationsCount","length","t","useTranslation","presentationName","expanded","setExpanded","_temp","toggle","count","title","ToneIcon","Symbol","for","margin","t4","t5","transform","transition","l","active","areUrlsMatching","href","t6","t7","v","LocationItem","documentType","node","toolName","currentPresentationToolName","isCurrentTool","navigate","paneParams","usePaneRouter","structureParams","intent","mode","presentationLinkProps","useIntentLink","handleCurrentToolClick","onClick","t8","t9","previewUrlString","locationUrlString","previewUrl","URL","location","origin","locationUrl","pathname","locationParams","URLSearchParams","search","previewParams","entries","get","LocationStack","styled","div","theme","getTheme_v2","css","rem","space","PresentationDocumentHeader","PresentationDocumentContext","contextOptions","some","Boolean","hasResolvers","_options","idx","o","locate","PresentationDocumentProvider","children","parent","parentRegister","register","optionsArray","setOptionsArray","options_0","prev","concat","prev_0","filter","options_1","registerEffectEvent","useEffectEvent","useLayoutEffect","useOpenInStructureAction","path","workspace","useWorkspace","navigateIntent","useRouter","tools","findStructureTool","defaultStructureTool","icon","MasterDetailIcon","hidden","onAction","pathToString","renderAsButton","openInStructure","defineDocumentFieldAction","useAction","presentationToolName","results","match","canHandleIntent","tool","modeMatches","isRecord","preservedSearchParamKeys","getIntentState","routerState","payload","searchParams","_searchParams","includes","reduce","acc","window","getPublishedId","Object","templateParams","encodeJsonParams","uuid","PresentationSpinner","width","router","route","create","__unsafe_disableScopedSearchParams","intents","PresentationTool","lazy","BroadcastDisplayedDocument","defineLocations","defineDocuments","presentationTool","definePlugin","console","warn","hasLocationsResolver","PresentationDocumentInput","_id","getVersionFromId","documentVersion","isDocumentSchemaType","renderDefault","canHandleCreateIntent","template","canHandleEditIntent","i18n","bundles","document","unstable_fieldActions","a","form","components","input","component","__internalApplicationType","usePresentationNavigate","PresentationNavigateContext","usePresentationParams","PresentationParamsContext"],"mappings":";;;;;;;;;;;;;;;AAKO,MAAMA,iBAAiBA,CAAAC,KAAAC,UAAA;AAAA,QAAAC,IAAAC,EAAA,CAAA,GAC5BC,UAAgBC,WAAWC,8BAA8B;AAEzD,MAAI,CAACF;AACH,UAAM,IAAIG,MAAM,sCAAsC;AAGxD,QAAA;AAAA,IAAAC;AAAAA,EAAAA,IAAmBJ;AAAO,MAAAK,IAAAC;AAAAR,IAAA,CAAA,MAAAF,OAAAE,SAAAM,YAAAN,EAAA,CAAA,MAAAD,SAEhBQ,KAAAA,MAAA;AACRD,aAASR,KAAKC,KAAK;AAAA,EAAC,GACnBS,MAACV,KAAKC,OAAOO,QAAQ,GAACN,OAAAF,KAAAE,OAAAM,UAAAN,OAAAD,OAAAC,OAAAO,IAAAP,OAAAQ,OAAAD,KAAAP,EAAA,CAAA,GAAAQ,KAAAR,EAAA,CAAA,IAFzBS,UAAUF,IAEPC,EAAsB;AAAC,GCbfE,oBAAoBC,aACpBC,oBAAoB,gBACpBC,qBAAqB,gBAErBC,mBAAmB,gBAGnBC,kCAAkC,KAGlCC,cAAcC,YAGdC,6CAA6C,K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AAA;AACL,QAAAyE,wBAAAzE,OAAAgD,SAAA,KAAAhD,IAEA0B,SAAe9B,WAAW0Q,yBAAyB;AAEnD,MAAI7L,yBAAA,CAA0B/C;AAC5B,UAAM,IAAI5B,MAAM,wCAAwC;AACzD,SAEM4B;AAAM;"}
1
+ {"version":3,"file":"presentation.js","sources":["../../src/presentation/overlays/useSharedState.ts","../../src/presentation/constants.ts","../../src/presentation/i18n/index.ts","../../src/presentation/usePresentationPerspectiveStack.ts","../../src/presentation/useDocumentLocations.ts","../../src/presentation/usePresentationTool.ts","../../src/presentation/document/useCurrentPresentationToolName.ts","../../src/presentation/document/LocationsBanner.tsx","../../src/presentation/document/PresentationDocumentHeader.tsx","../../src/presentation/document/PresentationDocumentProvider.tsx","../../src/presentation/fieldActions/openInStructure.ts","../../src/presentation/getIntentState.ts","../../src/presentation/PresentationSpinner.tsx","../../src/presentation/router.ts","../../src/presentation/plugin.tsx","../../src/presentation/usePresentationNavigate.ts","../../src/presentation/usePresentationParams.ts"],"sourcesContent":["import {type Serializable} from '@sanity/presentation-comlink'\nimport {useContext, useEffect} from 'react'\nimport {PresentationSharedStateContext} from 'sanity/_singletons'\n\n/** @public */\nexport const useSharedState = (key: string, value: Serializable): undefined => {\n const context = useContext(PresentationSharedStateContext)\n\n if (!context) {\n throw new Error('Preview Snapshots context is missing')\n }\n\n const {setValue} = context\n\n useEffect(() => {\n setValue(key, value)\n }, [key, value, setValue])\n\n return undefined\n}\n","import {ComposeIcon} from '@sanity/icons'\nimport {apiVersion} from '@sanity/preview-url-secret/constants'\n\nexport const DEFAULT_TOOL_ICON = ComposeIcon\nexport const DEFAULT_TOOL_NAME = 'presentation'\nexport const DEFAULT_TOOL_TITLE = 'Presentation'\n\nexport const EDIT_INTENT_MODE = 'presentation'\n\n// How long we wait until an iframe is loaded until we consider it to be slow and possibly failed\nexport const MAX_TIME_TO_OVERLAYS_CONNECTION = 3_000 // ms\n\n// The API version to use when using `@sanity/client`\nexport const API_VERSION = apiVersion\n\n// Heartbeats shouldn't fire on intervals that are so short it causes performance issues\nexport const MIN_LOADER_QUERY_LISTEN_HEARTBEAT_INTERVAL = 1000 // ms\n\n// How often the list over loader queries should be garbage collected\nexport const LOADER_QUERY_GC_INTERVAL = 30_000 // ms\n\n// The interval at which we check if existing popups have been closed\nexport const POPUP_CHECK_INTERVAL = 1000 // ms\n","import {defineLocaleResourceBundle} from 'sanity'\n\n/**\n * The locale namespace for the presentation tool\n *\n * @public\n */\nexport const presentationLocaleNamespace = 'presentation' as const\n\n/**\n * The default locale bundle for the presentation tool, which is US English.\n *\n * @internal\n */\nexport const presentationUsEnglishLocaleBundle = defineLocaleResourceBundle({\n locale: 'en-US',\n namespace: presentationLocaleNamespace,\n resources: () => import('./resources'),\n})\n","import {useContext} from 'react'\nimport {usePerspective} from 'sanity'\nimport {PaneRouterContext} from 'sanity/structure'\n\nexport function usePresentationPerspectiveStack() {\n const {perspectiveStack} = usePerspective()\n const paneRouter = useContext(PaneRouterContext)\n if (!paneRouter) {\n throw new Error('PaneRouter not found')\n }\n const scheduledDraftPerspective = paneRouter.params?.scheduledDraft\n\n if (scheduledDraftPerspective) {\n return [scheduledDraftPerspective, ...perspectiveStack]\n }\n return perspectiveStack\n}\n","import {useEffect, useMemo, useState} from 'react'\nimport {isObservable, map, of} from 'rxjs'\nimport {\n type ObjectSchemaType,\n type PreviewableType,\n useDocumentPreviewStore,\n useDocumentStore,\n} from 'sanity'\n\nimport {\n type DocumentLocationResolver,\n type DocumentLocationResolvers,\n type DocumentLocationsState,\n type DocumentLocationsStatus,\n} from './types'\nimport {usePresentationPerspectiveStack} from './usePresentationPerspectiveStack'\n\nconst INITIAL_STATE: DocumentLocationsState = {locations: []}\n\nexport function useDocumentLocations(props: {\n id: string\n version: string | undefined\n resolvers?: DocumentLocationResolver | DocumentLocationResolvers\n type: ObjectSchemaType\n}): {\n state: DocumentLocationsState\n status: DocumentLocationsStatus\n} {\n const {id, resolvers, type, version} = props\n const documentStore = useDocumentStore()\n const documentPreviewStore = useDocumentPreviewStore()\n\n const perspectiveStack = usePresentationPerspectiveStack()\n const [locationsState, setLocationsState] = useState<DocumentLocationsState>(INITIAL_STATE)\n\n const resolver = resolvers && (typeof resolvers === 'function' ? resolvers : resolvers[type.name])\n\n const [locationsStatus, setLocationsStatus] = useState<DocumentLocationsStatus>(\n resolver ? 'resolving' : 'empty',\n )\n\n const result = useMemo(() => {\n if (!resolver) return undefined\n\n // Original/advanced resolver which requires explicit use of Observables\n if (typeof resolver === 'function') {\n const params = {id, type: type.name, version, perspectiveStack}\n const context = {documentStore}\n const _result = resolver(params, context)\n return isObservable(_result) ? _result : of(_result)\n }\n\n // Simplified resolver pattern which abstracts away Observable logic\n if ('select' in resolver && 'resolve' in resolver) {\n const doc = {_type: 'reference', _ref: id}\n // Override the preview selection in the schema type to use the user\n // defined selection defined by the resolver\n const _type = {...type, preview: {select: resolver.select}} satisfies PreviewableType\n const options = {perspective: perspectiveStack}\n return documentPreviewStore\n .observeForPreview(doc, _type, options)\n .pipe(map((preview) => resolver.resolve(preview.snapshot || null)))\n }\n\n // Resolver is explicitly provided state\n return of(resolver)\n }, [documentStore, documentPreviewStore, id, resolver, type, version, perspectiveStack])\n\n useEffect(() => {\n const sub = result?.subscribe((state) => {\n setLocationsState(state || INITIAL_STATE)\n setLocationsStatus(state ? 'resolved' : 'empty')\n })\n\n return () => sub?.unsubscribe()\n }, [result])\n\n return {\n state: locationsState,\n status: locationsStatus,\n }\n}\n","import {useContext} from 'react'\nimport {PresentationContext} from 'sanity/_singletons'\n\nimport {type PresentationContextValue} from './types'\n\nexport function usePresentationTool(throwOnMissingContext?: true): PresentationContextValue\nexport function usePresentationTool(throwOnMissingContext: false): PresentationContextValue | null\nexport function usePresentationTool(throwOnMissingContext = true): PresentationContextValue | null {\n const presentation = useContext(PresentationContext)\n\n if (throwOnMissingContext && !presentation) {\n throw new Error('Presentation context is missing')\n }\n\n return presentation\n}\n","import {usePresentationTool} from '../usePresentationTool'\n\nexport function useCurrentPresentationToolName(): string | undefined {\n return usePresentationTool(false)?.name ?? undefined\n}\n","import {\n ChevronRightIcon,\n DesktopIcon,\n ErrorOutlineIcon,\n InfoOutlineIcon,\n WarningOutlineIcon,\n} from '@sanity/icons'\nimport {Box, Card, Flex, Spinner, Stack, Text} from '@sanity/ui'\nimport {type ComponentType, type ReactNode, useCallback, useContext, useState} from 'react'\nimport {type ObjectSchemaType, useTranslation} from 'sanity'\nimport {PresentationContext} from 'sanity/_singletons'\nimport {useIntentLink} from 'sanity/router'\nimport {usePaneRouter} from 'sanity/structure'\n\nimport {DEFAULT_TOOL_NAME, DEFAULT_TOOL_TITLE} from '../constants'\nimport {presentationLocaleNamespace} from '../i18n'\nimport {\n type DocumentLocation,\n type DocumentLocationResolver,\n type DocumentLocationResolvers,\n type PresentationPluginOptions,\n} from '../types'\nimport {useDocumentLocations} from '../useDocumentLocations'\nimport {useCurrentPresentationToolName} from './useCurrentPresentationToolName'\n\nconst TONE_ICONS: Record<'positive' | 'caution' | 'critical', ComponentType> = {\n positive: InfoOutlineIcon,\n caution: WarningOutlineIcon,\n critical: ErrorOutlineIcon,\n}\n\nexport function LocationsBanner(props: {\n documentId: string\n options: PresentationPluginOptions\n resolvers?: DocumentLocationResolver | DocumentLocationResolvers\n schemaType: ObjectSchemaType\n showPresentationTitle: boolean\n version: string | undefined\n}): ReactNode {\n const {documentId, options, resolvers, schemaType, showPresentationTitle, version} = props\n\n const {state, status} = useDocumentLocations({\n id: documentId,\n version,\n resolvers,\n type: schemaType,\n })\n\n const isResolving = status === 'resolving'\n\n const {locations, message, tone} = state\n const locationsCount = locations?.length || 0\n\n const {t} = useTranslation(presentationLocaleNamespace)\n const presentation = useContext(PresentationContext)\n const presentationName = presentation?.name\n const [expanded, setExpanded] = useState(false)\n const toggle = useCallback(() => {\n if (!locationsCount) return\n setExpanded((v) => !v)\n }, [locationsCount])\n\n const title = isResolving\n ? t('locations-banner.resolving.text')\n : message || t('locations-banner.locations-count', {count: locationsCount})\n\n const ToneIcon = tone ? TONE_ICONS[tone] : undefined\n\n if (!resolvers || status === 'empty') return null\n return (\n <Card padding={1} radius={2} border tone={tone}>\n <div style={{margin: -1}}>\n {!locations && (\n <Flex align=\"flex-start\" gap={3} padding={3}>\n {tone && ToneIcon && (\n <Box flex=\"none\">\n <Text size={1}>\n <ToneIcon />\n </Text>\n </Box>\n )}\n <Box flex={1}>\n <Text size={1} weight=\"medium\">\n {showPresentationTitle && <>{options.title || DEFAULT_TOOL_TITLE} &middot; </>}\n {title}\n </Text>\n </Box>\n </Flex>\n )}\n {locations && (\n <>\n <Card\n as={locationsCount ? 'button' : undefined}\n onClick={toggle}\n padding={3}\n radius={1}\n tone=\"inherit\"\n >\n <Flex gap={3}>\n <Box flex=\"none\">\n {isResolving ? (\n <Spinner size={1} />\n ) : (\n <Text size={1}>\n {locationsCount === 0 ? (\n <InfoOutlineIcon />\n ) : (\n <ChevronRightIcon\n style={{\n transform: `rotate(${expanded ? '90deg' : 0})`,\n transition: 'transform 100ms ease-in-out',\n }}\n />\n )}\n </Text>\n )}\n </Box>\n <Box flex={1}>\n <Text size={1} weight=\"medium\">\n {showPresentationTitle && <>{options.title || DEFAULT_TOOL_TITLE} &middot; </>}\n {title}\n </Text>\n </Box>\n </Flex>\n </Card>\n <Stack hidden={!expanded} marginTop={1} space={1}>\n {locations.map((l) => {\n let active = false\n if (\n (options.name || DEFAULT_TOOL_NAME) === presentationName &&\n presentation?.params.preview\n ) {\n active = areUrlsMatching(presentation.params.preview, l.href)\n }\n\n return (\n <LocationItem\n key={l.href}\n active={active}\n documentId={documentId}\n documentType={schemaType.name}\n node={l}\n toolName={options.name || DEFAULT_TOOL_NAME}\n />\n )\n })}\n </Stack>\n </>\n )}\n </div>\n </Card>\n )\n}\n\nfunction LocationItem(props: {\n active: boolean\n documentId: string\n documentType: string\n node: DocumentLocation\n toolName: string\n}) {\n const {documentId, documentType, node, active, toolName} = props\n const presentation = useContext(PresentationContext)\n const currentPresentationToolName = useCurrentPresentationToolName()\n const isCurrentTool = toolName === currentPresentationToolName\n const navigate = presentation?.navigate\n const {params: paneParams} = usePaneRouter()\n\n const presentationLinkProps = useIntentLink({\n intent: 'edit',\n params: {\n id: documentId,\n type: documentType,\n mode: 'presentation',\n presentation: toolName,\n ...presentation?.structureParams,\n ...paneParams,\n preview: node.href,\n },\n })\n\n const handleCurrentToolClick = useCallback(() => {\n navigate?.({params: {preview: node.href}})\n }, [node.href, navigate])\n\n return (\n <Card\n key={node.href}\n {...(isCurrentTool ? {} : presentationLinkProps)}\n as=\"a\"\n onClick={isCurrentTool ? handleCurrentToolClick : presentationLinkProps.onClick}\n padding={3}\n radius={1}\n pressed={active}\n tone=\"inherit\"\n >\n <Flex gap={3}>\n <Box flex=\"none\">\n <Text size={1}>\n <DesktopIcon />\n </Text>\n </Box>\n <Stack flex={1} space={2}>\n <Text size={1} weight=\"medium\">\n {node.title}\n </Text>\n <Text muted size={1} textOverflow=\"ellipsis\">\n {node.href}\n </Text>\n </Stack>\n </Flex>\n </Card>\n )\n}\n\n/**\n * Compares two URLs to determine if they match based on origin, pathname, and search parameters\n * The previewUrl should have all the search parameters that are in the locationUrl\n */\nfunction areUrlsMatching(previewUrlString: string, locationUrlString: string): boolean {\n try {\n const previewUrl = new URL(previewUrlString, location.origin)\n const locationUrl = new URL(locationUrlString, previewUrl.origin)\n\n // First compare origin and pathname\n if (previewUrl.origin !== locationUrl.origin || previewUrl.pathname !== locationUrl.pathname) {\n return false\n }\n\n // Then check search params\n // All search params in locationUrl must exist with the same values in previewUrl\n const locationParams = new URLSearchParams(locationUrl.search)\n const previewParams = new URLSearchParams(previewUrl.search)\n\n for (const [key, value] of locationParams.entries()) {\n if (previewParams.get(key) !== value) {\n return false\n }\n }\n\n return true\n } catch {\n // If URL parsing fails, URLs don't match\n return false\n }\n}\n","import {rem} from '@sanity/ui'\n// eslint-disable-next-line camelcase\nimport {getTheme_v2} from '@sanity/ui/theme'\nimport {type ReactNode, useContext} from 'react'\nimport {type ObjectSchemaType, type PublishedId} from 'sanity'\nimport {PresentationDocumentContext} from 'sanity/_singletons'\nimport {css, styled} from 'styled-components'\n\nimport {type PresentationPluginOptions} from '../types'\nimport {LocationsBanner} from './LocationsBanner'\n\nconst LocationStack = styled.div((props) => {\n const theme = getTheme_v2(props.theme)\n return css`\n display: flex;\n flex-direction: column;\n gap: ${rem(theme.space[2])};\n min-height: ${rem(42)};\n margin-bottom: ${rem(theme.space[5])};\n\n &:empty {\n display: none;\n }\n `\n})\n\nexport function PresentationDocumentHeader(props: {\n documentId: PublishedId\n version: string | undefined\n options: PresentationPluginOptions\n schemaType: ObjectSchemaType\n}): ReactNode {\n const {documentId, options, schemaType, version} = props\n const context = useContext(PresentationDocumentContext)\n\n const contextOptions = context?.options || []\n const resolvers = contextOptions.map((o) => o.resolve?.locations || o.locate)\n const hasResolvers = resolvers.some(Boolean)\n\n if ((context && context.options[0] !== options) || !hasResolvers) {\n return null\n }\n\n return (\n <LocationStack>\n {contextOptions.map((_options, idx) => (\n <LocationsBanner\n // oxlint-disable-next-line no-array-index-key\n key={idx}\n documentId={documentId}\n options={_options}\n resolvers={resolvers[idx]}\n schemaType={schemaType}\n showPresentationTitle={contextOptions.length > 1}\n version={version}\n />\n ))}\n </LocationStack>\n )\n}\n","import {type ReactNode, useCallback, useContext, useLayoutEffect, useMemo, useState} from 'react'\nimport {PresentationDocumentContext} from 'sanity/_singletons'\nimport {useEffectEvent} from 'use-effect-event'\n\nimport {type PresentationPluginOptions} from '../types'\nimport {type PresentationDocumentContextValue} from './types'\n\n/** @internal */\nexport function PresentationDocumentProvider(props: {\n children?: ReactNode\n options: PresentationPluginOptions\n}): React.JSX.Element {\n const {children, options} = props\n const parent = useContext(PresentationDocumentContext)\n const parentRegister = parent?.register\n\n const [optionsArray, setOptionsArray] = useState<PresentationPluginOptions[]>(() => [])\n\n const register = useCallback(\n // eslint-disable-next-line @typescript-eslint/no-shadow\n (options: PresentationPluginOptions) => {\n if (parentRegister) {\n return parentRegister(options)\n }\n\n setOptionsArray((prev) => [options].concat(prev))\n\n return () => {\n setOptionsArray((prev) => prev.filter((o) => o !== options))\n }\n },\n [parentRegister],\n )\n\n const context: PresentationDocumentContextValue = useMemo(\n () => ({\n options: parent?.options || optionsArray,\n register,\n }),\n [optionsArray, parent, register],\n )\n\n // eslint-disable-next-line @typescript-eslint/no-shadow\n const registerEffectEvent = useEffectEvent((options: PresentationPluginOptions) =>\n register(options),\n )\n useLayoutEffect(() => registerEffectEvent(options), [options])\n\n return (\n <PresentationDocumentContext.Provider value={context}>\n {children}\n </PresentationDocumentContext.Provider>\n )\n}\n","import {MasterDetailIcon} from '@sanity/icons'\nimport {useContext, useMemo} from 'react'\nimport {\n defineDocumentFieldAction,\n type DocumentFieldActionGroup,\n type DocumentFieldActionItem,\n type DocumentFieldActionProps,\n isRecord,\n pathToString,\n type Tool,\n useWorkspace,\n} from 'sanity'\nimport {PresentationContext} from 'sanity/_singletons'\nimport {useRouter} from 'sanity/router'\n\nimport {DEFAULT_TOOL_NAME} from '../constants'\n\nfunction useOpenInStructureAction(\n props: DocumentFieldActionProps,\n): DocumentFieldActionItem | DocumentFieldActionGroup {\n const {documentId, documentType, path} = props\n const workspace = useWorkspace()\n const {navigateIntent} = useRouter()\n const presentation = useContext(PresentationContext)\n\n const defaultStructureTool = useMemo(\n () =>\n findStructureTool(\n workspace.tools,\n documentId,\n documentType,\n presentation?.name || DEFAULT_TOOL_NAME,\n ),\n [documentId, documentType, workspace.tools, presentation],\n )\n\n return {\n type: 'action',\n hidden: !presentation || path.length > 0 || !defaultStructureTool,\n icon: defaultStructureTool?.icon || MasterDetailIcon,\n title: `Open in ${defaultStructureTool?.title || 'Structure'}`,\n onAction() {\n navigateIntent('edit', {\n id: documentId,\n type: documentType,\n mode: 'structure',\n path: pathToString(path),\n })\n },\n renderAsButton: true,\n }\n}\n\nexport const openInStructure = defineDocumentFieldAction({\n name: 'presentation/openInStructure',\n useAction: useOpenInStructureAction,\n})\n\nfunction findStructureTool(\n tools: Tool[],\n documentId: string,\n documentType: string,\n presentationToolName?: string,\n): Tool | undefined {\n const results = tools\n .filter((t) => t.name !== presentationToolName)\n .map((t) => {\n const match = t.canHandleIntent?.(\n 'edit',\n {\n id: documentId,\n type: documentType,\n mode: 'structure',\n },\n {},\n )\n\n return {tool: t, match}\n })\n\n const modeMatches = results.filter((t) => isRecord(t.match) && t.match.mode)\n\n if (modeMatches.length > 0) {\n return modeMatches[0].tool\n }\n\n const matches = results.filter((t) => t.match)\n\n return matches[0]?.tool\n}\n","import {uuid} from '@sanity/uuid'\nimport {getPublishedId} from 'sanity'\nimport {encodeJsonParams, type RouterState, type SearchParam} from 'sanity/router'\n\nimport {type PresentationSearchParams, type PresentationStateParams} from './types'\n\nconst preservedSearchParamKeys: Array<keyof PresentationSearchParams> = ['preview', 'viewport']\n\n/**\n * @internal\n */\nexport function getIntentState(\n intent: string,\n params: Record<string, string>,\n routerState: RouterState | undefined,\n payload: unknown,\n):\n | (PresentationStateParams & {_searchParams: SearchParam[]})\n | {intent: string; params: Record<string, string>; payload: unknown} {\n // oxlint-disable-next-line no-unused-vars\n const {id, mode, path, presentation, type, ...searchParams} = params\n\n const preservedSearchParams = (routerState?._searchParams || [])\n // @todo Casting https://github.com/microsoft/TypeScript/issues/14520\n .filter(([key]) => preservedSearchParamKeys.includes(key as keyof PresentationSearchParams))\n .reduce((acc, [key, value]) => ({...acc, [key]: value}), {} as Record<string, string>)\n\n const _searchParams = {\n ...preservedSearchParams,\n ...searchParams,\n }\n\n if (intent === 'edit' && id) {\n _searchParams.preview =\n _searchParams.preview || new URLSearchParams(window.location.search).get('preview') || '/'\n return {\n type: type || '*',\n id: getPublishedId(id),\n path,\n _searchParams: Object.entries(_searchParams),\n }\n }\n\n if (intent === 'create') {\n _searchParams.preview =\n _searchParams.preview || new URLSearchParams(window.location.search).get('preview') || '/'\n\n if (payload && typeof payload === 'object') {\n _searchParams.templateParams = encodeJsonParams(payload as Record<string, unknown>)\n }\n\n return {\n type: type || '*',\n id: id || uuid(),\n _searchParams: Object.entries(_searchParams),\n }\n }\n return {intent, params, payload}\n}\n","import {Flex, Spinner} from '@sanity/ui'\n\nexport function PresentationSpinner(): React.JSX.Element {\n return (\n <Flex align=\"center\" direction=\"column\" height=\"fill\" justify=\"center\" style={{width: '100%'}}>\n <Spinner />\n </Flex>\n )\n}\n","import {route} from 'sanity/router'\n\n// eslint-disable-next-line camelcase\nexport const router = route.create('/', {__unsafe_disableScopedSearchParams: true}, [\n route.intents('/intent'),\n route.create(':type', [route.create(':id', [route.create(':path')])]),\n])\n","import {type SanityDocument} from '@sanity/client'\nimport {lazy, Suspense} from 'react'\nimport {\n definePlugin,\n getPublishedId,\n getVersionFromId,\n type InputProps,\n isDocumentSchemaType,\n} from 'sanity'\n\nimport {DEFAULT_TOOL_ICON, DEFAULT_TOOL_NAME, EDIT_INTENT_MODE} from './constants'\nimport {PresentationDocumentHeader} from './document/PresentationDocumentHeader'\nimport {PresentationDocumentProvider} from './document/PresentationDocumentProvider'\nimport {openInStructure} from './fieldActions/openInStructure'\nimport {getIntentState} from './getIntentState'\nimport {presentationUsEnglishLocaleBundle} from './i18n'\nimport {PresentationSpinner} from './PresentationSpinner'\nimport {router} from './router'\nimport {\n type DocumentLocationResolverObject,\n type DocumentLocationsState,\n type DocumentResolver,\n type PresentationPluginOptions,\n} from './types'\n\nconst PresentationTool = lazy(() => import('./PresentationToolGrantsCheck'))\nconst BroadcastDisplayedDocument = lazy(() => import('./loader/BroadcastDisplayedDocument'))\n\n/**\n * Define locations for a given document type.\n * This function doesn't do anything itself, it is used to provide type information.\n * @param resolver - resolver that return locations for a document.\n * @public\n */\nexport function defineLocations<K extends string>(\n resolver: DocumentLocationResolverObject<K> | DocumentLocationsState,\n): typeof resolver {\n return resolver\n}\n\n/**\n * Define documents for a given location.\n * This function doesn't do anything itself, it is used to provide type information.\n * @param resolvers - resolvers that return documents.\n * @public\n */\nexport function defineDocuments(resolvers: DocumentResolver[]): typeof resolvers {\n return resolvers\n}\n\n/** @public */\nexport const presentationTool = definePlugin<PresentationPluginOptions>((options) => {\n const toolName = options.name || DEFAULT_TOOL_NAME\n\n if ('locate' in options) {\n console.warn('Presentation’s `locate` option is deprecated. Use `resolve.locations` instead.')\n }\n\n const hasLocationsResolver = !!(options.resolve?.locations || options.locate)\n\n function PresentationDocumentInput(props: InputProps) {\n const value = props.value as SanityDocument\n const documentId = value?._id ? getPublishedId(value?._id) : undefined\n const documentVersion = value?._id ? getVersionFromId(value._id) : undefined\n if (isDocumentSchemaType(props.schemaType)) {\n return (\n <PresentationDocumentProvider options={options}>\n {hasLocationsResolver && documentId && (\n <PresentationDocumentHeader\n documentId={documentId}\n version={documentVersion}\n options={options}\n schemaType={props.schemaType}\n />\n )}\n <Suspense fallback={<PresentationSpinner />}>{props.renderDefault(props)}</Suspense>\n <Suspense key=\"broadcast-displayed-document\">\n <BroadcastDisplayedDocument key={documentId} value={value} />\n </Suspense>\n </PresentationDocumentProvider>\n )\n }\n\n return props.renderDefault(props)\n }\n\n function canHandleCreateIntent(params: Record<string, unknown>) {\n // We can't handle create intents without a `type` parameter\n if (!('type' in params)) {\n return false\n }\n\n if ('presentation' in params && params.presentation !== toolName) {\n return false\n }\n\n return 'template' in params ? {template: true} : true\n }\n\n function canHandleEditIntent(params: Record<string, unknown>) {\n // We can't handle edit intents without `type` or `id` parameters\n if (!('type' in params) || !('id' in params)) {\n return false\n }\n\n if ('presentation' in params && params.presentation !== toolName) {\n return false\n }\n\n return 'mode' in params ? {mode: params.mode === EDIT_INTENT_MODE} : true\n }\n\n return {\n i18n: {\n bundles: [presentationUsEnglishLocaleBundle],\n },\n document: {\n unstable_fieldActions: (prev) => {\n return [\n ...prev.filter((a) => a.name !== openInStructure.name), // prevent duplication\n openInStructure,\n ]\n },\n },\n\n form: {\n components: {\n input: PresentationDocumentInput,\n },\n },\n\n tools: [\n {\n icon: options.icon || DEFAULT_TOOL_ICON,\n name: toolName,\n title: options.title,\n component: PresentationTool,\n options,\n canHandleIntent(intent, params) {\n if (intent === 'create') return canHandleCreateIntent(params)\n if (intent === 'edit') return canHandleEditIntent(params)\n return false\n },\n getIntentState,\n router,\n __internalApplicationType: 'sanity/presentation',\n },\n ],\n }\n})\n","import {useContext} from 'react'\nimport {PresentationNavigateContext} from 'sanity/_singletons'\n\nimport {type PresentationNavigateContextValue} from './types'\n\n/** @public */\nexport function usePresentationNavigate(): PresentationNavigateContextValue {\n const navigate = useContext(PresentationNavigateContext)\n\n if (!navigate) {\n throw new Error('Presentation navigate context is missing')\n }\n\n return navigate\n}\n\nexport type {PresentationNavigateContextValue}\n","import {useContext} from 'react'\nimport {PresentationParamsContext} from 'sanity/_singletons'\n\nimport {type PresentationParamsContextValue} from './types'\n\n/** @public */\nexport function usePresentationParams(throwOnMissingContext?: true): PresentationParamsContextValue\n/** @public */\nexport function usePresentationParams(\n throwOnMissingContext: false,\n): PresentationParamsContextValue | null\n/** @public */\nexport function usePresentationParams(\n throwOnMissingContext = true,\n): PresentationParamsContextValue | null {\n const params = useContext(PresentationParamsContext)\n\n if (throwOnMissingContext && !params) {\n throw new Error('Presentation params context is missing')\n }\n\n return params\n}\n"],"names":["useSharedState","key","value","$","_c","context","useContext","PresentationSharedStateContext","Error","setValue","t0","t1","useEffect","DEFAULT_TOOL_ICON","ComposeIcon","DEFAULT_TOOL_NAME","DEFAULT_TOOL_TITLE","EDIT_INTENT_MODE","MAX_TIME_TO_OVERLAYS_CONNECTION","API_VERSION","apiVersion","MIN_LOADER_QUERY_LISTEN_HEARTBEAT_INTERVAL","LOADER_QUERY_GC_INTERVAL","POPUP_CHECK_INTERVAL","presentationLocaleNamespace","presentationUsEnglishLocaleBundle","defineLocaleResourceBundle","locale","namespace","resources","usePresentationPerspectiveStack","perspectiveStack","usePerspective","paneRouter","PaneRouterContext","scheduledDraftPerspective","params","scheduledDraft","INITIAL_STATE","locations","useDocumentLocations","props","id","resolvers","type","version","documentStore","useDocumentStore","documentPreviewStore","useDocumentPreviewStore","locationsState","setLocationsState","useState","resolver","name","locationsStatus","setLocationsStatus","bb0","undefined","_result","isObservable","of","doc","_type","_ref","preview","select","options","perspective","t2","resolve","snapshot","observeForPreview","pipe","map","result","sub","subscribe","state","unsubscribe","t3","status","usePresentationTool","throwOnMissingContext","presentation","PresentationContext","useCurrentPresentationToolName","TONE_ICONS","positive","InfoOutlineIcon","caution","WarningOutlineIcon","critical","ErrorOutlineIcon","LocationsBanner","documentId","schemaType","showPresentationTitle","isResolving","message","tone","locationsCount","length","t","useTranslation","presentationName","expanded","setExpanded","_temp","toggle","count","title","ToneIcon","for","margin","t4","t5","transform","transition","l","active","areUrlsMatching","href","t6","t7","v","LocationItem","documentType","node","toolName","currentPresentationToolName","isCurrentTool","navigate","paneParams","usePaneRouter","structureParams","intent","mode","presentationLinkProps","useIntentLink","handleCurrentToolClick","onClick","Symbol","t8","t9","previewUrlString","locationUrlString","previewUrl","URL","location","origin","locationUrl","pathname","locationParams","URLSearchParams","search","previewParams","entries","get","LocationStack","styled","div","theme","getTheme_v2","css","rem","space","PresentationDocumentHeader","PresentationDocumentContext","contextOptions","some","Boolean","hasResolvers","_options","idx","o","locate","PresentationDocumentProvider","children","parent","parentRegister","register","optionsArray","setOptionsArray","options_0","prev","concat","prev_0","filter","options_1","registerEffectEvent","useEffectEvent","useLayoutEffect","useOpenInStructureAction","path","workspace","useWorkspace","navigateIntent","useRouter","tools","findStructureTool","defaultStructureTool","icon","MasterDetailIcon","hidden","onAction","pathToString","renderAsButton","openInStructure","defineDocumentFieldAction","useAction","presentationToolName","results","match","canHandleIntent","tool","modeMatches","isRecord","preservedSearchParamKeys","getIntentState","routerState","payload","searchParams","_searchParams","includes","reduce","acc","window","getPublishedId","Object","templateParams","encodeJsonParams","uuid","PresentationSpinner","width","router","route","create","__unsafe_disableScopedSearchParams","intents","PresentationTool","lazy","BroadcastDisplayedDocument","defineLocations","defineDocuments","presentationTool","definePlugin","console","warn","hasLocationsResolver","PresentationDocumentInput","_id","getVersionFromId","documentVersion","isDocumentSchemaType","renderDefault","canHandleCreateIntent","template","canHandleEditIntent","i18n","bundles","document","unstable_fieldActions","a","form","components","input","component","__internalApplicationType","usePresentationNavigate","PresentationNavigateContext","usePresentationParams","PresentationParamsContext"],"mappings":";;;;;;;;;;;;;;;AAKO,MAAMA,iBAAiBA,CAAAC,KAAAC,UAAA;AAAA,QAAAC,IAAAC,EAAA,CAAA,GAC5BC,UAAgBC,WAAWC,8BAA8B;AAEzD,MAAI,CAACF;AACH,UAAM,IAAIG,MAAM,sCAAsC;AAGxD,QAAA;AAAA,IAAAC;AAAAA,EAAAA,IAAmBJ;AAAO,MAAAK,IAAAC;AAAAR,IAAA,CAAA,MAAAF,OAAAE,SAAAM,YAAAN,EAAA,CAAA,MAAAD,SAEhBQ,KAAAA,MAAA;AACRD,aAASR,KAAKC,KAAK;AAAA,EAAC,GACnBS,MAACV,KAAKC,OAAOO,QAAQ,GAACN,OAAAF,KAAAE,OAAAM,UAAAN,OAAAD,OAAAC,OAAAO,IAAAP,OAAAQ,OAAAD,KAAAP,EAAA,CAAA,GAAAQ,KAAAR,EAAA,CAAA,IAFzBS,UAAUF,IAEPC,EAAsB;AAAC,GCbfE,oBAAoBC,aACpBC,oBAAoB,gBACpBC,qBAAqB,gBAErBC,mBAAmB,gBAGnBC,kCAAkC,KAGlCC,cAAcC,YAGdC,6CAA6C,KAG7CC,2BAA2B,KAG3BC,uBAAuB,KCfvBC,8BAA8B,gBAO9BC,oCAAoCC,2BAA2B;AAAA,EAC1EC,QAAQ;AAAA,EACRC,WAAWJ;AAAAA,EACXK,WAAWA,MAAM,OAAO,iBAAa;AACvC,CAAC;ACdM,SAAAC,kCAAA;AAAA,QAAA3B,IAAAC,EAAA,CAAA,GACL;AAAA,IAAA2B;AAAAA,EAAAA,IAA2BC,eAAAA,GAC3BC,aAAmB3B,WAAW4B,iBAAiB;AAC/C,MAAI,CAACD;AACH,UAAM,IAAIzB,MAAM,sBAAsB;AAExC,QAAA2B,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C;AAAA,IAAA;AAAA,IAE7C4O,UAAU;AAAA,MACRC,uBAAwB7E,CAAAA,SACf;AAAA,QACL,GAAGA,KAAKG,OAAQ2E,OAAMA,EAAEjN,SAAS0J,gBAAgB1J,IAAI;AAAA;AAAA,QACrD0J;AAAAA,MAAAA;AAAAA,IAAe;AAAA,IAKrBwD,MAAM;AAAA,MACJC,YAAY;AAAA,QACVC,OAAOhB;AAAAA,MAAAA;AAAAA,IACT;AAAA,IAGFnD,OAAO,CACL;AAAA,MACEG,MAAMvI,QAAQuI,QAAQ7L;AAAAA,MACtByC,MAAM2E;AAAAA,MACNlB,OAAO5C,QAAQ4C;AAAAA,MACf4J,WAAW3B;AAAAA,MACX7K;AAAAA,MACAmJ,gBAAgB9E,QAAQpG,QAAQ;AAC9B,eAAIoG,WAAW,WAAiBwH,sBAAsB5N,MAAM,IACxDoG,WAAW,SAAe0H,oBAAoB9N,MAAM,IACjD;AAAA,MACT;AAAA,MACAuL;AAAAA,MACAgB;AAAAA,MACAiC,2BAA2B;AAAA,IAAA,CAC5B;AAAA,EAAA;AAGP,CAAC;AC/IM,SAAAC,0BAAA;AACL,QAAAzI,WAAiB9H,WAAWwQ,2BAA2B;AAEvD,MAAI,CAAC1I;AACH,UAAM,IAAI5H,MAAM,0CAA0C;AAC3D,SAEM4H;AAAQ;ACDV,SAAA2I,sBAAArQ,IAAA;AACL,QAAAyE,wBAAAzE,OAAAgD,SAAA,KAAAhD,IAEA0B,SAAe9B,WAAW0Q,yBAAyB;AAEnD,MAAI7L,yBAAA,CAA0B/C;AAC5B,UAAM,IAAI5B,MAAM,wCAAwC;AACzD,SAEM4B;AAAM;"}
@@ -1,11 +1,12 @@
1
1
  import { constants } from "node:fs";
2
2
  import fs from "node:fs/promises";
3
3
  import path from "node:path";
4
+ import { fileURLToPath } from "node:url";
4
5
  import readPkgUp from "read-pkg-up";
5
6
  import { debug as debug$2, writeSanityRuntime, getViteConfig, extendViteConfigWithUserConfig, finalizeViteConfig, generateWebManifest } from "./runtime.js";
6
7
  import chalk from "chalk";
7
8
  import { version } from "vite";
8
- const __dirname$1 = path.dirname(new URL(import.meta.url).pathname), debug$1 = debug$2.extend("static");
9
+ const __dirname$1 = path.dirname(fileURLToPath(import.meta.url)), debug$1 = debug$2.extend("static");
9
10
  async function buildStaticFiles(options) {
10
11
  const {
11
12
  cwd,
@@ -1 +1 @@
1
- {"version":3,"file":"previewServer.js","sources":["../../src/_internal/cli/server/buildStaticFiles.ts","../../src/_internal/cli/server/vite/plugin-sanity-basepath-redirect.ts","../../src/_internal/cli/server/previewServer.ts"],"sourcesContent":["import {constants as fsConstants} from 'node:fs'\nimport fs from 'node:fs/promises'\nimport path from 'node:path'\n\nimport {type ReactCompilerConfig, type UserViteConfig} from '@sanity/cli'\nimport readPkgUp from 'read-pkg-up'\n\nimport {debug as serverDebug} from './debug'\nimport {extendViteConfigWithUserConfig, finalizeViteConfig, getViteConfig} from './getViteConfig'\nimport {writeSanityRuntime} from './runtime'\nimport {generateWebManifest} from './webManifest'\n\nconst __dirname = path.dirname(new URL(import.meta.url).pathname)\n\nconst debug = serverDebug.extend('static')\n\nexport interface ChunkModule {\n name: string\n originalLength: number\n renderedLength: number\n}\n\nexport interface ChunkStats {\n name: string\n modules: ChunkModule[]\n}\n\nexport interface StaticBuildOptions {\n cwd: string\n basePath: string\n outputDir: string\n minify?: boolean\n profile?: boolean\n sourceMap?: boolean\n importMap?: {imports?: Record<string, string>}\n\n vite?: UserViteConfig\n reactCompiler: ReactCompilerConfig | undefined\n entry?: string\n isApp?: boolean\n}\n\nexport async function buildStaticFiles(\n options: StaticBuildOptions,\n): Promise<{chunks: ChunkStats[]}> {\n const {\n cwd,\n outputDir,\n sourceMap = false,\n minify = true,\n basePath,\n vite: extendViteConfig,\n importMap,\n reactCompiler,\n entry,\n isApp,\n } = options\n\n debug('Writing Sanity runtime files')\n await writeSanityRuntime({\n cwd,\n reactStrictMode: false,\n watch: false,\n basePath,\n entry,\n isApp,\n })\n\n debug('Resolving vite config')\n const mode = 'production'\n let viteConfig = await getViteConfig({\n cwd,\n basePath,\n outputDir,\n minify,\n sourceMap,\n mode,\n importMap,\n reactCompiler,\n isApp,\n })\n\n // Extend Vite configuration with user-provided config\n if (extendViteConfig) {\n viteConfig = await extendViteConfigWithUserConfig(\n {command: 'build', mode},\n viteConfig,\n extendViteConfig,\n )\n viteConfig = await finalizeViteConfig(viteConfig)\n }\n\n // Copy files placed in /static to the built /static\n debug('Copying static files from /static to output dir')\n const staticPath = path.join(outputDir, 'static')\n await copyDir(path.join(cwd, 'static'), staticPath)\n\n // Write favicons, not overwriting ones that already exist, to static folder\n debug('Writing favicons to output dir')\n const faviconBasePath = `${basePath.replace(/\\/+$/, '')}/static`\n await writeFavicons(faviconBasePath, staticPath)\n\n debug('Bundling using vite')\n const {build} = await import('vite')\n const bundle = await build(viteConfig)\n debug('Bundling complete')\n\n // For typescript only - this shouldn't ever be the case given we're not watching\n if (Array.isArray(bundle) || !('output' in bundle)) {\n return {chunks: []}\n }\n\n const stats: ChunkStats[] = []\n bundle.output.forEach((chunk) => {\n if (chunk.type !== 'chunk') {\n return\n }\n\n stats.push({\n name: chunk.name,\n modules: Object.entries(chunk.modules).map(([rawFilePath, chunkModule]) => {\n const filePath = rawFilePath.startsWith('\\x00')\n ? rawFilePath.slice('\\x00'.length)\n : rawFilePath\n\n return {\n name: path.isAbsolute(filePath) ? path.relative(cwd, filePath) : filePath,\n originalLength: chunkModule.originalLength,\n renderedLength: chunkModule.renderedLength,\n }\n }),\n })\n })\n\n return {chunks: stats}\n}\n\nasync function copyDir(srcDir: string, destDir: string, skipExisting?: boolean): Promise<void> {\n await fs.mkdir(destDir, {recursive: true})\n\n for (const file of await tryReadDir(srcDir)) {\n const srcFile = path.resolve(srcDir, file)\n if (srcFile === destDir) {\n continue\n }\n\n const destFile = path.resolve(destDir, file)\n const stat = await fs.stat(srcFile)\n\n if (stat.isDirectory()) {\n await copyDir(srcFile, destFile, skipExisting)\n } else if (skipExisting) {\n await fs.copyFile(srcFile, destFile, fsConstants.COPYFILE_EXCL).catch(skipIfExistsError)\n } else {\n await fs.copyFile(srcFile, destFile)\n }\n }\n}\n\nasync function tryReadDir(dir: string): Promise<string[]> {\n try {\n const content = await fs.readdir(dir)\n return content\n } catch (err) {\n if (err.code === 'ENOENT') {\n return []\n }\n\n throw err\n }\n}\n\nfunction skipIfExistsError(err: Error & {code: string}) {\n if (err.code === 'EEXIST') {\n return\n }\n\n throw err\n}\n\nasync function writeFavicons(basePath: string, destDir: string): Promise<void> {\n const sanityPkgPath = (await readPkgUp({cwd: __dirname}))?.path\n const faviconsPath = sanityPkgPath\n ? path.join(path.dirname(sanityPkgPath), 'static', 'favicons')\n : undefined\n\n if (!faviconsPath) {\n throw new Error('Unable to resolve `sanity` module root')\n }\n\n await fs.mkdir(destDir, {recursive: true})\n await copyDir(faviconsPath, destDir, true)\n await writeWebManifest(basePath, destDir)\n\n // Copy the /static/favicon.ico to /favicon.ico as well, because some tools/browsers\n // blindly expects it to be there before requesting the HTML containing the actual path\n await fs.copyFile(path.join(destDir, 'favicon.ico'), path.join(destDir, '..', 'favicon.ico'))\n}\n\nasync function writeWebManifest(basePath: string, destDir: string): Promise<void> {\n const content = JSON.stringify(generateWebManifest(basePath), null, 2)\n await fs\n .writeFile(path.join(destDir, 'manifest.webmanifest'), content, 'utf8')\n .catch(skipIfExistsError)\n}\n","import {type Plugin} from 'vite'\n\nexport function sanityBasePathRedirectPlugin(basePath: string | undefined): Plugin {\n return {\n name: 'sanity/server/sanity-base-path-redirect',\n apply: 'serve',\n configurePreviewServer(vitePreviewServer) {\n return () => {\n if (!basePath) {\n return\n }\n\n vitePreviewServer.middlewares.use((req, res, next) => {\n if (req.url !== '/') {\n next()\n return\n }\n\n res.writeHead(302, {Location: basePath})\n res.end()\n })\n }\n },\n }\n}\n","import fs from 'node:fs/promises'\nimport path from 'node:path'\n\nimport {type UserViteConfig} from '@sanity/cli'\nimport chalk from 'chalk'\nimport {type InlineConfig, version} from 'vite'\n\nimport {debug as serverDebug} from './debug'\nimport {extendViteConfigWithUserConfig} from './getViteConfig'\nimport {sanityBasePathRedirectPlugin} from './vite/plugin-sanity-basepath-redirect'\n\nconst debug = serverDebug.extend('preview')\n\nexport interface PreviewServer {\n urls: {local: string[]; network: string[]}\n close(): Promise<void>\n}\n\nexport interface PreviewServerOptions {\n root: string\n cwd: string\n\n httpPort: number\n httpHost?: string\n\n vite?: UserViteConfig\n isApp?: boolean\n}\n\nexport async function startPreviewServer(options: PreviewServerOptions): Promise<PreviewServer> {\n const {httpPort, httpHost, root, vite: extendViteConfig, isApp} = options\n const startTime = Date.now()\n\n const indexPath = path.join(root, 'index.html')\n let basePath: string | undefined\n try {\n const index = await fs.readFile(indexPath, 'utf8')\n basePath = tryResolveBasePathFromIndex(index)\n } catch (err) {\n if (err.code !== 'ENOENT') {\n throw err\n }\n\n const error = new Error(\n `Could not find a production build in the '${root}' directory.\\nTry building your ${isApp ? 'application' : 'studio '}app with 'sanity build' before starting the preview server.`,\n )\n error.name = 'BUILD_NOT_FOUND'\n throw error\n }\n\n const mode = 'production'\n let previewConfig: InlineConfig = {\n root,\n base: basePath || '/',\n plugins: [sanityBasePathRedirectPlugin(basePath)],\n configFile: false,\n preview: {\n port: httpPort,\n host: httpHost,\n strictPort: true,\n },\n // Needed for vite to not serve `root/dist`\n build: {\n outDir: root,\n },\n mode,\n }\n\n // Extend Vite configuration with user-provided config\n if (extendViteConfig) {\n previewConfig = await extendViteConfigWithUserConfig(\n {command: 'serve', mode},\n previewConfig,\n extendViteConfig,\n )\n }\n\n debug('Creating vite server')\n const {preview} = await import('vite')\n const server = await preview(previewConfig)\n const warn = server.config.logger.warn\n const info = server.config.logger.info\n const url = server.resolvedUrls!.local[0]\n\n if (typeof basePath === 'undefined') {\n warn('Could not determine base path from index.html, using \"/\" as default')\n } else if (basePath && basePath !== '/') {\n info(`Using resolved base path from static build: ${chalk.cyan(basePath)}`)\n }\n\n const startupDuration = Date.now() - startTime\n\n info(\n `Sanity ${isApp ? 'application' : 'Studio'} ` +\n `using ${chalk.cyan(`vite@${version}`)} ` +\n `ready in ${chalk.cyan(`${Math.ceil(startupDuration)}ms`)} ` +\n `and running at ${chalk.cyan(url)} (production preview mode)`,\n )\n\n return {\n urls: server.resolvedUrls!,\n close: () =>\n new Promise((resolve, reject) =>\n server.httpServer.close((err) => (err ? reject(err) : resolve())),\n ),\n }\n}\n\nfunction tryResolveBasePathFromIndex(index: string): string | undefined {\n // <script ... src=\"/some-base-path/static/sanity-a3cc3d86.js\"></script>\n const basePath = index.match(/<script[^>]+src=\"(.*?)\\/static\\/sanity-/)?.[1]\n\n // We _expect_ to be able to find the base path. If we can't, we should warn.\n // Note that we're checking for `undefined` here, since an empty string is a\n // valid base path.\n if (typeof basePath === 'undefined') {\n return undefined\n }\n\n // In the case of an empty base path, we still want to return `/` to indicate\n // that we _found_ the basepath - it just happens to be empty. Eg:\n // <script ... src = \"/static/sanity-a3cc3d86.js\"></script>\n // Which differs from not being able to find the script tag at all, in which\n // case we'll want to show a warning to indicate that it is an abnormality.\n return basePath === '' ? '/' : basePath\n}\n"],"names":["__dirname","path","dirname","URL","import","url","pathname","debug","serverDebug","extend","buildStaticFiles","options","cwd","outputDir","sourceMap","minify","basePath","vite","extendViteConfig","importMap","reactCompiler","entry","isApp","writeSanityRuntime","reactStrictMode","watch","mode","viteConfig","getViteConfig","extendViteConfigWithUserConfig","command","finalizeViteConfig","staticPath","join","copyDir","faviconBasePath","replace","writeFavicons","build","bundle","Array","isArray","chunks","stats","output","forEach","chunk","type","push","name","modules","Object","entries","map","rawFilePath","chunkModule","filePath","startsWith","slice","isAbsolute","relative","originalLength","renderedLength","srcDir","destDir","skipExisting","fs","mkdir","recursive","file","tryReadDir","srcFile","resolve","destFile","stat","isDirectory","copyFile","fsConstants","COPYFILE_EXCL","catch","skipIfExistsError","dir","readdir","err","code","sanityPkgPath","readPkgUp","faviconsPath","undefined","Error","writeWebManifest","content","JSON","stringify","generateWebManifest","writeFile","sanityBasePathRedirectPlugin","apply","configurePreviewServer","vitePreviewServer","middlewares","use","req","res","next","writeHead","Location","end","startPreviewServer","httpPort","httpHost","root","startTime","Date","now","indexPath","index","readFile","tryResolveBasePathFromIndex","error","previewConfig","base","plugins","configFile","preview","port","host","strictPort","outDir","server","warn","config","logger","info","resolvedUrls","local","chalk","cyan","startupDuration","version","Math","ceil","urls","close","Promise","reject","httpServer","match"],"mappings":";;;;;;;AAYA,MAAMA,cAAYC,KAAKC,QAAQ,IAAIC,IAAIC,YAAYC,GAAG,EAAEC,QAAQ,GAE1DC,UAAQC,QAAYC,OAAO,QAAQ;AA4BzC,eAAsBC,iBACpBC,SACiC;AACjC,QAAM;AAAA,IACJC;AAAAA,IACAC;AAAAA,IACAC,YAAY;AAAA,IACZC,SAAS;AAAA,IACTC;AAAAA,IACAC,MAAMC;AAAAA,IACNC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,EAAAA,IACEX;AAEJJ,UAAM,8BAA8B,GACpC,MAAMgB,mBAAmB;AAAA,IACvBX;AAAAA,IACAY,iBAAiB;AAAA,IACjBC,OAAO;AAAA,IACPT;AAAAA,IACAK;AAAAA,IACAC;AAAAA,EAAAA,CACD,GAEDf,QAAM,uBAAuB;AAC7B,QAAMmB,OAAO;AACb,MAAIC,aAAa,MAAMC,cAAc;AAAA,IACnChB;AAAAA,IACAI;AAAAA,IACAH;AAAAA,IACAE;AAAAA,IACAD;AAAAA,IACAY;AAAAA,IACAP;AAAAA,IACAC;AAAAA,IACAE;AAAAA,EAAAA,CACD;AAGGJ,uBACFS,aAAa,MAAME,+BACjB;AAAA,IAACC,SAAS;AAAA,IAASJ;AAAAA,EAAAA,GACnBC,YACAT,gBACF,GACAS,aAAa,MAAMI,mBAAmBJ,UAAU,IAIlDpB,QAAM,iDAAiD;AACvD,QAAMyB,aAAa/B,KAAKgC,KAAKpB,WAAW,QAAQ;AAChD,QAAMqB,QAAQjC,KAAKgC,KAAKrB,K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AAOnI,WAAa;AASxB,WAAOA,aAAa,KAAK,MAAMA;AACjC;"}
1
+ {"version":3,"file":"previewServer.js","sources":["../../src/_internal/cli/server/buildStaticFiles.ts","../../src/_internal/cli/server/vite/plugin-sanity-basepath-redirect.ts","../../src/_internal/cli/server/previewServer.ts"],"sourcesContent":["import {constants as fsConstants} from 'node:fs'\nimport fs from 'node:fs/promises'\nimport path from 'node:path'\nimport {fileURLToPath} from 'node:url'\n\nimport {type ReactCompilerConfig, type UserViteConfig} from '@sanity/cli'\nimport readPkgUp from 'read-pkg-up'\n\nimport {debug as serverDebug} from './debug'\nimport {extendViteConfigWithUserConfig, finalizeViteConfig, getViteConfig} from './getViteConfig'\nimport {writeSanityRuntime} from './runtime'\nimport {generateWebManifest} from './webManifest'\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url))\n\nconst debug = serverDebug.extend('static')\n\nexport interface ChunkModule {\n name: string\n originalLength: number\n renderedLength: number\n}\n\nexport interface ChunkStats {\n name: string\n modules: ChunkModule[]\n}\n\nexport interface StaticBuildOptions {\n cwd: string\n basePath: string\n outputDir: string\n minify?: boolean\n profile?: boolean\n sourceMap?: boolean\n importMap?: {imports?: Record<string, string>}\n\n vite?: UserViteConfig\n reactCompiler: ReactCompilerConfig | undefined\n entry?: string\n isApp?: boolean\n}\n\nexport async function buildStaticFiles(\n options: StaticBuildOptions,\n): Promise<{chunks: ChunkStats[]}> {\n const {\n cwd,\n outputDir,\n sourceMap = false,\n minify = true,\n basePath,\n vite: extendViteConfig,\n importMap,\n reactCompiler,\n entry,\n isApp,\n } = options\n\n debug('Writing Sanity runtime files')\n await writeSanityRuntime({\n cwd,\n reactStrictMode: false,\n watch: false,\n basePath,\n entry,\n isApp,\n })\n\n debug('Resolving vite config')\n const mode = 'production'\n let viteConfig = await getViteConfig({\n cwd,\n basePath,\n outputDir,\n minify,\n sourceMap,\n mode,\n importMap,\n reactCompiler,\n isApp,\n })\n\n // Extend Vite configuration with user-provided config\n if (extendViteConfig) {\n viteConfig = await extendViteConfigWithUserConfig(\n {command: 'build', mode},\n viteConfig,\n extendViteConfig,\n )\n viteConfig = await finalizeViteConfig(viteConfig)\n }\n\n // Copy files placed in /static to the built /static\n debug('Copying static files from /static to output dir')\n const staticPath = path.join(outputDir, 'static')\n await copyDir(path.join(cwd, 'static'), staticPath)\n\n // Write favicons, not overwriting ones that already exist, to static folder\n debug('Writing favicons to output dir')\n const faviconBasePath = `${basePath.replace(/\\/+$/, '')}/static`\n await writeFavicons(faviconBasePath, staticPath)\n\n debug('Bundling using vite')\n const {build} = await import('vite')\n const bundle = await build(viteConfig)\n debug('Bundling complete')\n\n // For typescript only - this shouldn't ever be the case given we're not watching\n if (Array.isArray(bundle) || !('output' in bundle)) {\n return {chunks: []}\n }\n\n const stats: ChunkStats[] = []\n bundle.output.forEach((chunk) => {\n if (chunk.type !== 'chunk') {\n return\n }\n\n stats.push({\n name: chunk.name,\n modules: Object.entries(chunk.modules).map(([rawFilePath, chunkModule]) => {\n const filePath = rawFilePath.startsWith('\\x00')\n ? rawFilePath.slice('\\x00'.length)\n : rawFilePath\n\n return {\n name: path.isAbsolute(filePath) ? path.relative(cwd, filePath) : filePath,\n originalLength: chunkModule.originalLength,\n renderedLength: chunkModule.renderedLength,\n }\n }),\n })\n })\n\n return {chunks: stats}\n}\n\nasync function copyDir(srcDir: string, destDir: string, skipExisting?: boolean): Promise<void> {\n await fs.mkdir(destDir, {recursive: true})\n\n for (const file of await tryReadDir(srcDir)) {\n const srcFile = path.resolve(srcDir, file)\n if (srcFile === destDir) {\n continue\n }\n\n const destFile = path.resolve(destDir, file)\n const stat = await fs.stat(srcFile)\n\n if (stat.isDirectory()) {\n await copyDir(srcFile, destFile, skipExisting)\n } else if (skipExisting) {\n await fs.copyFile(srcFile, destFile, fsConstants.COPYFILE_EXCL).catch(skipIfExistsError)\n } else {\n await fs.copyFile(srcFile, destFile)\n }\n }\n}\n\nasync function tryReadDir(dir: string): Promise<string[]> {\n try {\n const content = await fs.readdir(dir)\n return content\n } catch (err) {\n if (err.code === 'ENOENT') {\n return []\n }\n\n throw err\n }\n}\n\nfunction skipIfExistsError(err: Error & {code: string}) {\n if (err.code === 'EEXIST') {\n return\n }\n\n throw err\n}\n\nasync function writeFavicons(basePath: string, destDir: string): Promise<void> {\n const sanityPkgPath = (await readPkgUp({cwd: __dirname}))?.path\n const faviconsPath = sanityPkgPath\n ? path.join(path.dirname(sanityPkgPath), 'static', 'favicons')\n : undefined\n\n if (!faviconsPath) {\n throw new Error('Unable to resolve `sanity` module root')\n }\n\n await fs.mkdir(destDir, {recursive: true})\n await copyDir(faviconsPath, destDir, true)\n await writeWebManifest(basePath, destDir)\n\n // Copy the /static/favicon.ico to /favicon.ico as well, because some tools/browsers\n // blindly expects it to be there before requesting the HTML containing the actual path\n await fs.copyFile(path.join(destDir, 'favicon.ico'), path.join(destDir, '..', 'favicon.ico'))\n}\n\nasync function writeWebManifest(basePath: string, destDir: string): Promise<void> {\n const content = JSON.stringify(generateWebManifest(basePath), null, 2)\n await fs\n .writeFile(path.join(destDir, 'manifest.webmanifest'), content, 'utf8')\n .catch(skipIfExistsError)\n}\n","import {type Plugin} from 'vite'\n\nexport function sanityBasePathRedirectPlugin(basePath: string | undefined): Plugin {\n return {\n name: 'sanity/server/sanity-base-path-redirect',\n apply: 'serve',\n configurePreviewServer(vitePreviewServer) {\n return () => {\n if (!basePath) {\n return\n }\n\n vitePreviewServer.middlewares.use((req, res, next) => {\n if (req.url !== '/') {\n next()\n return\n }\n\n res.writeHead(302, {Location: basePath})\n res.end()\n })\n }\n },\n }\n}\n","import fs from 'node:fs/promises'\nimport path from 'node:path'\n\nimport {type UserViteConfig} from '@sanity/cli'\nimport chalk from 'chalk'\nimport {type InlineConfig, version} from 'vite'\n\nimport {debug as serverDebug} from './debug'\nimport {extendViteConfigWithUserConfig} from './getViteConfig'\nimport {sanityBasePathRedirectPlugin} from './vite/plugin-sanity-basepath-redirect'\n\nconst debug = serverDebug.extend('preview')\n\nexport interface PreviewServer {\n urls: {local: string[]; network: string[]}\n close(): Promise<void>\n}\n\nexport interface PreviewServerOptions {\n root: string\n cwd: string\n\n httpPort: number\n httpHost?: string\n\n vite?: UserViteConfig\n isApp?: boolean\n}\n\nexport async function startPreviewServer(options: PreviewServerOptions): Promise<PreviewServer> {\n const {httpPort, httpHost, root, vite: extendViteConfig, isApp} = options\n const startTime = Date.now()\n\n const indexPath = path.join(root, 'index.html')\n let basePath: string | undefined\n try {\n const index = await fs.readFile(indexPath, 'utf8')\n basePath = tryResolveBasePathFromIndex(index)\n } catch (err) {\n if (err.code !== 'ENOENT') {\n throw err\n }\n\n const error = new Error(\n `Could not find a production build in the '${root}' directory.\\nTry building your ${isApp ? 'application' : 'studio '}app with 'sanity build' before starting the preview server.`,\n )\n error.name = 'BUILD_NOT_FOUND'\n throw error\n }\n\n const mode = 'production'\n let previewConfig: InlineConfig = {\n root,\n base: basePath || '/',\n plugins: [sanityBasePathRedirectPlugin(basePath)],\n configFile: false,\n preview: {\n port: httpPort,\n host: httpHost,\n strictPort: true,\n },\n // Needed for vite to not serve `root/dist`\n build: {\n outDir: root,\n },\n mode,\n }\n\n // Extend Vite configuration with user-provided config\n if (extendViteConfig) {\n previewConfig = await extendViteConfigWithUserConfig(\n {command: 'serve', mode},\n previewConfig,\n extendViteConfig,\n )\n }\n\n debug('Creating vite server')\n const {preview} = await import('vite')\n const server = await preview(previewConfig)\n const warn = server.config.logger.warn\n const info = server.config.logger.info\n const url = server.resolvedUrls!.local[0]\n\n if (typeof basePath === 'undefined') {\n warn('Could not determine base path from index.html, using \"/\" as default')\n } else if (basePath && basePath !== '/') {\n info(`Using resolved base path from static build: ${chalk.cyan(basePath)}`)\n }\n\n const startupDuration = Date.now() - startTime\n\n info(\n `Sanity ${isApp ? 'application' : 'Studio'} ` +\n `using ${chalk.cyan(`vite@${version}`)} ` +\n `ready in ${chalk.cyan(`${Math.ceil(startupDuration)}ms`)} ` +\n `and running at ${chalk.cyan(url)} (production preview mode)`,\n )\n\n return {\n urls: server.resolvedUrls!,\n close: () =>\n new Promise((resolve, reject) =>\n server.httpServer.close((err) => (err ? reject(err) : resolve())),\n ),\n }\n}\n\nfunction tryResolveBasePathFromIndex(index: string): string | undefined {\n // <script ... src=\"/some-base-path/static/sanity-a3cc3d86.js\"></script>\n const basePath = index.match(/<script[^>]+src=\"(.*?)\\/static\\/sanity-/)?.[1]\n\n // We _expect_ to be able to find the base path. If we can't, we should warn.\n // Note that we're checking for `undefined` here, since an empty string is a\n // valid base path.\n if (typeof basePath === 'undefined') {\n return undefined\n }\n\n // In the case of an empty base path, we still want to return `/` to indicate\n // that we _found_ the basepath - it just happens to be empty. Eg:\n // <script ... src = \"/static/sanity-a3cc3d86.js\"></script>\n // Which differs from not being able to find the script tag at all, in which\n // case we'll want to show a warning to indicate that it is an abnormality.\n return basePath === '' ? '/' : basePath\n}\n"],"names":["__dirname","path","dirname","fileURLToPath","import","url","debug","serverDebug","extend","buildStaticFiles","options","cwd","outputDir","sourceMap","minify","basePath","vite","extendViteConfig","importMap","reactCompiler","entry","isApp","writeSanityRuntime","reactStrictMode","watch","mode","viteConfig","getViteConfig","extendViteConfigWithUserConfig","command","finalizeViteConfig","staticPath","join","copyDir","faviconBasePath","replace","writeFavicons","build","bundle","Array","isArray","chunks","stats","output","forEach","chunk","type","push","name","modules","Object","entries","map","rawFilePath","chunkModule","filePath","startsWith","slice","isAbsolute","relative","originalLength","renderedLength","srcDir","destDir","skipExisting","fs","mkdir","recursive","file","tryReadDir","srcFile","resolve","destFile","stat","isDirectory","copyFile","fsConstants","COPYFILE_EXCL","catch","skipIfExistsError","dir","readdir","err","code","sanityPkgPath","readPkgUp","faviconsPath","undefined","Error","writeWebManifest","content","JSON","stringify","generateWebManifest","writeFile","sanityBasePathRedirectPlugin","apply","configurePreviewServer","vitePreviewServer","middlewares","use","req","res","next","writeHead","Location","end","startPreviewServer","httpPort","httpHost","root","startTime","Date","now","indexPath","index","readFile","tryResolveBasePathFromIndex","error","previewConfig","base","plugins","configFile","preview","port","host","strictPort","outDir","server","warn","config","logger","info","resolvedUrls","local","chalk","cyan","startupDuration","version","Math","ceil","urls","close","Promise","reject","httpServer","match"],"mappings":";;;;;;;;AAaA,MAAMA,cAAYC,KAAKC,QAAQC,cAAcC,YAAYC,GAAG,CAAC,GAEvDC,UAAQC,QAAYC,OAAO,QAAQ;AA4BzC,eAAsBC,iBACpBC,SACiC;AACjC,QAAM;AAAA,IACJC;AAAAA,IACAC;AAAAA,IACAC,YAAY;AAAA,IACZC,SAAS;AAAA,IACTC;AAAAA,IACAC,MAAMC;AAAAA,IACNC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,EAAAA,IACEX;AAEJJ,UAAM,8BAA8B,GACpC,MAAMgB,mBAAmB;AAAA,IACvBX;AAAAA,IACAY,iBAAiB;AAAA,IACjBC,OAAO;AAAA,IACPT;AAAAA,IACAK;AAAAA,IACAC;AAAAA,EAAAA,CACD,GAEDf,QAAM,uBAAuB;AAC7B,QAAMmB,OAAO;AACb,MAAIC,aAAa,MAAMC,cAAc;AAAA,IACnChB;AAAAA,IACAI;AAAAA,IACAH;AAAAA,IACAE;AAAAA,IACAD;AAAAA,IACAY;AAAAA,IACAP;AAAAA,IACAC;AAAAA,IACAE;AAAAA,EAAAA,CACD;AAGGJ,uBACFS,aAAa,MAAME,+BACjB;AAAA,IAACC,SAAS;AAAA,IAASJ;AAAAA,EAAAA,GACnBC,YACAT,gBACF,GACAS,aAAa,MAAMI,mBAAmBJ,UAAU,IAIlDpB,QAAM,iDAAiD;AACvD,QAAMyB,aAAa9B,KAAK+B,KAAKpB,WAAW,QAAQ;AAChD,QAAMqB,QAAQhC,KAAK+B,KAAKrB,KAAK,QAAQ,GAAGoB,UAAU,GAGlDzB,QAAM,gCAAgC;AACtC,QAAM4B,kBAAkB,GAAGnB,SAASoB,QAAQ,QAAQ,EAAE,CAAC;AACvD,QAAMC,cAAcF,iBAAiBH,UAAU,GAE/CzB,QAAM,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AAA,IAAAA;AAAAA,IAEVrF;AAAAA,EAAAA;AAIER,uBACFsG,gBAAgB,MAAM3F,+BACpB;AAAA,IAACC,SAAS;AAAA,IAASJ;AAAAA,EAAAA,GACnB8F,eACAtG,gBACF,IAGFX,MAAM,sBAAsB;AAC5B,QAAM;AAAA,IAACqH;AAAAA,EAAAA,IAAW,MAAM,OAAO,MAAM,GAC/BK,SAAS,MAAML,QAAQJ,aAAa,GACpCU,OAAOD,OAAOE,OAAOC,OAAOF,MAC5BG,OAAOJ,OAAOE,OAAOC,OAAOC,MAC5B/H,MAAM2H,OAAOK,aAAcC,MAAM,CAAC;AAEpC,SAAOvH,WAAa,MACtBkH,KAAK,qEAAqE,IACjElH,YAAYA,aAAa,OAClCqH,KAAK,+CAA+CG,MAAMC,KAAKzH,QAAQ,CAAC,EAAE;AAG5E,QAAM0H,kBAAkBzB,KAAKC,IAAAA,IAAQF;AAErCqB,SAAAA,KACE,UAAU/G,QAAQ,gBAAgB,QAAQ,UAC/BkH,MAAMC,KAAK,QAAQE,OAAO,EAAE,CAAC,aAC1BH,MAAMC,KAAK,GAAGG,KAAKC,KAAKH,eAAe,CAAC,IAAI,CAAC,mBACvCF,MAAMC,KAAKnI,GAAG,CAAC,4BACrC,GAEO;AAAA,IACLwI,MAAMb,OAAOK;AAAAA,IACbS,OAAOA,MACL,IAAIC,QAAQ,CAACxE,SAASyE,WACpBhB,OAAOiB,WAAWH,MAAO5D,SAASA,MAAM8D,OAAO9D,GAAG,IAAIX,SAAU,CAClE;AAAA,EAAA;AAEN;AAEA,SAAS8C,4BAA4BF,OAAmC;AAEtE,QAAMpG,WAAWoG,MAAM+B,MAAM,yCAAyC,IAAI,CAAC;AAK3E,MAAI,SAAOnI,WAAa;AASxB,WAAOA,aAAa,KAAK,MAAMA;AACjC;"}
@@ -1,4 +1,5 @@
1
1
  import path from "node:path";
2
+ import { fileURLToPath } from "node:url";
2
3
  import debug$4 from "debug";
3
4
  import readPkgUp from "read-pkg-up";
4
5
  import escapeRegExp from "lodash/escapeRegExp.js";
@@ -9,7 +10,6 @@ import fs$1 from "node:fs/promises";
9
10
  import chokidar from "chokidar";
10
11
  import { jsxs, Fragment, jsx } from "react/jsx-runtime";
11
12
  import fs from "node:fs";
12
- import { fileURLToPath } from "node:url";
13
13
  import { Worker, parentPort, isMainThread, workerData } from "node:worker_threads";
14
14
  import chalk from "chalk";
15
15
  import importFresh from "import-fresh";
@@ -65,7 +65,7 @@ async function loadSanityMonorepo(cwd) {
65
65
  function Favicons() {
66
66
  const $ = c(1);
67
67
  let t0;
68
- return $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsxs(Fragment, { children: [
68
+ return $[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsxs(Fragment, { children: [
69
69
  /* @__PURE__ */ jsx("link", { rel: "icon", href: "/static/favicon.ico", sizes: "any" }),
70
70
  /* @__PURE__ */ jsx("link", { rel: "icon", href: "/static/favicon.svg", type: "image/svg+xml" }),
71
71
  /* @__PURE__ */ jsx("link", { rel: "apple-touch-icon", href: "/static/apple-touch-icon.png" }),
@@ -202,7 +202,7 @@ const errorHandlerScript = `
202
202
  function GlobalErrorHandler() {
203
203
  const $ = c(1);
204
204
  let t0;
205
- return $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsx("script", { dangerouslySetInnerHTML: {
205
+ return $[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsx("script", { dangerouslySetInnerHTML: {
206
206
  __html: errorHandlerScript
207
207
  } }), $[0] = t0) : t0 = $[0], t0;
208
208
  }
@@ -228,9 +228,9 @@ const NoJsStyles = `
228
228
  function NoJavascript() {
229
229
  const $ = c(3);
230
230
  let t0, t1;
231
- $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsx("style", { type: "text/css", children: NoJsStyles }), t1 = /* @__PURE__ */ jsx("h1", { children: "JavaScript disabled" }), $[0] = t0, $[1] = t1) : (t0 = $[0], t1 = $[1]);
231
+ $[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsx("style", { type: "text/css", children: NoJsStyles }), t1 = /* @__PURE__ */ jsx("h1", { children: "JavaScript disabled" }), $[0] = t0, $[1] = t1) : (t0 = $[0], t1 = $[1]);
232
232
  let t2;
233
- return $[2] === Symbol.for("react.memo_cache_sentinel") ? (t2 = /* @__PURE__ */ jsx("noscript", { children: /* @__PURE__ */ jsx("div", { className: "sanity-app-no-js__root", children: /* @__PURE__ */ jsxs("div", { className: "sanity-app-no-js__content", children: [
233
+ return $[2] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t2 = /* @__PURE__ */ jsx("noscript", { children: /* @__PURE__ */ jsx("div", { className: "sanity-app-no-js__root", children: /* @__PURE__ */ jsxs("div", { className: "sanity-app-no-js__content", children: [
234
234
  t0,
235
235
  t1,
236
236
  /* @__PURE__ */ jsxs("p", { children: [
@@ -247,7 +247,7 @@ function BasicDocument(props) {
247
247
  css: t0
248
248
  } = props, css = t0 === void 0 ? EMPTY_ARRAY$1 : t0;
249
249
  let t1, t2, t3, t4, t5, t6, t7;
250
- $[0] === Symbol.for("react.memo_cache_sentinel") ? (t1 = /* @__PURE__ */ jsx("meta", { charSet: "utf-8" }), t2 = /* @__PURE__ */ jsx("meta", { name: "viewport", content: "width=device-width, initial-scale=1, viewport-fit=cover" }), t3 = /* @__PURE__ */ jsx("meta", { name: "robots", content: "noindex" }), t4 = /* @__PURE__ */ jsx("meta", { name: "referrer", content: "same-origin" }), t5 = /* @__PURE__ */ jsx(Favicons, {}), t6 = /* @__PURE__ */ jsx("title", { children: "Sanity Custom App" }), t7 = /* @__PURE__ */ jsx(GlobalErrorHandler, {}), $[0] = t1, $[1] = t2, $[2] = t3, $[3] = t4, $[4] = t5, $[5] = t6, $[6] = t7) : (t1 = $[0], t2 = $[1], t3 = $[2], t4 = $[3], t5 = $[4], t6 = $[5], t7 = $[6]);
250
+ $[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t1 = /* @__PURE__ */ jsx("meta", { charSet: "utf-8" }), t2 = /* @__PURE__ */ jsx("meta", { name: "viewport", content: "width=device-width, initial-scale=1, viewport-fit=cover" }), t3 = /* @__PURE__ */ jsx("meta", { name: "robots", content: "noindex" }), t4 = /* @__PURE__ */ jsx("meta", { name: "referrer", content: "same-origin" }), t5 = /* @__PURE__ */ jsx(Favicons, {}), t6 = /* @__PURE__ */ jsx("title", { children: "Sanity Custom App" }), t7 = /* @__PURE__ */ jsx(GlobalErrorHandler, {}), $[0] = t1, $[1] = t2, $[2] = t3, $[3] = t4, $[4] = t5, $[5] = t6, $[6] = t7) : (t1 = $[0], t2 = $[1], t3 = $[2], t4 = $[3], t5 = $[4], t6 = $[5], t7 = $[6]);
251
251
  let t8;
252
252
  $[7] !== css ? (t8 = css.map(_temp$1), $[7] = css, $[8] = t8) : t8 = $[8];
253
253
  let t9;
@@ -262,11 +262,11 @@ function BasicDocument(props) {
262
262
  t8
263
263
  ] }), $[9] = t8, $[10] = t9) : t9 = $[10];
264
264
  let t10;
265
- $[11] === Symbol.for("react.memo_cache_sentinel") ? (t10 = /* @__PURE__ */ jsx("div", { id: "root" }), $[11] = t10) : t10 = $[11];
265
+ $[11] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t10 = /* @__PURE__ */ jsx("div", { id: "root" }), $[11] = t10) : t10 = $[11];
266
266
  let t11;
267
267
  $[12] !== entryPath ? (t11 = /* @__PURE__ */ jsx("script", { type: "module", src: entryPath }), $[12] = entryPath, $[13] = t11) : t11 = $[13];
268
268
  let t12;
269
- $[14] === Symbol.for("react.memo_cache_sentinel") ? (t12 = /* @__PURE__ */ jsx(NoJavascript, {}), $[14] = t12) : t12 = $[14];
269
+ $[14] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t12 = /* @__PURE__ */ jsx(NoJavascript, {}), $[14] = t12) : t12 = $[14];
270
270
  let t13;
271
271
  $[15] !== t11 ? (t13 = /* @__PURE__ */ jsxs("body", { children: [
272
272
  t10,
@@ -391,11 +391,11 @@ function DefaultDocument(props) {
391
391
  css: t0
392
392
  } = props, css = t0 === void 0 ? EMPTY_ARRAY : t0;
393
393
  let t1, t2, t3, t4, t5, t6, t7;
394
- $[0] === Symbol.for("react.memo_cache_sentinel") ? (t1 = /* @__PURE__ */ jsx("meta", { charSet: "utf-8" }), t2 = /* @__PURE__ */ jsx("meta", { name: "viewport", content: "width=device-width, initial-scale=1, maximum-scale=1, viewport-fit=cover" }), t3 = /* @__PURE__ */ jsx("meta", { name: "robots", content: "noindex" }), t4 = /* @__PURE__ */ jsx("meta", { name: "referrer", content: "same-origin" }), t5 = /* @__PURE__ */ jsx(Favicons, {}), t6 = /* @__PURE__ */ jsx("title", { children: "Sanity Studio" }), t7 = /* @__PURE__ */ jsx(GlobalErrorHandler, {}), $[0] = t1, $[1] = t2, $[2] = t3, $[3] = t4, $[4] = t5, $[5] = t6, $[6] = t7) : (t1 = $[0], t2 = $[1], t3 = $[2], t4 = $[3], t5 = $[4], t6 = $[5], t7 = $[6]);
394
+ $[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t1 = /* @__PURE__ */ jsx("meta", { charSet: "utf-8" }), t2 = /* @__PURE__ */ jsx("meta", { name: "viewport", content: "width=device-width, initial-scale=1, maximum-scale=1, viewport-fit=cover" }), t3 = /* @__PURE__ */ jsx("meta", { name: "robots", content: "noindex" }), t4 = /* @__PURE__ */ jsx("meta", { name: "referrer", content: "same-origin" }), t5 = /* @__PURE__ */ jsx(Favicons, {}), t6 = /* @__PURE__ */ jsx("title", { children: "Sanity Studio" }), t7 = /* @__PURE__ */ jsx(GlobalErrorHandler, {}), $[0] = t1, $[1] = t2, $[2] = t3, $[3] = t4, $[4] = t5, $[5] = t6, $[6] = t7) : (t1 = $[0], t2 = $[1], t3 = $[2], t4 = $[3], t5 = $[4], t6 = $[5], t7 = $[6]);
395
395
  let t8;
396
396
  $[7] !== css ? (t8 = css.map(_temp), $[7] = css, $[8] = t8) : t8 = $[8];
397
397
  let t9;
398
- $[9] === Symbol.for("react.memo_cache_sentinel") ? (t9 = /* @__PURE__ */ jsx("style", { dangerouslySetInnerHTML: {
398
+ $[9] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t9 = /* @__PURE__ */ jsx("style", { dangerouslySetInnerHTML: {
399
399
  __html: globalStyles
400
400
  } }), $[9] = t9) : t9 = $[9];
401
401
  let t10;
@@ -411,11 +411,11 @@ function DefaultDocument(props) {
411
411
  t9
412
412
  ] }), $[10] = t8, $[11] = t10) : t10 = $[11];
413
413
  let t11;
414
- $[12] === Symbol.for("react.memo_cache_sentinel") ? (t11 = /* @__PURE__ */ jsx("div", { id: "sanity" }), $[12] = t11) : t11 = $[12];
414
+ $[12] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t11 = /* @__PURE__ */ jsx("div", { id: "sanity" }), $[12] = t11) : t11 = $[12];
415
415
  let t12;
416
416
  $[13] !== entryPath ? (t12 = /* @__PURE__ */ jsx("script", { type: "module", src: entryPath }), $[13] = entryPath, $[14] = t12) : t12 = $[14];
417
417
  let t13;
418
- $[15] === Symbol.for("react.memo_cache_sentinel") ? (t13 = /* @__PURE__ */ jsx(NoJavascript, {}), $[15] = t13) : t13 = $[15];
418
+ $[15] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t13 = /* @__PURE__ */ jsx(NoJavascript, {}), $[15] = t13) : t13 = $[15];
419
419
  let t14;
420
420
  $[16] !== t12 ? (t14 = /* @__PURE__ */ jsxs("body", { children: [
421
421
  t11,
@@ -765,7 +765,7 @@ function sanityRuntimeRewritePlugin() {
765
765
  }
766
766
  };
767
767
  }
768
- const __dirname$1 = path.dirname(new URL(import.meta.url).pathname);
768
+ const __dirname$1 = path.dirname(fileURLToPath(import.meta.url));
769
769
  async function getViteConfig(options) {
770
770
  const {
771
771
  cwd,
@@ -844,6 +844,7 @@ async function getViteConfig(options) {
844
844
  },
845
845
  define: {
846
846
  __SANITY_STAGING__: process.env.SANITY_INTERNAL_ENV === "staging",
847
+ __SANITY_BUILD_TIMESTAMP__: JSON.stringify(Date.now()),
847
848
  "process.env.PKG_BUILD_VERSION": JSON.stringify(process.env.PKG_BUILD_VERSION),
848
849
  "process.env.MODE": JSON.stringify(mode),
849
850
  /**