Skip to content

Commit

Permalink
[v1.7.8] Merge pull request #275 from bridge-core/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
solvedDev authored Oct 2, 2020
2 parents 286e391 + ece736a commit a88334c
Show file tree
Hide file tree
Showing 301 changed files with 8,361 additions and 20,801 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ npm-debug.log
npm-debug.log.*
thumbs.db
!.gitkeep

.env
60 changes: 0 additions & 60 deletions FAQ.md

This file was deleted.

135 changes: 0 additions & 135 deletions GETTING_STARTED.md

This file was deleted.

41 changes: 23 additions & 18 deletions app/index.ejs
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>bridge.</title>
<% if (htmlWebpackPlugin.options.nodeModules) { %>
<!-- Add `node_modules/` to global paths so `require` works properly in development -->
<script>
require("module").globalPaths.push("<%= htmlWebpackPlugin.options.nodeModules.replace(/\\/g, '\\\\') %>")
</script>
<% } %>
</head>
<body>
<div id="app"></div>
<!-- Set `__static` path to static files in production -->
<script>
if(process.env.NODE_ENV !== "development") window.__static = require("path").join(__dirname, "/static").replace(/\\/g, "\\\\")
</script>
<head>
<meta charset="utf-8" />
<title>bridge.</title>
<% if (htmlWebpackPlugin.options.nodeModules) { %>
<!-- Add `node_modules/` to global paths so `require` works properly in development -->
<script>
require('module').globalPaths.push(
"<%= htmlWebpackPlugin.options.nodeModules.replace(/\\/g, '\\\\') %>"
)
</script>
<% } %>
</head>
<body>
<div id="app"></div>
<!-- Set `__static` path to static files in production -->
<script>
if (process.env.NODE_ENV !== 'development')
window.__static = require('path')
.join(__dirname, '/static')
.replace(/\\/g, '\\\\')
</script>

<!-- webpack builds are automatically injected -->
</body>
<!-- webpack builds are automatically injected -->
</body>
</html>
32 changes: 12 additions & 20 deletions app/main/index.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
import {
app,
BrowserWindow,
ipcMain,
Menu
} from 'electron'
import { app, BrowserWindow, ipcMain, Menu } from 'electron'
import './communicator'
import './Discord'
import {
BP_BASE_PATH
} from '../shared/Paths'
import {
join
} from 'path'
import { BP_BASE_PATH } from '../shared/Paths'
import { join } from 'path'
import fs from 'fs'
import {
DATA_PATH
} from '../shared/DefaultDir'
import { DATA_PATH } from '../shared/DefaultDir'

let SETTINGS = {}
try {
Expand All @@ -29,6 +18,8 @@ if (process.env.NODE_ENV !== 'development') {
global.__static = require('path')
.join(__dirname, '/static')
.replace(/\\/g, '\\\\')
} else {
require('dotenv').config()
}

if (SETTINGS.disable_hardware_acceleration) {
Expand All @@ -46,14 +37,15 @@ let mainWindow,
minHeight: 600,
show: false,
webPreferences: {
nodeIntegrationInWorker: false,
nodeIntegration: true,
webSecurity: false,
},
}
const winURL =
process.env.NODE_ENV === 'development' ?
`http://localhost:9080` :
`file://${__dirname}/index.html`
process.env.NODE_ENV === 'development'
? `http://localhost:9080`
: `file://${__dirname}/index.html`

function createWindow() {
/**
Expand Down Expand Up @@ -89,7 +81,7 @@ function createSplashScreen() {
frame: process.platform === 'darwin',
resizable: false,
webPreferences: {
nodeIntegration: true
nodeIntegration: true,
},
})

Expand Down Expand Up @@ -131,4 +123,4 @@ ipcMain.on('bridge:setOverlayIcon', (event, project) => {
} catch (e) {
mainWindow.setOverlayIcon(null, '')
}
})
})
33 changes: 33 additions & 0 deletions app/renderer/src/AppCycle/fetchDeps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { promises as fs } from 'fs'
import { join } from 'path'
import { BRIDGE_DATA_PATH, DEPS_URLS } from '../constants'
import Store from '../../store/index'

export async function loadDependency(src: string) {
//In development mode, always use data from disk
if (process.env.NODE_ENV === 'development' && process.env.DEV_DATA_PATH)
return eval(
await (
await fs.readFile(join(process.env.DEV_DATA_PATH, src))
).toString('utf-8')
)

const script = await fetch(
join(DEPS_URLS(Store.state.Settings.remote_data_version), src)
)
.then(data => data.text())
.then(async script => {
try {
fs.mkdir(join(BRIDGE_DATA_PATH, 'cache'), { recursive: true })
} catch {}
fs.writeFile(join(BRIDGE_DATA_PATH, 'cache', src), script)
return script
})
.catch(async () => {
return await (
await fs.readFile(join(BRIDGE_DATA_PATH, 'cache', src))
).toString('utf-8')
})

return eval(script)
}
8 changes: 8 additions & 0 deletions app/renderer/src/AppCycle/startUp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,20 @@ import './DropFile'
import './ResizeWatcher'
import './Errors'
import Store from '../../store/index'
import Provider from '../autoCompletions/Provider'
import { loadDependency } from './fetchDeps'

export default async function startUp() {
SETTINGS.setup()
// Start listening for online and offline events
CONNECTION.startListening()

//Setup auto-completions
Provider.loadAssets(
await loadDependency('auto-completions.js'),
await loadDependency('file-definitions.js')
)

setupDefaultMenus()
if (process.env.NODE_ENV !== 'development') {
let discordMsg = createNotification({
Expand Down
6 changes: 5 additions & 1 deletion app/renderer/src/UI/Toolbar/Category/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import PluginLoader from '../../../plugins/PluginLoader'
import Store from '../../../../store/index'
import ThemeManager from '../../../editor/Themes/ThemeManager'
import LoadingWindow from '../../../../windows/LoadingWindow'
import { loadDependency } from '../../../AppCycle/fetchDeps'

export const DevMenu: IAppMenu = {
displayName: 'Development',
Expand Down Expand Up @@ -34,7 +35,10 @@ export const DevMenu: IAppMenu = {
const lw = new LoadingWindow()

trigger('bridge:scriptRunner.resetCaches')
Provider.loadAssets()
Provider.loadAssets(
await loadDependency('auto-completions.js'),
await loadDependency('file-definitions.js')
)
ThemeManager.reloadDefaultThemes()
await PluginLoader.loadPlugins()

Expand Down
Loading

0 comments on commit a88334c

Please sign in to comment.