flok 0.0.40 → 0.0.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/drivers/chrome/src/dispatch.js +7 -2
- data/app/kern/dispatch.js +10 -1
- data/app/kern/mod/event.js +9 -0
- data/app/kern/pagers/pg_mem.js +21 -0
- data/app/kern/pagers/pg_net_sim.js +44 -0
- data/app/kern/pagers/pg_spec.js +23 -0
- data/app/kern/services/vm.rb +60 -64
- data/bin/flok +44 -23
- data/docs/callout.md +1 -1
- data/docs/client_api.md +5 -2
- data/docs/config_yml.md +41 -0
- data/docs/controllers.md +4 -0
- data/docs/datatypes.md +5 -2
- data/docs/debug_server.md +2 -0
- data/docs/dispatch.md +8 -3
- data/docs/known_issues.md +6 -0
- data/docs/mod/event.md +25 -20
- data/docs/mod/persist.md +1 -1
- data/docs/mod/speech.md +12 -0
- data/docs/project.md +2 -2
- data/docs/services/vm.md +46 -17
- data/docs/services/vm/pagers.md +22 -2
- data/lib/flok/build.rb +0 -4
- data/lib/flok/user_compiler.rb +123 -47
- data/lib/flok/user_compiler_templates/ctable.js.erb +39 -1
- data/lib/flok/version.rb +1 -1
- data/spec/env/global.rb +1 -0
- data/spec/env/kern.rb +5 -1
- data/spec/etc/cli_spec.rb +337 -322
- data/spec/etc/service_compiler/config0.rb +1 -1
- data/spec/etc/service_compiler/config0b.rb +1 -0
- data/spec/etc/services_compiler_spec.rb +29 -29
- data/spec/etc/user_compiler/controller0b.rb +9 -0
- data/spec/etc/user_compiler/controller0timer.rb +16 -0
- data/spec/etc/user_compiler_spec.rb +24 -1
- data/spec/iface/driver/dispatch_spec.rb +8 -2
- data/spec/iface/driver/persist_spec.rb +11 -0
- data/spec/kern/assets/controller0defer.rb +18 -0
- data/spec/kern/assets/controller0defer0.rb +13 -0
- data/spec/kern/assets/controller0defer2.rb +17 -0
- data/spec/kern/assets/global_on_entry.rb +8 -0
- data/spec/kern/assets/global_on_entry2.rb +16 -0
- data/spec/kern/assets/global_on_entry3.rb +17 -0
- data/spec/kern/assets/global_on_entry4.rb +12 -0
- data/spec/kern/assets/interval.rb +29 -0
- data/spec/kern/assets/interval2.rb +33 -0
- data/spec/kern/assets/interval3.rb +39 -0
- data/spec/kern/assets/service1.rb +4 -1
- data/spec/kern/assets/service_controller1.rb +11 -0
- data/spec/kern/assets/specimin/controller0.rb +74 -0
- data/spec/kern/assets/vm/config5.rb +20 -0
- data/spec/kern/assets/vm/config6.rb +20 -0
- data/spec/kern/assets/vm/controller10.rb +1 -1
- data/spec/kern/assets/vm/controller11.rb +1 -1
- data/spec/kern/assets/vm/controller12.rb +1 -1
- data/spec/kern/assets/vm/controller13.rb +1 -1
- data/spec/kern/assets/vm/controller16b.rb +28 -0
- data/spec/kern/assets/vm/controller18.rb +1 -1
- data/spec/kern/assets/vm/controller21.rb +1 -1
- data/spec/kern/assets/vm/controller22.rb +8 -0
- data/spec/kern/assets/vm/controller_exc_ewatch.rb +1 -0
- data/spec/kern/assets/vm/controller_exc_ewatch2.rb +30 -0
- data/spec/kern/assets/vm/controller_exc_ewatch3.rb +16 -0
- data/spec/kern/assets/vm/controller_exc_ewatch4.rb +16 -0
- data/spec/kern/assets/vm/macros/copy_page_c.rb +1 -0
- data/spec/kern/assets/vm/macros/copy_page_ch.rb +25 -0
- data/spec/kern/assets/vm/macros/entry_del_c.rb +1 -0
- data/spec/kern/assets/vm/macros/entry_del_ch.rb +20 -0
- data/spec/kern/assets/vm/macros/entry_insert_c.rb +1 -0
- data/spec/kern/assets/vm/macros/entry_insert_ch.rb +23 -0
- data/spec/kern/assets/vm/macros/entry_mutable_c.rb +8 -7
- data/spec/kern/assets/vm/macros/entry_mutable_ch.rb +34 -0
- data/spec/kern/assets/vm/macros/new_page_c.rb +1 -1
- data/spec/kern/assets/vm/macros/new_page_c2.rb +1 -1
- data/spec/kern/assets/vm/macros/new_page_ch.rb +7 -0
- data/spec/kern/assets/vm/pg_mem/config.rb +10 -0
- data/spec/kern/assets/vm/pg_mem/config1.rb +10 -0
- data/spec/kern/assets/vm/pg_mem/config2.rb +10 -0
- data/spec/kern/assets/vm/pg_mem/config3.rb +15 -0
- data/spec/kern/assets/vm/pg_mem/write.rb +23 -0
- data/spec/kern/assets/vm/pg_mem/write2.rb +38 -0
- data/spec/kern/assets/vm/pg_net_sim/config.rb +10 -0
- data/spec/kern/assets/vm/pg_net_sim/nothing.rb +12 -0
- data/spec/kern/assets/vm/pg_net_sim/pages.json +1 -0
- data/spec/kern/assets/vm/pg_net_sim/watch.rb +18 -0
- data/spec/kern/callout_spec.rb +1 -1
- data/spec/kern/controller_macro_spec.rb +153 -20
- data/spec/kern/controller_spec.rb +232 -1
- data/spec/kern/debug_ui_spec.rb +235 -235
- data/spec/kern/event_spec.rb +112 -0
- data/spec/kern/service_controller_spec.rb +14 -2
- data/spec/kern/vm_service_mem_pagers_spec.rb +117 -0
- data/spec/kern/vm_service_net_sim_pager_spec.rb +97 -0
- data/spec/kern/vm_service_spec.rb +304 -17
- data/spec/kern/vm_service_spec2.rb +39 -0
- metadata +88 -6
- data/app/kern/pagers/mem_pager.js +0 -2
- data/app/kern/pagers/pg_spec0.js +0 -20
- data/lib/flok/project_template/Guardfile +0 -7
- data/lib/flok/project_template/config/config.yml +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
service_instance :
|
|
1
|
+
service_instance :my_service, :test
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
service_instance :test, :my_service
|
|
@@ -21,46 +21,46 @@ RSpec.describe "lib/services_compiler" do
|
|
|
21
21
|
end
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
it "Does fail to compile a controller with a non-existant type" do
|
|
25
|
+
expect { compile "service_bad_type" }.to raise_exception
|
|
26
|
+
end
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
it "Can call compile method and get a copy of all the functions" do
|
|
29
|
+
ctx, _ = compile "service0", "config0b"
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
#on_wakeup
|
|
32
|
+
res = ctx.eval("test_on_wakeup")
|
|
33
|
+
expect(res).not_to eq(nil)
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
#on_sleep
|
|
36
|
+
res = ctx.eval("test_on_sleep")
|
|
37
|
+
expect(res).not_to eq(nil)
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
#on_connect
|
|
40
|
+
res = ctx.eval("test_on_connect");
|
|
41
|
+
expect(res).not_to eq(nil)
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
#on_disconnect
|
|
44
|
+
res = ctx.eval("test_on_disconnect")
|
|
45
|
+
expect(res).not_to eq(nil)
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
#on_event
|
|
48
|
+
res = ctx.eval("test_on_hello");
|
|
49
|
+
expect(res).not_to eq(nil)
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
#on_handle_timer_events
|
|
52
|
+
res = ctx.eval("test_handle_timer_events");
|
|
53
|
+
expect(res).not_to eq(nil)
|
|
54
|
+
end
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
it "Can call compile method with options" do
|
|
57
|
+
ctx, js = compile "service1", "config2"
|
|
58
|
+
expect(js).to include("23rntoheuh3nthoeunthn23th");
|
|
59
|
+
end
|
|
60
60
|
|
|
61
61
|
#If SEND works, then all kernel macros should work
|
|
62
62
|
it "Can compile with a SEND macro" do
|
|
63
|
-
ctx, src = compile "service3", "
|
|
63
|
+
ctx, src = compile "service3", "config0b"
|
|
64
64
|
|
|
65
65
|
expect(src).not_to include("SEND")
|
|
66
66
|
expect(src).to include("_q.push")
|
|
@@ -46,13 +46,28 @@ RSpec.describe "User compiler" do
|
|
|
46
46
|
expect(actions).not_to eq(nil)
|
|
47
47
|
end
|
|
48
48
|
|
|
49
|
-
|
|
50
49
|
it "Can compile a controller with an action that contains an on_entry" do
|
|
51
50
|
ctx = compile "controller0"
|
|
52
51
|
on_entry = ctx.eval "ctable.my_controller.actions.my_action.on_entry"
|
|
53
52
|
expect(on_entry).not_to eq(nil)
|
|
54
53
|
end
|
|
55
54
|
|
|
55
|
+
it "Can compile a controller with an action that does not contains an on_entry" do
|
|
56
|
+
ctx = compile "controller0b"
|
|
57
|
+
on_entry = ctx.eval "ctable.my_controller.actions.my_action.on_entry"
|
|
58
|
+
expect(on_entry).not_to eq(nil)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it "on_entry controller has more code than non on_entry controller" do
|
|
62
|
+
ctx = compile "controller0"
|
|
63
|
+
on_entry = ctx.eval "ctable.my_controller.actions.my_action.on_entry"
|
|
64
|
+
|
|
65
|
+
ctx2 = compile "controller0b"
|
|
66
|
+
on_entry2 = ctx2.eval "ctable.my_controller.actions.my_action.on_entry"
|
|
67
|
+
expect(on_entry2.to_s.length).to be < on_entry.to_s.length
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
|
|
56
71
|
it "Can compile a controller with an action that contains the name" do
|
|
57
72
|
ctx = compile "controller0"
|
|
58
73
|
on_entry = ctx.eval "ctable.my_controller.name"
|
|
@@ -72,4 +87,12 @@ RSpec.describe "User compiler" do
|
|
|
72
87
|
expect(spot_names).to include "world"
|
|
73
88
|
expect(spot_names).to include "main" #Should be added by default
|
|
74
89
|
end
|
|
90
|
+
|
|
91
|
+
it "Can compile a controller with an action containing a timer and set the appropriate every_handlers key" do
|
|
92
|
+
ctx = compile "controller0timer"
|
|
93
|
+
|
|
94
|
+
function_names = JSON.parse(ctx.eval "JSON.stringify(Object.keys(ctable.my_controller.actions.my_action.handlers))")
|
|
95
|
+
expect(function_names).to include("hello")
|
|
96
|
+
expect(function_names.detect{|e| e =~ /_sec_/}).not_to eq(nil)
|
|
97
|
+
end
|
|
75
98
|
end
|
|
@@ -4,12 +4,18 @@ require './spec/env/iface.rb'
|
|
|
4
4
|
RSpec.describe "iface:driver:dispatch_spec" do
|
|
5
5
|
include_context "iface:driver"
|
|
6
6
|
|
|
7
|
-
it "Does automatically dispatch a blank array (signaling int_disptach) when a bulk queue is received prefixed with '
|
|
7
|
+
it "Does automatically dispatch a blank array (signaling int_disptach) when a bulk queue is received prefixed with 'i' indicating incomplete-ness" do
|
|
8
8
|
@pipe.puts ['i', [0, 0, "ping_nothing"]].to_json
|
|
9
9
|
expect(@pipe).to readline_and_equal_json_x_within_y_seconds([], 6.seconds)
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
it "Does
|
|
12
|
+
it "Does automatically dispatch a blank array (signaling int_disptach) when a blank queue is received prefixed with 'i' indicating incomplete-ness" do
|
|
13
|
+
@pipe.puts ['i'].to_json
|
|
14
|
+
expect(@pipe).to readline_and_equal_json_x_within_y_seconds([], 6.seconds)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
it "Does not dispatch a blank array (signaling int_disptach) when a bulk queue is received prefixed without 'i' indicating incomplete-ness" do
|
|
13
19
|
@pipe.puts [[0, 0, "ping_nothing"]].to_json
|
|
14
20
|
expect(@pipe).not_to readline_and_equal_json_x_within_y_seconds([], 6.seconds)
|
|
15
21
|
end
|
|
@@ -22,6 +22,17 @@ RSpec.describe "iface:driver:persist" do
|
|
|
22
22
|
expect(@pipe).to readline_and_equal_json_x_within_y_seconds([0, "pong"], 5.seconds)
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
+
it "retuns null when calling get on a blank key" do
|
|
26
|
+
key = SecureRandom.hex
|
|
27
|
+
value = SecureRandom.hex
|
|
28
|
+
|
|
29
|
+
@pipe.puts [[0, 3, "if_per_get", "session", "my_ns", key]].to_json
|
|
30
|
+
|
|
31
|
+
#Expect a response
|
|
32
|
+
res = [3, "int_per_get_res", "session", "my_ns", nil]
|
|
33
|
+
expect(@pipe).to readline_and_equal_json_x_within_y_seconds(res, 5.seconds)
|
|
34
|
+
end
|
|
35
|
+
|
|
25
36
|
it "Can set a persist, and then get" do
|
|
26
37
|
key = SecureRandom.hex
|
|
27
38
|
value = SecureRandom.hex
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
controller :my_controller do
|
|
2
|
+
action :my_action do
|
|
3
|
+
on_entry %{
|
|
4
|
+
//Queue up a deferred event
|
|
5
|
+
int_event_defer(__base__, "defer_res", {foo: "bar"});
|
|
6
|
+
|
|
7
|
+
int_event(__base__, "sync_res", {foo_sync: "bar"});
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
on "defer_res", %{
|
|
11
|
+
defer_res_params = params;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
on "sync_res", %{
|
|
15
|
+
sync_res_params = params;
|
|
16
|
+
}
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
controller :my_controller do
|
|
2
|
+
action :my_action do
|
|
3
|
+
on_entry %{
|
|
4
|
+
//Queue up a deferred event
|
|
5
|
+
int_event_defer(__base__, "defer_res", {foo: "bar"});
|
|
6
|
+
int_event_defer(__base__, "defer_res2", {foo: "bar"});
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
on "defer_res", %{
|
|
10
|
+
defer_res_params = params;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
on "defer_res2", %{
|
|
14
|
+
defer_res2_params = params;
|
|
15
|
+
}
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
controller :my_controller do
|
|
2
|
+
spots "hello", "world"
|
|
3
|
+
|
|
4
|
+
action :my_action do
|
|
5
|
+
on_entry %{
|
|
6
|
+
on_entry_base_pointer = __base__;
|
|
7
|
+
every_025_called_count = 0;
|
|
8
|
+
every_05_called_count = 0;
|
|
9
|
+
every_1_called_count = 0;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
on "hello", %{
|
|
13
|
+
var x = 3;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
every (0.25).seconds, %{
|
|
17
|
+
every_025_called_count += 1;
|
|
18
|
+
Send("025_message", {});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
every (0.5).seconds, %{
|
|
22
|
+
every_05_called_count += 1;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
every 1.seconds, %{
|
|
26
|
+
every_1_called_count += 1;
|
|
27
|
+
}
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
controller :my_controller do
|
|
2
|
+
spots "hello", "world"
|
|
3
|
+
|
|
4
|
+
on_entry %{
|
|
5
|
+
every_025_called_count = 0;
|
|
6
|
+
every_05_called_count = 0;
|
|
7
|
+
every_1_called_count = 0;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
action :my_action do
|
|
11
|
+
on "next", %{
|
|
12
|
+
Goto("other");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
every (0.25).seconds, %{
|
|
16
|
+
every_025_called_count += 1;
|
|
17
|
+
}
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
action :other do
|
|
21
|
+
every (0.5).seconds, %{
|
|
22
|
+
every_05_called_count += 1;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
every 1.seconds, %{
|
|
26
|
+
every_1_called_count += 1;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
on "back", %{
|
|
30
|
+
Goto("my_action")
|
|
31
|
+
}
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
controller :my_controller do
|
|
2
|
+
spots "content"
|
|
3
|
+
|
|
4
|
+
on_entry %{
|
|
5
|
+
timer_called = 0;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
action :my_action do
|
|
9
|
+
on_entry %{
|
|
10
|
+
Embed("alt1", "content", {});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
on "next", %{
|
|
14
|
+
Goto("other");
|
|
15
|
+
}
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
action :other do
|
|
19
|
+
on_entry %{
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
on "back", %{
|
|
23
|
+
Goto("my_action")
|
|
24
|
+
}
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
controller :alt1 do
|
|
29
|
+
|
|
30
|
+
action :index do
|
|
31
|
+
on_entry %{
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
every (0.25).seconds, %{
|
|
35
|
+
timer_called += 1;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -23,6 +23,17 @@ controller :my_controller do
|
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
controller :my_other_controller do
|
|
26
|
+
spots "content"
|
|
27
|
+
services :spec
|
|
28
|
+
|
|
29
|
+
action :my_action do
|
|
30
|
+
on_entry %{
|
|
31
|
+
Embed("my_other2_controller", "content", {});
|
|
32
|
+
}
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
controller :my_other2_controller do
|
|
26
37
|
services :spec
|
|
27
38
|
|
|
28
39
|
action :my_action do
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
controller :workout_window_exercise do
|
|
2
|
+
spots "verb"
|
|
3
|
+
|
|
4
|
+
on_entry %{
|
|
5
|
+
context.ep = context.ep;
|
|
6
|
+
context.ui_title = context.ui_title;
|
|
7
|
+
context.image_url = context.image_url;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
action :verb do
|
|
11
|
+
on_entry %{
|
|
12
|
+
var ctx = {
|
|
13
|
+
parent: context,
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (context.ep.verb_type == "seconds") {
|
|
17
|
+
Embed("exercise_verb_secs", "verb", ctx);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
on "verb_secs_completed", %{
|
|
22
|
+
Goto("presay");
|
|
23
|
+
}
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
action :presay do
|
|
27
|
+
on_entry %{
|
|
28
|
+
|
|
29
|
+
var ctx = {
|
|
30
|
+
parent: context,
|
|
31
|
+
}
|
|
32
|
+
Embed("workout_window_exercise_presay", "verb", ctx);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
on "start_clicked", %{
|
|
36
|
+
Goto("countdown");
|
|
37
|
+
}
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
action :countdown do
|
|
41
|
+
on_entry %{
|
|
42
|
+
Embed("workout_window_exercise_countdown", "verb", {});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
on "countdown_finished", %{
|
|
46
|
+
Goto("verb");
|
|
47
|
+
}
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
#Verb Seconds
|
|
53
|
+
####################################################################################################
|
|
54
|
+
controller :exercise_verb_secs do
|
|
55
|
+
action :index do
|
|
56
|
+
on_entry %{
|
|
57
|
+
context.seconds = context.parent.ep.seconds;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
every 1.seconds, %{
|
|
61
|
+
if (context.seconds == 0) {
|
|
62
|
+
debugger;
|
|
63
|
+
Raise("verb_secs_completed", {});
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
context.seconds -= 1;
|
|
68
|
+
|
|
69
|
+
Send("seconds", context.seconds.toString());
|
|
70
|
+
}
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
####################################################################################################
|
|
74
|
+
|