@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.
- package/dist/cjs/api-handler/handlers/manifest.js +1 -1
- package/dist/cjs/client/index.js +3 -3
- package/dist/cjs/components/builtin/Button/Button.js.map +1 -1
- package/dist/cjs/components/builtin/Carousel/Carousel.js.map +1 -1
- package/dist/cjs/components/builtin/Embed/Embed.js +3 -1
- package/dist/cjs/components/builtin/Embed/Embed.js.map +1 -1
- package/dist/cjs/components/builtin/Form/components/Field/components/Label/index.js.map +1 -1
- package/dist/cjs/components/builtin/Form/components/Field/components/PlaceholderTableField/index.js.map +1 -1
- package/dist/cjs/components/builtin/Form/components/Field/index.js.map +1 -1
- package/dist/cjs/components/builtin/Form/components/Placeholder/index.js.map +1 -1
- package/dist/cjs/components/builtin/Form/components/Spinner/index.js.map +1 -1
- package/dist/cjs/components/builtin/Navigation/Navigation.js.map +1 -1
- package/dist/cjs/components/builtin/Navigation/components/DropDownButton/index.js.map +1 -1
- package/dist/cjs/components/builtin/Navigation/components/LinksPlaceholder/index.js.map +1 -1
- package/dist/cjs/components/builtin/Navigation/components/MobileMenu/components/MobileDropDownButton/index.js.map +1 -1
- package/dist/cjs/components/builtin/Navigation/components/MobileMenu/index.js.map +1 -1
- package/dist/cjs/components/builtin/SocialLinks/components/SocialLinksPlaceholder/index.js.map +1 -1
- package/dist/cjs/components/shared/BackgroundsContainer/components/BackgroundVideo/index.js.map +1 -1
- package/dist/cjs/components/shared/BackgroundsContainer/components/Backgrounds/index.js.map +1 -1
- package/dist/cjs/components/shared/BackgroundsContainer/components/Parallax/index.js.map +1 -1
- package/dist/cjs/controls/rich-text-v2/plugin.js.map +1 -1
- package/dist/cjs/next/components/framework-provider/pages-router/HeadSnippet.js.map +1 -1
- package/dist/cjs/next/components/tests/controls/page-control-prop-rendering.js +2 -3
- package/dist/cjs/next/components/tests/controls/page-control-prop-rendering.js.map +1 -1
- package/dist/cjs/next/components/tests/makeswift-component/fixtures.js +102 -0
- package/dist/cjs/next/components/tests/makeswift-component/fixtures.js.map +1 -0
- package/dist/cjs/next/components/tests/prop-controllers/page-prop-controller.js +6 -6
- package/dist/cjs/next/components/tests/prop-controllers/page-prop-controller.js.map +1 -1
- package/dist/cjs/next/testing/page-rendering.js +3 -3
- package/dist/cjs/next/testing/page-rendering.js.map +1 -1
- package/dist/cjs/runtimes/react/components/Document.js.map +1 -1
- package/dist/cjs/runtimes/react/components/DocumentRoot.js.map +1 -1
- package/dist/cjs/runtimes/react/components/Element.js.map +1 -1
- package/dist/cjs/runtimes/react/components/ElementData.js +2 -2
- package/dist/cjs/runtimes/react/components/ElementData.js.map +1 -1
- package/dist/cjs/runtimes/react/components/ElementReference.js.map +1 -1
- package/dist/cjs/runtimes/react/components/ElementRegistration.js.map +1 -1
- package/dist/cjs/runtimes/react/components/LiveProvider.js.map +1 -1
- package/dist/cjs/runtimes/react/components/MakeswiftComponent.js +2 -2
- package/dist/cjs/runtimes/react/components/MakeswiftComponent.js.map +1 -1
- package/dist/cjs/runtimes/react/components/PreviewProvider.js.map +1 -1
- package/dist/cjs/runtimes/react/components/activity-with-fallback.js +54 -0
- package/dist/cjs/runtimes/react/components/activity-with-fallback.js.map +1 -0
- package/dist/cjs/runtimes/react/components/page/HeadSnippet.js.map +1 -1
- package/dist/cjs/runtimes/react/components/page/Page.js.map +1 -1
- package/dist/cjs/runtimes/react/components/page/PageHead.js.map +1 -1
- package/dist/cjs/runtimes/react/components/page/head-tags.js.map +1 -1
- package/dist/cjs/runtimes/react/components/page/index.js +2 -1
- package/dist/cjs/runtimes/react/components/page/index.js.map +1 -1
- package/dist/cjs/runtimes/react/components/render-hook.js.map +1 -1
- package/dist/cjs/runtimes/react/controls/control.js.map +1 -1
- package/dist/cjs/runtimes/react/controls/group.js.map +1 -1
- package/dist/cjs/runtimes/react/controls/rich-text-v2/EditableTextV2/render-leaf.js.map +1 -1
- package/dist/cjs/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.js.map +1 -1
- package/dist/cjs/runtimes/react/controls/slot.js.map +1 -1
- package/dist/cjs/runtimes/react/controls.js.map +1 -1
- package/dist/cjs/runtimes/react/find-dom-node.js +2 -0
- package/dist/cjs/runtimes/react/find-dom-node.js.map +1 -1
- package/dist/cjs/runtimes/react/hooks/makeswift-api.js +2 -2
- package/dist/cjs/runtimes/react/hooks/makeswift-api.js.map +1 -1
- package/dist/cjs/runtimes/react/legacy-controls.js.map +1 -1
- package/dist/cjs/runtimes/react/lib/react-dom.js +2 -1
- package/dist/cjs/runtimes/react/lib/react-dom.js.map +1 -1
- package/dist/cjs/runtimes/react/react-runtime-core.js +6 -0
- package/dist/cjs/runtimes/react/react-runtime-core.js.map +1 -1
- package/dist/cjs/runtimes/react/use-global-style.js +1 -1
- package/dist/cjs/runtimes/react/use-global-style.js.map +1 -1
- package/dist/esm/api-handler/handlers/manifest.js +1 -1
- package/dist/esm/client/index.js +3 -3
- package/dist/esm/components/builtin/Button/Button.js.map +1 -1
- package/dist/esm/components/builtin/Carousel/Carousel.js.map +1 -1
- package/dist/esm/components/builtin/Embed/Embed.js +3 -1
- package/dist/esm/components/builtin/Embed/Embed.js.map +1 -1
- package/dist/esm/components/builtin/Form/components/Field/components/Label/index.js.map +1 -1
- package/dist/esm/components/builtin/Form/components/Field/components/PlaceholderTableField/index.js.map +1 -1
- package/dist/esm/components/builtin/Form/components/Field/index.js.map +1 -1
- package/dist/esm/components/builtin/Form/components/Placeholder/index.js.map +1 -1
- package/dist/esm/components/builtin/Form/components/Spinner/index.js.map +1 -1
- package/dist/esm/components/builtin/Navigation/Navigation.js.map +1 -1
- package/dist/esm/components/builtin/Navigation/components/DropDownButton/index.js.map +1 -1
- package/dist/esm/components/builtin/Navigation/components/LinksPlaceholder/index.js.map +1 -1
- package/dist/esm/components/builtin/Navigation/components/MobileMenu/components/MobileDropDownButton/index.js.map +1 -1
- package/dist/esm/components/builtin/Navigation/components/MobileMenu/index.js.map +1 -1
- package/dist/esm/components/builtin/SocialLinks/components/SocialLinksPlaceholder/index.js.map +1 -1
- package/dist/esm/components/shared/BackgroundsContainer/components/BackgroundVideo/index.js.map +1 -1
- package/dist/esm/components/shared/BackgroundsContainer/components/Backgrounds/index.js.map +1 -1
- package/dist/esm/components/shared/BackgroundsContainer/components/Parallax/index.js.map +1 -1
- package/dist/esm/controls/rich-text-v2/plugin.js.map +1 -1
- package/dist/esm/next/components/framework-provider/pages-router/HeadSnippet.js.map +1 -1
- package/dist/esm/next/components/tests/controls/page-control-prop-rendering.js +1 -2
- package/dist/esm/next/components/tests/controls/page-control-prop-rendering.js.map +1 -1
- package/dist/esm/next/components/tests/makeswift-component/fixtures.js +61 -0
- package/dist/esm/next/components/tests/makeswift-component/fixtures.js.map +1 -0
- package/dist/esm/next/components/tests/prop-controllers/page-prop-controller.js +1 -1
- package/dist/esm/next/components/tests/prop-controllers/page-prop-controller.js.map +1 -1
- package/dist/esm/next/testing/page-rendering.js +1 -1
- package/dist/esm/next/testing/page-rendering.js.map +1 -1
- package/dist/esm/runtimes/react/components/Document.js.map +1 -1
- package/dist/esm/runtimes/react/components/DocumentRoot.js.map +1 -1
- package/dist/esm/runtimes/react/components/Element.js.map +1 -1
- package/dist/esm/runtimes/react/components/ElementData.js +3 -3
- package/dist/esm/runtimes/react/components/ElementData.js.map +1 -1
- package/dist/esm/runtimes/react/components/ElementReference.js.map +1 -1
- package/dist/esm/runtimes/react/components/ElementRegistration.js.map +1 -1
- package/dist/esm/runtimes/react/components/LiveProvider.js.map +1 -1
- package/dist/esm/runtimes/react/components/MakeswiftComponent.js +3 -3
- package/dist/esm/runtimes/react/components/MakeswiftComponent.js.map +1 -1
- package/dist/esm/runtimes/react/components/PreviewProvider.js.map +1 -1
- package/dist/esm/runtimes/react/components/activity-with-fallback.js +19 -0
- package/dist/esm/runtimes/react/components/activity-with-fallback.js.map +1 -0
- package/dist/esm/runtimes/react/components/page/HeadSnippet.js.map +1 -1
- package/dist/esm/runtimes/react/components/page/Page.js.map +1 -1
- package/dist/esm/runtimes/react/components/page/PageHead.js.map +1 -1
- package/dist/esm/runtimes/react/components/page/head-tags.js.map +1 -1
- package/dist/esm/runtimes/react/components/page/index.js +3 -2
- package/dist/esm/runtimes/react/components/page/index.js.map +1 -1
- package/dist/esm/runtimes/react/components/render-hook.js.map +1 -1
- package/dist/esm/runtimes/react/controls/control.js.map +1 -1
- package/dist/esm/runtimes/react/controls/group.js.map +1 -1
- package/dist/esm/runtimes/react/controls/rich-text-v2/EditableTextV2/render-leaf.js.map +1 -1
- package/dist/esm/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.js.map +1 -1
- package/dist/esm/runtimes/react/controls/slot.js.map +1 -1
- package/dist/esm/runtimes/react/controls.js.map +1 -1
- package/dist/esm/runtimes/react/find-dom-node.js +2 -0
- package/dist/esm/runtimes/react/find-dom-node.js.map +1 -1
- package/dist/esm/runtimes/react/hooks/makeswift-api.js +2 -2
- package/dist/esm/runtimes/react/hooks/makeswift-api.js.map +1 -1
- package/dist/esm/runtimes/react/legacy-controls.js.map +1 -1
- package/dist/esm/runtimes/react/lib/react-dom.js +2 -1
- package/dist/esm/runtimes/react/lib/react-dom.js.map +1 -1
- package/dist/esm/runtimes/react/react-runtime-core.js +6 -0
- package/dist/esm/runtimes/react/react-runtime-core.js.map +1 -1
- package/dist/esm/runtimes/react/use-global-style.js +1 -1
- package/dist/esm/runtimes/react/use-global-style.js.map +1 -1
- package/dist/types/components/builtin/Button/Button.d.ts +2 -2
- package/dist/types/components/builtin/Button/Button.d.ts.map +1 -1
- package/dist/types/components/builtin/Carousel/Carousel.d.ts.map +1 -1
- package/dist/types/components/builtin/Embed/Embed.d.ts.map +1 -1
- package/dist/types/components/builtin/Form/components/Field/components/Label/index.d.ts +2 -2
- package/dist/types/components/builtin/Form/components/Field/components/Label/index.d.ts.map +1 -1
- package/dist/types/components/builtin/Form/components/Field/components/PlaceholderTableField/index.d.ts +2 -1
- package/dist/types/components/builtin/Form/components/Field/components/PlaceholderTableField/index.d.ts.map +1 -1
- package/dist/types/components/builtin/Form/components/Field/index.d.ts +2 -1
- package/dist/types/components/builtin/Form/components/Field/index.d.ts.map +1 -1
- package/dist/types/components/builtin/Form/components/Spinner/index.d.ts +2 -1
- package/dist/types/components/builtin/Form/components/Spinner/index.d.ts.map +1 -1
- package/dist/types/components/builtin/Navigation/components/DropDownButton/index.d.ts +2 -2
- package/dist/types/components/builtin/Navigation/components/DropDownButton/index.d.ts.map +1 -1
- package/dist/types/components/builtin/Navigation/components/LinksPlaceholder/index.d.ts +2 -1
- package/dist/types/components/builtin/Navigation/components/LinksPlaceholder/index.d.ts.map +1 -1
- package/dist/types/components/builtin/Navigation/components/MobileMenu/components/MobileDropDownButton/index.d.ts +2 -2
- package/dist/types/components/builtin/Navigation/components/MobileMenu/components/MobileDropDownButton/index.d.ts.map +1 -1
- package/dist/types/components/builtin/Navigation/components/MobileMenu/index.d.ts +2 -1
- package/dist/types/components/builtin/Navigation/components/MobileMenu/index.d.ts.map +1 -1
- package/dist/types/components/builtin/SocialLinks/components/SocialLinksPlaceholder/index.d.ts +2 -1
- package/dist/types/components/builtin/SocialLinks/components/SocialLinksPlaceholder/index.d.ts.map +1 -1
- package/dist/types/components/shared/BackgroundsContainer/components/BackgroundVideo/index.d.ts +2 -1
- package/dist/types/components/shared/BackgroundsContainer/components/BackgroundVideo/index.d.ts.map +1 -1
- package/dist/types/components/shared/BackgroundsContainer/components/Backgrounds/index.d.ts +2 -1
- package/dist/types/components/shared/BackgroundsContainer/components/Backgrounds/index.d.ts.map +1 -1
- package/dist/types/components/shared/BackgroundsContainer/components/Parallax/index.d.ts +1 -1
- package/dist/types/components/shared/BackgroundsContainer/components/Parallax/index.d.ts.map +1 -1
- package/dist/types/components/shared/ErrorBoundary.d.ts +1 -1
- package/dist/types/controls/rich-text-v2/plugin.d.ts +7 -7
- package/dist/types/controls/rich-text-v2/plugin.d.ts.map +1 -1
- package/dist/types/next/components/tests/controls/page-control-prop-rendering.d.ts.map +1 -1
- package/dist/types/next/components/tests/global-element-rendering.test.d.ts +1 -1
- package/dist/types/next/components/tests/global-element-rendering.test.d.ts.map +1 -1
- package/dist/types/next/components/tests/makeswift-component/fixtures.d.ts +27 -0
- package/dist/types/next/components/tests/makeswift-component/fixtures.d.ts.map +1 -0
- package/dist/types/next/components/tests/{makeswift-component-rendering.test.d.ts → makeswift-component/rendering.react18.test.d.ts} +1 -1
- package/dist/types/next/components/tests/makeswift-component/rendering.react18.test.d.ts.map +1 -0
- package/dist/types/next/components/tests/makeswift-component/rendering.test.d.ts +3 -0
- package/dist/types/next/components/tests/makeswift-component/rendering.test.d.ts.map +1 -0
- package/dist/types/next/testing/page-rendering.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/Document.d.ts +1 -1
- package/dist/types/runtimes/react/components/Document.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/DocumentRoot.d.ts +1 -1
- package/dist/types/runtimes/react/components/DocumentRoot.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/Element.d.ts +1 -1
- package/dist/types/runtimes/react/components/Element.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/ElementData.d.ts +1 -1
- package/dist/types/runtimes/react/components/ElementData.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/ElementReference.d.ts +1 -1
- package/dist/types/runtimes/react/components/ElementReference.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/LiveProvider.d.ts +2 -2
- package/dist/types/runtimes/react/components/LiveProvider.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/MakeswiftComponent.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/PreviewProvider.d.ts +2 -2
- package/dist/types/runtimes/react/components/PreviewProvider.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/activity-with-fallback.d.ts +13 -0
- package/dist/types/runtimes/react/components/activity-with-fallback.d.ts.map +1 -0
- package/dist/types/runtimes/react/components/page/HeadSnippet.d.ts +2 -1
- package/dist/types/runtimes/react/components/page/HeadSnippet.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/page/Page.d.ts +2 -1
- package/dist/types/runtimes/react/components/page/Page.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/page/PageHead.d.ts +2 -1
- package/dist/types/runtimes/react/components/page/PageHead.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/page/head-tags.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/page/index.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/render-hook.d.ts +3 -2
- package/dist/types/runtimes/react/components/render-hook.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls/control.d.ts +3 -2
- package/dist/types/runtimes/react/controls/control.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls/group.d.ts +3 -2
- package/dist/types/runtimes/react/controls/group.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls/rich-text-v2/EditableTextV2/render-leaf.d.ts +2 -1
- package/dist/types/runtimes/react/controls/rich-text-v2/EditableTextV2/render-leaf.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.d.ts +2 -1
- package/dist/types/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls/slot.d.ts +2 -2
- package/dist/types/runtimes/react/controls/slot.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls.d.ts +3 -2
- package/dist/types/runtimes/react/controls.d.ts.map +1 -1
- package/dist/types/runtimes/react/find-dom-node.d.ts.map +1 -1
- package/dist/types/runtimes/react/legacy-controls.d.ts +2 -1
- package/dist/types/runtimes/react/legacy-controls.d.ts.map +1 -1
- package/dist/types/runtimes/react/lib/react-dom.d.ts.map +1 -1
- package/dist/types/runtimes/react/react-runtime-core.d.ts +5 -0
- package/dist/types/runtimes/react/react-runtime-core.d.ts.map +1 -1
- package/dist/types/slate/BlockPlugin/index.d.ts +2 -2
- package/dist/types/slate/InlineModePlugin/index.d.ts +2 -2
- package/dist/types/slate/InlinePlugin/index.d.ts +2 -2
- package/dist/types/slate/LinkPlugin/index.d.ts +2 -2
- package/dist/types/slate/TextAlignPlugin/index.d.ts +2 -2
- package/dist/types/slate/TypographyPlugin/index.d.ts +2 -2
- package/dist/types/slate/test-helpers/editor-v1.d.ts +1 -0
- package/dist/types/slate/test-helpers/editor-v1.d.ts.map +1 -1
- package/dist/types/slate/test-helpers/editor-v2-inline.d.ts +1 -0
- package/dist/types/slate/test-helpers/editor-v2-inline.d.ts.map +1 -1
- package/dist/types/slate/test-helpers/editor-v2.d.ts +1 -0
- package/dist/types/slate/test-helpers/editor-v2.d.ts.map +1 -1
- package/dist/types/slate/test-helpers/test-elements.d.ts +1 -1
- package/dist/types/slate/test-helpers/test-elements.d.ts.map +1 -1
- package/package.json +9 -6
- package/dist/types/next/components/tests/makeswift-component-rendering.test.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/runtimes/react/components/ElementReference.tsx"],"sourcesContent":["import { Ref, forwardRef, memo, useMemo } from 'react'\nimport { ElementImperativeHandle } from '../element-imperative-handle'\nimport { useGlobalElement, useLocalizedGlobalElement } from '../hooks/makeswift-api'\nimport { useDocument } from '../hooks/use-document'\nimport { DocumentCyclesContext, useDocumentCycles } from '../hooks/use-document-cycles'\nimport {\n ElementData as ReactPageElementData,\n ElementReference as ReactPageElementReference,\n} from '../../../state/react-page'\nimport { FallbackComponent } from '../../../components/shared/FallbackComponent'\nimport { Element } from './Element'\nimport { Document } from './Document'\nimport { DisableRegisterElement } from '../hooks/use-disable-register-element'\nimport { useDocumentLocale } from '../hooks/use-document-context'\n\ntype ElementRefereceProps = {\n elementReference: ReactPageElementReference\n}\n\nexport const ElementReference = memo(\n forwardRef(function ElementReference(\n { elementReference }: ElementRefereceProps,\n ref: Ref<ElementImperativeHandle>,\n ):
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/components/ElementReference.tsx"],"sourcesContent":["import { Ref, forwardRef, memo, useMemo, ReactNode } from 'react'\nimport { ElementImperativeHandle } from '../element-imperative-handle'\nimport { useGlobalElement, useLocalizedGlobalElement } from '../hooks/makeswift-api'\nimport { useDocument } from '../hooks/use-document'\nimport { DocumentCyclesContext, useDocumentCycles } from '../hooks/use-document-cycles'\nimport {\n ElementData as ReactPageElementData,\n ElementReference as ReactPageElementReference,\n} from '../../../state/react-page'\nimport { FallbackComponent } from '../../../components/shared/FallbackComponent'\nimport { Element } from './Element'\nimport { Document } from './Document'\nimport { DisableRegisterElement } from '../hooks/use-disable-register-element'\nimport { useDocumentLocale } from '../hooks/use-document-context'\n\ntype ElementRefereceProps = {\n elementReference: ReactPageElementReference\n}\n\nexport const ElementReference = memo(\n forwardRef(function ElementReference(\n { elementReference }: ElementRefereceProps,\n ref: Ref<ElementImperativeHandle>,\n ): ReactNode {\n const globalElement = useGlobalElement(elementReference.value)\n const locale = useDocumentLocale()\n // Update the logic here when we can merge element trees\n const localizedGlobalElement = useLocalizedGlobalElement(locale, elementReference.value)\n const globalElementData = (localizedGlobalElement?.data ?? globalElement?.data) as\n | ReactPageElementData\n | undefined\n const elementReferenceDocument = useDocument(elementReference.key)\n const documentKey = elementReference.key\n const documentKeys = useDocumentCycles()\n const providedDocumentKeys = useMemo(\n () => [...documentKeys, documentKey],\n [documentKeys, documentKey],\n )\n\n if (globalElementData == null) {\n return (\n <FallbackComponent\n ref={ref as Ref<HTMLDivElement>}\n text=\"This global component doesn't exist\"\n />\n )\n }\n\n if (documentKeys.includes(documentKey)) {\n return (\n <FallbackComponent\n ref={ref as Ref<HTMLDivElement>}\n text=\"This global component contains itself!\"\n />\n )\n }\n\n return (\n <DocumentCyclesContext.Provider value={providedDocumentKeys}>\n {elementReferenceDocument != null ? (\n <Document document={elementReferenceDocument} ref={ref} />\n ) : (\n <DisableRegisterElement.Provider value={true}>\n {/* We render Element instead of ElementData because we rely on the FindDomNode */}\n <Element element={globalElementData} ref={ref} />\n </DisableRegisterElement.Provider>\n )}\n </DocumentCyclesContext.Provider>\n )\n }),\n)\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAyCQ;AAzCR,mBAA0D;AAE1D,2BAA4D;AAC5D,0BAA4B;AAC5B,iCAAyD;AAKzD,+BAAkC;AAClC,qBAAwB;AACxB,sBAAyB;AACzB,0CAAuC;AACvC,kCAAkC;AAM3B,MAAM,uBAAmB;AAAA,MAC9B,yBAAW,SAASA,kBAClB,EAAE,iBAAiB,GACnB,KACW;AACX,UAAM,oBAAgB,uCAAiB,iBAAiB,KAAK;AAC7D,UAAM,aAAS,+CAAkB;AAEjC,UAAM,6BAAyB,gDAA0B,QAAQ,iBAAiB,KAAK;AACvF,UAAM,oBAAqB,wBAAwB,QAAQ,eAAe;AAG1E,UAAM,+BAA2B,iCAAY,iBAAiB,GAAG;AACjE,UAAM,cAAc,iBAAiB;AACrC,UAAM,mBAAe,8CAAkB;AACvC,UAAM,2BAAuB;AAAA,MAC3B,MAAM,CAAC,GAAG,cAAc,WAAW;AAAA,MACnC,CAAC,cAAc,WAAW;AAAA,IAC5B;AAEA,QAAI,qBAAqB,MAAM;AAC7B,aACE;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA,MAAK;AAAA;AAAA,MACP;AAAA,IAEJ;AAEA,QAAI,aAAa,SAAS,WAAW,GAAG;AACtC,aACE;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA,MAAK;AAAA;AAAA,MACP;AAAA,IAEJ;AAEA,WACE,4CAAC,iDAAsB,UAAtB,EAA+B,OAAO,sBACpC,sCAA4B,OAC3B,4CAAC,4BAAS,UAAU,0BAA0B,KAAU,IAExD,4CAAC,2DAAuB,UAAvB,EAAgC,OAAO,MAEtC,sDAAC,0BAAQ,SAAS,mBAAmB,KAAU,GACjD,GAEJ;AAAA,EAEJ,CAAC;AACH;","names":["ElementReference"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/runtimes/react/components/ElementRegistration.tsx"],"sourcesContent":["'use client'\n\nimport { ReactNode, memo, useEffect } from 'react'\nimport { ElementImperativeHandle } from '../element-imperative-handle'\nimport { useDispatch } from '../hooks/use-dispatch'\nimport { useDocumentKey } from '../hooks/use-document-context'\nimport { useDisableRegisterElement } from '../hooks/use-disable-register-element'\nimport { mountComponentEffect } from '../../../state/builder-api/actions'\nimport { registerComponentHandleEffect } from '../../../state/actions/internal'\n\ntype RegisterChildrenAsElementProps = {\n elementKey: string\n componentHandle: ElementImperativeHandle\n children?: ReactNode\n}\n\nexport const ElementRegistration = memo(function ElementRegistration({\n elementKey,\n componentHandle,\n children,\n}: RegisterChildrenAsElementProps):
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/components/ElementRegistration.tsx"],"sourcesContent":["'use client'\n\nimport { ReactNode, memo, useEffect } from 'react'\nimport { ElementImperativeHandle } from '../element-imperative-handle'\nimport { useDispatch } from '../hooks/use-dispatch'\nimport { useDocumentKey } from '../hooks/use-document-context'\nimport { useDisableRegisterElement } from '../hooks/use-disable-register-element'\nimport { mountComponentEffect } from '../../../state/builder-api/actions'\nimport { registerComponentHandleEffect } from '../../../state/actions/internal'\n\ntype RegisterChildrenAsElementProps = {\n elementKey: string\n componentHandle: ElementImperativeHandle\n children?: ReactNode\n}\n\nexport const ElementRegistration = memo(function ElementRegistration({\n elementKey,\n componentHandle,\n children,\n}: RegisterChildrenAsElementProps): ReactNode {\n const dispatch = useDispatch()\n const documentKey = useDocumentKey()\n\n const isRegisterElementDisabled = useDisableRegisterElement()\n\n useEffect(() => {\n if (documentKey == null || isRegisterElementDisabled) return\n\n return dispatch(registerComponentHandleEffect(documentKey, elementKey, componentHandle))\n }, [dispatch, documentKey, elementKey, isRegisterElementDisabled])\n\n useEffect(() => {\n if (documentKey == null || isRegisterElementDisabled) return\n\n return dispatch(mountComponentEffect(documentKey, elementKey))\n }, [dispatch, documentKey, elementKey, isRegisterElementDisabled])\n\n return <>{children}</>\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAsCS;AApCT,mBAA2C;AAE3C,0BAA4B;AAC5B,kCAA+B;AAC/B,0CAA0C;AAC1C,qBAAqC;AACrC,sBAA8C;AAQvC,MAAM,0BAAsB,mBAAK,SAASA,qBAAoB;AAAA,EACnE;AAAA,EACA;AAAA,EACA;AACF,GAA8C;AAC5C,QAAM,eAAW,iCAAY;AAC7B,QAAM,kBAAc,4CAAe;AAEnC,QAAM,gCAA4B,+DAA0B;AAE5D,8BAAU,MAAM;AACd,QAAI,eAAe,QAAQ;AAA2B;AAEtD,WAAO,aAAS,+CAA8B,aAAa,YAAY,eAAe,CAAC;AAAA,EACzF,GAAG,CAAC,UAAU,aAAa,YAAY,yBAAyB,CAAC;AAEjE,8BAAU,MAAM;AACd,QAAI,eAAe,QAAQ;AAA2B;AAEtD,WAAO,aAAS,qCAAqB,aAAa,UAAU,CAAC;AAAA,EAC/D,GAAG,CAAC,UAAU,aAAa,YAAY,yBAAyB,CAAC;AAEjE,SAAO,2EAAG,UAAS;AACrB,CAAC;","names":["ElementRegistration"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/runtimes/react/components/LiveProvider.tsx"],"sourcesContent":["import { type PropsWithChildren, useMemo } from 'react'\n\nimport * as ReactPage from '../../../state/react-page'\n\nimport { useReactRuntime } from '../hooks/use-react-runtime'\nimport { StoreContext } from '../hooks/use-store'\n\nexport default function LiveProvider({ children }: PropsWithChildren):
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/components/LiveProvider.tsx"],"sourcesContent":["import { type PropsWithChildren, useMemo, ReactNode } from 'react'\n\nimport * as ReactPage from '../../../state/react-page'\n\nimport { useReactRuntime } from '../hooks/use-react-runtime'\nimport { StoreContext } from '../hooks/use-store'\n\nexport default function LiveProvider({ children }: PropsWithChildren): ReactNode {\n const runtime = useReactRuntime()\n const store = useMemo(\n () =>\n ReactPage.configureStore({\n name: 'Host store',\n preloadedState: runtime.store.getState(),\n }),\n [runtime],\n )\n\n return <StoreContext.Provider value={store}>{children}</StoreContext.Provider>\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBS;AAlBT,mBAA2D;AAE3D,gBAA2B;AAE3B,+BAAgC;AAChC,uBAA6B;AAEd,SAAR,aAA8B,EAAE,SAAS,GAAiC;AAC/E,QAAM,cAAU,0CAAgB;AAChC,QAAM,YAAQ;AAAA,IACZ,MACE,UAAU,eAAe;AAAA,MACvB,MAAM;AAAA,MACN,gBAAgB,QAAQ,MAAM,SAAS;AAAA,IACzC,CAAC;AAAA,IACH,CAAC,OAAO;AAAA,EACV;AAEA,SAAO,4CAAC,8BAAa,UAAb,EAAsB,OAAO,OAAQ,UAAS;AACxD;","names":[]}
|
|
@@ -29,6 +29,7 @@ var import_react_page = require("../../../state/react-page");
|
|
|
29
29
|
var import_use_cache_data = require("../hooks/use-cache-data");
|
|
30
30
|
var import_use_register_document = require("../hooks/use-register-document");
|
|
31
31
|
var import_use_builtin_suspense = require("../hooks/use-builtin-suspense");
|
|
32
|
+
var import_activity_with_fallback = require("./activity-with-fallback");
|
|
32
33
|
var import_DocumentRoot = require("./DocumentRoot");
|
|
33
34
|
const MakeswiftComponent = (0, import_react.memo)(({ snapshot, label, type, description }) => {
|
|
34
35
|
(0, import_use_cache_data.useCacheData)(snapshot.cacheData);
|
|
@@ -45,8 +46,7 @@ const MakeswiftComponent = (0, import_react.memo)(({ snapshot, label, type, desc
|
|
|
45
46
|
);
|
|
46
47
|
(0, import_use_register_document.useRegisterDocument)(rootDocument);
|
|
47
48
|
const builtinSuspense = (0, import_use_builtin_suspense.useBuiltinSuspense)((0, import_react_page.getRootElement)(rootDocument).type);
|
|
48
|
-
|
|
49
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SuspenseOrFragment, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_DocumentRoot.DocumentRoot, { rootDocument }) });
|
|
49
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_activity_with_fallback.ActivityOrFallback, { suspenseFallback: builtinSuspense, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_DocumentRoot.DocumentRoot, { rootDocument }) });
|
|
50
50
|
});
|
|
51
51
|
// Annotate the CommonJS export names for ESM import in node:
|
|
52
52
|
0 && (module.exports = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/runtimes/react/components/MakeswiftComponent.tsx"],"sourcesContent":["'use client'\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/components/MakeswiftComponent.tsx"],"sourcesContent":["'use client'\n\nimport { memo, useMemo } from 'react'\n\nimport {\n componentDocumentToRootEmbeddedDocument,\n MakeswiftComponentSnapshot,\n} from '../../../client'\nimport { getRootElement } from '../../../state/react-page'\n\nimport { useCacheData } from '../hooks/use-cache-data'\nimport { useRegisterDocument } from '../hooks/use-register-document'\nimport { useBuiltinSuspense } from '../hooks/use-builtin-suspense'\nimport { ActivityOrFallback } from './activity-with-fallback'\n\nimport { DocumentRoot } from './DocumentRoot'\n\ntype Props = {\n snapshot: MakeswiftComponentSnapshot\n label: string\n type: string\n description?: string\n}\n\nexport const MakeswiftComponent = memo(({ snapshot, label, type, description }: Props) => {\n useCacheData(snapshot.cacheData)\n\n const rootDocument = useMemo(\n () =>\n componentDocumentToRootEmbeddedDocument({\n document: snapshot.document,\n documentKey: snapshot.key,\n name: label,\n type,\n description,\n meta: snapshot.meta,\n }),\n [snapshot, label, type, description],\n )\n\n useRegisterDocument(rootDocument)\n\n const builtinSuspense = useBuiltinSuspense(getRootElement(rootDocument).type)\n\n return (\n <ActivityOrFallback suspenseFallback={builtinSuspense}>\n <DocumentRoot rootDocument={rootDocument} />\n </ActivityOrFallback>\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA8CM;AA5CN,mBAA8B;AAE9B,oBAGO;AACP,wBAA+B;AAE/B,4BAA6B;AAC7B,mCAAoC;AACpC,kCAAmC;AACnC,oCAAmC;AAEnC,0BAA6B;AAStB,MAAM,yBAAqB,mBAAK,CAAC,EAAE,UAAU,OAAO,MAAM,YAAY,MAAa;AACxF,0CAAa,SAAS,SAAS;AAE/B,QAAM,mBAAe;AAAA,IACnB,UACE,uDAAwC;AAAA,MACtC,UAAU,SAAS;AAAA,MACnB,aAAa,SAAS;AAAA,MACtB,MAAM;AAAA,MACN;AAAA,MACA;AAAA,MACA,MAAM,SAAS;AAAA,IACjB,CAAC;AAAA,IACH,CAAC,UAAU,OAAO,MAAM,WAAW;AAAA,EACrC;AAEA,wDAAoB,YAAY;AAEhC,QAAM,sBAAkB,oDAAmB,kCAAe,YAAY,EAAE,IAAI;AAE5E,SACE,4CAAC,oDAAmB,kBAAkB,iBACpC,sDAAC,oCAAa,cAA4B,GAC5C;AAEJ,CAAC;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/runtimes/react/components/PreviewProvider.tsx"],"sourcesContent":["'use client'\n\nimport { type PropsWithChildren, useEffect, useMemo } from 'react'\n\nimport * as ReactBuilderPreview from '../../../state/react-builder-preview'\nimport { BuilderAPIProxy } from '../../../state/builder-api/proxy'\n\nimport { useReactRuntime } from '../hooks/use-react-runtime'\nimport { StoreContext } from '../hooks/use-store'\nimport { useMakeswiftHostApiClient } from '../host-api-client'\n\nexport default function PreviewProvider({\n appOrigin,\n children,\n}: PropsWithChildren<{ appOrigin: string }>):
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/components/PreviewProvider.tsx"],"sourcesContent":["'use client'\n\nimport { type PropsWithChildren, useEffect, useMemo, ReactNode } from 'react'\n\nimport * as ReactBuilderPreview from '../../../state/react-builder-preview'\nimport { BuilderAPIProxy } from '../../../state/builder-api/proxy'\n\nimport { useReactRuntime } from '../hooks/use-react-runtime'\nimport { StoreContext } from '../hooks/use-store'\nimport { useMakeswiftHostApiClient } from '../host-api-client'\n\nexport default function PreviewProvider({\n appOrigin,\n children,\n}: PropsWithChildren<{ appOrigin: string }>): ReactNode {\n const runtime = useReactRuntime()\n const client = useMakeswiftHostApiClient()\n const builderProxy = useMemo(() => new BuilderAPIProxy({ appOrigin }), [appOrigin])\n\n const store = useMemo(\n () =>\n ReactBuilderPreview.configureStore({\n preloadedState: runtime.store.getState(),\n client,\n builderProxy,\n }),\n [runtime, client, builderProxy],\n )\n\n useEffect(() => {\n store.setup()\n return () => store.teardown()\n }, [store])\n\n return <StoreContext.Provider value={store}>{children}</StoreContext.Provider>\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAkCS;AAhCT,mBAAsE;AAEtE,0BAAqC;AACrC,mBAAgC;AAEhC,+BAAgC;AAChC,uBAA6B;AAC7B,6BAA0C;AAE3B,SAAR,gBAAiC;AAAA,EACtC;AAAA,EACA;AACF,GAAwD;AACtD,QAAM,cAAU,0CAAgB;AAChC,QAAM,aAAS,kDAA0B;AACzC,QAAM,mBAAe,sBAAQ,MAAM,IAAI,6BAAgB,EAAE,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC;AAElF,QAAM,YAAQ;AAAA,IACZ,MACE,oBAAoB,eAAe;AAAA,MACjC,gBAAgB,QAAQ,MAAM,SAAS;AAAA,MACvC;AAAA,MACA;AAAA,IACF,CAAC;AAAA,IACH,CAAC,SAAS,QAAQ,YAAY;AAAA,EAChC;AAEA,8BAAU,MAAM;AACd,UAAM,MAAM;AACZ,WAAO,MAAM,MAAM,SAAS;AAAA,EAC9B,GAAG,CAAC,KAAK,CAAC;AAEV,SAAO,4CAAC,8BAAa,UAAb,EAAsB,OAAO,OAAQ,UAAS;AACxD;","names":[]}
|
|
@@ -0,0 +1,54 @@
|
|
|
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 activity_with_fallback_exports = {};
|
|
30
|
+
__export(activity_with_fallback_exports, {
|
|
31
|
+
ActivityOrFallback: () => ActivityOrFallback,
|
|
32
|
+
supportsActivity: () => supportsActivity
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(activity_with_fallback_exports);
|
|
35
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
|
+
var React = __toESM(require("react"));
|
|
37
|
+
var import_react = require("react");
|
|
38
|
+
const ACTIVITY_KEY = "Activity";
|
|
39
|
+
const Activity = React[ACTIVITY_KEY];
|
|
40
|
+
function supportsActivity() {
|
|
41
|
+
return Activity != null;
|
|
42
|
+
}
|
|
43
|
+
function ActivityOrFallback({ suspenseFallback = true, children }) {
|
|
44
|
+
if (supportsActivity()) {
|
|
45
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Activity, { children });
|
|
46
|
+
}
|
|
47
|
+
return suspenseFallback ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Suspense, { children }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children });
|
|
48
|
+
}
|
|
49
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
+
0 && (module.exports = {
|
|
51
|
+
ActivityOrFallback,
|
|
52
|
+
supportsActivity
|
|
53
|
+
});
|
|
54
|
+
//# sourceMappingURL=activity-with-fallback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/components/activity-with-fallback.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Suspense, type ReactNode } from 'react'\n\ntype Props = {\n suspenseFallback?: boolean\n children: ReactNode\n}\n\n// Activity is only available in React 19.2+. On Next.js <16, direct access like React['Activity'] or React.Activity\n// triggers bundler warnings about missing exports. Using a variable bypasses static analysis.\nconst ACTIVITY_KEY = 'Activity'\nconst Activity = React[ACTIVITY_KEY]\n\nexport function supportsActivity(): boolean {\n return Activity != null\n}\n\n/**\n * Uses React.Activity if available, otherwise falls back to\n * Suspense (when suspenseFallback is true) or Fragment (when false).\n */\nexport function ActivityOrFallback({ suspenseFallback = true, children }: Props): ReactNode {\n if (supportsActivity()) {\n return <Activity>{children}</Activity>\n }\n\n return suspenseFallback ? <Suspense>{children}</Suspense> : <>{children}</>\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuBW;AAvBX,YAAuB;AACvB,mBAAyC;AASzC,MAAM,eAAe;AACrB,MAAM,WAAW,MAAM,YAAY;AAE5B,SAAS,mBAA4B;AAC1C,SAAO,YAAY;AACrB;AAMO,SAAS,mBAAmB,EAAE,mBAAmB,MAAM,SAAS,GAAqB;AAC1F,MAAI,iBAAiB,GAAG;AACtB,WAAO,4CAAC,YAAU,UAAS;AAAA,EAC7B;AAEA,SAAO,mBAAmB,4CAAC,yBAAU,UAAS,IAAc,2EAAG,UAAS;AAC1E;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/runtimes/react/components/page/HeadSnippet.tsx"],"sourcesContent":["import { Children, createElement, useEffect } from 'react'\nimport parse from 'html-react-parser'\n\nimport { type Snippet } from '../../../../client'\n\nexport function BaseHeadSnippet({ snippet }: { snippet: Snippet }) {\n useEffect(() => {\n const snippetElements = getSnippetElementsFromDOM(snippet)\n const isAlreadyInTheDOM = snippetElements.length > 0\n\n if (isAlreadyInTheDOM) return\n\n return renderSnippetAndExecuteScripts(snippet, window.document.head)\n }, [snippet])\n\n return null\n}\n\nconst SNIPPET_ID_ATRIBUTE_NAME = 'data-makeswift-snippet-id'\n\nconst VALID_HEAD_ELEMENT_TYPES = [\n 'title',\n 'base',\n 'link',\n 'style',\n 'meta',\n 'script',\n 'noscript',\n 'template',\n]\n\nexport function snippetToElements(snippet: Pick<Snippet, 'id' | 'code'>): (string |
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/runtimes/react/components/page/HeadSnippet.tsx"],"sourcesContent":["import { Children, createElement, useEffect, ReactNode } from 'react'\nimport parse from 'html-react-parser'\n\nimport { type Snippet } from '../../../../client'\n\nexport function BaseHeadSnippet({ snippet }: { snippet: Snippet }) {\n useEffect(() => {\n const snippetElements = getSnippetElementsFromDOM(snippet)\n const isAlreadyInTheDOM = snippetElements.length > 0\n\n if (isAlreadyInTheDOM) return\n\n return renderSnippetAndExecuteScripts(snippet, window.document.head)\n }, [snippet])\n\n return null\n}\n\nconst SNIPPET_ID_ATRIBUTE_NAME = 'data-makeswift-snippet-id'\n\nconst VALID_HEAD_ELEMENT_TYPES = [\n 'title',\n 'base',\n 'link',\n 'style',\n 'meta',\n 'script',\n 'noscript',\n 'template',\n]\n\nexport function snippetToElements(snippet: Pick<Snippet, 'id' | 'code'>): (string | ReactNode)[] {\n return Children.map(parse(snippet.code), element => {\n if (typeof element === 'string') return element\n\n if (!VALID_HEAD_ELEMENT_TYPES.includes(element.type as string)) return null\n\n const key = element.key ? `${snippet.id}:${element.key}` : snippet.id\n\n return createElement(element.type, {\n ...element.props,\n key,\n [SNIPPET_ID_ATRIBUTE_NAME]: snippet.id,\n })\n })\n}\n\nexport function renderSnippetAndExecuteScripts(\n snippet: Snippet,\n container: HTMLElement,\n): () => void {\n const virtualContainer = container.ownerDocument.createElement(container.tagName)\n\n virtualContainer.innerHTML = snippet.code\n\n const elements = Array.from(virtualContainer.querySelectorAll('*'))\n const scripts = elements.filter(el => el instanceof HTMLScriptElement)\n\n scripts.forEach(script => {\n const clone = script.ownerDocument.createElement(script.tagName)\n\n clone.textContent = script.textContent\n Array.from(script.attributes).forEach(({ name, value }) => {\n clone.setAttribute(name, value)\n })\n clone.setAttribute(SNIPPET_ID_ATRIBUTE_NAME, snippet.id)\n script.parentNode?.replaceChild(clone, script)\n })\n\n const nodes = Array.from(virtualContainer.childNodes)\n container.append(...nodes)\n\n return () => {\n nodes.forEach(node => {\n node.parentNode?.removeChild(node)\n })\n\n cleanUpSnippet(snippet)\n }\n}\n\nexport function cleanUpSnippet(snippet: Snippet): void {\n if (snippet.cleanup == null) return\n try {\n const cleanUp = new Function(snippet.cleanup)\n cleanUp()\n } catch {\n // Ignore errors from user input.\n }\n}\n\nexport function getSnippetElementsFromDOM(snippet: Snippet) {\n return document.head.querySelectorAll(`[${SNIPPET_ID_ATRIBUTE_NAME}=\"${snippet.id}\"]`)\n}\n"],"mappings":";;;;;;;;;;;;;;;;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M,KAAK,OAAO,UAAU,EAAE,QAAQ,CAAC,EAAE,MAAM,MAAM,MAAM;AACzD,YAAM,aAAa,MAAM,KAAK;AAAA,IAChC,CAAC;AACD,UAAM,aAAa,0BAA0B,QAAQ,EAAE;AACvD,WAAO,YAAY,aAAa,OAAO,MAAM;AAAA,EAC/C,CAAC;AAED,QAAM,QAAQ,MAAM,KAAK,iBAAiB,UAAU;AACpD,YAAU,OAAO,GAAG,KAAK;AAEzB,SAAO,MAAM;AACX,UAAM,QAAQ,UAAQ;AACpB,WAAK,YAAY,YAAY,IAAI;AAAA,IACnC,CAAC;AAED,mBAAe,OAAO;AAAA,EACxB;AACF;AAEO,SAAS,eAAe,SAAwB;AACrD,MAAI,QAAQ,WAAW;AAAM;AAC7B,MAAI;AACF,UAAM,UAAU,IAAI,SAAS,QAAQ,OAAO;AAC5C,YAAQ;AAAA,EACV,QAAQ;AAAA,EAER;AACF;AAEO,SAAS,0BAA0B,SAAkB;AAC1D,SAAO,SAAS,KAAK,iBAAiB,IAAI,wBAAwB,KAAK,QAAQ,EAAE,IAAI;AACvF;","names":["parse"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/runtimes/react/components/page/Page.tsx"],"sourcesContent":["import { useMemo } from 'react'\n\nimport { DocumentRoot } from '../DocumentRoot'\nimport { type Document } from '../../../../state/react-page'\nimport { MakeswiftPageDocument } from '../../../../client'\nimport { usePageSnippets } from '../hooks/use-page-snippets'\n\nimport { BodySnippet } from './BodySnippet'\nimport { PageHead } from './PageHead'\nimport { flattenMetadataSettings, type PageMetadataSettings } from './page-seo-settings'\n\ntype Props = {\n page: MakeswiftPageDocument\n rootDocument: Document\n metadata?: boolean | PageMetadataSettings\n}\n\nexport function Page({ page, rootDocument, metadata = true }: Props):
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/runtimes/react/components/page/Page.tsx"],"sourcesContent":["import { useMemo, ReactNode } from 'react'\n\nimport { DocumentRoot } from '../DocumentRoot'\nimport { type Document } from '../../../../state/react-page'\nimport { MakeswiftPageDocument } from '../../../../client'\nimport { usePageSnippets } from '../hooks/use-page-snippets'\n\nimport { BodySnippet } from './BodySnippet'\nimport { PageHead } from './PageHead'\nimport { flattenMetadataSettings, type PageMetadataSettings } from './page-seo-settings'\n\ntype Props = {\n page: MakeswiftPageDocument\n rootDocument: Document\n metadata?: boolean | PageMetadataSettings\n}\n\nexport function Page({ page, rootDocument, metadata = true }: Props): ReactNode {\n const { bodySnippets } = usePageSnippets({ page })\n const pageMetadataSettings = useMemo(() => flattenMetadataSettings(metadata), [metadata])\n\n return (\n <>\n <PageHead document={page} metadata={pageMetadataSettings} />\n\n <DocumentRoot rootDocument={rootDocument} />\n\n {bodySnippets.map(snippet => (\n <BodySnippet key={snippet.id} code={snippet.code} cleanup={snippet.cleanup} />\n ))}\n </>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAsBI;AAtBJ,mBAAmC;AAEnC,0BAA6B;AAG7B,+BAAgC;AAEhC,yBAA4B;AAC5B,sBAAyB;AACzB,+BAAmE;AAQ5D,SAAS,KAAK,EAAE,MAAM,cAAc,WAAW,KAAK,GAAqB;AAC9E,QAAM,EAAE,aAAa,QAAI,0CAAgB,EAAE,KAAK,CAAC;AACjD,QAAM,2BAAuB,sBAAQ,UAAM,kDAAwB,QAAQ,GAAG,CAAC,QAAQ,CAAC;AAExF,SACE,4EACE;AAAA,gDAAC,4BAAS,UAAU,MAAM,UAAU,sBAAsB;AAAA,IAE1D,4CAAC,oCAAa,cAA4B;AAAA,IAEzC,aAAa,IAAI,aAChB,4CAAC,kCAA6B,MAAM,QAAQ,MAAM,SAAS,QAAQ,WAAjD,QAAQ,EAAkD,CAC7E;AAAA,KACH;AAEJ;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/runtimes/react/components/page/PageHead.tsx"],"sourcesContent":["import { useMemo, useSyncExternalStore } from 'react'\n\nimport { type MakeswiftPageDocument } from '../../../../client'\nimport { type Site } from '../../../../api'\n\nimport { useMakeswiftHostApiClient } from '../../host-api-client'\n\nimport { useFrameworkContext } from '../hooks/use-framework-context'\nimport { useIsInBuilder } from '../../hooks/use-is-in-builder'\nimport { usePageSnippets } from '../hooks/use-page-snippets'\n\nimport { PageTitle, PageMeta, PageLink, PageStyle } from './head-tags'\nimport { type PageMetadataSettings } from './page-seo-settings'\n\nconst defaultFavicon = {\n id: 'default-favicon',\n mimetype: 'image/png',\n publicUrl:\n 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACIAAAAiCAYAAAA6RwvCAAAACXBIWXMAABcRAAAXEQHKJvM/AAABjElEQVRYhc2XzU3EMBCFB8TddAAXn6EE6GCpgNABZ1/IXnymBOgAOmA7YM8+ABVsXEHQQFaKQryeN3Yk3ilKJtEnv/nLUd/3pFG0riGi88yrnQn+UfJ5FUi0riWiB2H4nQn+KRd0DFP8agXEfkqCYJBoHdtxIQxfm+DfFgEhoith3NYE30o/qgGR2BJB+xY7kdYEL8oNFUi0jiFMJuxVWrJqEMFxsyUNCsE6AeNztvBp7aJ143vXksoRnwhYtmNdSoIQa6RlO9YXEWW7KgoCleOgxgTf1QZBT+RZ2lXFING6UxCCq+ceeUE8fYdknY599v9sJvzGBP+yCEgC7GPmETc0OJ+0awAlkhe2pAbIXAeFZ8xe2g2Nk3c3ub0xwWt6zY9qbmiqGVMbZK21ZC/YmhlbeBMTzZNDQqcvDb1kM1x32iqZSt1HaqukfKvq34BAOTLsrH+ETNmUkKHHA+428RgeclPVWozeSyAI2EdWB34jtqXNTAySOY3i/KgFIlqOa4GkFmBegorzg4joG07he/M7zl6jAAAAAElFTkSuQmCC',\n}\n\ntype Props = {\n document: MakeswiftPageDocument\n metadata?: PageMetadataSettings\n}\n\nexport function PageHead({ document: page, metadata = {} }: Props):
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/runtimes/react/components/page/PageHead.tsx"],"sourcesContent":["import { useMemo, useSyncExternalStore, ReactNode } from 'react'\n\nimport { type MakeswiftPageDocument } from '../../../../client'\nimport { type Site } from '../../../../api'\n\nimport { useMakeswiftHostApiClient } from '../../host-api-client'\n\nimport { useFrameworkContext } from '../hooks/use-framework-context'\nimport { useIsInBuilder } from '../../hooks/use-is-in-builder'\nimport { usePageSnippets } from '../hooks/use-page-snippets'\n\nimport { PageTitle, PageMeta, PageLink, PageStyle } from './head-tags'\nimport { type PageMetadataSettings } from './page-seo-settings'\n\nconst defaultFavicon = {\n id: 'default-favicon',\n mimetype: 'image/png',\n publicUrl:\n 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACIAAAAiCAYAAAA6RwvCAAAACXBIWXMAABcRAAAXEQHKJvM/AAABjElEQVRYhc2XzU3EMBCFB8TddAAXn6EE6GCpgNABZ1/IXnymBOgAOmA7YM8+ABVsXEHQQFaKQryeN3Yk3ilKJtEnv/nLUd/3pFG0riGi88yrnQn+UfJ5FUi0riWiB2H4nQn+KRd0DFP8agXEfkqCYJBoHdtxIQxfm+DfFgEhoith3NYE30o/qgGR2BJB+xY7kdYEL8oNFUi0jiFMJuxVWrJqEMFxsyUNCsE6AeNztvBp7aJ143vXksoRnwhYtmNdSoIQa6RlO9YXEWW7KgoCleOgxgTf1QZBT+RZ2lXFING6UxCCq+ceeUE8fYdknY599v9sJvzGBP+yCEgC7GPmETc0OJ+0awAlkhe2pAbIXAeFZ8xe2g2Nk3c3ub0xwWt6zY9qbmiqGVMbZK21ZC/YmhlbeBMTzZNDQqcvDb1kM1x32iqZSt1HaqukfKvq34BAOTLsrH+ETNmUkKHHA+428RgeclPVWozeSyAI2EdWB34jtqXNTAySOY3i/KgFIlqOa4GkFmBegorzg4joG07he/M7zl6jAAAAAElFTkSuQmCC',\n}\n\ntype Props = {\n document: MakeswiftPageDocument\n metadata?: PageMetadataSettings\n}\n\nexport function PageHead({ document: page, metadata = {} }: Props): ReactNode {\n const {\n title: useTitle = false,\n favicon: useFavicon = false,\n canonicalUrl: useCanonicalUrl = false,\n indexingBlocked: useIndexingBlocked = false,\n description: useDescription = false,\n keywords: useKeywords = false,\n socialImage: useSocialImage = false,\n } = metadata\n\n const { headSnippets } = usePageSnippets({ page })\n const { HeadSnippet } = useFrameworkContext()\n\n const isInBuilder = useIsInBuilder()\n\n const site = useCachedSite(isInBuilder ? page.site.id : null)\n const baseLocalizedPage = page.localizedPages.find(({ parentId }) => parentId == null)\n\n const favicon = page.meta.favicon ?? defaultFavicon\n const title = baseLocalizedPage?.meta.title ?? page.meta.title\n const description = baseLocalizedPage?.meta.description ?? page.meta.description\n const keywords = baseLocalizedPage?.meta.keywords ?? page.meta.keywords\n const socialImage = baseLocalizedPage?.meta.socialImage ?? page.meta.socialImage\n const canonicalUrl = baseLocalizedPage?.seo.canonicalUrl ?? page.seo.canonicalUrl\n const isIndexingBlocked = baseLocalizedPage?.seo.isIndexingBlocked ?? page.seo.isIndexingBlocked\n\n const fontFamilyParamValue = useMemo(() => {\n if (site == null) {\n return page.fonts\n .map(({ family, variants }) => {\n return `${family.replace(/ /g, '+')}:${variants.join()}`\n })\n .join('|')\n }\n\n return site.googleFonts.edges\n .filter((edge): edge is NonNullable<typeof edge> => edge != null)\n .map(({ activeVariants, node: { family, variants } }) => {\n const activeVariantSpecifiers = variants\n .filter(variant =>\n activeVariants.some(activeVariant => activeVariant.specifier === variant.specifier),\n )\n .map(variant => variant.specifier)\n .join()\n\n return `${family.replace(/ /g, '+')}:${activeVariantSpecifiers}`\n })\n .join('|')\n }, [site, page])\n\n return (\n <>\n <PageStyle precedence=\"high\" href=\"makeswift-base-styles\">\n {`\n html {\n font-family: sans-serif;\n }\n div#__next {\n overflow: hidden;\n }\n `}\n </PageStyle>\n {useTitle && title && (\n <>\n <PageTitle>{title}</PageTitle>\n <PageMeta property=\"og:title\" content={title} />\n <PageMeta name=\"twitter:title\" content={title} />\n </>\n )}\n {useFavicon && favicon && (\n <PageLink rel=\"icon\" type={favicon.mimetype} href={favicon.publicUrl} />\n )}\n {useCanonicalUrl && canonicalUrl && <PageLink rel=\"canonical\" href={canonicalUrl} />}\n {useIndexingBlocked && isIndexingBlocked && <PageMeta name=\"robots\" content=\"noindex\" />}\n {useDescription && description && (\n <>\n <PageMeta name=\"description\" content={description} />\n <PageMeta property=\"og:description\" content={description} />\n <PageMeta name=\"twitter:description\" content={description} />\n </>\n )}\n {useKeywords && keywords && <PageMeta name=\"keywords\" content={keywords} />}\n {useSocialImage && socialImage && (\n <>\n <PageMeta property=\"og:image\" content={socialImage.publicUrl} />\n <PageMeta property=\"og:image:type\" content={socialImage.mimetype} />\n <PageMeta name=\"twitter:image\" content={socialImage.publicUrl} />\n <PageMeta name=\"twitter:card\" content=\"summary_large_image\" />\n </>\n )}\n {fontFamilyParamValue !== '' && (\n <PageLink\n precedence=\"medium\"\n rel=\"stylesheet\"\n href={`https://fonts.googleapis.com/css?family=${fontFamilyParamValue}&display=swap`}\n />\n )}\n {headSnippets.map(snippet => (\n <HeadSnippet key={snippet.id} snippet={snippet} />\n ))}\n </>\n )\n}\n\nfunction useCachedSite(siteId: string | null): Site | null {\n const client = useMakeswiftHostApiClient()\n const getSnapshot = () => (siteId == null ? null : client.readSite(siteId))\n\n const site = useSyncExternalStore(client.subscribe, getSnapshot, getSnapshot)\n\n return site\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA+EM;AA/EN,mBAAyD;AAKzD,6BAA0C;AAE1C,mCAAoC;AACpC,+BAA+B;AAC/B,+BAAgC;AAEhC,uBAAyD;AAGzD,MAAM,iBAAiB;AAAA,EACrB,IAAI;AAAA,EACJ,UAAU;AAAA,EACV,WACE;AACJ;AAOO,SAAS,SAAS,EAAE,UAAU,MAAM,WAAW,CAAC,EAAE,GAAqB;AAC5E,QAAM;AAAA,IACJ,OAAO,WAAW;AAAA,IAClB,SAAS,aAAa;AAAA,IACtB,cAAc,kBAAkB;AAAA,IAChC,iBAAiB,qBAAqB;AAAA,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AI;AAAA,QACJ,MAAM,2CAA2C,oBAAoB;AAAA;AAAA,IACvE;AAAA,IAED,aAAa,IAAI,aAChB,4CAAC,eAA6B,WAAZ,QAAQ,EAAsB,CACjD;AAAA,KACH;AAEJ;AAEA,SAAS,cAAc,QAAoC;AACzD,QAAM,aAAS,kDAA0B;AACzC,QAAM,cAAc,MAAO,UAAU,OAAO,OAAO,OAAO,SAAS,MAAM;AAEzE,QAAM,WAAO,mCAAqB,OAAO,WAAW,aAAa,WAAW;AAE5E,SAAO;AACT;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/runtimes/react/components/page/head-tags.tsx"],"sourcesContent":["import { type ComponentPropsWithoutRef } from 'react'\n\nimport { useFrameworkContext } from '../hooks/use-framework-context'\n\ntype PageTitleProps = Omit<ComponentPropsWithoutRef<'title'>, 'children'> & {\n children?: string\n}\n\nexport function PageTitle({ children, ...props }: PageTitleProps) {\n const { Head } = useFrameworkContext()\n return (\n <Head>\n <title {...props}>{children}</title>\n </Head>\n )\n}\n\nexport function PageMeta(props: ComponentPropsWithoutRef<'meta'>) {\n const { Head } = useFrameworkContext()\n return (\n <Head>\n <meta {...props} />\n </Head>\n )\n}\n\ntype ReactCanaryLinkProps = {\n precedence?: 'reset' | 'low' | 'medium' | 'high'\n}\ntype PageLinkProps = ComponentPropsWithoutRef<'link'> & ReactCanaryLinkProps\n\nexport function PageLink({ precedence, ...props }: PageLinkProps) {\n const { Head } = useFrameworkContext()\n return (\n <Head>\n
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/runtimes/react/components/page/head-tags.tsx"],"sourcesContent":["import { type ComponentPropsWithoutRef } from 'react'\n\nimport { useFrameworkContext } from '../hooks/use-framework-context'\n\ntype PageTitleProps = Omit<ComponentPropsWithoutRef<'title'>, 'children'> & {\n children?: string\n}\n\nexport function PageTitle({ children, ...props }: PageTitleProps) {\n const { Head } = useFrameworkContext()\n return (\n <Head>\n <title {...props}>{children}</title>\n </Head>\n )\n}\n\nexport function PageMeta(props: ComponentPropsWithoutRef<'meta'>) {\n const { Head } = useFrameworkContext()\n return (\n <Head>\n <meta {...props} />\n </Head>\n )\n}\n\ntype ReactCanaryLinkProps = {\n precedence?: 'reset' | 'low' | 'medium' | 'high'\n}\ntype PageLinkProps = ComponentPropsWithoutRef<'link'> & ReactCanaryLinkProps\n\nexport function PageLink({ precedence, ...props }: PageLinkProps) {\n const { Head } = useFrameworkContext()\n return (\n <Head>\n <link {...props} precedence={precedence} />\n </Head>\n )\n}\n\ntype ReactCanaryStyleProps = {\n precedence?: 'reset' | 'low' | 'medium' | 'high'\n href?: string\n}\ntype PageStyleProps = ComponentPropsWithoutRef<'style'> & ReactCanaryStyleProps\n\nexport function PageStyle({ children, precedence, href, ...props }: PageStyleProps) {\n const { Head } = useFrameworkContext()\n return (\n <Head>\n <style {...props} precedence={precedence} href={href}>\n {children}\n </style>\n </Head>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYM;AAVN,mCAAoC;AAM7B,SAAS,UAAU,EAAE,UAAU,GAAG,MAAM,GAAmB;AAChE,QAAM,EAAE,KAAK,QAAI,kDAAoB;AACrC,SACE,4CAAC,QACC,sDAAC,WAAO,GAAG,OAAQ,UAAS,GAC9B;AAEJ;AAEO,SAAS,SAAS,OAAyC;AAChE,QAAM,EAAE,KAAK,QAAI,kDAAoB;AACrC,SACE,4CAAC,QACC,sDAAC,UAAM,GAAG,OAAO,GACnB;AAEJ;AAOO,SAAS,SAAS,EAAE,YAAY,GAAG,MAAM,GAAkB;AAChE,QAAM,EAAE,KAAK,QAAI,kDAAoB;AACrC,SACE,4CAAC,QACC,sDAAC,UAAM,GAAG,OAAO,YAAwB,GAC3C;AAEJ;AAQO,SAAS,UAAU,EAAE,UAAU,YAAY,MAAM,GAAG,MAAM,GAAmB;AAClF,QAAM,EAAE,KAAK,QAAI,kDAAoB;AACrC,SACE,4CAAC,QACC,sDAAC,WAAO,GAAG,OAAO,YAAwB,MACvC,UACH,GACF;AAEJ;","names":[]}
|
|
@@ -27,6 +27,7 @@ var import_use_cache_data = require("../../hooks/use-cache-data");
|
|
|
27
27
|
var import_client = require("../../../../client");
|
|
28
28
|
var import_Page = require("./Page");
|
|
29
29
|
var import_use_register_document = require("../../hooks/use-register-document");
|
|
30
|
+
var import_activity_with_fallback = require("../activity-with-fallback");
|
|
30
31
|
const Page = (0, import_react.memo)(
|
|
31
32
|
({
|
|
32
33
|
snapshot,
|
|
@@ -35,7 +36,7 @@ const Page = (0, import_react.memo)(
|
|
|
35
36
|
(0, import_use_cache_data.useCacheData)(snapshot.cacheData);
|
|
36
37
|
const rootDocument = (0, import_react.useMemo)(() => (0, import_client.pageToRootDocument)(snapshot.document), [snapshot.document]);
|
|
37
38
|
(0, import_use_register_document.useRegisterDocument)(rootDocument);
|
|
38
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
39
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_activity_with_fallback.ActivityOrFallback, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
39
40
|
import_Page.Page,
|
|
40
41
|
{
|
|
41
42
|
page: snapshot.document,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/runtimes/react/components/page/index.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/runtimes/react/components/page/index.tsx"],"sourcesContent":["import { useMemo, memo, type ComponentProps } from 'react'\n\nimport { useCacheData } from '../../hooks/use-cache-data'\n\nimport { type MakeswiftPageSnapshot, pageToRootDocument } from '../../../../client'\n\nimport { type PageMetadataSettings } from './page-seo-settings'\nimport { Page as PageComponent } from './Page'\nimport { useRegisterDocument } from '../../hooks/use-register-document'\nimport { ActivityOrFallback } from '../activity-with-fallback'\n\nexport { type PageMetadataSettings } from './page-seo-settings'\n\n/**\n * @param snapshot - The snapshot of the page to render, from\n * `client.getPageSnapshot()`.\n * @param metadata - Allows control over whether to use data from Makeswift for\n * rendering metadata tags in the `<head>` of the page. Pass `true` (default if\n * not provided) to render all metadata tags, or `false` to not render any. For\n * more granular control, pass an object with boolean values for specific\n * metadata fields. Valid fields include:\n * - `title`\n * - `description`\n * - `keywords`\n * - `socialImage`\n * - `canonicalUrl`\n * - `indexingBlocked`\n * - `favicon`\n *\n * If a field is not provided, it will default to `false`.\n */\nexport const Page = memo(\n ({\n snapshot,\n metadata = true,\n }: {\n snapshot: MakeswiftPageSnapshot\n metadata?: boolean | PageMetadataSettings\n }) => {\n useCacheData(snapshot.cacheData)\n\n const rootDocument = useMemo(() => pageToRootDocument(snapshot.document), [snapshot.document])\n useRegisterDocument(rootDocument)\n\n return (\n <ActivityOrFallback>\n {/* We use a key here to reset the Snippets state in the PageMeta component */}\n <PageComponent\n key={snapshot.document.data.key}\n page={snapshot.document}\n rootDocument={rootDocument}\n metadata={metadata}\n />\n </ActivityOrFallback>\n )\n },\n)\n\nexport type PageProps = ComponentProps<typeof Page>\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA+CQ;AA/CR,mBAAmD;AAEnD,4BAA6B;AAE7B,oBAA+D;AAG/D,kBAAsC;AACtC,mCAAoC;AACpC,oCAAmC;AAsB5B,MAAM,WAAO;AAAA,EAClB,CAAC;AAAA,IACC;AAAA,IACA,WAAW;AAAA,EACb,MAGM;AACJ,4CAAa,SAAS,SAAS;AAE/B,UAAM,mBAAe,sBAAQ,UAAM,kCAAmB,SAAS,QAAQ,GAAG,CAAC,SAAS,QAAQ,CAAC;AAC7F,0DAAoB,YAAY;AAEhC,WACE,4CAAC,oDAEC;AAAA,MAAC,YAAAA;AAAA,MAAA;AAAA,QAEC,MAAM,SAAS;AAAA,QACf;AAAA,QACA;AAAA;AAAA,MAHK,SAAS,SAAS,KAAK;AAAA,IAI9B,GACF;AAAA,EAEJ;AACF;","names":["PageComponent"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/runtimes/react/components/render-hook.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/components/render-hook.ts"],"sourcesContent":["import { ReactNode } from 'react'\n\ntype Props<H extends (...args: any[]) => any> = {\n /**\n * `<RenderHook>` requires key that changes whenever the `hook` prop changes to ensure the rules of\n * hooks are followed.\n */\n key: string\n\n hook: H\n parameters: Parameters<H>\n children(result: ReturnType<H>): ReactNode\n}\n\nexport function RenderHook<H extends (...args: any[]) => any>({\n hook: useHook,\n parameters,\n children,\n}: Props<H>) {\n return children(useHook(...parameters))\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAcO,SAAS,WAA8C;AAAA,EAC5D,MAAM;AAAA,EACN;AAAA,EACA;AACF,GAAa;AACX,SAAO,SAAS,QAAQ,GAAG,UAAU,CAAC;AACxC;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/runtimes/react/controls/control.tsx"],"sourcesContent":["'use client'\n\nimport {\n ControlDefinition,\n type InstanceType,\n type DataType,\n type ResolvedValueType,\n} from '@makeswift/controls'\n\nimport { useResolvedValue } from '../hooks/use-resolved-value'\nimport { useStylesheetFactory } from '../hooks/use-stylesheet-factory'\nimport { useCssId } from '../hooks/use-css-id'\n\ntype ControlValueProps = {\n definition: ControlDefinition\n data: DataType<ControlDefinition> | undefined\n children(value: ResolvedValueType<ControlDefinition>):
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/controls/control.tsx"],"sourcesContent":["'use client'\n\nimport {\n ControlDefinition,\n type InstanceType,\n type DataType,\n type ResolvedValueType,\n} from '@makeswift/controls'\nimport { ReactNode } from 'react'\n\nimport { useResolvedValue } from '../hooks/use-resolved-value'\nimport { useStylesheetFactory } from '../hooks/use-stylesheet-factory'\nimport { useCssId } from '../hooks/use-css-id'\n\ntype ControlValueProps = {\n definition: ControlDefinition\n data: DataType<ControlDefinition> | undefined\n children(value: ResolvedValueType<ControlDefinition>): ReactNode\n control?: InstanceType<ControlDefinition>\n}\n\nexport function ControlValue({\n data,\n definition,\n children,\n control,\n}: ControlValueProps): ReactNode {\n const stylesheetFactory = useStylesheetFactory()\n const id = `cv-${useCssId()}`\n\n const value = useResolvedValue(\n data,\n (data, resourceResolver) =>\n definition.resolveValue(data, resourceResolver, stylesheetFactory.get(id), control),\n (definition.config as any)?.defaultValue,\n )\n\n stylesheetFactory.useDefinedStyles()\n\n return children(value)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,gCAAiC;AACjC,oCAAqC;AACrC,wBAAyB;AASlB,SAAS,aAAa;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAiC;AAC/B,QAAM,wBAAoB,oDAAqB;AAC/C,QAAM,KAAK,UAAM,4BAAS,CAAC;AAE3B,QAAM,YAAQ;AAAA,IACZ;AAAA,IACA,CAACA,OAAM,qBACL,WAAW,aAAaA,OAAM,kBAAkB,kBAAkB,IAAI,EAAE,GAAG,OAAO;AAAA,IACnF,WAAW,QAAgB;AAAA,EAC9B;AAEA,oBAAkB,iBAAiB;AAEnC,SAAO,SAAS,KAAK;AACvB;","names":["data"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/runtimes/react/controls/group.tsx"],"sourcesContent":["import {\n GroupControl,\n GroupDefinition,\n type DataType,\n type ResolvedValueType,\n} from '@makeswift/controls'\n\nimport { ControlValue } from './control'\n\ntype GroupControlValueProps = {\n definition: GroupDefinition\n data: DataType<GroupDefinition> | undefined\n children(value: ResolvedValueType<GroupDefinition>):
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/controls/group.tsx"],"sourcesContent":["import { ReactNode } from 'react'\nimport {\n GroupControl,\n GroupDefinition,\n type DataType,\n type ResolvedValueType,\n} from '@makeswift/controls'\n\nimport { ControlValue } from './control'\n\ntype GroupControlValueProps = {\n definition: GroupDefinition\n data: DataType<GroupDefinition> | undefined\n children(value: ResolvedValueType<GroupDefinition>): ReactNode\n control: GroupControl\n}\n\nexport function GroupControlValue({ definition, data, children, control }: GroupControlValueProps) {\n return Object.entries(definition.config.props).reduceRight(\n (renderFn, [key, controlDefinition]) =>\n shapeControlValue => (\n <ControlValue\n definition={controlDefinition}\n data={data != null ? GroupDefinition.propsData(data)[key] : undefined}\n control={control?.child(key)}\n >\n {value => renderFn({ ...shapeControlValue, [key]: value })}\n </ControlValue>\n ),\n children,\n )({} as ResolvedValueType<GroupDefinition>)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAqBQ;AApBR,sBAKO;AAEP,qBAA6B;AAStB,SAAS,kBAAkB,EAAE,YAAY,MAAM,UAAU,QAAQ,GAA2B;AACjG,SAAO,OAAO,QAAQ,WAAW,OAAO,KAAK,EAAE;AAAA,IAC7C,CAAC,UAAU,CAAC,KAAK,iBAAiB,MAChC,uBACE;AAAA,MAAC;AAAA;AAAA,QACC,YAAY;AAAA,QACZ,MAAM,QAAQ,OAAO,gCAAgB,UAAU,IAAI,EAAE,GAAG,IAAI;AAAA,QAC5D,SAAS,SAAS,MAAM,GAAG;AAAA,QAE1B,qBAAS,SAAS,EAAE,GAAG,mBAAmB,CAAC,GAAG,GAAG,MAAM,CAAC;AAAA;AAAA,IAC3D;AAAA,IAEJ;AAAA,EACF,EAAE,CAAC,CAAuC;AAC5C;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-leaf.tsx"],"sourcesContent":["import { RenderLeafProps } from 'slate-react'\nimport { RichTextV2Definition } from '../../../../../controls/rich-text-v2'\nimport { RichTextV2Plugin } from '../../../../../controls/rich-text-v2/plugin'\nimport { ControlValue } from '../../control'\n\ntype RichTextV2LeafProps = RenderLeafProps & {\n definition: RichTextV2Definition\n plugins: RichTextV2Plugin[]\n}\n\nexport function RichTextV2Leaf({ definition, plugins, ...props }: RichTextV2LeafProps) {\n function initialRenderLeaf({ attributes, children, leaf }: RenderLeafProps) {\n return (\n <span className={leaf.className} {...attributes}>\n {children}\n </span>\n )\n }\n\n const renderLeaf = plugins.reduce(\n (renderFn, plugin) => (props: RenderLeafProps) => {\n const { control, renderLeaf } = plugin\n\n if (control?.definition == null || renderLeaf == null) return renderFn(props)\n\n if (control.getLeafValue == null) return renderLeaf(renderFn, undefined)(props)\n\n return (\n <ControlValue definition={control.definition} data={control.getLeafValue(props.leaf)}>\n {value => renderLeaf(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderLeaf,\n )\n\n return renderLeaf(props)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/runtimes/react/controls/rich-text-v2/EditableTextV2/render-leaf.tsx"],"sourcesContent":["import { ReactNode } from 'react'\nimport { RenderLeafProps } from 'slate-react'\nimport { RichTextV2Definition } from '../../../../../controls/rich-text-v2'\nimport { RichTextV2Plugin } from '../../../../../controls/rich-text-v2/plugin'\nimport { ControlValue } from '../../control'\n\ntype RichTextV2LeafProps = RenderLeafProps & {\n definition: RichTextV2Definition\n plugins: RichTextV2Plugin[]\n}\n\nexport function RichTextV2Leaf({ definition, plugins, ...props }: RichTextV2LeafProps) {\n function initialRenderLeaf({ attributes, children, leaf }: RenderLeafProps): ReactNode {\n return (\n <span className={leaf.className} {...attributes}>\n {children}\n </span>\n )\n }\n\n const renderLeaf = plugins.reduce(\n (renderFn, plugin) => (props: RenderLeafProps) => {\n const { control, renderLeaf } = plugin\n\n if (control?.definition == null || renderLeaf == null) return renderFn(props)\n\n if (control.getLeafValue == null) return renderLeaf(renderFn, undefined)(props)\n\n return (\n <ControlValue definition={control.definition} data={control.getLeafValue(props.leaf)}>\n {value => renderLeaf(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderLeaf,\n )\n\n return renderLeaf(props)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAcM;AAVN,qBAA6B;AAOtB,SAAS,eAAe,EAAE,YAAY,SAAS,GAAG,MAAM,GAAwB;AACrF,WAAS,kBAAkB,EAAE,YAAY,UAAU,KAAK,GAA+B;AACrF,WACE,4CAAC,UAAK,WAAW,KAAK,WAAY,GAAG,YAClC,UACH;AAAA,EAEJ;AAEA,QAAM,aAAa,QAAQ;AAAA,IACzB,CAAC,UAAU,WAAW,CAACA,WAA2B;AAChD,YAAM,EAAE,SAAS,YAAAC,YAAW,IAAI;AAEhC,UAAI,SAAS,cAAc,QAAQA,eAAc;AAAM,eAAO,SAASD,MAAK;AAE5E,UAAI,QAAQ,gBAAgB;AAAM,eAAOC,YAAW,UAAU,MAAS,EAAED,MAAK;AAE9E,aACE,4CAAC,+BAAa,YAAY,QAAQ,YAAY,MAAM,QAAQ,aAAaA,OAAM,IAAI,GAChF,qBAASC,YAAW,UAAU,KAAK,EAAED,MAAK,GAC7C;AAAA,IAEJ;AAAA,IACA;AAAA,EACF;AAEA,SAAO,WAAW,KAAK;AACzB;","names":["props","renderLeaf"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.tsx"],"sourcesContent":["import { ForwardedRef, forwardRef } from 'react'\nimport { Descendant, Element, Text } from 'slate'\nimport { RenderElementProps, RenderLeafProps } from 'slate-react'\n\nimport { RichTextV2Definition, RichText } from '../../../../controls/rich-text-v2'\nimport { useStyle } from '../../use-style'\nimport { toText } from '../../../../slate/utils'\nimport { RichTextV2Plugin } from '../../../../controls/rich-text-v2/plugin'\nimport { RichTextDataV2 } from '../../../../controls/rich-text-v2'\n\nimport { ControlValue } from '../control'\n\ntype Props = {\n text: RichTextDataV2 | undefined\n definition: RichTextV2Definition | undefined\n}\n\nconst ReadOnlyTextV2 = forwardRef(function ReadOnlyText(\n { text, definition }: Props,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const descendantsAsString = toText(\n text?.descendants ?? [],\n definition?.config.mode ?? RichText.Mode.Block,\n )\n\n return (\n <div\n ref={ref}\n style={{\n /**\n * These are the default styles that Slate uses for its editable div.\n * https://github.com/ianstormtaylor/slate/blob/4bd15ed3950e3a0871f5d0ecb391bb637c05e59d/packages/slate-react/src/components/editable.tsx\n * Search for `disableDefaultStyles`\n */\n position: 'relative',\n whiteSpace: 'pre-wrap',\n wordWrap: 'break-word',\n }}\n >\n {descendantsAsString === '' ? (\n <Placeholder />\n ) : (\n <Descendants\n plugins={definition?.config.plugins ?? []}\n descendants={text?.descendants ?? []}\n />\n )}\n </div>\n )\n})\n\nexport default ReadOnlyTextV2\n\nfunction Placeholder({ text = 'Write some text...' }: { text?: string }) {\n return (\n <span\n className={useStyle({\n display: 'inline-block',\n width: 0,\n maxWidth: '100%',\n whiteSpace: 'nowrap',\n opacity: 0.333,\n verticalAlign: 'text-top',\n })}\n >\n {text}\n </span>\n )\n}\n\ntype LeafProps = {\n leaf: Text\n plugins: RichTextV2Plugin[]\n}\n\nexport function LeafComponent({ plugins, ...props }: LeafProps) {\n function initialRenderLeaf({ leaf }: RenderLeafProps) {\n return <span className={leaf.className}>{leaf.text === '' ? '\\uFEFF' : leaf.text}</span>\n }\n\n const renderLeaf = plugins.reduce(\n (renderFn, plugin) => (props: RenderLeafProps) => {\n const { control, renderLeaf } = plugin\n\n if (control?.definition == null || renderLeaf == null) return renderFn(props)\n\n if (control.getLeafValue == null) return renderLeaf(renderFn, undefined)(props)\n\n return (\n <ControlValue definition={control.definition} data={control.getLeafValue(props.leaf)}>\n {value => renderLeaf(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderLeaf,\n )\n\n return renderLeaf({ attributes: {} as any, leaf: props.leaf, children: null, text: props.leaf })\n}\n\ntype ElementProps = {\n descendant: Element\n plugins: RichTextV2Plugin[]\n}\n\nfunction ElementComponent({ plugins, ...props }: ElementProps) {\n function initialRenderElement(props: RenderElementProps) {\n return <Descendants descendants={props.element.children} plugins={plugins} />\n }\n\n const renderElement = plugins.reduce(\n (renderFn, plugin) => (props: RenderElementProps) => {\n const { control, renderElement } = plugin\n\n if (control?.definition == null || renderElement == null) return renderFn(props)\n\n if (control.getElementValue == null) return renderElement(renderFn, undefined)(props)\n\n return (\n <ControlValue definition={control.definition} data={control.getElementValue(props.element)}>\n {value => renderElement(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderElement,\n )\n\n return renderElement({ attributes: {} as any, children: null, element: props.descendant })\n}\n\n// reimplemented from slate source for code splitting\nfunction isText(node: Descendant): node is Text {\n if (typeof node === 'object' && 'text' in node) return true\n\n return false\n}\n\nfunction Descendants({\n descendants,\n plugins,\n}: {\n plugins: RichTextV2Plugin[]\n descendants: Descendant[]\n}) {\n return (\n <>\n {descendants.map((descendant, index) => {\n if (isText(descendant)) {\n return <LeafComponent key={index} plugins={plugins} leaf={descendant} />\n }\n\n return <ElementComponent key={index} descendant={descendant} plugins={plugins} />\n })}\n </>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyCQ;AAzCR,
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.tsx"],"sourcesContent":["import { ForwardedRef, forwardRef, ReactNode } from 'react'\nimport { Descendant, Element, Text } from 'slate'\nimport { RenderElementProps, RenderLeafProps } from 'slate-react'\n\nimport { RichTextV2Definition, RichText } from '../../../../controls/rich-text-v2'\nimport { useStyle } from '../../use-style'\nimport { toText } from '../../../../slate/utils'\nimport { RichTextV2Plugin } from '../../../../controls/rich-text-v2/plugin'\nimport { RichTextDataV2 } from '../../../../controls/rich-text-v2'\n\nimport { ControlValue } from '../control'\n\ntype Props = {\n text: RichTextDataV2 | undefined\n definition: RichTextV2Definition | undefined\n}\n\nconst ReadOnlyTextV2 = forwardRef(function ReadOnlyText(\n { text, definition }: Props,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const descendantsAsString = toText(\n text?.descendants ?? [],\n definition?.config.mode ?? RichText.Mode.Block,\n )\n\n return (\n <div\n ref={ref}\n style={{\n /**\n * These are the default styles that Slate uses for its editable div.\n * https://github.com/ianstormtaylor/slate/blob/4bd15ed3950e3a0871f5d0ecb391bb637c05e59d/packages/slate-react/src/components/editable.tsx\n * Search for `disableDefaultStyles`\n */\n position: 'relative',\n whiteSpace: 'pre-wrap',\n wordWrap: 'break-word',\n }}\n >\n {descendantsAsString === '' ? (\n <Placeholder />\n ) : (\n <Descendants\n plugins={definition?.config.plugins ?? []}\n descendants={text?.descendants ?? []}\n />\n )}\n </div>\n )\n})\n\nexport default ReadOnlyTextV2\n\nfunction Placeholder({ text = 'Write some text...' }: { text?: string }) {\n return (\n <span\n className={useStyle({\n display: 'inline-block',\n width: 0,\n maxWidth: '100%',\n whiteSpace: 'nowrap',\n opacity: 0.333,\n verticalAlign: 'text-top',\n })}\n >\n {text}\n </span>\n )\n}\n\ntype LeafProps = {\n leaf: Text\n plugins: RichTextV2Plugin[]\n}\n\nexport function LeafComponent({ plugins, ...props }: LeafProps) {\n function initialRenderLeaf({ leaf }: RenderLeafProps): ReactNode {\n return <span className={leaf.className}>{leaf.text === '' ? '\\uFEFF' : leaf.text}</span>\n }\n\n const renderLeaf = plugins.reduce(\n (renderFn, plugin) => (props: RenderLeafProps) => {\n const { control, renderLeaf } = plugin\n\n if (control?.definition == null || renderLeaf == null) return renderFn(props)\n\n if (control.getLeafValue == null) return renderLeaf(renderFn, undefined)(props)\n\n return (\n <ControlValue definition={control.definition} data={control.getLeafValue(props.leaf)}>\n {value => renderLeaf(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderLeaf,\n )\n\n return renderLeaf({ attributes: {} as any, leaf: props.leaf, children: null, text: props.leaf })\n}\n\ntype ElementProps = {\n descendant: Element\n plugins: RichTextV2Plugin[]\n}\n\nfunction ElementComponent({ plugins, ...props }: ElementProps) {\n function initialRenderElement(props: RenderElementProps): ReactNode {\n return <Descendants descendants={props.element.children} plugins={plugins} />\n }\n\n const renderElement = plugins.reduce(\n (renderFn, plugin) => (props: RenderElementProps) => {\n const { control, renderElement } = plugin\n\n if (control?.definition == null || renderElement == null) return renderFn(props)\n\n if (control.getElementValue == null) return renderElement(renderFn, undefined)(props)\n\n return (\n <ControlValue definition={control.definition} data={control.getElementValue(props.element)}>\n {value => renderElement(renderFn, value)(props)}\n </ControlValue>\n )\n },\n initialRenderElement,\n )\n\n return renderElement({ attributes: {} as any, children: null, element: props.descendant })\n}\n\n// reimplemented from slate source for code splitting\nfunction isText(node: Descendant): node is Text {\n if (typeof node === 'object' && 'text' in node) return true\n\n return false\n}\n\nfunction Descendants({\n descendants,\n plugins,\n}: {\n plugins: RichTextV2Plugin[]\n descendants: Descendant[]\n}) {\n return (\n <>\n {descendants.map((descendant, index) => {\n if (isText(descendant)) {\n return <LeafComponent key={index} plugins={plugins} leaf={descendant} />\n }\n\n return <ElementComponent key={index} descendant={descendant} plugins={plugins} />\n })}\n </>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyCQ;AAzCR,mBAAoD;AAIpD,0BAA+C;AAC/C,uBAAyB;AACzB,mBAAuB;AAIvB,qBAA6B;AAO7B,MAAM,qBAAiB,yBAAW,SAAS,aACzC,EAAE,MAAM,WAAW,GACnB,KACA;AACA,QAAM,0BAAsB;AAAA,IAC1B,MAAM,eAAe,CAAC;AAAA,IACtB,YAAY,OAAO,QAAQ,6BAAS,KAAK;AAAA,EAC3C;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAML,UAAU;AAAA,QACV,YAAY;AAAA,QACZ,UAAU;A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AAS,qBAAqBA,QAAsC;AAClE,WAAO,4CAAC,eAAY,aAAaA,OAAM,QAAQ,UAAU,SAAkB;AAAA,EAC7E;AAEA,QAAM,gBAAgB,QAAQ;AAAA,IAC5B,CAAC,UAAU,WAAW,CAACA,WAA8B;AACnD,YAAM,EAAE,SAAS,eAAAE,eAAc,IAAI;AAEnC,UAAI,SAAS,cAAc,QAAQA,kBAAiB;AAAM,eAAO,SAASF,MAAK;AAE/E,UAAI,QAAQ,mBAAmB;AAAM,eAAOE,eAAc,UAAU,MAAS,EAAEF,MAAK;AAEpF,aACE,4CAAC,+BAAa,YAAY,QAAQ,YAAY,MAAM,QAAQ,gBAAgBA,OAAM,OAAO,GACtF,qBAASE,eAAc,UAAU,KAAK,EAAEF,MAAK,GAChD;AAAA,IAEJ;AAAA,IACA;AAAA,EACF;AAEA,SAAO,cAAc,EAAE,YAAY,CAAC,GAAU,UAAU,MAAM,SAAS,MAAM,WAAW,CAAC;AAC3F;AAGA,SAAS,OAAO,MAAgC;AAC9C,MAAI,OAAO,SAAS,YAAY,UAAU;AAAM,WAAO;AAEvD,SAAO;AACT;AAEA,SAAS,YAAY;AAAA,EACnB;AAAA,EACA;AACF,GAGG;AACD,SACE,2EACG,sBAAY,IAAI,CAAC,YAAY,UAAU;AACtC,QAAI,OAAO,UAAU,GAAG;AACtB,aAAO,4CAAC,iBAA0B,SAAkB,MAAM,cAA/B,KAA2C;AAAA,IACxE;AAEA,WAAO,4CAAC,oBAA6B,YAAwB,WAA/B,KAAiD;AAAA,EACjF,CAAC,GACH;AAEJ;","names":["props","renderLeaf","renderElement"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/runtimes/react/controls/slot.tsx"],"sourcesContent":["'use client'\n\nimport { ComponentPropsWithoutRef, ElementType, ReactNode, useEffect, useState, memo } from 'react'\nimport { cx } from '@emotion/css'\n\nimport { SlotDefinition, SlotControl, type DataType } from '@makeswift/controls'\n\nimport { Element } from '../components/Element'\nimport { getIndexes } from '../../../components/utils/columns'\nimport { useResponsiveStyle } from '../../../components/utils/responsive-style'\nimport { useStyle } from '../use-style'\nimport { pollBoxModel } from '../poll-box-model'\n\nexport function renderSlot(props: {\n data: DataType<SlotDefinition<ReactNode>> | undefined\n control: SlotControl | null\n}): ReactNode {\n return <SlotValue {...props} />\n}\n\nconst SlotValue = memo(\n ({\n data,\n control,\n }: {\n data: DataType<SlotDefinition<ReactNode>> | undefined\n control: SlotControl | null\n }): ReactNode => {\n // TODO(miguel): While the UI shouldn't allow the state, we should probably check that at least\n // one element is visible.\n if (data == null || data.elements.length === 0) {\n return <Slot.Placeholder control={control} />\n }\n\n return (\n <Slot control={control}>\n {data.elements.map((element, i) => (\n <Slot.Item key={element.key} control={control} grid={data.columns} index={i}>\n <Element element={element} />\n </Slot.Item>\n ))}\n </Slot>\n )\n },\n)\n\ntype SlotProps<T extends ElementType> = {\n as?: T\n control: SlotControl | null\n children?: ReactNode\n className?: string\n}\n\nexport function Slot<T extends ElementType = 'div'>({\n as,\n control,\n children,\n className,\n ...restOfProps\n}: SlotProps<T> & Omit<ComponentPropsWithoutRef<T>, keyof SlotProps<T>>) {\n const As = as ?? 'div'\n const [element, setElement] = useState<Element | null>(null)\n const baseClassName = useStyle({\n display: 'flex',\n flexWrap: 'wrap',\n width: '100%',\n })\n\n useEffect(() => {\n if (element == null || control == null) return\n\n return pollBoxModel({\n element,\n onBoxModelChange: boxModel => control.changeContainerBoxModel(boxModel),\n })\n }, [element, control])\n\n return (\n <As {...restOfProps} ref={setElement} className={cx(baseClassName, className)}>\n {children}\n </As>\n )\n}\n\nSlot.Placeholder = SlotPlaceholder\n\nSlot.Item = SlotItem\n\ntype SlotItemProps<T extends ElementType> = {\n as?: T\n control: SlotControl | null\n // @arvin: review for correctness\n grid: DataType<SlotDefinition<ReactNode>> extends undefined\n ? undefined\n : NonNullable<DataType<SlotDefinition<ReactNode>>>['columns']\n index: number\n children?: ReactNode\n className?: string\n}\n\nfunction SlotItem<T extends ElementType = 'div'>({\n as,\n control,\n grid,\n index,\n children,\n className,\n ...restOfProps\n}: SlotItemProps<T> & Omit<ComponentPropsWithoutRef<T>, keyof SlotItemProps<T>>):
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/controls/slot.tsx"],"sourcesContent":["'use client'\n\nimport { ComponentPropsWithoutRef, ElementType, ReactNode, useEffect, useState, memo } from 'react'\nimport { cx } from '@emotion/css'\n\nimport { SlotDefinition, SlotControl, type DataType } from '@makeswift/controls'\n\nimport { Element } from '../components/Element'\nimport { getIndexes } from '../../../components/utils/columns'\nimport { useResponsiveStyle } from '../../../components/utils/responsive-style'\nimport { useStyle } from '../use-style'\nimport { pollBoxModel } from '../poll-box-model'\n\nexport function renderSlot(props: {\n data: DataType<SlotDefinition<ReactNode>> | undefined\n control: SlotControl | null\n}): ReactNode {\n return <SlotValue {...props} />\n}\n\nconst SlotValue = memo(\n ({\n data,\n control,\n }: {\n data: DataType<SlotDefinition<ReactNode>> | undefined\n control: SlotControl | null\n }): ReactNode => {\n // TODO(miguel): While the UI shouldn't allow the state, we should probably check that at least\n // one element is visible.\n if (data == null || data.elements.length === 0) {\n return <Slot.Placeholder control={control} />\n }\n\n return (\n <Slot control={control}>\n {data.elements.map((element, i) => (\n <Slot.Item key={element.key} control={control} grid={data.columns} index={i}>\n <Element element={element} />\n </Slot.Item>\n ))}\n </Slot>\n )\n },\n)\n\ntype SlotProps<T extends ElementType> = {\n as?: T\n control: SlotControl | null\n children?: ReactNode\n className?: string\n}\n\nexport function Slot<T extends ElementType = 'div'>({\n as,\n control,\n children,\n className,\n ...restOfProps\n}: SlotProps<T> & Omit<ComponentPropsWithoutRef<T>, keyof SlotProps<T>>) {\n const As = as ?? 'div'\n const [element, setElement] = useState<Element | null>(null)\n const baseClassName = useStyle({\n display: 'flex',\n flexWrap: 'wrap',\n width: '100%',\n })\n\n useEffect(() => {\n if (element == null || control == null) return\n\n return pollBoxModel({\n element,\n onBoxModelChange: boxModel => control.changeContainerBoxModel(boxModel),\n })\n }, [element, control])\n\n return (\n <As {...restOfProps} ref={setElement} className={cx(baseClassName, className)}>\n {children}\n </As>\n )\n}\n\nSlot.Placeholder = SlotPlaceholder\n\nSlot.Item = SlotItem\n\ntype SlotItemProps<T extends ElementType> = {\n as?: T\n control: SlotControl | null\n // @arvin: review for correctness\n grid: DataType<SlotDefinition<ReactNode>> extends undefined\n ? undefined\n : NonNullable<DataType<SlotDefinition<ReactNode>>>['columns']\n index: number\n children?: ReactNode\n className?: string\n}\n\nfunction SlotItem<T extends ElementType = 'div'>({\n as,\n control,\n grid,\n index,\n children,\n className,\n ...restOfProps\n}: SlotItemProps<T> & Omit<ComponentPropsWithoutRef<T>, keyof SlotItemProps<T>>): ReactNode {\n const As = as ?? 'div'\n const [element, setElement] = useState<Element | null>(null)\n const baseClassName = useStyle({\n display: 'flex',\n ...useResponsiveStyle([grid], ([{ count = 12, spans = [[12]] } = {}]) => {\n const [rowIndex, columnIndex] = getIndexes(spans, index)\n const span = spans[rowIndex][columnIndex]\n const flexBasis = `calc(100% * ${(span / count).toFixed(5)})`\n\n return span === 0 ? { display: 'none' } : { flexBasis, minWidth: flexBasis }\n }),\n })\n\n useEffect(() => {\n if (element == null || control == null) return\n\n return pollBoxModel({\n element,\n onBoxModelChange: boxModel => control.changeItemBoxModel(index, boxModel),\n })\n }, [element, control, index])\n\n return (\n <As {...restOfProps} ref={setElement} className={cx(baseClassName, className)}>\n {children}\n </As>\n )\n}\n\ntype SlotPlaceholderProps = {\n control: SlotControl | null\n}\n\nfunction SlotPlaceholder({ control }: SlotPlaceholderProps): ReactNode {\n const [element, setElement] = useState<Element | null>(null)\n\n useEffect(() => {\n if (element == null || control == null) return\n\n return pollBoxModel({\n element,\n onBoxModelChange: boxModel => control.changeContainerBoxModel(boxModel),\n })\n }, [element, control])\n\n return (\n <div\n ref={setElement}\n className={useStyle({\n width: '100%',\n background: 'rgba(161, 168, 194, 0.18)',\n height: '80px',\n })}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"100%\"\n height=\"100%\"\n className={useStyle({ overflow: 'visible', padding: 8 })}\n >\n <rect\n x={0}\n y={0}\n width=\"100%\"\n height=\"100%\"\n strokeWidth={2}\n strokeDasharray=\"4 2\"\n fill=\"none\"\n stroke=\"rgba(161, 168, 194, 0.40)\"\n rx=\"4\"\n ry=\"4\"\n />\n </svg>\n </div>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBS;AAfT,mBAA4F;AAC5F,iBAAmB;AAInB,qBAAwB;AACxB,qBAA2B;AAC3B,8BAAmC;AACnC,uBAAyB;AACzB,4BAA6B;AAEtB,SAAS,WAAW,OAGb;AACZ,SAAO,4CAAC,aAAW,GAAG,OAAO;AAC/B;AAEA,MAAM,gBAAY;AAAA,EAChB,CAAC;AAAA,IACC;AAAA,IACA;AAAA,EACF,MAGiB;AAGf,QAAI,QAAQ,QAAQ,KAAK,SAAS,WAAW,GAAG;AAC9C,aAAO,4CAAC,KAAK,aAAL,EAAiB,SAAkB;AAAA,IAC7C;AAEA,WACE,4CAAC,QAAK,SACH,eAAK,SAAS,IAAI,CAAC,SAAS,MAC3B,4CAAC,KAAK,MAAL,EAA4B,SAAkB,MAAM,KAAK,SAAS,OAAO,GACxE,sDAAC,0BAAQ,SAAkB,KADb,QAAQ,GAExB,CACD,GACH;AAAA,EAEJ;AACF;AASO,SAAS,KAAoC;AAAA,EAClD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAyE;AACvE,QAAM,KAAK,MAAM;AACjB,QAAM,CAAC,SAAS,UAAU,QAAI,uBAAyB,IAAI;AAC3D,QAAM,oBAAgB,2BAAS;AAAA,IAC7B,SAAS;AAAA,IACT,UAAU;AAAA,IACV,OAAO;AAAA,EACT,CAAC;AAED,8BAAU,MAAM;AACd,QAAI,WAAW,QAAQ,WAAW;AAAM;AAExC,eAAO,oCAA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rE,QAAM,CAAC,SAAS,UAAU,QAAI,uBAAyB,IAAI;AAE3D,8BAAU,MAAM;AACd,QAAI,WAAW,QAAQ,WAAW;AAAM;AAExC,eAAO,oCAAa;AAAA,MAClB;AAAA,MACA,kBAAkB,cAAY,QAAQ,wBAAwB,QAAQ;AAAA,IACxE,CAAC;AAAA,EACH,GAAG,CAAC,SAAS,OAAO,CAAC;AAErB,SACE;AAAA,IAAC;AAAA;AAAA,MACC,KAAK;AAAA,MACL,eAAW,2BAAS;AAAA,QAClB,OAAO;AAAA,QACP,YAAY;AAAA,QACZ,QAAQ;AAAA,MACV,CAAC;AAAA,MAED;AAAA,QAAC;AAAA;AAAA,UACC,OAAM;AAAA,UACN,OAAM;AAAA,UACN,QAAO;AAAA,UACP,eAAW,2BAAS,EAAE,UAAU,WAAW,SAAS,EAAE,CAAC;AAAA,UAEvD;AAAA,YAAC;AAAA;AAAA,cACC,GAAG;AAAA,cACH,GAAG;AAAA,cACH,OAAM;AAAA,cACN,QAAO;AAAA,cACP,aAAa;AAAA,cACb,iBAAgB;AAAA,cAChB,MAAK;AAAA,cACL,QAAO;AAAA,cACP,IAAG;AAAA,cACH,IAAG;AAAA;AAAA,UACL;AAAA;AAAA,MACF;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/runtimes/react/controls.tsx"],"sourcesContent":["import { useRef } from 'react'\n\nimport { ControlDefinition } from '@makeswift/controls'\n\nimport { partitionRecord } from '../../utils/partition'\n\nimport * as ReactPage from '../../state/react-page'\nimport { isLegacyDescriptor, LegacyDescriptor } from '../../prop-controllers/descriptors'\n\nimport { useStore } from './hooks/use-store'\n\nimport { resolveLegacyDescriptorProp } from './legacy-controls'\nimport { useResolvedProps } from './hooks/use-resolved-props'\n\ntype PropsValueProps = {\n element: ReactPage.ElementData\n children(props: Record<string, unknown>):
|
|
1
|
+
{"version":3,"sources":["../../../../src/runtimes/react/controls.tsx"],"sourcesContent":["import { useRef, ReactNode } from 'react'\n\nimport { ControlDefinition } from '@makeswift/controls'\n\nimport { partitionRecord } from '../../utils/partition'\n\nimport * as ReactPage from '../../state/react-page'\nimport { isLegacyDescriptor, LegacyDescriptor } from '../../prop-controllers/descriptors'\n\nimport { useStore } from './hooks/use-store'\n\nimport { resolveLegacyDescriptorProp } from './legacy-controls'\nimport { useResolvedProps } from './hooks/use-resolved-props'\n\ntype PropsValueProps = {\n element: ReactPage.ElementData\n children(props: Record<string, unknown>): ReactNode\n}\n\nfunction useControlDefs(\n elementType: string,\n): readonly [Record<string, LegacyDescriptor>, Record<string, ControlDefinition>] {\n const store = useStore()\n const all = ReactPage.getComponentPropControllerDescriptors(store.getState(), elementType) ?? {}\n return useRef(partitionRecord(all, isLegacyDescriptor)).current\n}\n\nexport function ResolveProps({ element, children: renderComponent }: PropsValueProps): ReactNode {\n const [legacyDescriptors, definitions] = useControlDefs(element.type)\n\n const resolvedProps = useResolvedProps(definitions, element.props, element.key)\n\n const renderFn = Object.entries(legacyDescriptors).reduceRight(\n (renderFn, [propName, descriptor]) =>\n props =>\n resolveLegacyDescriptorProp(descriptor, propName, element.props[propName], props, renderFn),\n renderComponent,\n )\n\n return renderFn(resolvedProps)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkC;AAIlC,uBAAgC;AAEhC,gBAA2B;AAC3B,yBAAqD;AAErD,uBAAyB;AAEzB,6BAA4C;AAC5C,gCAAiC;AAOjC,SAAS,eACP,aACgF;AAChF,QAAM,YAAQ,2BAAS;AACvB,QAAM,MAAM,UAAU,sCAAsC,MAAM,SAAS,GAAG,WAAW,KAAK,CAAC;AAC/F,aAAO,yBAAO,kCAAgB,KAAK,qCAAkB,CAAC,EAAE;AAC1D;AAEO,SAAS,aAAa,EAAE,SAAS,UAAU,gBAAgB,GAA+B;AAC/F,QAAM,CAAC,mBAAmB,WAAW,IAAI,eAAe,QAAQ,IAAI;AAEpE,QAAM,oBAAgB,4CAAiB,aAAa,QAAQ,OAAO,QAAQ,GAAG;AAE9E,QAAM,WAAW,OAAO,QAAQ,iBAAiB,EAAE;AAAA,IACjD,CAACA,WAAU,CAAC,UAAU,UAAU,MAC9B,eACE,oDAA4B,YAAY,UAAU,QAAQ,MAAM,QAAQ,GAAG,OAAOA,SAAQ;AAAA,IAC9F;AAAA,EACF;AAEA,SAAO,SAAS,aAAa;AAC/B;","names":["renderFn"]}
|
|
@@ -29,6 +29,8 @@ function suppressWarningAndFindDomNode(instance) {
|
|
|
29
29
|
console.error = (...args) => {
|
|
30
30
|
if (typeof args[0] === "string" && args[0].includes("%s is deprecated in StrictMode."))
|
|
31
31
|
return;
|
|
32
|
+
if (typeof args[0] === "string" && args[0].includes("findDOMNode is deprecated"))
|
|
33
|
+
return;
|
|
32
34
|
return error.apply(console, args);
|
|
33
35
|
};
|
|
34
36
|
const foundDomNode = (0, import_react_dom.findDOMNode)(instance);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/runtimes/react/find-dom-node.tsx"],"sourcesContent":["import {\n Component,\n MutableRefObject,\n ReactNode,\n forwardRef,\n useImperativeHandle,\n useRef,\n} from 'react'\n\nimport { findDOMNode } from './lib/react-dom'\n\n/**\n * @see https://github.com/facebook/react/blob/a2505792ed17fd4d7ddc69561053c3ac90899491/packages/react-reconciler/src/ReactFiberReconciler.new.js#L179-L244\n */\nfunction suppressWarningAndFindDomNode(\n instance: Component | null | undefined,\n): Element | Text | null {\n const error = console.error\n\n console.error = (...args) => {\n if (typeof args[0] === 'string' && args[0].includes('%s is deprecated in StrictMode.')) return\n\n return error.apply(console, args)\n }\n\n const foundDomNode = findDOMNode(instance)\n\n console.error = error\n\n return foundDomNode\n}\n\ntype FindDomNodeClassComponentProps = {\n innerRef: MutableRefObject<(() => Element | Text | null) | null>\n children?: ReactNode\n}\n\nclass FindDomNodeClassComponent extends Component<FindDomNodeClassComponentProps> {\n constructor(props: FindDomNodeClassComponentProps) {\n super(props)\n\n this.props.innerRef.current = () => suppressWarningAndFindDomNode(this)\n }\n\n render() {\n return <>{this.props.children}</>\n }\n}\n\ntype FindDomNodeProps = {\n children?: ReactNode\n}\n\nexport const FindDomNode = forwardRef<() => Element | Text | null, FindDomNodeProps>(\n function FindDomNode(props, ref) {\n const findDomNodeRef = useRef<() => Element | Text | null>(null)\n\n useImperativeHandle(ref, () => () => findDomNodeRef.current?.() ?? null, [])\n\n return <FindDomNodeClassComponent {...props} innerRef={findDomNodeRef} />\n },\n)\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
1
|
+
{"version":3,"sources":["../../../../src/runtimes/react/find-dom-node.tsx"],"sourcesContent":["import {\n Component,\n MutableRefObject,\n ReactNode,\n forwardRef,\n useImperativeHandle,\n useRef,\n} from 'react'\n\nimport { findDOMNode } from './lib/react-dom'\n\n/**\n * @see https://github.com/facebook/react/blob/a2505792ed17fd4d7ddc69561053c3ac90899491/packages/react-reconciler/src/ReactFiberReconciler.new.js#L179-L244\n * @see https://github.com/facebook/react/commit/c3b283964108b0e8dbcf1f9eb2e7e67815e39dfb\n */\nfunction suppressWarningAndFindDomNode(\n instance: Component | null | undefined,\n): Element | Text | null {\n const error = console.error\n\n console.error = (...args) => {\n if (typeof args[0] === 'string' && args[0].includes('%s is deprecated in StrictMode.')) return\n if (typeof args[0] === 'string' && args[0].includes('findDOMNode is deprecated')) return\n\n return error.apply(console, args)\n }\n\n const foundDomNode = findDOMNode(instance)\n\n console.error = error\n\n return foundDomNode\n}\n\ntype FindDomNodeClassComponentProps = {\n innerRef: MutableRefObject<(() => Element | Text | null) | null>\n children?: ReactNode\n}\n\nclass FindDomNodeClassComponent extends Component<FindDomNodeClassComponentProps> {\n constructor(props: FindDomNodeClassComponentProps) {\n super(props)\n\n this.props.innerRef.current = () => suppressWarningAndFindDomNode(this)\n }\n\n render() {\n return <>{this.props.children}</>\n }\n}\n\ntype FindDomNodeProps = {\n children?: ReactNode\n}\n\nexport const FindDomNode = forwardRef<() => Element | Text | null, FindDomNodeProps>(\n function FindDomNode(props, ref) {\n const findDomNodeRef = useRef<() => Element | Text | null>(null)\n\n useImperativeHandle(ref, () => () => findDomNodeRef.current?.() ?? null, [])\n\n return <FindDomNodeClassComponent {...props} innerRef={findDomNodeRef} />\n },\n)\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA+CW;AA/CX,mBAOO;AAEP,uBAA4B;AAM5B,SAAS,8BACP,UACuB;AACvB,QAAM,QAAQ,QAAQ;AAEtB,UAAQ,QAAQ,IAAI,SAAS;AAC3B,QAAI,OAAO,KAAK,CAAC,MAAM,YAAY,KAAK,CAAC,EAAE,SAAS,iCAAiC;AAAG;AACxF,QAAI,OAAO,KAAK,CAAC,MAAM,YAAY,KAAK,CAAC,EAAE,SAAS,2BAA2B;AAAG;AAElF,WAAO,MAAM,MAAM,SAAS,IAAI;AAAA,EAClC;AAEA,QAAM,mBAAe,8BAAY,QAAQ;AAEzC,UAAQ,QAAQ;AAEhB,SAAO;AACT;AAOA,MAAM,kCAAkC,uBAA0C;AAAA,EAChF,YAAY,OAAuC;AACjD,UAAM,KAAK;AAEX,SAAK,MAAM,SAAS,UAAU,MAAM,8BAA8B,IAAI;AAAA,EACxE;AAAA,EAEA,SAAS;AACP,WAAO,2EAAG,eAAK,MAAM,UAAS;AAAA,EAChC;AACF;AAMO,MAAM,kBAAc;AAAA,EACzB,SAASA,aAAY,OAAO,KAAK;AAC/B,UAAM,qBAAiB,qBAAoC,IAAI;AAE/D,0CAAoB,KAAK,MAAM,MAAM,eAAe,UAAU,KAAK,MAAM,CAAC,CAAC;AAE3E,WAAO,4CAAC,6BAA2B,GAAG,OAAO,UAAU,gBAAgB;AAAA,EACzE;AACF;","names":["FindDomNode"]}
|
|
@@ -45,7 +45,7 @@ function useSwatch(swatchId) {
|
|
|
45
45
|
}
|
|
46
46
|
function useSwatches(swatchIds) {
|
|
47
47
|
const client = (0, import_host_api_client.useMakeswiftHostApiClient)();
|
|
48
|
-
const lastSnapshot = (0, import_react.useRef)();
|
|
48
|
+
const lastSnapshot = (0, import_react.useRef)(null);
|
|
49
49
|
function getSnapshot() {
|
|
50
50
|
const swatches2 = swatchIds.map((swatchId) => client.readSwatch(swatchId));
|
|
51
51
|
if (lastSnapshot.current != null && lastSnapshot.current.length === swatches2.length && lastSnapshot.current.every((swatch, idx) => swatches2[idx] === swatch)) {
|
|
@@ -71,7 +71,7 @@ function useFile(fileId) {
|
|
|
71
71
|
}
|
|
72
72
|
function useFiles(fileIds) {
|
|
73
73
|
const client = (0, import_host_api_client.useMakeswiftHostApiClient)();
|
|
74
|
-
const lastSnapshot = (0, import_react.useRef)();
|
|
74
|
+
const lastSnapshot = (0, import_react.useRef)(null);
|
|
75
75
|
function getSnapshot() {
|
|
76
76
|
const files2 = fileIds.map((fileId) => client.readFile(fileId));
|
|
77
77
|
if (lastSnapshot.current != null && lastSnapshot.current.length === files2.length && lastSnapshot.current.every((file, idx) => files2[idx] === file)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/runtimes/react/hooks/makeswift-api.ts"],"sourcesContent":["'use client'\n\nimport { useEffect, useRef, useSyncExternalStore } from 'react'\nimport {\n File,\n GlobalElement,\n LocalizedGlobalElement,\n PagePathnameSlice,\n Swatch,\n Table,\n Typography,\n} from '../../../api'\n\nimport { useMakeswiftHostApiClient } from '../host-api-client'\nimport { useDocumentLocale } from './use-document-context'\n\nexport function useSwatch(swatchId: string | null): Swatch | null {\n const client = useMakeswiftHostApiClient()\n const readSwatch = () => (swatchId == null ? null : client.readSwatch(swatchId))\n const swatch = useSyncExternalStore(client.subscribe, readSwatch, readSwatch)\n\n useEffect(() => {\n if (swatchId != null) client.fetchSwatch(swatchId).catch(console.error)\n }, [client, swatchId])\n\n return swatch\n}\n\nexport function useSwatches(swatchIds: string[]): (Swatch | null)[] {\n const client = useMakeswiftHostApiClient()\n const lastSnapshot = useRef<(Swatch | null)[]>()\n\n function getSnapshot() {\n const swatches = swatchIds.map(swatchId => client.readSwatch(swatchId))\n\n if (\n lastSnapshot.current != null &&\n lastSnapshot.current.length === swatches.length &&\n lastSnapshot.current.every((swatch, idx) => swatches[idx] === swatch)\n ) {\n return lastSnapshot.current\n }\n\n return (lastSnapshot.current = swatches)\n }\n\n const swatches = useSyncExternalStore(client.subscribe, getSnapshot, getSnapshot)\n\n useEffect(() => {\n Promise.all(swatchIds.map(swatchId => client.fetchSwatch(swatchId))).catch(console.error)\n }, [client, swatchIds])\n\n return swatches\n}\n\nexport function useFile(fileId: string | null): File | null {\n const client = useMakeswiftHostApiClient()\n const readFile = () => (fileId == null ? null : client.readFile(fileId))\n const file = useSyncExternalStore(client.subscribe, readFile, readFile)\n\n useEffect(() => {\n if (fileId != null) client.fetchFile(fileId)\n }, [client, fileId])\n\n return file\n}\n\nexport function useFiles(fileIds: string[]): (File | null)[] {\n const client = useMakeswiftHostApiClient()\n const lastSnapshot = useRef<(File | null)[]>()\n\n function getSnapshot() {\n const files = fileIds.map(fileId => client.readFile(fileId))\n\n if (\n lastSnapshot.current != null &&\n lastSnapshot.current.length === files.length &&\n lastSnapshot.current.every((file, idx) => files[idx] === file)\n ) {\n return lastSnapshot.current\n }\n\n return (lastSnapshot.current = files)\n }\n\n const files = useSyncExternalStore(client.subscribe, getSnapshot, getSnapshot)\n\n useEffect(() => {\n Promise.all(fileIds.map(fileId => client.fetchFile(fileId))).catch(console.error)\n }, [client, fileIds])\n\n return files\n}\n\nexport function useTypography(typographyId: string | null): Typography | null {\n const client = useMakeswiftHostApiClient()\n const readTypography = () => (typographyId == null ? null : client.readTypography(typographyId))\n const typography = useSyncExternalStore(client.subscribe, readTypography, readTypography)\n\n useEffect(() => {\n if (typographyId != null) client.fetchTypography(typographyId).catch(console.error)\n }, [client, typographyId])\n\n return typography\n}\n\nexport function useGlobalElement(globalElementId: string | null): GlobalElement | null {\n const client = useMakeswiftHostApiClient()\n const readGlobalElement = () =>\n globalElementId == null ? null : client.readGlobalElement(globalElementId)\n const globalElement = useSyncExternalStore(client.subscribe, readGlobalElement, readGlobalElement)\n\n useEffect(() => {\n if (globalElementId != null) client.fetchGlobalElement(globalElementId).catch(console.error)\n }, [client, globalElementId])\n\n return globalElement\n}\n\nexport function useLocalizedGlobalElement(\n locale: string | null,\n globalElementId: string | null,\n): LocalizedGlobalElement | null {\n const client = useMakeswiftHostApiClient()\n const readLocalizedGlobalElement = () =>\n locale == null || globalElementId == null\n ? null\n : client.readLocalizedGlobalElement({ globalElementId, locale })\n\n const localizedGlobalElement = useSyncExternalStore(\n client.subscribe,\n readLocalizedGlobalElement,\n readLocalizedGlobalElement,\n )\n\n useEffect(() => {\n if (locale != null && globalElementId != null) {\n client.fetchLocalizedGlobalElement({ globalElementId, locale }).catch(console.error)\n }\n }, [client, locale, globalElementId])\n\n return localizedGlobalElement\n}\n\nexport function usePagePathnameSlice(pageId: string | null): PagePathnameSlice | null {\n const client = useMakeswiftHostApiClient()\n const locale = useDocumentLocale()\n\n const readPagePathnameSlice = () =>\n pageId == null ? null : client.readPagePathnameSlice({ pageId, locale })\n\n const pagePathnameSlice = useSyncExternalStore(\n client.subscribe,\n readPagePathnameSlice,\n readPagePathnameSlice,\n )\n\n useEffect(() => {\n if (pageId != null) client.fetchPagePathnameSlice({ pageId, locale }).catch(console.error)\n }, [client, pageId, locale])\n\n return pagePathnameSlice\n}\n\nexport function useTable(tableId: string | null): Table | null {\n const client = useMakeswiftHostApiClient()\n const readTable = () => (tableId == null ? null : client.readTable(tableId))\n const table = useSyncExternalStore(client.subscribe, readTable, readTable)\n\n useEffect(() => {\n if (tableId != null) client.fetchTable(tableId).catch(console.error)\n }, [client, tableId])\n\n return table\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAwD;AAWxD,6BAA0C;AAC1C,kCAAkC;AAE3B,SAAS,UAAU,UAAwC;AAChE,QAAM,aAAS,kDAA0B;AACzC,QAAM,aAAa,MAAO,YAAY,OAAO,OAAO,OAAO,WAAW,QAAQ;AAC9E,QAAM,aAAS,mCAAqB,OAAO,WAAW,YAAY,UAAU;AAE5E,8BAAU,MAAM;AACd,QAAI,YAAY;AAAM,aAAO,YAAY,QAAQ,EAAE,MAAM,QAAQ,KAAK;AAAA,EACxE,GAAG,CAAC,QAAQ,QAAQ,CAAC;AAErB,SAAO;AACT;AAEO,SAAS,YAAY,WAAwC;AAClE,QAAM,aAAS,kDAA0B;AACzC,QAAM,mBAAe,
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/hooks/makeswift-api.ts"],"sourcesContent":["'use client'\n\nimport { useEffect, useRef, useSyncExternalStore } from 'react'\nimport {\n File,\n GlobalElement,\n LocalizedGlobalElement,\n PagePathnameSlice,\n Swatch,\n Table,\n Typography,\n} from '../../../api'\n\nimport { useMakeswiftHostApiClient } from '../host-api-client'\nimport { useDocumentLocale } from './use-document-context'\n\nexport function useSwatch(swatchId: string | null): Swatch | null {\n const client = useMakeswiftHostApiClient()\n const readSwatch = () => (swatchId == null ? null : client.readSwatch(swatchId))\n const swatch = useSyncExternalStore(client.subscribe, readSwatch, readSwatch)\n\n useEffect(() => {\n if (swatchId != null) client.fetchSwatch(swatchId).catch(console.error)\n }, [client, swatchId])\n\n return swatch\n}\n\nexport function useSwatches(swatchIds: string[]): (Swatch | null)[] {\n const client = useMakeswiftHostApiClient()\n const lastSnapshot = useRef<(Swatch | null)[] | null>(null)\n\n function getSnapshot() {\n const swatches = swatchIds.map(swatchId => client.readSwatch(swatchId))\n\n if (\n lastSnapshot.current != null &&\n lastSnapshot.current.length === swatches.length &&\n lastSnapshot.current.every((swatch, idx) => swatches[idx] === swatch)\n ) {\n return lastSnapshot.current\n }\n\n return (lastSnapshot.current = swatches)\n }\n\n const swatches = useSyncExternalStore(client.subscribe, getSnapshot, getSnapshot)\n\n useEffect(() => {\n Promise.all(swatchIds.map(swatchId => client.fetchSwatch(swatchId))).catch(console.error)\n }, [client, swatchIds])\n\n return swatches\n}\n\nexport function useFile(fileId: string | null): File | null {\n const client = useMakeswiftHostApiClient()\n const readFile = () => (fileId == null ? null : client.readFile(fileId))\n const file = useSyncExternalStore(client.subscribe, readFile, readFile)\n\n useEffect(() => {\n if (fileId != null) client.fetchFile(fileId)\n }, [client, fileId])\n\n return file\n}\n\nexport function useFiles(fileIds: string[]): (File | null)[] {\n const client = useMakeswiftHostApiClient()\n const lastSnapshot = useRef<(File | null)[] | null>(null)\n\n function getSnapshot() {\n const files = fileIds.map(fileId => client.readFile(fileId))\n\n if (\n lastSnapshot.current != null &&\n lastSnapshot.current.length === files.length &&\n lastSnapshot.current.every((file, idx) => files[idx] === file)\n ) {\n return lastSnapshot.current\n }\n\n return (lastSnapshot.current = files)\n }\n\n const files = useSyncExternalStore(client.subscribe, getSnapshot, getSnapshot)\n\n useEffect(() => {\n Promise.all(fileIds.map(fileId => client.fetchFile(fileId))).catch(console.error)\n }, [client, fileIds])\n\n return files\n}\n\nexport function useTypography(typographyId: string | null): Typography | null {\n const client = useMakeswiftHostApiClient()\n const readTypography = () => (typographyId == null ? null : client.readTypography(typographyId))\n const typography = useSyncExternalStore(client.subscribe, readTypography, readTypography)\n\n useEffect(() => {\n if (typographyId != null) client.fetchTypography(typographyId).catch(console.error)\n }, [client, typographyId])\n\n return typography\n}\n\nexport function useGlobalElement(globalElementId: string | null): GlobalElement | null {\n const client = useMakeswiftHostApiClient()\n const readGlobalElement = () =>\n globalElementId == null ? null : client.readGlobalElement(globalElementId)\n const globalElement = useSyncExternalStore(client.subscribe, readGlobalElement, readGlobalElement)\n\n useEffect(() => {\n if (globalElementId != null) client.fetchGlobalElement(globalElementId).catch(console.error)\n }, [client, globalElementId])\n\n return globalElement\n}\n\nexport function useLocalizedGlobalElement(\n locale: string | null,\n globalElementId: string | null,\n): LocalizedGlobalElement | null {\n const client = useMakeswiftHostApiClient()\n const readLocalizedGlobalElement = () =>\n locale == null || globalElementId == null\n ? null\n : client.readLocalizedGlobalElement({ globalElementId, locale })\n\n const localizedGlobalElement = useSyncExternalStore(\n client.subscribe,\n readLocalizedGlobalElement,\n readLocalizedGlobalElement,\n )\n\n useEffect(() => {\n if (locale != null && globalElementId != null) {\n client.fetchLocalizedGlobalElement({ globalElementId, locale }).catch(console.error)\n }\n }, [client, locale, globalElementId])\n\n return localizedGlobalElement\n}\n\nexport function usePagePathnameSlice(pageId: string | null): PagePathnameSlice | null {\n const client = useMakeswiftHostApiClient()\n const locale = useDocumentLocale()\n\n const readPagePathnameSlice = () =>\n pageId == null ? null : client.readPagePathnameSlice({ pageId, locale })\n\n const pagePathnameSlice = useSyncExternalStore(\n client.subscribe,\n readPagePathnameSlice,\n readPagePathnameSlice,\n )\n\n useEffect(() => {\n if (pageId != null) client.fetchPagePathnameSlice({ pageId, locale }).catch(console.error)\n }, [client, pageId, locale])\n\n return pagePathnameSlice\n}\n\nexport function useTable(tableId: string | null): Table | null {\n const client = useMakeswiftHostApiClient()\n const readTable = () => (tableId == null ? null : client.readTable(tableId))\n const table = useSyncExternalStore(client.subscribe, readTable, readTable)\n\n useEffect(() => {\n if (tableId != null) client.fetchTable(tableId).catch(console.error)\n }, [client, tableId])\n\n return table\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAwD;AAWxD,6BAA0C;AAC1C,kCAAkC;AAE3B,SAAS,UAAU,UAAwC;AAChE,QAAM,aAAS,kDAA0B;AACzC,QAAM,aAAa,MAAO,YAAY,OAAO,OAAO,OAAO,WAAW,QAAQ;AAC9E,QAAM,aAAS,mCAAqB,OAAO,WAAW,YAAY,UAAU;AAE5E,8BAAU,MAAM;AACd,QAAI,YAAY;AAAM,aAAO,YAAY,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