slice-machine-ui 1.26.1-alpha.aa-playground-script.1 → 1.26.1-beta.1

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.
Files changed (30) hide show
  1. package/components/Simulator/components/IframeRenderer/index.tsx +6 -8
  2. package/components/Simulator/index.tsx +40 -44
  3. package/out/404.html +1 -1
  4. package/out/_next/static/chunks/pages/{_app-b57b205722703789.js → _app-756c037ed6c707e9.js} +49 -49
  5. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/simulator-01d67e97cb901e46.js +1 -0
  6. package/out/_next/static/{Xw1akSboLhT-BhSrQS3lZ → dLmvq3LL0BsWu15laiKoK}/_buildManifest.js +1 -1
  7. package/out/changelog.html +1 -1
  8. package/out/changes.html +1 -1
  9. package/out/custom-types/[customTypeId].html +1 -1
  10. package/out/custom-types.html +1 -1
  11. package/out/index.html +1 -1
  12. package/out/labs.html +1 -1
  13. package/out/page-types/[pageTypeId].html +1 -1
  14. package/out/settings.html +1 -1
  15. package/out/slices/[lib]/[sliceName]/[variation]/simulator.html +1 -1
  16. package/out/slices/[lib]/[sliceName]/[variation].html +1 -1
  17. package/out/slices.html +1 -1
  18. package/package.json +3 -4
  19. package/src/modules/loading/index.ts +0 -24
  20. package/src/modules/loading/types.ts +0 -3
  21. package/src/modules/useSliceMachineActions.ts +1 -14
  22. package/src/redux/reducer.ts +0 -2
  23. package/src/redux/store.ts +1 -5
  24. package/src/redux/type.ts +0 -2
  25. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/simulator-3eb0fdce3228d389.js +0 -1
  26. package/src/modules/simulator/index.ts +0 -102
  27. package/src/modules/simulator/types.ts +0 -5
  28. package/src/redux/saga.ts +0 -8
  29. package/test/src/modules/simulator.test.ts +0 -43
  30. /package/out/_next/static/{Xw1akSboLhT-BhSrQS3lZ → dLmvq3LL0BsWu15laiKoK}/_ssgManifest.js +0 -0
