slice-machine-ui 1.25.1-beta.1 → 1.25.1-beta.2
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/components/Simulator/components/FailedConnect/index.tsx +1 -1
- package/components/Simulator/index.tsx +17 -57
- package/lib/builders/SliceBuilder/SimulatorButton/index.tsx +4 -26
- package/lib/builders/SliceBuilder/index.tsx +1 -11
- package/lib/models/common/Environment.ts +0 -1
- package/out/404.html +1 -1
- package/out/_next/static/chunks/{474-5a072e6fac61f703.js → 210-aee6116139329803.js} +2 -2
- package/out/_next/static/chunks/46-d22d7a121254e31d.js +8 -0
- package/out/_next/static/chunks/{696-b12edad30a3617e5.js → 696-b992b9e1ce75777e.js} +1 -1
- package/out/_next/static/chunks/{904-bed9c8dade39dc27.js → 904-1a755ebb0f5ee4ac.js} +1 -1
- package/out/_next/static/chunks/pages/{_app-e32e7f8142e6cde0.js → _app-c0d8973a13d54a4c.js} +23 -23
- package/out/_next/static/chunks/pages/custom-types/{[customTypeId]-97ab3b90b85d645d.js → [customTypeId]-d1a4a07e6b600fa6.js} +1 -1
- package/out/_next/static/chunks/pages/page-types/{[pageTypeId]-84a22c5e480d3fa9.js → [pageTypeId]-a724ff12ef322020.js} +1 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/simulator-3eb0fdce3228d389.js +1 -0
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-ba6c3e2624f32fcd.js +1 -0
- package/out/_next/static/re4cxnEJmZdCTdRZZUIWc/_buildManifest.js +1 -0
- package/out/changelog.html +1 -1
- package/out/changes.html +1 -1
- package/out/custom-types/[customTypeId].html +1 -1
- package/out/custom-types.html +1 -1
- package/out/index.html +1 -1
- package/out/labs.html +1 -1
- package/out/page-types/[pageTypeId].html +1 -1
- package/out/settings.html +1 -1
- package/out/slices/[lib]/[sliceName]/[variation]/simulator.html +1 -1
- package/out/slices/[lib]/[sliceName]/[variation].html +1 -1
- package/out/slices.html +1 -1
- package/package.json +3 -5
- package/src/apiClient.ts +0 -6
- package/src/modules/environment/index.ts +0 -6
- package/src/modules/modal/types.ts +0 -1
- package/src/modules/simulator/index.ts +5 -133
- package/src/modules/simulator/types.ts +0 -6
- package/src/modules/useSliceMachineActions.ts +1 -11
- package/test/__testutils__/createTestPlugin.ts +0 -1
- package/test/src/modules/__fixtures__/serverState.ts +0 -1
- package/test/src/modules/simulator.test.ts +0 -196
- package/components/CodeSpan/index.tsx +0 -23
- package/components/HTMLRenderer/index.tsx +0 -137
- package/components/Simulator/components/SetupModal/TextWithInlineCode.tsx +0 -21
- package/components/Simulator/components/SetupModal/index.tsx +0 -165
- package/out/_next/static/PAJQyEuW0rRHPSn18wYrk/_buildManifest.js +0 -1
- package/out/_next/static/chunks/777-7bc4ca95c82802e5.js +0 -8
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/simulator-a8213af71b0a99c9.js +0 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-60858a3cead6dc81.js +0 -1
- /package/out/_next/static/{PAJQyEuW0rRHPSn18wYrk → re4cxnEJmZdCTdRZZUIWc}/_ssgManifest.js +0 -0
|
@@ -41,7 +41,7 @@ const FailedConnect = ({ onRetrigger }: { onRetrigger: () => void }) => (
|
|
|
41
41
|
<br /> If that doesn't work, see the
|
|
42
42
|
<Link
|
|
43
43
|
target="_blank"
|
|
44
|
-
href="https://prismic.io/docs/slice-machine"
|
|
44
|
+
href="https://prismic.io/docs/slice-machine#simulate-slices"
|
|
45
45
|
sx={{
|
|
46
46
|
color: "link",
|
|
47
47
|
}}
|
|
@@ -39,20 +39,16 @@ import IframeRenderer from "./components/IframeRenderer";
|
|
|
39
39
|
import {
|
|
40
40
|
selectIframeStatus,
|
|
41
41
|
selectIsWaitingForIFrameCheck,
|
|
42
|
-
selectSetupStatus,
|
|
43
42
|
} from "@src/modules/simulator";
|
|
44
43
|
import { ErrorBoundary } from "@src/ErrorBoundary";
|
|
45
44
|
|
|
46
45
|
import FullPage from "./components/FullPage";
|
|
47
46
|
import FailedConnect from "./components/FailedConnect";
|
|
48
|
-
import SetupModal from "./components/SetupModal";
|
|
49
47
|
import { Slices, VariationSM } from "@lib/models/common/Slice";
|
|
50
48
|
import { ComponentUI } from "@lib/models/common/ComponentUI";
|
|
51
49
|
|
|
52
50
|
export enum UiState {
|
|
53
|
-
LOADING_SETUP = "LOADING_SETUP",
|
|
54
51
|
LOADING_IFRAME = "LOADING_IFRAME",
|
|
55
|
-
FAILED_SETUP = "FAILED_SETUP",
|
|
56
52
|
FAILED_CONNECT = "FAILED_CONNECT",
|
|
57
53
|
SUCCESS = "SUCCESS",
|
|
58
54
|
}
|
|
@@ -63,24 +59,15 @@ type SimulatorProps = {
|
|
|
63
59
|
};
|
|
64
60
|
|
|
65
61
|
const Simulator: FC<SimulatorProps> = ({ slice, variation }) => {
|
|
66
|
-
const {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
isWaitingForIFrameCheck,
|
|
76
|
-
endpoints,
|
|
77
|
-
} = useSelector((state: SliceMachineStoreType) => ({
|
|
78
|
-
simulatorUrl: selectSimulatorUrl(state),
|
|
79
|
-
iframeStatus: selectIframeStatus(state),
|
|
80
|
-
manifestStatus: selectSetupStatus(state).manifest,
|
|
81
|
-
isWaitingForIFrameCheck: selectIsWaitingForIFrameCheck(state),
|
|
82
|
-
endpoints: selectEndpoints(state),
|
|
83
|
-
}));
|
|
62
|
+
const { connectToSimulatorIframe, updateSliceMockSuccess } =
|
|
63
|
+
useSliceMachineActions();
|
|
64
|
+
const { simulatorUrl, iframeStatus, isWaitingForIFrameCheck, endpoints } =
|
|
65
|
+
useSelector((state: SliceMachineStoreType) => ({
|
|
66
|
+
simulatorUrl: selectSimulatorUrl(state),
|
|
67
|
+
iframeStatus: selectIframeStatus(state),
|
|
68
|
+
isWaitingForIFrameCheck: selectIsWaitingForIFrameCheck(state),
|
|
69
|
+
endpoints: selectEndpoints(state),
|
|
70
|
+
}));
|
|
84
71
|
|
|
85
72
|
const editorConfig: EditorConfig = useMemo(
|
|
86
73
|
() => ({
|
|
@@ -91,12 +78,7 @@ const Simulator: FC<SimulatorProps> = ({ slice, variation }) => {
|
|
|
91
78
|
[endpoints.PrismicOembed, endpoints.PrismicUnsplash],
|
|
92
79
|
);
|
|
93
80
|
|
|
94
|
-
const setupIntervalId = useRef<NodeJS.Timeout | null>(null);
|
|
95
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
96
|
-
const checkSimulatorSetupCb = useCallback(() => checkSimulatorSetup(), []);
|
|
97
|
-
|
|
98
81
|
useEffect(() => {
|
|
99
|
-
checkSimulatorSetup();
|
|
100
82
|
void telemetry.track({ event: "slice-simulator:open" });
|
|
101
83
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
102
84
|
}, []);
|
|
@@ -114,41 +96,20 @@ const Simulator: FC<SimulatorProps> = ({ slice, variation }) => {
|
|
|
114
96
|
};
|
|
115
97
|
|
|
116
98
|
const currentState: UiState = (() => {
|
|
117
|
-
|
|
118
|
-
|
|
99
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
100
|
+
if (isWaitingForIFrameCheck || !iframeStatus) {
|
|
101
|
+
return UiState.LOADING_IFRAME;
|
|
119
102
|
}
|
|
120
|
-
if (
|
|
121
|
-
|
|
122
|
-
if (isWaitingForIFrameCheck || !iframeStatus) {
|
|
123
|
-
return UiState.LOADING_IFRAME;
|
|
124
|
-
}
|
|
125
|
-
if (iframeStatus !== "ok") {
|
|
126
|
-
return UiState.FAILED_CONNECT;
|
|
127
|
-
}
|
|
128
|
-
return UiState.SUCCESS;
|
|
103
|
+
if (iframeStatus !== "ok") {
|
|
104
|
+
return UiState.FAILED_CONNECT;
|
|
129
105
|
}
|
|
130
|
-
return UiState.
|
|
106
|
+
return UiState.SUCCESS;
|
|
131
107
|
})();
|
|
132
108
|
|
|
133
109
|
useEffect(() => {
|
|
134
|
-
|
|
135
|
-
const id = setInterval(() => {
|
|
136
|
-
checkSimulatorSetupCb();
|
|
137
|
-
}, 3000);
|
|
138
|
-
setupIntervalId.current = id;
|
|
139
|
-
}
|
|
140
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
141
|
-
}, [currentState]);
|
|
142
|
-
|
|
143
|
-
useEffect(() => {
|
|
144
|
-
if (manifestStatus === "ok") {
|
|
145
|
-
if (setupIntervalId.current) {
|
|
146
|
-
clearInterval(setupIntervalId.current);
|
|
147
|
-
}
|
|
148
|
-
connectToSimulatorIframe();
|
|
149
|
-
}
|
|
110
|
+
connectToSimulatorIframe();
|
|
150
111
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
151
|
-
}, [
|
|
112
|
+
}, []);
|
|
152
113
|
|
|
153
114
|
useEffect(() => {
|
|
154
115
|
if (currentState === UiState.FAILED_CONNECT) {
|
|
@@ -255,7 +216,6 @@ const Simulator: FC<SimulatorProps> = ({ slice, variation }) => {
|
|
|
255
216
|
|
|
256
217
|
return (
|
|
257
218
|
<Flex sx={{ flexDirection: "column", height: "100vh" }}>
|
|
258
|
-
<SetupModal isOpen={currentState === UiState.FAILED_SETUP} />
|
|
259
219
|
<Header
|
|
260
220
|
slice={slice}
|
|
261
221
|
variation={variation}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Button, tokens } from "@prismicio/editor-ui";
|
|
2
2
|
import React, { PropsWithChildren, useEffect, useRef } from "react";
|
|
3
|
-
import { Text } from "theme-ui";
|
|
4
3
|
|
|
5
4
|
import { SIMULATOR_WINDOW_ID, VIDEO_SIMULATOR_TOOLTIP } from "@lib/consts";
|
|
6
5
|
import { useRouter } from "next/router";
|
|
@@ -13,7 +12,6 @@ import { SliceMachineStoreType } from "@src/redux/type";
|
|
|
13
12
|
import useSliceMachineActions from "@src/modules/useSliceMachineActions";
|
|
14
13
|
import { telemetry } from "@src/apiClient";
|
|
15
14
|
|
|
16
|
-
import { ReactTooltipPortal } from "@components/ReactTooltipPortal";
|
|
17
15
|
import {
|
|
18
16
|
HoverCard,
|
|
19
17
|
HoverCardCloseButton,
|
|
@@ -22,21 +20,6 @@ import {
|
|
|
22
20
|
HoverCardTitle,
|
|
23
21
|
} from "@src/components/HoverCard";
|
|
24
22
|
|
|
25
|
-
const SimulatorNotSupportedTooltip: React.FC = () => (
|
|
26
|
-
<ReactTooltipPortal>
|
|
27
|
-
<ReactTooltip
|
|
28
|
-
clickable
|
|
29
|
-
place="bottom"
|
|
30
|
-
effect="solid"
|
|
31
|
-
delayHide={500}
|
|
32
|
-
id="simulator-button-tooltip"
|
|
33
|
-
>
|
|
34
|
-
<Text as="b">Framework not supported</Text>
|
|
35
|
-
<Text as="p">Slice Simulator does not support your framework yet.</Text>
|
|
36
|
-
</ReactTooltip>
|
|
37
|
-
</ReactTooltipPortal>
|
|
38
|
-
);
|
|
39
|
-
|
|
40
23
|
const SimulatorOnboardingTooltip: React.FC<
|
|
41
24
|
PropsWithChildren<{
|
|
42
25
|
open: boolean;
|
|
@@ -71,9 +54,8 @@ const SimulatorOnboardingTooltip: React.FC<
|
|
|
71
54
|
};
|
|
72
55
|
|
|
73
56
|
const SimulatorButton: React.FC<{
|
|
74
|
-
isSimulatorAvailableForFramework: boolean;
|
|
75
57
|
disabled: boolean;
|
|
76
|
-
}> = ({
|
|
58
|
+
}> = ({ disabled }) => {
|
|
77
59
|
const router = useRouter();
|
|
78
60
|
|
|
79
61
|
const ref = useRef<HTMLButtonElement | null>(null);
|
|
@@ -88,10 +70,10 @@ const SimulatorButton: React.FC<{
|
|
|
88
70
|
|
|
89
71
|
useEffect(() => {
|
|
90
72
|
const node = ref.current;
|
|
91
|
-
if (node &&
|
|
73
|
+
if (node && !hasSeenSimulatorTooltip) {
|
|
92
74
|
setTimeout(() => ReactTooltip.show(node), 5000);
|
|
93
75
|
}
|
|
94
|
-
}, [
|
|
76
|
+
}, [hasSeenSimulatorTooltip]);
|
|
95
77
|
|
|
96
78
|
const onCloseToolTip = () => {
|
|
97
79
|
setSeenSimulatorToolTip();
|
|
@@ -101,8 +83,7 @@ const SimulatorButton: React.FC<{
|
|
|
101
83
|
}
|
|
102
84
|
};
|
|
103
85
|
|
|
104
|
-
const shouldShowSimulatorTooltip =
|
|
105
|
-
isSimulatorAvailableForFramework && !hasSeenSimulatorTooltip;
|
|
86
|
+
const shouldShowSimulatorTooltip = !hasSeenSimulatorTooltip;
|
|
106
87
|
|
|
107
88
|
return (
|
|
108
89
|
<span
|
|
@@ -138,9 +119,6 @@ const SimulatorButton: React.FC<{
|
|
|
138
119
|
Simulate
|
|
139
120
|
</Button>
|
|
140
121
|
</SimulatorOnboardingTooltip>
|
|
141
|
-
{isSimulatorAvailableForFramework === false ? (
|
|
142
|
-
<SimulatorNotSupportedTooltip />
|
|
143
|
-
) : undefined}
|
|
144
122
|
</span>
|
|
145
123
|
);
|
|
146
124
|
};
|
|
@@ -4,8 +4,6 @@ import { type FC } from "react";
|
|
|
4
4
|
import FieldZones from "./FieldZones";
|
|
5
5
|
import { Sidebar } from "./Sidebar";
|
|
6
6
|
|
|
7
|
-
import { useSelector } from "react-redux";
|
|
8
|
-
|
|
9
7
|
import SimulatorButton from "@builders/SliceBuilder/SimulatorButton";
|
|
10
8
|
import {
|
|
11
9
|
AppLayout,
|
|
@@ -16,17 +14,12 @@ import {
|
|
|
16
14
|
AppLayoutHeader,
|
|
17
15
|
} from "@components/AppLayout";
|
|
18
16
|
import { FloatingBackButton } from "@src/features/slices/sliceBuilder/FloatingBackButton";
|
|
19
|
-
import { selectIsSimulatorAvailableForFramework } from "@src/modules/environment";
|
|
20
17
|
import { useSliceState } from "@src/features/slices/sliceBuilder/SliceBuilderProvider";
|
|
21
18
|
import { AutoSaveStatusIndicator } from "@src/features/autoSave/AutoSaveStatusIndicator";
|
|
22
19
|
|
|
23
20
|
export const SliceBuilder: FC = () => {
|
|
24
21
|
const { slice, actionQueueStatus } = useSliceState();
|
|
25
22
|
|
|
26
|
-
const isSimulatorAvailableForFramework = useSelector(
|
|
27
|
-
selectIsSimulatorAvailableForFramework,
|
|
28
|
-
);
|
|
29
|
-
|
|
30
23
|
return (
|
|
31
24
|
<AppLayout>
|
|
32
25
|
<AppLayoutHeader>
|
|
@@ -34,10 +27,7 @@ export const SliceBuilder: FC = () => {
|
|
|
34
27
|
<AppLayoutBreadcrumb folder="Slices" page={slice.model.name} />
|
|
35
28
|
<AppLayoutActions>
|
|
36
29
|
<AutoSaveStatusIndicator status={actionQueueStatus} />
|
|
37
|
-
<SimulatorButton
|
|
38
|
-
isSimulatorAvailableForFramework={isSimulatorAvailableForFramework}
|
|
39
|
-
disabled={actionQueueStatus !== "done"}
|
|
40
|
-
/>
|
|
30
|
+
<SimulatorButton disabled={actionQueueStatus !== "done"} />
|
|
41
31
|
</AppLayoutActions>
|
|
42
32
|
</AppLayoutHeader>
|
|
43
33
|
<AppLayoutContent>
|
package/out/404.html
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/css/4f1e84c70ef0e169.css" as="style"/><link rel="stylesheet" href="/_next/static/css/4f1e84c70ef0e169.css" data-n-g=""/><noscript data-n-css=""></noscript><script defer="" nomodule="" src="/_next/static/chunks/polyfills-c67a75d1b6f99dc8.js"></script><script src="/_next/static/chunks/webpack-2f903acb0cccbf9e.js" defer=""></script><script src="/_next/static/chunks/framework-cdccea7a52cc6e81.js" defer=""></script><script src="/_next/static/chunks/main-5e6780279ca21cb9.js" defer=""></script><script src="/_next/static/chunks/pages/_app-
|
|
1
|
+
<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/css/4f1e84c70ef0e169.css" as="style"/><link rel="stylesheet" href="/_next/static/css/4f1e84c70ef0e169.css" data-n-g=""/><noscript data-n-css=""></noscript><script defer="" nomodule="" src="/_next/static/chunks/polyfills-c67a75d1b6f99dc8.js"></script><script src="/_next/static/chunks/webpack-2f903acb0cccbf9e.js" defer=""></script><script src="/_next/static/chunks/framework-cdccea7a52cc6e81.js" defer=""></script><script src="/_next/static/chunks/main-5e6780279ca21cb9.js" defer=""></script><script src="/_next/static/chunks/pages/_app-c0d8973a13d54a4c.js" defer=""></script><script src="/_next/static/chunks/pages/_error-69b4f498bafdd188.js" defer=""></script><script src="/_next/static/re4cxnEJmZdCTdRZZUIWc/_buildManifest.js" defer=""></script><script src="/_next/static/re4cxnEJmZdCTdRZZUIWc/_ssgManifest.js" defer=""></script></head><body><div id="__next"></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":404}},"page":"/_error","query":{},"buildId":"re4cxnEJmZdCTdRZZUIWc","runtimeConfig":{"sentryEnvironment":"beta"},"nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
|