From f49db74638a852ac8bc7335c2943314bf78a0dd5 Mon Sep 17 00:00:00 2001 From: nukeop <12746779+nukeop@users.noreply.github.com> Date: Wed, 18 Oct 2023 00:28:38 +0200 Subject: [PATCH] Fix app build --- package-lock.json | 45 ++++++++++++++++++- packages/app/package.json | 1 + packages/app/webpack.config.ts | 14 ++++-- packages/core/src/plugins/transform.ts | 4 +- packages/core/typings/babel.d.ts | 1 - .../TrackTable/Headers/ColumnHeader.tsx | 6 +-- .../ui/lib/components/TrackTable/index.tsx | 6 +-- packages/ui/package.json | 2 +- 8 files changed, 62 insertions(+), 17 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1a8077c389..57e2e399f2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19994,6 +19994,24 @@ "integrity": "sha512-e/1zu3xH5MQryN2zdVaF0OrdNLUbvWxzMbi+iNA6Bky7l1RoP8a2fIbRocyHclXt/arDrrR6lL3TqFD9pMQTsg==", "dev": true }, + "node_modules/deasync": { + "version": "0.1.28", + "resolved": "https://registry.npmjs.org/deasync/-/deasync-0.1.28.tgz", + "integrity": "sha512-QqLF6inIDwiATrfROIyQtwOQxjZuek13WRYZ7donU5wJPLoP67MnYxA6QtqdvdBy2mMqv5m3UefBVdJjvevOYg==", + "hasInstallScript": true, + "dependencies": { + "bindings": "^1.5.0", + "node-addon-api": "^1.7.1" + }, + "engines": { + "node": ">=0.11.0" + } + }, + "node_modules/deasync/node_modules/node-addon-api": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-1.7.2.tgz", + "integrity": "sha512-ibPK3iA+vaY1eEjESkQkM0BbCqFOaZMiXRTtdB0u7b4djtY6JnsjvPdUHVMg6xQt3B8fpTTWHI9A+ADjM9frzg==" + }, "node_modules/debounce-fn": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/debounce-fn/-/debounce-fn-3.0.1.tgz", @@ -46184,6 +46202,7 @@ } }, "packages/app": { + "name": "@nuclear/app", "version": "0.6.30", "hasInstallScript": true, "license": "AGPL-3.0", @@ -46201,6 +46220,7 @@ "classnames": "^2.2.6", "d3-drag": "^1.2.3", "d3-selection": "^1.4.0", + "deasync": "^0.1.28", "dotenv": "^8.2.0", "electron": "^12.1.0", "electron-timber": "^0.5.1", @@ -46289,6 +46309,7 @@ } }, "packages/core": { + "name": "@nuclear/core", "version": "0.6.30", "license": "AGPL-3.0", "dependencies": { @@ -46333,6 +46354,7 @@ } }, "packages/i18n": { + "name": "@nuclear/i18n", "version": "0.6.30", "license": "AGPL-3.0", "dependencies": { @@ -46346,6 +46368,7 @@ } }, "packages/main": { + "name": "@nuclear/main", "version": "0.6.30", "license": "AGPL-3.0", "dependencies": { @@ -46441,6 +46464,7 @@ } }, "packages/ui": { + "name": "@nuclear/ui", "version": "0.6.30", "license": "AGPL-3.0", "dependencies": { @@ -46489,7 +46513,7 @@ "@types/numeral": "0.0.28", "@types/react-beautiful-dnd": "^13.0.0", "@types/react-measure": "^2.0.6", - "@types/react-table": "^7.7.12", + "@types/react-table": "^7.7.16", "babel-eslint": "^10.0.3", "babel-loader": "^8.1.0", "copyfiles": "^2.2.0", @@ -50069,6 +50093,7 @@ "css-loader": "^5.2.7", "d3-drag": "^1.2.3", "d3-selection": "^1.4.0", + "deasync": "*", "dotenv": "^8.2.0", "electron": "^12.1.0", "electron-timber": "^0.5.1", @@ -50294,7 +50319,7 @@ "@types/numeral": "0.0.28", "@types/react-beautiful-dnd": "^13.0.0", "@types/react-measure": "^2.0.6", - "@types/react-table": "^7.7.12", + "@types/react-table": "^7.7.16", "@types/react-window": "^1.8.5", "babel-eslint": "^10.0.3", "babel-loader": "^8.1.0", @@ -62084,6 +62109,22 @@ "integrity": "sha512-e/1zu3xH5MQryN2zdVaF0OrdNLUbvWxzMbi+iNA6Bky7l1RoP8a2fIbRocyHclXt/arDrrR6lL3TqFD9pMQTsg==", "dev": true }, + "deasync": { + "version": "0.1.28", + "resolved": "https://registry.npmjs.org/deasync/-/deasync-0.1.28.tgz", + "integrity": "sha512-QqLF6inIDwiATrfROIyQtwOQxjZuek13WRYZ7donU5wJPLoP67MnYxA6QtqdvdBy2mMqv5m3UefBVdJjvevOYg==", + "requires": { + "bindings": "^1.5.0", + "node-addon-api": "^1.7.1" + }, + "dependencies": { + "node-addon-api": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-1.7.2.tgz", + "integrity": "sha512-ibPK3iA+vaY1eEjESkQkM0BbCqFOaZMiXRTtdB0u7b4djtY6JnsjvPdUHVMg6xQt3B8fpTTWHI9A+ADjM9frzg==" + } + } + }, "debounce-fn": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/debounce-fn/-/debounce-fn-3.0.1.tgz", diff --git a/packages/app/package.json b/packages/app/package.json index 3f227543f1..70c1d069ab 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -48,6 +48,7 @@ "classnames": "^2.2.6", "d3-drag": "^1.2.3", "d3-selection": "^1.4.0", + "deasync": "^0.1.28", "dotenv": "^8.2.0", "electron": "^12.1.0", "electron-timber": "^0.5.1", diff --git a/packages/app/webpack.config.ts b/packages/app/webpack.config.ts index ab81e7cfd6..e1c3aaf626 100644 --- a/packages/app/webpack.config.ts +++ b/packages/app/webpack.config.ts @@ -13,13 +13,17 @@ const UI_DIR = path.resolve(__dirname, 'node_modules', '@nuclear', 'ui'); const VENDOR_DIR = path.resolve(__dirname, '..', '..', 'node_modules'); const buildIncludedPaths = () => { - const paths = []; + const paths: string[] = []; const modules = ['core', 'i18n', 'ui']; const srcs = ['src', 'lib', 'index.js', 'index.ts']; modules.forEach((module) => { srcs.forEach((src) => { paths.push( - path.resolve(__dirname, 'node_modules', '@nuclear', module, src) + path.resolve( + __dirname, + '..', '..', + 'node_modules', '@nuclear', module, src + ) ); }); }); @@ -120,7 +124,9 @@ module.exports = (env) => { if (IS_PROD) { jsxRule.loader = 'ts-loader'; - jsxRule.options = {}; + jsxRule.options = { + allowTsInNodeModules: true + }; jsxRule.include = [APP_DIR, ...NUCLEAR_MODULES]; jsxRule.exclude = [ /node_modules\/electron-timber\/preload\.js/, @@ -153,7 +159,7 @@ module.exports = (env) => { mode: IS_PROD ? 'production' : 'development', optimization, resolve: { - extensions: ['*', '.js', '.ts', '.jsx', '.tsx', '.json'], + extensions: ['.*', '.js', '.ts', '.jsx', '.tsx', '.json'], alias: { react: path.resolve(__dirname, '..', '..', 'node_modules', 'react'), 'styled-component': path.resolve( diff --git a/packages/core/src/plugins/transform.ts b/packages/core/src/plugins/transform.ts index e95980d942..9df53d0d87 100644 --- a/packages/core/src/plugins/transform.ts +++ b/packages/core/src/plugins/transform.ts @@ -1,5 +1,3 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ -/* eslint-disable @typescript-eslint/explicit-function-return-type */ import { createConfigItem, transform, transformFile } from '@babel/core'; import presetEnv from '@babel/preset-env'; import presetReact from '@babel/preset-react'; @@ -16,7 +14,7 @@ interface TransformResult { } type Cb = (err: Error, result: TransformResult) => void; -type Transformer = (input: string, babelConfig: BabelConfig, cb: Cb) => void; +type Transformer = typeof transform | typeof transformFile; const transformGeneric = (transformer: Transformer) => (input: string) => diff --git a/packages/core/typings/babel.d.ts b/packages/core/typings/babel.d.ts index 2c07b4eab1..8e88cbc534 100644 --- a/packages/core/typings/babel.d.ts +++ b/packages/core/typings/babel.d.ts @@ -1,3 +1,2 @@ -declare module '@babel/core'; declare module '@babel/preset-env'; declare module '@babel/preset-react'; diff --git a/packages/ui/lib/components/TrackTable/Headers/ColumnHeader.tsx b/packages/ui/lib/components/TrackTable/Headers/ColumnHeader.tsx index d2ea198af5..f26cfeec93 100644 --- a/packages/ui/lib/components/TrackTable/Headers/ColumnHeader.tsx +++ b/packages/ui/lib/components/TrackTable/Headers/ColumnHeader.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { ColumnInstance } from 'react-table'; +import { ColumnInstance, UseSortByColumnProps } from 'react-table'; import { Icon } from 'semantic-ui-react'; import { Track } from '../../../types'; @@ -7,7 +7,7 @@ import { Track } from '../../../types'; import styles from '../styles.scss'; type ColumnHeaderProps = { - column: ColumnInstance; + column: ColumnInstance & UseSortByColumnProps; header: string | React.ReactNode; 'data-testid'?: string; }; @@ -18,7 +18,7 @@ const ColumnHeader: React.FC = ({ 'data-testid': dataTestId }) => { const { isSorted, isSortedDesc } = column; - const name = column.isSortedDesc + const name = isSortedDesc ? 'sort content descending' : 'sort content ascending'; return ( diff --git a/packages/ui/lib/components/TrackTable/index.tsx b/packages/ui/lib/components/TrackTable/index.tsx index b4818a454c..d3ccc8153a 100644 --- a/packages/ui/lib/components/TrackTable/index.tsx +++ b/packages/ui/lib/components/TrackTable/index.tsx @@ -1,7 +1,7 @@ /* eslint-disable react/jsx-key */ import React, { TableHTMLAttributes, useMemo } from 'react'; import cx from 'classnames'; -import { useTable, Column, useRowSelect, useSortBy } from 'react-table'; +import { useTable, Column, useRowSelect, useSortBy, HeaderGroup, UseSortByColumnProps, TableState, UseSortByState } from 'react-table'; import { isNumber, isString } from 'lodash'; import { DragDropContext, Droppable, Draggable, DragDropContextProps } from 'react-beautiful-dnd'; @@ -129,7 +129,7 @@ function TrackTable({ ].filter(Boolean) as Column[], [displayDeleteButton, displayPosition, displayThumbnail, displayFavorite, isTrackFavorite, titleHeader, displayArtist, artistHeader, displayAlbum, albumHeader, shouldDisplayDuration, durationHeader, selectable, positionHeader, thumbnailHeader]); const data = useMemo(() => tracks, [tracks]); - const initialState = { + const initialState: Partial & UseSortByState> = { sortBy: [{ id: TrackTableColumn.Position, desc: false }] }; @@ -150,7 +150,7 @@ function TrackTable({ headerGroups.map(headerGroup => ( }> { - headerGroup.headers.map(column => ( + headerGroup.headers.map((column: (HeaderGroup & UseSortByColumnProps)) => ( }> {column.render('Header', extraProps)} diff --git a/packages/ui/package.json b/packages/ui/package.json index 32f498e051..0e2e92c60f 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -49,7 +49,7 @@ "@types/numeral": "0.0.28", "@types/react-beautiful-dnd": "^13.0.0", "@types/react-measure": "^2.0.6", - "@types/react-table": "^7.7.12", + "@types/react-table": "^7.7.16", "babel-eslint": "^10.0.3", "babel-loader": "^8.1.0", "copyfiles": "^2.2.0",