File tree 5 files changed +45
-6
lines changed
5 files changed +45
-6
lines changed Original file line number Diff line number Diff line change @@ -4,4 +4,4 @@ source "https://rubygems.org"
4
4
5
5
gem "js" , "~> 2.5" unless ENV [ "JS" ] == "false"
6
6
gem "ruby_wasm" , "~> 2.5"
7
- gem "ruby-next" , "~> 1.0"
7
+ gem "ruby-next" , "~> 1.0.3 "
Original file line number Diff line number Diff line change 5
5
diff-lcs (1.5.1 )
6
6
js (2.5.0 )
7
7
paco (0.2.3 )
8
- parser (3.3.0.5 )
8
+ parser (3.3.1.0 )
9
9
ast (~> 2.4.1 )
10
10
racc
11
11
racc (1.7.3 )
12
12
require-hooks (0.2.2 )
13
- ruby-next (1.0.2 )
13
+ ruby-next (1.0.3 )
14
14
paco (~> 0.2 )
15
15
require-hooks (~> 0.2 )
16
- ruby-next-core (= 1.0.2 )
16
+ ruby-next-core (= 1.0.3 )
17
17
ruby-next-parser (>= 3.2.2.0 )
18
18
unparser (~> 0.6.0 )
19
- ruby-next-core (1.0.2 )
19
+ ruby-next-core (1.0.3 )
20
20
ruby-next-parser (3.2.2.0 )
21
21
parser (>= 3.0.3.1 )
22
22
ruby_wasm (2.5.0 )
@@ -35,7 +35,7 @@ PLATFORMS
35
35
36
36
DEPENDENCIES
37
37
js (~> 2.5 )
38
- ruby-next (~> 1.0 )
38
+ ruby-next (~> 1.0.3 )
39
39
ruby_wasm (~> 2.5 )
40
40
41
41
BUNDLED WITH
Original file line number Diff line number Diff line change @@ -103,6 +103,22 @@ export default class App {
103
103
this . showEditor ( "outputEditor" ) ;
104
104
} ) ;
105
105
106
+ this . autorunCb = document . getElementById ( "autorun" ) ;
107
+ let refreshDebounceId ;
108
+
109
+ this . codeEditor . onDidChangeModelContent ( ( ev ) => {
110
+ if ( ! this . autorunCb . checked ) return ;
111
+
112
+ if ( refreshDebounceId ) {
113
+ clearTimeout ( refreshDebounceId ) ;
114
+ }
115
+
116
+ refreshDebounceId = setTimeout ( ( ) => {
117
+ this . refresh ( ) ;
118
+ refreshDebounceId = undefined ;
119
+ } , 500 ) ;
120
+ } ) ;
121
+
106
122
this . el . addEventListener ( "change" , this . onSelectEditor ) ;
107
123
108
124
this . versionSelect = document . getElementById ( "versionSelect" ) ;
@@ -197,6 +213,23 @@ export default class App {
197
213
this . loadExampleFromUrl ( ) ;
198
214
}
199
215
216
+ refresh ( ) {
217
+ let newSource ;
218
+ try {
219
+ newSource = this . transpile ( this . codeEditor . getValue ( ) , { raise : true } ) ;
220
+ } catch ( e ) {
221
+ return ;
222
+ }
223
+
224
+ this . previewEditor . setValue ( newSource ) ;
225
+
226
+ let { result, output } = this . executeWithOutput ( newSource ) ;
227
+
228
+ if ( result ) output += "\n\n> " + result ;
229
+
230
+ this . outputEditor . setValue ( output ) ;
231
+ }
232
+
200
233
transpile ( code , opts = { } ) {
201
234
let rubyOptions = "{" ;
202
235
@@ -218,6 +251,10 @@ export default class App {
218
251
219
252
return result ;
220
253
} catch ( e ) {
254
+ if ( opts . raise ) {
255
+ throw e ;
256
+ }
257
+
221
258
console . error ( e ) ;
222
259
return e . message ;
223
260
}
Original file line number Diff line number Diff line change @@ -72,6 +72,7 @@ <h1 class="text-2xl">Playground</h1>
72
72
< span > Run</ span >
73
73
</ span >
74
74
</ sl-button >
75
+ < sl-checkbox id ="autorun "> Auto</ sl-checkbox >
75
76
</ div >
76
77
< div class ="flex flex-row space-x-2 justify-center items-center px-2 mr-4 ">
77
78
< a href ="https://github.com/ruby-next/ruby-next " target ="_blank " class ="flex flex-row items-center space-x-1 hover:opacity-75 cursor-pointer ">
Original file line number Diff line number Diff line change @@ -8,3 +8,4 @@ import "@shoelace-style/shoelace/dist/components/dialog/dialog.js";
8
8
import "@shoelace-style/shoelace/dist/components/icon/icon.js" ;
9
9
import "@shoelace-style/shoelace/dist/components/button/button.js" ;
10
10
import "@shoelace-style/shoelace/dist/components/input/input.js" ;
11
+ import "@shoelace-style/shoelace/dist/components/checkbox/checkbox.js" ;
You can’t perform that action at this time.
0 commit comments