summaryrefslogtreecommitdiffstats
path: root/src/webview/plugin.js
blob: 569fa94932e10af5f1ff3d8c019c1d775279f564 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { ipcRenderer } from 'electron';
import path from 'path';

import RecipeWebview from './lib/RecipeWebview';

import './spellchecker.js';
import './notifications.js';
import './ime.js';

ipcRenderer.on('initializeRecipe', (e, data) => {
  const modulePath = path.join(data.recipe.path, 'webview.js');
  // Delete module from cache
  delete require.cache[require.resolve(modulePath)];
  try {
    // eslint-disable-next-line
    require(modulePath)(new RecipeWebview(), data);
  } catch (err) {
    console.error(err);
  }
});

document.addEventListener('DOMContentLoaded', () => {
  ipcRenderer.sendToHost('hello');
}, false);