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.
Files changed (63) hide show
  1. package/lib/_chunks-cjs/PostMessageSchema.js.map +1 -1
  2. package/lib/_chunks-cjs/PostMessageTelemetry.js +1 -1
  3. package/lib/_chunks-cjs/PostMessageTelemetry.js.map +1 -1
  4. package/lib/_chunks-cjs/PresentationToolGrantsCheck.js +429 -1417
  5. package/lib/_chunks-cjs/PresentationToolGrantsCheck.js.map +1 -1
  6. package/lib/_chunks-cjs/presentation.js +70 -22
  7. package/lib/_chunks-cjs/presentation.js.map +1 -1
  8. package/lib/_chunks-cjs/resources6.js +0 -8
  9. package/lib/_chunks-cjs/resources6.js.map +1 -1
  10. package/lib/_chunks-cjs/version.js +1 -1
  11. package/lib/_chunks-es/PostMessageSchema.mjs.map +1 -1
  12. package/lib/_chunks-es/PostMessageTelemetry.mjs +1 -1
  13. package/lib/_chunks-es/PostMessageTelemetry.mjs.map +1 -1
  14. package/lib/_chunks-es/PresentationToolGrantsCheck.mjs +437 -1406
  15. package/lib/_chunks-es/PresentationToolGrantsCheck.mjs.map +1 -1
  16. package/lib/_chunks-es/presentation.mjs +73 -24
  17. package/lib/_chunks-es/presentation.mjs.map +1 -1
  18. package/lib/_chunks-es/resources6.mjs +0 -8
  19. package/lib/_chunks-es/resources6.mjs.map +1 -1
  20. package/lib/_chunks-es/version.mjs +1 -1
  21. package/lib/_singletons.d.mts +61 -2889
  22. package/lib/_singletons.d.ts +61 -2889
  23. package/lib/presentation.d.mts +57 -2887
  24. package/lib/presentation.d.ts +57 -2887
  25. package/lib/presentation.js +4 -0
  26. package/lib/presentation.js.map +1 -1
  27. package/lib/presentation.mjs +5 -1
  28. package/package.json +15 -16
  29. package/src/presentation/PostMessageTelemetry.tsx +1 -1
  30. package/src/presentation/PresentationTool.tsx +76 -85
  31. package/src/presentation/PresentationToolGrantsCheck.tsx +75 -39
  32. package/src/presentation/document/LocationsBanner.tsx +13 -52
  33. package/src/presentation/i18n/resources.ts +0 -10
  34. package/src/presentation/index.ts +13 -0
  35. package/src/presentation/{util → lib}/parse.ts +1 -2
  36. package/src/presentation/overlays/schema/PostMessageSchema.tsx +0 -1
  37. package/src/presentation/panels/usePanelsStorage.ts +1 -1
  38. package/src/presentation/preview/IFrame.tsx +35 -83
  39. package/src/presentation/preview/Preview.tsx +56 -172
  40. package/src/presentation/preview/PreviewHeader.tsx +10 -43
  41. package/src/presentation/preview/PreviewLocationInput.tsx +24 -48
  42. package/src/presentation/preview/SharePreviewMenu.tsx +2 -2
  43. package/src/presentation/reducers/presentationReducer.ts +134 -0
  44. package/src/presentation/types.ts +7 -139
  45. package/src/presentation/useMainDocument.ts +12 -4
  46. package/src/presentation/useParams.ts +3 -2
  47. package/src/presentation/usePreviewUrl.ts +133 -0
  48. package/src/presentation/actors/create-preview-secret.ts +0 -19
  49. package/src/presentation/actors/read-shared-secret.ts +0 -18
  50. package/src/presentation/actors/resolve-allow-patterns.ts +0 -55
  51. package/src/presentation/actors/resolve-initial-url.ts +0 -65
  52. package/src/presentation/actors/resolve-preview-mode-url.ts +0 -72
  53. package/src/presentation/actors/resolve-preview-mode.ts +0 -66
  54. package/src/presentation/actors/resolve-url-from-preview-search-param.ts +0 -29
  55. package/src/presentation/machines/presentation-machine.ts +0 -101
  56. package/src/presentation/machines/preview-url.ts +0 -568
  57. package/src/presentation/useAllowPatterns.ts +0 -12
  58. package/src/presentation/useId.ts +0 -7
  59. package/src/presentation/usePresentationPerspective.ts +0 -14
  60. package/src/presentation/usePreviewUrlActorRef.ts +0 -96
  61. package/src/presentation/useReportInvalidPreviewSearchParam.tsx +0 -43
  62. package/src/presentation/useTargetOrigin.ts +0 -11
  63. /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