format the source code

pull/405/head
Abdullah Alfaraj 2023-10-09 13:02:07 +03:00
parent 66ae39351f
commit 5f89d34568
8 changed files with 61 additions and 55 deletions

View File

@ -1,32 +1,33 @@
import chalk from 'chalk'; import chalk from 'chalk'
import { program } from 'commander'; import { program } from 'commander'
import { createWriteStream, readFileSync, statSync, writeFileSync } from 'fs'; import { createWriteStream, readFileSync, statSync, writeFileSync } from 'fs'
import { globSync } from 'glob'; import { globSync } from 'glob'
import { dirname, join, relative } from 'path'; import { dirname, join, relative } from 'path'
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'url'
import yazl from 'yazl' import yazl from 'yazl'
const __dirname = dirname(fileURLToPath(import.meta.url)) const __dirname = dirname(fileURLToPath(import.meta.url))
const basePath = join(__dirname, '..') const basePath = join(__dirname, '..')
program program.requiredOption('--version <platform>', 'the target platform').parse()
.requiredOption("--version <platform>", "the target platform")
.parse();
const version = program.opts().version; const version = program.opts().version
if (!version.match(/\d+\.\d+\.\d+/)) throw new Error(`invalid version format: ${version}`); if (!version.match(/\d+\.\d+\.\d+/))
throw new Error(`invalid version format: ${version}`)
console.log(chalk.cyan("rewriting manifest.json's version field to " + version)); console.log(chalk.cyan("rewriting manifest.json's version field to " + version))
const manifest = JSON.parse(readFileSync(`${basePath}/manifest.json`, 'utf-8')); const manifest = JSON.parse(readFileSync(`${basePath}/manifest.json`, 'utf-8'))
manifest.version = version; manifest.version = version
writeFileSync(`${basePath}/manifest.json`, JSON.stringify(manifest)); writeFileSync(`${basePath}/manifest.json`, JSON.stringify(manifest))
console.log(chalk.cyan("rewriting package.json's version field to " + version)); console.log(chalk.cyan("rewriting package.json's version field to " + version))
const packageJSON = JSON.parse(readFileSync(`${basePath}/package.json`, 'utf-8')); const packageJSON = JSON.parse(
packageJSON.version = version; readFileSync(`${basePath}/package.json`, 'utf-8')
writeFileSync(`${basePath}/package.json`, JSON.stringify(packageJSON)); )
packageJSON.version = version
writeFileSync(`${basePath}/package.json`, JSON.stringify(packageJSON))
console.log(chalk.cyan("packaging .ccx")); console.log(chalk.cyan('packaging .ccx'))
const zipList = [ const zipList = [
'./manifest.json', './manifest.json',
'./i18n/**/*', './i18n/**/*',
@ -46,24 +47,28 @@ const zipList = [
'./*.png', './*.png',
] ]
const zipfile = new yazl.ZipFile(); const zipfile = new yazl.ZipFile()
zipList.forEach(globber => { zipList.forEach((globber) => {
globSync( globSync(join(basePath, globber).replace(/\\/g, '/')).forEach(
join(basePath, globber).replace(/\\/g, '/') (filepath) => {
).forEach(filepath => { if (statSync(filepath).isDirectory()) return
if (statSync(filepath).isDirectory()) return;
const rpath = relative(basePath, filepath); const rpath = relative(basePath, filepath)
zipfile.addFile(filepath, rpath) zipfile.addFile(filepath, rpath)
}) }
)
}) })
zipfile.outputStream.pipe( zipfile.outputStream.pipe(
createWriteStream(join(basePath, `Auto.Photoshop.SD.plugin_v${version}.ccx`)) createWriteStream(
); join(basePath, `Auto.Photoshop.SD.plugin_v${version}.ccx`)
)
)
zipfile.outputStream.pipe( zipfile.outputStream.pipe(
createWriteStream(join(basePath, `Auto.Photoshop.SD.plugin_v${version}.zip`)) createWriteStream(
); join(basePath, `Auto.Photoshop.SD.plugin_v${version}.zip`)
)
)
zipfile.end() zipfile.end()

View File

@ -37,4 +37,4 @@
margin: 0; margin: 0;
padding: 0; padding: 0;
border: none; border: none;
} }

