@makeswift/runtime 0.26.2 → 0.26.3

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 (236) hide show
  1. package/dist/cjs/api-handler/handlers/manifest.js +1 -1
  2. package/dist/cjs/client/index.js +3 -3
  3. package/dist/cjs/components/builtin/Button/Button.js.map +1 -1
  4. package/dist/cjs/components/builtin/Carousel/Carousel.js.map +1 -1
  5. package/dist/cjs/components/builtin/Embed/Embed.js +3 -1
  6. package/dist/cjs/components/builtin/Embed/Embed.js.map +1 -1
  7. package/dist/cjs/components/builtin/Form/components/Field/components/Label/index.js.map +1 -1
  8. package/dist/cjs/components/builtin/Form/components/Field/components/PlaceholderTableField/index.js.map +1 -1
  9. package/dist/cjs/components/builtin/Form/components/Field/index.js.map +1 -1
  10. package/dist/cjs/components/builtin/Form/components/Placeholder/index.js.map +1 -1
  11. package/dist/cjs/components/builtin/Form/components/Spinner/index.js.map +1 -1
  12. package/dist/cjs/components/builtin/Navigation/Navigation.js.map +1 -1
  13. package/dist/cjs/components/builtin/Navigation/components/DropDownButton/index.js.map +1 -1
  14. package/dist/cjs/components/builtin/Navigation/components/LinksPlaceholder/index.js.map +1 -1
  15. package/dist/cjs/components/builtin/Navigation/components/MobileMenu/components/MobileDropDownButton/index.js.map +1 -1
  16. package/dist/cjs/components/builtin/Navigation/components/MobileMenu/index.js.map +1 -1
  17. package/dist/cjs/components/builtin/SocialLinks/components/SocialLinksPlaceholder/index.js.map +1 -1
  18. package/dist/cjs/components/shared/BackgroundsContainer/components/BackgroundVideo/index.js.map +1 -1
  19. package/dist/cjs/components/shared/BackgroundsContainer/components/Backgrounds/index.js.map +1 -1
  20. package/dist/cjs/components/shared/BackgroundsContainer/components/Parallax/index.js.map +1 -1
  21. package/dist/cjs/controls/rich-text-v2/plugin.js.map +1 -1
  22. package/dist/cjs/next/components/framework-provider/pages-router/HeadSnippet.js.map +1 -1
  23. package/dist/cjs/next/components/tests/controls/page-control-prop-rendering.js +2 -3
  24. package/dist/cjs/next/components/tests/controls/page-control-prop-rendering.js.map +1 -1
  25. package/dist/cjs/next/components/tests/makeswift-component/fixtures.js +102 -0
  26. package/dist/cjs/next/components/tests/makeswift-component/fixtures.js.map +1 -0
  27. package/dist/cjs/next/components/tests/prop-controllers/page-prop-controller.js +6 -6
  28. package/dist/cjs/next/components/tests/prop-controllers/page-prop-controller.js.map +1 -1
  29. package/dist/cjs/next/testing/page-rendering.js +3 -3
  30. package/dist/cjs/next/testing/page-rendering.js.map +1 -1
  31. package/dist/cjs/runtimes/react/components/Document.js.map +1 -1
  32. package/dist/cjs/runtimes/react/components/DocumentRoot.js.map +1 -1
  33. package/dist/cjs/runtimes/react/components/Element.js.map +1 -1
  34. package/dist/cjs/runtimes/react/components/ElementData.js +2 -2
  35. package/dist/cjs/runtimes/react/components/ElementData.js.map +1 -1
  36. package/dist/cjs/runtimes/react/components/ElementReference.js.map +1 -1
  37. package/dist/cjs/runtimes/react/components/ElementRegistration.js.map +1 -1
  38. package/dist/cjs/runtimes/react/components/LiveProvider.js.map +1 -1
  39. package/dist/cjs/runtimes/react/components/MakeswiftComponent.js +2 -2
  40. package/dist/cjs/runtimes/react/components/MakeswiftComponent.js.map +1 -1
  41. package/dist/cjs/runtimes/react/components/PreviewProvider.js.map +1 -1
  42. package/dist/cjs/runtimes/react/components/activity-with-fallback.js +54 -0
  43. package/dist/cjs/runtimes/react/components/activity-with-fallback.js.map +1 -0
  44. package/dist/cjs/runtimes/react/components/page/HeadSnippet.js.map +1 -1
  45. package/dist/cjs/runtimes/react/components/page/Page.js.map +1 -1
  46. package/dist/cjs/runtimes/react/components/page/PageHead.js.map +1 -1
  47. package/dist/cjs/runtimes/react/components/page/head-tags.js.map +1 -1
  48. package/dist/cjs/runtimes/react/components/page/index.js +2 -1
  49. package/dist/cjs/runtimes/react/components/page/index.js.map +1 -1
  50. package/dist/cjs/runtimes/react/components/render-hook.js.map +1 -1
  51. package/dist/cjs/runtimes/react/controls/control.js.map +1 -1
  52. package/dist/cjs/runtimes/react/controls/group.js.map +1 -1
  53. package/dist/cjs/runtimes/react/controls/rich-text-v2/EditableTextV2/render-leaf.js.map +1 -1
  54. package/dist/cjs/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.js.map +1 -1
  55. package/dist/cjs/runtimes/react/controls/slot.js.map +1 -1
  56. package/dist/cjs/runtimes/react/controls.js.map +1 -1
  57. package/dist/cjs/runtimes/react/find-dom-node.js +2 -0
  58. package/dist/cjs/runtimes/react/find-dom-node.js.map +1 -1
  59. package/dist/cjs/runtimes/react/hooks/makeswift-api.js +2 -2
  60. package/dist/cjs/runtimes/react/hooks/makeswift-api.js.map +1 -1
  61. package/dist/cjs/runtimes/react/legacy-controls.js.map +1 -1
  62. package/dist/cjs/runtimes/react/lib/react-dom.js +2 -1
  63. package/dist/cjs/runtimes/react/lib/react-dom.js.map +1 -1
  64. package/dist/cjs/runtimes/react/react-runtime-core.js +6 -0
  65. package/dist/cjs/runtimes/react/react-runtime-core.js.map +1 -1
  66. package/dist/cjs/runtimes/react/use-global-style.js +1 -1
  67. package/dist/cjs/runtimes/react/use-global-style.js.map +1 -1
  68. package/dist/esm/api-handler/handlers/manifest.js +1 -1
  69. package/dist/esm/client/index.js +3 -3
  70. package/dist/esm/components/builtin/Button/Button.js.map +1 -1
  71. package/dist/esm/components/builtin/Carousel/Carousel.js.map +1 -1
  72. package/dist/esm/components/builtin/Embed/Embed.js +3 -1
  73. package/dist/esm/components/builtin/Embed/Embed.js.map +1 -1
  74. package/dist/esm/components/builtin/Form/components/Field/components/Label/index.js.map +1 -1
  75. package/dist/esm/components/builtin/Form/components/Field/components/PlaceholderTableField/index.js.map +1 -1
  76. package/dist/esm/components/builtin/Form/components/Field/index.js.map +1 -1
  77. package/dist/esm/components/builtin/Form/components/Placeholder/index.js.map +1 -1
  78. package/dist/esm/components/builtin/Form/components/Spinner/index.js.map +1 -1
  79. package/dist/esm/components/builtin/Navigation/Navigation.js.map +1 -1
  80. package/dist/esm/components/builtin/Navigation/components/DropDownButton/index.js.map +1 -1
  81. package/dist/esm/components/builtin/Navigation/components/LinksPlaceholder/index.js.map +1 -1
  82. package/dist/esm/components/builtin/Navigation/components/MobileMenu/components/MobileDropDownButton/index.js.map +1 -1
  83. package/dist/esm/components/builtin/Navigation/components/MobileMenu/index.js.map +1 -1
  84. package/dist/esm/components/builtin/SocialLinks/components/SocialLinksPlaceholder/index.js.map +1 -1
  85. package/dist/esm/components/shared/BackgroundsContainer/components/BackgroundVideo/index.js.map +1 -1
  86. package/dist/esm/components/shared/BackgroundsContainer/components/Backgrounds/index.js.map +1 -1
  87. package/dist/esm/components/shared/BackgroundsContainer/components/Parallax/index.js.map +1 -1
  88. package/dist/esm/controls/rich-text-v2/plugin.js.map +1 -1
  89. package/dist/esm/next/components/framework-provider/pages-router/HeadSnippet.js.map +1 -1
  90. package/dist/esm/next/components/tests/controls/page-control-prop-rendering.js +1 -2
  91. package/dist/esm/next/components/tests/controls/page-control-prop-rendering.js.map +1 -1
  92. package/dist/esm/next/components/tests/makeswift-component/fixtures.js +61 -0
  93. package/dist/esm/next/components/tests/makeswift-component/fixtures.js.map +1 -0
  94. package/dist/esm/next/components/tests/prop-controllers/page-prop-controller.js +1 -1
  95. package/dist/esm/next/components/tests/prop-controllers/page-prop-controller.js.map +1 -1
  96. package/dist/esm/next/testing/page-rendering.js +1 -1
  97. package/dist/esm/next/testing/page-rendering.js.map +1 -1
  98. package/dist/esm/runtimes/react/components/Document.js.map +1 -1
  99. package/dist/esm/runtimes/react/components/DocumentRoot.js.map +1 -1
  100. package/dist/esm/runtimes/react/components/Element.js.map +1 -1
  101. package/dist/esm/runtimes/react/components/ElementData.js +3 -3
  102. package/dist/esm/runtimes/react/components/ElementData.js.map +1 -1
  103. package/dist/esm/runtimes/react/components/ElementReference.js.map +1 -1
  104. package/dist/esm/runtimes/react/components/ElementRegistration.js.map +1 -1
  105. package/dist/esm/runtimes/react/components/LiveProvider.js.map +1 -1
  106. package/dist/esm/runtimes/react/components/MakeswiftComponent.js +3 -3
  107. package/dist/esm/runtimes/react/components/MakeswiftComponent.js.map +1 -1
  108. package/dist/esm/runtimes/react/components/PreviewProvider.js.map +1 -1
  109. package/dist/esm/runtimes/react/components/activity-with-fallback.js +19 -0
  110. package/dist/esm/runtimes/react/components/activity-with-fallback.js.map +1 -0
  111. package/dist/esm/runtimes/react/components/page/HeadSnippet.js.map +1 -1
  112. package/dist/esm/runtimes/react/components/page/Page.js.map +1 -1
  113. package/dist/esm/runtimes/react/components/page/PageHead.js.map +1 -1
  114. package/dist/esm/runtimes/react/components/page/head-tags.js.map +1 -1
  115. package/dist/esm/runtimes/react/components/page/index.js +3 -2
  116. package/dist/esm/runtimes/react/components/page/index.js.map +1 -1
  117. package/dist/esm/runtimes/react/components/render-hook.js.map +1 -1
  118. package/dist/esm/runtimes/react/controls/control.js.map +1 -1
  119. package/dist/esm/runtimes/react/controls/group.js.map +1 -1
  120. package/dist/esm/runtimes/react/controls/rich-text-v2/EditableTextV2/render-leaf.js.map +1 -1
  121. package/dist/esm/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.js.map +1 -1
  122. package/dist/esm/runtimes/react/controls/slot.js.map +1 -1
  123. package/dist/esm/runtimes/react/controls.js.map +1 -1
  124. package/dist/esm/runtimes/react/find-dom-node.js +2 -0
  125. package/dist/esm/runtimes/react/find-dom-node.js.map +1 -1
  126. package/dist/esm/runtimes/react/hooks/makeswift-api.js +2 -2
  127. package/dist/esm/runtimes/react/hooks/makeswift-api.js.map +1 -1
  128. package/dist/esm/runtimes/react/legacy-controls.js.map +1 -1
  129. package/dist/esm/runtimes/react/lib/react-dom.js +2 -1
  130. package/dist/esm/runtimes/react/lib/react-dom.js.map +1 -1
  131. package/dist/esm/runtimes/react/react-runtime-core.js +6 -0
  132. package/dist/esm/runtimes/react/react-runtime-core.js.map +1 -1
  133. package/dist/esm/runtimes/react/use-global-style.js +1 -1
  134. package/dist/esm/runtimes/react/use-global-style.js.map +1 -1
  135. package/dist/types/components/builtin/Button/Button.d.ts +2 -2
  136. package/dist/types/components/builtin/Button/Button.d.ts.map +1 -1
  137. package/dist/types/components/builtin/Carousel/Carousel.d.ts.map +1 -1
  138. package/dist/types/components/builtin/Embed/Embed.d.ts.map +1 -1
  139. package/dist/types/components/builtin/Form/components/Field/components/Label/index.d.ts +2 -2
  140. package/dist/types/components/builtin/Form/components/Field/components/Label/index.d.ts.map +1 -1
  141. package/dist/types/components/builtin/Form/components/Field/components/PlaceholderTableField/index.d.ts +2 -1
  142. package/dist/types/components/builtin/Form/components/Field/components/PlaceholderTableField/index.d.ts.map +1 -1
  143. package/dist/types/components/builtin/Form/components/Field/index.d.ts +2 -1
  144. package/dist/types/components/builtin/Form/components/Field/index.d.ts.map +1 -1
  145. package/dist/types/components/builtin/Form/components/Spinner/index.d.ts +2 -1
  146. package/dist/types/components/builtin/Form/components/Spinner/index.d.ts.map +1 -1
  147. package/dist/types/components/builtin/Navigation/components/DropDownButton/index.d.ts +2 -2
  148. package/dist/types/components/builtin/Navigation/components/DropDownButton/index.d.ts.map +1 -1
  149. package/dist/types/components/builtin/Navigation/components/LinksPlaceholder/index.d.ts +2 -1
  150. package/dist/types/components/builtin/Navigation/components/LinksPlaceholder/index.d.ts.map +1 -1
  151. package/dist/types/components/builtin/Navigation/components/MobileMenu/components/MobileDropDownButton/index.d.ts +2 -2
  152. package/dist/types/components/builtin/Navigation/components/MobileMenu/components/MobileDropDownButton/index.d.ts.map +1 -1
  153. package/dist/types/components/builtin/Navigation/components/MobileMenu/index.d.ts +2 -1
  154. package/dist/types/components/builtin/Navigation/components/MobileMenu/index.d.ts.map +1 -1
  155. package/dist/types/components/builtin/SocialLinks/components/SocialLinksPlaceholder/index.d.ts +2 -1
  156. package/dist/types/components/builtin/SocialLinks/components/SocialLinksPlaceholder/index.d.ts.map +1 -1
  157. package/dist/types/components/shared/BackgroundsContainer/components/BackgroundVideo/index.d.ts +2 -1
  158. package/dist/types/components/shared/BackgroundsContainer/components/BackgroundVideo/index.d.ts.map +1 -1
  159. package/dist/types/components/shared/BackgroundsContainer/components/Backgrounds/index.d.ts +2 -1
  160. package/dist/types/components/shared/BackgroundsContainer/components/Backgrounds/index.d.ts.map +1 -1
  161. package/dist/types/components/shared/BackgroundsContainer/components/Parallax/index.d.ts +1 -1
  162. package/dist/types/components/shared/BackgroundsContainer/components/Parallax/index.d.ts.map +1 -1
  163. package/dist/types/components/shared/ErrorBoundary.d.ts +1 -1
  164. package/dist/types/controls/rich-text-v2/plugin.d.ts +7 -7
  165. package/dist/types/controls/rich-text-v2/plugin.d.ts.map +1 -1
  166. package/dist/types/next/components/tests/controls/page-control-prop-rendering.d.ts.map +1 -1
  167. package/dist/types/next/components/tests/global-element-rendering.test.d.ts +1 -1
  168. package/dist/types/next/components/tests/global-element-rendering.test.d.ts.map +1 -1
  169. package/dist/types/next/components/tests/makeswift-component/fixtures.d.ts +27 -0
  170. package/dist/types/next/components/tests/makeswift-component/fixtures.d.ts.map +1 -0
  171. package/dist/types/next/components/tests/{makeswift-component-rendering.test.d.ts → makeswift-component/rendering.react18.test.d.ts} +1 -1
  172. package/dist/types/next/components/tests/makeswift-component/rendering.react18.test.d.ts.map +1 -0
  173. package/dist/types/next/components/tests/makeswift-component/rendering.test.d.ts +3 -0
  174. package/dist/types/next/components/tests/makeswift-component/rendering.test.d.ts.map +1 -0
  175. package/dist/types/next/testing/page-rendering.d.ts.map +1 -1
  176. package/dist/types/runtimes/react/components/Document.d.ts +1 -1
  177. package/dist/types/runtimes/react/components/Document.d.ts.map +1 -1
  178. package/dist/types/runtimes/react/components/DocumentRoot.d.ts +1 -1
  179. package/dist/types/runtimes/react/components/DocumentRoot.d.ts.map +1 -1
  180. package/dist/types/runtimes/react/components/Element.d.ts +1 -1
  181. package/dist/types/runtimes/react/components/Element.d.ts.map +1 -1
  182. package/dist/types/runtimes/react/components/ElementData.d.ts +1 -1
  183. package/dist/types/runtimes/react/components/ElementData.d.ts.map +1 -1
  184. package/dist/types/runtimes/react/components/ElementReference.d.ts +1 -1
  185. package/dist/types/runtimes/react/components/ElementReference.d.ts.map +1 -1
  186. package/dist/types/runtimes/react/components/LiveProvider.d.ts +2 -2
  187. package/dist/types/runtimes/react/components/LiveProvider.d.ts.map +1 -1
  188. package/dist/types/runtimes/react/components/MakeswiftComponent.d.ts.map +1 -1
  189. package/dist/types/runtimes/react/components/PreviewProvider.d.ts +2 -2
  190. package/dist/types/runtimes/react/components/PreviewProvider.d.ts.map +1 -1
  191. package/dist/types/runtimes/react/components/activity-with-fallback.d.ts +13 -0
  192. package/dist/types/runtimes/react/components/activity-with-fallback.d.ts.map +1 -0
  193. package/dist/types/runtimes/react/components/page/HeadSnippet.d.ts +2 -1
  194. package/dist/types/runtimes/react/components/page/HeadSnippet.d.ts.map +1 -1
  195. package/dist/types/runtimes/react/components/page/Page.d.ts +2 -1
  196. package/dist/types/runtimes/react/components/page/Page.d.ts.map +1 -1
  197. package/dist/types/runtimes/react/components/page/PageHead.d.ts +2 -1
  198. package/dist/types/runtimes/react/components/page/PageHead.d.ts.map +1 -1
  199. package/dist/types/runtimes/react/components/page/head-tags.d.ts.map +1 -1
  200. package/dist/types/runtimes/react/components/page/index.d.ts.map +1 -1
  201. package/dist/types/runtimes/react/components/render-hook.d.ts +3 -2
  202. package/dist/types/runtimes/react/components/render-hook.d.ts.map +1 -1
  203. package/dist/types/runtimes/react/controls/control.d.ts +3 -2
  204. package/dist/types/runtimes/react/controls/control.d.ts.map +1 -1
  205. package/dist/types/runtimes/react/controls/group.d.ts +3 -2
  206. package/dist/types/runtimes/react/controls/group.d.ts.map +1 -1
  207. package/dist/types/runtimes/react/controls/rich-text-v2/EditableTextV2/render-leaf.d.ts +2 -1
  208. package/dist/types/runtimes/react/controls/rich-text-v2/EditableTextV2/render-leaf.d.ts.map +1 -1
  209. package/dist/types/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.d.ts +2 -1
  210. package/dist/types/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.d.ts.map +1 -1
  211. package/dist/types/runtimes/react/controls/slot.d.ts +2 -2
  212. package/dist/types/runtimes/react/controls/slot.d.ts.map +1 -1
  213. package/dist/types/runtimes/react/controls.d.ts +3 -2
  214. package/dist/types/runtimes/react/controls.d.ts.map +1 -1
  215. package/dist/types/runtimes/react/find-dom-node.d.ts.map +1 -1
  216. package/dist/types/runtimes/react/legacy-controls.d.ts +2 -1
  217. package/dist/types/runtimes/react/legacy-controls.d.ts.map +1 -1
  218. package/dist/types/runtimes/react/lib/react-dom.d.ts.map +1 -1
  219. package/dist/types/runtimes/react/react-runtime-core.d.ts +5 -0
  220. package/dist/types/runtimes/react/react-runtime-core.d.ts.map +1 -1
  221. package/dist/types/slate/BlockPlugin/index.d.ts +2 -2
  222. package/dist/types/slate/InlineModePlugin/index.d.ts +2 -2
  223. package/dist/types/slate/InlinePlugin/index.d.ts +2 -2
  224. package/dist/types/slate/LinkPlugin/index.d.ts +2 -2
  225. package/dist/types/slate/TextAlignPlugin/index.d.ts +2 -2
  226. package/dist/types/slate/TypographyPlugin/index.d.ts +2 -2
  227. package/dist/types/slate/test-helpers/editor-v1.d.ts +1 -0
  228. package/dist/types/slate/test-helpers/editor-v1.d.ts.map +1 -1
  229. package/dist/types/slate/test-helpers/editor-v2-inline.d.ts +1 -0
  230. package/dist/types/slate/test-helpers/editor-v2-inline.d.ts.map +1 -1
  231. package/dist/types/slate/test-helpers/editor-v2.d.ts +1 -0
  232. package/dist/types/slate/test-helpers/editor-v2.d.ts.map +1 -1
  233. package/dist/types/slate/test-helpers/test-elements.d.ts +1 -1
  234. package/dist/types/slate/test-helpers/test-elements.d.ts.map +1 -1
  235. package/package.json +9 -6
  236. package/dist/types/next/components/tests/makeswift-component-rendering.test.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../src/components/builtin/Navigation/components/MobileMenu/index.tsx"],"sourcesContent":["import { ComponentPropsWithoutRef, Fragment } from 'react'\n\nimport { ColorValue as Color } from '../../../../utils/types'\nimport { colorToString } from '../../../../utils/colorToString'\nimport { Times16 } from '../../../../icons/Times16'\n\nimport Button from '../../../Button'\nimport DropDownButton from './components/MobileDropDownButton'\nimport { useResponsiveColor } from '../../../../hooks'\nimport { cx } from '@emotion/css'\nimport { useStyle } from '../../../../../runtimes/react/use-style'\nimport { useResponsiveStyle } from '../../../../utils/responsive-style'\nimport { type ResponsiveColor } from '../../../../utils/types'\nimport {\n type NavigationButtonData,\n type NavigationLinksData,\n type ResponsiveValue,\n} from '@makeswift/prop-controllers'\n\ntype NavigationButtonProps = NavigationButtonData['payload'] &\n Omit<ComponentPropsWithoutRef<typeof Button>, 'color' | 'textColor'>\n\nfunction ButtonLink({\n className,\n textColor,\n color,\n ...restOfProps\n}: NavigationButtonProps): JSX.Element {\n return (\n <Button\n {...restOfProps}\n className={cx(useStyle({ margin: '8px 0' }), className)}\n textColor={useResponsiveColor(textColor)}\n color={useResponsiveColor(color)}\n />\n )\n}\n\ntype ContainerBaseProps = {\n className?: string\n animation?: ResponsiveValue<'coverRight' | 'coverLeft'>\n backgroundColor?: ResponsiveValue<Color> | null\n open: boolean\n}\n\ntype ContainerProps = ContainerBaseProps &\n Omit<ComponentPropsWithoutRef<'div'>, keyof ContainerBaseProps>\n\nfunction Container({\n className,\n animation,\n backgroundColor,\n open,\n ...restOfProps\n}: ContainerProps) {\n return (\n <div\n {...restOfProps}\n className={cx(\n useStyle({\n position: 'fixed',\n flexDirection: 'column',\n width: '100%',\n padding: '40px 15px',\n transition: 'transform 300ms ease-in-out',\n overflowY: 'auto',\n zIndex: 9999,\n maxWidth: 575,\n }),\n useStyle(\n useResponsiveStyle(\n [animation, backgroundColor] as const,\n ([animation, backgroundColor]) => {\n if (animation == null) return { display: 'none' }\n\n return {\n display: 'flex',\n backgroundColor: backgroundColor == null ? 'black' : colorToString(backgroundColor),\n transform: open\n ? `translate3d(0,0,0)`\n : `translate3d(${{ coverRight: '', coverLeft: '-' }[animation]}100%, 0, 0)`,\n ...{\n coverRight: { top: 0, bottom: 0, right: 0 },\n coverLeft: { top: 0, bottom: 0, left: 0 },\n }[animation],\n }\n },\n ),\n ),\n className,\n )}\n />\n )\n}\n\ntype CloseIconContainerBaseProps = {\n className?: string\n color?: ResponsiveColor | null\n}\n\ntype CloseIconContainerProps = CloseIconContainerBaseProps &\n Omit<ComponentPropsWithoutRef<'button'>, keyof CloseIconContainerBaseProps>\n\nfunction CloseIconContainer({ className, color, ...restOfProps }: CloseIconContainerProps) {\n return (\n <button\n {...restOfProps}\n className={cx(\n useStyle({\n position: 'absolute',\n top: 15,\n right: 15,\n padding: 0,\n border: 0,\n outline: 0,\n background: 'none',\n fill: 'currentcolor',\n }),\n useStyle(\n useResponsiveStyle([color] as const, ([color]) => ({\n color: color == null ? 'rgba(161, 168, 194, 0.5)' : colorToString(color),\n })),\n ),\n className,\n )}\n />\n )\n}\n\ntype Props = {\n animation?: ResponsiveValue<'coverRight' | 'coverLeft'>\n backgroundColor?: ResponsiveColor | null\n closeIconColor?: ResponsiveColor | null\n links?: NavigationLinksData\n onClose?: () => unknown\n open?: boolean\n}\n\nexport default function MobileMenu({\n animation,\n backgroundColor,\n open = false,\n closeIconColor,\n links = [],\n onClose = () => {},\n}: Props): JSX.Element {\n return (\n <Container animation={animation} backgroundColor={backgroundColor} open={open}>\n <CloseIconContainer color={closeIconColor} onClick={onClose}>\n <Times16 />\n </CloseIconContainer>\n <div\n style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', flexShrink: 0 }}\n >\n {links.map(link => (\n <Fragment key={link.id}>\n {link.type === 'button' && (\n <ButtonLink {...link.payload} onClick={onClose}>\n {link.payload.label}\n </ButtonLink>\n )}\n {link.type === 'dropdown' && <DropDownButton {...link.payload} onClose={onClose} />}\n </Fragment>\n ))}\n </div>\n </Container>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA6BI;AA7BJ,mBAAmD;A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":["Button","animation","backgroundColor","color","DropDownButton"]}
1
+ {"version":3,"sources":["../../../../../../../src/components/builtin/Navigation/components/MobileMenu/index.tsx"],"sourcesContent":["import { ComponentPropsWithoutRef, Fragment, ReactNode } from 'react'\n\nimport { ColorValue as Color } from '../../../../utils/types'\nimport { colorToString } from '../../../../utils/colorToString'\nimport { Times16 } from '../../../../icons/Times16'\n\nimport Button from '../../../Button'\nimport DropDownButton from './components/MobileDropDownButton'\nimport { useResponsiveColor } from '../../../../hooks'\nimport { cx } from '@emotion/css'\nimport { useStyle } from '../../../../../runtimes/react/use-style'\nimport { useResponsiveStyle } from '../../../../utils/responsive-style'\nimport { type ResponsiveColor } from '../../../../utils/types'\nimport {\n type NavigationButtonData,\n type NavigationLinksData,\n type ResponsiveValue,\n} from '@makeswift/prop-controllers'\n\ntype NavigationButtonProps = NavigationButtonData['payload'] &\n Omit<ComponentPropsWithoutRef<typeof Button>, 'color' | 'textColor'>\n\nfunction ButtonLink({\n className,\n textColor,\n color,\n ...restOfProps\n}: NavigationButtonProps): ReactNode {\n return (\n <Button\n {...restOfProps}\n className={cx(useStyle({ margin: '8px 0' }), className)}\n textColor={useResponsiveColor(textColor)}\n color={useResponsiveColor(color)}\n />\n )\n}\n\ntype ContainerBaseProps = {\n className?: string\n animation?: ResponsiveValue<'coverRight' | 'coverLeft'>\n backgroundColor?: ResponsiveValue<Color> | null\n open: boolean\n}\n\ntype ContainerProps = ContainerBaseProps &\n Omit<ComponentPropsWithoutRef<'div'>, keyof ContainerBaseProps>\n\nfunction Container({\n className,\n animation,\n backgroundColor,\n open,\n ...restOfProps\n}: ContainerProps) {\n return (\n <div\n {...restOfProps}\n className={cx(\n useStyle({\n position: 'fixed',\n flexDirection: 'column',\n width: '100%',\n padding: '40px 15px',\n transition: 'transform 300ms ease-in-out',\n overflowY: 'auto',\n zIndex: 9999,\n maxWidth: 575,\n }),\n useStyle(\n useResponsiveStyle(\n [animation, backgroundColor] as const,\n ([animation, backgroundColor]) => {\n if (animation == null) return { display: 'none' }\n\n return {\n display: 'flex',\n backgroundColor: backgroundColor == null ? 'black' : colorToString(backgroundColor),\n transform: open\n ? `translate3d(0,0,0)`\n : `translate3d(${{ coverRight: '', coverLeft: '-' }[animation]}100%, 0, 0)`,\n ...{\n coverRight: { top: 0, bottom: 0, right: 0 },\n coverLeft: { top: 0, bottom: 0, left: 0 },\n }[animation],\n }\n },\n ),\n ),\n className,\n )}\n />\n )\n}\n\ntype CloseIconContainerBaseProps = {\n className?: string\n color?: ResponsiveColor | null\n}\n\ntype CloseIconContainerProps = CloseIconContainerBaseProps &\n Omit<ComponentPropsWithoutRef<'button'>, keyof CloseIconContainerBaseProps>\n\nfunction CloseIconContainer({ className, color, ...restOfProps }: CloseIconContainerProps) {\n return (\n <button\n {...restOfProps}\n className={cx(\n useStyle({\n position: 'absolute',\n top: 15,\n right: 15,\n padding: 0,\n border: 0,\n outline: 0,\n background: 'none',\n fill: 'currentcolor',\n }),\n useStyle(\n useResponsiveStyle([color] as const, ([color]) => ({\n color: color == null ? 'rgba(161, 168, 194, 0.5)' : colorToString(color),\n })),\n ),\n className,\n )}\n />\n )\n}\n\ntype Props = {\n animation?: ResponsiveValue<'coverRight' | 'coverLeft'>\n backgroundColor?: ResponsiveColor | null\n closeIconColor?: ResponsiveColor | null\n links?: NavigationLinksData\n onClose?: () => unknown\n open?: boolean\n}\n\nexport default function MobileMenu({\n animation,\n backgroundColor,\n open = false,\n closeIconColor,\n links = [],\n onClose = () => {},\n}: Props): ReactNode {\n return (\n <Container animation={animation} backgroundColor={backgroundColor} open={open}>\n <CloseIconContainer color={closeIconColor} onClick={onClose}>\n <Times16 />\n </CloseIconContainer>\n <div\n style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', flexShrink: 0 }}\n >\n {links.map(link => (\n <Fragment key={link.id}>\n {link.type === 'button' && (\n <ButtonLink {...link.payload} onClick={onClose}>\n {link.payload.label}\n </ButtonLink>\n )}\n {link.type === 'dropdown' && <DropDownButton {...link.payload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AAA,UAED,KAAK,SAAS,cAAc,4CAAC,4BAAAC,SAAA,EAAgB,GAAG,KAAK,SAAS,SAAkB;AAAA,aANpE,KAAK,EAOpB,CACD;AAAA;AAAA,IACH;AAAA,KACF;AAEJ;","names":["Button","animation","backgroundColor","color","DropDownButton"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../src/components/builtin/SocialLinks/components/SocialLinksPlaceholder/index.tsx"],"sourcesContent":["import { LengthData, ResponsiveValue } from '@makeswift/prop-controllers'\nimport { useStyle } from '../../../../../runtimes/react/use-style'\n\nimport GutterContainer from '../../../../shared/GutterContainer'\n\nconst links = [{ id: '1' }, { id: '2' }, { id: '3' }]\n\ntype Props = { gutter?: ResponsiveValue<LengthData> }\n\nexport default function SocialLinksPlaceholder({ gutter }: Props): JSX.Element {\n return (\n <>\n {links.map((link, i) => (\n <GutterContainer\n key={link.id}\n gutter={gutter}\n first={i === 0}\n last={i === links.length - 1}\n >\n <PlaceholderLink />\n </GutterContainer>\n ))}\n </>\n )\n}\n\nfunction PlaceholderLink() {\n return (\n <div\n className={useStyle({\n width: 44,\n height: 44,\n borderRadius: '50%',\n backgroundColor: 'rgba(161, 168, 194, 0.4)',\n })}\n />\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAWI;AAVJ,uBAAyB;AAEzB,6BAA4B;AAE5B,MAAM,QAAQ,CAAC,EAAE,IAAI,IAAI,GAAG,EAAE,IAAI,IAAI,GAAG,EAAE,IAAI,IAAI,CAAC;AAIrC,SAAR,uBAAwC,EAAE,OAAO,GAAuB;AAC7E,SACE,2EACG,gBAAM,IAAI,CAAC,MAAM,MAChB;AAAA,IAAC,uBAAAA;AAAA,IAAA;AAAA,MAEC;AAAA,MACA,OAAO,MAAM;AAAA,MACb,MAAM,MAAM,MAAM,SAAS;AAAA,MAE3B,sDAAC,mBAAgB;AAAA;AAAA,IALZ,KAAK;AAAA,EAMZ,CACD,GACH;AAEJ;AAEA,SAAS,kBAAkB;AACzB,SACE;AAAA,IAAC;AAAA;AAAA,MACC,eAAW,2BAAS;AAAA,QAClB,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,cAAc;AAAA,QACd,iBAAiB;AAAA,MACnB,CAAC;AAAA;AAAA,EACH;AAEJ;","names":["GutterContainer"]}
1
+ {"version":3,"sources":["../../../../../../../src/components/builtin/SocialLinks/components/SocialLinksPlaceholder/index.tsx"],"sourcesContent":["import { ReactNode } from 'react'\nimport { LengthData, ResponsiveValue } from '@makeswift/prop-controllers'\nimport { useStyle } from '../../../../../runtimes/react/use-style'\n\nimport GutterContainer from '../../../../shared/GutterContainer'\n\nconst links = [{ id: '1' }, { id: '2' }, { id: '3' }]\n\ntype Props = { gutter?: ResponsiveValue<LengthData> }\n\nexport default function SocialLinksPlaceholder({ gutter }: Props): ReactNode {\n return (\n <>\n {links.map((link, i) => (\n <GutterContainer\n key={link.id}\n gutter={gutter}\n first={i === 0}\n last={i === links.length - 1}\n >\n <PlaceholderLink />\n </GutterContainer>\n ))}\n </>\n )\n}\n\nfunction PlaceholderLink() {\n return (\n <div\n className={useStyle({\n width: 44,\n height: 44,\n borderRadius: '50%',\n backgroundColor: 'rgba(161, 168, 194, 0.4)',\n })}\n />\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAYI;AAVJ,uBAAyB;AAEzB,6BAA4B;AAE5B,MAAM,QAAQ,CAAC,EAAE,IAAI,IAAI,GAAG,EAAE,IAAI,IAAI,GAAG,EAAE,IAAI,IAAI,CAAC;AAIrC,SAAR,uBAAwC,EAAE,OAAO,GAAqB;AAC3E,SACE,2EACG,gBAAM,IAAI,CAAC,MAAM,MAChB;AAAA,IAAC,uBAAAA;AAAA,IAAA;AAAA,MAEC;AAAA,MACA,OAAO,MAAM;AAAA,MACb,MAAM,MAAM,MAAM,SAAS;AAAA,MAE3B,sDAAC,mBAAgB;AAAA;AAAA,IALZ,KAAK;AAAA,EAMZ,CACD,GACH;AAEJ;AAEA,SAAS,kBAAkB;AACzB,SACE;AAAA,IAAC;AAAA;AAAA,MACC,eAAW,2BAAS;AAAA,QAClB,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,cAAc;AAAA,QACd,iBAAiB;AAAA,MACnB,CAAC;AAAA;AAAA,EACH;AAEJ;","names":["GutterContainer"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../src/components/shared/BackgroundsContainer/components/BackgroundVideo/index.tsx"],"sourcesContent":["import { cx } from '@emotion/css'\nimport { useState, useRef, ComponentPropsWithoutRef, ForwardedRef, forwardRef } from 'react'\n\nimport { ReactPlayer } from '../../../react-player'\nimport { useStyle } from '../../../../../runtimes/react/use-style'\n\nimport { useIsomorphicLayoutEffect } from '../../../../hooks/useIsomorphicLayoutEffect'\n\nconst Container = forwardRef(function Container(\n { className, ...restOfProps }: ComponentPropsWithoutRef<'div'>,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n return (\n <div\n {...restOfProps}\n ref={ref}\n className={cx(\n useStyle({\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n pointerEvents: 'none',\n overflow: 'hidden',\n }),\n className,\n )}\n />\n )\n})\n\nfunction Mask({\n backgroundColor,\n visible,\n}: {\n backgroundColor: string | undefined\n visible: boolean\n}) {\n return (\n <div\n className={useStyle({\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n background: backgroundColor,\n opacity: visible ? 1 : 0,\n transition: 'opacity 1s',\n })}\n />\n )\n}\n\nconst getScale = (element: HTMLElement, aspectRatio: number, zoom: number) => {\n const { offsetWidth: width, offsetHeight: height } = element\n const computedAspectRatio = width / height\n\n return Math.max(aspectRatio / computedAspectRatio, computedAspectRatio / aspectRatio) * zoom\n}\n\ntype Props = {\n url?: string\n aspectRatio?: number\n zoom?: number\n opacity?: number\n maskColor?: string\n}\n\nexport default function BackgroundVideo({\n url = '',\n aspectRatio = 16 / 9,\n zoom = 1,\n maskColor,\n opacity,\n}: Props): JSX.Element {\n const [ready, setReady] = useState(false)\n const [scale, setScale] = useState(1)\n const container = useRef<HTMLDivElement>(null)\n\n useIsomorphicLayoutEffect(() => {\n const { current: containerEl } = container\n\n if (!containerEl) return undefined\n\n const { defaultView } = containerEl.ownerDocument\n const handleResize = () => setScale(getScale(containerEl, aspectRatio, zoom))\n\n handleResize()\n\n defaultView!.addEventListener('resize', handleResize)\n\n return () => defaultView!.removeEventListener('resize', handleResize)\n }, [aspectRatio, zoom])\n\n if (!ReactPlayer.canPlay(url)) return <></>\n\n return (\n <Container ref={container}>\n {container.current && (\n <ReactPlayer\n url={url}\n config={{\n vimeo: { playerOptions: { background: true } },\n youtube: {\n playerVars: {\n origin: container.current.ownerDocument.defaultView?.location.origin,\n },\n },\n wistia: {\n options: {\n endVideoBehavior: 'loop',\n playbackRateControl: false,\n playbar: false,\n playButton: false,\n volumeControl: false,\n fullscreenButton: false,\n muted: true,\n },\n },\n }}\n playing\n loop\n muted\n playsinline={true}\n controls={false}\n onReady={() => setReady(true)}\n style={{\n transform: `scale3d(${scale}, ${scale}, 1)`,\n opacity,\n }}\n width=\"100%\"\n height=\"100%\"\n />\n )}\n <Mask backgroundColor={maskColor} visible={!ready} />\n </Container>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAaI;AAbJ,iBAAmB;AACnB,mBAAqF;AAErF,0BAA4B;AAC5B,uBAAyB;AAEzB,uCAA0C;AAE1C,MAAM,gBAAY,yBAAW,SAASA,WACpC,EAAE,WAAW,GAAG,YAAY,GAC5B,KACA;AACA,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ;AAAA,MACA,eAAW;AAAA,YACT,2BAAS;AAAA,UACP,UAAU;AAAA,UACV,KAAK;AAAA,UACL,MAAM;AAAA,UACN,OAAO;AAAA,UACP,QAAQ;AAAA,UACR,eAAe;A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ACb;AAAA,cAAU,WACT;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA,QAAQ;AAAA,UACN,OAAO,EAAE,eAAe,EAAE,YAAY,KAAK,EAAE;AAAA,UAC7C,SAAS;AAAA,YACP,YAAY;AAAA,cACV,QAAQ,UAAU,QAAQ,cAAc,aAAa,SAAS;AAAA,YAChE;AAAA,UACF;AAAA,UACA,QAAQ;AAAA,YACN,SAAS;AAAA,cACP,kBAAkB;AAAA,cAClB,qBAAqB;AAAA,cACrB,SAAS;AAAA,cACT,YAAY;AAAA,cACZ,eAAe;AAAA,cACf,kBAAkB;AAAA,cAClB,OAAO;AAAA,YACT;AAAA,UACF;AAAA,QACF;AAAA,QACA,SAAO;AAAA,QACP,MAAI;AAAA,QACJ,OAAK;AAAA,QACL,aAAa;AAAA,QACb,UAAU;AAAA,QACV,SAAS,MAAM,SAAS,IAAI;AAAA,QAC5B,OAAO;AAAA,UACL,WAAW,WAAW,KAAK,KAAK,KAAK;AAAA,UACrC;AAAA,QACF;AAAA,QACA,OAAM;AAAA,QACN,QAAO;AAAA;AAAA,IACT;AAAA,IAEF,4CAAC,QAAK,iBAAiB,WAAW,SAAS,CAAC,OAAO;AAAA,KACrD;AAEJ;","names":["Container"]}
1
+ {"version":3,"sources":["../../../../../../../src/components/shared/BackgroundsContainer/components/BackgroundVideo/index.tsx"],"sourcesContent":["import { cx } from '@emotion/css'\nimport { useState, useRef, ComponentPropsWithoutRef, ForwardedRef, forwardRef, ReactNode } from 'react'\n\nimport { ReactPlayer } from '../../../react-player'\nimport { useStyle } from '../../../../../runtimes/react/use-style'\n\nimport { useIsomorphicLayoutEffect } from '../../../../hooks/useIsomorphicLayoutEffect'\n\nconst Container = forwardRef(function Container(\n { className, ...restOfProps }: ComponentPropsWithoutRef<'div'>,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n return (\n <div\n {...restOfProps}\n ref={ref}\n className={cx(\n useStyle({\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n pointerEvents: 'none',\n overflow: 'hidden',\n }),\n className,\n )}\n />\n )\n})\n\nfunction Mask({\n backgroundColor,\n visible,\n}: {\n backgroundColor: string | undefined\n visible: boolean\n}) {\n return (\n <div\n className={useStyle({\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n background: backgroundColor,\n opacity: visible ? 1 : 0,\n transition: 'opacity 1s',\n })}\n />\n )\n}\n\nconst getScale = (element: HTMLElement, aspectRatio: number, zoom: number) => {\n const { offsetWidth: width, offsetHeight: height } = element\n const computedAspectRatio = width / height\n\n return Math.max(aspectRatio / computedAspectRatio, computedAspectRatio / aspectRatio) * zoom\n}\n\ntype Props = {\n url?: string\n aspectRatio?: number\n zoom?: number\n opacity?: number\n maskColor?: string\n}\n\nexport default function BackgroundVideo({\n url = '',\n aspectRatio = 16 / 9,\n zoom = 1,\n maskColor,\n opacity,\n}: Props): ReactNode {\n const [ready, setReady] = useState(false)\n const [scale, setScale] = useState(1)\n const container = useRef<HTMLDivElement>(null)\n\n useIsomorphicLayoutEffect(() => {\n const { current: containerEl } = container\n\n if (!containerEl) return undefined\n\n const { defaultView } = containerEl.ownerDocument\n const handleResize = () => setScale(getScale(containerEl, aspectRatio, zoom))\n\n handleResize()\n\n defaultView!.addEventListener('resize', handleResize)\n\n return () => defaultView!.removeEventListener('resize', handleResize)\n }, [aspectRatio, zoom])\n\n if (!ReactPlayer.canPlay(url)) return <></>\n\n return (\n <Container ref={container}>\n {container.current && (\n <ReactPlayer\n url={url}\n config={{\n vimeo: { playerOptions: { background: true } },\n youtube: {\n playerVars: {\n origin: container.current.ownerDocument.defaultView?.location.origin,\n },\n },\n wistia: {\n options: {\n endVideoBehavior: 'loop',\n playbackRateControl: false,\n playbar: false,\n playButton: false,\n volumeControl: false,\n fullscreenButton: false,\n muted: true,\n },\n },\n }}\n playing\n loop\n muted\n playsinline={true}\n controls={false}\n onReady={() => setReady(true)}\n style={{\n transform: `scale3d(${scale}, ${scale}, 1)`,\n opacity,\n }}\n width=\"100%\"\n height=\"100%\"\n />\n )}\n <Mask backgroundColor={maskColor} visible={!ready} />\n </Container>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAaI;AAbJ,iBAAmB;AACnB,mBAAgG;AAEhG,0BAA4B;AAC5B,uBAAyB;AAEzB,uCAA0C;AAE1C,MAAM,gBAAY,yBAAW,SAASA,WACpC,EAAE,WAAW,GAAG,YAAY,GAC5B,KACA;AACA,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ;AAAA,MACA,eAAW;AAAA,YACT,2BAAS;AAAA,UACP,UAAU;AAAA,UACV,KAAK;AAAA,UACL,MAAM;AAAA,UACN,OAAO;AAAA,UACP,QAAQ;AAAA,UACR,eAAe;AAAA,UACf,UAAU;AAAA,QACZ,CAAC;AAAA,QACD;AAAA,MACF;AAAA;AAAA,EACF;AAEJ,CAAC;AAED,SAAS,KAAK;AAAA,EACZ;AAAA,EACA;AACF,GAGG;AACD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,eAAW,2BAAS;AAAA,QAClB,UAAU;AAAA,QACV,KAAK;AAAA,QACL,MAAM;AAAA,QACN,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,YAAY;AAAA,QACZ,SAAS,UAAU,IAAI;AAAA,QACvB,YAAY;AAAA,MACd,CAAC;AAAA;AAAA,EACH;AAEJ;AAEA,MAAM,WAAW,CAAC,SAAsB,aAAqB,SAAiB;AAC5E,QAAM,EAAE,aAAa,OAAO,cAAc,OAAO,IAAI;AACrD,QAAM,sBAAsB,QAAQ;AAEpC,SAAO,KAAK,IAAI,cAAc,qBAAqB,sBAAsB,WAAW,IAAI;AAC1F;AAUe,SAAR,gBAAiC;AAAA,EACtC,MAAM;AAAA,EACN,cAAc,KAAK;AAAA,EACnB,OAAO;AAAA,EACP;AAAA,EACA;AACF,GAAqB;AACnB,QAAM,CAAC,OAAO,QAAQ,QAAI,uBAA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CAAC,OAAO;AAAA,KACrD;AAEJ;","names":["Container"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../src/components/shared/BackgroundsContainer/components/Backgrounds/index.tsx"],"sourcesContent":["import { BackgroundsPropControllerValue, BackgroundsData } from '../../../../hooks'\nimport { type ResponsiveValue } from '@makeswift/controls'\nimport { ColorValue as Color } from '../../../../utils/types'\nimport { colorToString } from '../../../../utils/colorToString'\nimport Parallax from '../Parallax'\nimport BackgroundVideo from '../BackgroundVideo'\nimport { type CSSObject } from '@emotion/serialize'\nimport { useStyle } from '../../../../../runtimes/react/use-style'\nimport { useResponsiveStyle } from '../../../../utils/responsive-style'\nimport { useFrameworkContext } from '../../../../../runtimes/react/components/hooks/use-framework-context'\n\nfunction getColor(color: Color | null | undefined) {\n if (color == null) return 'black'\n\n if (color.swatch == null) {\n return colorToString({ ...color, swatch: { hue: 0, saturation: 0, lightness: 0 } })\n }\n\n return colorToString(color)\n}\n\ntype GradientStop = { color: Color | null | undefined; location: number }\n\nconst getStopsStyle = (stops: GradientStop[]) =>\n stops.map(({ color, location }) => `${getColor(color)} ${location}%`).join(',')\n\nconst absoluteFillStyle: CSSObject = {\n position: 'absolute',\n top: 0,\n right: 0,\n bottom: 0,\n left: 0,\n}\n\nconst containerStyle: CSSObject = {\n ...absoluteFillStyle,\n borderRadius: 'inherit',\n}\n\ntype Props = { backgrounds: BackgroundsPropControllerValue | null | undefined }\n\nexport default function Backgrounds({ backgrounds }: Props): JSX.Element {\n if (backgrounds == null) return <></>\n\n return (\n <>\n {backgrounds.map(({ value, deviceId }) => {\n const visibility = backgrounds.map(v => ({\n deviceId: v.deviceId,\n value: v.deviceId === deviceId,\n }))\n\n return <BackgroundDeviceLayer key={deviceId} layer={value} visibility={visibility} />\n })}\n </>\n )\n}\n\ntype BackgroundLayerProps = {\n layer: BackgroundsData\n visibility: ResponsiveValue<boolean>\n}\n\nfunction BackgroundDeviceLayer({ layer, visibility }: BackgroundLayerProps) {\n const visibilityStyle = useResponsiveStyle([visibility], ([v]) => ({\n display: v === true ? 'block' : 'none',\n }))\n\n return (\n <div className={useStyle({ ...containerStyle, ...visibilityStyle, overflow: 'hidden' })}>\n {[...layer].reverse().map(bg => {\n if (bg.type === 'color') {\n return <ColorBackground key={bg.id} color={getColor(bg.payload)} />\n }\n\n if (bg.type === 'image' && bg.payload) {\n return <ImageBackground {...bg.payload} key={bg.id} />\n }\n\n if (bg.type === 'gradient' && bg.payload) {\n return (\n <GradientBackground\n {...bg.payload}\n key={bg.id}\n gradient={getStopsStyle(bg.payload.stops)}\n />\n )\n }\n\n if (bg.type === 'video' && bg.payload) {\n return (\n <VideoBackground\n {...bg.payload}\n key={bg.id}\n maskColor={getColor(bg.payload.maskColor)}\n />\n )\n }\n\n return null\n })}\n </div>\n )\n}\n\ntype ColorBackgroundProps = { color: string }\n\nfunction ColorBackground({ color }: ColorBackgroundProps) {\n return <div className={useStyle({ ...containerStyle, backgroundColor: color })} />\n}\n\nconst ImageBackgroundRepeat = {\n NoRepeat: 'no-repeat',\n RepeatX: 'repeat-x',\n RepeatY: 'repeat-y',\n Repeat: 'repeat',\n} as const\n\ntype ImageBackgroundRepeat = (typeof ImageBackgroundRepeat)[keyof typeof ImageBackgroundRepeat]\n\nconst ImageBackgroundSize = {\n Cover: 'cover',\n Contain: 'contain',\n Auto: 'auto',\n} as const\n\ntype ImageBackgroundSize = (typeof ImageBackgroundSize)[keyof typeof ImageBackgroundSize]\n\ntype ImageBackgroundProps = {\n publicUrl?: string\n position: { x: number; y: number }\n repeat?: ImageBackgroundRepeat\n size?: ImageBackgroundSize\n opacity?: number\n parallax?: number\n priority?: boolean\n}\n\nfunction ImageBackground({\n publicUrl,\n position,\n repeat = ImageBackgroundRepeat.NoRepeat,\n size = ImageBackgroundSize.Cover,\n opacity,\n parallax,\n priority,\n}: ImageBackgroundProps) {\n const backgroundPosition = `${position.x}% ${position.y}%`\n const containerClassName = useStyle(containerStyle)\n const { Image } = useFrameworkContext()\n\n if (repeat === 'no-repeat' && size !== 'auto' && publicUrl != null) {\n return (\n <Parallax strength={parallax}>\n {getParallaxProps => (\n <div {...getParallaxProps({ style: { opacity, overflow: 'hidden' } })}>\n <Image\n src={publicUrl}\n alt={''}\n fill\n sizes=\"100vw\"\n style={{\n objectPosition: backgroundPosition,\n objectFit: size,\n }}\n priority={priority}\n />\n </div>\n )}\n </Parallax>\n )\n }\n\n return (\n <Parallax strength={parallax}>\n {getParallaxProps => (\n <div\n className={containerClassName}\n {...getParallaxProps({\n style: {\n backgroundImage: publicUrl != null ? `url('${publicUrl}')` : undefined,\n backgroundPosition,\n backgroundRepeat: repeat,\n backgroundSize: size,\n opacity,\n },\n })}\n />\n )}\n </Parallax>\n )\n}\n\ntype GradientBackgroundProps = {\n gradient: string\n angle?: number\n isRadial?: boolean\n}\n\nfunction GradientBackground({\n gradient,\n isRadial = false,\n angle = Math.PI,\n}: GradientBackgroundProps) {\n return (\n <div\n className={useStyle({\n ...containerStyle,\n background: isRadial\n ? `radial-gradient(${gradient})`\n : `linear-gradient(${angle}rad, ${gradient})`,\n })}\n />\n )\n}\n\nconst BackgroundVideoAspectRatio = {\n Wide: 'wide',\n Standard: 'standard',\n} as const\n\ntype BackgroundVideoAspectRatio =\n (typeof BackgroundVideoAspectRatio)[keyof typeof BackgroundVideoAspectRatio]\n\nfunction getAspectRatio(aspectRatio: BackgroundVideoAspectRatio | null | undefined): number {\n switch (aspectRatio) {\n case 'wide':\n return 16 / 9\n\n case 'standard':\n return 4 / 3\n\n default:\n return 16 / 9\n }\n}\n\ntype VideoBackgroundProps = {\n url?: string\n aspectRatio?: BackgroundVideoAspectRatio\n maskColor: string\n zoom?: number\n opacity?: number\n parallax?: number\n}\n\nfunction VideoBackground({\n url,\n aspectRatio,\n maskColor,\n zoom,\n opacity,\n parallax,\n}: VideoBackgroundProps) {\n return (\n <Parallax strength={parallax}>\n {getParallaxProps => (\n <div {...getParallaxProps({ className: useStyle(containerStyle) })}>\n <BackgroundVideo\n url={url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BAA6B;AAAA,EACjC,MAAM;AAAA,EACN,UAAU;AACZ;AAKA,SAAS,eAAe,aAAoE;AAC1F,UAAQ,aAAa;AAAA,IACnB,KAAK;AACH,aAAO,KAAK;AAAA,IAEd,KAAK;AACH,aAAO,IAAI;AAAA,IAEb;AACE,aAAO,KAAK;AAAA,EAChB;AACF;AAWA,SAAS,gBAAgB;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAyB;AACvB,SACE,4CAAC,gBAAAA,SAAA,EAAS,UAAU,UACjB,gCACC,4CAAC,SAAK,GAAG,iBAAiB,EAAE,eAAW,2BAAS,cAAc,EAAE,CAAC,GAC/D;AAAA,IAAC,uBAAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA,aAAa,eAAe,WAAW;AAAA,MACvC;AAAA;AAAA,EACF,GACF,GAEJ;AAEJ;","names":["Parallax","BackgroundVideo"]}
1
+ {"version":3,"sources":["../../../../../../../src/components/shared/BackgroundsContainer/components/Backgrounds/index.tsx"],"sourcesContent":["import { ReactNode } from 'react'\nimport { BackgroundsPropControllerValue, BackgroundsData } from '../../../../hooks'\nimport { type ResponsiveValue } from '@makeswift/controls'\nimport { ColorValue as Color } from '../../../../utils/types'\nimport { colorToString } from '../../../../utils/colorToString'\nimport Parallax from '../Parallax'\nimport BackgroundVideo from '../BackgroundVideo'\nimport { type CSSObject } from '@emotion/serialize'\nimport { useStyle } from '../../../../../runtimes/react/use-style'\nimport { useResponsiveStyle } from '../../../../utils/responsive-style'\nimport { useFrameworkContext } from '../../../../../runtimes/react/components/hooks/use-framework-context'\n\nfunction getColor(color: Color | null | undefined) {\n if (color == null) return 'black'\n\n if (color.swatch == null) {\n return colorToString({ ...color, swatch: { hue: 0, saturation: 0, lightness: 0 } })\n }\n\n return colorToString(color)\n}\n\ntype GradientStop = { color: Color | null | undefined; location: number }\n\nconst getStopsStyle = (stops: GradientStop[]) =>\n stops.map(({ color, location }) => `${getColor(color)} ${location}%`).join(',')\n\nconst absoluteFillStyle: CSSObject = {\n position: 'absolute',\n top: 0,\n right: 0,\n bottom: 0,\n left: 0,\n}\n\nconst containerStyle: CSSObject = {\n ...absoluteFillStyle,\n borderRadius: 'inherit',\n}\n\ntype Props = { backgrounds: BackgroundsPropControllerValue | null | undefined }\n\nexport default function Backgrounds({ backgrounds }: Props): ReactNode {\n if (backgrounds == null) return <></>\n\n return (\n <>\n {backgrounds.map(({ value, deviceId }) => {\n const visibility = backgrounds.map(v => ({\n deviceId: v.deviceId,\n value: v.deviceId === deviceId,\n }))\n\n return <BackgroundDeviceLayer key={deviceId} layer={value} visibility={visibility} />\n })}\n </>\n )\n}\n\ntype BackgroundLayerProps = {\n layer: BackgroundsData\n visibility: ResponsiveValue<boolean>\n}\n\nfunction BackgroundDeviceLayer({ layer, visibility }: BackgroundLayerProps) {\n const visibilityStyle = useResponsiveStyle([visibility], ([v]) => ({\n display: v === true ? 'block' : 'none',\n }))\n\n return (\n <div className={useStyle({ ...containerStyle, ...visibilityStyle, overflow: 'hidden' })}>\n {[...layer].reverse().map(bg => {\n if (bg.type === 'color') {\n return <ColorBackground key={bg.id} color={getColor(bg.payload)} />\n }\n\n if (bg.type === 'image' && bg.payload) {\n return <ImageBackground {...bg.payload} key={bg.id} />\n }\n\n if (bg.type === 'gradient' && bg.payload) {\n return (\n <GradientBackground\n {...bg.payload}\n key={bg.id}\n gradient={getStopsStyle(bg.payload.stops)}\n />\n )\n }\n\n if (bg.type === 'video' && bg.payload) {\n return (\n <VideoBackground\n {...bg.payload}\n key={bg.id}\n maskColor={getColor(bg.payload.maskColor)}\n />\n )\n }\n\n return null\n })}\n </div>\n )\n}\n\ntype ColorBackgroundProps = { color: string }\n\nfunction ColorBackground({ color }: ColorBackgroundProps) {\n return <div className={useStyle({ ...containerStyle, backgroundColor: color })} />\n}\n\nconst ImageBackgroundRepeat = {\n NoRepeat: 'no-repeat',\n RepeatX: 'repeat-x',\n RepeatY: 'repeat-y',\n Repeat: 'repeat',\n} as const\n\ntype ImageBackgroundRepeat = (typeof ImageBackgroundRepeat)[keyof typeof ImageBackgroundRepeat]\n\nconst ImageBackgroundSize = {\n Cover: 'cover',\n Contain: 'contain',\n Auto: 'auto',\n} as const\n\ntype ImageBackgroundSize = (typeof ImageBackgroundSize)[keyof typeof ImageBackgroundSize]\n\ntype ImageBackgroundProps = {\n publicUrl?: string\n position: { x: number; y: number }\n repeat?: ImageBackgroundRepeat\n size?: ImageBackgroundSize\n opacity?: number\n parallax?: number\n priority?: boolean\n}\n\nfunction ImageBackground({\n publicUrl,\n position,\n repeat = ImageBackgroundRepeat.NoRepeat,\n size = ImageBackgroundSize.Cover,\n opacity,\n parallax,\n priority,\n}: ImageBackgroundProps) {\n const backgroundPosition = `${position.x}% ${position.y}%`\n const containerClassName = useStyle(containerStyle)\n const { Image } = useFrameworkContext()\n\n if (repeat === 'no-repeat' && size !== 'auto' && publicUrl != null) {\n return (\n <Parallax strength={parallax}>\n {getParallaxProps => (\n <div {...getParallaxProps({ style: { opacity, overflow: 'hidden' } })}>\n <Image\n src={publicUrl}\n alt={''}\n fill\n sizes=\"100vw\"\n style={{\n objectPosition: backgroundPosition,\n objectFit: size,\n }}\n priority={priority}\n />\n </div>\n )}\n </Parallax>\n )\n }\n\n return (\n <Parallax strength={parallax}>\n {getParallaxProps => (\n <div\n className={containerClassName}\n {...getParallaxProps({\n style: {\n backgroundImage: publicUrl != null ? `url('${publicUrl}')` : undefined,\n backgroundPosition,\n backgroundRepeat: repeat,\n backgroundSize: size,\n opacity,\n },\n })}\n />\n )}\n </Parallax>\n )\n}\n\ntype GradientBackgroundProps = {\n gradient: string\n angle?: number\n isRadial?: boolean\n}\n\nfunction GradientBackground({\n gradient,\n isRadial = false,\n angle = Math.PI,\n}: GradientBackgroundProps) {\n return (\n <div\n className={useStyle({\n ...containerStyle,\n background: isRadial\n ? `radial-gradient(${gradient})`\n : `linear-gradient(${angle}rad, ${gradient})`,\n })}\n />\n )\n}\n\nconst BackgroundVideoAspectRatio = {\n Wide: 'wide',\n Standard: 'standard',\n} as const\n\ntype BackgroundVideoAspectRatio =\n (typeof BackgroundVideoAspectRatio)[keyof typeof BackgroundVideoAspectRatio]\n\nfunction getAspectRatio(aspectRatio: BackgroundVideoAspectRatio | null | undefined): number {\n switch (aspectRatio) {\n case 'wide':\n return 16 / 9\n\n case 'standard':\n return 4 / 3\n\n default:\n return 16 / 9\n }\n}\n\ntype VideoBackgroundProps = {\n url?: string\n aspectRatio?: BackgroundVideoAspectRatio\n maskColor: string\n zoom?: number\n opacity?: number\n parallax?: number\n}\n\nfunction VideoBackground({\n url,\n aspectRatio,\n maskColor,\n zoom,\n opacity,\n parallax,\n}: VideoBackgroundProps) {\n return (\n <Parallax strength={parallax}>\n {getParallaxProps => (\n <div {...getParallaxProps({ className: useStyle(containerStyle) })}>\n <BackgroundVideo\n url={url}\n zoom={zoom}\n opacity={opacity}\n aspectRatio={getAspectRatio(aspectRatio)}\n maskColor={maskColor}\n />\n </div>\n )}\n </Parallax>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA2CkC;AAkCjB;AAzEjB,2BAA8B;AAC9B,sBAAqB;AACrB,6BAA4B;AAE5B,uBAAyB;AACzB,8BAAmC;AACnC,mCAAoC;AAEpC,SAAS,SAAS,OAAiC;AACjD,MAAI,SAAS;AAAM,WAAO;AAE1B,MAAI,MAAM,UAAU,MAAM;AACxB,eAAO,oCAAc,EAAE,GAAG,OAAO,QAAQ,EAAE,KAAK,GAAG,YAAY,GAAG,WAAW,EAAE,EAAE,CAAC;AAAA,EACpF;AAEA,aAAO,oCAAc,KAAK;AAC5B;AAIA,MAAM,gBAAgB,CAAC,UACrB,MAAM,IAAI,CAAC,EAAE,OAAO,SAAS,MAAM,GAAG,SAAS,KAAK,CAAC,IAAI,QAAQ,GAAG,EAAE,KAAK,GAAG;AAEhF,MAAM,oB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EAAS,UAAU,UACjB,gCACC;AAAA,IAAC;AAAA;AAAA,MACC,WAAW;AAAA,MACV,GAAG,iBAAiB;AAAA,QACnB,OAAO;AAAA,UACL,iBAAiB,aAAa,OAAO,QAAQ,SAAS,OAAO;AAAA,UAC7D;AAAA,UACA,kBAAkB;AAAA,UAClB,gBAAgB;AAAA,UAChB;AAAA,QACF;AAAA,MACF,CAAC;AAAA;AAAA,EACH,GAEJ;AAEJ;AAQA,SAAS,mBAAmB;AAAA,EAC1B;AAAA,EACA,WAAW;AAAA,EACX,QAAQ,KAAK;AACf,GAA4B;AAC1B,SACE;AAAA,IAAC;AAAA;AAAA,MACC,eAAW,2BAAS;AAAA,QAClB,GAAG;AAAA,QACH,YAAY,WACR,mBAAmB,QAAQ,MAC3B,mBAAmB,KAAK,QAAQ,QAAQ;AAAA,MAC9C,CAAC;AAAA;AAAA,EACH;AAEJ;AAEA,MAAM,6BAA6B;AAAA,EACjC,MAAM;AAAA,EACN,UAAU;AACZ;AAKA,SAAS,eAAe,aAAoE;AAC1F,UAAQ,aAAa;AAAA,IACnB,KAAK;AACH,aAAO,KAAK;AAAA,IAEd,KAAK;AACH,aAAO,IAAI;AAAA,IAEb;AACE,aAAO,KAAK;AAAA,EAChB;AACF;AAWA,SAAS,gBAAgB;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAyB;AACvB,SACE,4CAAC,gBAAAA,SAAA,EAAS,UAAU,UACjB,gCACC,4CAAC,SAAK,GAAG,iBAAiB,EAAE,eAAW,2BAAS,cAAc,EAAE,CAAC,GAC/D;AAAA,IAAC,uBAAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA,aAAa,eAAe,WAAW;AAAA,MACvC;AAAA;AAAA,EACF,GACF,GAEJ;AAEJ;","names":["Parallax","BackgroundVideo"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../src/components/shared/BackgroundsContainer/components/Parallax/index.tsx"],"sourcesContent":["import { useState, useRef, useCallback, ReactNode, CSSProperties } from 'react'\nimport clamp from '../../../../../utils/clamp'\nimport { useIsomorphicLayoutEffect } from '../../../../hooks/useIsomorphicLayoutEffect'\n\nfunction isScrollable(element: HTMLElement) {\n const { overflow, overflowY, overflowX } =\n element.ownerDocument.defaultView!.getComputedStyle(element)\n\n return /(auto|scroll)/.test(overflow + overflowX + overflowY)\n}\n\nfunction getScrollParent(element: HTMLElement): HTMLElement {\n const { parentElement } = element\n\n if (!element || !parentElement) return element\n\n if (isScrollable(element)) return element\n\n return getScrollParent(parentElement)\n}\n\ntype Props = {\n strength: number | null | undefined\n children: (\n getParallaxProps: <P extends { style?: CSSProperties; [key: string]: unknown }>(props: P) => P,\n ) => ReactNode\n}\n\nexport default function Parallax({ strength, children, ...rest }: Props): JSX.Element {\n const container = useRef<HTMLDivElement>(null)\n const [containerScrollTop, setContainerScrollTop] = useState(strength == null ? 0 : strength)\n const lastScrollParentScrollTop = useRef(0)\n\n useIsomorphicLayoutEffect(() => {\n if (!container.current || strength == null || strength === 0) return undefined\n\n const containerDocument = container.current.ownerDocument\n const scrollParent = getScrollParent(container.current)\n const eventTarget =\n containerDocument.documentElement === scrollParent\n ? containerDocument.defaultView!\n : scrollParent\n\n lastScrollParentScrollTop.current = scrollParent.scrollTop\n setContainerScrollTop(strength)\n\n function handleScroll() {\n containerDocument.defaultView!.requestAnimationFrame(() => {\n if (!container.current) return\n\n const { top: containerTop, bottom: containerBottom } =\n container.current.getBoundingClientRect()\n const { top: scrollParentTop, bottom: scrollParentBottom } =\n scrollParent === containerDocument.documentElement\n ? { top: 0, bottom: containerDocument.defaultView!.innerHeight }\n : scrollParent.getBoundingClientRect()\n const { scrollTop: scrollParentScrollTop } =\n scrollParent === containerDocument.documentElement\n ? { scrollTop: containerDocument.defaultView!.pageYOffset }\n : scrollParent\n const scrollParentHeight = scrollParentBottom - scrollParentTop\n const scrollParentScrollDelta = scrollParentScrollTop - lastScrollParentScrollTop.current\n\n lastScrollParentScrollTop.current = scrollParentScrollTop\n\n setContainerScrollTop(scrollTop => {\n const isContainerVisible =\n containerTop < scrollParentTop + scrollParentHeight && containerBottom > scrollParentTop\n const containerScrollRemaining =\n scrollParentScrollDelta > 0 ? 2 * strength! - scrollTop : scrollTop\n const scrollParentScrollRemaining =\n scrollParentScrollDelta > 0\n ? scrollParentTop + containerBottom\n : scrollParentHeight - containerTop\n const parallaxRatio = containerScrollRemaining / scrollParentScrollRemaining\n const containerScrollDelta = isContainerVisible\n ? parallaxRatio * scrollParentScrollDelta\n : 0\n\n return clamp(0, scrollTop + containerScrollDelta, strength! * 2)\n })\n })\n }\n\n eventTarget.addEventListener('scroll', handleScroll)\n\n return () => eventTarget.removeEventListener('scroll', handleScroll)\n }, [strength])\n\n const getProps = useCallback(\n ({ style, ...restOfChildrenProps }: any) => ({\n ...restOfChildrenProps,\n style: {\n ...style,\n position: 'absolute',\n left: 0,\n right: 0,\n top: 0,\n bottom: 0,\n ...(strength == null || strength === 0\n ? {}\n : {\n top: -strength,\n bottom: -strength,\n transform: `translate3d(0, ${containerScrollTop - strength}px, 0)`,\n }),\n },\n }),\n [strength, containerScrollTop],\n )\n\n return (\n <div\n {...rest}\n ref={container}\n style={{ position: 'absolute', top: 0, left: 0, right: 0, bottom: 0 }}\n >\n {children(getProps)}\n </div>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgHI;AAhHJ,mBAAwE;AACxE,mBAAkB;AAClB,uCAA0C;AAE1C,SAAS,aAAa,SAAsB;AAC1C,QAAM,EAAE,UAAU,WAAW,UAAU,IACrC,QAAQ,cAAc,YAAa,iBAAiB,OAAO;AAE7D,SAAO,gBAAgB,KAAK,WAAW,YAAY,SAAS;AAC9D;AAEA,SAAS,gBAAgB,SAAmC;AAC1D,QAAM,EAAE,cAAc,IAAI;AAE1B,MAAI,CAAC,WAAW,CAAC;AAAe,WAAO;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,2BAA2B;AACjD,gBAAM,uBAAuB,qBACzB,gBAAgB,0BAChB;AAEJ,qBAAO,aAAAA,SAAM,GAAG,YAAY,sBAAsB,WAAY,CAAC;AAAA,QACjE,CAAC;AAAA,MACH,CAAC;AAAA,IACH;AAEA,gBAAY,iBAAiB,UAAU,YAAY;AAEnD,WAAO,MAAM,YAAY,oBAAoB,UAAU,YAAY;AAAA,EACrE,GAAG,CAAC,QAAQ,CAAC;AAEb,QAAM,eAAW;AAAA,IACf,CAAC,EAAE,OAAO,GAAG,oBAAoB,OAAY;AAAA,MAC3C,GAAG;AAAA,MACH,OAAO;AAAA,QACL,GAAG;AAAA,QACH,UAAU;AAAA,QACV,MAAM;AAAA,QACN,OAAO;AAAA,QACP,KAAK;AAAA,QACL,QAAQ;AAAA,QACR,GAAI,YAAY,QAAQ,aAAa,IACjC,CAAC,IACD;AAAA,UACE,KAAK,CAAC;AAAA,UACN,QAAQ,CAAC;AAAA,UACT,WAAW,kBAAkB,qBAAqB,QAAQ;AAAA,QAC5D;AAAA,MACN;AAAA,IACF;AAAA,IACA,CAAC,UAAU,kBAAkB;AAAA,EAC/B;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,KAAK;AAAA,MACL,OAAO,EAAE,UAAU,YAAY,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,EAAE;AAAA,MAEnE,mBAAS,QAAQ;AAAA;AAAA,EACpB;AAEJ;","names":["clamp"]}
1
+ {"version":3,"sources":["../../../../../../../src/components/shared/BackgroundsContainer/components/Parallax/index.tsx"],"sourcesContent":["import { useState, useRef, useCallback, ReactNode, CSSProperties } from 'react'\nimport clamp from '../../../../../utils/clamp'\nimport { useIsomorphicLayoutEffect } from '../../../../hooks/useIsomorphicLayoutEffect'\n\nfunction isScrollable(element: HTMLElement) {\n const { overflow, overflowY, overflowX } =\n element.ownerDocument.defaultView!.getComputedStyle(element)\n\n return /(auto|scroll)/.test(overflow + overflowX + overflowY)\n}\n\nfunction getScrollParent(element: HTMLElement): HTMLElement {\n const { parentElement } = element\n\n if (!element || !parentElement) return element\n\n if (isScrollable(element)) return element\n\n return getScrollParent(parentElement)\n}\n\ntype Props = {\n strength: number | null | undefined\n children: (\n getParallaxProps: <P extends { style?: CSSProperties; [key: string]: unknown }>(props: P) => P,\n ) => ReactNode\n}\n\nexport default function Parallax({ strength, children, ...rest }: Props): ReactNode {\n const container = useRef<HTMLDivElement>(null)\n const [containerScrollTop, setContainerScrollTop] = useState(strength == null ? 0 : strength)\n const lastScrollParentScrollTop = useRef(0)\n\n useIsomorphicLayoutEffect(() => {\n if (!container.current || strength == null || strength === 0) return undefined\n\n const containerDocument = container.current.ownerDocument\n const scrollParent = getScrollParent(container.current)\n const eventTarget =\n containerDocument.documentElement === scrollParent\n ? containerDocument.defaultView!\n : scrollParent\n\n lastScrollParentScrollTop.current = scrollParent.scrollTop\n setContainerScrollTop(strength)\n\n function handleScroll() {\n containerDocument.defaultView!.requestAnimationFrame(() => {\n if (!container.current) return\n\n const { top: containerTop, bottom: containerBottom } =\n container.current.getBoundingClientRect()\n const { top: scrollParentTop, bottom: scrollParentBottom } =\n scrollParent === containerDocument.documentElement\n ? { top: 0, bottom: containerDocument.defaultView!.innerHeight }\n : scrollParent.getBoundingClientRect()\n const { scrollTop: scrollParentScrollTop } =\n scrollParent === containerDocument.documentElement\n ? { scrollTop: containerDocument.defaultView!.pageYOffset }\n : scrollParent\n const scrollParentHeight = scrollParentBottom - scrollParentTop\n const scrollParentScrollDelta = scrollParentScrollTop - lastScrollParentScrollTop.current\n\n lastScrollParentScrollTop.current = scrollParentScrollTop\n\n setContainerScrollTop(scrollTop => {\n const isContainerVisible =\n containerTop < scrollParentTop + scrollParentHeight && containerBottom > scrollParentTop\n const containerScrollRemaining =\n scrollParentScrollDelta > 0 ? 2 * strength! - scrollTop : scrollTop\n const scrollParentScrollRemaining =\n scrollParentScrollDelta > 0\n ? scrollParentTop + containerBottom\n : scrollParentHeight - containerTop\n const parallaxRatio = containerScrollRemaining / scrollParentScrollRemaining\n const containerScrollDelta = isContainerVisible\n ? parallaxRatio * scrollParentScrollDelta\n : 0\n\n return clamp(0, scrollTop + containerScrollDelta, strength! * 2)\n })\n })\n }\n\n eventTarget.addEventListener('scroll', handleScroll)\n\n return () => eventTarget.removeEventListener('scroll', handleScroll)\n }, [strength])\n\n const getProps = useCallback(\n ({ style, ...restOfChildrenProps }: any) => ({\n ...restOfChildrenProps,\n style: {\n ...style,\n position: 'absolute',\n left: 0,\n right: 0,\n top: 0,\n bottom: 0,\n ...(strength == null || strength === 0\n ? {}\n : {\n top: -strength,\n bottom: -strength,\n transform: `translate3d(0, ${containerScrollTop - strength}px, 0)`,\n }),\n },\n }),\n [strength, containerScrollTop],\n )\n\n return (\n <div\n {...rest}\n ref={container}\n style={{ position: 'absolute', top: 0, left: 0, right: 0, bottom: 0 }}\n >\n {children(getProps)}\n </div>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgHI;AAhHJ,mBAAwE;AACxE,mBAAkB;AAClB,uCAA0C;AAE1C,SAAS,aAAa,SAAsB;AAC1C,QAAM,EAAE,UAAU,WAAW,UAAU,IACrC,QAAQ,cAAc,YAAa,iBAAiB,OAAO;AAE7D,SAAO,gBAAgB,KAAK,WAAW,YAAY,SAAS;AAC9D;AAEA,SAAS,gBAAgB,SAAmC;AAC1D,QAAM,EAAE,cAAc,IAAI;AAE1B,MAAI,CAAC,WAAW,CAAC;AAAe,WAAO;AAEvC,MAAI,aAAa,OAAO;AAAG,WAAO;AAElC,SAAO,gBAAgB,aAAa;AACtC;AASe,SAAR,SAA0B,EAAE,UAAU,UAAU,GAAG,KAAK,GAAqB;AAClF,QAAM,gBAAY,qBAAuB,IAAI;AAC7C,QAAM,CAAC,oBAAoB,qBAAqB,QAAI,uBAAS,YAAY,OAAO,IAAI,QAAQ;AAC5F,QAAM,gCAA4B,qBAAO,CAAC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Q,CAAC;AAEb,QAAM,eAAW;AAAA,IACf,CAAC,EAAE,OAAO,GAAG,oBAAoB,OAAY;AAAA,MAC3C,GAAG;AAAA,MACH,OAAO;AAAA,QACL,GAAG;AAAA,QACH,UAAU;AAAA,QACV,MAAM;AAAA,QACN,OAAO;AAAA,QACP,KAAK;AAAA,QACL,QAAQ;AAAA,QACR,GAAI,YAAY,QAAQ,aAAa,IACjC,CAAC,IACD;AAAA,UACE,KAAK,CAAC;AAAA,UACN,QAAQ,CAAC;AAAA,UACT,WAAW,kBAAkB,qBAAqB,QAAQ;AAAA,QAC5D;AAAA,MACN;AAAA,IACF;AAAA,IACA,CAAC,UAAU,kBAAkB;AAAA,EAC/B;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,KAAK;AAAA,MACL,OAAO,EAAE,UAAU,YAAY,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,EAAE;AAAA,MAEnE,mBAAS,QAAQ;AAAA;AAAA,EACpB;AAEJ;","names":["clamp"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/controls/rich-text-v2/plugin.ts"],"sourcesContent":["import { type KeyboardEvent } from 'react'\nimport { type Editor } from 'slate'\nimport { type RenderElementProps, type RenderLeafProps } from 'slate-react'\nimport { ControlDefinition, type Data, type RichTextPluginControl } from '@makeswift/controls'\n\nexport type RenderElement = (props: RenderElementProps) => JSX.Element\nexport type RenderLeaf = (props: RenderLeafProps) => JSX.Element\n\nexport type RichTextV2Plugin<C extends RichTextPluginControl = RichTextPluginControl> = {\n control?: C\n withPlugin?(editor: Editor): Editor\n onKeyDown?(event: KeyboardEvent, editor: Editor): void\n renderElement?: (\n renderElement: RenderElement,\n value: any,\n ) => (props: RenderElementProps) => JSX.Element\n renderLeaf?: (renderLeaf: RenderLeaf, value: any) => (props: RenderLeafProps) => JSX.Element\n}\n\nexport function Plugin<Def extends ControlDefinition, ValueType extends Data>({\n control,\n withPlugin,\n onKeyDown,\n renderElement,\n renderLeaf,\n}: RichTextV2Plugin<RichTextPluginControl<Def, ValueType>>) {\n return { control, withPlugin, onKeyDown, renderElement, renderLeaf }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAmBO,SAAS,OAA8D;AAAA,EAC5E;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA4D;AAC1D,SAAO,EAAE,SAAS,YAAY,WAAW,eAAe,WAAW;AACrE;","names":[]}
1
+ {"version":3,"sources":["../../../../src/controls/rich-text-v2/plugin.ts"],"sourcesContent":["import { type KeyboardEvent, ReactNode } from 'react'\nimport { type Editor } from 'slate'\nimport { type RenderElementProps, type RenderLeafProps } from 'slate-react'\nimport { ControlDefinition, type Data, type RichTextPluginControl } from '@makeswift/controls'\n\nexport type RenderElement = (props: RenderElementProps) => ReactNode\nexport type RenderLeaf = (props: RenderLeafProps) => ReactNode\n\nexport type RichTextV2Plugin<C extends RichTextPluginControl = RichTextPluginControl> = {\n control?: C\n withPlugin?(editor: Editor): Editor\n onKeyDown?(event: KeyboardEvent, editor: Editor): void\n renderElement?: (\n renderElement: RenderElement,\n value: any,\n ) => (props: RenderElementProps) => ReactNode\n renderLeaf?: (renderLeaf: RenderLeaf, value: any) => (props: RenderLeafProps) => ReactNode\n}\n\nexport function Plugin<Def extends ControlDefinition, ValueType extends Data>({\n control,\n withPlugin,\n onKeyDown,\n renderElement,\n renderLeaf,\n}: RichTextV2Plugin<RichTextPluginControl<Def, ValueType>>) {\n return { control, withPlugin, onKeyDown, renderElement, renderLeaf }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAmBO,SAAS,OAA8D;AAAA,EAC5E;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA4D;AAC1D,SAAO,EAAE,SAAS,YAAY,WAAW,eAAe,WAAW;AACrE;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/next/components/framework-provider/pages-router/HeadSnippet.tsx"],"sourcesContent":["import { type ReactElement, useEffect, isValidElement } from 'react'\n\nimport Head from 'next/head'\nimport Script from 'next/script'\n\nimport { type Snippet } from '../../../../client'\n\nimport {\n snippetToElements,\n getSnippetElementsFromDOM,\n cleanUpSnippet,\n} from '../../../../runtimes/react/components/page/HeadSnippet'\n\nconst isScriptElement = (element: string | JSX.Element): element is ReactElement<any, 'script'> =>\n isValidElement(element) && element.type === 'script'\n\nexport function HeadSnippet({ snippet }: { snippet: Snippet }) {\n useEffect(() => {\n return () => {\n const snippetElements = getSnippetElementsFromDOM(snippet)\n if (snippetElements.length > 0) return\n cleanUpSnippet(snippet)\n }\n }, [snippet])\n\n const headSnippetElements = snippetToElements(snippet)\n\n return (\n <>\n {headSnippetElements.map((element, i) =>\n isScriptElement(element) ? (\n <Script key={element.key} {...element.props} strategy=\"beforeInteractive\" />\n ) : (\n <Head key={isValidElement(element) ? element.key : i}>{element}</Head>\n ),\n )}\n </>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA4BI;AA5BJ,mBAA6D;AAE7D,kBAAiB;AACjB,oBAAmB;AAInB,yBAIO;AAEP,MAAM,kBAAkB,CAAC,gBACvB,6BAAe,OAAO,KAAK,QAAQ,SAAS;AAEvC,SAAS,YAAY,EAAE,QAAQ,GAAyB;AAC7D,8BAAU,MAAM;AACd,WAAO,MAAM;AACX,YAAM,sBAAkB,8CAA0B,OAAO;AACzD,UAAI,gBAAgB,SAAS;AAAG;AAChC,6CAAe,OAAO;AAAA,IACxB;AAAA,EACF,GAAG,CAAC,OAAO,CAAC;AAEZ,QAAM,0BAAsB,sCAAkB,OAAO;AAErD,SACE,2EACG,8BAAoB;AAAA,IAAI,CAAC,SAAS,MACjC,gBAAgB,OAAO,IACrB,4CAAC,cAAAA,SAAA,EAA0B,GAAG,QAAQ,OAAO,UAAS,uBAAzC,QAAQ,GAAqD,IAE1E,4CAAC,YAAAC,SAAA,EAAsD,yBAA5C,6BAAe,OAAO,IAAI,QAAQ,MAAM,CAAY;AAAA,EAEnE,GACF;AAEJ;","names":["Script","Head"]}
1
+ {"version":3,"sources":["../../../../../../src/next/components/framework-provider/pages-router/HeadSnippet.tsx"],"sourcesContent":["import { type ReactElement, useEffect, isValidElement, ReactNode } from 'react'\n\nimport Head from 'next/head'\nimport Script from 'next/script'\n\nimport { type Snippet } from '../../../../client'\n\nimport {\n snippetToElements,\n getSnippetElementsFromDOM,\n cleanUpSnippet,\n} from '../../../../runtimes/react/components/page/HeadSnippet'\n\nconst isScriptElement = (element: string | ReactNode): element is ReactElement<any, 'script'> =>\n isValidElement(element) && element.type === 'script'\n\nexport function HeadSnippet({ snippet }: { snippet: Snippet }) {\n useEffect(() => {\n return () => {\n const snippetElements = getSnippetElementsFromDOM(snippet)\n if (snippetElements.length > 0) return\n cleanUpSnippet(snippet)\n }\n }, [snippet])\n\n const headSnippetElements = snippetToElements(snippet)\n\n return (\n <>\n {headSnippetElements.map((element, i) =>\n isScriptElement(element) ? (\n <Script key={element.key} {...element.props} strategy=\"beforeInteractive\" />\n ) : (\n <Head key={isValidElement(element) ? element.key : i}>{element}</Head>\n ),\n )}\n </>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA4BI;AA5BJ,mBAAwE;AAExE,kBAAiB;AACjB,oBAAmB;AAInB,yBAIO;AAEP,MAAM,kBAAkB,CAAC,gBACvB,6BAAe,OAAO,KAAK,QAAQ,SAAS;AAEvC,SAAS,YAAY,EAAE,QAAQ,GAAyB;AAC7D,8BAAU,MAAM;AACd,WAAO,MAAM;AACX,YAAM,sBAAkB,8CAA0B,OAAO;AACzD,UAAI,gBAAgB,SAAS;AAAG;AAChC,6CAAe,OAAO;AAAA,IACxB;AAAA,EACF,GAAG,CAAC,OAAO,CAAC;AAEZ,QAAM,0BAAsB,sCAAkB,OAAO;AAErD,SACE,2EACG,8BAAoB;AAAA,IAAI,CAAC,SAAS,MACjC,gBAAgB,OAAO,IACrB,4CAAC,cAAAA,SAAA,EAA0B,GAAG,QAAQ,OAAO,UAAS,uBAAzC,QAAQ,GAAqD,IAE1E,4CAAC,YAAAC,SAAA,EAAsD,yBAA5C,6BAAe,OAAO,IAAI,QAAQ,MAAM,CAAY;AAAA,EAEnE,GACF;AAEJ;","names":["Script","Head"]}
@@ -35,7 +35,6 @@ var import_jsx_runtime = require("react/jsx-runtime");
35
35
  var import_react = require("react");
36
36
  var import_server = require("react-dom/server");
37
37
  var import_jsdom = require("jsdom");
38
- var import_test_utils = require("react-dom/test-utils");
39
38
  var import_react2 = require("@testing-library/react");
40
39
  var import_jest_dom = require("@testing-library/jest-dom");
41
40
  var import_navigation = require("next/navigation");
@@ -127,9 +126,9 @@ async function testPageControlPropRendering(controlDefinition, {
127
126
  ROOT_ID
128
127
  );
129
128
  const snapshot = Testing.createMakeswiftPageSnapshot(rootElementData, { locale, cacheData });
130
- await (0, import_test_utils.act)(async () => (0, import_react2.render)(testElementTree(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_page.Page, { snapshot }))));
129
+ await (0, import_react.act)(async () => (0, import_react2.render)(testElementTree(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_page.Page, { snapshot }))));
131
130
  if (action) {
132
- await (0, import_test_utils.act)(async () => {
131
+ await (0, import_react.act)(async () => {
133
132
  await action(import_react2.screen.getByTestId(testId));
134
133
  });
135
134
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/next/components/tests/controls/page-control-prop-rendering.tsx"],"sourcesContent":["import { type ReactNode, Fragment, forwardRef, useRef, isValidElement } from 'react'\nimport { renderToReadableStream } from 'react-dom/server'\nimport { JSDOM } from 'jsdom'\nimport { act } from 'react-dom/test-utils'\nimport { render, screen } from '@testing-library/react'\nimport '@testing-library/jest-dom'\nimport { ServerInsertedHTMLContext } from 'next/navigation'\n\nimport { type Data, type ValueType, type DataType, ControlDefinition } from '@makeswift/controls'\n\nimport { type CacheData } from '../../../../api/react'\nimport { ElementData } from '../../../../state/react-page'\nimport { ReactRuntime } from '../../../../react'\nimport { MakeswiftComponent } from '../../../../runtimes/react/components/MakeswiftComponent'\nimport { Page } from '../../page'\nimport { isServer } from '../../../../utils/is-server'\nimport * as Testing from '../../../testing'\n\nconst ROOT_ID = '00000000-0000-0000-0000-000000000000'\nconst ELEMENT_ID = '11111111-1111-1111-1111-111111111111'\n\nconst renderProp = (prop: any) =>\n prop === undefined ? 'undefined' : isValidElement(prop) ? prop : JSON.stringify(prop)\n\nconst propSnapshot = (prop: HTMLElement | null) =>\n prop?.childElementCount ? prop.childNodes : parseStringifiedProp(prop?.textContent ?? '')\n\nconst parseStringifiedProp = (prop: string) => (prop === 'undefined' ? undefined : JSON.parse(prop))\n\nasync function streamToString(stream: ReadableStream) {\n const reader = stream.getReader()\n const decoder = new TextDecoder()\n\n let result = ''\n\n while (true) {\n const { done, value } = await reader.read()\n if (done) break\n result += decoder.decode(value, { stream: true })\n }\n\n return result\n}\n\nasync function renderToString(element: ReactNode) {\n return await streamToString(await renderToReadableStream(element))\n}\n\nasync function serverSideRender(children: ReactNode) {\n // wrap the children in a context provider to capture server-inserted HTML, see\n // https://github.com/vercel/next.js/blob/canary/packages/next/src/server/app-render/server-inserted-html.tsx\n const serverInsertedCallbacks: (() => React.ReactNode)[] = []\n\n const elementTree = (\n <ServerInsertedHTMLContext.Provider value={handler => serverInsertedCallbacks.push(handler)}>\n {children}\n </ServerInsertedHTMLContext.Provider>\n )\n\n const elementsHTML = await renderToString(elementTree)\n\n const serverInsertedNodes = serverInsertedCallbacks.map((callback, index) => (\n <Fragment key={'__next_server_inserted__' + index}>{callback()}</Fragment>\n ))\n\n const headHTML = await renderToString(serverInsertedNodes)\n\n const dom = new JSDOM(\n `<!DOCTYPE html><head>${headHTML}</head><body><div id=\"root\">${elementsHTML}</div></body></div>`,\n {\n runScripts: 'dangerously',\n },\n )\n\n return dom.window.document\n}\n\nexport async function testPageControlPropRendering<D extends ControlDefinition>(\n controlDefinition: D,\n {\n toData,\n value,\n locale,\n cacheData,\n expectedRenders,\n registerComponents,\n action,\n rootElements = [],\n }: {\n toData?: (value: ValueType<D>) => DataType<D>\n value: ValueType<D> | undefined\n locale?: string | null\n cacheData?: Partial<CacheData>\n expectedRenders?: number\n registerComponents?: (runtime: ReactRuntime) => void\n action?: (element: HTMLElement) => Promise<void>\n rootElements?: ElementData[]\n },\n) {\n // Arrange\n const controlData: DataType<D> | Data =\n value !== undefined ? (toData ? toData(value) : controlDefinition.toData(value)) : undefined\n\n const testComponentMeta = {\n type: 'TestComponent',\n label: 'Test Component',\n }\n\n const testId = 'test-id'\n const renderCountTestId = 'render-count-test-id'\n const elementData: ElementData = {\n key: ELEMENT_ID,\n type: testComponentMeta.type,\n props: {\n propKey: controlData,\n },\n }\n\n const runtime = new ReactRuntime()\n registerComponents?.(runtime)\n\n // Act\n runtime.registerComponent(\n forwardRef<HTMLDivElement, { propKey?: any }>(({ propKey }, ref) => {\n const renderCount = useRef(0)\n ++renderCount.current\n\n return (\n <div ref={ref}>\n <div data-testid={renderCountTestId}>{renderCount.current}</div>\n <div data-testid={testId}>{renderProp(propKey)}</div>\n </div>\n )\n }),\n {\n ...testComponentMeta,\n props: {\n propKey: controlDefinition as any,\n },\n },\n )\n\n const testElementTree = (component: ReactNode) => (\n <Testing.ReactProvider runtime={runtime}>{component}</Testing.ReactProvider>\n )\n\n if (!isServer()) {\n const rootElementData: ElementData = Testing.createRootComponent(\n [elementData, ...rootElements],\n ROOT_ID,\n )\n\n const snapshot = Testing.createMakeswiftPageSnapshot(rootElementData, { locale, cacheData })\n\n // Assert\n await act(async () => render(testElementTree(<Page snapshot={snapshot} />)))\n\n if (action) {\n await act(async () => {\n await action(screen.getByTestId(testId))\n })\n }\n\n expect(snapshot).toMatchSnapshot('snapshot')\n expect(propSnapshot(screen.getByTestId(testId))).toMatchSnapshot('resolvedValue')\n\n if (expectedRenders != null) {\n expect(Number(screen.getByTestId(renderCountTestId).textContent)).toBe(expectedRenders)\n }\n } else {\n // test server-side rendering using a component snapshot\n console.assert(action == null)\n console.assert(rootElements.length === 0)\n\n const snapshot = Testing.createMakeswiftComponentSnapshot(elementData, { locale, cacheData })\n const elementTree = testElementTree(\n <MakeswiftComponent snapshot={snapshot} {...testComponentMeta} />,\n )\n\n const document = await serverSideRender(elementTree)\n const getByTestId = (id: string): HTMLElement | null =>\n document.querySelector(`[data-testid=\"${id}\"]`)\n\n expect(propSnapshot(getByTestId(testId))).toMatchSnapshot('resolvedValue')\n expect([...document.querySelectorAll('style')].map(n => n.textContent)).toMatchSnapshot(\n 'component styles',\n )\n expect(Number(getByTestId(renderCountTestId)?.textContent)).toBe(1)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAsDI;AAtDJ,mBAA6E;AAC7E,oBAAuC;AACvC,mBAAsB;AACtB,wBAAoB;AACpB,IAAAA,gBAA+B;AAC/B,sBAAO;AACP,wBAA0C;AAM1C,IAAAA,gBAA6B;AAC7B,gCAAmC;AACnC,kBAAqB;AACrB,uBAAyB;AACzB,cAAyB;AAEzB,MAAM,UAAU;AAChB,MAAM,aAAa;AAEnB,MAAM,aAAa,CAAC,SAClB,SAAS,SAAY,kBAAc,6BAAe,IAAI,IAAI,OAAO,KAAK,UAAU,IAAI;AAEtF,MAAM,eAAe,CAAC,SACpB,MAAM,oBAAoB,KAAK,aAAa,qBAAqB,MAAM,eAAe,EAAE;AAE1F,MAAM,uBAAuB,CAAC,SAAkB,SAAS,cAAc,SAAY,KAAK,MAAM,IAAI;AAElG,eAAe,eAAe,QAAwB;AACpD,QAAM,SAAS,OAAO,UAAU;AAChC,QAAM,UAAU,IAAI,YAAY;AAEhC,MAAI,SAAS;AAEb,SAAO,MAAM;AACX,UAAM,EAAE,MAAM,MAAM,IAAI,MAAM,OAAO,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A,UAAM,WAAW,MAAM,iBAAiB,WAAW;AACnD,UAAM,cAAc,CAAC,OACnB,SAAS,cAAc,iBAAiB,EAAE,IAAI;AAEhD,WAAO,aAAa,YAAY,MAAM,CAAC,CAAC,EAAE,gBAAgB,eAAe;AACzE,WAAO,CAAC,GAAG,SAAS,iBAAiB,OAAO,CAAC,EAAE,IAAI,OAAK,EAAE,WAAW,CAAC,EAAE;AAAA,MACtE;AAAA,IACF;AACA,WAAO,OAAO,YAAY,iBAAiB,GAAG,WAAW,CAAC,EAAE,KAAK,CAAC;AAAA,EACpE;AACF;","names":["import_react"]}
1
+ {"version":3,"sources":["../../../../../../src/next/components/tests/controls/page-control-prop-rendering.tsx"],"sourcesContent":["import { type ReactNode, Fragment, forwardRef, useRef, isValidElement, act } from 'react';\nimport { renderToReadableStream } from 'react-dom/server'\nimport { JSDOM } from 'jsdom'\nimport { render, screen } from '@testing-library/react'\nimport '@testing-library/jest-dom'\nimport { ServerInsertedHTMLContext } from 'next/navigation'\n\nimport { type Data, type ValueType, type DataType, ControlDefinition } from '@makeswift/controls'\n\nimport { type CacheData } from '../../../../api/react'\nimport { ElementData } from '../../../../state/react-page'\nimport { ReactRuntime } from '../../../../react'\nimport { MakeswiftComponent } from '../../../../runtimes/react/components/MakeswiftComponent'\nimport { Page } from '../../page'\nimport { isServer } from '../../../../utils/is-server'\nimport * as Testing from '../../../testing'\n\nconst ROOT_ID = '00000000-0000-0000-0000-000000000000'\nconst ELEMENT_ID = '11111111-1111-1111-1111-111111111111'\n\nconst renderProp = (prop: any) =>\n prop === undefined ? 'undefined' : isValidElement(prop) ? prop : JSON.stringify(prop)\n\nconst propSnapshot = (prop: HTMLElement | null) =>\n prop?.childElementCount ? prop.childNodes : parseStringifiedProp(prop?.textContent ?? '')\n\nconst parseStringifiedProp = (prop: string) => (prop === 'undefined' ? undefined : JSON.parse(prop))\n\nasync function streamToString(stream: ReadableStream) {\n const reader = stream.getReader()\n const decoder = new TextDecoder()\n\n let result = ''\n\n while (true) {\n const { done, value } = await reader.read()\n if (done) break\n result += decoder.decode(value, { stream: true })\n }\n\n return result\n}\n\nasync function renderToString(element: ReactNode) {\n return await streamToString(await renderToReadableStream(element))\n}\n\nasync function serverSideRender(children: ReactNode) {\n // wrap the children in a context provider to capture server-inserted HTML, see\n // https://github.com/vercel/next.js/blob/canary/packages/next/src/server/app-render/server-inserted-html.tsx\n const serverInsertedCallbacks: (() => React.ReactNode)[] = []\n\n const elementTree = (\n <ServerInsertedHTMLContext.Provider value={handler => serverInsertedCallbacks.push(handler)}>\n {children}\n </ServerInsertedHTMLContext.Provider>\n )\n\n const elementsHTML = await renderToString(elementTree)\n\n const serverInsertedNodes = serverInsertedCallbacks.map((callback, index) => (\n <Fragment key={'__next_server_inserted__' + index}>{callback()}</Fragment>\n ))\n\n const headHTML = await renderToString(serverInsertedNodes)\n\n const dom = new JSDOM(\n `<!DOCTYPE html><head>${headHTML}</head><body><div id=\"root\">${elementsHTML}</div></body></div>`,\n {\n runScripts: 'dangerously',\n },\n )\n\n return dom.window.document\n}\n\nexport async function testPageControlPropRendering<D extends ControlDefinition>(\n controlDefinition: D,\n {\n toData,\n value,\n locale,\n cacheData,\n expectedRenders,\n registerComponents,\n action,\n rootElements = [],\n }: {\n toData?: (value: ValueType<D>) => DataType<D>\n value: ValueType<D> | undefined\n locale?: string | null\n cacheData?: Partial<CacheData>\n expectedRenders?: number\n registerComponents?: (runtime: ReactRuntime) => void\n action?: (element: HTMLElement) => Promise<void>\n rootElements?: ElementData[]\n },\n) {\n // Arrange\n const controlData: DataType<D> | Data =\n value !== undefined ? (toData ? toData(value) : controlDefinition.toData(value)) : undefined\n\n const testComponentMeta = {\n type: 'TestComponent',\n label: 'Test Component',\n }\n\n const testId = 'test-id'\n const renderCountTestId = 'render-count-test-id'\n const elementData: ElementData = {\n key: ELEMENT_ID,\n type: testComponentMeta.type,\n props: {\n propKey: controlData,\n },\n }\n\n const runtime = new ReactRuntime()\n registerComponents?.(runtime)\n\n // Act\n runtime.registerComponent(\n forwardRef<HTMLDivElement, { propKey?: any }>(({ propKey }, ref) => {\n const renderCount = useRef(0)\n ++renderCount.current\n\n return (\n <div ref={ref}>\n <div data-testid={renderCountTestId}>{renderCount.current}</div>\n <div data-testid={testId}>{renderProp(propKey)}</div>\n </div>\n )\n }),\n {\n ...testComponentMeta,\n props: {\n propKey: controlDefinition as any,\n },\n },\n )\n\n const testElementTree = (component: ReactNode) => (\n <Testing.ReactProvider runtime={runtime}>{component}</Testing.ReactProvider>\n )\n\n if (!isServer()) {\n const rootElementData: ElementData = Testing.createRootComponent(\n [elementData, ...rootElements],\n ROOT_ID,\n )\n\n const snapshot = Testing.createMakeswiftPageSnapshot(rootElementData, { locale, cacheData })\n\n // Assert\n await act(async () => render(testElementTree(<Page snapshot={snapshot} />)))\n\n if (action) {\n await act(async () => {\n await action(screen.getByTestId(testId))\n })\n }\n\n expect(snapshot).toMatchSnapshot('snapshot')\n expect(propSnapshot(screen.getByTestId(testId))).toMatchSnapshot('resolvedValue')\n\n if (expectedRenders != null) {\n expect(Number(screen.getByTestId(renderCountTestId).textContent)).toBe(expectedRenders)\n }\n } else {\n // test server-side rendering using a component snapshot\n console.assert(action == null)\n console.assert(rootElements.length === 0)\n\n const snapshot = Testing.createMakeswiftComponentSnapshot(elementData, { locale, cacheData })\n const elementTree = testElementTree(\n <MakeswiftComponent snapshot={snapshot} {...testComponentMeta} />,\n )\n\n const document = await serverSideRender(elementTree)\n const getByTestId = (id: string): HTMLElement | null =>\n document.querySelector(`[data-testid=\"${id}\"]`)\n\n expect(propSnapshot(getByTestId(testId))).toMatchSnapshot('resolvedValue')\n expect([...document.querySelectorAll('style')].map(n => n.textContent)).toMatchSnapshot(\n 'component styles',\n )\n expect(Number(getByTestId(renderCountTestId)?.textContent)).toBe(1)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAqDI;AArDJ,mBAAkF;AAClF,oBAAuC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B,CAAE,CAAC,CAAC;AAE3E,QAAI,QAAQ;AACV,gBAAM,kBAAI,YAAY;AACpB,cAAM,OAAO,qBAAO,YAAY,MAAM,CAAC;AAAA,MACzC,CAAC;AAAA,IACH;AAEA,WAAO,QAAQ,EAAE,gBAAgB,UAAU;AAC3C,WAAO,aAAa,qBAAO,YAAY,MAAM,CAAC,CAAC,EAAE,gBAAgB,eAAe;AAEhF,QAAI,mBAAmB,MAAM;AAC3B,aAAO,OAAO,qBAAO,YAAY,iBAAiB,EAAE,WAAW,CAAC,EAAE,KAAK,eAAe;AAAA,IACxF;AAAA,EACF,OAAO;AAEL,YAAQ,OAAO,UAAU,IAAI;AAC7B,YAAQ,OAAO,aAAa,WAAW,CAAC;AAExC,UAAM,WAAW,QAAQ,iCAAiC,aAAa,EAAE,QAAQ,UAAU,CAAC;AAC5F,UAAM,cAAc;AAAA,MAClB,4CAAC,gDAAmB,UAAqB,GAAG,mBAAmB;AAAA,IACjE;AAEA,UAAM,WAAW,MAAM,iBAAiB,WAAW;AACnD,UAAM,cAAc,CAAC,OACnB,SAAS,cAAc,iBAAiB,EAAE,IAAI;AAEhD,WAAO,aAAa,YAAY,MAAM,CAAC,CAAC,EAAE,gBAAgB,eAAe;AACzE,WAAO,CAAC,GAAG,SAAS,iBAAiB,OAAO,CAAC,EAAE,IAAI,OAAK,EAAE,WAAW,CAAC,EAAE;AAAA,MACtE;AAAA,IACF;AACA,WAAO,OAAO,YAAY,iBAAiB,GAAG,WAAW,CAAC,EAAE,KAAK,CAAC;AAAA,EACpE;AACF;","names":["import_react"]}
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var fixtures_exports = {};
30
+ __export(fixtures_exports, {
31
+ CustomComponent: () => CustomComponent,
32
+ CustomComponentType: () => CustomComponentType,
33
+ CustomComponentWithFallback: () => CustomComponentWithFallback,
34
+ componentId: () => componentId,
35
+ containerId: () => containerId,
36
+ elementData: () => elementData,
37
+ fallbackId: () => fallbackId,
38
+ renderComponentSnapshot: () => renderComponentSnapshot
39
+ });
40
+ module.exports = __toCommonJS(fixtures_exports);
41
+ var import_jsx_runtime = require("react/jsx-runtime");
42
+ var import_react = require("react");
43
+ var import_react2 = require("@testing-library/react");
44
+ var import_react3 = require("../../../../react");
45
+ var Testing = __toESM(require("../../../testing"));
46
+ var import_MakeswiftComponent = require("../../../../runtimes/react/components/MakeswiftComponent");
47
+ var import_controls = require("@makeswift/controls");
48
+ const CustomComponentType = "CustomComponent";
49
+ const componentId = "component-id";
50
+ const containerId = "container-id";
51
+ const fallbackId = "fallback-id";
52
+ function CustomComponent({ text, suspend }) {
53
+ if (suspend) {
54
+ throw new Promise(() => {
55
+ });
56
+ }
57
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { "data-testid": componentId, children: text });
58
+ }
59
+ function CustomComponentWithFallback(props) {
60
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { "data-testid": fallbackId, children: "Loading..." }), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CustomComponent, { ...props }) });
61
+ }
62
+ const elementData = (props) => ({
63
+ type: CustomComponentType,
64
+ key: "0000-0000-0000-0000",
65
+ props
66
+ });
67
+ async function renderComponentSnapshot(snapshot, component = CustomComponent, { builtinSuspense } = {}) {
68
+ const runtime = new import_react3.ReactRuntime();
69
+ runtime.registerComponent(component, {
70
+ type: CustomComponentType,
71
+ label: "Custom Component",
72
+ builtinSuspense,
73
+ props: {
74
+ text: (0, import_controls.TextInput)({ defaultValue: "Default Text" }),
75
+ suspend: (0, import_controls.Checkbox)({ defaultValue: false, label: "Suspend" })
76
+ }
77
+ });
78
+ await (0, import_react.act)(
79
+ async () => (0, import_react2.render)(
80
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Testing.ReactProvider, { runtime, siteVersion: null, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { "data-testid": containerId, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
81
+ import_MakeswiftComponent.MakeswiftComponent,
82
+ {
83
+ label: "Embedded Component",
84
+ type: CustomComponentType,
85
+ snapshot
86
+ }
87
+ ) }) })
88
+ )
89
+ );
90
+ }
91
+ // Annotate the CommonJS export names for ESM import in node:
92
+ 0 && (module.exports = {
93
+ CustomComponent,
94
+ CustomComponentType,
95
+ CustomComponentWithFallback,
96
+ componentId,
97
+ containerId,
98
+ elementData,
99
+ fallbackId,
100
+ renderComponentSnapshot
101
+ });
102
+ //# sourceMappingURL=fixtures.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../src/next/components/tests/makeswift-component/fixtures.tsx"],"sourcesContent":["import { Suspense, act } from 'react'\nimport { render } from '@testing-library/react'\n\nimport { ReactRuntime } from '../../../../react'\nimport * as Testing from '../../../testing'\nimport { MakeswiftComponent } from '../../../../runtimes/react/components/MakeswiftComponent'\nimport { type MakeswiftComponentSnapshot } from '../../../../client'\n\nimport { Checkbox, TextInput } from '@makeswift/controls'\nimport { ComponentType } from '../../../../state/react-page'\n\nexport const CustomComponentType = 'CustomComponent'\nexport const componentId = 'component-id'\nexport const containerId = 'container-id'\nexport const fallbackId = 'fallback-id'\n\nexport type ComponentProps = {\n text: string\n suspend: boolean\n}\n\nexport function CustomComponent({ text, suspend }: ComponentProps) {\n if (suspend) {\n throw new Promise(() => {}) // suspend indefinitely\n }\n\n return <div data-testid={componentId}>{text}</div>\n}\n\nexport function CustomComponentWithFallback(props: ComponentProps) {\n return (\n <Suspense fallback={<div data-testid={fallbackId}>Loading...</div>}>\n <CustomComponent {...props} />\n </Suspense>\n )\n}\n\nexport const elementData = (props: { text: string; suspend?: boolean }) => ({\n type: CustomComponentType,\n key: '0000-0000-0000-0000',\n props,\n})\n\nexport async function renderComponentSnapshot(\n snapshot: MakeswiftComponentSnapshot,\n component: ComponentType<ComponentProps> = CustomComponent,\n { builtinSuspense }: { builtinSuspense?: boolean } = {},\n) {\n const runtime = new ReactRuntime()\n\n runtime.registerComponent(component, {\n type: CustomComponentType,\n label: 'Custom Component',\n builtinSuspense,\n props: {\n text: TextInput({ defaultValue: 'Default Text' }),\n suspend: Checkbox({ defaultValue: false, label: 'Suspend' }),\n },\n })\n\n await act(async () =>\n render(\n <Testing.ReactProvider runtime={runtime} siteVersion={null}>\n <div data-testid={containerId}>\n <MakeswiftComponent\n label=\"Embedded Component\"\n type={CustomComponentType}\n snapshot={snapshot}\n />\n </div>\n </Testing.ReactProvider>,\n ),\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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est-dom");
37
37
  var import_prop_controllers = require("@makeswift/prop-controllers");
38
38
  var import_crypto = require("crypto");
39
39
  var import_page = require("../../page");
40
- var import_test_utils = require("react-dom/test-utils");
41
- var import_react2 = require("../../../../react");
40
+ var import_react2 = require("react");
41
+ var import_react3 = require("../../../../react");
42
42
  var Testing = __toESM(require("../../../testing"));
43
43
  const pagePropControllerTest = (propDef, value, component, assert, options) => describe("Page", () => {
44
44
  test(`can render ${propDef.type} v0 data`, async () => {
@@ -58,7 +58,7 @@ const pagePropControllerTest = (propDef, value, component, assert, options) => d
58
58
  }
59
59
  ]);
60
60
  const snapshot = Testing.createMakeswiftPageSnapshot(elementData);
61
- const runtime = new import_react2.ReactRuntime();
61
+ const runtime = new import_react3.ReactRuntime();
62
62
  runtime.registerComponent(component(testId), {
63
63
  type: TestComponentType,
64
64
  label: "TestComponent",
@@ -66,7 +66,7 @@ const pagePropControllerTest = (propDef, value, component, assert, options) => d
66
66
  propKey: propDef(options)
67
67
  }
68
68
  });
69
- await (0, import_test_utils.act)(
69
+ await (0, import_react2.act)(
70
70
  async () => (0, import_react.render)(
71
71
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Testing.ReactProvider, { runtime, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_page.Page, { snapshot }) })
72
72
  )
@@ -91,7 +91,7 @@ const pagePropControllerTest = (propDef, value, component, assert, options) => d
91
91
  }
92
92
  ]);
93
93
  const snapshot = Testing.createMakeswiftPageSnapshot(elementData);
94
- const runtime = new import_react2.ReactRuntime();
94
+ const runtime = new import_react3.ReactRuntime();
95
95
  runtime.registerComponent(component(testId), {
96
96
  type: TestComponentType,
97
97
  label: "TestComponent",
@@ -99,7 +99,7 @@ const pagePropControllerTest = (propDef, value, component, assert, options) => d
99
99
  propKey: propDef(options)
100
100
  }
101
101
  });
102
- await (0, import_test_utils.act)(
102
+ await (0, import_react2.act)(
103
103
  async () => (0, import_react.render)(
104
104
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Testing.ReactProvider, { runtime, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_page.Page, { snapshot }) })
105
105
  )
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/next/components/tests/prop-controllers/page-prop-controller.tsx"],"sourcesContent":["/** @jest-environment jsdom */\n\nimport { render, screen } from '@testing-library/react'\nimport '@testing-library/jest-dom'\n\nimport {\n type OptionsType,\n Types,\n type Descriptor,\n type PropDef,\n type Value,\n} from '@makeswift/prop-controllers'\n\nimport { type ElementData, type ComponentType } from '../../../../state/react-page'\nimport { randomUUID } from 'crypto'\n\nimport { Page } from '../../page'\nimport { act } from 'react-dom/test-utils'\nimport { ReactRuntime } from '../../../../react'\nimport * as Testing from '../../../testing'\n\nexport const pagePropControllerTest = <\n P extends PropDef & ((options?: any) => any),\n C extends ComponentType<{ propKey: Value<P> | undefined }>,\n>(\n propDef: P,\n value: Value<typeof propDef>,\n component: (testId: string) => C,\n assert: (element: HTMLElement) => void,\n options?: OptionsType<P>,\n) =>\n describe('Page', () => {\n test(`can render ${propDef.type} v0 data`, async () => {\n // Arrange\n const descriptorV0: Descriptor<typeof propDef> = {\n type: propDef.type,\n options,\n }\n\n const TestComponentType = 'TestComponent'\n const testId = 'test-id'\n\n const elementData: ElementData = Testing.createRootComponent([\n {\n key: randomUUID(),\n type: TestComponentType,\n props: {\n propKey: propDef.toPropData(value, descriptorV0),\n },\n },\n ])\n const snapshot = Testing.createMakeswiftPageSnapshot(elementData)\n const runtime = new ReactRuntime()\n\n runtime.registerComponent(component(testId), {\n type: TestComponentType,\n label: 'TestComponent',\n props: {\n propKey: propDef(options),\n },\n })\n\n await act(async () =>\n render(\n <Testing.ReactProvider runtime={runtime}>\n <Page snapshot={snapshot} />\n </Testing.ReactProvider>,\n ),\n )\n\n assert(screen.getByTestId(testId))\n })\n\n test(`can render ${propDef.type} v1 data`, async () => {\n // Arrange\n const gapXDefinitionV1: Descriptor<typeof propDef> = {\n type: Types.GapX,\n version: 1,\n options: {},\n }\n\n const TestComponentType = 'TestComponent'\n const testId = 'test-id'\n const elementData: ElementData = Testing.createRootComponent([\n {\n key: randomUUID(),\n type: TestComponentType,\n props: {\n propKey: propDef.toPropData(value, gapXDefinitionV1),\n },\n },\n ])\n const snapshot = Testing.createMakeswiftPageSnapshot(elementData)\n const runtime = new ReactRuntime()\n\n runtime.registerComponent(component(testId), {\n type: TestComponentType,\n label: 'TestComponent',\n props: {\n propKey: propDef(options),\n },\n })\n\n await act(async () =>\n render(\n <Testing.ReactProvider runtime={runtime}>\n <Page snapshot={snapshot} />\n </Testing.ReactProvider>,\n ),\n )\n\n assert(screen.getByTestId(testId))\n })\n })\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAiEY;AA/DZ,mBAA+B;AAC/B,sBAAO;AAEP,8BAMO;AAGP,oBAA2B;AAE3B,kBAAqB;AACrB,wBAAoB;AACpB,IAAAA,gBAA6B;AAC7B,cAAyB;AAElB,MAAM,yBAAyB,CAIpC,SACA,OACA,WACA,QACA,YAEA,SAAS,QAAQ,MAAM;AACrB,OAAK,cAAc,QAAQ,IAAI,YAAY,YAAY;AAErD,UAAM,eAA2C;AAAA,MAC/C,MAAM,QAAQ;AAAA,MACd;AAAA,IACF;AAEA,UAAM,oBAAoB;AAC1B,UAAM,SAAS;AAEf,UAAM,cAA2B,QAAQ,oBAAoB;AAAA,MAC3D;AAAA,QACE,SAAK,0BAAW;AAAA,QAChB,MAAM;AAAA,QACN,OAAO;AAAA,UACL,SAAS,QAAQ,WAAW,OAAO,YAAY;AAAA,QACjD;AAAA,MACF;AAAA,IACF,CAAC;AACD,UAAM,WAAW,QAAQ,4BAA4B,WAAW;AAChE,UAAM,UAAU,IAAI,2BAAa;AAEjC,YAAQ,kBAAkB,UAAU,MAAM,GAAG;AAAA,MAC3C,MAAM;AAAA,MACN,OAAO;AAAA,MACP,OAAO;AAAA,QACL,SAAS,QAAQ,OAAO;AAAA,MAC1B;AAAA,IACF,CAAC;AAED,cAAM;AAAA,MAAI,gBACR;AAAA,QACE,4CAAC,QAAQ,eAAR,EAAsB,SACrB,sDAAC,oBAAK,UAAoB,GAC5B;AAAA,MACF;AAAA,IACF;AAEA,WAAO,oBAAO,YAAY,MAAM,CAAC;AAAA,EACnC,CAAC;AAED,OAAK,cAAc,QAAQ,IAAI,YAAY,YAAY;AAErD,UAAM,mBAA+C;AAAA,MACnD,MAAM,8BAAM;AAAA,MACZ,SAAS;AAAA,MACT,SAAS,CAAC;AAAA,IACZ;AAEA,UAAM,oBAAoB;AAC1B,UAAM,SAAS;AACf,UAAM,cAA2B,QAAQ,oBAAoB;AAAA,MAC3D;AAAA,QACE,SAAK,0BAAW;AAAA,QAChB,MAAM;AAAA,QACN,OAAO;AAAA,UACL,SAAS,QAAQ,WAAW,OAAO,gBAAgB;AAAA,QACrD;AAAA,MACF;AAAA,IACF,CAAC;AACD,UAAM,WAAW,QAAQ,4BAA4B,WAAW;AAChE,UAAM,UAAU,IAAI,2BAAa;AAEjC,YAAQ,kBAAkB,UAAU,MAAM,GAAG;AAAA,MAC3C,MAAM;AAAA,MACN,OAAO;AAAA,MACP,OAAO;AAAA,QACL,SAAS,QAAQ,OAAO;AAAA,MAC1B;AAAA,IACF,CAAC;AAED,cAAM;AAAA,MAAI,gBACR;AAAA,QACE,4CAAC,QAAQ,eAAR,EAAsB,SACrB,sDAAC,oBAAK,UAAoB,GAC5B;AAAA,MACF;AAAA,IACF;AAEA,WAAO,oBAAO,YAAY,MAAM,CAAC;AAAA,EACnC,CAAC;AACH,CAAC;","names":["import_react"]}
1
+ {"version":3,"sources":["../../../../../../src/next/components/tests/prop-controllers/page-prop-controller.tsx"],"sourcesContent":["/** @jest-environment jsdom */\n\nimport { render, screen } from '@testing-library/react'\nimport '@testing-library/jest-dom'\n\nimport {\n type OptionsType,\n Types,\n type Descriptor,\n type PropDef,\n type Value,\n} from '@makeswift/prop-controllers'\n\nimport { type ElementData, type ComponentType } from '../../../../state/react-page'\nimport { randomUUID } from 'crypto'\n\nimport { Page } from '../../page'\nimport { act } from \"react\";\nimport { ReactRuntime } from '../../../../react'\nimport * as Testing from '../../../testing'\n\nexport const pagePropControllerTest = <\n P extends PropDef & ((options?: any) => any),\n C extends ComponentType<{ propKey: Value<P> | undefined }>,\n>(\n propDef: P,\n value: Value<typeof propDef>,\n component: (testId: string) => C,\n assert: (element: HTMLElement) => void,\n options?: OptionsType<P>,\n) =>\n describe('Page', () => {\n test(`can render ${propDef.type} v0 data`, async () => {\n // Arrange\n const descriptorV0: Descriptor<typeof propDef> = {\n type: propDef.type,\n options,\n }\n\n const TestComponentType = 'TestComponent'\n const testId = 'test-id'\n\n const elementData: ElementData = Testing.createRootComponent([\n {\n key: randomUUID(),\n type: TestComponentType,\n props: {\n propKey: propDef.toPropData(value, descriptorV0),\n },\n },\n ])\n const snapshot = Testing.createMakeswiftPageSnapshot(elementData)\n const runtime = new ReactRuntime()\n\n runtime.registerComponent(component(testId), {\n type: TestComponentType,\n label: 'TestComponent',\n props: {\n propKey: propDef(options),\n },\n })\n\n await act(async () =>\n render(\n <Testing.ReactProvider runtime={runtime}>\n <Page snapshot={snapshot} />\n </Testing.ReactProvider>,\n ),\n )\n\n assert(screen.getByTestId(testId))\n })\n\n test(`can render ${propDef.type} v1 data`, async () => {\n // Arrange\n const gapXDefinitionV1: Descriptor<typeof propDef> = {\n type: Types.GapX,\n version: 1,\n options: {},\n }\n\n const TestComponentType = 'TestComponent'\n const testId = 'test-id'\n const elementData: ElementData = Testing.createRootComponent([\n {\n key: randomUUID(),\n type: TestComponentType,\n props: {\n propKey: propDef.toPropData(value, gapXDefinitionV1),\n },\n },\n ])\n const snapshot = Testing.createMakeswiftPageSnapshot(elementData)\n const runtime = new ReactRuntime()\n\n runtime.registerComponent(component(testId), {\n type: TestComponentType,\n label: 'TestComponent',\n props: {\n propKey: propDef(options),\n },\n })\n\n await act(async () =>\n render(\n <Testing.ReactProvider runtime={runtime}>\n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AAA,IACZ;AAEA,UAAM,oBAAoB;AAC1B,UAAM,SAAS;AACf,UAAM,cAA2B,QAAQ,oBAAoB;AAAA,MAC3D;AAAA,QACE,SAAK,0BAAW;AAAA,QAChB,MAAM;AAAA,QACN,OAAO;AAAA,UACL,SAAS,QAAQ,WAAW,OAAO,gBAAgB;AAAA,QACrD;AAAA,MACF;AAAA,IACF,CAAC;AACD,UAAM,WAAW,QAAQ,4BAA4B,WAAW;AAChE,UAAM,UAAU,IAAI,2BAAa;AAEjC,YAAQ,kBAAkB,UAAU,MAAM,GAAG;AAAA,MAC3C,MAAM;AAAA,MACN,OAAO;AAAA,MACP,OAAO;AAAA,QACL,SAAS,QAAQ,OAAO;AAAA,MAC1B;AAAA,IACF,CAAC;AAED,cAAM;AAAA,MAAI,gBACR;AAAA,QACE,4CAAC,QAAQ,eAAR,EAAsB,SACrB,sDAAC,oBAAK,UAAoB,GAC5B;AAAA,MACF;AAAA,IACF;AAEA,WAAO,oBAAO,YAAY,MAAM,CAAC;AAAA,EACnC,CAAC;AACH,CAAC;","names":["import_react"]}
@@ -23,8 +23,8 @@ __export(page_rendering_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(page_rendering_exports);
25
25
  var import_jsx_runtime = require("react/jsx-runtime");
26
+ var import_react = require("react");
26
27
  var import_jest_dom = require("@testing-library/jest-dom");
27
- var import_test_utils = require("react-dom/test-utils");
28
28
  var import_react2 = require("@testing-library/react");
29
29
  var import_react_runtime = require("../../runtimes/react/react-runtime");
30
30
  var import_constants = require("../../components/builtin/constants");
@@ -37,7 +37,7 @@ async function testMakeswiftPageHeadRendering(props, { forcePagesRouter = false
37
37
  label: "Root",
38
38
  props: {}
39
39
  });
40
- return await (0, import_test_utils.act)(
40
+ return await (0, import_react.act)(
41
41
  async () => (0, import_react2.render)(
42
42
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_provider.ReactProvider, { runtime, siteVersion: null, forcePagesRouter, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_page.Page, { ...props }) }),
43
43
  {
@@ -48,7 +48,7 @@ async function testMakeswiftPageHeadRendering(props, { forcePagesRouter = false
48
48
  }
49
49
  async function testMakeswiftPageRendering(props, { forcePagesRouter = false } = {}) {
50
50
  const runtime = new import_react_runtime.ReactRuntime();
51
- return await (0, import_test_utils.act)(
51
+ return await (0, import_react.act)(
52
52
  async () => (0, import_react2.render)(
53
53
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_provider.ReactProvider, { runtime, siteVersion: null, forcePagesRouter, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_page.Page, { ...props }) }),
54
54
  {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/next/testing/page-rendering.tsx"],"sourcesContent":["import { type ComponentPropsWithoutRef } from 'react'\n\nimport '@testing-library/jest-dom'\nimport { act } from 'react-dom/test-utils'\nimport { render } from '@testing-library/react'\n\nimport { ReactRuntime } from '../../runtimes/react/react-runtime'\nimport { MakeswiftComponentType } from '../../components/builtin/constants'\n\nimport { Page as MakeswiftPage } from '../components/page'\n\nimport { ReactProvider } from './react-provider'\n\nexport async function testMakeswiftPageHeadRendering(\n props: ComponentPropsWithoutRef<typeof MakeswiftPage>,\n { forcePagesRouter = false }: { forcePagesRouter?: boolean } = {},\n) {\n const runtime = new ReactRuntime()\n\n runtime.registerComponent(() => <></>, {\n type: MakeswiftComponentType.Root,\n label: 'Root',\n props: {},\n })\n\n return await act(async () =>\n render(\n <ReactProvider runtime={runtime} siteVersion={null} forcePagesRouter={forcePagesRouter}>\n <MakeswiftPage {...props} />\n </ReactProvider>,\n {\n container: document.body.appendChild(document.createElement('head')),\n },\n ),\n )\n}\n\nexport async function testMakeswiftPageRendering(\n props: ComponentPropsWithoutRef<typeof MakeswiftPage>,\n { forcePagesRouter = false }: { forcePagesRouter?: boolean } = {},\n) {\n const runtime = new ReactRuntime()\n\n return await act(async () =>\n render(\n <ReactProvider runtime={runtime} siteVersion={null} forcePagesRouter={forcePagesRouter}>\n <MakeswiftPage {...props} />\n </ReactProvider>,\n {\n container: document.body.appendChild(document.createElement('div')),\n },\n ),\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmBkC;AAjBlC,sBAAO;AACP,wBAAoB;AACpB,IAAAA,gBAAuB;AAEvB,2BAA6B;AAC7B,uBAAuC;AAEvC,kBAAsC;AAEtC,4BAA8B;AAE9B,eAAsB,+BACpB,OACA,EAAE,mBAAmB,MAAM,IAAoC,CAAC,GAChE;AACA,QAAM,UAAU,IAAI,kCAAa;AAEjC,UAAQ,kBAAkB,MAAM,2EAAE,GAAK;AAAA,IACrC,MAAM,wCAAuB;AAAA,IAC7B,OAAO;AAAA,IACP,OAAO,CAAC;AAAA,EACV,CAAC;AAED,SAAO,UAAM;AAAA,IAAI,gBACf;AAAA,MACE,4CAAC,uCAAc,SAAkB,aAAa,MAAM,kBAClD,sDAAC,YAAAC,MAAA,EAAe,GAAG,OAAO,GAC5B;AAAA,MACA;AAAA,QACE,WAAW,SAAS,KAAK,YAAY,SAAS,cAAc,MAAM,CAAC;AAAA,MACrE;AAAA,IACF;AAAA,EACF;AACF;AAEA,eAAsB,2BACpB,OACA,EAAE,mBAAmB,MAAM,IAAoC,CAAC,GAChE;AACA,QAAM,UAAU,IAAI,kCAAa;AAEjC,SAAO,UAAM;AAAA,IAAI,gBACf;AAAA,MACE,4CAAC,uCAAc,SAAkB,aAAa,MAAM,kBAClD,sDAAC,YAAAA,MAAA,EAAe,GAAG,OAAO,GAC5B;AAAA,MACA;AAAA,QACE,WAAW,SAAS,KAAK,YAAY,SAAS,cAAc,KAAK,CAAC;AAAA,MACpE;AAAA,IACF;AAAA,EACF;AACF;","names":["import_react","MakeswiftPage"]}
1
+ {"version":3,"sources":["../../../../src/next/testing/page-rendering.tsx"],"sourcesContent":["import { type ComponentPropsWithoutRef, act } from 'react';\n\nimport '@testing-library/jest-dom'\nimport { render } from '@testing-library/react'\n\nimport { ReactRuntime } from '../../runtimes/react/react-runtime'\nimport { MakeswiftComponentType } from '../../components/builtin/constants'\n\nimport { Page as MakeswiftPage } from '../components/page'\n\nimport { ReactProvider } from './react-provider'\n\nexport async function testMakeswiftPageHeadRendering(\n props: ComponentPropsWithoutRef<typeof MakeswiftPage>,\n { forcePagesRouter = false }: { forcePagesRouter?: boolean } = {},\n) {\n const runtime = new ReactRuntime()\n\n runtime.registerComponent(() => <></>, {\n type: MakeswiftComponentType.Root,\n label: 'Root',\n props: {},\n })\n\n return await act(async () =>\n render(\n <ReactProvider runtime={runtime} siteVersion={null} forcePagesRouter={forcePagesRouter}>\n <MakeswiftPage {...props} />\n </ReactProvider>,\n {\n container: document.body.appendChild(document.createElement('head')),\n },\n ),\n )\n}\n\nexport async function testMakeswiftPageRendering(\n props: ComponentPropsWithoutRef<typeof MakeswiftPage>,\n { forcePagesRouter = false }: { forcePagesRouter?: boolean } = {},\n) {\n const runtime = new ReactRuntime()\n\n return await act(async () =>\n render(\n <ReactProvider runtime={runtime} siteVersion={null} forcePagesRouter={forcePagesRouter}>\n <MakeswiftPage {...props} />\n </ReactProvider>,\n {\n container: document.body.appendChild(document.createElement('div')),\n },\n ),\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBkC;AAlBlC,mBAAmD;AAEnD,sBAAO;AACP,IAAAA,gBAAuB;AAEvB,2BAA6B;AAC7B,uBAAuC;AAEvC,kBAAsC;AAEtC,4BAA8B;AAE9B,eAAsB,+BACpB,OACA,EAAE,mBAAmB,MAAM,IAAoC,CAAC,GAChE;AACA,QAAM,UAAU,IAAI,kCAAa;AAEjC,UAAQ,kBAAkB,MAAM,2EAAE,GAAK;AAAA,IACrC,MAAM,wCAAuB;AAAA,IAC7B,OAAO;AAAA,IACP,OAAO,CAAC;AAAA,EACV,CAAC;AAED,SAAO,UAAM;AAAA,IAAI,gBACf;AAAA,MACE,4CAAC,uCAAc,SAAkB,aAAa,MAAM,kBAClD,sDAAC,YAAAC,MAAA,EAAe,GAAG,OAAO,GAC5B;AAAA,MACA;AAAA,QACE,WAAW,SAAS,KAAK,YAAY,SAAS,cAAc,MAAM,CAAC;AAAA,MACrE;AAAA,IACF;AAAA,EACF;AACF;AAEA,eAAsB,2BACpB,OACA,EAAE,mBAAmB,MAAM,IAAoC,CAAC,GAChE;AACA,QAAM,UAAU,IAAI,kCAAa;AAEjC,SAAO,UAAM;AAAA,IAAI,gBACf;AAAA,MACE,4CAAC,uCAAc,SAAkB,aAAa,MAAM,kBAClD,sDAAC,YAAAA,MAAA,EAAe,GAAG,OAAO,GAC5B;AAAA,MACA;AAAA,QACE,WAAW,SAAS,KAAK,YAAY,SAAS,cAAc,KAAK,CAAC;AAAA,MACpE;AAAA,IACF;AAAA,EACF;AACF;","names":["import_react","MakeswiftPage"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/components/Document.tsx"],"sourcesContent":["import { Ref, forwardRef, memo } from 'react'\nimport { type Document as ReactPageDocument, getRootElement } from '../../../state/react-page'\nimport { ElementImperativeHandle } from '../element-imperative-handle'\nimport { DocumentKeyContext, DocumentLocaleContext } from '../hooks/use-document-context'\nimport { Element } from './Element'\n\ntype DocumentProps = {\n document: ReactPageDocument\n}\n\nexport const Document = memo(\n forwardRef(function Document(\n { document }: DocumentProps,\n ref: Ref<ElementImperativeHandle>,\n ): JSX.Element {\n return (\n <DocumentKeyContext.Provider value={document.key}>\n <DocumentLocaleContext.Provider value={document.locale}>\n <Element ref={ref} element={getRootElement(document)} />\n </DocumentLocaleContext.Provider>\n </DocumentKeyContext.Provider>\n )\n }),\n)\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBU;AAlBV,mBAAsC;AACtC,wBAAmE;AAEnE,kCAA0D;AAC1D,qBAAwB;AAMjB,MAAM,eAAW;AAAA,MACtB,yBAAW,SAASA,UAClB,EAAE,SAAS,GACX,KACa;AACb,WACE,4CAAC,+CAAmB,UAAnB,EAA4B,OAAO,SAAS,KAC3C,sDAAC,kDAAsB,UAAtB,EAA+B,OAAO,SAAS,QAC9C,sDAAC,0BAAQ,KAAU,aAAS,kCAAe,QAAQ,GAAG,GACxD,GACF;AAAA,EAEJ,CAAC;AACH;","names":["Document"]}
1
+ {"version":3,"sources":["../../../../../src/runtimes/react/components/Document.tsx"],"sourcesContent":["import { Ref, forwardRef, memo, ReactNode } from 'react'\nimport { type Document as ReactPageDocument, getRootElement } from '../../../state/react-page'\nimport { ElementImperativeHandle } from '../element-imperative-handle'\nimport { DocumentKeyContext, DocumentLocaleContext } from '../hooks/use-document-context'\nimport { Element } from './Element'\n\ntype DocumentProps = {\n document: ReactPageDocument\n}\n\nexport const Document = memo(\n forwardRef(function Document(\n { document }: DocumentProps,\n ref: Ref<ElementImperativeHandle>,\n ): ReactNode {\n return (\n <DocumentKeyContext.Provider value={document.key}>\n <DocumentLocaleContext.Provider value={document.locale}>\n <Element ref={ref} element={getRootElement(document)} />\n </DocumentLocaleContext.Provider>\n </DocumentKeyContext.Provider>\n )\n }),\n)\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBU;AAlBV,mBAAiD;AACjD,wBAAmE;AAEnE,kCAA0D;AAC1D,qBAAwB;AAMjB,MAAM,eAAW;AAAA,MACtB,yBAAW,SAASA,UAClB,EAAE,SAAS,GACX,KACW;AACX,WACE,4CAAC,+CAAmB,UAAnB,EAA4B,OAAO,SAAS,KAC3C,sDAAC,kDAAsB,UAAtB,EAA+B,OAAO,SAAS,QAC9C,sDAAC,0BAAQ,KAAU,aAAS,kCAAe,QAAQ,GAAG,GACxD,GACF;AAAA,EAEJ,CAAC;AACH;","names":["Document"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/components/DocumentRoot.tsx"],"sourcesContent":["import { Ref, forwardRef, memo } from 'react'\nimport { type Document } from '../../../state/react-page'\nimport { ElementImperativeHandle } from '../element-imperative-handle'\nimport { useDocument } from '../hooks/use-document'\nimport { FallbackComponent } from '../../../components/shared/FallbackComponent'\nimport { Document as DocumentComponent } from './Document'\n\ntype Props = {\n rootDocument: Document\n}\n\nexport const DocumentRoot = memo(\n forwardRef(function DocumentRoot(\n { rootDocument }: Props,\n ref: Ref<ElementImperativeHandle>,\n ): JSX.Element {\n const document = useDocument(rootDocument.key) ?? rootDocument\n\n if (document == null) {\n return <FallbackComponent ref={ref as Ref<HTMLDivElement>} text=\"Document not found\" />\n }\n\n return <DocumentComponent ref={ref} document={document} />\n }),\n)\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAmBa;AAnBb,mBAAsC;AAGtC,0BAA4B;AAC5B,+BAAkC;AAClC,sBAA8C;AAMvC,MAAM,mBAAe;AAAA,MAC1B,yBAAW,SAASA,cAClB,EAAE,aAAa,GACf,KACa;AACb,UAAM,eAAW,iCAAY,aAAa,GAAG,KAAK;AAElD,QAAI,YAAY,MAAM;AACpB,aAAO,4CAAC,8CAAkB,KAAiC,MAAK,sBAAqB;AAAA,IACvF;AAEA,WAAO,4CAAC,gBAAAC,UAAA,EAAkB,KAAU,UAAoB;AAAA,EAC1D,CAAC;AACH;","names":["DocumentRoot","DocumentComponent"]}
1
+ {"version":3,"sources":["../../../../../src/runtimes/react/components/DocumentRoot.tsx"],"sourcesContent":["import { Ref, forwardRef, memo, ReactNode } from 'react'\nimport { type Document } from '../../../state/react-page'\nimport { ElementImperativeHandle } from '../element-imperative-handle'\nimport { useDocument } from '../hooks/use-document'\nimport { FallbackComponent } from '../../../components/shared/FallbackComponent'\nimport { Document as DocumentComponent } from './Document'\n\ntype Props = {\n rootDocument: Document\n}\n\nexport const DocumentRoot = memo(\n forwardRef(function DocumentRoot(\n { rootDocument }: Props,\n ref: Ref<ElementImperativeHandle>,\n ): ReactNode {\n const document = useDocument(rootDocument.key) ?? rootDocument\n\n if (document == null) {\n return <FallbackComponent ref={ref as Ref<HTMLDivElement>} text=\"Document not found\" />\n }\n\n return <DocumentComponent ref={ref} document={document} />\n }),\n)\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAmBa;AAnBb,mBAAiD;AAGjD,0BAA4B;AAC5B,+BAAkC;AAClC,sBAA8C;AAMvC,MAAM,mBAAe;AAAA,MAC1B,yBAAW,SAASA,cAClB,EAAE,aAAa,GACf,KACW;AACX,UAAM,eAAW,iCAAY,aAAa,GAAG,KAAK;AAElD,QAAI,YAAY,MAAM;AACpB,aAAO,4CAAC,8CAAkB,KAAiC,MAAK,sBAAqB;AAAA,IACvF;AAEA,WAAO,4CAAC,gBAAAC,UAAA,EAAkB,KAAU,UAAoB;AAAA,EAC1D,CAAC;AACH;","names":["DocumentRoot","DocumentComponent"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/components/Element.tsx"],"sourcesContent":["'use client'\n\nimport { forwardRef, memo, Ref, useCallback, useImperativeHandle, useRef } from 'react'\nimport { isElementReference, type Element as ElementDataOrRef } from '../../../state/react-page'\nimport { ElementRegistration } from './ElementRegistration'\nimport { ElementReference } from './ElementReference'\nimport { ElementData } from './ElementData'\nimport { ElementImperativeHandle } from '../element-imperative-handle'\nimport { FindDomNode } from '../find-dom-node'\nimport { FallbackComponent } from '../../../components/shared/FallbackComponent'\nimport { ErrorBoundary } from '../../../components/shared/ErrorBoundary'\n\ntype Props = {\n element: ElementDataOrRef\n}\n\nexport const Element = memo(\n forwardRef(function Element(\n { element }: Props,\n ref: Ref<ElementImperativeHandle>,\n ): JSX.Element | null {\n const useFindDomNodeRef = useRef(true)\n const imperativeHandleRef = useRef(new ElementImperativeHandle())\n\n const findDomNodeCallbackRef = useCallback((current: (() => Element | Text | null) | null) => {\n if (useFindDomNodeRef.current === true) {\n imperativeHandleRef.current.callback(() => current?.() ?? null)\n }\n }, [])\n\n const elementCallbackRef = useCallback((current: unknown | null) => {\n useFindDomNodeRef.current = false\n\n imperativeHandleRef.current.callback(() => current)\n }, [])\n\n useImperativeHandle(ref, () => imperativeHandleRef.current, [])\n\n return (\n <ElementRegistration componentHandle={imperativeHandleRef.current} elementKey={element.key}>\n <FindDomNode ref={findDomNodeCallbackRef}>\n <ErrorBoundary FallbackComponent={ErrorFallback}>\n {isElementReference(element) ? (\n <ElementReference\n key={element.key}\n ref={elementCallbackRef}\n elementReference={element}\n />\n ) : (\n <ElementData key={element.key} ref={elementCallbackRef} elementData={element} />\n )}\n </ErrorBoundary>\n </FindDomNode>\n </ElementRegistration>\n )\n }),\n)\n\nfunction ErrorFallback() {\n return <FallbackComponent text={`Error rendering component`} />\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA2Cc;AAzCd,mBAAgF;AAChF,wBAAqE;AACrE,iCAAoC;AACpC,8BAAiC;AACjC,yBAA4B;AAC5B,uCAAwC;AACxC,2BAA4B;AAC5B,+BAAkC;AAClC,2BAA8B;AAMvB,MAAM,cAAU;AAAA,MACrB,yBAAW,SAASA,SAClB,EAAE,QAAQ,GACV,KACoB;AACpB,UAAM,wBAAoB,qBAAO,IAAI;AACrC,UAAM,0BAAsB,qBAAO,IAAI,yDAAwB,CAAC;AAEhE,UAAM,6BAAyB,0BAAY,CAAC,YAAkD;AAC5F,UAAI,kBAAkB,YAAY,MAAM;AACtC,4BAAoB,QAAQ,SAAS,MAAM,UAAU,KAAK,IAAI;AAAA,MAChE;AAAA,IACF,GAAG,CAAC,CAAC;AAEL,UAAM,yBAAqB,0BAAY,CAAC,YAA4B;AAClE,wBAAkB,UAAU;AAE5B,0BAAoB,QAAQ,SAAS,MAAM,OAAO;AAAA,IACpD,GAAG,CAAC,CAAC;AAEL,0CAAoB,KAAK,MAAM,oBAAoB,SAAS,CAAC,CAAC;AAE9D,WACE,4CAAC,kDAAoB,iBAAiB,oBAAoB,SAAS,YAAY,QAAQ,KACrF,sDAAC,oCAAY,KAAK,wBAChB,sDAAC,sCAAc,mBAAmB,eAC/B,oDAAmB,OAAO,IACzB;AAAA,MAAC;AAAA;AAAA,QAEC,KAAK;AAAA,QACL,kBAAkB;AAAA;AAAA,MAFb,QAAQ;AAAA,IAGf,IAEA,4CAAC,kCAA8B,KAAK,oBAAoB,aAAa,WAAnD,QAAQ,GAAoD,GAElF,GACF,GACF;AAAA,EAEJ,CAAC;AACH;AAEA,SAAS,gBAAgB;AACvB,SAAO,4CAAC,8CAAkB,MAAM,6BAA6B;AAC/D;","names":["Element"]}
1
+ {"version":3,"sources":["../../../../../src/runtimes/react/components/Element.tsx"],"sourcesContent":["'use client'\n\nimport { forwardRef, memo, Ref, useCallback, useImperativeHandle, useRef, ReactNode } from 'react'\nimport { isElementReference, type Element as ElementDataOrRef } from '../../../state/react-page'\nimport { ElementRegistration } from './ElementRegistration'\nimport { ElementReference } from './ElementReference'\nimport { ElementData } from './ElementData'\nimport { ElementImperativeHandle } from '../element-imperative-handle'\nimport { FindDomNode } from '../find-dom-node'\nimport { FallbackComponent } from '../../../components/shared/FallbackComponent'\nimport { ErrorBoundary } from '../../../components/shared/ErrorBoundary'\n\ntype Props = {\n element: ElementDataOrRef\n}\n\nexport const Element = memo(\n forwardRef(function Element(\n { element }: Props,\n ref: Ref<ElementImperativeHandle>,\n ): ReactNode | null {\n const useFindDomNodeRef = useRef(true)\n const imperativeHandleRef = useRef(new ElementImperativeHandle())\n\n const findDomNodeCallbackRef = useCallback((current: (() => Element | Text | null) | null) => {\n if (useFindDomNodeRef.current === true) {\n imperativeHandleRef.current.callback(() => current?.() ?? null)\n }\n }, [])\n\n const elementCallbackRef = useCallback((current: unknown | null) => {\n useFindDomNodeRef.current = false\n\n imperativeHandleRef.current.callback(() => current)\n }, [])\n\n useImperativeHandle(ref, () => imperativeHandleRef.current, [])\n\n return (\n <ElementRegistration componentHandle={imperativeHandleRef.current} elementKey={element.key}>\n <FindDomNode ref={findDomNodeCallbackRef}>\n <ErrorBoundary FallbackComponent={ErrorFallback}>\n {isElementReference(element) ? (\n <ElementReference\n key={element.key}\n ref={elementCallbackRef}\n elementReference={element}\n />\n ) : (\n <ElementData key={element.key} ref={elementCallbackRef} elementData={element} />\n )}\n </ErrorBoundary>\n </FindDomNode>\n </ElementRegistration>\n )\n }),\n)\n\nfunction ErrorFallback() {\n return <FallbackComponent text={`Error rendering component`} />\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA2Cc;AAzCd,mBAA2F;AAC3F,wBAAqE;AACrE,iCAAoC;AACpC,8BAAiC;AACjC,yBAA4B;AAC5B,uCAAwC;AACxC,2BAA4B;AAC5B,+BAAkC;AAClC,2BAA8B;AAMvB,MAAM,cAAU;AAAA,MACrB,yBAAW,SAASA,SAClB,EAAE,QAAQ,GACV,KACkB;AAClB,UAAM,wBAAoB,qBAAO,IAAI;AACrC,UAAM,0BAAsB,qBAAO,IAAI,yDAAwB,CAAC;AAEhE,UAAM,6BAAyB,0BAAY,CAAC,YAAkD;AAC5F,UAAI,kBAAkB,YAAY,MAAM;AACtC,4BAAoB,QAAQ,SAAS,MAAM,UAAU,KAAK,IAAI;AAAA,MAChE;AAAA,IACF,GAAG,CAAC,CAAC;AAEL,UAAM,yBAAqB,0BAAY,CAAC,YAA4B;AAClE,wBAAkB,UAAU;AAE5B,0BAAoB,QAAQ,SAAS,MAAM,OAAO;AAAA,IACpD,GAAG,CAAC,CAAC;AAEL,0CAAoB,KAAK,MAAM,oBAAoB,SAAS,CAAC,CAAC;AAE9D,WACE,4CAAC,kDAAoB,iBAAiB,oBAAoB,SAAS,YAAY,QAAQ,KACrF,sDAAC,oCAAY,KAAK,wBAChB,sDAAC,sCAAc,mBAAmB,eAC/B,oDAAmB,OAAO,IACzB;AAAA,MAAC;AAAA;AAAA,QAEC,KAAK;AAAA,QACL,kBAAkB;AAAA;AAAA,MAFb,QAAQ;AAAA,IAGf,IAEA,4CAAC,kCAA8B,KAAK,oBAAoB,aAAa,WAAnD,QAAQ,GAAoD,GAElF,GACF,GACF;AAAA,EAEJ,CAAC;AACH;AAEA,SAAS,gBAAgB;AACvB,SAAO,4CAAC,8CAAkB,MAAM,6BAA6B;AAC/D;","names":["Element"]}
@@ -29,6 +29,7 @@ var import_use_component = require("../hooks/use-component");
29
29
  var import_can_accept_ref = require("../utils/can-accept-ref");
30
30
  var import_FallbackComponent = require("../../../components/shared/FallbackComponent");
31
31
  var import_controls = require("../controls");
32
+ var import_activity_with_fallback = require("./activity-with-fallback");
32
33
  const ElementData = (0, import_react2.memo)(
33
34
  (0, import_react2.forwardRef)(function ElementData2({ elementData }, ref) {
34
35
  const Component = (0, import_use_component.useComponent)(elementData.type);
@@ -38,8 +39,7 @@ const ElementData = (0, import_react2.memo)(
38
39
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_FallbackComponent.FallbackComponent, { ref, text: "Component not found" });
39
40
  }
40
41
  const forwardRef2 = (0, import_can_accept_ref.canAcceptRef)(Component);
41
- const SuspenseOrFragment = builtinSuspense ? import_react2.Suspense : import_react2.Fragment;
42
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SuspenseOrFragment, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_controls.ResolveProps, { element: elementData, children: (props) => forwardRef2 ? /* @__PURE__ */ (0, import_react.createElement)(Component, { ...props, key: elementData.key, ref }) : /* @__PURE__ */ (0, import_react.createElement)(Component, { ...props, key: elementData.key }) }) });
42
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_activity_with_fallback.ActivityOrFallback, { suspenseFallback: builtinSuspense, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_controls.ResolveProps, { element: elementData, children: (props) => forwardRef2 ? /* @__PURE__ */ (0, import_react.createElement)(Component, { ...props, key: elementData.key, ref }) : /* @__PURE__ */ (0, import_react.createElement)(Component, { ...props, key: elementData.key }) }) });
43
43
  })
44
44
  );
45
45
  // Annotate the CommonJS export names for ESM import in node:
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/components/ElementData.tsx"],"sourcesContent":["import { Ref, Suspense, Fragment, forwardRef, memo } from 'react'\nimport { ElementData as ReactPageElementData } from '../../../state/react-page'\nimport { useBuiltinSuspense } from '../hooks/use-builtin-suspense'\nimport { useComponent } from '../hooks/use-component'\nimport { canAcceptRef } from '../utils/can-accept-ref'\nimport { FallbackComponent } from '../../../components/shared/FallbackComponent'\nimport { ResolveProps } from '../controls'\n\ntype ElementDataProps = {\n elementData: ReactPageElementData\n}\n\nexport const ElementData = memo(\n forwardRef(function ElementData(\n { elementData }: ElementDataProps,\n ref: Ref<unknown>,\n ): JSX.Element {\n const Component = useComponent(elementData.type)\n const builtinSuspense = useBuiltinSuspense(elementData.type)\n\n if (Component == null) {\n console.warn(`Unknown component '${elementData.type}'`, { elementData })\n return <FallbackComponent ref={ref as Ref<HTMLDivElement>} text=\"Component not found\" />\n }\n\n const forwardRef = canAcceptRef(Component)\n const SuspenseOrFragment = builtinSuspense ? Suspense : Fragment\n\n return (\n <SuspenseOrFragment>\n <ResolveProps element={elementData}>\n {props =>\n forwardRef ? (\n <Component {...props} key={elementData.key} ref={ref} />\n ) : (\n <Component {...props} key={elementData.key} />\n )\n }\n </ResolveProps>\n </SuspenseOrFragment>\n )\n }),\n)\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAsBa;AAWC;AAjCd,IAAAA,gBAA0D;AAE1D,kCAAmC;AACnC,2BAA6B;AAC7B,4BAA6B;AAC7B,+BAAkC;AAClC,sBAA6B;AAMtB,MAAM,kBAAc;AAAA,MACzB,0BAAW,SAASC,aAClB,EAAE,YAAY,GACd,KACa;AACb,UAAM,gBAAY,mCAAa,YAAY,IAAI;AAC/C,UAAM,sBAAkB,gDAAmB,YAAY,IAAI;AAE3D,QAAI,aAAa,MAAM;AACrB,cAAQ,KAAK,sBAAsB,YAAY,IAAI,KAAK,EAAE,YAAY,CAAC;AACvE,aAAO,4CAAC,8CAAkB,KAAiC,MAAK,uBAAsB;AAAA,IACxF;AAEA,UAAMC,kBAAa,oCAAa,SAAS;AACzC,UAAM,qBAAqB,kBAAkB,yBAAW;AAExD,WACE,4CAAC,sBACC,sDAAC,gCAAa,SAAS,aACpB,qBACCA,cACE,gDAAC,aAAW,GAAG,OAAO,KAAK,YAAY,KAAK,KAAU,IAEtD,gDAAC,aAAW,GAAG,OAAO,KAAK,YAAY,KAAK,GAGlD,GACF;AAAA,EAEJ,CAAC;AACH;","names":["import_react","ElementData","forwardRef"]}
1
+ {"version":3,"sources":["../../../../../src/runtimes/react/components/ElementData.tsx"],"sourcesContent":["import { Ref, forwardRef, memo, ReactNode } from 'react'\nimport { ElementData as ReactPageElementData } from '../../../state/react-page'\nimport { useBuiltinSuspense } from '../hooks/use-builtin-suspense'\nimport { useComponent } from '../hooks/use-component'\nimport { canAcceptRef } from '../utils/can-accept-ref'\nimport { FallbackComponent } from '../../../components/shared/FallbackComponent'\nimport { ResolveProps } from '../controls'\nimport { ActivityOrFallback } from './activity-with-fallback'\n\ntype ElementDataProps = {\n elementData: ReactPageElementData\n}\n\nexport const ElementData = memo(\n forwardRef(function ElementData({ elementData }: ElementDataProps, ref: Ref<unknown>): ReactNode {\n const Component = useComponent(elementData.type)\n const builtinSuspense = useBuiltinSuspense(elementData.type)\n\n if (Component == null) {\n console.warn(`Unknown component '${elementData.type}'`, { elementData })\n return <FallbackComponent ref={ref as Ref<HTMLDivElement>} text=\"Component not found\" />\n }\n\n const forwardRef = canAcceptRef(Component)\n\n return (\n <ActivityOrFallback suspenseFallback={builtinSuspense}>\n <ResolveProps element={elementData}>\n {props =>\n forwardRef ? (\n <Component {...props} key={elementData.key} ref={ref} />\n ) : (\n <Component {...props} key={elementData.key} />\n )\n }\n </ResolveProps>\n </ActivityOrFallback>\n )\n }),\n)\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAoBa;AAUC;AA9Bd,IAAAA,gBAAiD;AAEjD,kCAAmC;AACnC,2BAA6B;AAC7B,4BAA6B;AAC7B,+BAAkC;AAClC,sBAA6B;AAC7B,oCAAmC;AAM5B,MAAM,kBAAc;AAAA,MACzB,0BAAW,SAASC,aAAY,EAAE,YAAY,GAAqB,KAA8B;AAC/F,UAAM,gBAAY,mCAAa,YAAY,IAAI;AAC/C,UAAM,sBAAkB,gDAAmB,YAAY,IAAI;AAE3D,QAAI,aAAa,MAAM;AACrB,cAAQ,KAAK,sBAAsB,YAAY,IAAI,KAAK,EAAE,YAAY,CAAC;AACvE,aAAO,4CAAC,8CAAkB,KAAiC,MAAK,uBAAsB;AAAA,IACxF;AAEA,UAAMC,kBAAa,oCAAa,SAAS;AAEzC,WACE,4CAAC,oDAAmB,kBAAkB,iBACpC,sDAAC,gCAAa,SAAS,aACpB,qBACCA,cACE,gDAAC,aAAW,GAAG,OAAO,KAAK,YAAY,KAAK,KAAU,IAEtD,gDAAC,aAAW,GAAG,OAAO,KAAK,YAAY,KAAK,GAGlD,GACF;AAAA,EAEJ,CAAC;AACH;","names":["import_react","ElementData","forwardRef"]}