Skip to content

Commit

Permalink
better build.mjs and retired kalam support on macos <14
Browse files Browse the repository at this point in the history
  • Loading branch information
ganeshrvel committed Jan 13, 2023
1 parent a1162f8 commit f8ef209
Show file tree
Hide file tree
Showing 25 changed files with 475 additions and 235 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,5 @@ resources
tmp/*
*.prod.js
*.js.map
*.js.LICENSE.txt
*.prod.js.LICENSE.txt
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,5 @@ resources
tmp/*
*.prod.js
*.js.map
*.js.LICENSE.txt
*.prod.js.LICENSE.txt
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ Do checkout the Go package which I've written to build Kalam Kernel: [github.com
### System Requirements and Support

- To support macOS version below Big Sur the Kalam kernel needs to be compiled on an older macOS machine everytime there is an update, which is practically very difficult
- The latest 3 versions of macOS will receive the `Kalam` Kernel updates, which includes new device support, fixes, stability improvements. macOS Big Sur (11.0) or above will receive the above said updates
- OpenMTP will continue working on a machine which has macOS 10.11 (OS X El Capitan) or higher installed but won't receive the MTP Kernel updates
- Only the latest 3 versions of macOS will receive the `Kalam` Kernel updates, which includes new device supports, fixes, stability improvements. macOS Big Sur (11.0) or above will receive the above said updates
- We have now officially retired the support for `Kalam` Kernel on macOS 10.13 (OS X El High Sierra) and lower. Only the "Legacy" MTP mode will continue working on these outdated machines.
- We will continue releasing the updates for both `Intel` and `ARM64` machines

### Installation
Expand Down
1 change: 0 additions & 1 deletion app/844.main.prod.js.LICENSE.txt

This file was deleted.

13 changes: 13 additions & 0 deletions app/classes/Storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,17 @@ export default class Storage {
log.error(e, `Storage -> setAll`);
}
}

setItems({ ...data }) {
try {
const currentSettings = this.getAll();

writeFileSync(
this.filePath,
JSON.stringify({ ...currentSettings, ...data })
);
} catch (e) {
log.error(e, `Storage -> setAll`);
}
}
}
4 changes: 2 additions & 2 deletions app/constants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ export const OS_ARCH_TYPE = {
// To support macOS version below Big Sur the Kalam kernel needs to be compiled on an older macOS machine everytime there is an update, which is practically very difficult.
// So any version included in the [KALAM_HISTORIC_VERSION_TYPE] will not receive the latest Kalam Kernel updates
export const KALAM_HISTORIC_VERSION_TYPE = {
paleolithic: 'paleolithic', // very old OSes. macOS 10.11 (OS X El Capitan) to 10.13 (High Sierra). libusb support is limited in this. So practically discontinued kernel
medieval: 'medieval', // macOS 10.14 (Mojave) and 10.15 (Catalina). libusb support is still available but since it requires Mojave or lower to compile the kernel, it is being deprecated.
};

// if the user's os version is higher than the ones listed here then latest kalam kernel binaies will be used
// reference: https://github.com/npm/node-semver#ranges
export const KALAM_HISTORIC_MACOS_VERSION_RANGE = {
[KALAM_HISTORIC_VERSION_TYPE.paleolithic]: `>=10.11.0 <10.14`,
[KALAM_HISTORIC_VERSION_TYPE.medieval]: `>=10.14 <=10.15.999`,
};

export const NODE_MAC_PERMISSIONS_MIN_OS = `11.0.0`;

export const KALAM_MODE_MIN_MACOS_VERSION = `>=10.14`;

export const DEVICES_DEFAULT_PATH = {
[DEVICE_TYPE.mtp]: '/',
[DEVICE_TYPE.local]: PATHS.homeDir,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import Typography from '@material-ui/core/Typography';
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
import PowerIcon from '@material-ui/icons/Power';
import ReplayIcon from '@material-ui/icons/Replay';
import SystemUpdate from '@material-ui/icons/SystemUpdate';
import { styles } from '../styles/HelpPhoneNotRecognized';
import { openExternalUrl } from '../../../utils/url';
import {
Expand All @@ -42,14 +43,15 @@ import {
DEVICES_LABEL,
DONATE_PAYPAL_URL,
} from '../../../constants';
import { DEVICE_TYPE } from '../../../enums';
import { DEVICE_TYPE, MTP_MODE } from '../../../enums';
import {
localErrorDictionary,
mtpErrors,
} from '../../../helpers/processBufferOutput';
import { MTP_ERROR } from '../../../enums/mtpError';
import { imgsrc } from '../../../utils/imgsrc';
import { helpPhoneNotConnecting } from '../../../templates/fileExplorer';
import { isKalamModeSupported } from '../../../helpers/binaries';

const hotplugSettingText = `Check if 'Enable auto device detection (USB Hotplug)' is enabled under Settings > General Tab`;
const deviceLabel = DEVICES_LABEL[DEVICE_TYPE.mtp];
Expand Down Expand Up @@ -254,6 +256,7 @@ class HelpPhoneNotRecognized extends PureComponent {
render() {
const { classes: styles, showPhoneNotRecognizedNote } = this.props;
const { RenderBasicConnection, RenderRefreshButtonIsStuck } = this;
const isKalamModeDisabled = !isKalamModeSupported();

return (
<div className={styles.root}>
Expand Down Expand Up @@ -329,6 +332,39 @@ class HelpPhoneNotRecognized extends PureComponent {
</>
)}

{isKalamModeDisabled && (
<Accordion className={styles.expansionRoot}>
{/* <----- Kalam Mode is disabed -----> */}