View File

@ -39,7 +39,8 @@ async function requestControlNetApiVersion() {
async function requestControlNetMaxUnits() { async function requestControlNetMaxUnits() {
const json = await api.requestGet(`${g_sd_url}/controlnet/settings`) const json = await api.requestGet(`${g_sd_url}/controlnet/settings`)
const control_net_max_models_num = (json?.control_net_unit_count || json?.control_net_max_models_num) ?? 0 const control_net_max_models_num =
(json?.control_net_unit_count || json?.control_net_max_models_num) ?? 0
return control_net_max_models_num return control_net_max_models_num
} }

View File

@ -259,7 +259,7 @@ export async function updateClickEventHandler(current_version: string) {
online_data.new_version online_data.new_version
) )
let header_message = "Your Plugin is up to date." let header_message = 'Your Plugin is up to date.'
let long_message = '' let long_message = ''
if (b_need_update) { if (b_need_update) {
header_message = `New Version is Available (${online_data.new_version})` header_message = `New Version is Available (${online_data.new_version})`

View File

@ -5,16 +5,9 @@
} }
.generateColor { .generateColor {
background-color: #ff595e; background-color: #ff595e;
} }
.generateMoreColor { .generateMoreColor {
background-color: #6db579; background-color: #6db579;
}
}

View File

@ -1,4 +1,4 @@
/* styles.css */ /* styles.css */
#_tool_bar_container button:not(:last-child) { #_tool_bar_container button:not(:last-child) {
margin-bottom: 3px; margin-bottom: 3px;
} }

View File

@ -251,7 +251,8 @@ export async function base64ToFileAndGetLayer(
_obj: 'rectangle', _obj: 'rectangle',
bottom: { bottom: {
_unit: 'pixelsUnit', _unit: 'pixelsUnit',
_value: jimp_image.bitmap.height * willScaleSize, _value:
jimp_image.bitmap.height * willScaleSize,
}, },
left: { left: {
_unit: 'pixelsUnit', _unit: 'pixelsUnit',
@ -274,7 +275,7 @@ export async function base64ToFileAndGetLayer(
commandName: 'select import area', commandName: 'select import area',
} }
) )
await executeAsModal( await executeAsModal(
async () => { async () => {
const result = await batchPlay( const result = await batchPlay(
@ -288,19 +289,25 @@ export async function base64ToFileAndGetLayer(
}, },
freeTransformCenterState: { freeTransformCenterState: {
_enum: 'quadCenterState', _enum: 'quadCenterState',
_value: "QCSCorner0" _value: 'QCSCorner0',
}, },
offset: { offset: {
_obj: "offset", _obj: 'offset',
horizontal: { _unit: "pixelsUnit", _value: 0.0 }, horizontal: { _unit: 'pixelsUnit', _value: 0.0 },
vertical: { _unit: "pixelsUnit", _value: 0.0 } vertical: { _unit: 'pixelsUnit', _value: 0.0 },
}, },
_isCommand: true, _isCommand: true,
_options: { _options: {
dialogOptions: 'dontDisplay', dialogOptions: 'dontDisplay',
}, },
width: { "_unit": "percentUnit", "_value": 1 / willScaleSize * 100 }, width: {
height: { "_unit": "percentUnit", "_value": 1 / willScaleSize * 100 } _unit: 'percentUnit',
_value: (1 / willScaleSize) * 100,
},
height: {
_unit: 'percentUnit',
_value: (1 / willScaleSize) * 100,
},
}, },
], ],
{} {}

View File

@ -3,4 +3,4 @@
border-right: 2px solid #3e3e3e; border-right: 2px solid #3e3e3e;
margin: 0; margin: 0;
width: 100%; width: 100%;
} }