add jsdom to KissConfig

This commit is contained in:
2022-03-23 14:17:45 -06:00
parent 35782287d5
commit ae45fb3e74
5 changed files with 22 additions and 1 deletions

View File

@@ -15,6 +15,7 @@ import sys.FileSystem;
import ktxt2.KTxt2;
import re_flex.R;
import kiss_tools.KeyShortcutHandler;
import JSDomExterns;
using haxe.io.Path;
using StringTools;

View File

@@ -249,4 +249,10 @@
(#unless test
(var :Array<KTxt2Conversion> conversions [])
(function registerConversion [:KTxt2Conversion conversion] (conversions.push conversion)))
(function registerConversion [:KTxt2Conversion conversion] (conversions.push conversion)))
(function quickWebview []
(let [dom (new JSDOM "<!DOCTYPE html><p>Hello world</p>")
document dom.window.document]
document))

View File

@@ -0,0 +1,11 @@
import js.html.Document;
typedef JSDOMWindow = {
document:Document
};
@:jsRequire("jsdom")
extern class JSDOM {
function new(html:String);
var window:JSDOMWindow;
}

View File

@@ -100,6 +100,8 @@
// install all of the user's Node dependencies:
(when (FileSystem.exists (joinPath activeConfigDir "package.json"))
(npmSafeTrySpawnSync ["npm" "install"] handleConfigFailure))
// install built-in node dependencies:
(npmSafeTrySpawnSync ["npm" "install" "jsdom"] handleConfigFailure)
// Run the haxe compiler:
(trySpawnSync "haxe" ["build.hxml"] (object cwd activeConfigDir) handleConfigFailure)

View File

@@ -114,6 +114,7 @@
(openFile dirOrFile)))))))
// This has to be a macro so it can return from tryLoadConfig
// TODO this macro should use gensyms
(defMacro trySpawnSync [command args options onError]
`(let [command ,command
args ,args