<AccordionSummary expandIcon={<ExpandMoreIcon />}>
<Typography className={styles.heading}>
{`Upgrade you mac's OS version for better app experience`}
</Typography>
</AccordionSummary>
<AccordionDetails>
<List component="div" disablePadding>
<ListItem>
<ListItemIcon>
<SystemUpdate />
</ListItemIcon>
<ListItemText
primary={`We have now officially retired the support for '${MTP_MODE.kalam}' Kernel on 'macOS 10.13' (OS X El High Sierra) and lower. Only the '${MTP_MODE.legacy}' MTP mode will continue working on these outdated machines.`}
/>
</ListItem>

<ListItem>
<ListItemIcon>
<SystemUpdate />
</ListItemIcon>
<ListItemText
primary={`Only the latest 3 versions of macOS will receive the '${MTP_MODE.kalam}' Kernel updates, which includes new devices support, fixes, stability improvements`}
/>
</ListItem>
</List>
</AccordionDetails>
</Accordion>
)}

<Accordion className={styles.expansionRoot}>
{/* <----- my device is not connecting -----> */}

Expand Down
25 changes: 17 additions & 8 deletions app/containers/HomePage/components/ToolbarBody.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
import { DEVICE_TYPE, MTP_MODE } from '../../../enums';
import { capitalize, isEmpty } from '../../../utils/funcs';
import { imgsrc } from '../../../utils/imgsrc';
import { isKalamModeSupported } from '../../../helpers/binaries';

