Thought cabinet

This commit is contained in:
2024-12-11 19:21:57 -07:00
parent 50acba5cdb
commit bb6662d7b1
41 changed files with 32477 additions and 2338 deletions

File diff suppressed because one or more lines are too long

View File

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

View File

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

View File

@@ -1,22 +0,0 @@
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

@@ -1,125 +0,0 @@
{
let userHome
const handleNeutralinoError = err => {
throw new Error(err.code + ': ' + err.message)
}
const mapDirent = ({ entry, type }) => ({
name: entry,
type
})
window.Platform = {
//
// Paths
//
dirname(path) {
let normalPath = this.normalize(path)
let index = normalPath.lastIndexOf('/')
return index === -1 ? '' : normalPath.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 ? '' : filename.slice(index + 1)
},
join(...args) {
let parts = []
for(let arg of args) {
parts = parts.concat(arg.split('/'))
}
return this.normalizePathFromParts(parts)
},
// TODO: support non-posix
absolute(path) {
return path.charAt(0) === '/'
},
normalize(path) {
return this.normalizePathFromParts(path.split('/'))
},
normalizePathFromParts(parts) {
// let newPath = path !== '/' && path.endsWith('/') ?
// path.slice(0, -1) :
// path
let out = []
let skips = 0
for(let i = parts.length - 1; i >= 0; i--) {
let part = parts[i]
if(part.length == 0 || part === '.') {
continue
} else if(part == '..') {
skips++
continue
} else if(skips == 0) {
out.unshift(part)
} else {
skips--
}
}
return '/' + out.join('/')
},
//
// FS
//
async access(path) {
try {
await Neutralino.filesystem.getStats(path)
return
} catch(err) {
if(err.name = 'NE_FS_NOPATHE') {
return false
} else {
throw err
}
}
},
writeText(path, content) {
return Neutralino.filesystem.writeFile(path, content)
.catch(handleNeutralinoError)
},
readText(path) {
return Neutralino.filesystem.readFile(path)
.catch(handleNeutralinoError)
},
readdir(path) {
return Neutralino.filesystem.readDirectory(path)
.catch(handleNeutralinoError)
.then(dirents => dirents.map(mapDirent))
},
//
// OS
//
async getHome() {
return userHome ?? (userHome = await Neutralino.os.getEnv('HOME'))
},
}
}

View File

@@ -1,48 +0,0 @@
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
// }))
]