Skip to content

Commit

Permalink
refactor: extract electron related files
Browse files Browse the repository at this point in the history
  • Loading branch information
4gray committed Jul 1, 2022
1 parent 4e39f15 commit e3a6e12
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 43 deletions.
10 changes: 5 additions & 5 deletions api.ts → electron/api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios from 'axios';
import { app, BrowserWindow, ipcMain, session } from 'electron';
import { parse } from 'iptv-playlist-parser';
import { GLOBAL_FAVORITES_PLAYLIST_ID } from './shared/constants';
import { GLOBAL_FAVORITES_PLAYLIST_ID } from '../shared/constants';
import {
CHANNEL_SET_USER_AGENT,
EPG_ERROR,
Expand All @@ -26,13 +26,13 @@ import {
PLAYLIST_UPDATE_FAVORITES,
PLAYLIST_UPDATE_POSITIONS,
PLAYLIST_UPDATE_RESPONSE,
} from './shared/ipc-commands';
import { Playlist, PlaylistUpdateState } from './shared/playlist.interface';
} from '../shared/ipc-commands';
import { Playlist, PlaylistUpdateState } from '../shared/playlist.interface';
import {
aggregateFavoriteChannels,
createFavoritesPlaylist,
} from './shared/playlist.utils';
import { ParsedPlaylist } from './src/typings.d';
} from '../shared/playlist.utils';
import { ParsedPlaylist } from '../src/typings.d';

const Nedb = require('nedb-promises');

Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions epg-worker.ts → electron/epg-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import {
EPG_GET_CHANNELS_DONE,
EPG_GET_PROGRAM,
EPG_GET_PROGRAM_DONE,
} from './shared/ipc-commands';
import { EpgChannel } from './src/app/player/models/epg-channel.model';
import { EpgProgram } from './src/app/player/models/epg-program.model';
} from '../shared/ipc-commands';
import { EpgChannel } from '../src/app/player/models/epg-channel.model';
import { EpgProgram } from '../src/app/player/models/epg-program.model';

// EPG data store
let EPG_DATA: { channels: EpgChannel[]; programs: EpgProgram[] };
Expand Down
12 changes: 6 additions & 6 deletions main.ts → electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import { app, BrowserWindow, Menu } from 'electron';
import * as path from 'path';
import * as url from 'url';
import { Api } from './api';
import { AppMenu } from './menu';
import { Api } from '../api';
import { AppMenu } from '../menu';
const contextMenu = require('electron-context-menu');

let win: BrowserWindow = null;
Expand All @@ -28,7 +28,7 @@ function createWindow(): BrowserWindow {
},
resizable: true,
darkTheme: true,
icon: path.join(__dirname, 'dist/assets/icons/icon.png'),
icon: path.join(__dirname, '../build/assets/icons/icon.png'),
titleBarStyle: 'hidden',
frame: false,
minWidth: 900,
Expand All @@ -44,7 +44,7 @@ function createWindow(): BrowserWindow {
} else {
win.loadURL(
url.format({
pathname: path.join(__dirname, 'dist/index.html'),
pathname: path.join(__dirname, '../build/index.html'),
protocol: 'file:',
slashes: true,
})
Expand Down Expand Up @@ -80,10 +80,10 @@ function createEpgWorkerWindow() {
});

if (serve) {
window.loadFile('epg-worker.html');
window.loadFile(path.join(__dirname, '../electron/index.html'));
window.webContents.openDevTools();
} else {
window.loadFile('epg-worker.html');
window.loadFile('./epg-worker.html');
}

window.once('ready-to-show', () => {
Expand Down
2 changes: 1 addition & 1 deletion menu.ts → electron/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
SHOW_WHATS_NEW,
VIEW_ADD_PLAYLIST,
VIEW_SETTINGS,
} from './shared/ipc-commands';
} from '../shared/ipc-commands';
const openAboutWindow = require('about-window').default;

export class AppMenu {
Expand Down
7 changes: 7 additions & 0 deletions electron/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "iptvnator-electron",
"version": "0.10.0",
"main": "main.js",
"private": true,
"dependencies": {}
}
File renamed without changes.
45 changes: 17 additions & 28 deletions tsconfig.serve.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,20 @@
{
"compilerOptions": {
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"types": [
"node"
"compilerOptions": {
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"types": ["node"],
"lib": ["es2017", "es2016", "es2015", "dom"]
},
"files": [
"electron/api.ts",
"electron/epg-worker.ts",
"electron/main.ts",
"electron/menu.ts",
"electron/preload.ts"
],
"lib": [
"es2017",
"es2016",
"es2015",
"dom"
]
},
"files": [
"api.ts",
"epg-worker.ts",
"main.ts",
"menu.ts",
"preload.ts"
],
"exclude": [
"node_modules",
"**/*.spec.ts",
"**/*.stub.ts"
]
"exclude": ["node_modules", "**/*.spec.ts", "**/*.stub.ts"]
}

0 comments on commit e3a6e12

Please sign in to comment.