export default class ToolbarAreaPane extends PureComponent {
activeToolbarList = ({ ...args }) => {
Expand Down Expand Up @@ -173,6 +174,9 @@ export default class ToolbarAreaPane extends PureComponent {
},
];

// We have now officially retired the support for `Kalam` Kernel on macOS 10.13 (OS X El High Sierra) and lower. Only the "Legacy" MTP mode will continue working on these outdated machines.
const showMtpModeSelection = isKalamModeSupported();

return (
<div className={styles.root}>
<ConfirmDialog
Expand All @@ -192,14 +196,19 @@ export default class ToolbarAreaPane extends PureComponent {
}
onClose={onMtpStoragesListClick}
/>
<SelectionDialog
titleText="Select MTP Mode"
list={mtpModeList}
id="selectionDialog"
showAvatar
open={deviceType === DEVICE_TYPE.mtp && toggleMtpModeSelectionDialog}
onClose={onMtpModeSelectionDialogClick}
/>

{showMtpModeSelection && (
<SelectionDialog
titleText="Select MTP Mode"
list={mtpModeList}
id="selectionDialog"
showAvatar
open={
deviceType === DEVICE_TYPE.mtp && toggleMtpModeSelectionDialog
}
onClose={onMtpModeSelectionDialogClick}
/>
)}
<Drawer
open={toggleDrawer}
onClose={onToggleDrawer(false)}
Expand Down
3 changes: 2 additions & 1 deletion app/containers/HomePage/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
buyMeACoffeeText,
donateUsingPayPal,
} from '../../templates/fileExplorer';
import { isKalamModeSupported } from '../../helpers/binaries';

export const initialState = {
focussedFileExplorerDeviceType: {
Expand Down Expand Up @@ -118,7 +119,7 @@ export const initialState = {
icon: faSdCard,
},
mtpMode: {
enabled: true,
enabled: isKalamModeSupported(),
label: 'MTP Mode',
icon: faPlug,
},
Expand Down
16 changes: 16 additions & 0 deletions app/containers/Onboarding/components/WhatsNew.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ import BuildIcon from '@material-ui/icons/Build';
import SmartphoneIcon from '@material-ui/icons/Smartphone';
import CameraRollIcon from '@material-ui/icons/CameraRoll';
import MemoryIcon from '@material-ui/icons/Memory';
import SystemUpdate from '@material-ui/icons/SystemUpdate';
import { styles } from '../styles/WhatsNew';
import { APP_NAME, APP_VERSION } from '../../../constants/meta';
import { isKalamModeSupported } from '../../../helpers/binaries';
import { MTP_MODE } from '../../../enums';

class WhatsNew extends PureComponent {
render() {
const isKalamModeDisabled = !isKalamModeSupported();
const { classes: styles, hideTitle } = this.props;

return (
Expand All @@ -29,6 +33,18 @@ class WhatsNew extends PureComponent {
)}

<List>
{!isKalamModeDisabled && (
<ListItem>
<ListItemIcon>
<SystemUpdate htmlColor="#fa4d0a" />
</ListItemIcon>
<ListItemText
primary={`We have now officially retired the support for '${MTP_MODE.kalam}' Kernel on macOS 10.13 (OS X El High Sierra) and lower`}
secondary={`However the '${MTP_MODE.legacy}' MTP mode will continue working on these outdated machines`}
/>
</ListItem>
)}

<ListItem>
<ListItemIcon>
<MemoryIcon htmlColor="#fa4d0a" />
Expand Down
57 changes: 32 additions & 25 deletions app/containers/Settings/components/SettingsDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
} from '../../../enums';
import { capitalize, isPrereleaseVersion } from '../../../utils/funcs';
import { IpcEvents } from '../../../services/ipc-events/IpcEventType';
import { isKalamModeSupported } from '../../../helpers/binaries';

const isMas = electronIs.mas();

Expand Down Expand Up @@ -110,6 +111,8 @@ export default class SettingsDialog extends PureComponent {
const fileExplorerListingTypeMtpGrid =
fileExplorerListingType[DEVICE_TYPE.mtp] === FILE_EXPLORER_VIEW_TYPE.grid;

const showMtpModeSelection = isKalamModeSupported();

return (
<Dialog
open={open}
Expand Down Expand Up @@ -182,31 +185,35 @@ export default class SettingsDialog extends PureComponent {
/>
</RadioGroup>

<Typography
variant="subtitle2"
className={`${styles.subtitle} ${styles.fmSettingsStylesFix}`}
>
MTP Mode
</Typography>
<RadioGroup
aria-label="app-theme-mode"
name="app-theme-mode"
value={mtpMode}
onChange={(e, value) =>
onMtpModeChange(e, value, DEVICE_TYPE.mtp)
}
>
<FormControlLabel
value={MTP_MODE.kalam}
control={<Radio />}
label={capitalize(MTP_MODE.kalam)}
/>
<FormControlLabel
value={MTP_MODE.legacy}
control={<Radio />}
label={capitalize(MTP_MODE.legacy)}
/>
</RadioGroup>
{showMtpModeSelection && (
<>
<Typography
variant="subtitle2"
className={`${styles.subtitle} ${styles.fmSettingsStylesFix}`}
>
MTP Mode
</Typography>
<RadioGroup
aria-label="app-theme-mode"
name="app-theme-mode"
value={mtpMode}
onChange={(e, value) =>
onMtpModeChange(e, value, DEVICE_TYPE.mtp)
}
>
<FormControlLabel
value={MTP_MODE.kalam}
control={<Radio />}
label={capitalize(MTP_MODE.kalam)}
/>
<FormControlLabel
value={MTP_MODE.legacy}
control={<Radio />}
label={capitalize(MTP_MODE.legacy)}
/>
</RadioGroup>
</>
)}

<Typography
variant="subtitle2"
Expand Down
1 change: 1 addition & 0 deletions app/containers/Settings/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const initialState = {
showLocalPaneOnLeftSide: true,
showDirectoriesFirst: true,
mtpMode: MTP_MODE.kalam,
wasForcedToToggleMtpModeForMinOsRequirement: false,
filesPreprocessingBeforeTransfer: {
[FILE_TRANSFER_DIRECTION.upload]: true,
[FILE_TRANSFER_DIRECTION.download]: true,
Expand Down
10 changes: 9 additions & 1 deletion app/helpers/binaries.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import {
import { IS_PROD } from '../constants/env';
import { PATHS } from '../constants/paths';
import { isPackaged } from '../utils/isPackaged';
import { KALAM_HISTORIC_MACOS_VERSION_RANGE } from '../constants';
import {
KALAM_HISTORIC_MACOS_VERSION_RANGE,
KALAM_MODE_MIN_MACOS_VERSION,
} from '../constants';
import { undefinedOrNull } from '../utils/funcs';

const { root } = PATHS;
Expand Down Expand Up @@ -83,3 +86,8 @@ export const kalamDebugReportCli = path.resolve(
export const kalamLibPath = path.resolve(
path.join(binariesPath({ includeArchDirectory: true }), './kalam.dylib')
);

// We have now officially retired the support for `Kalam` Kernel on macOS 10.13 (OS X El High Sierra) and lower. Only the "Legacy" MTP mode will continue working on these outdated machines.
export function isKalamModeSupported() {
return macosVersion.is(KALAM_MODE_MIN_MACOS_VERSION);
}
Loading

0 comments on commit f8ef209

Please sign in to comment.