Browse Source

More code refactoring!

tags/v1.4.4
Ivan Bravo Bravo 11 months ago
parent
commit
6a2e8ba79e

+ 3
- 1
src/.eslintrc.js View File

@@ -17,7 +17,9 @@ module.exports = {
],
globals: {
$dream: false,
$provider: false
$provider: false,
Logger: false,
AppError: false
},
parserOptions: {
parser: "babel-eslint"

+ 5
- 5
src/components/Layout/Navigation.vue View File

@@ -15,7 +15,7 @@
<!-- App Navigation -->
<section class="navbar-section">
<nav class="navbar-items">
<nuxt-link v-if="$platform.requirements.all" to="/" class="navbar-item">
<nuxt-link v-if="$provider.tools.system.canNudify" to="/" class="navbar-item">
<span class="icon">📷</span>
<span>Nudify</span>
</nuxt-link>
@@ -33,19 +33,19 @@
</section>

<!-- Nice links -->
<section v-if="!$platform.isLimited" class="navbar-section">
<section v-if="$provider.tools.system.online" class="navbar-section">
<nav class="navbar-items">
<app-external-link :href="$nucleus.urls.web" class="navbar-item">
<app-external-link :href="$provider.services.nucleus.urls.web" class="navbar-item">
<span class="icon">🌎</span>
<span>Website</span>
</app-external-link>

<app-external-link :href="$nucleus.urls.chat" class="navbar-item">
<app-external-link :href="$provider.services.nucleus.urls.chat" class="navbar-item">
<span class="icon">💬</span>
<span>Chat</span>
</app-external-link>

<app-external-link :href="$nucleus.urls.forum" class="navbar-item">
<app-external-link :href="$provider.services.nucleus.urls.forum" class="navbar-item">
<span class="icon">👥</span>
<span>Forum</span>
</app-external-link>

+ 3
- 2
src/components/Nudity/Job.vue View File

@@ -104,7 +104,8 @@

<script>
import _ from 'lodash'
import { api } from 'electron-utils'

const { shell } = $provider.api

export default {
filters: {
@@ -135,7 +136,7 @@ export default {
view() {},

save() {
const savePath = api.shell.showSaveDialog({
const savePath = shell.showSaveDialog({
defaultPath: this.job.getFileName(),
filters: [
{ name: 'PNG', extensions: ['png'] },

+ 2
- 2
src/components/UI/AppExternalLink.vue View File

@@ -5,7 +5,7 @@
</template>

<script>
import { api } from 'electron-utils'
const { shell } = $provider.api

export default {
props: {
@@ -18,7 +18,7 @@ export default {
methods: {
openExternal() {
$provider.services.nucleus.track('EXTERNAL_LINK', { href: this.href })
api.shell.openExternal(this.href)
shell.openExternal(this.href)
},
},
}

+ 12
- 11
src/components/UI/AppUpdate.vue View File

@@ -14,7 +14,7 @@

<!-- Update available -->
<box-section-item
v-else-if="!updater.updating.active"
v-else-if="!updater.update.active"
:label="`${projectTitle} ${updater.latest.tag_name} available.`"
icon="🌐"
class="update-item">
@@ -26,15 +26,15 @@
</app-external-link>
</box-section-item>

<!-- Updating... -->
<!-- update... -->
<!-- eslint-disable-next-line vue/valid-template-root --->
<box-section-item
v-else
:label="updater.updating.text"
:label="updater.update.text"
icon="🌐">
<template slot="description">
<p v-if="updater.updating.text === 'Downloading...'" class="item-description">
<strong>{{ updater.updating.progress | progress }}</strong> - {{ updater.updating.mbWritten | size }}/{{ updater.updating.mbTotal | size }} MB.
<p v-if="updater.update.text === 'Downloading...'" class="item-description">
<strong>{{ updater.update.progress | progress }}</strong> - {{ updater.update.mbWritten | size }}/{{ updater.update.mbTotal | size }} MB.
</p>
<p v-else class="item-description">
Wait a few minutes, please do not close the program.
@@ -48,7 +48,8 @@
</template>

<script>
import { api } from 'electron-utils'
const { shell } = $provider.api
const { getPath } = $provider.tools.paths

export default {
filters: {
@@ -80,16 +81,16 @@ export default {

computed: {
updater() {
return this.$updater[this.project]
return $provider.updater[this.project]
},

downloadURL() {
return this.updater.getUpdateDownloadURLs()[0]
return this.updater.downloadUrls[0]
},
},

async created() {
this.currentVersion = await this.updater.getCurrentVersion()
created() {
this.currentVersion = this.updater.currentVersion
},

beforeDestroy() {
@@ -98,7 +99,7 @@ export default {

methods: {
openDownload() {
api.shell.openItem($provider.tools.paths.getPath('downloads'))
shell.openItem(getPath('downloads'))
},
},
}

+ 3
- 2
src/components/UI/BoxItem.vue View File

@@ -20,7 +20,8 @@

<script>
import _ from 'lodash'
import { api } from 'electron-utils'

const { shell } = $provider.api

export default {
props: {
@@ -67,7 +68,7 @@ export default {
this.$emit('click')
if (!_.isNil(this.href)) {
$provider.services.nucleus.track('EXTERNAL_LINK', { href: this.href })
api.shell.openExternal(this.href)
shell.openExternal(this.href)
}
},
isURL(str) {

+ 1
- 1
src/components/UI/BoxSectionItem.vue View File

@@ -40,7 +40,7 @@ export default {
return true
}

return this.version === $dream.version
return this.version === this.$dream.version
},
},
render(createElement) {

+ 2
- 3
src/electron-builder.js View File

@@ -1,10 +1,9 @@
/* eslint-disable no-template-curly-in-string */
require('dotenv').config()
const pkg = require('./package.json')

module.exports = {
appId: 'com.dreamnet.dreamtime',
productName: process.env.APP_NAME,
productName: process.env.npm_package_name,
copyright: 'Copyright (C) DreamNet. All rights reserved.',
directories: {
output: '../dist',
@@ -44,7 +43,7 @@ module.exports = {
},
linux: {
target: 'snap',
executableName: process.env.APP_NAME,
executableName: process.env.npm_package_name,
synopsis: pkg.description,
category: 'Graphics',
extraResources: [

+ 6
- 3
src/electron/src/index.js View File

@@ -13,7 +13,7 @@ import { dirname, join } from 'path'
import { URL } from 'url'
import contextMenu from 'electron-context-menu'
import Logger from 'logplease'
import { pack, enforceMacOSAppLocation } from 'electron-utils'
import { enforceMacOSAppLocation, is } from 'electron-util'
import { AppError } from './modules/app-error'
import { settings, nucleus, rollbar } from './modules/services'
import { system } from './modules/tools/system'
@@ -27,6 +27,10 @@ const logger = Logger.create('electron')
// NuxtJS root directory
config.rootDir = dirname(__dirname)

if (!is.development) {
process.chdir(getPath('exe', '../'))
}

class DreamApp {
/**
* Start the app!
@@ -40,7 +44,6 @@ class DreamApp {

logger.debug({
env: process.env.NODE_ENV,
isStatic: pack.isStatic(),
paths: {
appPath: app.getAppPath(),
exePath: app.getPath('exe'),
@@ -126,7 +129,7 @@ class DreamApp {
minHeight: 700,
icon: join(config.rootDir, 'dist', 'icon.ico'),
webPreferences: {
nodeIntegration: false,
nodeIntegration: true,
preload: join(app.getAppPath(), 'electron', 'dist', 'provider.js'),
},
})

+ 71
- 17
src/electron/src/modules/app-error.js View File

@@ -7,11 +7,14 @@
//
// Written by Ivan Bravo Bravo <ivan@dreamnet.tech>, 2019.

import { isError, isString } from 'lodash'
import { app, dialog } from 'electron'
import {
isError, isString, isObject, isArray,
} from 'lodash'
import { app, dialog, ipcMain } from 'electron'
import { activeWindow } from 'electron-util'
import { rollbar } from './services/rollbar'

const logger = require('logplease').create('electron:scripts:error')
const logger = require('logplease').create('electron:app-error')

/**
* @typedef {Object} ErrorOptions
@@ -22,11 +25,14 @@ const logger = require('logplease').create('electron:scripts:error')
*/

export class AppError extends Error {
renderer = false

options = {
title: null,
error: null,
level: 'error',
fatal: false,
quiet: false,
}

/**
@@ -69,10 +75,10 @@ export class AppError extends Error {

try {
// logger
logger[level](`💔 ${this.message}`)
logger[level](this.message)

if (rollbar.enabled) {
const error = this.options.error || Error(this.message)
const error = this.options.error || this

const response = rollbar[level](this.message, error, this.options)

@@ -81,17 +87,45 @@ export class AppError extends Error {
}
}
} catch (err) {
logger.warn('💔 Error report fail!', err)
logger.warn('Error report fail!', err)
}

this.show()
}

show() {
dialog.showErrorBox(
this.options.title || 'A problem has occurred.',
this.message,
)
const window = activeWindow()

if (this.renderer && window) {
let icon = 'error'

if (this.level === 'warning' || this.level === 'warn') {
icon = 'warning'
}

if (this.level === 'info') {
icon = 'info'
}

window.webContents.send('alert', {
title: this.options.title,
text: this.message,
icon,
})
} else {
dialog.showErrorBox(
this.options.title || 'A problem has occurred.',
this.message,
)
}
}

handle() {
if (process.env.NODE_ENV !== 'development') {
this.report()
}

if (!this.options.quiet) {
this.show()
}

if (this.options.fatal) {
app.quit()
@@ -101,15 +135,35 @@ export class AppError extends Error {
static handle(error) {
let appError = error

if (!(appError instanceof this)) {
appError = new this(
isError(appError) ? error : 'The program has encountered an unexpected error.',
if (!(error instanceof AppError)) {
let reportError

if (isError(error)) {
reportError = error
} else if (isObject(error) || isArray(error)) {
reportError = JSON.stringify(error)
} else {
reportError = new Error(error)
}

appError = new AppError(
isError(error) ? error : 'The application has encountered an unexpected error. It\'s all we know, try again or restart the application.',
{
error: isError(appError) ? appError : new Error(appError),
error: reportError,
title: 'Unexpected error!',
},
)
}

appError.report()
appError.handle()
}

static handleRenderer(message, stack, options = {}) {
const appError = new AppError(message, options)

appError.stack = stack
appError.renderer = true

appError.handle()
}
}

+ 44
- 35
src/electron/src/modules/services/base.js View File

@@ -14,6 +14,44 @@ import fs from 'fs'

const logger = require('logplease').create('services')

export function makeServiceProxy(obj) {
return new Proxy(obj, {
get: (obj, prop) => {
if (prop in obj) {
return obj[prop]
}

/* eslint-disable no-underscore-dangle */
if (obj._service && prop in obj._service) {
return obj._service[prop]
}
/* eslint-enable no-underscore-dangle */

if (prop in obj.payload) {
return obj.payload[prop]
}

return undefined
},

/* eslint-disable no-param-reassign */
set: (obj, prop, value) => {
if (!isNil(obj.payload)) {
if (prop in obj.payload) {
obj.payload[prop] = value
obj.save()

return true
}
}

obj[prop] = value
return true
},
/* eslint-enable no-param-reassign */
})
}

export class BaseService {
/**
* the payload.
@@ -51,42 +89,13 @@ export class BaseService {
*
* @return {BaseService}
*/
static make() {
return new Proxy(new this(), {
get: (obj, prop) => {
if (prop in obj) {
return obj[prop]
}

/* eslint-disable no-underscore-dangle */
if (obj._service && prop in obj._service) {
return obj._service[prop]
}
/* eslint-enable no-underscore-dangle */

if (prop in obj.payload) {
return obj.payload[prop]
}

return undefined
},

/* eslint-disable no-param-reassign */
set: (obj, prop, value) => {
if (!isNil(obj.payload)) {
if (prop in obj.payload) {
obj.payload[prop] = value
obj.save()

return true
}
}
static make(obj) {
if (!obj) {
// eslint-disable-next-line no-param-reassign
obj = new this()
}

obj[prop] = value
return true
},
/* eslint-enable no-param-reassign */
})
return makeServiceProxy(obj)
}

/**

+ 1
- 0
src/electron/src/modules/services/index.js View File

@@ -7,6 +7,7 @@
//
// Written by Ivan Bravo Bravo <ivan@dreamnet.tech>, 2019.

export { makeServiceProxy } from './base'
export { settings } from './settings'
export { nucleus } from './nucleus'
export { rollbar } from './rollbar'

+ 1
- 1
src/electron/src/modules/services/nucleus.js View File

@@ -20,7 +20,7 @@ const logger = require('logplease').create('services:nucleus')
* https://nucleus.sh
* Analytics and bug tracking for Javascript desktop apps.
*/
class NucleusService extends BaseService {
export class NucleusService extends BaseService {
/**
* @type {string}
*/

+ 7
- 1
src/electron/src/modules/services/rollbar.js View File

@@ -13,6 +13,7 @@ import Rollbar from 'rollbar'
import { BaseService } from './base'
import { settings } from './settings'
import { nucleus } from './nucleus'
import { system } from '../tools/system'

const logger = require('logplease').create('services:rollbar')

@@ -52,7 +53,7 @@ class RollbarService extends BaseService {
captureUncaught: false,
captureUnhandledRejections: false,
captureIp: 'anonymize',
enabled: settings.telemetry.enabled && process.env.NODE_ENV !== 'development',
enabled: settings.telemetry.enabled,
verbose: process.env.NODE_ENV === 'development',
logLevel: 'info',
nodeSourceMaps: true,
@@ -69,6 +70,11 @@ class RollbarService extends BaseService {
},
},
settings: settings.payload,
system: {
graphics: system.graphics,
cpu: system.cpu,
os: system.os,
},
},
}
}

+ 1
- 1
src/electron/src/modules/tools/fs.js View File

@@ -7,7 +7,7 @@ import { isNil } from 'lodash'
import mime from 'mime-types'
import EventBus from 'js-event-bus'
import axios from 'axios'
import { api, is, platform } from 'electron-utils'
import { api, is, platform } from 'electron-util'
import filesize from 'filesize'
import unzipper from 'unzipper'
import deferred from 'deferred'

+ 3
- 2
src/electron/src/modules/tools/index.js View File

@@ -10,11 +10,12 @@
import * as paths from './paths'
import * as shell from './shell'
import * as power from './power'
import * as fs from './fs'

// eslint-disable-next-line import/no-cycle
export fs from './fs'
export { fs }
export { shell }
export { paths }
export { power }
export utils from 'electron-utils'
export utils from 'electron-util'
export { system } from './system'

+ 1
- 1
src/electron/src/modules/tools/paths.js View File

@@ -9,7 +9,7 @@

import path from 'path'
import fs from 'fs-extra'
import { api } from 'electron-utils'
import { api } from 'electron-util'
import { settings } from '../services'

/**

+ 1
- 1
src/electron/src/modules/tools/shell.js View File

@@ -8,7 +8,7 @@
// Written by Ivan Bravo Bravo <ivan@dreamnet.tech>, 2019.

import { isNil } from 'lodash'
import { is } from 'electron-utils'
import { is } from 'electron-util'
import regedit from 'regedit'
import { getAppResourcesPath } from './paths'


+ 34
- 17
src/electron/src/modules/tools/system.js View File

@@ -8,14 +8,14 @@
// Written by Ivan Bravo Bravo <ivan@dreamnet.tech>, 2019.

import {
filter, isString, isNil, isArray, toInteger,
filter, isString, isNil, isArray, toInteger, get,
} from 'lodash'
import { existsSync, statSync } from 'fs'
import si from 'systeminformation'
import isOnline from 'is-online'
import compareVersions from 'compare-versions'
import filesize from 'filesize'
import { is } from 'electron-utils'
import { is } from 'electron-util'
import regedit from 'regedit'
import { nucleus } from '../services'
import { getAppResourcesPath, getPowerPath, getCheckpointsPath } from './paths'
@@ -65,6 +65,10 @@ class System {
minimum: false,
recommended: false,
},
gpuram: {
minimum: false,
recommended: false,
},
}

/**
@@ -101,18 +105,33 @@ class System {
*
*/
async scan() {
this.requirements.power.installed = this._hasPower
this.requirements.power.compatible = await this._hasCompatiblePower()
this.requirements.power.checkpoints = this._hasCheckpoints
const { requirements } = this

// dreampower
requirements.power.installed = this._hasPower
requirements.power.compatible = await this._hasCompatiblePower()
requirements.power.checkpoints = this._hasCheckpoints

this.requirements.windows.media = await this._hasWindowsMedia()
// windows
requirements.windows.media = await this._hasWindowsMedia()

this.requirements.ram.recommended = this.memory.total >= 8589934592 // 8 GB
this.requirements.ram.minimum = this.memory.total >= 6442450944 // 6 GB
// ram
requirements.ram.recommended = this.memory.total >= 8589934592 // 8 GB
requirements.ram.minimum = this.memory.total >= 6442450944 // 6 GB

// gpu ram
this.requirements = requirements

logger.info('Requirements:', this.requirements)
}

/**
* @type {boolean}
*/
get canNudify() {
return this.requirements.power.installed && this.requirements.power.compatible && this.requirements.power.checkpoints
}

/**
* @type {Array}
*/
@@ -159,18 +178,16 @@ class System {
}

const version = await getVersion()
const compatibility = nucleus.compatibility[`v${process.env.npm_package_version}`]

if (!isArray(compatibility)) {
return true
const minimum = get(nucleus, `projects.dreamtime.releases.v${process.env.npm_package_version}.dreampower.minimum`, 'v1.2.3')
const maximum = get(nucleus, `projects.dreamtime.releases.v${process.env.npm_package_version}.dreampower.maximum`)

if (compareVersions.compare(version, minimum, '<')) {
return false
}

for (const conditions of compatibility) {
// v1.2.2 v1.0.0 >= = true
// v1.2.2 v.1.0 <= = false
if (!compareVersions.compare(version, conditions[0], conditions[1])) {
return false
}
if (!isNil(maximum) && compareVersions.compare(version, maximum, '>')) {
return false
}

return true

+ 1
- 1
src/electron/src/modules/updater/base.js View File

@@ -17,7 +17,7 @@ import deferred from 'deferred'
import filesize from 'filesize'
import delay from 'delay'
import { dialog } from 'electron'
import { platform } from 'electron-utils'
import { platform } from 'electron-util'
import { basename } from 'path'
import { nucleus } from '../services'
import { system } from '../tools'

+ 1
- 1
src/electron/src/modules/updater/checkpoints.js View File

@@ -8,7 +8,7 @@
// Written by Ivan Bravo Bravo <ivan@dreamnet.tech>, 2019.

import { app, Notification } from 'electron'
import { activeWindow } from 'electron-utils'
import { activeWindow } from 'electron-util'
import { BaseUpdater } from './base'
import { AppError } from '../app-error'
import { system } from '../tools/system'

+ 1
- 1
src/electron/src/modules/updater/dreampower.js View File

@@ -10,7 +10,7 @@
import { isNil, get } from 'lodash'
import compareVersions from 'compare-versions'
import { app, Notification } from 'electron'
import { activeWindow } from 'electron-utils'
import { activeWindow } from 'electron-util'
import { BaseUpdater } from './base'
import { AppError } from '../app-error'
import { settings } from '../services/settings'

+ 1
- 1
src/electron/src/modules/updater/dreamtime.js View File

@@ -10,7 +10,7 @@
import { shell, app, Notification } from 'electron'
import { dirname } from 'path'
import delay from 'delay'
import { activeWindow } from 'electron-utils'
import { activeWindow } from 'electron-util'
import { BaseUpdater } from './base'
import { AppError } from '../app-error'


+ 21
- 3
src/electron/src/provider.js View File

@@ -1,12 +1,30 @@
const { remote } = require('electron')
const { makeServiceProxy } = require('./modules/services')

const util = remote.require('electron-util')
const Logger = remote.require('logplease')
const { AppError } = remote.require('./modules/app-error')
const services = remote.require('./modules/services')
const updater = remote.require('./modules/updater')
const tools = remote.require('./modules/tools')

// main process provider
// tools provider
window.$provider = {
AppError,
services,
services: {
nucleus: makeServiceProxy(services.nucleus),
rollbar: makeServiceProxy(services.rollbar),
settings: makeServiceProxy(services.settings),
},

tools,
updater,

api: util.api,
util,
}

// logger
window.Logger = Logger

// application error
window.AppError = AppError

+ 7
- 4
src/modules/dream.js View File

@@ -2,13 +2,16 @@
const debug = require('debug').default('app:modules:app')

export default {
name: process.env.npm_package_displayName,

version: `v${process.env.npm_package_version}`,

status: 'stable',

/**
*
*/
init() {
this.name = process.env.npm_package_displayName
this.version = `v${process.env.npm_package_version}`
this.status = 'stable'
setup() {
this.settings = $provider.services.nucleus
},
}

+ 2
- 4
src/modules/models/photo-job.js View File

@@ -1,13 +1,10 @@
import _ from 'lodash'
import moment from 'moment'
import Deferred from 'deferred'
import { activeWindow } from 'electron-utils'

import File from '../file'
import Timer from '../timer'
import { rand } from '../helpers'
import WebError from '~/modules/web-error'

import { WebError } from '~/modules/web-error'
import cliErrors from '../config/cli-errors'
import preferencesConfig from '../config/preferences'

@@ -15,6 +12,7 @@ const debug = require('debug').default('app:modules:models:photo-job')

const { settings, nucleus } = $provider.services
const { transform } = $provider.tools.power
const { activeWindow } = $provider.util

export default class PhotoJob {
constructor(id, photo) {

+ 2
- 2
src/modules/models/photo.js View File

@@ -3,15 +3,15 @@ import uuid from 'uuid'
import swal from 'sweetalert'
import Queue from 'better-queue'
import MemoryStore from 'better-queue-memory'
import { activeWindow } from 'electron-utils'
import Timer from '../timer'
import PhotoJob from './photo-job'
import WebError from '../web-error'
import { WebError } from '../web-error'

const debug = require('debug').default('app:modules:models:photo')

const { settings } = $provider.services
const { getModelsPath } = $provider.tools.paths
const { activeWindow } = $provider.util

/**
* Represents the photo to be processed of a Model.

+ 3
- 23
src/modules/web-error.js View File

@@ -7,33 +7,13 @@
//
// Written by Ivan Bravo Bravo <ivan@dreamnet.tech>, 2019.

import _ from 'lodash'
import { isError } from 'lodash'
import { markdown } from 'markdown'
import { api } from 'electron-utils'
import swal from 'sweetalert'

const { AppError } = $provider
const { app } = $provider.api

export class WebError extends AppError {
show() {
let icon = 'error'
export class WebError extends Error {

if (this.level === 'warning' || this.level === 'warn') {
icon = 'warning'
}

if (this.level === 'info') {
icon = 'info'
}

swal({
title: this.title,
content: this.message,
icon,
})

if (this.options.fatal) {
api.app.quit()
}
}
}

+ 22
- 17
src/nuxt.config.js View File

@@ -1,5 +1,8 @@
/* eslint-disable no-param-reassign */
// eslint-disable-next-line nuxt/no-cjs-in-config
/* eslint-disable nuxt/no-cjs-in-config */

const nodeExternals = require('webpack-node-externals')

module.exports = {
mode: 'spa',

@@ -22,7 +25,7 @@ module.exports = {
** Headers of the page
*/
head: {
title: `${process.env.npm_package_name} v${process.env.npm_package_version}`,
title: `${process.env.npm_package_displayName} v${process.env.npm_package_version}`,

meta: [
{ charset: 'utf-8' },
@@ -113,24 +116,26 @@ module.exports = {
** You can extend webpack config here
*/
extend(config, { isClient, isDev }) {
// config.target = 'electron-renderer'
config.target = 'electron-renderer'

config.externals = [nodeExternals({
modulesFromFile: {
include: ['dependencies'],
},
})]

// exclude browser field resolution
const mainFields = ['esnext', 'main']
config.resolve.mainFields = mainFields
config.resolve.aliasFields = mainFields

config.node = {
__dirname: process.env.NODE_ENV === 'development',
__filename: process.env.NODE_ENV === 'development',
}

if (isDev) {
config.devtool = isClient ? 'source-map' : 'inline-source-map'

// const RollbarSourceMapPlugin = require('rollbar-sourcemap-webpack-plugin')
/*
config.plugins.push(
new RollbarSourceMapPlugin({
accessToken: process.env.ROLLBAR_ACCESS_TOKEN,
version: process.env.npm_package_version,
publicPath: source => {
console.log(source)
return `@/${source}`
}
})
)
*/
} else {
config.output.publicPath = './_nuxt/'
}

+ 4
- 2
src/package.json View File

@@ -63,13 +63,14 @@
"delay": "^4.3.0",
"electron": "^7.1.1",
"electron-context-menu": "^0.15.1",
"electron-utils": "^3.0.11",
"electron-util": "^0.13.0",
"filesize": "^6.0.1",
"fs-extra": "^8.1.0",
"gpu-info": "^0.0.1",
"gsap": "^3.0.1",
"image-js": "^0.21.8",
"is-online": "^8.2.0",
"izitoast": "^1.4.0",
"js-event-bus": "^1.0.0",
"lodash": "^4.17.15",
"logplease": "^1.2.15",
@@ -94,7 +95,8 @@
"systeminformation": "^4.15.3",
"tippy.js": "^5.1.1",
"unzipper": "^0.10.5",
"uuid": "^3.3.3"
"uuid": "^3.3.3",
"webpack-node-externals": "^1.7.2"
},
"devDependencies": {
"@babel/cli": "^7.7.0",

+ 2
- 2
src/pages/nudify/results.vue View File

@@ -66,7 +66,7 @@
</template>

<script>
import { api } from 'electron-utils'
const { shell } = $provider.api

export default {
data: () => ({
@@ -105,7 +105,7 @@ export default {
*
*/
openFolder() {
api.shell.openItem(this.photo.getFolderPath())
shell.openItem(this.photo.getFolderPath())
},
},
}

+ 20
- 24
src/pages/system/about.vue View File

@@ -14,21 +14,21 @@
<div v-if="alert" class="notification is-warning text-lg" v-html="alert" />

<!-- Limited! -->
<section v-if="$platform.isLimited" class="box box-section">
<section v-if="!$provider.tools.system.online" class="box box-section">
<box-section-item
:description="`It's okay! You can use ${$dream.name} offline, but while you are disconnected we cannot offer you more information about the project, updates or report errors automatically.`"
label="It seems that you are offline" />
</section>

<!-- Requirements -->
<section v-if="!$platform.requirements.all" class="box box-section">
<section v-if="!$provider.tools.system.canNudify" class="box box-section">
<box-section-item :description="`You need to meet all the requirements below to start using ${$dream.name}. Some require an Internet connection to update.`" icon="📜" label="Requirements" />

<box-section-item
label="DreamPower"
description="You have not installed DreamPower or the current version is not compatible.">
<template slot="icon">
<span v-if="$platform.requirements.cli" class="item-icon">✔</span>
<span v-if="$provider.tools.system.requirements.power.installed" class="item-icon">✔</span>
<span v-else class="item-icon">❌</span>
</template>

@@ -42,7 +42,7 @@
label="Checkpoints"
description="Data models required by the algorithm.">
<template slot="icon">
<span v-if="$platform.requirements.checkpoints" class="item-icon">✔</span>
<span v-if="$provider.tools.system.requirements.power.checkpoints" class="item-icon">✔</span>
<span v-else class="item-icon">❌</span>
</template>

@@ -53,7 +53,7 @@
label="Media Feature Pack"
description="Multimedia package required by some versions of Windows.">
<template slot="icon">
<span v-if="$platform.requirements.windowsMedia" class="item-icon">✔</span>
<span v-if="$provider.tools.system.requirements.windows.media" class="item-icon">✔</span>
<span v-else class="item-icon">❗</span>
</template>

@@ -110,7 +110,7 @@

<app-update id="dreampower" project-title="DreamPower" project="dreampower" />

<app-update v-if="$platform.requirements.cli" id="checkpoints" project-title="Checkpoints" project="checkpoints" />
<app-update v-if="$provider.tools.system.requirements.power.installed" id="checkpoints" project-title="Checkpoints" project="checkpoints" />

<box-section-item
v-for="(item, index) in cliNavigation"
@@ -187,52 +187,48 @@
</template>

<script>
import _ from 'lodash'
import { api } from 'electron-utils'
import { get, isNil } from 'lodash'

const { nucleus } = $provider.services
const { getAppPath, getPowerPath } = $provider.tools.paths
const { shell } = $provider.api

export default {
computed: {
guiNavigation() {
return nucleus.enabled ? nucleus.about.dreamtime.navigation : []
return get(nucleus, 'about.dreamtime.navigation', [])
},

guiDescription() {
return nucleus.enabled
? nucleus.about.dreamtime.description
: 'Friendly user interface for DreamPower.'
return get(nucleus, 'about.dreamtime.description', process.env.npm_package_description)
},

cliNavigation() {
return nucleus.enabled ? nucleus.about.dreampower.navigation : []
return get(nucleus, 'about.dreampower.navigation', [])
},

cliTitle() {
return nucleus.enabled ? nucleus.about.dreampower.title : 'DreamPower'
return get(nucleus, 'about.dreampower.title', 'DreamPower')
},

cliDescription() {
return nucleus.enabled
? nucleus.about.dreampower.description
: 'Deep learning algorithm capable of nudify people photos.'
return get(nucleus, 'about.dreampower.description', 'Deep learning algorithm capable of nudify people photos.')
},

dreamNetNavigation() {
return nucleus.enabled ? nucleus.about.dreamnet.navigation : []
return get(nucleus, 'about.dreamnet.navigation', [])
},

contributors() {
return nucleus.enabled ? nucleus.about.contributors : []
return get(nucleus, 'about.contributors', [])
},

developers() {
return nucleus.enabled ? nucleus.about.developers : []
return get(nucleus, 'about.developers', [])
},

alert() {
return nucleus.enabled ? nucleus.alerts.about : undefined
return get(nucleus, 'alerts.about', [])
},
},

@@ -242,15 +238,15 @@ export default {

methods: {
openGUI() {
api.shell.openItem(getAppPath())
shell.openItem(getAppPath())
},

openCLI() {
api.shell.openItem(getPowerPath())
shell.openItem(getPowerPath())
},

isURL(str) {
if (_.isNil(str)) {
if (isNil(str)) {
return false
}


+ 2
- 2
src/pages/system/settings/folders.vue View File

@@ -37,10 +37,10 @@

<script>
import _ from 'lodash'
import { api } from 'electron-utils'
import { VModel } from '~/mixins'

const { existsSync } = $provider.tools.fs
const { shell } = $provider.api

export default {
mixins: [VModel],
@@ -53,7 +53,7 @@ export default {

methods: {
showOpenDialog(path) {
const dir = api.shell.showOpenDialog(null, {
const dir = shell.showOpenDialog(null, {
defaultPath: path,
properties: ['openDirectory'],
})

+ 34
- 12
src/plugins/boot.js View File

@@ -2,12 +2,15 @@
import Vue from 'vue'
import moment from 'moment'
import tippy from 'tippy.js'
import swal from 'sweetalert'
import { isError } from 'lodash'
import { ipcRenderer } from 'electron'
import BaseMixin from '~/mixins/BaseMixin'
import {
dream, nudify, WebError,
dream, nudify,
} from '~/modules'

const logger = require('logplease').create('plugins:boot')
const logger = Logger.create('plugins:boot')

// lift off!
logger.info('Lift off!')
@@ -24,37 +27,56 @@ tippy.setDefaultProps({
arrow: true,
})

// eslint-disable-next-line no-unused-vars
export default async ({ app }, inject) => {
// provider shortcuts
inject('provider', $provider)
inject('settings', $provider.services.settings)
inject('nucleus', $provider.services.nucleus)

ipcRenderer.on('alert', (event, payload) => {
swal(payload)
})

// error handlers

window.addEventListener('error', (err) => {
logger.warn('Web error!', err)
WebError.handle(err)
const handleError = (error, quiet = false) => {
let message
let stack
let options = { quiet }

if (isError(error)) {
message = error.message
stack = error.stack

if (error instanceof AppError) {
options = error.options
}
} else {
message = error
stack = (new Error('dummy')).stack
}

AppError.handleRenderer(message, stack, options)
}

window.addEventListener('error', (err) => {
handleError(err)
return true
})

window.addEventListener('unhandledrejection', (rejection) => {
logger.warn('Web Unhandled rejection!', rejection)
WebError.handle(rejection.reason)

handleError(rejection.reason)
return true
})

Vue.config.errorHandler = (err) => {
logger.warn('VueJS error!', err)
WebError.handle(err)

handleError(err, true)
throw err
}

// dreamtime
dream.init()
dream.setup()
inject('dream', dream)

// nudify process

Loading…
Cancel
Save