Qwe is born

This commit is contained in:
2023-12-24 22:49:54 -05:00
parent 4879f5a7cf
commit eb0077c849
20 changed files with 512 additions and 354 deletions

43
lib/codemirror.js Normal file
View File

@@ -0,0 +1,43 @@
import { EditorState, Compartment, Transaction, Annotation } from '@codemirror/state'
import { indentWithTab, undo, redo, history, defaultKeymap, historyKeymap } from '@codemirror/commands'
import { EditorView, lineNumbers, highlightActiveLineGutter, highlightSpecialChars, drawSelection, dropCursor, rectangularSelection, crosshairCursor, highlightActiveLine, keymap } from '@codemirror/view'
import { foldGutter, indentOnInput, syntaxHighlighting, defaultHighlightStyle, bracketMatching, foldKeymap } from '@codemirror/language'
import { highlightSelectionMatches, searchKeymap } from '@codemirror/search'
import { closeBrackets, autocompletion, closeBracketsKeymap, completionKeymap } from '@codemirror/autocomplete'
import { lintKeymap } from '@codemirror/lint'
export default {
EditorView,
Compartment,
EditorState,
keymap,
indentWithTab,
lineNumbers,
highlightActiveLineGutter,
highlightSpecialChars,
history,
foldGutter,
drawSelection,
dropCursor,
indentOnInput,
syntaxHighlighting,
bracketMatching,
closeBrackets,
autocompletion,
rectangularSelection,
crosshairCursor,
highlightActiveLine,
highlightSelectionMatches,
closeBracketsKeymap,
defaultKeymap,
searchKeymap,
historyKeymap,
foldKeymap,
completionKeymap,
lintKeymap,
undo,
redo,
Transaction,
Annotation,
defaultHighlightStyle
}

2
lib/lang/javascript.js Normal file
View File

@@ -0,0 +1,2 @@
import * as m from '@codemirror/lang-javascript'
export default m

2
lib/lang/markdown.js Normal file
View File

@@ -0,0 +1,2 @@
import * as m from '@codemirror/lang-markdown'
export default m

22
lib/platforms/browser.js Normal file
View File

@@ -0,0 +1,22 @@
function Platform() {
this.save = async (path, data) => {
localStorage.setItem(path, data)
}
this.open = (path) => {
return localStorage.getItem(path)
}
this.readdir = (path) => {
return Object.keys(localStorage)
.filter(key => key.startsWith(path))
}
this.createWindow = url => {
return window.open(url ?? 'about:blank', '_blank')
}
this.createInstance = url => {
return window.open(url ?? this.location)
}
}

View File

@@ -0,0 +1,33 @@
export default {
async access(path) {
try {
await Neutralino.filesystem.getStats(path)
return
} catch(err) {
if(err.name = 'NE_FS_NOPATHE') {
return false
} else {
throw err
}
}
},
dirname(path) {
let index = path.lastIndexOf('/')
return index === -1 ? '' : path.slice(0, index)
},
filename(path) {
let index = path.lastIndexOf('/')
return index === -1 ? path : path.slice(index + 1)
},
ext(path) {
let filename = this.filename(path)
let index = filename.lastIndexOf('.')
return index === -1 ? '' : path.slice(index + 1)
}
}

48
lib/rollup.config.mjs Normal file
View File

@@ -0,0 +1,48 @@
import nodeResolve from "@rollup/plugin-node-resolve";
import Path, { format } from 'path'
import FS from 'fs'
let plugins = [
nodeResolve()
]
let targetDir = '../src/lib'
const dirname = Path.dirname(new URL(import.meta.url).pathname)
let langDir = Path.join(dirname, 'lang')
export default [
{
input: [
'./codemirror.js',
...FS.readdirSync(langDir, { withFileTypes: true })
.filter(dirent => dirent.isFile() && dirent.name.endsWith('.js'))
.map(dirent => Path.join(langDir, dirent.name))
],
output: {
dir: targetDir,
format: "es"
},
plugins
},
// ...FS.readdirSync(langDir, { withFileTypes: true })
// .filter(dirent => dirent.isFile() && dirent.name.endsWith('.js'))
// .map(dirent => ({
// input: Path.join(langDir, dirent.name),
// external: [
// '@codemirror/state',
// '@codemirror/commands',
// '@codemirror/view',
// '@codemirror/language',
// '@codemirror/search',
// '@codemirror/autocomplete',
// '@codemirror/lint'
// ],
// output: {
// file: Path.join(targetDir, dirent.name),
// format: "es",
// globals
// },
// plugins
// }))
]