@makeswift/runtime 0.26.2 → 0.26.3-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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,6 +1,6 @@
|
|
|
1
1
|
import { Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { act } from "react";
|
|
2
3
|
import "@testing-library/jest-dom";
|
|
3
|
-
import { act } from "react-dom/test-utils";
|
|
4
4
|
import { render } from "@testing-library/react";
|
|
5
5
|
import { ReactRuntime } from "../../runtimes/react/react-runtime";
|
|
6
6
|
import { MakeswiftComponentType } from "../../components/builtin/constants";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/next/testing/page-rendering.tsx"],"sourcesContent":["import { type ComponentPropsWithoutRef } from 'react'
|
|
1
|
+
{"version":3,"sources":["../../../../src/next/testing/page-rendering.tsx"],"sourcesContent":["import { type ComponentPropsWithoutRef, act } from 'react';\n\nimport '@testing-library/jest-dom'\nimport { render } from '@testing-library/react'\n\nimport { ReactRuntime } from '../../runtimes/react/react-runtime'\nimport { MakeswiftComponentType } from '../../components/builtin/constants'\n\nimport { Page as MakeswiftPage } from '../components/page'\n\nimport { ReactProvider } from './react-provider'\n\nexport async function testMakeswiftPageHeadRendering(\n props: ComponentPropsWithoutRef<typeof MakeswiftPage>,\n { forcePagesRouter = false }: { forcePagesRouter?: boolean } = {},\n) {\n const runtime = new ReactRuntime()\n\n runtime.registerComponent(() => <></>, {\n type: MakeswiftComponentType.Root,\n label: 'Root',\n props: {},\n })\n\n return await act(async () =>\n render(\n <ReactProvider runtime={runtime} siteVersion={null} forcePagesRouter={forcePagesRouter}>\n <MakeswiftPage {...props} />\n </ReactProvider>,\n {\n container: document.body.appendChild(document.createElement('head')),\n },\n ),\n )\n}\n\nexport async function testMakeswiftPageRendering(\n props: ComponentPropsWithoutRef<typeof MakeswiftPage>,\n { forcePagesRouter = false }: { forcePagesRouter?: boolean } = {},\n) {\n const runtime = new ReactRuntime()\n\n return await act(async () =>\n render(\n <ReactProvider runtime={runtime} siteVersion={null} forcePagesRouter={forcePagesRouter}>\n <MakeswiftPage {...props} />\n </ReactProvider>,\n {\n container: document.body.appendChild(document.createElement('div')),\n },\n ),\n )\n}\n"],"mappings":"AAkBkC;AAlBlC,SAAwC,WAAW;AAEnD,OAAO;AACP,SAAS,cAAc;AAEvB,SAAS,oBAAoB;AAC7B,SAAS,8BAA8B;AAEvC,SAAS,QAAQ,qBAAqB;AAEtC,SAAS,qBAAqB;AAE9B,eAAsB,+BACpB,OACA,EAAE,mBAAmB,MAAM,IAAoC,CAAC,GAChE;AACA,QAAM,UAAU,IAAI,aAAa;AAEjC,UAAQ,kBAAkB,MAAM,gCAAE,GAAK;AAAA,IACrC,MAAM,uBAAuB;AAAA,IAC7B,OAAO;AAAA,IACP,OAAO,CAAC;AAAA,EACV,CAAC;AAED,SAAO,MAAM;AAAA,IAAI,YACf;AAAA,MACE,oBAAC,iBAAc,SAAkB,aAAa,MAAM,kBAClD,8BAAC,iBAAe,GAAG,OAAO,GAC5B;AAAA,MACA;AAAA,QACE,WAAW,SAAS,KAAK,YAAY,SAAS,cAAc,MAAM,CAAC;AAAA,MACrE;AAAA,IACF;AAAA,EACF;AACF;AAEA,eAAsB,2BACpB,OACA,EAAE,mBAAmB,MAAM,IAAoC,CAAC,GAChE;AACA,QAAM,UAAU,IAAI,aAAa;AAEjC,SAAO,MAAM;AAAA,IAAI,YACf;AAAA,MACE,oBAAC,iBAAc,SAAkB,aAAa,MAAM,kBAClD,8BAAC,iBAAe,GAAG,OAAO,GAC5B;AAAA,MACA;AAAA,QACE,WAAW,SAAS,KAAK,YAAY,SAAS,cAAc,KAAK,CAAC;AAAA,MACpE;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/runtimes/react/components/Document.tsx"],"sourcesContent":["import { Ref, forwardRef, memo } from 'react'\nimport { type Document as ReactPageDocument, getRootElement } from '../../../state/react-page'\nimport { ElementImperativeHandle } from '../element-imperative-handle'\nimport { DocumentKeyContext, DocumentLocaleContext } from '../hooks/use-document-context'\nimport { Element } from './Element'\n\ntype DocumentProps = {\n document: ReactPageDocument\n}\n\nexport const Document = memo(\n forwardRef(function Document(\n { document }: DocumentProps,\n ref: Ref<ElementImperativeHandle>,\n ):
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/components/Document.tsx"],"sourcesContent":["import { Ref, forwardRef, memo, ReactNode } from 'react'\nimport { type Document as ReactPageDocument, getRootElement } from '../../../state/react-page'\nimport { ElementImperativeHandle } from '../element-imperative-handle'\nimport { DocumentKeyContext, DocumentLocaleContext } from '../hooks/use-document-context'\nimport { Element } from './Element'\n\ntype DocumentProps = {\n document: ReactPageDocument\n}\n\nexport const Document = memo(\n forwardRef(function Document(\n { document }: DocumentProps,\n ref: Ref<ElementImperativeHandle>,\n ): ReactNode {\n return (\n <DocumentKeyContext.Provider value={document.key}>\n <DocumentLocaleContext.Provider value={document.locale}>\n <Element ref={ref} element={getRootElement(document)} />\n </DocumentLocaleContext.Provider>\n </DocumentKeyContext.Provider>\n )\n }),\n)\n"],"mappings":"AAkBU;AAlBV,SAAc,YAAY,YAAuB;AACjD,SAA6C,sBAAsB;AAEnE,SAAS,oBAAoB,6BAA6B;AAC1D,SAAS,eAAe;AAMjB,MAAM,WAAW;AAAA,EACtB,WAAW,SAASA,UAClB,EAAE,SAAS,GACX,KACW;AACX,WACE,oBAAC,mBAAmB,UAAnB,EAA4B,OAAO,SAAS,KAC3C,8BAAC,sBAAsB,UAAtB,EAA+B,OAAO,SAAS,QAC9C,8BAAC,WAAQ,KAAU,SAAS,eAAe,QAAQ,GAAG,GACxD,GACF;AAAA,EAEJ,CAAC;AACH;","names":["Document"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/runtimes/react/components/DocumentRoot.tsx"],"sourcesContent":["import { Ref, forwardRef, memo } from 'react'\nimport { type Document } from '../../../state/react-page'\nimport { ElementImperativeHandle } from '../element-imperative-handle'\nimport { useDocument } from '../hooks/use-document'\nimport { FallbackComponent } from '../../../components/shared/FallbackComponent'\nimport { Document as DocumentComponent } from './Document'\n\ntype Props = {\n rootDocument: Document\n}\n\nexport const DocumentRoot = memo(\n forwardRef(function DocumentRoot(\n { rootDocument }: Props,\n ref: Ref<ElementImperativeHandle>,\n ):
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/components/DocumentRoot.tsx"],"sourcesContent":["import { Ref, forwardRef, memo, ReactNode } from 'react'\nimport { type Document } from '../../../state/react-page'\nimport { ElementImperativeHandle } from '../element-imperative-handle'\nimport { useDocument } from '../hooks/use-document'\nimport { FallbackComponent } from '../../../components/shared/FallbackComponent'\nimport { Document as DocumentComponent } from './Document'\n\ntype Props = {\n rootDocument: Document\n}\n\nexport const DocumentRoot = memo(\n forwardRef(function DocumentRoot(\n { rootDocument }: Props,\n ref: Ref<ElementImperativeHandle>,\n ): ReactNode {\n const document = useDocument(rootDocument.key) ?? rootDocument\n\n if (document == null) {\n return <FallbackComponent ref={ref as Ref<HTMLDivElement>} text=\"Document not found\" />\n }\n\n return <DocumentComponent ref={ref} document={document} />\n }),\n)\n"],"mappings":"AAmBa;AAnBb,SAAc,YAAY,YAAuB;AAGjD,SAAS,mBAAmB;AAC5B,SAAS,yBAAyB;AAClC,SAAS,YAAY,yBAAyB;AAMvC,MAAM,eAAe;AAAA,EAC1B,WAAW,SAASA,cAClB,EAAE,aAAa,GACf,KACW;AACX,UAAM,WAAW,YAAY,aAAa,GAAG,KAAK;AAElD,QAAI,YAAY,MAAM;AACpB,aAAO,oBAAC,qBAAkB,KAAiC,MAAK,sBAAqB;AAAA,IACvF;AAEA,WAAO,oBAAC,qBAAkB,KAAU,UAAoB;AAAA,EAC1D,CAAC;AACH;","names":["DocumentRoot"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/runtimes/react/components/Element.tsx"],"sourcesContent":["'use client'\n\nimport { forwardRef, memo, Ref, useCallback, useImperativeHandle, useRef } from 'react'\nimport { isElementReference, type Element as ElementDataOrRef } from '../../../state/react-page'\nimport { ElementRegistration } from './ElementRegistration'\nimport { ElementReference } from './ElementReference'\nimport { ElementData } from './ElementData'\nimport { ElementImperativeHandle } from '../element-imperative-handle'\nimport { FindDomNode } from '../find-dom-node'\nimport { FallbackComponent } from '../../../components/shared/FallbackComponent'\nimport { ErrorBoundary } from '../../../components/shared/ErrorBoundary'\n\ntype Props = {\n element: ElementDataOrRef\n}\n\nexport const Element = memo(\n forwardRef(function Element(\n { element }: Props,\n ref: Ref<ElementImperativeHandle>,\n ):
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/components/Element.tsx"],"sourcesContent":["'use client'\n\nimport { forwardRef, memo, Ref, useCallback, useImperativeHandle, useRef, ReactNode } from 'react'\nimport { isElementReference, type Element as ElementDataOrRef } from '../../../state/react-page'\nimport { ElementRegistration } from './ElementRegistration'\nimport { ElementReference } from './ElementReference'\nimport { ElementData } from './ElementData'\nimport { ElementImperativeHandle } from '../element-imperative-handle'\nimport { FindDomNode } from '../find-dom-node'\nimport { FallbackComponent } from '../../../components/shared/FallbackComponent'\nimport { ErrorBoundary } from '../../../components/shared/ErrorBoundary'\n\ntype Props = {\n element: ElementDataOrRef\n}\n\nexport const Element = memo(\n forwardRef(function Element(\n { element }: Props,\n ref: Ref<ElementImperativeHandle>,\n ): ReactNode | null {\n const useFindDomNodeRef = useRef(true)\n const imperativeHandleRef = useRef(new ElementImperativeHandle())\n\n const findDomNodeCallbackRef = useCallback((current: (() => Element | Text | null) | null) => {\n if (useFindDomNodeRef.current === true) {\n imperativeHandleRef.current.callback(() => current?.() ?? null)\n }\n }, [])\n\n const elementCallbackRef = useCallback((current: unknown | null) => {\n useFindDomNodeRef.current = false\n\n imperativeHandleRef.current.callback(() => current)\n }, [])\n\n useImperativeHandle(ref, () => imperativeHandleRef.current, [])\n\n return (\n <ElementRegistration componentHandle={imperativeHandleRef.current} elementKey={element.key}>\n <FindDomNode ref={findDomNodeCallbackRef}>\n <ErrorBoundary FallbackComponent={ErrorFallback}>\n {isElementReference(element) ? (\n <ElementReference\n key={element.key}\n ref={elementCallbackRef}\n elementReference={element}\n />\n ) : (\n <ElementData key={element.key} ref={elementCallbackRef} elementData={element} />\n )}\n </ErrorBoundary>\n </FindDomNode>\n </ElementRegistration>\n )\n }),\n)\n\nfunction ErrorFallback() {\n return <FallbackComponent text={`Error rendering component`} />\n}\n"],"mappings":";AA2Cc;AAzCd,SAAS,YAAY,MAAW,aAAa,qBAAqB,cAAyB;AAC3F,SAAS,0BAA4D;AACrE,SAAS,2BAA2B;AACpC,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAC5B,SAAS,+BAA+B;AACxC,SAAS,mBAAmB;AAC5B,SAAS,yBAAyB;AAClC,SAAS,qBAAqB;AAMvB,MAAM,UAAU;AAAA,EACrB,WAAW,SAASA,SAClB,EAAE,QAAQ,GACV,KACkB;AAClB,UAAM,oBAAoB,OAAO,IAAI;AACrC,UAAM,sBAAsB,OAAO,IAAI,wBAAwB,CAAC;AAEhE,UAAM,yBAAyB,YAAY,CAAC,YAAkD;AAC5F,UAAI,kBAAkB,YAAY,MAAM;AACtC,4BAAoB,QAAQ,SAAS,MAAM,UAAU,KAAK,IAAI;AAAA,MAChE;AAAA,IACF,GAAG,CAAC,CAAC;AAEL,UAAM,qBAAqB,YAAY,CAAC,YAA4B;AAClE,wBAAkB,UAAU;AAE5B,0BAAoB,QAAQ,SAAS,MAAM,OAAO;AAAA,IACpD,GAAG,CAAC,CAAC;AAEL,wBAAoB,KAAK,MAAM,oBAAoB,SAAS,CAAC,CAAC;AAE9D,WACE,oBAAC,uBAAoB,iBAAiB,oBAAoB,SAAS,YAAY,QAAQ,KACrF,8BAAC,eAAY,KAAK,wBAChB,8BAAC,iBAAc,mBAAmB,eAC/B,6BAAmB,OAAO,IACzB;AAAA,MAAC;AAAA;AAAA,QAEC,KAAK;AAAA,QACL,kBAAkB;AAAA;AAAA,MAFb,QAAQ;AAAA,IAGf,IAEA,oBAAC,eAA8B,KAAK,oBAAoB,aAAa,WAAnD,QAAQ,GAAoD,GAElF,GACF,GACF;AAAA,EAEJ,CAAC;AACH;AAEA,SAAS,gBAAgB;AACvB,SAAO,oBAAC,qBAAkB,MAAM,6BAA6B;AAC/D;","names":["Element"]}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { createElement } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { forwardRef, memo } from "react";
|
|
4
4
|
import { useBuiltinSuspense } from "../hooks/use-builtin-suspense";
|
|
5
5
|
import { useComponent } from "../hooks/use-component";
|
|
6
6
|
import { canAcceptRef } from "../utils/can-accept-ref";
|
|
7
7
|
import { FallbackComponent } from "../../../components/shared/FallbackComponent";
|
|
8
8
|
import { ResolveProps } from "../controls";
|
|
9
|
+
import { ActivityOrFallback } from "./activity-with-fallback";
|
|
9
10
|
const ElementData = memo(
|
|
10
11
|
forwardRef(function ElementData2({ elementData }, ref) {
|
|
11
12
|
const Component = useComponent(elementData.type);
|
|
@@ -15,8 +16,7 @@ const ElementData = memo(
|
|
|
15
16
|
return /* @__PURE__ */ jsx(FallbackComponent, { ref, text: "Component not found" });
|
|
16
17
|
}
|
|
17
18
|
const forwardRef2 = canAcceptRef(Component);
|
|
18
|
-
|
|
19
|
-
return /* @__PURE__ */ jsx(SuspenseOrFragment, { children: /* @__PURE__ */ jsx(ResolveProps, { element: elementData, children: (props) => forwardRef2 ? /* @__PURE__ */ createElement(Component, { ...props, key: elementData.key, ref }) : /* @__PURE__ */ createElement(Component, { ...props, key: elementData.key }) }) });
|
|
19
|
+
return /* @__PURE__ */ jsx(ActivityOrFallback, { suspenseFallback: builtinSuspense, children: /* @__PURE__ */ jsx(ResolveProps, { element: elementData, children: (props) => forwardRef2 ? /* @__PURE__ */ createElement(Component, { ...props, key: elementData.key, ref }) : /* @__PURE__ */ createElement(Component, { ...props, key: elementData.key }) }) });
|
|
20
20
|
})
|
|
21
21
|
);
|
|
22
22
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/runtimes/react/components/ElementData.tsx"],"sourcesContent":["import { Ref,
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/components/ElementData.tsx"],"sourcesContent":["import { Ref, forwardRef, memo, ReactNode } from 'react'\nimport { ElementData as ReactPageElementData } from '../../../state/react-page'\nimport { useBuiltinSuspense } from '../hooks/use-builtin-suspense'\nimport { useComponent } from '../hooks/use-component'\nimport { canAcceptRef } from '../utils/can-accept-ref'\nimport { FallbackComponent } from '../../../components/shared/FallbackComponent'\nimport { ResolveProps } from '../controls'\nimport { ActivityOrFallback } from './activity-with-fallback'\n\ntype ElementDataProps = {\n elementData: ReactPageElementData\n}\n\nexport const ElementData = memo(\n forwardRef(function ElementData({ elementData }: ElementDataProps, ref: Ref<unknown>): ReactNode {\n const Component = useComponent(elementData.type)\n const builtinSuspense = useBuiltinSuspense(elementData.type)\n\n if (Component == null) {\n console.warn(`Unknown component '${elementData.type}'`, { elementData })\n return <FallbackComponent ref={ref as Ref<HTMLDivElement>} text=\"Component not found\" />\n }\n\n const forwardRef = canAcceptRef(Component)\n\n return (\n <ActivityOrFallback suspenseFallback={builtinSuspense}>\n <ResolveProps element={elementData}>\n {props =>\n forwardRef ? (\n <Component {...props} key={elementData.key} ref={ref} />\n ) : (\n <Component {...props} key={elementData.key} />\n )\n }\n </ResolveProps>\n </ActivityOrFallback>\n )\n }),\n)\n"],"mappings":"AAoBa;AAUC;AA9Bd,SAAc,YAAY,YAAuB;AAEjD,SAAS,0BAA0B;AACnC,SAAS,oBAAoB;AAC7B,SAAS,oBAAoB;AAC7B,SAAS,yBAAyB;AAClC,SAAS,oBAAoB;AAC7B,SAAS,0BAA0B;AAM5B,MAAM,cAAc;AAAA,EACzB,WAAW,SAASA,aAAY,EAAE,YAAY,GAAqB,KAA8B;AAC/F,UAAM,YAAY,aAAa,YAAY,IAAI;AAC/C,UAAM,kBAAkB,mBAAmB,YAAY,IAAI;AAE3D,QAAI,aAAa,MAAM;AACrB,cAAQ,KAAK,sBAAsB,YAAY,IAAI,KAAK,EAAE,YAAY,CAAC;AACvE,aAAO,oBAAC,qBAAkB,KAAiC,MAAK,uBAAsB;AAAA,IACxF;AAEA,UAAMC,cAAa,aAAa,SAAS;AAEzC,WACE,oBAAC,sBAAmB,kBAAkB,iBACpC,8BAAC,gBAAa,SAAS,aACpB,qBACCA,cACE,8BAAC,aAAW,GAAG,OAAO,KAAK,YAAY,KAAK,KAAU,IAEtD,8BAAC,aAAW,GAAG,OAAO,KAAK,YAAY,KAAK,GAGlD,GACF;AAAA,EAEJ,CAAC;AACH;","names":["ElementData","forwardRef"]}
|
|
@@ -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":"AAyCQ;AAzCR,SAAc,YAAY,MAAM,eAA0B;AAE1D,SAAS,kBAAkB,iCAAiC;AAC5D,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB,yBAAyB;AAKzD,SAAS,yBAAyB;AAClC,SAAS,eAAe;AACxB,SAAS,gBAAgB;AACzB,SAAS,8BAA8B;AACvC,SAAS,yBAAyB;AAM3B,MAAM,mBAAmB;AAAA,EAC9B,WAAW,SAASA,kBAClB,EAAE,iBAAiB,GACnB,KACW;AACX,UAAM,gBAAgB,iBAAiB,iBAAiB,KAAK;AAC7D,UAAM,SAAS,kBAAkB;AAEjC,UAAM,yBAAyB,0BAA0B,QAAQ,iBAAiB,KAAK;AACvF,UAAM,oBAAqB,wBAAwB,QAAQ,eAAe;AAG1E,UAAM,2BAA2B,YAAY,iBAAiB,GAAG;AACjE,UAAM,cAAc,iBAAiB;AACrC,UAAM,eAAe,kBAAkB;AACvC,UAAM,uBAAuB;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,oBAAC,sBAAsB,UAAtB,EAA+B,OAAO,sBACpC,sCAA4B,OAC3B,oBAAC,YAAS,UAAU,0BAA0B,KAAU,IAExD,oBAAC,uBAAuB,UAAvB,EAAgC,OAAO,MAEtC,8BAAC,WAAQ,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":";AAsCS;AApCT,SAAoB,MAAM,iBAAiB;AAE3C,SAAS,mBAAmB;AAC5B,SAAS,sBAAsB;AAC/B,SAAS,iCAAiC;AAC1C,SAAS,4BAA4B;AACrC,SAAS,qCAAqC;AAQvC,MAAM,sBAAsB,KAAK,SAASA,qBAAoB;AAAA,EACnE;AAAA,EACA;AAAA,EACA;AACF,GAA8C;AAC5C,QAAM,WAAW,YAAY;AAC7B,QAAM,cAAc,eAAe;AAEnC,QAAM,4BAA4B,0BAA0B;AAE5D,YAAU,MAAM;AACd,QAAI,eAAe,QAAQ;AAA2B;AAEtD,WAAO,SAAS,8BAA8B,aAAa,YAAY,eAAe,CAAC;AAAA,EACzF,GAAG,CAAC,UAAU,aAAa,YAAY,yBAAyB,CAAC;AAEjE,YAAU,MAAM;AACd,QAAI,eAAe,QAAQ;AAA2B;AAEtD,WAAO,SAAS,qBAAqB,aAAa,UAAU,CAAC;AAAA,EAC/D,GAAG,CAAC,UAAU,aAAa,YAAY,yBAAyB,CAAC;AAEjE,SAAO,gCAAG,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":"AAkBS;AAlBT,SAAiC,eAA0B;AAE3D,YAAY,eAAe;AAE3B,SAAS,uBAAuB;AAChC,SAAS,oBAAoB;AAEd,SAAR,aAA8B,EAAE,SAAS,GAAiC;AAC/E,QAAM,UAAU,gBAAgB;AAChC,QAAM,QAAQ;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,oBAAC,aAAa,UAAb,EAAsB,OAAO,OAAQ,UAAS;AACxD;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { memo, useMemo } from "react";
|
|
4
4
|
import {
|
|
5
5
|
componentDocumentToRootEmbeddedDocument
|
|
6
6
|
} from "../../../client";
|
|
@@ -8,6 +8,7 @@ import { getRootElement } from "../../../state/react-page";
|
|
|
8
8
|
import { useCacheData } from "../hooks/use-cache-data";
|
|
9
9
|
import { useRegisterDocument } from "../hooks/use-register-document";
|
|
10
10
|
import { useBuiltinSuspense } from "../hooks/use-builtin-suspense";
|
|
11
|
+
import { ActivityOrFallback } from "./activity-with-fallback";
|
|
11
12
|
import { DocumentRoot } from "./DocumentRoot";
|
|
12
13
|
const MakeswiftComponent = memo(({ snapshot, label, type, description }) => {
|
|
13
14
|
useCacheData(snapshot.cacheData);
|
|
@@ -24,8 +25,7 @@ const MakeswiftComponent = memo(({ snapshot, label, type, description }) => {
|
|
|
24
25
|
);
|
|
25
26
|
useRegisterDocument(rootDocument);
|
|
26
27
|
const builtinSuspense = useBuiltinSuspense(getRootElement(rootDocument).type);
|
|
27
|
-
|
|
28
|
-
return /* @__PURE__ */ jsx(SuspenseOrFragment, { children: /* @__PURE__ */ jsx(DocumentRoot, { rootDocument }) });
|
|
28
|
+
return /* @__PURE__ */ jsx(ActivityOrFallback, { suspenseFallback: builtinSuspense, children: /* @__PURE__ */ jsx(DocumentRoot, { rootDocument }) });
|
|
29
29
|
});
|
|
30
30
|
export {
|
|
31
31
|
MakeswiftComponent
|
|
@@ -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":";AA8CM;AA5CN,SAAS,MAAM,eAAe;AAE9B;AAAA,EACE;AAAA,OAEK;AACP,SAAS,sBAAsB;AAE/B,SAAS,oBAAoB;AAC7B,SAAS,2BAA2B;AACpC,SAAS,0BAA0B;AACnC,SAAS,0BAA0B;AAEnC,SAAS,oBAAoB;AAStB,MAAM,qBAAqB,KAAK,CAAC,EAAE,UAAU,OAAO,MAAM,YAAY,MAAa;AACxF,eAAa,SAAS,SAAS;AAE/B,QAAM,eAAe;AAAA,IACnB,MACE,wCAAwC;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,sBAAoB,YAAY;AAEhC,QAAM,kBAAkB,mBAAmB,eAAe,YAAY,EAAE,IAAI;AAE5E,SACE,oBAAC,sBAAmB,kBAAkB,iBACpC,8BAAC,gBAAa,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":";AAkCS;AAhCT,SAAiC,WAAW,eAA0B;AAEtE,YAAY,yBAAyB;AACrC,SAAS,uBAAuB;AAEhC,SAAS,uBAAuB;AAChC,SAAS,oBAAoB;AAC7B,SAAS,iCAAiC;AAE3B,SAAR,gBAAiC;AAAA,EACtC;AAAA,EACA;AACF,GAAwD;AACtD,QAAM,UAAU,gBAAgB;AAChC,QAAM,SAAS,0BAA0B;AACzC,QAAM,eAAe,QAAQ,MAAM,IAAI,gBAAgB,EAAE,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC;AAElF,QAAM,QAAQ;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,YAAU,MAAM;AACd,UAAM,MAAM;AACZ,WAAO,MAAM,MAAM,SAAS;AAAA,EAC9B,GAAG,CAAC,KAAK,CAAC;AAEV,SAAO,oBAAC,aAAa,UAAb,EAAsB,OAAO,OAAQ,UAAS;AACxD;","names":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Suspense } from "react";
|
|
4
|
+
const ACTIVITY_KEY = "Activity";
|
|
5
|
+
const Activity = React[ACTIVITY_KEY];
|
|
6
|
+
function supportsActivity() {
|
|
7
|
+
return Activity != null;
|
|
8
|
+
}
|
|
9
|
+
function ActivityOrFallback({ suspenseFallback = true, children }) {
|
|
10
|
+
if (supportsActivity()) {
|
|
11
|
+
return /* @__PURE__ */ jsx(Activity, { children });
|
|
12
|
+
}
|
|
13
|
+
return suspenseFallback ? /* @__PURE__ */ jsx(Suspense, { children }) : /* @__PURE__ */ jsx(Fragment, { children });
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
ActivityOrFallback,
|
|
17
|
+
supportsActivity
|
|
18
|
+
};
|
|
19
|
+
//# 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":"AAuBW,SAGmD,UAHnD;AAvBX,YAAY,WAAW;AACvB,SAAS,gBAAgC;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,oBAAC,YAAU,UAAS;AAAA,EAC7B;AAEA,SAAO,mBAAmB,oBAAC,YAAU,UAAS,IAAc,gCAAG,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":"AAAA,SAAS,UAAU,eAAe,iBAA4B;AAC9D,OAAO,WAAW;AAIX,SAAS,gBAAgB,EAAE,QAAQ,GAAyB;AACjE,YAAU,MAAM;AACd,UAAM,kBAAkB,0BAA0B,OAAO;AACzD,UAAM,oBAAoB,gBAAgB,SAAS;AAEnD,QAAI;AAAmB;AAEvB,WAAO,+BAA+B,SAAS,OAAO,SAAS,IAAI;AAAA,EACrE,GAAG,CAAC,OAAO,CAAC;AAEZ,SAAO;AACT;AAEA,MAAM,2BAA2B;AAEjC,MAAM,2BAA2B;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,SAAS,kBAAkB,SAA+D;AAC/F,SAAO,SAAS,IAAI,MAAM,QAAQ,IAAI,GAAG,aAAW;AAClD,QAAI,OAAO,YAAY;AAAU,aAAO;AAExC,QAAI,CAAC,yBAAyB,SAAS,QAAQ,IAAc;AAAG,aAAO;AAEvE,UAAM,MAAM,QAAQ,MAAM,GAAG,QAAQ,EAAE,IAAI,QAAQ,GAAG,KAAK,QAAQ;AAEnE,WAAO,cAAc,QAAQ,MAAM;AAAA,MACjC,GAAG,QAAQ;AAAA,MACX;AAAA,MACA,CAAC,wBAAwB,GAAG,QAAQ;AAAA,IACtC,CAAC;AAAA,EACH,CAAC;AACH;AAEO,SAAS,+BACd,SACA,WACY;AACZ,QAAM,mBAAmB,UAAU,cAAc,cAAc,UAAU,OAAO;AAEhF,mBAAiB,YAAY,QAAQ;AAErC,QAAM,WAAW,MAAM,KAAK,iBAAiB,iBAAiB,GAAG,CAAC;AAClE,QAAM,UAAU,SAAS,OAAO,QAAM,cAAc,iBAAiB;AAErE,UAAQ,QAAQ,YAAU;AACxB,UAAM,QAAQ,OAAO,cAAc,cAAc,OAAO,OAAO;AAE/D,UAAM,cAAc,OAAO;AAC3B,UAAM,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":[]}
|
|
@@ -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":"AAsBI,mBACE,KADF;AAtBJ,SAAS,eAA0B;AAEnC,SAAS,oBAAoB;AAG7B,SAAS,uBAAuB;AAEhC,SAAS,mBAAmB;AAC5B,SAAS,gBAAgB;AACzB,SAAS,+BAA0D;AAQ5D,SAAS,KAAK,EAAE,MAAM,cAAc,WAAW,KAAK,GAAqB;AAC9E,QAAM,EAAE,aAAa,IAAI,gBAAgB,EAAE,KAAK,CAAC;AACjD,QAAM,uBAAuB,QAAQ,MAAM,wBAAwB,QAAQ,GAAG,CAAC,QAAQ,CAAC;AAExF,SACE,iCACE;AAAA,wBAAC,YAAS,UAAU,MAAM,UAAU,sBAAsB;AAAA,IAE1D,oBAAC,gBAAa,cAA4B;AAAA,IAEzC,aAAa,IAAI,aAChB,oBAAC,eAA6B,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":"AA+EM,SAWE,UAXF,KAWE,YAXF;AA/EN,SAAS,SAAS,4BAAuC;AAKzD,SAAS,iCAAiC;AAE1C,SAAS,2BAA2B;AACpC,SAAS,sBAAsB;AAC/B,SAAS,uBAAuB;AAEhC,SAAS,WAAW,UAAU,UAAU,iBAAiB;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,IACtC,aAAa,iBAAiB;AAAA,IAC9B,UAAU,cAAc;AAAA,IACxB,aAAa,iBAAiB;AAAA,EAChC,IAAI;AAEJ,QAAM,EAAE,aAAa,IAAI,gBAAgB,EAAE,KAAK,CAAC;AACjD,QAAM,EAAE,YAAY,IAAI,oBAAoB;AAE5C,QAAM,cAAc,eAAe;AAEnC,QAAM,OAAO,cAAc,cAAc,KAAK,KAAK,KAAK,IAAI;AAC5D,QAAM,oBAAoB,KAAK,eAAe,KAAK,CAAC,EAAE,SAAS,MAAM,YAAY,IAAI;AAErF,QAAM,UAAU,KAAK,KAAK,WAAW;AACrC,QAAM,QAAQ,mBAAmB,KAAK,SAAS,KAAK,KAAK;AACzD,QAAM,cAAc,mBAAmB,KAAK,eAAe,KAAK,KAAK;AACrE,QAAM,WAAW,mBAAmB,KAAK,YAAY,KAAK,KAAK;AAC/D,QAAM,cAAc,mBAAmB,KAAK,eAAe,KAAK,KAAK;AACrE,QAAM,eAAe,mBAAmB,IAAI,gBAAgB,KAAK,IAAI;AACrE,QAAM,oBAAoB,mBAAmB,IAAI,qBAAqB,KAAK,IAAI;AAE/E,QAAM,uBAAuB,QAAQ,MAAM;AACzC,QAAI,QAAQ,MAAM;AAChB,aAAO,KAAK,MACT,IAAI,CAAC,EAAE,QAAQ,SAAS,MAAM;AAC7B,eAAO,GAAG,OAAO,QAAQ,MAAM,GAAG,CAAC,IAAI,SAAS,KAAK,CAAC;AAAA,MACxD,CAAC,EACA,KAAK,GAAG;AAAA,IACb;AAEA,WAAO,KAAK,YAAY,MACrB,OAAO,CAAC,SAA2C,QAAQ,IAAI,EAC/D,IAAI,CAAC,EAAE,gBAAgB,MAAM,EAAE,QAAQ,SAAS,EAAE,MAAM;AACvD,YAAM,0BAA0B,SAC7B;AAAA,QAAO,aACN,eAAe,KAAK,mBAAiB,cAAc,cAAc,QAAQ,SAAS;AAAA,MACpF,EACC,IAAI,aAAW,QAAQ,SAAS,EAChC,KAAK;AAER,aAAO,GAAG,OAAO,QAAQ,MAAM,GAAG,CAAC,IAAI,uBAAuB;AAAA,IAChE,CAAC,EACA,KAAK,GAAG;AAAA,EACb,GAAG,CAAC,MAAM,IAAI,CAAC;AAEf,SACE,iCACE;AAAA,wBAAC,aAAU,YAAW,QAAO,MAAK,yBAC/B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,WAQH;AAAA,IACC,YAAY,SACX,iCACE;AAAA,0BAAC,aAAW,iBAAM;AAAA,MAClB,oBAAC,YAAS,UAAS,YAAW,SAAS,OAAO;AAAA,MAC9C,oBAAC,YAAS,MAAK,iBAAgB,SAAS,OAAO;AAAA,OACjD;AAAA,IAED,cAAc,WACb,oBAAC,YAAS,KAAI,QAAO,MAAM,QAAQ,UAAU,MAAM,QAAQ,WAAW;AAAA,IAEvE,mBAAmB,gBAAgB,oBAAC,YAAS,KAAI,aAAY,MAAM,cAAc;AAAA,IACjF,sBAAsB,qBAAqB,oBAAC,YAAS,MAAK,UAAS,SAAQ,WAAU;AAAA,IACrF,kBAAkB,eACjB,iCACE;AAAA,0BAAC,YAAS,MAAK,eAAc,SAAS,aAAa;AAAA,MACnD,oBAAC,YAAS,UAAS,kBAAiB,SAAS,aAAa;AAAA,MAC1D,oBAAC,YAAS,MAAK,uBAAsB,SAAS,aAAa;AAAA,OAC7D;AAAA,IAED,eAAe,YAAY,oBAAC,YAAS,MAAK,YAAW,SAAS,UAAU;AAAA,IACxE,kBAAkB,eACjB,iCACE;AAAA,0BAAC,YAAS,UAAS,YAAW,SAAS,YAAY,WAAW;AAAA,MAC9D,oBAAC,YAAS,UAAS,iBAAgB,SAAS,YAAY,UAAU;AAAA,MAClE,oBAAC,YAAS,MAAK,iBAAgB,SAAS,YAAY,WAAW;AAAA,MAC/D,oBAAC,YAAS,MAAK,gBAAe,SAAQ,uBAAsB;AAAA,OAC9D;AAAA,IAED,yBAAyB,MACxB;AAAA,MAAC;AAAA;AAAA,QACC,YAAW;AAAA,QACX,KAAI;AAAA,QACJ,MAAM,2CAA2C,oBAAoB;AAAA;AAAA,IACvE;AAAA,IAED,aAAa,IAAI,aAChB,oBAAC,eAA6B,WAAZ,QAAQ,EAAsB,CACjD;AAAA,KACH;AAEJ;AAEA,SAAS,cAAc,QAAoC;AACzD,QAAM,SAAS,0BAA0B;AACzC,QAAM,cAAc,MAAO,UAAU,OAAO,OAAO,OAAO,SAAS,MAAM;AAEzE,QAAM,OAAO,qBAAqB,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":"AAYM;AAVN,SAAS,2BAA2B;AAM7B,SAAS,UAAU,EAAE,UAAU,GAAG,MAAM,GAAmB;AAChE,QAAM,EAAE,KAAK,IAAI,oBAAoB;AACrC,SACE,oBAAC,QACC,8BAAC,WAAO,GAAG,OAAQ,UAAS,GAC9B;AAEJ;AAEO,SAAS,SAAS,OAAyC;AAChE,QAAM,EAAE,KAAK,IAAI,oBAAoB;AACrC,SACE,oBAAC,QACC,8BAAC,UAAM,GAAG,OAAO,GACnB;AAEJ;AAOO,SAAS,SAAS,EAAE,YAAY,GAAG,MAAM,GAAkB;AAChE,QAAM,EAAE,KAAK,IAAI,oBAAoB;AACrC,SACE,oBAAC,QACC,8BAAC,UAAM,GAAG,OAAO,YAAwB,GAC3C;AAEJ;AAQO,SAAS,UAAU,EAAE,UAAU,YAAY,MAAM,GAAG,MAAM,GAAmB;AAClF,QAAM,EAAE,KAAK,IAAI,oBAAoB;AACrC,SACE,oBAAC,QACC,8BAAC,WAAO,GAAG,OAAO,YAAwB,MACvC,UACH,GACF;AAEJ;","names":[]}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useMemo, memo } from "react";
|
|
3
3
|
import { useCacheData } from "../../hooks/use-cache-data";
|
|
4
4
|
import { pageToRootDocument } from "../../../../client";
|
|
5
5
|
import { Page as PageComponent } from "./Page";
|
|
6
6
|
import { useRegisterDocument } from "../../hooks/use-register-document";
|
|
7
|
+
import { ActivityOrFallback } from "../activity-with-fallback";
|
|
7
8
|
const Page = memo(
|
|
8
9
|
({
|
|
9
10
|
snapshot,
|
|
@@ -12,7 +13,7 @@ const Page = memo(
|
|
|
12
13
|
useCacheData(snapshot.cacheData);
|
|
13
14
|
const rootDocument = useMemo(() => pageToRootDocument(snapshot.document), [snapshot.document]);
|
|
14
15
|
useRegisterDocument(rootDocument);
|
|
15
|
-
return /* @__PURE__ */ jsx(
|
|
16
|
+
return /* @__PURE__ */ jsx(ActivityOrFallback, { children: /* @__PURE__ */ jsx(
|
|
16
17
|
PageComponent,
|
|
17
18
|
{
|
|
18
19
|
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":"AA+CQ;AA/CR,SAAS,SAAS,YAAiC;AAEnD,SAAS,oBAAoB;AAE7B,SAAqC,0BAA0B;AAG/D,SAAS,QAAQ,qBAAqB;AACtC,SAAS,2BAA2B;AACpC,SAAS,0BAA0B;AAsB5B,MAAM,OAAO;AAAA,EAClB,CAAC;AAAA,IACC;AAAA,IACA,WAAW;AAAA,EACb,MAGM;AACJ,iBAAa,SAAS,SAAS;AAE/B,UAAM,eAAe,QAAQ,MAAM,mBAAmB,SAAS,QAAQ,GAAG,CAAC,SAAS,QAAQ,CAAC;AAC7F,wBAAoB,YAAY;AAEhC,WACE,oBAAC,sBAEC;AAAA,MAAC;AAAA;AAAA,QAEC,MAAM,SAAS;AAAA,QACf;AAAA,QACA;AAAA;AAAA,MAHK,SAAS,SAAS,KAAK;AAAA,IAI9B,GACF;AAAA,EAEJ;AACF;","names":[]}
|
|
@@ -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":"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":";AAUA,SAAS,wBAAwB;AACjC,SAAS,4BAA4B;AACrC,SAAS,gBAAgB;AASlB,SAAS,aAAa;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAiC;AAC/B,QAAM,oBAAoB,qBAAqB;AAC/C,QAAM,KAAK,MAAM,SAAS,CAAC;AAE3B,QAAM,QAAQ;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":"AAqBQ;AApBR;AAAA,EAEE;AAAA,OAGK;AAEP,SAAS,oBAAoB;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,gBAAgB,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":"
|
|
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":"AAcM;AAVN,SAAS,oBAAoB;AAOtB,SAAS,eAAe,EAAE,YAAY,SAAS,GAAG,MAAM,GAAwB;AACrF,WAAS,kBAAkB,EAAE,YAAY,UAAU,KAAK,GAA+B;AACrF,WACE,oBAAC,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,oBAAC,gBAAa,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":"AAyCQ,SAyGJ,UAzGI;AAzCR,SAAuB,
|
|
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":"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","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":";AAiBS;AAfT,SAA2D,WAAW,UAAU,YAAY;AAC5F,SAAS,UAAU;AAInB,SAAS,eAAe;AACxB,SAAS,kBAAkB;AAC3B,SAAS,0BAA0B;AACnC,SAAS,gBAAgB;AACzB,SAAS,oBAAoB;AAEtB,SAAS,WAAW,OAGb;AACZ,SAAO,oBAAC,aAAW,GAAG,OAAO;AAC/B;AAEA,MAAM,YAAY;AAAA,EAChB,CAAC;AAAA,IACC;AAAA,IACA;AAAA,EACF,MAGiB;AAGf,QAAI,QAAQ,QAAQ,KAAK,SAAS,WAAW,GAAG;AAC9C,aAAO,oBAAC,KAAK,aAAL,EAAiB,SAAkB;AAAA,IAC7C;AAEA,WACE,oBAAC,QAAK,SACH,eAAK,SAAS,IAAI,CAAC,SAAS,MAC3B,oBAAC,KAAK,MAAL,EAA4B,SAAkB,MAAM,KAAK,SAAS,OAAO,GACxE,8BAAC,WAAQ,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,IAAI,SAAyB,IAAI;AAC3D,QAAM,gBAAgB,SAAS;AAAA,IAC7B,SAAS;AAAA,IACT,UAAU;AAAA,IACV,OAAO;AAAA,EACT,CAAC;AAED,YAAU,MAAM;AACd,QAAI,WAAW,QAAQ,WAAW;AAAM;AAExC,WAAO,aAAa;AAAA,MAClB;AAAA,MACA,kBAAkB,cAAY,QAAQ,wBAAwB,QAAQ;AAAA,IACxE,CAAC;AAAA,EACH,GAAG,CAAC,SAAS,OAAO,CAAC;AAErB,SACE,oBAAC,MAAI,GAAG,aAAa,KAAK,YAAY,WAAW,GAAG,eAAe,SAAS,GACzE,UACH;AAEJ;AAEA,KAAK,cAAc;AAEnB,KAAK,OAAO;AAcZ,SAAS,SAAwC;AAAA,EAC/C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAA4F;AAC1F,QAAM,KAAK,MAAM;AACjB,QAAM,CAAC,SAAS,UAAU,IAAI,SAAyB,IAAI;AAC3D,QAAM,gBAAgB,SAAS;AAAA,IAC7B,SAAS;AAAA,IACT,GAAG,mBAAmB,CAAC,IAAI,GAAG,CAAC,CAAC,EAAE,QAAQ,IAAI,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,MAAM;AACvE,YAAM,CAAC,UAAU,WAAW,IAAI,WAAW,OAAO,KAAK;AACvD,YAAM,OAAO,MAAM,QAAQ,EAAE,WAAW;AACxC,YAAM,YAAY,gBAAgB,OAAO,OAAO,QAAQ,CAAC,CAAC;AAE1D,aAAO,SAAS,IAAI,EAAE,SAAS,OAAO,IAAI,EAAE,WAAW,UAAU,UAAU;AAAA,IAC7E,CAAC;AAAA,EACH,CAAC;AAED,YAAU,MAAM;AACd,QAAI,WAAW,QAAQ,WAAW;AAAM;AAExC,WAAO,aAAa;AAAA,MAClB;AAAA,MACA,kBAAkB,cAAY,QAAQ,mBAAmB,OAAO,QAAQ;AAAA,IAC1E,CAAC;AAAA,EACH,GAAG,CAAC,SAAS,SAAS,KAAK,CAAC;AAE5B,SACE,oBAAC,MAAI,GAAG,aAAa,KAAK,YAAY,WAAW,GAAG,eAAe,SAAS,GACzE,UACH;AAEJ;AAMA,SAAS,gBAAgB,EAAE,QAAQ,GAAoC;AACrE,QAAM,CAAC,SAAS,UAAU,IAAI,SAAyB,IAAI;AAE3D,YAAU,MAAM;AACd,QAAI,WAAW,QAAQ,WAAW;AAAM;AAExC,WAAO,aAAa;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,WAAW,SAAS;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,WAAW,SAAS,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,SAAS,cAAyB;AAIlC,SAAS,uBAAuB;AAEhC,YAAY,eAAe;AAC3B,SAAS,0BAA4C;AAErD,SAAS,gBAAgB;AAEzB,SAAS,mCAAmC;AAC5C,SAAS,wBAAwB;AAOjC,SAAS,eACP,aACgF;AAChF,QAAM,QAAQ,SAAS;AACvB,QAAM,MAAM,UAAU,sCAAsC,MAAM,SAAS,GAAG,WAAW,KAAK,CAAC;AAC/F,SAAO,OAAO,gBAAgB,KAAK,kBAAkB,CAAC,EAAE;AAC1D;AAEO,SAAS,aAAa,EAAE,SAAS,UAAU,gBAAgB,GAA+B;AAC/F,QAAM,CAAC,mBAAmB,WAAW,IAAI,eAAe,QAAQ,IAAI;AAEpE,QAAM,gBAAgB,iBAAiB,aAAa,QAAQ,OAAO,QAAQ,GAAG;AAE9E,QAAM,WAAW,OAAO,QAAQ,iBAAiB,EAAE;AAAA,IACjD,CAACA,WAAU,CAAC,UAAU,UAAU,MAC9B,WACE,4BAA4B,YAAY,UAAU,QAAQ,MAAM,QAAQ,GAAG,OAAOA,SAAQ;AAAA,IAC9F;AAAA,EACF;AAEA,SAAO,SAAS,aAAa;AAC/B;","names":["renderFn"]}
|
|
@@ -11,6 +11,8 @@ function suppressWarningAndFindDomNode(instance) {
|
|
|
11
11
|
console.error = (...args) => {
|
|
12
12
|
if (typeof args[0] === "string" && args[0].includes("%s is deprecated in StrictMode."))
|
|
13
13
|
return;
|
|
14
|
+
if (typeof args[0] === "string" && args[0].includes("findDOMNode is deprecated"))
|
|
15
|
+
return;
|
|
14
16
|
return error.apply(console, args);
|
|
15
17
|
};
|
|
16
18
|
const foundDomNode = 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":"
|
|
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":"AA+CW;AA/CX;AAAA,EACE;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,mBAAmB;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,eAAe,YAAY,QAAQ;AAEzC,UAAQ,QAAQ;AAEhB,SAAO;AACT;AAOA,MAAM,kCAAkC,UAA0C;AAAA,EAChF,YAAY,OAAuC;AACjD,UAAM,KAAK;AAEX,SAAK,MAAM,SAAS,UAAU,MAAM,8BAA8B,IAAI;AAAA,EACxE;AAAA,EAEA,SAAS;AACP,WAAO,gCAAG,eAAK,MAAM,UAAS;AAAA,EAChC;AACF;AAMO,MAAM,cAAc;AAAA,EACzB,SAASA,aAAY,OAAO,KAAK;AAC/B,UAAM,iBAAiB,OAAoC,IAAI;AAE/D,wBAAoB,KAAK,MAAM,MAAM,eAAe,UAAU,KAAK,MAAM,CAAC,CAAC;AAE3E,WAAO,oBAAC,6BAA2B,GAAG,OAAO,UAAU,gBAAgB;AAAA,EACzE;AACF;","names":["FindDomNode"]}
|
|
@@ -14,7 +14,7 @@ function useSwatch(swatchId) {
|
|
|
14
14
|
}
|
|
15
15
|
function useSwatches(swatchIds) {
|
|
16
16
|
const client = useMakeswiftHostApiClient();
|
|
17
|
-
const lastSnapshot = useRef();
|
|
17
|
+
const lastSnapshot = useRef(null);
|
|
18
18
|
function getSnapshot() {
|
|
19
19
|
const swatches2 = swatchIds.map((swatchId) => client.readSwatch(swatchId));
|
|
20
20
|
if (lastSnapshot.current != null && lastSnapshot.current.length === swatches2.length && lastSnapshot.current.every((swatch, idx) => swatches2[idx] === swatch)) {
|
|
@@ -40,7 +40,7 @@ function useFile(fileId) {
|
|
|
40
40
|
}
|
|
41
41
|
function useFiles(fileIds) {
|
|
42
42
|
const client = useMakeswiftHostApiClient();
|
|
43
|
-
const lastSnapshot = useRef();
|
|
43
|
+
const lastSnapshot = useRef(null);
|
|
44
44
|
function getSnapshot() {
|
|
45
45
|
const files2 = fileIds.map((fileId) => client.readFile(fileId));
|
|
46
46
|
if (lastSnapshot.current != null && lastSnapshot.current.length === files2.length && lastSnapshot.current.every((file, idx) => files2[idx] === file)) {
|