Run kiss code, provide monaco editor
This commit is contained in:
@@ -11,4 +11,4 @@
|
||||
|
||||
--main kiss_web_pad.Background
|
||||
--js bin/background.js
|
||||
-cmd cp node_modules/webextension-polyfill/dist/browser-polyfill.js* bin/ && zip -r kiss_web_pad.zip . -x *.git* -x *.hxml -x *.zip -x src/\* -x node_modules/\* -x libs/\* -x test.sh -x externs/\*
|
||||
-cmd cp -r node_modules/monaco-editor/min/vs bin/ && cp node_modules/webextension-polyfill/dist/browser-polyfill.js* bin/ && zip -r kiss_web_pad.zip . -x *.git* -x *.hxml -x *.zip -x src/\* -x node_modules/\* -x libs/\* -x test.sh -x externs/\*
|
||||
@@ -1,4 +1,4 @@
|
||||
# @install: lix --silent download "git:https://k7izh9.gitea.cloud/kiss-lang/kiss-firefox#4d5083e35e75de76282f40240c21080693235e38" into kiss-firefox/0.0.0/git/4d5083e35e75de76282f40240c21080693235e38
|
||||
# @install: lix --silent download "git:https://k7izh9.gitea.cloud/kiss-lang/kiss-firefox#902237de15ba614e223b40aa0e60ab999e287b91" into kiss-firefox/0.0.0/git/902237de15ba614e223b40aa0e60ab999e287b91
|
||||
-lib kiss
|
||||
-cp ${HAXE_LIBCACHE}/kiss-firefox/0.0.0/git/4d5083e35e75de76282f40240c21080693235e38/src/
|
||||
-cp ${HAXE_LIBCACHE}/kiss-firefox/0.0.0/git/902237de15ba614e223b40aa0e60ab999e287b91/src/
|
||||
-D kiss-firefox=0.0.0
|
||||
@@ -1,12 +1,12 @@
|
||||
# @install: lix --silent download "git:https://k7izh9.gitea.cloud/kiss-lang/kiss#de540e239a7b5b47e45ad618fa2f7a5be3820692" into kiss/0.0.1/git/de540e239a7b5b47e45ad618fa2f7a5be3820692
|
||||
# @run: haxelib run-dir kiss "${HAXE_LIBCACHE}/kiss/0.0.1/git/de540e239a7b5b47e45ad618fa2f7a5be3820692"
|
||||
# @install: lix --silent download "git:https://k7izh9.gitea.cloud/kiss-lang/kiss#050a5fbf66bbbb161e4ba5a0cab82594873d84a1" into kiss/0.0.1/git/050a5fbf66bbbb161e4ba5a0cab82594873d84a1
|
||||
# @run: haxelib run-dir kiss "${HAXE_LIBCACHE}/kiss/0.0.1/git/050a5fbf66bbbb161e4ba5a0cab82594873d84a1"
|
||||
-lib haxe-strings
|
||||
-lib hscript
|
||||
-lib tink_json
|
||||
-lib tink_macro
|
||||
-lib tink_syntaxhub
|
||||
-lib uuid
|
||||
-cp ${HAXE_LIBCACHE}/kiss/0.0.1/git/de540e239a7b5b47e45ad618fa2f7a5be3820692/src
|
||||
-cp ${HAXE_LIBCACHE}/kiss/0.0.1/git/050a5fbf66bbbb161e4ba5a0cab82594873d84a1/src
|
||||
-D kiss=0.0.1
|
||||
-w -WUnusedPattern
|
||||
--macro kiss.KissFrontend.use()
|
||||
@@ -14,6 +14,11 @@
|
||||
{
|
||||
"js": [
|
||||
"bin/browser-polyfill.js",
|
||||
"require.js",
|
||||
"bin/vs/loader.js",
|
||||
"bin/vs/editor/editor.main.nls.js",
|
||||
"bin/vs/editor/editor.main.js",
|
||||
"require-monaco.js",
|
||||
"bin/main.js"
|
||||
],
|
||||
"matches": [
|
||||
|
||||
6
package-lock.json
generated
6
package-lock.json
generated
@@ -10,6 +10,7 @@
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
"@types/webextension-polyfill": "^0.10.0",
|
||||
"monaco-editor": "^0.50.0",
|
||||
"webextension-polyfill": "^0.10.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -33,6 +34,11 @@
|
||||
"dts2hx": "cli.js"
|
||||
}
|
||||
},
|
||||
"node_modules/monaco-editor": {
|
||||
"version": "0.50.0",
|
||||
"resolved": "https://registry.npmjs.org/monaco-editor/-/monaco-editor-0.50.0.tgz",
|
||||
"integrity": "sha512-8CclLCmrRRh+sul7C08BmPBP3P8wVWfBHomsTcndxg5NRCEPfu/mc2AGU8k37ajjDVXcXFc12ORAMUkmk+lkFA=="
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "3.7.4",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.4.tgz",
|
||||
|
||||
@@ -3,8 +3,9 @@
|
||||
"name": "kiss-web-pad",
|
||||
"description": "keep notes (and kiss scripts) tied to web urls",
|
||||
"dependencies": {
|
||||
"webextension-polyfill": "^0.10.0",
|
||||
"@types/webextension-polyfill": "^0.10.0"
|
||||
"@types/webextension-polyfill": "^0.10.0",
|
||||
"monaco-editor": "^0.50.0",
|
||||
"webextension-polyfill": "^0.10.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"dts2hx": "^0.19.0"
|
||||
@@ -13,4 +14,4 @@
|
||||
"scripts": {
|
||||
"postinstall": "dts2hx --all --noLibWrap"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
3
require-monaco.js
Normal file
3
require-monaco.js
Normal file
@@ -0,0 +1,3 @@
|
||||
require(['vs/editor/editor.main'], function (){
|
||||
window.monaco = monaco;
|
||||
});
|
||||
1
require.js
Normal file
1
require.js
Normal file
@@ -0,0 +1 @@
|
||||
var require = { paths: { 'vs': browser.runtime.getURL('bin/vs') } };
|
||||
25
src/kiss_web_pad/KissWebPadInterp.hx
Normal file
25
src/kiss_web_pad/KissWebPadInterp.hx
Normal file
@@ -0,0 +1,25 @@
|
||||
package kiss_web_pad;
|
||||
|
||||
import kiss.Prelude;
|
||||
import kiss.Stream;
|
||||
import kiss.Reader;
|
||||
|
||||
using StringTools;
|
||||
using hx.strings.Strings;
|
||||
|
||||
@:build(kiss.KissInterp2.build())
|
||||
class KissWebPadInterp {
|
||||
function new() {
|
||||
globals["XMLHttpRequest"] = js.html.XMLHttpRequest;
|
||||
globals["XHR"] = js.html.XMLHttpRequest;
|
||||
// Convenience:
|
||||
globals["GET"] = function (url, cc) {
|
||||
var xhr = new js.html.XMLHttpRequest();
|
||||
xhr.open("GET", url);
|
||||
xhr.addEventListener("load", function (_) {
|
||||
cc(xhr.response);
|
||||
});
|
||||
xhr.send();
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,10 @@
|
||||
package kiss_web_pad;
|
||||
|
||||
@:native("window")
|
||||
extern class Monaco {
|
||||
static var monaco:Dynamic;
|
||||
}
|
||||
|
||||
class Main {
|
||||
static function main() {
|
||||
Main_.main();
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
(var &mut :Dynamic div)
|
||||
(var &mut showing false)
|
||||
|
||||
|
||||
|
||||
// on message from the button action, open the web pad
|
||||
(onMessage "openPad" [pad]
|
||||
(unless div
|
||||
@@ -18,18 +20,30 @@
|
||||
<label for=\"lang\">Language:</label><br>
|
||||
<input type=\"text\" id=\"lang\" name=\"lang\" value=\"${pad.language}\">
|
||||
|
||||
<!-- TODO This should be a Monaco editor! -->
|
||||
<textarea id=\"content\" name=\"content\" rows=\"20\" cols=\"80\">${pad.content}</textarea><br>
|
||||
<!-- This will hold a Monaco editor! -->
|
||||
<div id=\"content\" style=\"width: 80ch; height: 30em;\" ></div><br>
|
||||
|
||||
<input type=\"button\" value=\"Save\" />
|
||||
<input id=\"launchBtn\" type=\"button\" value=\"Launch\" />
|
||||
<input id=\"saveBtn\" type=\"button\" value=\"Save\" />
|
||||
|
||||
</form>")
|
||||
(timeoutUntil 100 ($>elem document.getElementById "kiss-web-pad")
|
||||
(.addEventListener ($elem "kiss-web-pad") "click"
|
||||
(timeoutUntil 100 (and Main.Monaco.monaco ($>elem document.getElementById "kiss-web-pad"))
|
||||
(localVar editor (Main.Monaco.monaco.editor.create (document.getElementById "content")
|
||||
(object
|
||||
theme "vs-dark"
|
||||
value pad.content
|
||||
language "lisp")))
|
||||
(.addEventListener ($elem "saveBtn") "click"
|
||||
->e (sendMessage "savePad" [(object
|
||||
id pad.id
|
||||
urlPattern .value ($elem "pattern")
|
||||
language .value ($elem "lang")
|
||||
content .value ($elem "content"))]))))
|
||||
content (editor.getValue))]))
|
||||
(.addEventListener ($elem "launchBtn") "click"
|
||||
->e (let [interp (new KissWebPadInterp)]
|
||||
(dictSet interp.globals "document" document)
|
||||
(dictSet interp.globals "window" window)
|
||||
(interp.evalCC (editor.getValue) ->:Void v (print v))))))
|
||||
(if showing
|
||||
(document.body.removeChild div)
|
||||
(document.body.appendChild div))
|
||||
|
||||
Reference in New Issue
Block a user