@@ -1,102 +0,0 @@
1
- import { fork, put, takeLeading, race, take, delay } from "redux-saga/effects";
2
- import { Reducer } from "redux";
3
- import { ActionType, createAsyncAction, getType } from "typesafe-actions";
4
-
5
- import { LoadingKeysEnum } from "@src/modules/loading/types";
6
- import { SliceMachineStoreType } from "@src/redux/type";
7
- import { withLoader } from "@src/modules/loading";
8
-
9
- import { SimulatorStoreType } from "./types";
10
-
11
- export const initialState: SimulatorStoreType = {
12
- iframeStatus: null,
13
- isWaitingForIframeCheck: false,
14
- };
15
-
16
- export const connectToSimulatorIframeCreator = createAsyncAction(
17
- "SIMULATOR/CONNECT_TO_SIMULATOR_IFRAME.REQUEST",
18
- "SIMULATOR/CONNECT_TO_SIMULATOR_IFRAME.SUCCESS",
19
- "SIMULATOR/CONNECT_TO_SIMULATOR_IFRAME.FAILURE",
20
- )<undefined, undefined, undefined>();
21
-
22
- type SimulatorActions = ActionType<
23
- | typeof connectToSimulatorIframeCreator.success
24
- | typeof connectToSimulatorIframeCreator.request
25
- | typeof connectToSimulatorIframeCreator.failure
26
- >;
27
-
28
- // Selectors
29
-
30
- export const selectIsWaitingForIFrameCheck = (
31
- state: SliceMachineStoreType,
32
- ): boolean => state.simulator.isWaitingForIframeCheck;
33
-
34
- export const selectIframeStatus = (
35
- state: SliceMachineStoreType,
36
- ): string | null => state.simulator.iframeStatus;
37
-
38
- // Reducer
39
- export const simulatorReducer: Reducer<SimulatorStoreType, SimulatorActions> = (
40
- state = initialState,
41
- action,
42
- ) => {
43
- switch (action.type) {
44
- case getType(connectToSimulatorIframeCreator.request):
45
- return {
46
- ...state,
47
- iframeStatus: null,
48
- isWaitingForIframeCheck: true,
49
- };
50
- case getType(connectToSimulatorIframeCreator.success):
51
- return {
52
- ...state,
53
- iframeStatus: "ok",
54
- isWaitingForIframeCheck: false,
55
- };
56
- case getType(connectToSimulatorIframeCreator.failure):
57
- return {
58
- ...state,
59
- iframeStatus: "ko",
60
- isWaitingForIframeCheck: false,
61
- };
62
- default:
63
- return state;
64
- }
65
- };
66
-
67
- function* connectToSimulatorIframe() {
68
- yield put(connectToSimulatorIframeCreator.request());
69
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
70
- const {
71
- iframeCheckOk,
72
- }: {
73
- iframeCheckOk: ReturnType<typeof connectToSimulatorIframeCreator.success>;
74
- } = yield race({
75
- iframeCheckOk: take(getType(connectToSimulatorIframeCreator.success)),
76
- iframeCheckKO: take(getType(connectToSimulatorIframeCreator.failure)),
77
- timeout: delay(20000),
78
- });
79
-
80
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
81
- if (iframeCheckOk) {
82
- yield put(connectToSimulatorIframeCreator.success());
83
- return;
84
- }
85
-
86
- yield put(connectToSimulatorIframeCreator.failure());
87
- }
88
-
89
- function* watchIframeCheck() {
90
- yield takeLeading(
91
- getType(connectToSimulatorIframeCreator.request),
92
- withLoader(
93
- connectToSimulatorIframe,
94
- LoadingKeysEnum.CHECK_SIMULATOR_IFRAME,
95
- ),
96
- );
97
- }
98
-
99
- // Saga Exports
100
- export function* watchSimulatorSagas() {
101
- yield fork(watchIframeCheck);
102
- }
@@ -1,5 +0,0 @@
1
- export type SimulatorStoreType = {
2
- // we use strings to check if key is defined
3
- iframeStatus: "ok" | "ko" | null;
4
- isWaitingForIframeCheck: boolean;
5
- };
package/src/redux/saga.ts DELETED
@@ -1,8 +0,0 @@
1
- import { fork } from "redux-saga/effects";
2
-
3
- import { watchSimulatorSagas } from "@src/modules/simulator";
4
-
5
- // Single entry point to start all Sagas at once
6
- export default function* rootSaga() {
7
- yield fork(watchSimulatorSagas);
8
- }
@@ -1,43 +0,0 @@
1
- // @vitest-environment jsdom
2
-
3
- import { describe, expect, it } from "vitest";
4
-
5
- import {
6
- initialState,
7
- simulatorReducer,
8
- connectToSimulatorIframeCreator,
9
- } from "@src/modules/simulator";
10
- import { SimulatorStoreType } from "@src/modules/simulator/types";
11
-
12
- const dummySimulatorState: SimulatorStoreType = initialState;
13
-
14
- describe("[Simulator module]", () => {
15
- describe("[Reducer]", () => {
16
- it("should return the initial state if no action", () => {
17
- // @ts-expect-error TS(2345) FIXME: Argument of type '{}' is not assignable to paramet... Remove this comment to see the full error message
18
- expect(simulatorReducer(dummySimulatorState, {})).toEqual(
19
- dummySimulatorState,
20
- );
21
- });
22
-
23
- it("should return the initial state if no matching action", () => {
24
- expect(
25
- // @ts-expect-error TS(2322) FIXME: Type '"NO.MATCH"' is not assignable to type '"SIMU... Remove this comment to see the full error message
26
- simulatorReducer(dummySimulatorState, { type: "NO.MATCH" }),
27
- ).toEqual(dummySimulatorState);
28
- });
29
-
30
- it("should update the state when given connectToSimulatorIframeCreator.success action", () => {
31
- const initialState: SimulatorStoreType = dummySimulatorState;
32
-
33
- const action = connectToSimulatorIframeCreator.success();
34
-
35
- const expectedState: SimulatorStoreType = {
36
- ...dummySimulatorState,
37
- iframeStatus: "ok",
38
- };
39
-
40
- expect(simulatorReducer(initialState, action)).toEqual(expectedState);
41
- });
42
- });
43
- });