Skip to content

Commit

Permalink
feat: redux typings refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
hlolli committed Dec 15, 2024
1 parent fdaf71b commit 11c4f97
Show file tree
Hide file tree
Showing 75 changed files with 2,203 additions and 4,867 deletions.
81 changes: 23 additions & 58 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@
"@csound/browser": "^6.18.7",
"@emotion/core": "^11.0.0",
"@emotion/css": "^11.13.5",
"@emotion/react": "^11.13.5",
"@emotion/styled": "^11.13.5",
"@emotion/react": "^11.14.0",
"@emotion/styled": "^11.14.0",
"@hlolli/codemirror-lang-csound": "^1.0.0-alpha9",
"@mui/icons-material": "^6.1.10",
"@mui/material": "^6.1.10",
"@reduxjs/toolkit": "^2.4.0",
"@mui/icons-material": "^6.2.0",
"@mui/material": "^6.2.0",
"@reduxjs/toolkit": "^2.5.0",
"@vitejs/plugin-react": "^4.3.4",
"connected-react-router": "^6.9.3",
"csound7": "npm:@csound/browser@^7.0.0-alpha2",
"date-fns": "^4.1.0",
"firebase-functions": "^6.1.1",
"history": "^5.3.0",
"firebase-functions": "^6.1.2",
"history": "5.3.0",
"mime": "^4.0.4",
"ramda": "^0.30.1",
"react": "^19.0.0",
Expand All @@ -51,11 +51,11 @@
"react-perfect-scrollbar": "^1.5.8",
"react-piano": "^3.1.3",
"react-poppop": "^1.5.0",
"react-redux": "^9.1.2",
"react-redux": "^9.2.0",
"react-refresh": "^0.16.0",
"react-router": "^7.0.2",
"react-router-dom": "^7.0.2",
"react-select": "^5.8.3",
"react-select": "^5.9.0",
"react-share": "^5.1.1",
"react-sortable-hoc": "^2.0.0",
"react-split-pane": "^0.1.92",
Expand All @@ -79,31 +79,31 @@
"@babel/preset-typescript": "^7.26.0",
"@babel/runtime": "^7.26.0",
"@emotion/babel-preset-css-prop": "^11.12.0",
"@eslint/js": "^9.16.0",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.15",
"@sentry/browser": "^8.42.0",
"@svgr/webpack": "^8.1.0",
"@eslint/js": "^9.17.0",
"@sentry/browser": "^8.45.0",
"@testing-library/react": "^16.1.0",
"@types/eslint__js": "^8.42.3",
"@types/history": "4.7.11",
"@types/jest": "^29.5.14",
"@types/lodash": "^4.17.13",
"@types/node": "^22.10.2",
"@types/ramda": "^0.30.2",
"@types/react": "^19.0.1",
"@types/react-dom": "^19.0.1",
"@types/react-color": "^3.0.13",
"@types/react-dom": "^19.0.2",
"@types/react-onclickoutside": "^6.7.10",
"@types/react-redux": "^7.1.34",
"@typescript-eslint/eslint-plugin": "^8.17.0",
"@typescript-eslint/parser": "^8.17.0",
"@types/throttle-debounce": "^5.0.2",
"@typescript-eslint/eslint-plugin": "^8.18.0",
"@typescript-eslint/parser": "^8.18.0",
"array-move": "^4.0.0",
"autosuggest-highlight": "^3.3.4",
"babel-eslint": "10.1.0",
"babel-loader": "9.2.1",
"babel-plugin-named-asset-import": "^0.3.8",
"camelcase": "^8.0.0",
"case-sensitive-paths-webpack-plugin": "2.4.0",
"codemirror": "^6.0.1",
"concurrently": "^9.1.0",
"copy-webpack-plugin": "^12.0.2",
"cross-env": "^7.0.3",
"css-loader": "7.1.2",
"d3-scale": "^4.0.2",
Expand All @@ -113,7 +113,7 @@
"electron": "^33.2.1",
"electron-builder": "^25.1.8",
"electron-is-dev": "^3.0.1",
"eslint": "^9.16.0",
"eslint": "^9.17.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-react-app": "^7.0.1",
"eslint-import-resolver-alias": "^1.1.2",
Expand All @@ -124,15 +124,12 @@
"eslint-plugin-react": "7.37.2",
"eslint-plugin-react-hooks": "^5.1.0",
"eslint-plugin-unicorn": "^56.0.1",
"eslint-webpack-plugin": "^4.2.0",
"file-loader": "6.2.0",
"file-saver": "^2.0.5",
"firebase": "^11.0.2",
"fork-ts-checker-webpack-plugin": "^9.0.2",
"firebase": "^11.1.0",
"fuse.js": "^7.0.0",
"globals": "^15.13.0",
"hex-rgb": "^5.0.0",
"html-webpack-plugin": "5.6.3",
"husky": "^9.1.7",
"jest": "29.7.0",
"jest-environment-jsdom-fourteen": "1.0.1",
Expand All @@ -141,57 +138,25 @@
"jszip": "^3.10.1",
"lodash": "^4.17.21",
"moment": "^2.30.1",
"pnp-webpack-plugin": "1.7.0",
"postcss-loader": "8.1.1",
"prettier": "^3.4.2",
"raw-loader": "^4.0.2",
"react-app-polyfill": "^3.0.0",
"react-redux-test-renderer": "^4.0.1",
"reselect": "^5.1.1",
"resolve": "1.22.8",
"resolve-url-loader": "5.0.0",
"robotstxt-webpack-plugin": "^8.0.0",
"sitemap-webpack-plugin": "^1.1.1",
"source-map-loader": "^5.0.0",
"resolve": "1.22.9",
"stream-browserify": "^3.0.0",
"style-loader": "4.0.0",
"terser-webpack-plugin": "5.3.10",
"throttle-debounce": "^5.0.2",
"ts-jest": "^29.2.5",
"ts-loader": "^9.5.1",
"ts-pnp": "1.2.0",
"typescript": "^5.7.2",
"typescript-eslint": "^8.17.0",
"url-loader": "4.1.1",
"typescript-eslint": "^8.18.0",
"uuid": "^11.0.3",
"vite-plugin-checker": "^0.8.0",
"vite-plugin-svgr": "^4.3.0",
"webpack": "5.97.1",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "5.1.0",
"webpack-manifest-plugin": "5.0.0",
"workbox-webpack-plugin": "7.3.0",
"workerize-loader": "^2.0.2"
"vite-plugin-svgr": "^4.3.0"
},
"resolutions": {
"react-iframe-comm/react": "*",
"react-iframe-comm/react-dom": "*",
"@babel/plugin-syntax-class-static-block@^7.0": "7.14.5",
"@hlolli/react-codemirror/codemirror": "^6.0.1"
},
"engines": {
"node": ">=15"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
27 changes: 10 additions & 17 deletions src/components/bottom-tabs/actions.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { AppThunkDispatch } from "@root/store";
import {
BottomTab,
CLOSE_BOTTOM_TAB,
Expand All @@ -6,30 +7,22 @@ import {
SET_BOTTOM_TAB_INDEX
} from "./types";

export const setBottomTabIndex = (
newIndex: number
): ((dispatch: (any) => void) => void) => {
return async (dispatch: any) =>
export const setBottomTabIndex = (newIndex: number) => {
return async (dispatch: AppThunkDispatch) =>
dispatch({ type: SET_BOTTOM_TAB_INDEX, newIndex });
};

export const reorderBottomTabs = (
newOrder: BottomTab[],
newIndex: number
): ((dispatch: (any) => void) => void) => {
return async (dispatch: any) =>
export const reorderBottomTabs = (newOrder: BottomTab[], newIndex: number) => {
return async (dispatch: AppThunkDispatch) =>
dispatch({ type: REORDER_TABS, newIndex, newOrder });
};

export const openBottomTab = (
tab: BottomTab
): ((dispatch: (any) => void) => void) => {
return async (dispatch: any) => dispatch({ type: OPEN_BOTTOM_TAB, tab });
export const openBottomTab = (tab: BottomTab) => {
return async (dispatch: AppThunkDispatch) =>
dispatch({ type: OPEN_BOTTOM_TAB, tab });
};

export const closeBottomTab = (
closeTab: BottomTab
): ((dispatch: (any) => void) => void) => {
return async (dispatch: any) =>
export const closeBottomTab = (closeTab: BottomTab) => {
return async (dispatch: AppThunkDispatch) =>
dispatch({ type: CLOSE_BOTTOM_TAB, closeTab });
};
73 changes: 34 additions & 39 deletions src/components/csound/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,36 +47,39 @@ export const setCsound = (csound: CsoundObj): void => {
);
};

export const syncFs = async (
csound: CsoundObj,
projectUid: string,
storeState: RootState
): Promise<void> => {
const documents = storeState.ProjectsReducer.projects[projectUid].documents;

for (const document of documents) {
// reminder: paths are store by document ref and not
// the actual filesystem name
const realPath = document.path.map((documentId) =>
path(
[
"ProjectsReducer",
"projects",
projectUid,
"documents",
documentId,
"name"
],
storeState
)
);
const filepath = isEmpty(realPath)
? document.filename
: realPath.join("/") + "/" + document.filename;

await addDocumentToEMFS(projectUid, csound, document, filepath);
}
};
// // can be deleted?
// export const syncFs = async (
// csound: CsoundObj,
// projectUid: string,
// storeState: RootState
// ): Promise<void> => {
// const documents = Object.keys(
// storeState.ProjectsReducer.projects[projectUid].documents
// );

// for (const document of documents) {
// // reminder: paths are store by document ref and not
// // the actual filesystem name
// const realPath = document.path.map((documentId: string) =>
// path(
// [
// "ProjectsReducer",
// "projects",
// projectUid,
// "documents",
// documentId,
// "name"
// ],
// storeState
// )
// );
// const filepath = isEmpty(realPath)
// ? document.filename
// : realPath.join("/") + "/" + document.filename;

// await addDocumentToEMFS(projectUid, csound, document, filepath);
// }
// };

export const playCsdFromFs = ({
projectUid,
Expand Down Expand Up @@ -112,7 +115,6 @@ export const playCsdFromFs = ({
await csoundObj.setOption("-odac");

const storeState = store.getState();
await syncFs(csoundObj, projectUid, storeState);
const result = await csoundObj.compileCsd(csdPath);

if (result === 0) {
Expand All @@ -137,8 +139,6 @@ export const playCsdFromFs = ({
);
}
}

await syncFs(csoundObj, projectUid, storeState);
});
await csoundObj.start();
dispatch(setCsoundPlayState("playing"));
Expand Down Expand Up @@ -190,7 +190,6 @@ export const playORCFromString = ({
await csoundObj.setOption("-odac");

const storeState = store.getState();
await syncFs(csoundObj, projectUid, storeState);

const result = await csoundObj.compileOrc(orc);

Expand Down Expand Up @@ -227,7 +226,7 @@ export const resumePausedCsound = () => {

export const renderToDisk = (
setConsole: any
): ((dispatch: (any) => void) => void) => {
): ((dispatch: (store: RootState) => void) => void) => {
return async (dispatch: any) => {
const state: RootState = store.getState();
const project: IProject | undefined = selectActiveProject(state);
Expand Down Expand Up @@ -284,8 +283,6 @@ export const renderToDisk = (
setConsole(append(message + "\n"))
);

await syncFs(csound, project.projectUid, state);

const filesPre = await csound.fs.readdir("/");

const targetDocumentName =
Expand Down Expand Up @@ -342,8 +339,6 @@ export const renderToDisk = (
}
}

await syncFs(csound, project.projectUid, state);

try {
await csound.terminateInstance();
} catch {}
Expand Down
7 changes: 5 additions & 2 deletions src/components/csound/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@ export interface ICsoundReducer {
}

const CsoundReducer = (
state: ICsoundReducer,
state: ICsoundReducer | undefined,
action: Record<string, any>
): ICsoundReducer => {
if (!state) {
return { status: "initialized" };
}
switch (action.type) {
case SET_CSOUND_PLAY_STATE: {
return assoc("status", action.status, state);
}
default: {
return state || { status: "initialized" };
return state;
}
}
};
Expand Down
Loading

0 comments on commit 11c4f97

Please sign in to comment.