shithub: mycel

Download patch

ref: a231102ec04f3496c84ead02f463189e64342bc3
parent: f1749d6a57566ec4b0984df50c940762ac1d8db9
author: Philip Silva <philip.silva@protonmail.com>
date: Sat Mar 6 03:46:23 EST 2021

Exec6: configure plugins

--- a/domino/domino.go
+++ b/domino/domino.go
@@ -255,12 +255,14 @@
 	return
 }
 
-func (d *Domino) Exec6(script string) (res string, err error) {
+func (d *Domino) Exec6(script string, initial bool) (res string, err error) {
 	babel.Init(4) // Setup 4 transformers (can be any number > 0)
 	r, err := babel.Transform(strings.NewReader(script), map[string]interface{}{
 		"plugins": []string{
-			"transform-react-jsx",
 			"transform-es2015-block-scoping",
+			"transform-es2015-destructuring",
+			"transform-es2015-spread",
+			"transform-es2015-parameters",
 		},
 	})
 	if err != nil {
@@ -270,7 +272,7 @@
 	if err != nil {
 		return "", fmt.Errorf("read all: %v", err)
 	}
-	return d.Exec(string(buf), true)
+	return d.Exec(string(buf), initial)
 }
 
 // CloseDoc fires DOMContentLoaded to trigger $(document).ready(..)
--- a/domino/domino_test.go
+++ b/domino/domino_test.go
@@ -500,19 +500,23 @@
 	d := NewDomino(simpleHTML, nil,  nil)
 	d.Start()
 	script := `
-	console.log('Hello!!');
-	const numberOne = 1;
+	var foo = function(data={}) {}
+	var h = {
+		a: 1,
+		b: 11
+	};
+	var {a, b} = h;
 	`
-	_, err := d.Exec6(script)
+	_, err := d.Exec6(script, true)
 	if err != nil {
 		t.Fatalf("%v", err)
 	}
-	res, err := d.Exec("numberOne+1", false)
+	res, err := d.Exec("a+b", false)
 	t.Logf("res=%v", res)
 	if err != nil {
 		t.Fatalf("%v", err)
 	}
-	if res != "2" {
+	if res != "12" {
 		t.Fatal()
 	}
 	d.Stop()
--- a/domino/domintf.js
+++ b/domino/domintf.js
@@ -11,6 +11,9 @@
 addEventListener = function() {};
 removeEventListener = function() {};
 window.location.href = 'http://example.com';
+window.history = {
+	replaceState: function() {}
+};
 
 var ___fq;
 ___fq = function(pre, el) {