sanity 3.83.1-canary.23 → 3.84.1-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/_chunks-cjs/PostMessageSchema.js.map +1 -1
- package/lib/_chunks-cjs/PostMessageTelemetry.js +1 -1
- package/lib/_chunks-cjs/PostMessageTelemetry.js.map +1 -1
- package/lib/_chunks-cjs/PresentationToolGrantsCheck.js +429 -1417
- package/lib/_chunks-cjs/PresentationToolGrantsCheck.js.map +1 -1
- package/lib/_chunks-cjs/presentation.js +70 -22
- package/lib/_chunks-cjs/presentation.js.map +1 -1
- package/lib/_chunks-cjs/resources6.js +0 -8
- package/lib/_chunks-cjs/resources6.js.map +1 -1
- package/lib/_chunks-cjs/version.js +1 -1
- package/lib/_chunks-es/PostMessageSchema.mjs.map +1 -1
- package/lib/_chunks-es/PostMessageTelemetry.mjs +1 -1
- package/lib/_chunks-es/PostMessageTelemetry.mjs.map +1 -1
- package/lib/_chunks-es/PresentationToolGrantsCheck.mjs +437 -1406
- package/lib/_chunks-es/PresentationToolGrantsCheck.mjs.map +1 -1
- package/lib/_chunks-es/presentation.mjs +73 -24
- package/lib/_chunks-es/presentation.mjs.map +1 -1
- package/lib/_chunks-es/resources6.mjs +0 -8
- package/lib/_chunks-es/resources6.mjs.map +1 -1
- package/lib/_chunks-es/version.mjs +1 -1
- package/lib/_singletons.d.mts +61 -2889
- package/lib/_singletons.d.ts +61 -2889
- package/lib/presentation.d.mts +57 -2887
- package/lib/presentation.d.ts +57 -2887
- package/lib/presentation.js +4 -0
- package/lib/presentation.js.map +1 -1
- package/lib/presentation.mjs +5 -1
- package/package.json +15 -16
- package/src/presentation/PostMessageTelemetry.tsx +1 -1
- package/src/presentation/PresentationTool.tsx +76 -85
- package/src/presentation/PresentationToolGrantsCheck.tsx +75 -39
- package/src/presentation/document/LocationsBanner.tsx +13 -52
- package/src/presentation/i18n/resources.ts +0 -10
- package/src/presentation/index.ts +13 -0
- package/src/presentation/{util → lib}/parse.ts +1 -2
- package/src/presentation/overlays/schema/PostMessageSchema.tsx +0 -1
- package/src/presentation/panels/usePanelsStorage.ts +1 -1
- package/src/presentation/preview/IFrame.tsx +35 -83
- package/src/presentation/preview/Preview.tsx +56 -172
- package/src/presentation/preview/PreviewHeader.tsx +10 -43
- package/src/presentation/preview/PreviewLocationInput.tsx +24 -48
- package/src/presentation/preview/SharePreviewMenu.tsx +2 -2
- package/src/presentation/reducers/presentationReducer.ts +134 -0
- package/src/presentation/types.ts +7 -139
- package/src/presentation/useMainDocument.ts +12 -4
- package/src/presentation/useParams.ts +3 -2
- package/src/presentation/usePreviewUrl.ts +133 -0
- package/src/presentation/actors/create-preview-secret.ts +0 -19
- package/src/presentation/actors/read-shared-secret.ts +0 -18
- package/src/presentation/actors/resolve-allow-patterns.ts +0 -55
- package/src/presentation/actors/resolve-initial-url.ts +0 -65
- package/src/presentation/actors/resolve-preview-mode-url.ts +0 -72
- package/src/presentation/actors/resolve-preview-mode.ts +0 -66
- package/src/presentation/actors/resolve-url-from-preview-search-param.ts +0 -29
- package/src/presentation/machines/presentation-machine.ts +0 -101
- package/src/presentation/machines/preview-url.ts +0 -568
- package/src/presentation/useAllowPatterns.ts +0 -12
- package/src/presentation/useId.ts +0 -7
- package/src/presentation/usePresentationPerspective.ts +0 -14
- package/src/presentation/usePreviewUrlActorRef.ts +0 -96
- package/src/presentation/useReportInvalidPreviewSearchParam.tsx +0 -43
- package/src/presentation/useTargetOrigin.ts +0 -11
- /package/src/presentation/{util → lib}/debounce.ts +0 -0
@@ -1,43 +0,0 @@
|
|
1
|
-
import {useToast} from '@sanity/ui'
|
2
|
-
import {useSelector} from '@xstate/react'
|
3
|
-
import {useEffect} from 'react'
|
4
|
-
import {Translate, useTranslation} from 'sanity'
|
5
|
-
import {useRouter} from 'sanity/router'
|
6
|
-
|
7
|
-
import {presentationLocaleNamespace} from './i18n'
|
8
|
-
import {type PreviewUrlRef} from './machines/preview-url'
|
9
|
-
|
10
|
-
export function useReportInvalidPreviewSearchParam(previewUrlRef: PreviewUrlRef): void {
|
11
|
-
const {t} = useTranslation(presentationLocaleNamespace)
|
12
|
-
const {push: pushToast} = useToast()
|
13
|
-
const router = useRouter()
|
14
|
-
const routerSearchParams = new URLSearchParams(router.state._searchParams)
|
15
|
-
const previewSearchParam = routerSearchParams.get('preview')
|
16
|
-
|
17
|
-
const allowOrigins = useSelector(previewUrlRef, (state) => state.context.allowOrigins)
|
18
|
-
const currentOrigin = useSelector(previewUrlRef, (state) => state.context.previewUrl?.origin)
|
19
|
-
useEffect(() => {
|
20
|
-
if (!Array.isArray(allowOrigins) || !previewSearchParam || !currentOrigin) return
|
21
|
-
const nextOrigin = new URL(previewSearchParam, currentOrigin).origin
|
22
|
-
if (!allowOrigins.some((pattern) => pattern.test(nextOrigin))) {
|
23
|
-
pushToast({
|
24
|
-
closable: true,
|
25
|
-
id: `presentation-iframe-origin-mismatch-${nextOrigin}`,
|
26
|
-
status: 'error',
|
27
|
-
duration: Infinity,
|
28
|
-
title: t('preview-search-param.configuration.error.title'),
|
29
|
-
description: (
|
30
|
-
<Translate
|
31
|
-
t={t}
|
32
|
-
i18nKey="preview-search-param.configuration.error.description"
|
33
|
-
components={{Code: 'code'}}
|
34
|
-
values={{
|
35
|
-
previewSearchParam,
|
36
|
-
blockedOrigin: nextOrigin,
|
37
|
-
}}
|
38
|
-
/>
|
39
|
-
),
|
40
|
-
})
|
41
|
-
}
|
42
|
-
}, [allowOrigins, currentOrigin, previewSearchParam, pushToast, t])
|
43
|
-
}
|
@@ -1,11 +0,0 @@
|
|
1
|
-
import {useSelector} from '@xstate/react'
|
2
|
-
|
3
|
-
import {type PreviewUrlRef} from './machines/preview-url'
|
4
|
-
|
5
|
-
export function useTargetOrigin(previewUrlRef: PreviewUrlRef): string {
|
6
|
-
const targetOrigin = useSelector(previewUrlRef, (state) => state.context.previewUrl?.origin)
|
7
|
-
if (!targetOrigin) {
|
8
|
-
throw new TypeError('targetOrigin is required')
|
9
|
-
}
|
10
|
-
return targetOrigin
|
11
|
-
}
|
File without changes
|