Skip to content

Commit

Permalink
Revert "refactor: use cjs (for upgrade)"
Browse files Browse the repository at this point in the history
This reverts commit 0cd24a1.
  • Loading branch information
will-stone committed Aug 26, 2024
1 parent 9d77482 commit e63e711
Show file tree
Hide file tree
Showing 58 changed files with 188 additions and 185 deletions.
6 changes: 4 additions & 2 deletions forge.config.ts → forge.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// @ts-check

import { MakerZIP } from '@electron-forge/maker-zip'
import { VitePlugin } from '@electron-forge/plugin-vite'
import type { ForgeConfig } from '@electron-forge/shared-types'

const config: ForgeConfig = {
/** @type {import('@electron-forge/shared-types').ForgeConfig} */
const config = {
makers: [new MakerZIP({}, ['darwin'])],
packagerConfig: {
appBundleId: 'com.browserosaurus',
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"repository": "https://github.com/will-stone/browserosaurus",
"license": "GPL-3.0-only",
"author": "Will Stone",
"type": "module",
"main": ".vite/build/main.js",
"scripts": {
"doctor": "npm run lint && npm run typecheck && npm run test",
Expand Down
4 changes: 2 additions & 2 deletions src/config/apps.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getKeys } from '../shared/utils/get-keys'
import { apps } from './apps'
import { getKeys } from '../shared/utils/get-keys.js'
import { apps } from './apps.js'

test.each(getKeys(apps))(
'%s should not include anything but allowed keys',
Expand Down
4 changes: 2 additions & 2 deletions src/main/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { app } from 'electron'
import { LowSync } from 'lowdb'
import { JSONFileSync } from 'lowdb/node'

import type { Storage } from '../shared/state/reducer.storage'
import { defaultStorage } from '../shared/state/reducer.storage'
import type { Storage } from '../shared/state/reducer.storage.js'
import { defaultStorage } from '../shared/state/reducer.storage.js'

const keys = Object.keys as <T>(o: T) => Extract<keyof T, string>[]

Expand Down
6 changes: 3 additions & 3 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import electron, { app } from 'electron'
import { TidyURL } from 'tidy-url'
import { sleep } from 'tings'

import { Channel } from '../shared/state/channels'
import { openedUrl, readiedApp } from './state/actions'
import { dispatch, getState } from './state/store'
import { Channel } from '../shared/state/channels.js'
import { openedUrl, readiedApp } from './state/actions.js'
import { dispatch, getState } from './state/store.js'

app.on('ready', () => dispatch(readiedApp()))

Expand Down
8 changes: 4 additions & 4 deletions src/main/state/actions.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { Rectangle } from 'electron/main'

import type { AppName } from '../../config/apps'
import type { Data } from '../../shared/state/reducer.data'
import type { Storage } from '../../shared/state/reducer.storage'
import { actionNamespacer } from '../../shared/utils/action-namespacer'
import type { AppName } from '../../config/apps.js'
import type { Data } from '../../shared/state/reducer.data.js'
import type { Storage } from '../../shared/state/reducer.storage.js'
import { actionNamespacer } from '../../shared/utils/action-namespacer.js'

const main = actionNamespacer('main')

Expand Down
28 changes: 14 additions & 14 deletions src/main/state/middleware.action-hub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import { app, autoUpdater, shell } from 'electron'
import deepEqual from 'fast-deep-equal'

import { B_URL, ISSUES_URL } from '../../config/constants'
import { B_URL, ISSUES_URL } from '../../config/constants.js'
import {
clickedApp,
clickedUpdateBar,
clickedUrlBar,
pressedKey,
startedPicker,
} from '../../renderers/picker/state/actions'
} from '../../renderers/picker/state/actions.js'
import {
clickedHomepageButton,
clickedOpenIssueButton,
Expand All @@ -20,32 +20,32 @@ import {
clickedUpdateRestartButton,
confirmedReset,
startedPrefs,
} from '../../renderers/prefs/state/actions'
import type { Middleware } from '../../shared/state/model'
import type { RootState } from '../../shared/state/reducer.root'
import { database } from '../database'
import { createTray } from '../tray'
import copyUrlToClipboard from '../utils/copy-url-to-clipboard'
import { getAppIcons } from '../utils/get-app-icons'
import { getInstalledAppNames } from '../utils/get-installed-app-names'
import { initUpdateChecker } from '../utils/init-update-checker'
import { openApp } from '../utils/open-app'
} from '../../renderers/prefs/state/actions.js'
import type { Middleware } from '../../shared/state/model.js'
import type { RootState } from '../../shared/state/reducer.root.js'
import { database } from '../database.js'
import { createTray } from '../tray.js'
import copyUrlToClipboard from '../utils/copy-url-to-clipboard.js'
import { getAppIcons } from '../utils/get-app-icons.js'
import { getInstalledAppNames } from '../utils/get-installed-app-names.js'
import { initUpdateChecker } from '../utils/init-update-checker.js'
import { openApp } from '../utils/open-app.js'
// import { removeWindowsFromMemory } from '../utils/remove-windows-from-memory'
import {
createWindows,
pickerWindow,
prefsWindow,
showPickerWindow,
showPrefsWindow,
} from '../windows'
} from '../windows.js'
import {
clickedOpenPrefs,
clickedRestorePicker,
openedUrl,
readiedApp,
receivedRendererStartupSignal,
retrievedInstalledApps,
} from './actions'
} from './actions.js'

/**
* Asynchronously update perma store on state.storage changes
Expand Down
8 changes: 4 additions & 4 deletions src/main/state/middleware.bus.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Channel } from '../../shared/state/channels'
import type { Middleware } from '../../shared/state/model'
import { isFSA } from '../../shared/state/model'
import { pickerWindow, prefsWindow } from '../windows'
import { Channel } from '../../shared/state/channels.js'
import type { Middleware } from '../../shared/state/model.js'
import { isFSA } from '../../shared/state/model.js'
import { pickerWindow, prefsWindow } from '../windows.js'

/**
* Pass actions between main and renderers
Expand Down
18 changes: 9 additions & 9 deletions src/main/state/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
import { configureStore } from '@reduxjs/toolkit'
import { app } from 'electron'

import { Channel } from '../../shared/state/channels'
import { channelInjectorMiddleware } from '../../shared/state/middleware.channel-injector'
import { logMiddleware } from '../../shared/state/middleware.log'
import { defaultData } from '../../shared/state/reducer.data'
import type { RootState } from '../../shared/state/reducer.root'
import { rootReducer } from '../../shared/state/reducer.root'
import { database } from '../database'
import { actionHubMiddleware } from './middleware.action-hub'
import { busMiddleware } from './middleware.bus'
import { Channel } from '../../shared/state/channels.js'
import { channelInjectorMiddleware } from '../../shared/state/middleware.channel-injector.js'
import { logMiddleware } from '../../shared/state/middleware.log.js'
import { defaultData } from '../../shared/state/reducer.data.js'
import type { RootState } from '../../shared/state/reducer.root.js'
import { rootReducer } from '../../shared/state/reducer.root.js'
import { database } from '../database.js'
import { actionHubMiddleware } from './middleware.action-hub.js'
import { busMiddleware } from './middleware.bus.js'

const channel = Channel.MAIN

Expand Down
4 changes: 2 additions & 2 deletions src/main/tray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { fileURLToPath } from 'node:url'

import { app, Menu, Tray } from 'electron'

import { clickedOpenPrefs, clickedRestorePicker } from './state/actions'
import { dispatch } from './state/store'
import { clickedOpenPrefs, clickedRestorePicker } from './state/actions.js'
import { dispatch } from './state/store.js'

const __dirname = path.dirname(fileURLToPath(import.meta.url))

Expand Down
2 changes: 1 addition & 1 deletion src/main/utils/copy-url-to-clipboard.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import electron, { clipboard } from 'electron'

import copyUrlToClipboard from './copy-url-to-clipboard'
import copyUrlToClipboard from './copy-url-to-clipboard.js'

test('should copy string', () => {
const notificationSpy = jest.spyOn(electron, 'Notification')
Expand Down
8 changes: 4 additions & 4 deletions src/main/utils/get-app-icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { promisify } from 'node:util'

import log from 'electron-log'

import type { AppName } from '../../config/apps'
import type { Storage } from '../../shared/state/reducer.storage'
import { gotAppIcons } from '../state/actions'
import { dispatch } from '../state/store'
import type { AppName } from '../../config/apps.js'
import type { Storage } from '../../shared/state/reducer.storage.js'
import { gotAppIcons } from '../state/actions.js'
import { dispatch } from '../state/store.js'

const __dirname = path.dirname(fileURLToPath(import.meta.url))

Expand Down
8 changes: 4 additions & 4 deletions src/main/utils/get-installed-app-names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import path from 'node:path'

import { sleep } from 'tings'

import type { AppName } from '../../config/apps'
import { apps } from '../../config/apps'
import { retrievedInstalledApps, startedScanning } from '../state/actions'
import { dispatch } from '../state/store'
import type { AppName } from '../../config/apps.js'
import { apps } from '../../config/apps.js'
import { retrievedInstalledApps, startedScanning } from '../state/actions.js'
import { dispatch } from '../state/store.js'

function getAllInstalledAppNames(): string[] {
const appNames = execSync(
Expand Down
12 changes: 6 additions & 6 deletions src/main/utils/init-update-checker.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { app, autoUpdater } from 'electron'

import package_ from '../../../package.json'
import { logger } from '../../shared/utils/logger'
import { logger } from '../../shared/utils/logger.js'
import {
availableUpdate,
downloadedUpdate,
downloadingUpdate,
} from '../state/actions'
import { dispatch } from '../state/store'
import { pickerWindow, prefsWindow } from '../windows'
import { getUpdateUrl } from './get-update-url'
import { isUpdateAvailable } from './is-update-available'
} from '../state/actions.js'
import { dispatch } from '../state/store.js'
import { pickerWindow, prefsWindow } from '../windows.js'
import { getUpdateUrl } from './get-update-url.js'
import { isUpdateAvailable } from './is-update-available.js'

/**
* Auto update check on production
Expand Down
2 changes: 1 addition & 1 deletion src/main/utils/is-update-available.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from 'axios'

import { getUpdateUrl } from './get-update-url'
import { getUpdateUrl } from './get-update-url.js'

export async function isUpdateAvailable(): Promise<boolean> {
let isNewVersionAvailable: boolean
Expand Down
4 changes: 2 additions & 2 deletions src/main/utils/open-app.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { execFile } from 'node:child_process'

import type { AppName } from '../../config/apps'
import { apps } from '../../config/apps'
import type { AppName } from '../../config/apps.js'
import { apps } from '../../config/apps.js'

export function openApp(
appName: AppName,
Expand Down
2 changes: 1 addition & 1 deletion src/main/utils/remove-windows-from-memory.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { pickerWindow, prefsWindow } from '../windows'
import { pickerWindow, prefsWindow } from '../windows.js'

/**
* When exiting the app, the windows must first be removed from memory so that
Expand Down
6 changes: 3 additions & 3 deletions src/main/windows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { fileURLToPath } from 'node:url'

import { app, BrowserWindow, screen } from 'electron'

import { database } from './database'
import { database } from './database.js'
import {
changedPickerWindowBounds,
gotDefaultBrowserStatus,
} from './state/actions'
import { dispatch } from './state/store'
} from './state/actions.js'
import { dispatch } from './state/store.js'

const __dirname = path.dirname(fileURLToPath(import.meta.url))

Expand Down
4 changes: 2 additions & 2 deletions src/renderers/picker/components/_bootstrap.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Provider } from 'react-redux'

import store from '../state/store'
import App from './layout'
import store from '../state/store.js'
import App from './layout.js'

const Bootstrap: React.FC = () => {
return (
Expand Down
2 changes: 1 addition & 1 deletion src/renderers/picker/components/atoms/app-logo.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import clsx from 'clsx'

import type { InstalledApp } from '../../../shared/state/hooks'
import type { InstalledApp } from '../../../shared/state/hooks.js'

type Props = React.ComponentPropsWithoutRef<'img'> & {
readonly app: InstalledApp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect } from 'react'
import { useDispatch } from 'react-redux'

import { pressedKey } from '../../state/actions'
import { pressedKey } from '../../state/actions.js'

export const useKeyboardEvents = (): void => {
const dispatch = useDispatch()
Expand Down
20 changes: 10 additions & 10 deletions src/renderers/picker/components/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ import clsx from 'clsx'
import { useEffect } from 'react'
import { useDispatch } from 'react-redux'

import { Spinner } from '../../shared/components/atoms/spinner'
import { Spinner } from '../../shared/components/atoms/spinner.js'
import {
useDeepEqualSelector,
useInstalledApps,
useKeyCodeMap,
useSelector,
} from '../../shared/state/hooks'
import { appsRef, appsScrollerRef } from '../refs'
import { clickedApp, startedPicker } from '../state/actions'
import AppLogo from './atoms/app-logo'
import Kbd from './atoms/kbd'
import { useKeyboardEvents } from './hooks/use-keyboard-events'
import SupportMessage from './organisms/support-message'
import UpdateBar from './organisms/update-bar'
import UrlBar from './organisms/url-bar'
} from '../../shared/state/hooks.js'
import { appsRef, appsScrollerRef } from '../refs.js'
import { clickedApp, startedPicker } from '../state/actions.js'
import AppLogo from './atoms/app-logo.js'
import Kbd from './atoms/kbd.js'
import { useKeyboardEvents } from './hooks/use-keyboard-events.js'
import SupportMessage from './organisms/support-message.js'
import UpdateBar from './organisms/update-bar.js'
import UrlBar from './organisms/url-bar.js'

const useAppStarted = () => {
const dispatch = useDispatch()
Expand Down
16 changes: 8 additions & 8 deletions src/renderers/picker/components/organisms/apps.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import '../../../shared/preload'
import { fireEvent, render, screen } from '@testing-library/react'
import electron from 'electron'

import { keyLayout } from '../../../../../__fixtures__/key-layout'
import { keyLayout } from '../../../../../__fixtures__/key-layout.js'
import {
openedUrl,
receivedRendererStartupSignal,
retrievedInstalledApps,
} from '../../../../main/state/actions'
import { Channel } from '../../../../shared/state/channels'
import { defaultData } from '../../../../shared/state/reducer.data'
import { addChannelToAction } from '../../../../shared/utils/add-channel-to-action'
import { reorderedApp } from '../../../prefs/state/actions'
import { clickedApp, pressedKey } from '../../state/actions'
import Wrapper from '../_bootstrap'
} from '../../../../main/state/actions.js'
import { Channel } from '../../../../shared/state/channels.js'
import { defaultData } from '../../../../shared/state/reducer.data.js'
import { addChannelToAction } from '../../../../shared/utils/add-channel-to-action.js'
import { reorderedApp } from '../../../prefs/state/actions.js'
import { clickedApp, pressedKey } from '../../state/actions.js'
import Wrapper from '../_bootstrap.js'

beforeAll(() => {
global.window ??= Object.create(window)
Expand Down
4 changes: 2 additions & 2 deletions src/renderers/picker/components/organisms/support-message.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import clsx from 'clsx'
import { useDispatch } from 'react-redux'

import { useIsSupportMessageHidden } from '../../../shared/state/hooks'
import { clickedDonate, clickedMaybeLater } from '../../state/actions'
import { useIsSupportMessageHidden } from '../../../shared/state/hooks.js'
import { clickedDonate, clickedMaybeLater } from '../../state/actions.js'

const SupportMessage = (): JSX.Element => {
const dispatch = useDispatch()
Expand Down
4 changes: 2 additions & 2 deletions src/renderers/picker/components/organisms/update-bar.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import clsx from 'clsx'
import { useDispatch } from 'react-redux'

import { useSelector } from '../../../shared/state/hooks'
import { clickedUpdateBar } from '../../state/actions'
import { useSelector } from '../../../shared/state/hooks.js'
import { clickedUpdateBar } from '../../state/actions.js'

const UpdateBar: React.FC = () => {
const dispatch = useDispatch()
Expand Down
Loading

0 comments on commit e63e711

Please sign in to comment.