@makeswift/runtime 0.25.0-canary.13 → 0.25.0-canary.14
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/site-version/index.js +103 -0
- package/dist/cjs/api/site-version/index.js.map +1 -0
- package/dist/cjs/api-handler/handlers/manifest.js +2 -3
- package/dist/cjs/api-handler/handlers/manifest.js.map +1 -1
- package/dist/cjs/api-handler/handlers/{clear-draft.js → redirect-live.js} +19 -10
- package/dist/cjs/api-handler/handlers/redirect-live.js.map +1 -0
- package/dist/cjs/api-handler/index.js +6 -5
- package/dist/cjs/api-handler/index.js.map +1 -1
- package/dist/cjs/api-handler/request-response.js +9 -0
- package/dist/cjs/api-handler/request-response.js.map +1 -1
- package/dist/cjs/client/index.js +67 -59
- package/dist/cjs/client/index.js.map +1 -1
- package/dist/cjs/components/builtin/Root/Root.js +4 -4
- package/dist/cjs/components/builtin/Root/Root.js.map +1 -1
- package/dist/cjs/components/builtin/Video/Video.js +3 -13
- package/dist/cjs/components/builtin/Video/Video.js.map +1 -1
- package/dist/cjs/components/hooks/useMediaQuery.js +1 -2
- package/dist/cjs/components/hooks/useMediaQuery.js.map +1 -1
- package/dist/cjs/components/shared/BackgroundsContainer/components/BackgroundVideo/index.js +3 -13
- package/dist/cjs/components/shared/BackgroundsContainer/components/BackgroundVideo/index.js.map +1 -1
- package/dist/cjs/components/shared/react-player.js +41 -0
- package/dist/cjs/components/shared/react-player.js.map +1 -0
- package/dist/cjs/next/api-handler/config/app-router.js +7 -9
- package/dist/cjs/next/api-handler/config/app-router.js.map +1 -1
- package/dist/cjs/next/api-handler/config/pages-router.js +7 -9
- package/dist/cjs/next/api-handler/config/pages-router.js.map +1 -1
- package/dist/cjs/next/api-handler/handlers/{redirect-draft.js → app-router-redirect-preview.js} +30 -26
- package/dist/cjs/next/api-handler/handlers/app-router-redirect-preview.js.map +1 -0
- package/dist/cjs/next/api-handler/handlers/{redirect-preview.js → pages-router-redirect-preview.js} +29 -22
- package/dist/cjs/next/api-handler/handlers/pages-router-redirect-preview.js.map +1 -0
- package/dist/cjs/next/api-handler/index.js +1 -1
- package/dist/cjs/next/api-handler/index.js.map +1 -1
- package/dist/cjs/next/api-handler/{draft.js → preview.js} +14 -9
- package/dist/cjs/next/api-handler/preview.js.map +1 -0
- package/dist/cjs/next/{draft-mode/index.js → app-router-site-version.js} +11 -27
- package/dist/cjs/next/app-router-site-version.js.map +1 -0
- package/dist/cjs/next/client.js +9 -3
- package/dist/cjs/next/client.js.map +1 -1
- package/dist/cjs/next/components/framework-provider/index.js.map +1 -1
- package/dist/cjs/next/components/page.js +1 -1
- package/dist/cjs/next/components/page.js.map +1 -1
- package/dist/cjs/next/index.js.map +1 -1
- package/dist/cjs/next/middleware/request-utils.js +11 -17
- package/dist/cjs/next/middleware/request-utils.js.map +1 -1
- package/dist/cjs/next/root-style-registry.js +13 -20
- package/dist/cjs/next/root-style-registry.js.map +1 -1
- package/dist/cjs/next/server.js +2 -2
- package/dist/cjs/next/server.js.map +1 -1
- package/dist/cjs/next/testing/page-rendering.js +2 -2
- package/dist/cjs/next/testing/page-rendering.js.map +1 -1
- package/dist/cjs/next/testing/react-provider.js +2 -2
- package/dist/cjs/next/testing/react-provider.js.map +1 -1
- package/dist/cjs/next/tests/test-utils.js +6 -4
- package/dist/cjs/next/tests/test-utils.js.map +1 -1
- package/dist/cjs/runtimes/react/components/RuntimeProvider.js +7 -9
- package/dist/cjs/runtimes/react/components/RuntimeProvider.js.map +1 -1
- package/dist/cjs/runtimes/react/components/framework-context.js +1 -1
- package/dist/cjs/runtimes/react/components/framework-context.js.map +1 -1
- package/dist/cjs/runtimes/react/components/page/index.js +18 -16
- package/dist/cjs/runtimes/react/components/page/index.js.map +1 -1
- package/dist/cjs/runtimes/react/components/{draft-switcher/draft-switcher.js → preview-switcher/preview-switcher.js} +12 -22
- package/dist/cjs/runtimes/react/components/preview-switcher/preview-switcher.js.map +1 -0
- package/dist/cjs/runtimes/react/components/{draft-switcher/draft-toolbar.js → preview-switcher/preview-toolbar.js} +17 -9
- package/dist/cjs/runtimes/react/components/preview-switcher/preview-toolbar.js.map +1 -0
- package/dist/cjs/runtimes/react/hooks/makeswift-api.js +9 -10
- package/dist/cjs/runtimes/react/hooks/makeswift-api.js.map +1 -1
- package/dist/cjs/runtimes/react/hooks/use-selector.js +1 -1
- package/dist/cjs/runtimes/react/hooks/use-selector.js.map +1 -1
- package/dist/cjs/runtimes/react/root-style-registry.js +24 -13
- package/dist/cjs/runtimes/react/root-style-registry.js.map +1 -1
- package/dist/cjs/{next/preview-mode.js → testing/fixtures.js} +16 -18
- package/dist/cjs/testing/fixtures.js.map +1 -0
- package/dist/cjs/utils/esm-compat.js +29 -0
- package/dist/cjs/utils/esm-compat.js.map +1 -0
- package/dist/esm/api/site-version/index.js +75 -0
- package/dist/esm/api/site-version/index.js.map +1 -0
- package/dist/esm/api-handler/handlers/manifest.js +2 -3
- package/dist/esm/api-handler/handlers/manifest.js.map +1 -1
- package/dist/esm/api-handler/handlers/redirect-live.js +26 -0
- package/dist/esm/api-handler/handlers/redirect-live.js.map +1 -0
- package/dist/esm/api-handler/index.js +7 -6
- package/dist/esm/api-handler/index.js.map +1 -1
- package/dist/esm/api-handler/request-response.js +9 -0
- package/dist/esm/api-handler/request-response.js.map +1 -1
- package/dist/esm/client/index.js +65 -58
- package/dist/esm/client/index.js.map +1 -1
- package/dist/esm/components/builtin/Root/Root.js +4 -4
- package/dist/esm/components/builtin/Root/Root.js.map +1 -1
- package/dist/esm/components/builtin/Video/Video.js +1 -1
- package/dist/esm/components/builtin/Video/Video.js.map +1 -1
- package/dist/esm/components/hooks/useMediaQuery.js +1 -2
- package/dist/esm/components/hooks/useMediaQuery.js.map +1 -1
- package/dist/esm/components/shared/BackgroundsContainer/components/BackgroundVideo/index.js +1 -1
- package/dist/esm/components/shared/BackgroundsContainer/components/BackgroundVideo/index.js.map +1 -1
- package/dist/esm/components/shared/react-player.js +7 -0
- package/dist/esm/components/shared/react-player.js.map +1 -0
- package/dist/esm/next/api-handler/config/app-router.js +7 -9
- package/dist/esm/next/api-handler/config/app-router.js.map +1 -1
- package/dist/esm/next/api-handler/config/pages-router.js +7 -9
- package/dist/esm/next/api-handler/config/pages-router.js.map +1 -1
- package/dist/esm/next/api-handler/handlers/app-router-redirect-preview.js +64 -0
- package/dist/esm/next/api-handler/handlers/app-router-redirect-preview.js.map +1 -0
- package/dist/esm/next/api-handler/handlers/pages-router-redirect-preview.js +52 -0
- package/dist/esm/next/api-handler/handlers/pages-router-redirect-preview.js.map +1 -0
- package/dist/esm/next/api-handler/index.js +1 -1
- package/dist/esm/next/api-handler/index.js.map +1 -1
- package/dist/esm/next/api-handler/preview.js +18 -0
- package/dist/esm/next/api-handler/preview.js.map +1 -0
- package/dist/esm/next/app-router-site-version.js +16 -0
- package/dist/esm/next/app-router-site-version.js.map +1 -0
- package/dist/esm/next/client.js +10 -4
- package/dist/esm/next/client.js.map +1 -1
- package/dist/esm/next/components/framework-provider/index.js.map +1 -1
- package/dist/esm/next/components/page.js +2 -4
- package/dist/esm/next/components/page.js.map +1 -1
- package/dist/esm/next/index.js.map +1 -1
- package/dist/esm/next/middleware/request-utils.js +14 -17
- package/dist/esm/next/middleware/request-utils.js.map +1 -1
- package/dist/esm/next/root-style-registry.js +12 -17
- package/dist/esm/next/root-style-registry.js.map +1 -1
- package/dist/esm/next/server.js +1 -1
- package/dist/esm/next/server.js.map +1 -1
- package/dist/esm/next/testing/page-rendering.js +2 -2
- package/dist/esm/next/testing/page-rendering.js.map +1 -1
- package/dist/esm/next/testing/react-provider.js +2 -2
- package/dist/esm/next/testing/react-provider.js.map +1 -1
- package/dist/esm/next/tests/test-utils.js +6 -4
- package/dist/esm/next/tests/test-utils.js.map +1 -1
- package/dist/esm/runtimes/react/components/RuntimeProvider.js +7 -9
- package/dist/esm/runtimes/react/components/RuntimeProvider.js.map +1 -1
- package/dist/esm/runtimes/react/components/framework-context.js +5 -2
- package/dist/esm/runtimes/react/components/framework-context.js.map +1 -1
- package/dist/esm/runtimes/react/components/page/index.js +19 -17
- package/dist/esm/runtimes/react/components/page/index.js.map +1 -1
- package/dist/esm/runtimes/react/components/{draft-switcher/draft-switcher.js → preview-switcher/preview-switcher.js} +8 -18
- package/dist/esm/runtimes/react/components/preview-switcher/preview-switcher.js.map +1 -0
- package/dist/esm/runtimes/react/components/{draft-switcher/draft-toolbar.js → preview-switcher/preview-toolbar.js} +13 -5
- package/dist/esm/runtimes/react/components/preview-switcher/preview-toolbar.js.map +1 -0
- package/dist/esm/runtimes/react/hooks/makeswift-api.js +1 -2
- package/dist/esm/runtimes/react/hooks/makeswift-api.js.map +1 -1
- package/dist/esm/runtimes/react/hooks/use-selector.js +1 -1
- package/dist/esm/runtimes/react/hooks/use-selector.js.map +1 -1
- package/dist/esm/runtimes/react/root-style-registry.js +24 -13
- package/dist/esm/runtimes/react/root-style-registry.js.map +1 -1
- package/dist/esm/testing/fixtures.js +13 -0
- package/dist/esm/testing/fixtures.js.map +1 -0
- package/dist/esm/utils/esm-compat.js +5 -0
- package/dist/esm/utils/esm-compat.js.map +1 -0
- package/dist/types/api/site-version/index.d.ts +19 -0
- package/dist/types/api/site-version/index.d.ts.map +1 -0
- package/dist/types/api/site-version/site-version.test.d.ts +2 -0
- package/dist/types/api/site-version/site-version.test.d.ts.map +1 -0
- package/dist/types/api-handler/handlers/manifest.d.ts +0 -2
- package/dist/types/api-handler/handlers/manifest.d.ts.map +1 -1
- package/dist/types/api-handler/handlers/redirect-live.d.ts +5 -0
- package/dist/types/api-handler/handlers/redirect-live.d.ts.map +1 -0
- package/dist/types/api-handler/index.d.ts +4 -4
- package/dist/types/api-handler/index.d.ts.map +1 -1
- package/dist/types/api-handler/request-response.d.ts +1 -0
- package/dist/types/api-handler/request-response.d.ts.map +1 -1
- package/dist/types/client/index.d.ts +32 -23
- package/dist/types/client/index.d.ts.map +1 -1
- package/dist/types/components/builtin/Root/Root.d.ts +1 -1
- package/dist/types/components/builtin/Root/Root.d.ts.map +1 -1
- package/dist/types/components/hooks/useMediaQuery.d.ts.map +1 -1
- package/dist/types/components/shared/BackgroundsContainer/components/BackgroundVideo/index.d.ts.map +1 -1
- package/dist/types/components/shared/react-player.d.ts +3 -0
- package/dist/types/components/shared/react-player.d.ts.map +1 -0
- package/dist/types/next/api-handler/config/app-router.d.ts +3 -2
- package/dist/types/next/api-handler/config/app-router.d.ts.map +1 -1
- package/dist/types/next/api-handler/config/pages-router.d.ts +3 -2
- package/dist/types/next/api-handler/config/pages-router.d.ts.map +1 -1
- package/dist/types/next/api-handler/handlers/app-router-redirect-preview.d.ts +5 -0
- package/dist/types/next/api-handler/handlers/app-router-redirect-preview.d.ts.map +1 -0
- package/dist/types/next/api-handler/handlers/app-router-redirect-preview.test.d.ts +2 -0
- package/dist/types/next/api-handler/handlers/app-router-redirect-preview.test.d.ts.map +1 -0
- package/dist/types/next/api-handler/handlers/pages-router-redirect-preview.d.ts +4 -0
- package/dist/types/next/api-handler/handlers/pages-router-redirect-preview.d.ts.map +1 -0
- package/dist/types/next/api-handler/preview.d.ts +11 -0
- package/dist/types/next/api-handler/preview.d.ts.map +1 -0
- package/dist/types/next/app-router-site-version.d.ts +3 -0
- package/dist/types/next/app-router-site-version.d.ts.map +1 -0
- package/dist/types/next/client.d.ts +3 -3
- package/dist/types/next/client.d.ts.map +1 -1
- package/dist/types/next/components/page.d.ts +2 -6
- package/dist/types/next/components/page.d.ts.map +1 -1
- package/dist/types/next/index.d.ts +1 -1
- package/dist/types/next/index.d.ts.map +1 -1
- package/dist/types/next/middleware/request-utils.d.ts +1 -0
- package/dist/types/next/middleware/request-utils.d.ts.map +1 -1
- package/dist/types/next/root-style-registry.d.ts +3 -12
- package/dist/types/next/root-style-registry.d.ts.map +1 -1
- package/dist/types/next/server.d.ts +1 -1
- package/dist/types/next/server.d.ts.map +1 -1
- package/dist/types/next/testing/react-provider.d.ts +3 -2
- package/dist/types/next/testing/react-provider.d.ts.map +1 -1
- package/dist/types/next/tests/server.api-handler-app-router-redirect-preview.test.d.ts +2 -0
- package/dist/types/next/tests/server.api-handler-app-router-redirect-preview.test.d.ts.map +1 -0
- package/dist/types/next/tests/server.api-handler-pages-router-redirect-preview.test.d.ts +2 -0
- package/dist/types/next/tests/server.api-handler-pages-router-redirect-preview.test.d.ts.map +1 -0
- package/dist/types/next/tests/server.api-handler-redirect-live.test.d.ts +2 -0
- package/dist/types/next/tests/server.api-handler-redirect-live.test.d.ts.map +1 -0
- package/dist/types/next/tests/test-utils.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/RuntimeProvider.d.ts +3 -2
- package/dist/types/runtimes/react/components/RuntimeProvider.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/framework-context.d.ts +2 -2
- package/dist/types/runtimes/react/components/framework-context.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/page/index.d.ts +23 -3
- package/dist/types/runtimes/react/components/page/index.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/preview-switcher/preview-switcher.d.ts +4 -0
- package/dist/types/runtimes/react/components/preview-switcher/preview-switcher.d.ts.map +1 -0
- package/dist/types/runtimes/react/components/preview-switcher/preview-toolbar.d.ts +2 -0
- package/dist/types/runtimes/react/components/preview-switcher/preview-toolbar.d.ts.map +1 -0
- package/dist/types/runtimes/react/hooks/makeswift-api.d.ts.map +1 -1
- package/dist/types/runtimes/react/hooks/use-selector.d.ts.map +1 -1
- package/dist/types/runtimes/react/root-style-registry.d.ts +23 -11
- package/dist/types/runtimes/react/root-style-registry.d.ts.map +1 -1
- package/dist/types/testing/fixtures.d.ts +7 -0
- package/dist/types/testing/fixtures.d.ts.map +1 -0
- package/dist/types/utils/esm-compat.d.ts +2 -0
- package/dist/types/utils/esm-compat.d.ts.map +1 -0
- package/package.json +6 -5
- package/dist/cjs/api/site-version.js +0 -42
- package/dist/cjs/api/site-version.js.map +0 -1
- package/dist/cjs/api-handler/handlers/clear-draft.js.map +0 -1
- package/dist/cjs/next/api-handler/draft.js.map +0 -1
- package/dist/cjs/next/api-handler/handlers/redirect-draft.js.map +0 -1
- package/dist/cjs/next/api-handler/handlers/redirect-preview.js.map +0 -1
- package/dist/cjs/next/draft-mode/index.js.map +0 -1
- package/dist/cjs/next/preview-mode.js.map +0 -1
- package/dist/cjs/runtimes/react/components/draft-switcher/draft-switcher.js.map +0 -1
- package/dist/cjs/runtimes/react/components/draft-switcher/draft-toolbar.js.map +0 -1
- package/dist/esm/api/site-version.js +0 -15
- package/dist/esm/api/site-version.js.map +0 -1
- package/dist/esm/api-handler/handlers/clear-draft.js +0 -17
- package/dist/esm/api-handler/handlers/clear-draft.js.map +0 -1
- package/dist/esm/next/api-handler/draft.js +0 -14
- package/dist/esm/next/api-handler/draft.js.map +0 -1
- package/dist/esm/next/api-handler/handlers/redirect-draft.js +0 -52
- package/dist/esm/next/api-handler/handlers/redirect-draft.js.map +0 -1
- package/dist/esm/next/api-handler/handlers/redirect-preview.js +0 -37
- package/dist/esm/next/api-handler/handlers/redirect-preview.js.map +0 -1
- package/dist/esm/next/draft-mode/index.js +0 -30
- package/dist/esm/next/draft-mode/index.js.map +0 -1
- package/dist/esm/next/preview-mode.js +0 -16
- package/dist/esm/next/preview-mode.js.map +0 -1
- package/dist/esm/runtimes/react/components/draft-switcher/draft-switcher.js.map +0 -1
- package/dist/esm/runtimes/react/components/draft-switcher/draft-toolbar.js.map +0 -1
- package/dist/types/api/site-version.d.ts +0 -7
- package/dist/types/api/site-version.d.ts.map +0 -1
- package/dist/types/api-handler/handlers/clear-draft.d.ts +0 -7
- package/dist/types/api-handler/handlers/clear-draft.d.ts.map +0 -1
- package/dist/types/next/api-handler/draft.d.ts +0 -8
- package/dist/types/next/api-handler/draft.d.ts.map +0 -1
- package/dist/types/next/api-handler/handlers/redirect-draft.d.ts +0 -6
- package/dist/types/next/api-handler/handlers/redirect-draft.d.ts.map +0 -1
- package/dist/types/next/api-handler/handlers/redirect-draft.test.d.ts +0 -2
- package/dist/types/next/api-handler/handlers/redirect-draft.test.d.ts.map +0 -1
- package/dist/types/next/api-handler/handlers/redirect-preview.d.ts +0 -5
- package/dist/types/next/api-handler/handlers/redirect-preview.d.ts.map +0 -1
- package/dist/types/next/draft-mode/index.d.ts +0 -15
- package/dist/types/next/draft-mode/index.d.ts.map +0 -1
- package/dist/types/next/preview-mode.d.ts +0 -17
- package/dist/types/next/preview-mode.d.ts.map +0 -1
- package/dist/types/next/tests/server.api-handler-clear-draft.test.d.ts +0 -2
- package/dist/types/next/tests/server.api-handler-clear-draft.test.d.ts.map +0 -1
- package/dist/types/next/tests/server.api-handler-redirect-draft.test.d.ts +0 -2
- package/dist/types/next/tests/server.api-handler-redirect-draft.test.d.ts.map +0 -1
- package/dist/types/next/tests/server.api-handler-redirect-preview.test.d.ts +0 -2
- package/dist/types/next/tests/server.api-handler-redirect-preview.test.d.ts.map +0 -1
- package/dist/types/runtimes/react/components/draft-switcher/draft-switcher.d.ts +0 -4
- package/dist/types/runtimes/react/components/draft-switcher/draft-switcher.d.ts.map +0 -1
- package/dist/types/runtimes/react/components/draft-switcher/draft-toolbar.d.ts +0 -6
- package/dist/types/runtimes/react/components/draft-switcher/draft-toolbar.d.ts.map +0 -1
|
@@ -39,7 +39,7 @@ async function testMakeswiftPageHeadRendering(props, { forcePagesRouter = false
|
|
|
39
39
|
});
|
|
40
40
|
return await (0, import_test_utils.act)(
|
|
41
41
|
async () => (0, import_react2.render)(
|
|
42
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_provider.ReactProvider, { runtime,
|
|
42
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_provider.ReactProvider, { runtime, siteVersion: null, forcePagesRouter, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_page.Page, { ...props }) }),
|
|
43
43
|
{
|
|
44
44
|
container: document.body.appendChild(document.createElement("head"))
|
|
45
45
|
}
|
|
@@ -50,7 +50,7 @@ async function testMakeswiftPageRendering(props, { forcePagesRouter = false } =
|
|
|
50
50
|
const runtime = new import_react_runtime.ReactRuntime();
|
|
51
51
|
return await (0, import_test_utils.act)(
|
|
52
52
|
async () => (0, import_react2.render)(
|
|
53
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_provider.ReactProvider, { runtime,
|
|
53
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_provider.ReactProvider, { runtime, siteVersion: null, forcePagesRouter, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_page.Page, { ...props }) }),
|
|
54
54
|
{
|
|
55
55
|
container: document.body.appendChild(document.createElement("div"))
|
|
56
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/next/testing/page-rendering.tsx"],"sourcesContent":["import { type ComponentPropsWithoutRef } from 'react'\n\nimport '@testing-library/jest-dom'\nimport { act } from 'react-dom/test-utils'\nimport { render } from '@testing-library/react'\n\nimport { ReactRuntime } from '../../runtimes/react/react-runtime'\nimport { MakeswiftComponentType } from '../../components'\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}
|
|
1
|
+
{"version":3,"sources":["../../../../src/next/testing/page-rendering.tsx"],"sourcesContent":["import { type ComponentPropsWithoutRef } from 'react'\n\nimport '@testing-library/jest-dom'\nimport { act } from 'react-dom/test-utils'\nimport { render } from '@testing-library/react'\n\nimport { ReactRuntime } from '../../runtimes/react/react-runtime'\nimport { MakeswiftComponentType } from '../../components'\n\nimport { Page as MakeswiftPage } from '../components/page'\n\nimport { ReactProvider } from './react-provider'\n\nexport async function testMakeswiftPageHeadRendering(\n props: ComponentPropsWithoutRef<typeof MakeswiftPage>,\n { forcePagesRouter = false }: { forcePagesRouter?: boolean } = {},\n) {\n const runtime = new ReactRuntime()\n\n runtime.registerComponent(() => <></>, {\n type: MakeswiftComponentType.Root,\n label: 'Root',\n props: {},\n })\n\n return await act(async () =>\n render(\n <ReactProvider runtime={runtime} siteVersion={null} forcePagesRouter={forcePagesRouter}>\n <MakeswiftPage {...props} />\n </ReactProvider>,\n {\n container: document.body.appendChild(document.createElement('head')),\n },\n ),\n )\n}\n\nexport async function testMakeswiftPageRendering(\n props: ComponentPropsWithoutRef<typeof MakeswiftPage>,\n { forcePagesRouter = false }: { forcePagesRouter?: boolean } = {},\n) {\n const runtime = new ReactRuntime()\n\n return await act(async () =>\n render(\n <ReactProvider runtime={runtime} siteVersion={null} forcePagesRouter={forcePagesRouter}>\n <MakeswiftPage {...props} />\n </ReactProvider>,\n {\n container: document.body.appendChild(document.createElement('div')),\n },\n ),\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmBkC;AAjBlC,sBAAO;AACP,wBAAoB;AACpB,IAAAA,gBAAuB;AAEvB,2BAA6B;AAC7B,wBAAuC;AAEvC,kBAAsC;AAEtC,4BAA8B;AAE9B,eAAsB,+BACpB,OACA,EAAE,mBAAmB,MAAM,IAAoC,CAAC,GAChE;AACA,QAAM,UAAU,IAAI,kCAAa;AAEjC,UAAQ,kBAAkB,MAAM,2EAAE,GAAK;AAAA,IACrC,MAAM,yCAAuB;AAAA,IAC7B,OAAO;AAAA,IACP,OAAO,CAAC;AAAA,EACV,CAAC;AAED,SAAO,UAAM;AAAA,IAAI,gBACf;AAAA,MACE,4CAAC,uCAAc,SAAkB,aAAa,MAAM,kBAClD,sDAAC,YAAAC,MAAA,EAAe,GAAG,OAAO,GAC5B;AAAA,MACA;AAAA,QACE,WAAW,SAAS,KAAK,YAAY,SAAS,cAAc,MAAM,CAAC;AAAA,MACrE;AAAA,IACF;AAAA,EACF;AACF;AAEA,eAAsB,2BACpB,OACA,EAAE,mBAAmB,MAAM,IAAoC,CAAC,GAChE;AACA,QAAM,UAAU,IAAI,kCAAa;AAEjC,SAAO,UAAM;AAAA,IAAI,gBACf;AAAA,MACE,4CAAC,uCAAc,SAAkB,aAAa,MAAM,kBAClD,sDAAC,YAAAA,MAAA,EAAe,GAAG,OAAO,GAC5B;AAAA,MACA;AAAA,QACE,WAAW,SAAS,KAAK,YAAY,SAAS,cAAc,KAAK,CAAC;AAAA,MACpE;AAAA,IACF;AAAA,EACF;AACF;","names":["import_react","MakeswiftPage"]}
|
|
@@ -28,10 +28,10 @@ var import_root_style_registry = require("../root-style-registry");
|
|
|
28
28
|
function ReactProvider({
|
|
29
29
|
children,
|
|
30
30
|
runtime,
|
|
31
|
-
|
|
31
|
+
siteVersion = null,
|
|
32
32
|
forcePagesRouter = false
|
|
33
33
|
}) {
|
|
34
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_framework_provider.FrameworkProvider, { forcePagesRouter, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_RuntimeProvider.RuntimeProvider, {
|
|
34
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_framework_provider.FrameworkProvider, { forcePagesRouter, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_RuntimeProvider.RuntimeProvider, { siteVersion, runtime, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_root_style_registry.NextRootStyleRegistry, { children }) }) });
|
|
35
35
|
}
|
|
36
36
|
// Annotate the CommonJS export names for ESM import in node:
|
|
37
37
|
0 && (module.exports = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/next/testing/react-provider.tsx"],"sourcesContent":["import { ReactRuntime } from '../../runtimes/react/react-runtime'\nimport { RuntimeProvider } from '../../runtimes/react/components/RuntimeProvider'\n\nimport { FrameworkProvider } from '../components/framework-provider'\nimport { NextRootStyleRegistry } from '../root-style-registry'\n\nexport function ReactProvider({\n children,\n runtime,\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/next/testing/react-provider.tsx"],"sourcesContent":["import { ReactRuntime } from '../../runtimes/react/react-runtime'\nimport { RuntimeProvider } from '../../runtimes/react/components/RuntimeProvider'\n\nimport { FrameworkProvider } from '../components/framework-provider'\nimport { NextRootStyleRegistry } from '../root-style-registry'\nimport { SiteVersion } from '../../api/site-version'\n\nexport function ReactProvider({\n children,\n runtime,\n siteVersion = null,\n forcePagesRouter = false,\n}: {\n children: React.ReactNode\n runtime: ReactRuntime\n siteVersion?: SiteVersion | null\n forcePagesRouter?: boolean\n}) {\n return (\n <FrameworkProvider forcePagesRouter={forcePagesRouter}>\n <RuntimeProvider siteVersion={siteVersion} runtime={runtime}>\n <NextRootStyleRegistry>{children}</NextRootStyleRegistry>\n </RuntimeProvider>\n </FrameworkProvider>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAqBQ;AApBR,6BAAgC;AAEhC,gCAAkC;AAClC,iCAAsC;AAG/B,SAAS,cAAc;AAAA,EAC5B;AAAA,EACA;AAAA,EACA,cAAc;AAAA,EACd,mBAAmB;AACrB,GAKG;AACD,SACE,4CAAC,+CAAkB,kBACjB,sDAAC,0CAAgB,aAA0B,SACzC,sDAAC,oDAAuB,UAAS,GACnC,GACF;AAEJ;","names":[]}
|
|
@@ -28,13 +28,15 @@ var import_server = require("next/server");
|
|
|
28
28
|
var import_node_mocks_http = require("node-mocks-http");
|
|
29
29
|
var import_api_handler = require("../api-handler");
|
|
30
30
|
var import_react = require("../../react");
|
|
31
|
+
var import_fixtures = require("../../testing/fixtures");
|
|
32
|
+
var import_preview = require("../api-handler/preview");
|
|
31
33
|
function createHandler(apiKey, args = {}) {
|
|
32
34
|
const runtime = new import_react.ReactRuntime();
|
|
33
35
|
return (0, import_api_handler.MakeswiftApiHandler)(apiKey, {
|
|
34
36
|
...args,
|
|
35
37
|
runtime,
|
|
36
|
-
apiOrigin:
|
|
37
|
-
appOrigin:
|
|
38
|
+
apiOrigin: import_fixtures.TestOrigins.apiOrigin,
|
|
39
|
+
appOrigin: import_fixtures.TestOrigins.appOrigin
|
|
38
40
|
});
|
|
39
41
|
}
|
|
40
42
|
const hostUrl = (path) => new URL(path, "https://example.com");
|
|
@@ -56,7 +58,7 @@ function createNextApiRequest({
|
|
|
56
58
|
query: {
|
|
57
59
|
...routeParams(hostUrl(path)),
|
|
58
60
|
...Object.fromEntries(url.searchParams.entries()),
|
|
59
|
-
...originalPath ? {
|
|
61
|
+
...originalPath ? { [import_preview.RewriteRuleMatches.OriginalPath]: originalPath } : {}
|
|
60
62
|
},
|
|
61
63
|
body,
|
|
62
64
|
headers
|
|
@@ -95,7 +97,7 @@ function pagesRouterApiRequestFixture(args = {}, responseMock) {
|
|
|
95
97
|
return response._getHeaders()["set-cookie"];
|
|
96
98
|
},
|
|
97
99
|
get(key) {
|
|
98
|
-
return key.toLowerCase() === "location" ? response._getRedirectUrl() : response._getHeaders()[key];
|
|
100
|
+
return key.toLowerCase() === "location" ? response._getRedirectUrl() || response._getHeaders()["location"] : response._getHeaders()[key];
|
|
99
101
|
}
|
|
100
102
|
}
|
|
101
103
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/next/tests/test-utils.ts"],"sourcesContent":["import { NextApiRequest, NextApiResponse } from 'next'\nimport { NextRequest } from 'next/server'\nimport {\n createRequest,\n createResponse,\n type RequestMethod,\n type MockResponse,\n} from 'node-mocks-http'\n\nimport { MakeswiftApiHandler } from '../api-handler'\nimport { ReactRuntime } from '../../react'\n\nexport type MakeswiftApiHandlerArgs = Partial<Parameters<typeof MakeswiftApiHandler>[1]>\n\nfunction createHandler(apiKey: string, args: Partial<MakeswiftApiHandlerArgs> = {}) {\n const runtime = new ReactRuntime()\n return MakeswiftApiHandler(apiKey, {\n ...args,\n runtime,\n apiOrigin:
|
|
1
|
+
{"version":3,"sources":["../../../../src/next/tests/test-utils.ts"],"sourcesContent":["import { NextApiRequest, NextApiResponse } from 'next'\nimport { NextRequest } from 'next/server'\nimport {\n createRequest,\n createResponse,\n type RequestMethod,\n type MockResponse,\n} from 'node-mocks-http'\n\nimport { MakeswiftApiHandler } from '../api-handler'\nimport { ReactRuntime } from '../../react'\nimport { TestOrigins } from '../../testing/fixtures'\nimport { RewriteRuleMatches } from '../api-handler/preview'\n\nexport type MakeswiftApiHandlerArgs = Partial<Parameters<typeof MakeswiftApiHandler>[1]>\n\nfunction createHandler(apiKey: string, args: Partial<MakeswiftApiHandlerArgs> = {}) {\n const runtime = new ReactRuntime()\n return MakeswiftApiHandler(apiKey, {\n ...args,\n runtime,\n apiOrigin: TestOrigins.apiOrigin,\n appOrigin: TestOrigins.appOrigin,\n })\n}\n\nexport const hostUrl = (path: string) => new URL(path, 'https://example.com')\n\nfunction routeParams(url: URL) {\n // simulate Next.js API route's context params, e.g. /api/makeswift/revalidate -> { 'makeswift': ['revalidate'] }\n const segments = url.pathname.split('/').filter(Boolean).slice(1)\n return { [segments[0]]: segments.slice(1) }\n}\n\nexport type RequestParams = {\n method: RequestMethod\n path: string\n originalPath?: string\n body?: Record<string, unknown>\n headers?: Record<string, string>\n}\n\nfunction createNextApiRequest({\n method,\n path,\n originalPath,\n body,\n headers,\n}: RequestParams): NextApiRequest {\n const url = hostUrl(originalPath ?? path)\n return createRequest<NextApiRequest>({\n method,\n url: url.toString(),\n query: {\n ...routeParams(hostUrl(path)),\n ...Object.fromEntries(url.searchParams.entries()),\n ...(originalPath ? { [RewriteRuleMatches.OriginalPath]: originalPath } : {}),\n },\n body,\n headers,\n })\n}\n\nfunction createNextRequestWithContext({\n method,\n path,\n originalPath,\n body,\n headers,\n}: RequestParams): [NextRequest, { params: { [key: string]: string | string[] } }] {\n const request = new NextRequest(hostUrl(originalPath ?? path), {\n method,\n body: JSON.stringify(body),\n headers,\n })\n\n return [request, { params: routeParams(hostUrl(path)) }]\n}\n\nexport function pagesRouterApiRequestFixture(\n args: MakeswiftApiHandlerArgs = {},\n responseMock?: MockResponse<NextApiResponse>,\n) {\n const apiKey = 'pages-router-api-key'\n const handler = createHandler(apiKey, args)\n\n const response = responseMock ?? createResponse<NextApiResponse>()\n const testApiRequest = async (reqParams: RequestParams) => {\n await handler(createNextApiRequest(reqParams), response)\n return {\n statusCode: response.statusCode,\n get jsonBody() {\n return response._getJSONData()\n },\n get textBody() {\n return response._getData()\n },\n headers: {\n getSetCookie() {\n return response._getHeaders()['set-cookie']\n },\n get(key: string) {\n return key.toLowerCase() === 'location'\n ? response._getRedirectUrl() || response._getHeaders()['location']\n : response._getHeaders()[key]\n },\n },\n }\n }\n\n return { testApiRequest, apiKey }\n}\n\nexport function appRouterApiRequestFixture(args: MakeswiftApiHandlerArgs = {}) {\n const apiKey = 'app-router-api-key'\n const handler = createHandler(apiKey, args)\n const testApiRequest = async (reqParams: RequestParams) => {\n const response = await handler(...createNextRequestWithContext(reqParams))\n return {\n statusCode: response?.status,\n get jsonBody() {\n return response?.json()\n },\n get textBody() {\n return response?.text()\n },\n headers: response?.headers ?? new Headers(),\n }\n }\n\n return { testApiRequest, apiKey }\n}\n\nexport const apiRequestFixtures = [\n { fixture: pagesRouterApiRequestFixture, router: 'pages' },\n { fixture: appRouterApiRequestFixture, router: 'app' },\n]\n"],"mappings":"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","names":[]}
|
|
@@ -37,8 +37,7 @@ var import_react = require("react");
|
|
|
37
37
|
var import_react2 = require("../../../api/react");
|
|
38
38
|
var import_use_react_runtime = require("../hooks/use-react-runtime");
|
|
39
39
|
var import_host_api_client = require("../host-api-client");
|
|
40
|
-
var
|
|
41
|
-
var import_draft_switcher = require("./draft-switcher/draft-switcher");
|
|
40
|
+
var import_preview_switcher = require("./preview-switcher/preview-switcher");
|
|
42
41
|
var import_use_builder_connection_ping = require("./hooks/use-builder-connection-ping");
|
|
43
42
|
var import_use_framework_context = require("./hooks/use-framework-context");
|
|
44
43
|
const LiveProvider = (0, import_react.lazy)(() => Promise.resolve().then(() => __toESM(require("./LiveProvider"))));
|
|
@@ -46,7 +45,7 @@ const PreviewProvider = (0, import_react.lazy)(() => Promise.resolve().then(() =
|
|
|
46
45
|
function RuntimeProvider({
|
|
47
46
|
children,
|
|
48
47
|
runtime,
|
|
49
|
-
|
|
48
|
+
siteVersion,
|
|
50
49
|
appOrigin = "https://app.makeswift.com",
|
|
51
50
|
apiOrigin = "https://api.makeswift.com",
|
|
52
51
|
locale = void 0
|
|
@@ -56,17 +55,16 @@ function RuntimeProvider({
|
|
|
56
55
|
() => new import_react2.MakeswiftHostApiClient({
|
|
57
56
|
uri: new URL("graphql", apiOrigin).href,
|
|
58
57
|
locale,
|
|
59
|
-
fetch: versionedFetch(
|
|
60
|
-
previewMode ? import_site_version.MakeswiftSiteVersion.Working : import_site_version.MakeswiftSiteVersion.Live
|
|
61
|
-
)
|
|
58
|
+
fetch: versionedFetch(siteVersion)
|
|
62
59
|
}),
|
|
63
|
-
[apiOrigin, locale,
|
|
60
|
+
[apiOrigin, locale, siteVersion, versionedFetch]
|
|
64
61
|
);
|
|
65
|
-
const
|
|
62
|
+
const isPreview = siteVersion != null;
|
|
63
|
+
const StoreProvider = isPreview ? PreviewProvider : LiveProvider;
|
|
66
64
|
(0, import_use_builder_connection_ping.useBuilderConnectionPing)({ appOrigin });
|
|
67
65
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_use_react_runtime.ReactRuntimeContext.Provider, { value: runtime, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_host_api_client.MakeswiftHostApiClientProvider, { client, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(StoreProvider, { children: [
|
|
68
66
|
children,
|
|
69
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
67
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_preview_switcher.PreviewSwitcher, { isPreview })
|
|
70
68
|
] }) }) });
|
|
71
69
|
}
|
|
72
70
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/runtimes/react/components/RuntimeProvider.tsx"],"sourcesContent":["'use client'\n\nimport { ReactNode, useMemo, lazy } from 'react'\n\nimport { MakeswiftHostApiClient } from '../../../api/react'\nimport { ReactRuntimeContext } from '../hooks/use-react-runtime'\nimport { ReactRuntime } from '../react-runtime'\nimport { MakeswiftHostApiClientProvider } from '../host-api-client'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/components/RuntimeProvider.tsx"],"sourcesContent":["'use client'\n\nimport { ReactNode, useMemo, lazy } from 'react'\n\nimport { MakeswiftHostApiClient } from '../../../api/react'\nimport { ReactRuntimeContext } from '../hooks/use-react-runtime'\nimport { ReactRuntime } from '../react-runtime'\nimport { MakeswiftHostApiClientProvider } from '../host-api-client'\nimport { type SiteVersion } from '../../../api/site-version'\nimport { PreviewSwitcher } from './preview-switcher/preview-switcher'\nimport { useBuilderConnectionPing } from './hooks/use-builder-connection-ping'\nimport { useFrameworkContext } from './hooks/use-framework-context'\n\nconst LiveProvider = lazy(() => import('./LiveProvider'))\nconst PreviewProvider = lazy(() => import('./PreviewProvider'))\n\nexport function RuntimeProvider({\n children,\n runtime,\n siteVersion,\n appOrigin = 'https://app.makeswift.com',\n apiOrigin = 'https://api.makeswift.com',\n locale = undefined,\n}: {\n children: ReactNode\n runtime: ReactRuntime\n siteVersion: SiteVersion | null\n apiOrigin?: string\n appOrigin?: string\n locale?: string\n}) {\n const { versionedFetch } = useFrameworkContext()\n\n const client = useMemo(\n () =>\n new MakeswiftHostApiClient({\n uri: new URL('graphql', apiOrigin).href,\n locale,\n fetch: versionedFetch(siteVersion),\n }),\n [apiOrigin, locale, siteVersion, versionedFetch],\n )\n\n const isPreview = siteVersion != null\n const StoreProvider = isPreview ? PreviewProvider : LiveProvider\n\n useBuilderConnectionPing({ appOrigin })\n\n return (\n <ReactRuntimeContext.Provider value={runtime}>\n <MakeswiftHostApiClientProvider client={client}>\n <StoreProvider>\n {children}\n <PreviewSwitcher isPreview={isPreview} />\n </StoreProvider>\n </MakeswiftHostApiClientProvider>\n </ReactRuntimeContext.Provider>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAmDQ;AAjDR,mBAAyC;AAEzC,IAAAA,gBAAuC;AACvC,+BAAoC;AAEpC,6BAA+C;AAE/C,8BAAgC;AAChC,yCAAyC;AACzC,mCAAoC;AAEpC,MAAM,mBAAe,mBAAK,MAAM,6CAAO,gBAAgB,GAAC;AACxD,MAAM,sBAAkB,mBAAK,MAAM,6CAAO,mBAAmB,GAAC;AAEvD,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,SAAS;AACX,GAOG;AACD,QAAM,EAAE,eAAe,QAAI,kDAAoB;AAE/C,QAAM,aAAS;AAAA,IACb,MACE,IAAI,qCAAuB;AAAA,MACzB,KAAK,IAAI,IAAI,WAAW,SAAS,EAAE;AAAA,MACnC;AAAA,MACA,OAAO,eAAe,WAAW;AAAA,IACnC,CAAC;AAAA,IACH,CAAC,WAAW,QAAQ,aAAa,cAAc;AAAA,EACjD;AAEA,QAAM,YAAY,eAAe;AACjC,QAAM,gBAAgB,YAAY,kBAAkB;AAEpD,mEAAyB,EAAE,UAAU,CAAC;AAEtC,SACE,4CAAC,6CAAoB,UAApB,EAA6B,OAAO,SACnC,sDAAC,yDAA+B,QAC9B,uDAAC,iBACE;AAAA;AAAA,IACD,4CAAC,2CAAgB,WAAsB;AAAA,KACzC,GACF,GACF;AAEJ;","names":["import_react"]}
|
|
@@ -52,7 +52,7 @@ const versionedFetch = (siteVersion) => (url, init) => fetch(url, {
|
|
|
52
52
|
...init,
|
|
53
53
|
headers: {
|
|
54
54
|
...init?.headers,
|
|
55
|
-
[import_site_version.
|
|
55
|
+
...siteVersion != null ? { [import_site_version.ApiHandlerHeaders.SiteVersion]: (0, import_site_version.serializeSiteVersion)(siteVersion) } : {}
|
|
56
56
|
}
|
|
57
57
|
});
|
|
58
58
|
const FrameworkContext = (0, import_react.createContext)({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/runtimes/react/components/framework-context.tsx"],"sourcesContent":["import {\n createContext,\n type ReactNode,\n type PropsWithChildren,\n type CSSProperties,\n type ComponentPropsWithoutRef,\n type MouseEvent,\n type ForwardRefExoticComponent,\n type RefAttributes,\n forwardRef,\n} from 'react'\n\nimport { type LinkData } from '@makeswift/prop-controllers'\n\nimport { type Snippet } from '../../../client'\nimport { type HttpFetch } from '../../../state/makeswift-api-client'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/components/framework-context.tsx"],"sourcesContent":["import {\n createContext,\n type ReactNode,\n type PropsWithChildren,\n type CSSProperties,\n type ComponentPropsWithoutRef,\n type MouseEvent,\n type ForwardRefExoticComponent,\n type RefAttributes,\n forwardRef,\n} from 'react'\n\nimport { type LinkData } from '@makeswift/prop-controllers'\n\nimport { type Snippet } from '../../../client'\nimport { type HttpFetch } from '../../../state/makeswift-api-client'\nimport {\n ApiHandlerHeaders,\n serializeSiteVersion,\n type SiteVersion,\n} from '../../../api/site-version'\n\nimport { BaseHeadSnippet } from './page/HeadSnippet'\n\ntype HeadComponent = (props: { children: ReactNode }) => ReactNode\ntype HeadSnippet = (props: { snippet: Snippet }) => ReactNode\ntype ImageComponent = (props: {\n src: string\n alt: string\n sizes?: string\n width?: number\n height?: number\n priority?: boolean\n fill?: boolean\n style?: CSSProperties\n}) => ReactNode\n\ntype LinkProps = Omit<ComponentPropsWithoutRef<'a'>, 'onClick'> & {\n linkType?: LinkData['type']\n onClick?: (event: MouseEvent<HTMLAnchorElement>) => unknown\n}\n\ntype LinkComponent = ForwardRefExoticComponent<RefAttributes<HTMLAnchorElement> & LinkProps>\n\nexport type FrameworkContext = {\n Head: HeadComponent\n HeadSnippet: HeadSnippet\n Image: ImageComponent\n Link: LinkComponent\n versionedFetch: (siteVersion: SiteVersion | null) => HttpFetch\n}\n\n// React 19 automatically hoists metadata tags to the <head>\nexport const DefaultHead = ({ children }: PropsWithChildren) => <>{children}</>\n\nexport const DefaultImage: ImageComponent = ({ priority, fill, style, ...props }) => (\n <img\n {...props}\n style={{\n ...(fill\n ? {\n height: '100%',\n width: '100%',\n objectFit: 'cover',\n }\n : {}),\n ...style,\n }}\n loading={priority ? 'eager' : 'lazy'}\n />\n)\n\nexport const DefaultLink: LinkComponent = forwardRef<HTMLAnchorElement, LinkProps>(\n ({ linkType, ...props }, ref) => <a {...props} ref={ref} />,\n)\n\nexport const versionedFetch: FrameworkContext['versionedFetch'] = siteVersion => (url, init) =>\n fetch(url, {\n ...init,\n headers: {\n ...init?.headers,\n ...(siteVersion != null\n ? { [ApiHandlerHeaders.SiteVersion]: serializeSiteVersion(siteVersion) }\n : {}),\n },\n })\n\nexport const FrameworkContext = createContext<FrameworkContext>({\n Head: DefaultHead,\n HeadSnippet: BaseHeadSnippet,\n Image: DefaultImage,\n Link: DefaultLink,\n versionedFetch,\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAqDgE;AArDhE,mBAUO;AAMP,0BAIO;AAEP,yBAAgC;AA+BzB,MAAM,cAAc,CAAC,EAAE,SAAS,MAAyB,2EAAG,UAAS;AAErE,MAAM,eAA+B,CAAC,EAAE,UAAU,MAAM,OAAO,GAAG,MAAM,MAC7E;AAAA,EAAC;AAAA;AAAA,IACE,GAAG;AAAA,IACJ,OAAO;AAAA,MACL,GAAI,OACA;AAAA,QACE,QAAQ;AAAA,QACR,OAAO;AAAA,QACP,WAAW;AAAA,MACb,IACA,CAAC;AAAA,MACL,GAAG;AAAA,IACL;AAAA,IACA,SAAS,WAAW,UAAU;AAAA;AAChC;AAGK,MAAM,kBAA6B;AAAA,EACxC,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,QAAQ,4CAAC,OAAG,GAAG,OAAO,KAAU;AAC3D;AAEO,MAAM,iBAAqD,iBAAe,CAAC,KAAK,SACrF,MAAM,KAAK;AAAA,EACT,GAAG;AAAA,EACH,SAAS;AAAA,IACP,GAAG,MAAM;AAAA,IACT,GAAI,eAAe,OACf,EAAE,CAAC,sCAAkB,WAAW,OAAG,0CAAqB,WAAW,EAAE,IACrE,CAAC;AAAA,EACP;AACF,CAAC;AAEI,MAAM,uBAAmB,4BAAgC;AAAA,EAC9D,MAAM;AAAA,EACN,aAAa;AAAA,EACb,OAAO;AAAA,EACP,MAAM;AAAA,EACN;AACF,CAAC;","names":[]}
|
|
@@ -38,22 +38,24 @@ function useRegisterPageDocument(pageDocument) {
|
|
|
38
38
|
(0, import_use_universal_dispatch.useUniversalDispatch)(dispatch, import_actions.registerDocumentsEffect, [rootDocuments]);
|
|
39
39
|
return rootDocuments[0];
|
|
40
40
|
}
|
|
41
|
-
const Page = (
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
};
|
|
41
|
+
const Page = (0, import_react.memo)(
|
|
42
|
+
({
|
|
43
|
+
snapshot,
|
|
44
|
+
metadata = true
|
|
45
|
+
}) => {
|
|
46
|
+
(0, import_use_cache_data.useCacheData)(snapshot.cacheData);
|
|
47
|
+
const rootDocument = useRegisterPageDocument(snapshot.document);
|
|
48
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Suspense, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
49
|
+
import_Page.Page,
|
|
50
|
+
{
|
|
51
|
+
page: snapshot.document,
|
|
52
|
+
rootDocument,
|
|
53
|
+
metadata
|
|
54
|
+
},
|
|
55
|
+
snapshot.document.data.key
|
|
56
|
+
) });
|
|
57
|
+
}
|
|
58
|
+
);
|
|
57
59
|
// Annotate the CommonJS export names for ESM import in node:
|
|
58
60
|
0 && (module.exports = {
|
|
59
61
|
Page
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/runtimes/react/components/page/index.tsx"],"sourcesContent":["import { Suspense, useMemo } from 'react'\n\nimport { useDispatch } from '../../hooks/use-dispatch'\nimport { useUniversalDispatch } from '../../hooks/use-universal-dispatch'\nimport { useCacheData } from '../../hooks/use-cache-data'\n\nimport {\n type MakeswiftPageSnapshot,\n type MakeswiftPageDocument,\n pageToRootDocument,\n} from '../../../../client'\n\nimport * as ReactPage from '../../../../state/react-page'\nimport { registerDocumentsEffect } from '../../../../state/actions'\n\nimport { type PageMetadataSettings } from './page-seo-settings'\nimport { Page as PageComponent } from './Page'\n\nexport { type PageMetadataSettings } from './page-seo-settings'\n\nfunction useRegisterPageDocument(pageDocument: MakeswiftPageDocument): ReactPage.Document {\n const dispatch = useDispatch()\n const rootDocuments: [ReactPage.Document] = useMemo(\n () => [pageToRootDocument(pageDocument)],\n [pageDocument],\n )\n\n useUniversalDispatch(dispatch, registerDocumentsEffect, [rootDocuments])\n\n return rootDocuments[0]\n}\n\nexport const Page = ({\n
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/runtimes/react/components/page/index.tsx"],"sourcesContent":["import { Suspense, useMemo, memo, type ComponentProps } from 'react'\n\nimport { useDispatch } from '../../hooks/use-dispatch'\nimport { useUniversalDispatch } from '../../hooks/use-universal-dispatch'\nimport { useCacheData } from '../../hooks/use-cache-data'\n\nimport {\n type MakeswiftPageSnapshot,\n type MakeswiftPageDocument,\n pageToRootDocument,\n} from '../../../../client'\n\nimport * as ReactPage from '../../../../state/react-page'\nimport { registerDocumentsEffect } from '../../../../state/actions'\n\nimport { type PageMetadataSettings } from './page-seo-settings'\nimport { Page as PageComponent } from './Page'\n\nexport { type PageMetadataSettings } from './page-seo-settings'\n\nfunction useRegisterPageDocument(pageDocument: MakeswiftPageDocument): ReactPage.Document {\n const dispatch = useDispatch()\n const rootDocuments: [ReactPage.Document] = useMemo(\n () => [pageToRootDocument(pageDocument)],\n [pageDocument],\n )\n\n useUniversalDispatch(dispatch, registerDocumentsEffect, [rootDocuments])\n\n return rootDocuments[0]\n}\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 = useRegisterPageDocument(snapshot.document)\n\n return (\n <Suspense>\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 </Suspense>\n )\n },\n)\n\nexport type PageProps = ComponentProps<typeof Page>\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAiEQ;AAjER,mBAA6D;AAE7D,0BAA4B;AAC5B,oCAAqC;AACrC,4BAA6B;AAE7B,oBAIO;AAGP,qBAAwC;AAGxC,kBAAsC;AAItC,SAAS,wBAAwB,cAAyD;AACxF,QAAM,eAAW,iCAAY;AAC7B,QAAM,oBAAsC;AAAA,IAC1C,MAAM,KAAC,kCAAmB,YAAY,CAAC;AAAA,IACvC,CAAC,YAAY;AAAA,EACf;AAEA,0DAAqB,UAAU,wCAAyB,CAAC,aAAa,CAAC;AAEvE,SAAO,cAAc,CAAC;AACxB;AAoBO,MAAM,WAAO;AAAA,EAClB,CAAC;AAAA,IACC;AAAA,IACA,WAAW;AAAA,EACb,MAGM;AACJ,4CAAa,SAAS,SAAS;AAE/B,UAAM,eAAe,wBAAwB,SAAS,QAAQ;AAE9D,WACE,4CAAC,yBAEC;AAAA,MAAC,YAAAA;AAAA,MAAA;AAAA,QAEC,MAAM,SAAS;AAAA,QACf;AAAA,QACA;AAAA;AAAA,MAHK,SAAS,SAAS,KAAK;AAAA,IAI9B,GACF;AAAA,EAEJ;AACF;","names":["PageComponent"]}
|
|
@@ -16,32 +16,22 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
21
|
-
|
|
19
|
+
var preview_switcher_exports = {};
|
|
20
|
+
__export(preview_switcher_exports, {
|
|
21
|
+
PreviewSwitcher: () => PreviewSwitcher
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
23
|
+
module.exports = __toCommonJS(preview_switcher_exports);
|
|
24
24
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
25
|
var import_react = require("react");
|
|
26
26
|
var import_react_dom = require("react-dom");
|
|
27
27
|
var import_head_tags = require("../page/head-tags");
|
|
28
28
|
var import_use_is_in_builder = require("../../hooks/use-is-in-builder");
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
async function exitDraftMode() {
|
|
32
|
-
try {
|
|
33
|
-
await fetch(ClearDraftModeRequestPath);
|
|
34
|
-
window.location.reload();
|
|
35
|
-
} catch (err) {
|
|
36
|
-
console.error("Could not clear Makeswift cookies. Please report this error to your developer.");
|
|
37
|
-
console.error(err);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
function DraftSwitcher({ isDraft }) {
|
|
29
|
+
var import_preview_toolbar = require("./preview-toolbar");
|
|
30
|
+
function PreviewSwitcher({ isPreview }) {
|
|
41
31
|
const shadowContainerRef = (0, import_react.useRef)(null);
|
|
42
32
|
const [shadowRoot, setShadowRoot] = (0, import_react.useState)(null);
|
|
43
33
|
const isInBuilder = (0, import_use_is_in_builder.useIsInBuilder)();
|
|
44
|
-
const showToolbar = !isInBuilder &&
|
|
34
|
+
const showToolbar = !isInBuilder && isPreview;
|
|
45
35
|
(0, import_react.useEffect)(() => {
|
|
46
36
|
if (!showToolbar)
|
|
47
37
|
return;
|
|
@@ -51,18 +41,18 @@ function DraftSwitcher({ isDraft }) {
|
|
|
51
41
|
}
|
|
52
42
|
}, [showToolbar, shadowRoot, setShadowRoot]);
|
|
53
43
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
54
|
-
showToolbar && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { id: "makeswift-
|
|
44
|
+
showToolbar && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { id: "makeswift-preview-switcher", ref: shadowContainerRef, children: shadowRoot ? (0, import_react_dom.createPortal)(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_preview_toolbar.PreviewToolbar, {}), shadowRoot) : null }),
|
|
55
45
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
56
46
|
import_head_tags.PageMeta,
|
|
57
47
|
{
|
|
58
|
-
name: "makeswift-
|
|
59
|
-
content: JSON.stringify({
|
|
48
|
+
name: "makeswift-preview-info",
|
|
49
|
+
content: JSON.stringify({ isPreview, inBuilder: isInBuilder })
|
|
60
50
|
}
|
|
61
51
|
)
|
|
62
52
|
] });
|
|
63
53
|
}
|
|
64
54
|
// Annotate the CommonJS export names for ESM import in node:
|
|
65
55
|
0 && (module.exports = {
|
|
66
|
-
|
|
56
|
+
PreviewSwitcher
|
|
67
57
|
});
|
|
68
|
-
//# sourceMappingURL=
|
|
58
|
+
//# sourceMappingURL=preview-switcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/runtimes/react/components/preview-switcher/preview-switcher.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react'\nimport { createPortal } from 'react-dom'\n\nimport { PageMeta } from '../page/head-tags'\nimport { useIsInBuilder } from '../../hooks/use-is-in-builder'\nimport { PreviewToolbar } from './preview-toolbar'\n\nexport function PreviewSwitcher({ isPreview }: { isPreview: boolean }) {\n const shadowContainerRef = useRef<HTMLSpanElement | null>(null)\n const [shadowRoot, setShadowRoot] = useState<ShadowRoot | null>(null)\n const isInBuilder = useIsInBuilder()\n\n const showToolbar = !isInBuilder && isPreview\n\n useEffect(() => {\n if (!showToolbar) return\n if (\n shadowContainerRef.current &&\n shadowContainerRef.current.shadowRoot == null &&\n shadowRoot == null\n ) {\n const root = shadowContainerRef.current.attachShadow({ mode: 'open' })\n setShadowRoot(root)\n }\n }, [showToolbar, shadowRoot, setShadowRoot])\n\n return (\n <>\n {showToolbar && (\n <span id=\"makeswift-preview-switcher\" ref={shadowContainerRef}>\n {shadowRoot ? createPortal(<PreviewToolbar />, shadowRoot) : null}\n </span>\n )}\n {/* Insert preview mode information into the DOM to make it easier to debug preview mode-related\n issues on production sites */}\n <PageMeta\n name=\"makeswift-preview-info\"\n content={JSON.stringify({ isPreview: isPreview, inBuilder: isInBuilder })}\n />\n </>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA2BI;AA3BJ,mBAA4C;AAC5C,uBAA6B;AAE7B,uBAAyB;AACzB,+BAA+B;AAC/B,6BAA+B;AAExB,SAAS,gBAAgB,EAAE,UAAU,GAA2B;AACrE,QAAM,yBAAqB,qBAA+B,IAAI;AAC9D,QAAM,CAAC,YAAY,aAAa,QAAI,uBAA4B,IAAI;AACpE,QAAM,kBAAc,yCAAe;AAEnC,QAAM,cAAc,CAAC,eAAe;AAEpC,8BAAU,MAAM;AACd,QAAI,CAAC;AAAa;AAClB,QACE,mBAAmB,WACnB,mBAAmB,QAAQ,cAAc,QACzC,cAAc,MACd;AACA,YAAM,OAAO,mBAAmB,QAAQ,aAAa,EAAE,MAAM,OAAO,CAAC;AACrE,oBAAc,IAAI;AAAA,IACpB;AAAA,EACF,GAAG,CAAC,aAAa,YAAY,aAAa,CAAC;AAE3C,SACE,4EACG;AAAA,mBACC,4CAAC,UAAK,IAAG,8BAA6B,KAAK,oBACxC,2BAAa,+BAAa,4CAAC,yCAAe,GAAI,UAAU,IAAI,MAC/D;AAAA,IAIF;AAAA,MAAC;AAAA;AAAA,QACC,MAAK;AAAA,QACL,SAAS,KAAK,UAAU,EAAE,WAAsB,WAAW,YAAY,CAAC;AAAA;AAAA,IAC1E;AAAA,KACF;AAEJ;","names":[]}
|
|
@@ -16,12 +16,13 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
21
|
-
|
|
19
|
+
var preview_toolbar_exports = {};
|
|
20
|
+
__export(preview_toolbar_exports, {
|
|
21
|
+
PreviewToolbar: () => PreviewToolbar
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
23
|
+
module.exports = __toCommonJS(preview_toolbar_exports);
|
|
24
24
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
+
var import_react = require("react");
|
|
25
26
|
const makeswiftIcon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACIAAAAiCAYAAAA6RwvCAAAACXBIWXMAABcRAAAXEQHKJvM/AAABjElEQVRYhc2XzU3EMBCFB8TddAAXn6EE6GCpgNABZ1/IXnymBOgAOmA7YM8+ABVsXEHQQFaKQryeN3Yk3ilKJtEnv/nLUd/3pFG0riGi88yrnQn+UfJ5FUi0riWiB2H4nQn+KRd0DFP8agXEfkqCYJBoHdtxIQxfm+DfFgEhoith3NYE30o/qgGR2BJB+xY7kdYEL8oNFUi0jiFMJuxVWrJqEMFxsyUNCsE6AeNztvBp7aJ143vXksoRnwhYtmNdSoIQa6RlO9YXEWW7KgoCleOgxgTf1QZBT+RZ2lXFING6UxCCq+ceeUE8fYdknY599v9sJvzGBP+yCEgC7GPmETc0OJ+0awAlkhe2pAbIXAeFZ8xe2g2Nk3c3ub0xwWt6zY9qbmiqGVMbZK21ZC/YmhlbeBMTzZNDQqcvDb1kM1x32iqZSt1HaqukfKvq34BAOTLsrH+ETNmUkKHHA+428RgeclPVWozeSyAI2EdWB34jtqXNTAySOY3i/KgFIlqOa4GkFmBegorzg4joG07he/M7zl6jAAAAAElFTkSuQmCC";
|
|
26
27
|
const styles = `
|
|
27
28
|
.exit-preview-container {
|
|
@@ -41,6 +42,7 @@ const styles = `
|
|
|
41
42
|
0 11px 40px 0 rgba(0, 0, 0, 0.25),
|
|
42
43
|
0 2px 10px 0 rgba(0, 0, 0, 0.12);
|
|
43
44
|
transition: 150ms;
|
|
45
|
+
text-decoration: none;
|
|
44
46
|
|
|
45
47
|
font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji',
|
|
46
48
|
'Segoe UI Emoji';
|
|
@@ -63,17 +65,23 @@ const styles = `
|
|
|
63
65
|
0 6px 10px 0 rgba(0, 0, 0, 0.15);
|
|
64
66
|
}
|
|
65
67
|
`;
|
|
66
|
-
function
|
|
68
|
+
function PreviewToolbar() {
|
|
69
|
+
const redirectLiveUrl = (0, import_react.useMemo)(() => {
|
|
70
|
+
const currentUrl = new URL(window.location.href);
|
|
71
|
+
const destination = `${currentUrl.pathname}${currentUrl.search}${currentUrl.hash}`;
|
|
72
|
+
currentUrl.searchParams.set("x-makeswift-redirect-live", encodeURIComponent(destination));
|
|
73
|
+
return currentUrl.toString();
|
|
74
|
+
}, []);
|
|
67
75
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
68
76
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("style", { dangerouslySetInnerHTML: { __html: styles } }),
|
|
69
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "exit-preview-container", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("
|
|
77
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "exit-preview-container", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("a", { className: "exit-preview-button", href: redirectLiveUrl, children: [
|
|
70
78
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", { src: makeswiftIcon, alt: "Makeswift Logo", width: 18, height: 18 }),
|
|
71
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "label", children: "Exit
|
|
79
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "label", children: "Exit preview" })
|
|
72
80
|
] }) })
|
|
73
81
|
] });
|
|
74
82
|
}
|
|
75
83
|
// Annotate the CommonJS export names for ESM import in node:
|
|
76
84
|
0 && (module.exports = {
|
|
77
|
-
|
|
85
|
+
PreviewToolbar
|
|
78
86
|
});
|
|
79
|
-
//# sourceMappingURL=
|
|
87
|
+
//# sourceMappingURL=preview-toolbar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/runtimes/react/components/preview-switcher/preview-toolbar.tsx"],"sourcesContent":["import { useMemo } from 'react'\n\nconst makeswiftIcon =\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\nconst styles = `\n.exit-preview-container {\n position: fixed;\n bottom: 16px;\n right: 16px;\n z-index: 2147483647;\n}\n\n.exit-preview-button {\n background: #2e2e2e;\n padding: 10px 18px 10px 14px;\n border: 0px;\n border-radius: 32px;\n color: #efefef;\n box-shadow:\n 0 11px 40px 0 rgba(0, 0, 0, 0.25),\n 0 2px 10px 0 rgba(0, 0, 0, 0.12);\n transition: 150ms;\n text-decoration: none;\n\n font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji',\n 'Segoe UI Emoji';\n font-size: 14px;\n cursor: pointer;\n\n display: flex;\n align-items: center;\n gap: 6px;\n}\n\n.exit-preview-button > .label {\n transform: translateY(-1px);\n}\n\n.exit-preview-container:hover > .exit-preview-button {\n transform: translateY(-2px);\n box-shadow:\n 0 15px 40px 0 rgba(0, 0, 0, 0.3),\n 0 6px 10px 0 rgba(0, 0, 0, 0.15);\n}\n`\n\nexport function PreviewToolbar() {\n const redirectLiveUrl = useMemo(() => {\n const currentUrl = new URL(window.location.href)\n const destination = `${currentUrl.pathname}${currentUrl.search}${currentUrl.hash}`\n currentUrl.searchParams.set('x-makeswift-redirect-live', encodeURIComponent(destination))\n return currentUrl.toString()\n }, [])\n\n return (\n <>\n <style dangerouslySetInnerHTML={{ __html: styles }} />\n <div className=\"exit-preview-container\">\n <a className=\"exit-preview-button\" href={redirectLiveUrl}>\n <img src={makeswiftIcon} alt=\"Makeswift Logo\" width={18} height={18} />\n <span className=\"label\">Exit preview</span>\n </a>\n </div>\n </>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAwDI;AAxDJ,mBAAwB;AAExB,MAAM,gBACJ;AAEF,MAAM,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA0CR,SAAS,iBAAiB;AAC/B,QAAM,sBAAkB,sBAAQ,MAAM;AACpC,UAAM,aAAa,IAAI,IAAI,OAAO,SAAS,IAAI;AAC/C,UAAM,cAAc,GAAG,WAAW,QAAQ,GAAG,WAAW,MAAM,GAAG,WAAW,IAAI;AAChF,eAAW,aAAa,IAAI,6BAA6B,mBAAmB,WAAW,CAAC;AACxF,WAAO,WAAW,SAAS;AAAA,EAC7B,GAAG,CAAC,CAAC;AAEL,SACE,4EACE;AAAA,gDAAC,WAAM,yBAAyB,EAAE,QAAQ,OAAO,GAAG;AAAA,IACpD,4CAAC,SAAI,WAAU,0BACb,uDAAC,OAAE,WAAU,uBAAsB,MAAM,iBACvC;AAAA,kDAAC,SAAI,KAAK,eAAe,KAAI,kBAAiB,OAAO,IAAI,QAAQ,IAAI;AAAA,MACrE,4CAAC,UAAK,WAAU,SAAQ,0BAAY;AAAA,OACtC,GACF;AAAA,KACF;AAEJ;","names":[]}
|
|
@@ -31,13 +31,12 @@ __export(makeswift_api_exports, {
|
|
|
31
31
|
});
|
|
32
32
|
module.exports = __toCommonJS(makeswift_api_exports);
|
|
33
33
|
var import_react = require("react");
|
|
34
|
-
var import_shim = require("use-sync-external-store/shim");
|
|
35
34
|
var import_host_api_client = require("../host-api-client");
|
|
36
35
|
var import_use_document_context = require("./use-document-context");
|
|
37
36
|
function useSwatch(swatchId) {
|
|
38
37
|
const client = (0, import_host_api_client.useMakeswiftHostApiClient)();
|
|
39
38
|
const readSwatch = () => swatchId == null ? null : client.readSwatch(swatchId);
|
|
40
|
-
const swatch = (0,
|
|
39
|
+
const swatch = (0, import_react.useSyncExternalStore)(client.subscribe, readSwatch, readSwatch);
|
|
41
40
|
(0, import_react.useEffect)(() => {
|
|
42
41
|
if (swatchId != null)
|
|
43
42
|
client.fetchSwatch(swatchId).catch(console.error);
|
|
@@ -54,7 +53,7 @@ function useSwatches(swatchIds) {
|
|
|
54
53
|
}
|
|
55
54
|
return lastSnapshot.current = swatches2;
|
|
56
55
|
}
|
|
57
|
-
const swatches = (0,
|
|
56
|
+
const swatches = (0, import_react.useSyncExternalStore)(client.subscribe, getSnapshot, getSnapshot);
|
|
58
57
|
(0, import_react.useEffect)(() => {
|
|
59
58
|
Promise.all(swatchIds.map((swatchId) => client.fetchSwatch(swatchId))).catch(console.error);
|
|
60
59
|
}, [client, swatchIds]);
|
|
@@ -63,7 +62,7 @@ function useSwatches(swatchIds) {
|
|
|
63
62
|
function useFile(fileId) {
|
|
64
63
|
const client = (0, import_host_api_client.useMakeswiftHostApiClient)();
|
|
65
64
|
const readFile = () => fileId == null ? null : client.readFile(fileId);
|
|
66
|
-
const file = (0,
|
|
65
|
+
const file = (0, import_react.useSyncExternalStore)(client.subscribe, readFile, readFile);
|
|
67
66
|
(0, import_react.useEffect)(() => {
|
|
68
67
|
if (fileId != null)
|
|
69
68
|
client.fetchFile(fileId);
|
|
@@ -80,7 +79,7 @@ function useFiles(fileIds) {
|
|
|
80
79
|
}
|
|
81
80
|
return lastSnapshot.current = files2;
|
|
82
81
|
}
|
|
83
|
-
const files = (0,
|
|
82
|
+
const files = (0, import_react.useSyncExternalStore)(client.subscribe, getSnapshot, getSnapshot);
|
|
84
83
|
(0, import_react.useEffect)(() => {
|
|
85
84
|
Promise.all(fileIds.map((fileId) => client.fetchFile(fileId))).catch(console.error);
|
|
86
85
|
}, [client, fileIds]);
|
|
@@ -89,7 +88,7 @@ function useFiles(fileIds) {
|
|
|
89
88
|
function useTypography(typographyId) {
|
|
90
89
|
const client = (0, import_host_api_client.useMakeswiftHostApiClient)();
|
|
91
90
|
const readTypography = () => typographyId == null ? null : client.readTypography(typographyId);
|
|
92
|
-
const typography = (0,
|
|
91
|
+
const typography = (0, import_react.useSyncExternalStore)(client.subscribe, readTypography, readTypography);
|
|
93
92
|
(0, import_react.useEffect)(() => {
|
|
94
93
|
if (typographyId != null)
|
|
95
94
|
client.fetchTypography(typographyId).catch(console.error);
|
|
@@ -99,7 +98,7 @@ function useTypography(typographyId) {
|
|
|
99
98
|
function useGlobalElement(globalElementId) {
|
|
100
99
|
const client = (0, import_host_api_client.useMakeswiftHostApiClient)();
|
|
101
100
|
const readGlobalElement = () => globalElementId == null ? null : client.readGlobalElement(globalElementId);
|
|
102
|
-
const globalElement = (0,
|
|
101
|
+
const globalElement = (0, import_react.useSyncExternalStore)(client.subscribe, readGlobalElement, readGlobalElement);
|
|
103
102
|
(0, import_react.useEffect)(() => {
|
|
104
103
|
if (globalElementId != null)
|
|
105
104
|
client.fetchGlobalElement(globalElementId).catch(console.error);
|
|
@@ -109,7 +108,7 @@ function useGlobalElement(globalElementId) {
|
|
|
109
108
|
function useLocalizedGlobalElement(locale, globalElementId) {
|
|
110
109
|
const client = (0, import_host_api_client.useMakeswiftHostApiClient)();
|
|
111
110
|
const readLocalizedGlobalElement = () => locale == null || globalElementId == null ? null : client.readLocalizedGlobalElement({ globalElementId, locale });
|
|
112
|
-
const localizedGlobalElement = (0,
|
|
111
|
+
const localizedGlobalElement = (0, import_react.useSyncExternalStore)(
|
|
113
112
|
client.subscribe,
|
|
114
113
|
readLocalizedGlobalElement,
|
|
115
114
|
readLocalizedGlobalElement
|
|
@@ -125,7 +124,7 @@ function usePagePathnameSlice(pageId) {
|
|
|
125
124
|
const client = (0, import_host_api_client.useMakeswiftHostApiClient)();
|
|
126
125
|
const locale = (0, import_use_document_context.useDocumentLocale)();
|
|
127
126
|
const readPagePathnameSlice = () => pageId == null ? null : client.readPagePathnameSlice({ pageId, locale });
|
|
128
|
-
const pagePathnameSlice = (0,
|
|
127
|
+
const pagePathnameSlice = (0, import_react.useSyncExternalStore)(
|
|
129
128
|
client.subscribe,
|
|
130
129
|
readPagePathnameSlice,
|
|
131
130
|
readPagePathnameSlice
|
|
@@ -139,7 +138,7 @@ function usePagePathnameSlice(pageId) {
|
|
|
139
138
|
function useTable(tableId) {
|
|
140
139
|
const client = (0, import_host_api_client.useMakeswiftHostApiClient)();
|
|
141
140
|
const readTable = () => tableId == null ? null : client.readTable(tableId);
|
|
142
|
-
const table = (0,
|
|
141
|
+
const table = (0, import_react.useSyncExternalStore)(client.subscribe, readTable, readTable);
|
|
143
142
|
(0, import_react.useEffect)(() => {
|
|
144
143
|
if (tableId != null)
|
|
145
144
|
client.fetchTable(tableId).catch(console.error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/runtimes/react/hooks/makeswift-api.ts"],"sourcesContent":["'use client'\n\nimport { useEffect, useRef
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/hooks/makeswift-api.ts"],"sourcesContent":["'use client'\n\nimport { useEffect, useRef, useSyncExternalStore } from 'react'\nimport {\n File,\n GlobalElement,\n LocalizedGlobalElement,\n PagePathnameSlice,\n Swatch,\n Table,\n Typography,\n} from '../../../api'\n\nimport { useMakeswiftHostApiClient } from '../host-api-client'\nimport { useDocumentLocale } from './use-document-context'\n\nexport function useSwatch(swatchId: string | null): Swatch | null {\n const client = useMakeswiftHostApiClient()\n const readSwatch = () => (swatchId == null ? null : client.readSwatch(swatchId))\n const swatch = useSyncExternalStore(client.subscribe, readSwatch, readSwatch)\n\n useEffect(() => {\n if (swatchId != null) client.fetchSwatch(swatchId).catch(console.error)\n }, [client, swatchId])\n\n return swatch\n}\n\nexport function useSwatches(swatchIds: string[]): (Swatch | null)[] {\n const client = useMakeswiftHostApiClient()\n const lastSnapshot = useRef<(Swatch | null)[]>()\n\n function getSnapshot() {\n const swatches = swatchIds.map(swatchId => client.readSwatch(swatchId))\n\n if (\n lastSnapshot.current != null &&\n lastSnapshot.current.length === swatches.length &&\n lastSnapshot.current.every((swatch, idx) => swatches[idx] === swatch)\n ) {\n return lastSnapshot.current\n }\n\n return (lastSnapshot.current = swatches)\n }\n\n const swatches = useSyncExternalStore(client.subscribe, getSnapshot, getSnapshot)\n\n useEffect(() => {\n Promise.all(swatchIds.map(swatchId => client.fetchSwatch(swatchId))).catch(console.error)\n }, [client, swatchIds])\n\n return swatches\n}\n\nexport function useFile(fileId: string | null): File | null {\n const client = useMakeswiftHostApiClient()\n const readFile = () => (fileId == null ? null : client.readFile(fileId))\n const file = useSyncExternalStore(client.subscribe, readFile, readFile)\n\n useEffect(() => {\n if (fileId != null) client.fetchFile(fileId)\n }, [client, fileId])\n\n return file\n}\n\nexport function useFiles(fileIds: string[]): (File | null)[] {\n const client = useMakeswiftHostApiClient()\n const lastSnapshot = useRef<(File | null)[]>()\n\n function getSnapshot() {\n const files = fileIds.map(fileId => client.readFile(fileId))\n\n if (\n lastSnapshot.current != null &&\n lastSnapshot.current.length === files.length &&\n lastSnapshot.current.every((file, idx) => files[idx] === file)\n ) {\n return lastSnapshot.current\n }\n\n return (lastSnapshot.current = files)\n }\n\n const files = useSyncExternalStore(client.subscribe, getSnapshot, getSnapshot)\n\n useEffect(() => {\n Promise.all(fileIds.map(fileId => client.fetchFile(fileId))).catch(console.error)\n }, [client, fileIds])\n\n return files\n}\n\nexport function useTypography(typographyId: string | null): Typography | null {\n const client = useMakeswiftHostApiClient()\n const readTypography = () => (typographyId == null ? null : client.readTypography(typographyId))\n const typography = useSyncExternalStore(client.subscribe, readTypography, readTypography)\n\n useEffect(() => {\n if (typographyId != null) client.fetchTypography(typographyId).catch(console.error)\n }, [client, typographyId])\n\n return typography\n}\n\nexport function useGlobalElement(globalElementId: string | null): GlobalElement | null {\n const client = useMakeswiftHostApiClient()\n const readGlobalElement = () =>\n globalElementId == null ? null : client.readGlobalElement(globalElementId)\n const globalElement = useSyncExternalStore(client.subscribe, readGlobalElement, readGlobalElement)\n\n useEffect(() => {\n if (globalElementId != null) client.fetchGlobalElement(globalElementId).catch(console.error)\n }, [client, globalElementId])\n\n return globalElement\n}\n\nexport function useLocalizedGlobalElement(\n locale: string | null,\n globalElementId: string | null,\n): LocalizedGlobalElement | null {\n const client = useMakeswiftHostApiClient()\n const readLocalizedGlobalElement = () =>\n locale == null || globalElementId == null\n ? null\n : client.readLocalizedGlobalElement({ globalElementId, locale })\n\n const localizedGlobalElement = useSyncExternalStore(\n client.subscribe,\n readLocalizedGlobalElement,\n readLocalizedGlobalElement,\n )\n\n useEffect(() => {\n if (locale != null && globalElementId != null) {\n client.fetchLocalizedGlobalElement({ globalElementId, locale }).catch(console.error)\n }\n }, [client, locale, globalElementId])\n\n return localizedGlobalElement\n}\n\nexport function usePagePathnameSlice(pageId: string | null): PagePathnameSlice | null {\n const client = useMakeswiftHostApiClient()\n const locale = useDocumentLocale()\n\n const readPagePathnameSlice = () =>\n pageId == null ? null : client.readPagePathnameSlice({ pageId, locale })\n\n const pagePathnameSlice = useSyncExternalStore(\n client.subscribe,\n readPagePathnameSlice,\n readPagePathnameSlice,\n )\n\n useEffect(() => {\n if (pageId != null) client.fetchPagePathnameSlice({ pageId, locale }).catch(console.error)\n }, [client, pageId, locale])\n\n return pagePathnameSlice\n}\n\nexport function useTable(tableId: string | null): Table | null {\n const client = useMakeswiftHostApiClient()\n const readTable = () => (tableId == null ? null : client.readTable(tableId))\n const table = useSyncExternalStore(client.subscribe, readTable, readTable)\n\n useEffect(() => {\n if (tableId != null) client.fetchTable(tableId).catch(console.error)\n }, [client, tableId])\n\n return table\n}\n"],"mappings":"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","names":["swatches","files"]}
|
|
@@ -21,7 +21,7 @@ __export(use_selector_exports, {
|
|
|
21
21
|
useSelector: () => useSelector
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(use_selector_exports);
|
|
24
|
-
var import_with_selector = require("use-sync-external-store/
|
|
24
|
+
var import_with_selector = require("use-sync-external-store/with-selector");
|
|
25
25
|
var import_use_store = require("./use-store");
|
|
26
26
|
function useSelector(selector) {
|
|
27
27
|
const store = (0, import_use_store.useStore)();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-selector.ts"],"sourcesContent":["import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-selector.ts"],"sourcesContent":["import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/with-selector'\n\nimport { useStore } from './use-store'\nimport { State as ReactPageState } from '../../../state/react-page'\nimport { State as ReactBuilderPreviewState } from '../../../state/react-builder-preview'\n\ntype State = ReactPageState | ReactBuilderPreviewState\n\nexport function useSelector<R>(selector: (state: State) => R): R {\n const store = useStore()\n\n return useSyncExternalStoreWithSelector(store.subscribe, store.getState, store.getState, selector)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAAiD;AAEjD,uBAAyB;AAMlB,SAAS,YAAe,UAAkC;AAC/D,QAAM,YAAQ,2BAAS;AAEvB,aAAO,uDAAiC,MAAM,WAAW,MAAM,UAAU,MAAM,UAAU,QAAQ;AACnG;","names":[]}
|