@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
|
@@ -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":"AAqBQ;AApBR,SAAS,uBAAuB;AAEhC,SAAS,yBAAyB;AAClC,SAAS,6BAA6B;AAG/B,SAAS,cAAc;AAAA,EAC5B;AAAA,EACA;AAAA,EACA,cAAc;AAAA,EACd,mBAAmB;AACrB,GAKG;AACD,SACE,oBAAC,qBAAkB,kBACjB,8BAAC,mBAAgB,aAA0B,SACzC,8BAAC,yBAAuB,UAAS,GACnC,GACF;AAEJ;","names":[]}
|
|
@@ -5,13 +5,15 @@ import {
|
|
|
5
5
|
} from "node-mocks-http";
|
|
6
6
|
import { MakeswiftApiHandler } from "../api-handler";
|
|
7
7
|
import { ReactRuntime } from "../../react";
|
|
8
|
+
import { TestOrigins } from "../../testing/fixtures";
|
|
9
|
+
import { RewriteRuleMatches } from "../api-handler/preview";
|
|
8
10
|
function createHandler(apiKey, args = {}) {
|
|
9
11
|
const runtime = new ReactRuntime();
|
|
10
12
|
return MakeswiftApiHandler(apiKey, {
|
|
11
13
|
...args,
|
|
12
14
|
runtime,
|
|
13
|
-
apiOrigin:
|
|
14
|
-
appOrigin:
|
|
15
|
+
apiOrigin: TestOrigins.apiOrigin,
|
|
16
|
+
appOrigin: TestOrigins.appOrigin
|
|
15
17
|
});
|
|
16
18
|
}
|
|
17
19
|
const hostUrl = (path) => new URL(path, "https://example.com");
|
|
@@ -33,7 +35,7 @@ function createNextApiRequest({
|
|
|
33
35
|
query: {
|
|
34
36
|
...routeParams(hostUrl(path)),
|
|
35
37
|
...Object.fromEntries(url.searchParams.entries()),
|
|
36
|
-
...originalPath ? {
|
|
38
|
+
...originalPath ? { [RewriteRuleMatches.OriginalPath]: originalPath } : {}
|
|
37
39
|
},
|
|
38
40
|
body,
|
|
39
41
|
headers
|
|
@@ -72,7 +74,7 @@ function pagesRouterApiRequestFixture(args = {}, responseMock) {
|
|
|
72
74
|
return response._getHeaders()["set-cookie"];
|
|
73
75
|
},
|
|
74
76
|
get(key) {
|
|
75
|
-
return key.toLowerCase() === "location" ? response._getRedirectUrl() : response._getHeaders()[key];
|
|
77
|
+
return key.toLowerCase() === "location" ? response._getRedirectUrl() || response._getHeaders()["location"] : response._getHeaders()[key];
|
|
76
78
|
}
|
|
77
79
|
}
|
|
78
80
|
};
|
|
@@ -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":[]}
|
|
@@ -4,8 +4,7 @@ import { useMemo, lazy } from "react";
|
|
|
4
4
|
import { MakeswiftHostApiClient } from "../../../api/react";
|
|
5
5
|
import { ReactRuntimeContext } from "../hooks/use-react-runtime";
|
|
6
6
|
import { MakeswiftHostApiClientProvider } from "../host-api-client";
|
|
7
|
-
import {
|
|
8
|
-
import { DraftSwitcher } from "./draft-switcher/draft-switcher";
|
|
7
|
+
import { PreviewSwitcher } from "./preview-switcher/preview-switcher";
|
|
9
8
|
import { useBuilderConnectionPing } from "./hooks/use-builder-connection-ping";
|
|
10
9
|
import { useFrameworkContext } from "./hooks/use-framework-context";
|
|
11
10
|
const LiveProvider = lazy(() => import("./LiveProvider"));
|
|
@@ -13,7 +12,7 @@ const PreviewProvider = lazy(() => import("./PreviewProvider"));
|
|
|
13
12
|
function RuntimeProvider({
|
|
14
13
|
children,
|
|
15
14
|
runtime,
|
|
16
|
-
|
|
15
|
+
siteVersion,
|
|
17
16
|
appOrigin = "https://app.makeswift.com",
|
|
18
17
|
apiOrigin = "https://api.makeswift.com",
|
|
19
18
|
locale = void 0
|
|
@@ -23,17 +22,16 @@ function RuntimeProvider({
|
|
|
23
22
|
() => new MakeswiftHostApiClient({
|
|
24
23
|
uri: new URL("graphql", apiOrigin).href,
|
|
25
24
|
locale,
|
|
26
|
-
fetch: versionedFetch(
|
|
27
|
-
previewMode ? MakeswiftSiteVersion.Working : MakeswiftSiteVersion.Live
|
|
28
|
-
)
|
|
25
|
+
fetch: versionedFetch(siteVersion)
|
|
29
26
|
}),
|
|
30
|
-
[apiOrigin, locale,
|
|
27
|
+
[apiOrigin, locale, siteVersion, versionedFetch]
|
|
31
28
|
);
|
|
32
|
-
const
|
|
29
|
+
const isPreview = siteVersion != null;
|
|
30
|
+
const StoreProvider = isPreview ? PreviewProvider : LiveProvider;
|
|
33
31
|
useBuilderConnectionPing({ appOrigin });
|
|
34
32
|
return /* @__PURE__ */ jsx(ReactRuntimeContext.Provider, { value: runtime, children: /* @__PURE__ */ jsx(MakeswiftHostApiClientProvider, { client, children: /* @__PURE__ */ jsxs(StoreProvider, { children: [
|
|
35
33
|
children,
|
|
36
|
-
/* @__PURE__ */ jsx(
|
|
34
|
+
/* @__PURE__ */ jsx(PreviewSwitcher, { isPreview })
|
|
37
35
|
] }) }) });
|
|
38
36
|
}
|
|
39
37
|
export {
|
|
@@ -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":";AAmDQ,SAEE,KAFF;AAjDR,SAAoB,SAAS,YAAY;AAEzC,SAAS,8BAA8B;AACvC,SAAS,2BAA2B;AAEpC,SAAS,sCAAsC;AAE/C,SAAS,uBAAuB;AAChC,SAAS,gCAAgC;AACzC,SAAS,2BAA2B;AAEpC,MAAM,eAAe,KAAK,MAAM,OAAO,gBAAgB,CAAC;AACxD,MAAM,kBAAkB,KAAK,MAAM,OAAO,mBAAmB,CAAC;AAEvD,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,SAAS;AACX,GAOG;AACD,QAAM,EAAE,eAAe,IAAI,oBAAoB;AAE/C,QAAM,SAAS;AAAA,IACb,MACE,IAAI,uBAAuB;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,2BAAyB,EAAE,UAAU,CAAC;AAEtC,SACE,oBAAC,oBAAoB,UAApB,EAA6B,OAAO,SACnC,8BAAC,kCAA+B,QAC9B,+BAAC,iBACE;AAAA;AAAA,IACD,oBAAC,mBAAgB,WAAsB;AAAA,KACzC,GACF,GACF;AAEJ;","names":[]}
|
|
@@ -3,7 +3,10 @@ import {
|
|
|
3
3
|
createContext,
|
|
4
4
|
forwardRef
|
|
5
5
|
} from "react";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
ApiHandlerHeaders,
|
|
8
|
+
serializeSiteVersion
|
|
9
|
+
} from "../../../api/site-version";
|
|
7
10
|
import { BaseHeadSnippet } from "./page/HeadSnippet";
|
|
8
11
|
const DefaultHead = ({ children }) => /* @__PURE__ */ jsx(Fragment, { children });
|
|
9
12
|
const DefaultImage = ({ priority, fill, style, ...props }) => /* @__PURE__ */ jsx(
|
|
@@ -28,7 +31,7 @@ const versionedFetch = (siteVersion) => (url, init) => fetch(url, {
|
|
|
28
31
|
...init,
|
|
29
32
|
headers: {
|
|
30
33
|
...init?.headers,
|
|
31
|
-
[
|
|
34
|
+
...siteVersion != null ? { [ApiHandlerHeaders.SiteVersion]: serializeSiteVersion(siteVersion) } : {}
|
|
32
35
|
}
|
|
33
36
|
});
|
|
34
37
|
const FrameworkContext = 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":"AAqDgE;AArDhE;AAAA,EACE;AAAA,EAQA;AAAA,OACK;AAMP;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AAEP,SAAS,uBAAuB;AA+BzB,MAAM,cAAc,CAAC,EAAE,SAAS,MAAyB,gCAAG,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,cAA6B;AAAA,EACxC,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,QAAQ,oBAAC,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,kBAAkB,WAAW,GAAG,qBAAqB,WAAW,EAAE,IACrE,CAAC;AAAA,EACP;AACF,CAAC;AAEI,MAAM,mBAAmB,cAAgC;AAAA,EAC9D,MAAM;AAAA,EACN,aAAa;AAAA,EACb,OAAO;AAAA,EACP,MAAM;AAAA,EACN;AACF,CAAC;","names":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Suspense, useMemo } from "react";
|
|
2
|
+
import { Suspense, useMemo, memo } from "react";
|
|
3
3
|
import { useDispatch } from "../../hooks/use-dispatch";
|
|
4
4
|
import { useUniversalDispatch } from "../../hooks/use-universal-dispatch";
|
|
5
5
|
import { useCacheData } from "../../hooks/use-cache-data";
|
|
@@ -17,22 +17,24 @@ function useRegisterPageDocument(pageDocument) {
|
|
|
17
17
|
useUniversalDispatch(dispatch, registerDocumentsEffect, [rootDocuments]);
|
|
18
18
|
return rootDocuments[0];
|
|
19
19
|
}
|
|
20
|
-
const Page = (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
};
|
|
20
|
+
const Page = memo(
|
|
21
|
+
({
|
|
22
|
+
snapshot,
|
|
23
|
+
metadata = true
|
|
24
|
+
}) => {
|
|
25
|
+
useCacheData(snapshot.cacheData);
|
|
26
|
+
const rootDocument = useRegisterPageDocument(snapshot.document);
|
|
27
|
+
return /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(
|
|
28
|
+
PageComponent,
|
|
29
|
+
{
|
|
30
|
+
page: snapshot.document,
|
|
31
|
+
rootDocument,
|
|
32
|
+
metadata
|
|
33
|
+
},
|
|
34
|
+
snapshot.document.data.key
|
|
35
|
+
) });
|
|
36
|
+
}
|
|
37
|
+
);
|
|
36
38
|
export {
|
|
37
39
|
Page
|
|
38
40
|
};
|
|
@@ -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":"AAiEQ;AAjER,SAAS,UAAU,SAAS,YAAiC;AAE7D,SAAS,mBAAmB;AAC5B,SAAS,4BAA4B;AACrC,SAAS,oBAAoB;AAE7B;AAAA,EAGE;AAAA,OACK;AAGP,SAAS,+BAA+B;AAGxC,SAAS,QAAQ,qBAAqB;AAItC,SAAS,wBAAwB,cAAyD;AACxF,QAAM,WAAW,YAAY;AAC7B,QAAM,gBAAsC;AAAA,IAC1C,MAAM,CAAC,mBAAmB,YAAY,CAAC;AAAA,IACvC,CAAC,YAAY;AAAA,EACf;AAEA,uBAAqB,UAAU,yBAAyB,CAAC,aAAa,CAAC;AAEvE,SAAO,cAAc,CAAC;AACxB;AAoBO,MAAM,OAAO;AAAA,EAClB,CAAC;AAAA,IACC;AAAA,IACA,WAAW;AAAA,EACb,MAGM;AACJ,iBAAa,SAAS,SAAS;AAE/B,UAAM,eAAe,wBAAwB,SAAS,QAAQ;AAE9D,WACE,oBAAC,YAEC;AAAA,MAAC;AAAA;AAAA,QAEC,MAAM,SAAS;AAAA,QACf;AAAA,QACA;AAAA;AAAA,MAHK,SAAS,SAAS,KAAK;AAAA,IAI9B,GACF;AAAA,EAEJ;AACF;","names":[]}
|
|
@@ -3,22 +3,12 @@ import { useEffect, useRef, useState } from "react";
|
|
|
3
3
|
import { createPortal } from "react-dom";
|
|
4
4
|
import { PageMeta } from "../page/head-tags";
|
|
5
5
|
import { useIsInBuilder } from "../../hooks/use-is-in-builder";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
async function exitDraftMode() {
|
|
9
|
-
try {
|
|
10
|
-
await fetch(ClearDraftModeRequestPath);
|
|
11
|
-
window.location.reload();
|
|
12
|
-
} catch (err) {
|
|
13
|
-
console.error("Could not clear Makeswift cookies. Please report this error to your developer.");
|
|
14
|
-
console.error(err);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
function DraftSwitcher({ isDraft }) {
|
|
6
|
+
import { PreviewToolbar } from "./preview-toolbar";
|
|
7
|
+
function PreviewSwitcher({ isPreview }) {
|
|
18
8
|
const shadowContainerRef = useRef(null);
|
|
19
9
|
const [shadowRoot, setShadowRoot] = useState(null);
|
|
20
10
|
const isInBuilder = useIsInBuilder();
|
|
21
|
-
const showToolbar = !isInBuilder &&
|
|
11
|
+
const showToolbar = !isInBuilder && isPreview;
|
|
22
12
|
useEffect(() => {
|
|
23
13
|
if (!showToolbar)
|
|
24
14
|
return;
|
|
@@ -28,17 +18,17 @@ function DraftSwitcher({ isDraft }) {
|
|
|
28
18
|
}
|
|
29
19
|
}, [showToolbar, shadowRoot, setShadowRoot]);
|
|
30
20
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
31
|
-
showToolbar && /* @__PURE__ */ jsx("span", { id: "makeswift-
|
|
21
|
+
showToolbar && /* @__PURE__ */ jsx("span", { id: "makeswift-preview-switcher", ref: shadowContainerRef, children: shadowRoot ? createPortal(/* @__PURE__ */ jsx(PreviewToolbar, {}), shadowRoot) : null }),
|
|
32
22
|
/* @__PURE__ */ jsx(
|
|
33
23
|
PageMeta,
|
|
34
24
|
{
|
|
35
|
-
name: "makeswift-
|
|
36
|
-
content: JSON.stringify({
|
|
25
|
+
name: "makeswift-preview-info",
|
|
26
|
+
content: JSON.stringify({ isPreview, inBuilder: isInBuilder })
|
|
37
27
|
}
|
|
38
28
|
)
|
|
39
29
|
] });
|
|
40
30
|
}
|
|
41
31
|
export {
|
|
42
|
-
|
|
32
|
+
PreviewSwitcher
|
|
43
33
|
};
|
|
44
|
-
//# sourceMappingURL=
|
|
34
|
+
//# 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":"AA2BI,mBAGiC,KAHjC;AA3BJ,SAAS,WAAW,QAAQ,gBAAgB;AAC5C,SAAS,oBAAoB;AAE7B,SAAS,gBAAgB;AACzB,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAExB,SAAS,gBAAgB,EAAE,UAAU,GAA2B;AACrE,QAAM,qBAAqB,OAA+B,IAAI;AAC9D,QAAM,CAAC,YAAY,aAAa,IAAI,SAA4B,IAAI;AACpE,QAAM,cAAc,eAAe;AAEnC,QAAM,cAAc,CAAC,eAAe;AAEpC,YAAU,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,iCACG;AAAA,mBACC,oBAAC,UAAK,IAAG,8BAA6B,KAAK,oBACxC,uBAAa,aAAa,oBAAC,kBAAe,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":[]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from "react";
|
|
2
3
|
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";
|
|
3
4
|
const styles = `
|
|
4
5
|
.exit-preview-container {
|
|
@@ -18,6 +19,7 @@ const styles = `
|
|
|
18
19
|
0 11px 40px 0 rgba(0, 0, 0, 0.25),
|
|
19
20
|
0 2px 10px 0 rgba(0, 0, 0, 0.12);
|
|
20
21
|
transition: 150ms;
|
|
22
|
+
text-decoration: none;
|
|
21
23
|
|
|
22
24
|
font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji',
|
|
23
25
|
'Segoe UI Emoji';
|
|
@@ -40,16 +42,22 @@ const styles = `
|
|
|
40
42
|
0 6px 10px 0 rgba(0, 0, 0, 0.15);
|
|
41
43
|
}
|
|
42
44
|
`;
|
|
43
|
-
function
|
|
45
|
+
function PreviewToolbar() {
|
|
46
|
+
const redirectLiveUrl = useMemo(() => {
|
|
47
|
+
const currentUrl = new URL(window.location.href);
|
|
48
|
+
const destination = `${currentUrl.pathname}${currentUrl.search}${currentUrl.hash}`;
|
|
49
|
+
currentUrl.searchParams.set("x-makeswift-redirect-live", encodeURIComponent(destination));
|
|
50
|
+
return currentUrl.toString();
|
|
51
|
+
}, []);
|
|
44
52
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
45
53
|
/* @__PURE__ */ jsx("style", { dangerouslySetInnerHTML: { __html: styles } }),
|
|
46
|
-
/* @__PURE__ */ jsx("div", { className: "exit-preview-container", children: /* @__PURE__ */ jsxs("
|
|
54
|
+
/* @__PURE__ */ jsx("div", { className: "exit-preview-container", children: /* @__PURE__ */ jsxs("a", { className: "exit-preview-button", href: redirectLiveUrl, children: [
|
|
47
55
|
/* @__PURE__ */ jsx("img", { src: makeswiftIcon, alt: "Makeswift Logo", width: 18, height: 18 }),
|
|
48
|
-
/* @__PURE__ */ jsx("span", { className: "label", children: "Exit
|
|
56
|
+
/* @__PURE__ */ jsx("span", { className: "label", children: "Exit preview" })
|
|
49
57
|
] }) })
|
|
50
58
|
] });
|
|
51
59
|
}
|
|
52
60
|
export {
|
|
53
|
-
|
|
61
|
+
PreviewToolbar
|
|
54
62
|
};
|
|
55
|
-
//# sourceMappingURL=
|
|
63
|
+
//# 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":"AAwDI,mBACE,KAEE,YAHJ;AAxDJ,SAAS,eAAe;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,kBAAkB,QAAQ,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,iCACE;AAAA,wBAAC,WAAM,yBAAyB,EAAE,QAAQ,OAAO,GAAG;AAAA,IACpD,oBAAC,SAAI,WAAU,0BACb,+BAAC,OAAE,WAAU,uBAAsB,MAAM,iBACvC;AAAA,0BAAC,SAAI,KAAK,eAAe,KAAI,kBAAiB,OAAO,IAAI,QAAQ,IAAI;AAAA,MACrE,oBAAC,UAAK,WAAU,SAAQ,0BAAY;AAAA,OACtC,GACF;AAAA,KACF;AAEJ;","names":[]}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useEffect, useRef } from "react";
|
|
3
|
-
import { useSyncExternalStore } from "use-sync-external-store/shim";
|
|
2
|
+
import { useEffect, useRef, useSyncExternalStore } from "react";
|
|
4
3
|
import { useMakeswiftHostApiClient } from "../host-api-client";
|
|
5
4
|
import { useDocumentLocale } from "./use-document-context";
|
|
6
5
|
function useSwatch(swatchId) {
|
|
@@ -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"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useSyncExternalStoreWithSelector } from "use-sync-external-store/
|
|
1
|
+
import { useSyncExternalStoreWithSelector } from "use-sync-external-store/with-selector";
|
|
2
2
|
import { useStore } from "./use-store";
|
|
3
3
|
function useSelector(selector) {
|
|
4
4
|
const 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,SAAS,wCAAwC;AAEjD,SAAS,gBAAgB;AAMlB,SAAS,YAAe,UAAkC;AAC/D,QAAM,QAAQ,SAAS;AAEvB,SAAO,iCAAiC,MAAM,WAAW,MAAM,UAAU,MAAM,UAAU,QAAQ;AACnG;","names":[]}
|
|
@@ -9,23 +9,34 @@ const CSSResetEnabledContext = createContext(DEFAULT_CSS_RESET_ENABLED);
|
|
|
9
9
|
const createRootStyleCache = ({ key } = {}) => {
|
|
10
10
|
const cache2 = createCache({ key: key ?? "mswft" });
|
|
11
11
|
cache2.compat = true;
|
|
12
|
-
const prevInsert = cache2.insert;
|
|
13
12
|
let inserted = [];
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
return {
|
|
14
|
+
...cache2,
|
|
15
|
+
// override the `insert` method to track inserted names
|
|
16
|
+
insert(...args) {
|
|
17
|
+
const serialized = args[1];
|
|
18
|
+
if (cache2.inserted[serialized.name] === void 0) {
|
|
19
|
+
inserted.push(serialized.name);
|
|
20
|
+
}
|
|
21
|
+
return cache2.insert(...args);
|
|
22
|
+
},
|
|
23
|
+
flush() {
|
|
24
|
+
const classNames = inserted;
|
|
25
|
+
inserted = [];
|
|
26
|
+
return {
|
|
27
|
+
classNames,
|
|
28
|
+
css: classNames.reduce((css, name) => {
|
|
29
|
+
return css + cache2.inserted[name];
|
|
30
|
+
}, "")
|
|
31
|
+
};
|
|
18
32
|
}
|
|
19
|
-
return prevInsert(...args);
|
|
20
33
|
};
|
|
21
|
-
const flush = () => {
|
|
22
|
-
const prevInserted = inserted;
|
|
23
|
-
inserted = [];
|
|
24
|
-
return prevInserted;
|
|
25
|
-
};
|
|
26
|
-
return { cache: cache2, flush };
|
|
27
34
|
};
|
|
28
|
-
function RootStyleRegistry({
|
|
35
|
+
function RootStyleRegistry({
|
|
36
|
+
children,
|
|
37
|
+
cache: cache2,
|
|
38
|
+
enableCssReset
|
|
39
|
+
}) {
|
|
29
40
|
return /* @__PURE__ */ jsx(CacheContext.Provider, { value: cache2, children: /* @__PURE__ */ jsx(CSSResetEnabledContext.Provider, { value: enableCssReset ?? DEFAULT_CSS_RESET_ENABLED, children }) });
|
|
30
41
|
}
|
|
31
42
|
function useCache() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/runtimes/react/root-style-registry.tsx"],"sourcesContent":["'use client'\n\nimport createCache, { EmotionCache } from '@emotion/cache'\nimport { cache } from '@emotion/css'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/runtimes/react/root-style-registry.tsx"],"sourcesContent":["'use client'\n\nimport createCache, { type EmotionCache } from '@emotion/cache'\nimport { cache } from '@emotion/css'\nimport { type PropsWithChildren, createContext, useContext } from 'react'\n\nconst CacheContext = createContext(cache)\n\nconst DEFAULT_CSS_RESET_ENABLED = true\nconst CSSResetEnabledContext = createContext(DEFAULT_CSS_RESET_ENABLED)\n\nexport type StyleCache = EmotionCache & {\n /**\n * Flush the inserted styles.\n * @returns A list of class names and the corresponding CSS rules that were flushed.\n */\n flush: () => { classNames: string[]; css: string }\n}\n\nexport const createRootStyleCache = ({ key }: { key?: string } = {}): StyleCache => {\n const cache = createCache({ key: key ?? 'mswft' })\n cache.compat = true\n\n // additional state to track inserted style names\n let inserted: string[] = []\n\n return {\n ...cache,\n\n // override the `insert` method to track inserted names\n insert(...args) {\n const serialized = args[1]\n if (cache.inserted[serialized.name] === undefined) {\n inserted.push(serialized.name)\n }\n return cache.insert(...args)\n },\n\n flush() {\n const classNames = inserted\n // reset our own state, leave `cache.inserted` intact\n inserted = []\n\n return {\n classNames,\n css: classNames.reduce((css, name) => {\n return css + cache.inserted[name]\n }, ''),\n }\n },\n }\n}\n\nexport type RootStyleProps = {\n /**\n * The key used to prefix generated class names.\n * If not provided, a default key will be used.\n */\n cacheKey?: string\n /**\n * Toggle the built-in CSS reset.\n * Set to `false` when using `@layer`-based CSS frameworks like Tailwind.\n */\n enableCssReset?: boolean\n}\n\nexport function RootStyleRegistry({\n children,\n cache,\n enableCssReset,\n}: PropsWithChildren<{\n cache: StyleCache\n enableCssReset?: boolean\n}>) {\n return (\n <CacheContext.Provider value={cache}>\n <CSSResetEnabledContext.Provider value={enableCssReset ?? DEFAULT_CSS_RESET_ENABLED}>\n {children}\n </CSSResetEnabledContext.Provider>\n </CacheContext.Provider>\n )\n}\n\nexport function useCache(): EmotionCache {\n return useContext(CacheContext)\n}\n\nexport function useCSSResetEnabled(): boolean {\n return useContext(CSSResetEnabledContext)\n}\n"],"mappings":";AA4EM;AA1EN,OAAO,iBAAwC;AAC/C,SAAS,aAAa;AACtB,SAAiC,eAAe,kBAAkB;AAElE,MAAM,eAAe,cAAc,KAAK;AAExC,MAAM,4BAA4B;AAClC,MAAM,yBAAyB,cAAc,yBAAyB;AAU/D,MAAM,uBAAuB,CAAC,EAAE,IAAI,IAAsB,CAAC,MAAkB;AAClF,QAAMA,SAAQ,YAAY,EAAE,KAAK,OAAO,QAAQ,CAAC;AACjD,EAAAA,OAAM,SAAS;AAGf,MAAI,WAAqB,CAAC;AAE1B,SAAO;AAAA,IACL,GAAGA;AAAA;AAAA,IAGH,UAAU,MAAM;AACd,YAAM,aAAa,KAAK,CAAC;AACzB,UAAIA,OAAM,SAAS,WAAW,IAAI,MAAM,QAAW;AACjD,iBAAS,KAAK,WAAW,IAAI;AAAA,MAC/B;AACA,aAAOA,OAAM,OAAO,GAAG,IAAI;AAAA,IAC7B;AAAA,IAEA,QAAQ;AACN,YAAM,aAAa;AAEnB,iBAAW,CAAC;AAEZ,aAAO;AAAA,QACL;AAAA,QACA,KAAK,WAAW,OAAO,CAAC,KAAK,SAAS;AACpC,iBAAO,MAAMA,OAAM,SAAS,IAAI;AAAA,QAClC,GAAG,EAAE;AAAA,MACP;AAAA,IACF;AAAA,EACF;AACF;AAeO,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA,OAAAA;AAAA,EACA;AACF,GAGI;AACF,SACE,oBAAC,aAAa,UAAb,EAAsB,OAAOA,QAC5B,8BAAC,uBAAuB,UAAvB,EAAgC,OAAO,kBAAkB,2BACvD,UACH,GACF;AAEJ;AAEO,SAAS,WAAyB;AACvC,SAAO,WAAW,YAAY;AAChC;AAEO,SAAS,qBAA8B;AAC5C,SAAO,WAAW,sBAAsB;AAC1C;","names":["cache"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const TestWorkingSiteVersion = {
|
|
2
|
+
version: "draft",
|
|
3
|
+
token: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJtYWtlc3dpZnQtcnVudGltZSIsImlhdCI6MTc1NDU5OTE0OSwiZXhwIjo0MTAyNDMyNzQ5LCJhdWQiOiJ0ZXN0Iiwic3ViIjoibWFrZXN3aWZ0LXJ1bnRpbWUifQ.-1BDOmEN1Q1QeKP7qfjPyAkrKRjb4q4qaqyhPBvMnhg"
|
|
4
|
+
};
|
|
5
|
+
const TestOrigins = {
|
|
6
|
+
apiOrigin: "https://api.fakeswift.com",
|
|
7
|
+
appOrigin: "https://app.fakeswift.com"
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
TestOrigins,
|
|
11
|
+
TestWorkingSiteVersion
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=fixtures.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/testing/fixtures.ts"],"sourcesContent":["import { type SiteVersion } from '../next'\n\nexport const TestWorkingSiteVersion: SiteVersion = {\n version: 'draft',\n token:\n 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJtYWtlc3dpZnQtcnVudGltZSIsImlhdCI6MTc1NDU5OTE0OSwiZXhwIjo0MTAyNDMyNzQ5LCJhdWQiOiJ0ZXN0Iiwic3ViIjoibWFrZXN3aWZ0LXJ1bnRpbWUifQ.-1BDOmEN1Q1QeKP7qfjPyAkrKRjb4q4qaqyhPBvMnhg',\n} as const\n\nexport const TestOrigins = {\n apiOrigin: 'https://api.fakeswift.com',\n appOrigin: 'https://app.fakeswift.com',\n} as const\n"],"mappings":"AAEO,MAAM,yBAAsC;AAAA,EACjD,SAAS;AAAA,EACT,OACE;AACJ;AAEO,MAAM,cAAc;AAAA,EACzB,WAAW;AAAA,EACX,WAAW;AACb;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/esm-compat.ts"],"sourcesContent":["// see https://www.npmjs.com/package/vite-plugin-cjs-interop\nexport const esmCompat = <T>(x: T): T => (x as any).default ?? x\n"],"mappings":"AACO,MAAM,YAAY,CAAI,MAAa,EAAU,WAAW;","names":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const ApiHandlerHeaders: {
|
|
3
|
+
SiteVersion: string;
|
|
4
|
+
};
|
|
5
|
+
export declare const siteVersionSchema: z.ZodObject<{
|
|
6
|
+
version: z.ZodString;
|
|
7
|
+
token: z.ZodString;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
version: string;
|
|
10
|
+
token: string;
|
|
11
|
+
}, {
|
|
12
|
+
version: string;
|
|
13
|
+
token: string;
|
|
14
|
+
}>;
|
|
15
|
+
export type SiteVersion = z.infer<typeof siteVersionSchema>;
|
|
16
|
+
export declare function serializeSiteVersion(data: SiteVersion): string;
|
|
17
|
+
export declare function secondsUntilSiteVersionExpiration(siteVersion: SiteVersion): number;
|
|
18
|
+
export declare function deserializeSiteVersion(input: string): SiteVersion | null;
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/api/site-version/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,eAAO,MAAM,iBAAiB;;CAE7B,CAAA;AAQD,eAAO,MAAM,iBAAiB;;;;;;;;;EAG5B,CAAA;AAEF,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAM3D,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,CAG9D;AA0BD,wBAAgB,iCAAiC,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAQlF;AAMD,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAcxE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"site-version.test.d.ts","sourceRoot":"","sources":["../../../../src/api/site-version/site-version.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { type ApiRequest, type ErrorResponseBody, ApiResponse } from '../request-response';
|
|
2
2
|
export type Manifest = {
|
|
3
3
|
version: string;
|
|
4
|
-
previewMode: boolean;
|
|
5
|
-
draftMode: boolean;
|
|
6
4
|
interactionMode: boolean;
|
|
7
5
|
clientSideNavigation: boolean;
|
|
8
6
|
elementFromPoint: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../../../src/api-handler/handlers/manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,WAAW,EAEZ,MAAM,qBAAqB,CAAA;AAE5B,MAAM,MAAM,QAAQ,GAAG;IACrB,OAAO,EAAE,MAAM,CAAA;IACf,
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../../../src/api-handler/handlers/manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,WAAW,EAEZ,MAAM,qBAAqB,CAAA;AAE5B,MAAM,MAAM,QAAQ,GAAG;IACrB,OAAO,EAAE,MAAM,CAAA;IACf,eAAe,EAAE,OAAO,CAAA;IACxB,oBAAoB,EAAE,OAAO,CAAA;IAC7B,gBAAgB,EAAE,OAAO,CAAA;IACzB,iBAAiB,EAAE,OAAO,CAAA;IAC1B,YAAY,EAAE,OAAO,CAAA;IACrB,qBAAqB,EAAE,OAAO,CAAA;IAC9B,gBAAgB,EAAE,OAAO,CAAA;IACzB,OAAO,EAAE,OAAO,CAAA;IAChB,6BAA6B,EAAE,OAAO,CAAA;CACvC,CAAA;AAED,wBAAsB,eAAe,CACnC,GAAG,EAAE,UAAU,EACf,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAA;CAAE,GACpE,OAAO,CAAC,WAAW,CAAC,QAAQ,GAAG,iBAAiB,CAAC,CAAC,CAqBpD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redirect-live.d.ts","sourceRoot":"","sources":["../../../../src/api-handler/handlers/redirect-live.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,UAAU,EAAE,WAAW,EAAgB,MAAM,qBAAqB,CAAA;AAKhF,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,UAAU,EACf,EAAE,kBAAkB,EAAE,EAAE;IAAE,kBAAkB,EAAE,MAAM,EAAE,CAAA;CAAE,GACvD,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAsB5B"}
|