Skip to content

Commit

Permalink
fix: Fix Mapeo window randomly not opening at startup (#465)
Browse files Browse the repository at this point in the history
* chore: Add incremental Typescript checking

Add // @ts-check to the top of files in src/background
and src/main to check JS files with JSDoc hints

* Refactor app startup code & background processes

* Manage background processes together, and time async startup actions

* Read backend state in main window

* Startup sequence in parallel

* remove console.log

* Fix startup sequence

* Fix background state updates (emit after state is updated)

* Update to latest electron@9

* Fix ipc message validation

* Fix settings extraction

* Wait for first render before showing main window

* Improve logging

* fixes for breaking mkdirp change

* add note about React devtools

* fix lint error

* chore(tsconfig): fix typo

* fix packaging config

* fix: Fix errors from Wifi Status display and disable on MacOS

Fixes #469

* fix: Package default config with app, rather than extracting at runtime

* fix: Fix IPC messaging with main process - call port.start()

* fix: Fix "zoom to data": include deletions and correct density calc

* fix: Fix crash when syncing by removing non-transferable objects from IPC

* Add message error handlers to IPC

* fix: Fix reload of Mapeo when config changes

* chore: update ecstatic & dedupe

* Fix package-lock

* Catch errors on startup

* Extend background process start timeout

* throw error if starting background process fails

* Pass through error events from background processes

* Cleanup subscriptions

* Clear closing timeout

Co-authored-by: Kira Oakley <kira@eight45.net>
  • Loading branch information
gmaclennan and hackergrrl authored Jun 11, 2021
1 parent d9df37b commit 5467c19
Show file tree
Hide file tree
Showing 36 changed files with 6,575 additions and 7,025 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ translations
storybook-static
updates
flow-typed
/**/*.d.ts
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ bin/test-data
translations
storybook-static
updates
temp-resources
3 changes: 1 addition & 2 deletions bin/build-translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ const fs = require('fs')

const readFile = util.promisify(fs.readFile)
const writeFile = util.promisify(fs.writeFile)
const mkdirpPromise = util.promisify(mkdirp)

async function readJson (file) {
return JSON.parse(await readFile(file))
}

async function writeJson (file, data) {
await mkdirpPromise(path.dirname(file))
await mkdirp(path.dirname(file))
await writeFile(file, JSON.stringify(data, null, 2))
}

Expand Down
19 changes: 19 additions & 0 deletions bin/extract-presets.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const path = require('path')
const mkdirp = require('mkdirp')
const fs = require('fs-extra')
const { DEFAULT_CONFIG_DIR } = require('../config')

// This is a really hacky fix to an annoying problem. Currently mapeo-server has
// a fallbackPresetsDir option, but it expects the presets to be in a `default`
// subfolder inside that. In production we copy mapeo-default-settings into the
// app resources folder, with a `default` subfolder, but in dev we need to copy
// the default presets into a subfolder so we can use them in dev. TODO: Fix the
// API for mapeo-server

// Sorry about confusing naming, working around hard-coded paths in @mapeo/settings
const defaultConfigFolder = path.join(DEFAULT_CONFIG_DIR, 'default')
mkdirp(defaultConfigFolder)
fs.copySync(
path.dirname(require.resolve('mapeo-default-settings')),
defaultConfigFolder
)
9 changes: 6 additions & 3 deletions builder.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ const config = {
{
from: 'build/app-update.yml',
to: 'app-update.yml'
},
{
from: path.dirname(require.resolve('mapeo-default-settings')),
to: 'presets/default'
}
]
}
Expand All @@ -75,9 +79,8 @@ const files = [
// Don't ship built sourcemaps, because they are 25Mb
'!static/*.map',
// Include everything in src/ apart from src/renderer
'src/main/**/*',
'src/background/**/**/*.{js,html}',
'src/*.js',
'src/**/*',
'!src/renderer/**/*',
// but also include src/renderer/index-preload.js since this is not included
// in the renderer bundle
'src/renderer/index-preload.js',
Expand Down
28 changes: 22 additions & 6 deletions config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
var path = require('path')
var APP_NAME = 'Mapeo'
var APP_TEAM = 'Digital Democracy'
var APP_VERSION = require('./package.json').version

module.exports = {
APP_NAME: APP_NAME,
APP_TEAM: APP_TEAM,
APP_VERSION: APP_VERSION,
var isElectron = typeof process.type === 'string'
// Is `true` when running from Node
var isDev = isElectron ? require('electron-is-dev') : true

MAPBOX_ACCESS_TOKEN: 'pk.eyJ1IjoiZ21hY2xlbm5hbiIsImEiOiJSaWVtd2lRIn0.ASYMZE2HhwkAw4Vt7SavEg',
// Sorry about this! In production the default config is shipped in the app
// resources folder, but for development we need to copy them into a temporary
// "resources" folder.
var RESOURCES_DIR = isDev
? path.join(__dirname, 'temp-resources')
: process.resourcesPath

module.exports = {
APP_NAME,
APP_TEAM,
APP_VERSION,
RESOURCES_DIR,
// This is super confusing... due to hard-coded paths in @mapeo/settings
// TODO: Clean all of this up in mapeo-server and @mapeo/settings
DEFAULT_CONFIG_DIR: path.join(RESOURCES_DIR, 'presets'),
MAPBOX_ACCESS_TOKEN:
'pk.eyJ1IjoiZ21hY2xlbm5hbiIsImEiOiJSaWVtd2lRIn0.ASYMZE2HhwkAw4Vt7SavEg',
GITHUB_URL: 'https://github.com/digidem/mapeo-desktop',
GITHUB_URL_RAW: 'https://raw.githubusercontent.com/digidem/mapeo-desktop/master'
GITHUB_URL_RAW:
'https://raw.githubusercontent.com/digidem/mapeo-desktop/master'
}
Loading

0 comments on commit 5467c19

Please sign in to comment.