Skip to content

Commit

Permalink
remove js scripting
Browse files Browse the repository at this point in the history
  • Loading branch information
Nimaoth committed Jan 4, 2024
1 parent 0ed005e commit 24ada1c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 83 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ Absytree supports different scripting languages/mechanisms. The editor API is ex
At startup Absytree loads the following scripts in order:
- `config/absytree_config_wasm.wasm`
- `config/absytree_config_wasm.nim` (NimScript, only in desktop version)
- `config/absytree_config.js` (Only in browser version)


At the moment `config/absytree_config_wasm.wasm` is generated from `config/absytree_config_wasm.nim` by compiling it to wasm using `config/config.nims` (uses Emscripten). So `absytree_config_wasm.nim` can be used as NimScript or as wasm plugin.
Expand Down
14 changes: 4 additions & 10 deletions src/app.nim
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import input, events, document, document_editor, popup, dispatch_tables, theme,

when not defined(js):
import scripting/scripting_nim
else:
import scripting/scripting_js

import scripting/scripting_wasm

Expand Down Expand Up @@ -604,9 +602,7 @@ proc initScripting(self: App) {.async.} =
if path.hasPrefix("app://", rest):
path = fs.getApplicationFilePath(rest)

when defined(js):
self.scriptContext = new ScriptContextJs
else:
when not defined(js):
self.scriptContext = await createScriptContext("./config/absytree_config.nim", searchPaths)

withScriptContext self, self.scriptContext:
Expand Down Expand Up @@ -1489,7 +1485,7 @@ proc setGithubAccessToken*(self: App, token: string) {.expose("editor").} =
proc reloadConfig*(self: App) {.expose("editor").} =
defer:
self.platform.requestRender()
if self.scriptContext.isNil.not:
if self.scriptContext.isNotNil:
try:
self.scriptContext.reload()
if not self.initializeCalled:
Expand Down Expand Up @@ -1708,10 +1704,8 @@ else:
return getActiveEditor()

proc loadCurrentConfig*(self: App) {.expose("editor").} =
## Javascript backend only!
## Opens the config file in a new view.
when defined(js):
discard self.createAndAddView(newTextDocument(self.asConfigProvider, "./config/absytree_config.js", fs.loadApplicationFile("./config/absytree_config.js"), true))
## Opens the default config file in a new view.
discard self.createAndAddView(newTextDocument(self.asConfigProvider, "./config/absytree_config.nim", fs.loadApplicationFile("./config/absytree_config.nim"), true))

proc logRootNode*(self: App) {.expose("editor").} =
let str = self.platform.builder.root.dump(true)
Expand Down
71 changes: 0 additions & 71 deletions src/scripting/scripting_js.nim

This file was deleted.

2 changes: 1 addition & 1 deletion src/scripting/scripting_nim.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
when defined(js):
{.error: "scripting_nim.nim does not work in js backend. Use scripting_js.nim instead.".}
{.error: "scripting_nim.nim does not work in js backend.".}

import std/[os, osproc, tables, strformat, json, strutils, macrocache, macros, genasts, sugar]
from logging import nil
Expand Down

0 comments on commit 24ada1c

Please sign in to comment.