Neutralino & new project structure

This commit is contained in:
dakedres 2023-12-23 17:03:28 -05:00
parent ebccf275a7
commit 4879f5a7cf
13 changed files with 159 additions and 10 deletions

11
.gitignore vendored
View File

@ -1,3 +1,10 @@
.temp/
.temp
.tmp
node_modules/
dist/
/index.html
/bin
/dist
/build
yarn-error.log
neutralinojs.log

54
build.js Normal file
View File

@ -0,0 +1,54 @@
// Usage: node build <platform> <[dev]/prod>
import Path from 'path'
import { copyFile } from 'fs/promises'
let [ platform, environment = 'dev' ] = process.argv.slice(2)
let projectRoot = Path.dirname(new URL(import.meta.url).pathname)
const indexTemplate = scripts => `\
<html>
<head>
<!-- <link rel="icon" href=".temp/editorapp/resources/icons/appIcon.png"> -->
${scripts.map(src => "<script async src=" + JSON.stringify(src) + "></script>").join('\n')}
<style id="stylesheet">
body { display: flex; flex-direction: column; margin: 0; height: 100vh; max-height: 100vh; font-size: 14px; }
nav { background: #f5f5f5; color: #6c6c6c; margin: 2px 5px }
nav input { all: unset; text-decoration: underline; font-family: sans-serif; }
.cm-editor { flex-grow: 1; outline: 1px solid #ddd; overflow-y: auto; }
</style>
</head>
</html>
`
let out
switch(environment) {
case 'dev':
out = indexTemplate([
Path.join('platforms', platform + '.js'),
'editor.js',
'build/libs.js'
])
break
case 'prod':
await copyFile(
Path.join(projectRoot, 'platforms', platform + '.js'),
Path.join(projectRoot, 'build', 'platform.js')
)
out = indexTemplate([
'platform.js',
'editor.js',
'libs.js'
])
break
}
process.stdout.write(out)

View File

@ -147,7 +147,7 @@ function App() {
}
},
{
key: 'Ctrl-n',
key: 'Ctrl-r',
run(state, event) {
event.preventDefault()
let mainSelection = self.editor.state.selection.main
@ -269,6 +269,7 @@ function ChildWindow(index) {
this.index = app.views.length
this.window = window.open('about:blank', '_blank')
console.log(this)
this.window.document.head.appendChild(document.getElementById('stylesheet').cloneNode(true))
this.editor = new $.EditorView({
state,

View File

@ -2,11 +2,13 @@
<head>
<script async src="./dist/libs.js"></script>
<script async src="./index.js"></script>
<!-- <link rel="icon" href=".temp/editorapp/resources/icons/appIcon.png"> -->
<script async src="platforms/neutralino.js"></script>
<script async src="editor.js"></script>
<script async src="build/libs.js"></script>
<style id="stylesheet">
body { display: flex; flex-direction: column; margin: 0; height: 100vh; max-height: 100vh; }
body { display: flex; flex-direction: column; margin: 0; height: 100vh; max-height: 100vh; font-size: 14px; }
nav { background: #f5f5f5; color: #6c6c6c; margin: 2px 5px }
nav input { all: unset; text-decoration: underline; font-family: sans-serif; }
.cm-editor { flex-grow: 1; outline: 1px solid #ddd; overflow-y: auto; }
@ -14,4 +16,4 @@ nav input { all: unset; text-decoration: underline; font-family: sans-serif; }
</head>
</html>
</html>

View File

@ -1,9 +1,9 @@
import nodeResolve from "@rollup/plugin-node-resolve";
export default {
input: "./libs.js",
input: "./index.js",
output: {
file: "./dist/libs.js",
file: "../build/libs.js",
name: '$',
format: "iife"
},

46
neutralino.config.json Normal file
View File

@ -0,0 +1,46 @@
{
"applicationId": "net.sys42.dakedres.editor",
"version": "1.0.0",
"defaultMode": "window",
"port": 0,
"documentRoot": "/",
"url": "/index.html",
"enableServer": true,
"enableNativeAPI": true,
"tokenSecurity": "one-time",
"logging": {
"enabled": true,
"writeToLogFile": true
},
"nativeAllowList": [
"app.*",
"os.*",
"debug.log"
],
"globalVariables": {},
"modes": {
"window": {
"title": "waw",
"width": 800,
"height": 500,
"minWidth": 400,
"minHeight": 200,
"fullScreen": false,
"alwaysOnTop": false,
"icon": "/resources/icon.png",
"enableInspector": false,
"borderless": false,
"maximize": false,
"hidden": false,
"resizable": true,
"exitProcessOnClose": true
}
},
"cli": {
"binaryName": "waw",
"resourcesPath": "/build/",
"clientLibrary": "/build/neutralino.js",
"binaryVersion": "4.14.1",
"clientVersion": "3.12.0"
}
}

4
notes.txt Normal file
View File

@ -0,0 +1,4 @@
# Deps
Needed to
```sudo apt install libsoup-2.4-dev libwebkit2gtk-4.0-dev libjavascriptcoregtk-4.0-dev```

View File

@ -4,9 +4,15 @@
"main": "index.js",
"license": "MIT",
"dependencies": {
"@neutralinojs/lib": "neutralinojs/neutralino.js",
"@neutralinojs/neu": "^10.1.0",
"@rollup/plugin-node-resolve": "^15.2.3",
"codemirror": "^6.0.1",
"rollup": "^4.9.1"
}
},
"scripts": {
"dev": "node build neutralino > index.html && neu run",
"build": "node build neutralino prod > index.html && neu build"
},
"type": "module"
}

22
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)
}
}

3
platforms/neutralino.js Normal file
View File

@ -0,0 +1,3 @@
function Platform() {
}

BIN
resources/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -85,6 +85,10 @@
dependencies:
"@lezer/common" "^1.0.0"
"@neutralinojs/lib@neutralinojs/neutralino.js":
version "3.13.0"
resolved "https://codeload.github.com/neutralinojs/neutralino.js/tar.gz/080900b7af3d79c6e387d213b437bdb62870f109"
"@neutralinojs/neu@^10.1.0":
version "10.1.0"
resolved "https://registry.yarnpkg.com/@neutralinojs/neu/-/neu-10.1.0.tgz#7c0fc2eaee14583651203309c9f653811df15499"