Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
heapwolf committed Feb 29, 2024
1 parent 34e28df commit 83db1d5
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 47 deletions.
77 changes: 38 additions & 39 deletions src/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,42 @@ import { resizePNG } from './icon/index.js'

import * as monaco from 'monaco-editor'

function rgbaToHex(rgbaString) {
const rgbaValues = rgbaString.match(/\d+/g);
const r = parseInt(rgbaValues[0]);
const g = parseInt(rgbaValues[1]);
const b = parseInt(rgbaValues[2]);
const a = Math.round(parseFloat(rgbaValues[3]) * 255);

const rHex = r.toString(16).padStart(2, '0');
const gHex = g.toString(16).padStart(2, '0');
const bHex = b.toString(16).padStart(2, '0');
const aHex = a.toString(16).padStart(2, '0');

return `#${rHex}${gHex}${bHex}${aHex}`;
function rgbaToHex (rgbaString) {
const rgbaValues = rgbaString.match(/\d+/g)

const r = parseInt(rgbaValues[0])
const g = parseInt(rgbaValues[1])
const b = parseInt(rgbaValues[2])

const a = Math.round(parseFloat(rgbaValues[3]) * 255)

const rHex = r.toString(16).padStart(2, '0')
const gHex = g.toString(16).padStart(2, '0')
const bHex = b.toString(16).padStart(2, '0')
const aHex = a.toString(16).padStart(2, '0')

return `#${rHex}${gHex}${bHex}${aHex}`
}

globalThis.MonacoEnvironment = {
getWorkerUrl: function (moduleId, label) {
if (label === 'json') {
return 'vs/language/json/json.worker.js';
return 'vs/language/json/json.worker.js'
}

if (label === 'css' || label === 'scss' || label === 'less') {
return 'vs/language/css/css.worker.js';
return 'vs/language/css/css.worker.js'
}

if (label === 'html' || label === 'handlebars' || label === 'razor') {
return 'vs/language/html/html.worker.js';
return 'vs/language/html/html.worker.js'
}

if (label === 'typescript' || label === 'javascript') {
return 'vs/language/typescript/ts.worker.js';
return 'vs/language/typescript/ts.worker.js'
}

return 'vs/editor/editor.worker.js';
return 'vs/editor/editor.worker.js'
}
}

Expand All @@ -60,14 +60,14 @@ class AppEditor extends Tonic {
const pickerOpts = {
types: [
{
description: "Images",
description: 'Images',
accept: {
"image/*": ['.png'],
},
},
'image/*': ['.png']
}
}
],
excludeAcceptAllOption: true,
multiple: false,
multiple: false
}

if (event === 'size') {
Expand Down Expand Up @@ -119,7 +119,6 @@ class AppEditor extends Tonic {

if (type.length) {
if (/image/.test(type[0].mime)) {

// Display a preview for this type.
return
}
Expand Down Expand Up @@ -209,43 +208,43 @@ class AppEditor extends Tonic {
monaco.editor.setTheme(theme)
}

async loadAPIs(directoryPath = './socket') {
async loadAPIs (directoryPath = './socket') {
const readDir = async (dirPath) => {
const entries = await fs.promises.readdir(dirPath, { withFileTypes: true });
const entries = await fs.promises.readdir(dirPath, { withFileTypes: true })

entries.forEach(async (entry) => {
const fullPath = path.join(dirPath, entry.name);
const fullPath = path.join(dirPath, entry.name)

if (entry.isDirectory()) {
readDir(fullPath).catch(err => console.error(`Error reading directory ${fullPath}:`, err));
readDir(fullPath).catch(err => console.error(`Error reading directory ${fullPath}:`, err))
} else {
if (path.extname(fullPath) === '.ts') {
fs.promises.readFile(fullPath, 'utf8')
.then(sourceText => {
monaco.languages.typescript.javascriptDefaults.addExtraLib(sourceText, `socket/${fullPath}`);
monaco.languages.typescript.typescriptDefaults.addExtraLib(sourceText, `socket/${fullPath}`);
monaco.languages.typescript.javascriptDefaults.addExtraLib(sourceText, `socket/${fullPath}`)
monaco.languages.typescript.typescriptDefaults.addExtraLib(sourceText, `socket/${fullPath}`)
})
.catch(err => console.error(`Error reading file ${fullPath}:`, err));
.catch(err => console.error(`Error reading file ${fullPath}:`, err))
}
}
});
};
})
}

try {
await readDir(directoryPath);
await readDir(directoryPath)
} catch (err) {
console.error('Error initiating read directory operation:', err);
console.error('Error initiating read directory operation:', err)
}
}

async refreshSettings () {
let parent = this.props.parent
const parent = this.props.parent
this.editor.updateOptions(parent.state.settings?.editorOptions || {})
}

connected () {
let theme
let parent = this.props.parent
const parent = this.props.parent

this.editor = monaco.editor.create(this.querySelector('.editor'), {
value: '',
Expand Down
7 changes: 3 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class AppView extends Tonic {

const settingsFile = path.join(this.state.cwd, 'settings.json')
const notifications = document.querySelector('#notifications')

try {
projectExists = await fs.promises.stat(path.join(this.state.cwd, 'socket.ini'))
} catch {}
Expand All @@ -74,7 +74,7 @@ class AppView extends Tonic {

this.state.settings = defaultSettings
await fs.promises.writeFile(settingsFile, JSON.stringify(defaultSettings))
await this.installTemplates()
await this.installTemplates()
}

if (projectExists) {
Expand All @@ -95,7 +95,6 @@ class AppView extends Tonic {
title: 'Unable to read settings from ${settingsFile}',
message: err.message
})
return
}
}
}
Expand All @@ -120,7 +119,7 @@ class AppView extends Tonic {
dir = path.join('icons', 'icon.ico')
} else {
dir = path.join('icons', 'icon.png')
}
}
}

paths[path.join(this.state.cwd, dir)] = data
Expand Down
2 changes: 1 addition & 1 deletion src/ini.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function set (src, section, key, value) {
if (parts[0] === key) {
value = `${parts[0]} = ${value}`
lines[i] = value
}
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ class AppTerminal extends Tonic {
// this.term.loadAddon(this.ligatures)
this._term.open(el)
this.resizer.fit()

this._term.options.cursorBlink = false

this._term.attachCustomKeyEventHandler(function (e) {
Expand All @@ -265,7 +265,7 @@ class AppTerminal extends Tonic {

window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
this.updated()
});
})

window.removeEventListener('resize', this.boundResizeEvent)
window.addEventListener('resize', this.boundResizeEvent)
Expand Down
2 changes: 1 addition & 1 deletion src/vm.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export async function init (options) {
.reduce((array, transfer) => array.concat(transfer), [])

port.postMessage({ method: 'console.debug', args }, { transfer })
},
}
})
}

Expand Down

0 comments on commit 83db1d5

Please sign in to comment.