hokusai-zero 0.1.1

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.
Files changed (166) hide show
  1. checksums.yaml +7 -0
  2. data/Dockerfile +26 -0
  3. data/Gemfile +15 -0
  4. data/Gemfile.lock +91 -0
  5. data/LICENSE +21 -0
  6. data/README.md +28 -0
  7. data/ast/genheader +3 -0
  8. data/ast/include/hashmap.c +1151 -0
  9. data/ast/include/hashmap.c.license +20 -0
  10. data/ast/include/hashmap.h +54 -0
  11. data/ast/src/core/ast.c +448 -0
  12. data/ast/src/core/ast.h +259 -0
  13. data/ast/src/core/common.h +24 -0
  14. data/ast/src/core/component.c +85 -0
  15. data/ast/src/core/component.h +35 -0
  16. data/ast/src/core/hml.c +665 -0
  17. data/ast/src/core/hml.h +11 -0
  18. data/ast/src/core/input.c +458 -0
  19. data/ast/src/core/input.h +118 -0
  20. data/ast/src/core/style.c +101 -0
  21. data/ast/src/core/style.h +41 -0
  22. data/ast/src/core/text.c +784 -0
  23. data/ast/src/core/text.h +93 -0
  24. data/ast/src/core/util.c +140 -0
  25. data/ast/src/core/util.h +48 -0
  26. data/ast/src/hokusai.c +6 -0
  27. data/ast/src/hokusai.h +6 -0
  28. data/ast/test/fixtures/test.ui +13 -0
  29. data/ast/test/greatest.h +1266 -0
  30. data/ast/test/hokusai.c +14 -0
  31. data/ast/test/parser.c +234 -0
  32. data/ast/test/text.c +116 -0
  33. data/ext/extconf.rb +27 -0
  34. data/grammar/Cargo.lock +80 -0
  35. data/grammar/Cargo.toml +26 -0
  36. data/grammar/binding.gyp +20 -0
  37. data/grammar/bindings/node/binding.cc +28 -0
  38. data/grammar/bindings/node/index.js +19 -0
  39. data/grammar/bindings/rust/build.rs +40 -0
  40. data/grammar/bindings/rust/lib.rs +52 -0
  41. data/grammar/corpus/1_document.txt +131 -0
  42. data/grammar/corpus/2_selectors.txt +58 -0
  43. data/grammar/corpus/3_spaces.txt +69 -0
  44. data/grammar/corpus/4_errors.txt +10 -0
  45. data/grammar/corpus/5_macros.txt +175 -0
  46. data/grammar/corpus/6_styles.txt +81 -0
  47. data/grammar/grammar.js +275 -0
  48. data/grammar/package-lock.json +34 -0
  49. data/grammar/package.json +33 -0
  50. data/grammar/src/grammar.json +1269 -0
  51. data/grammar/src/node-types.json +474 -0
  52. data/grammar/src/parser.c +5772 -0
  53. data/grammar/src/scanner.c +258 -0
  54. data/grammar/src/tree_sitter/parser.h +230 -0
  55. data/grammar/src/tree_sitter/scanner.h +12 -0
  56. data/grammar/test.nml +10 -0
  57. data/hokusai.gemspec +19 -0
  58. data/ui/examples/assets/DigitalDisplay.ttf +0 -0
  59. data/ui/examples/assets/OpenSans-Regular.ttf +0 -0
  60. data/ui/examples/assets/addy.png +0 -0
  61. data/ui/examples/assets/baby_sean.png +0 -0
  62. data/ui/examples/assets/football-troll.png +0 -0
  63. data/ui/examples/assets/gear.png +0 -0
  64. data/ui/examples/assets/icecold.ttf +0 -0
  65. data/ui/examples/assets/science-troll.png +0 -0
  66. data/ui/examples/buddy.rb +31 -0
  67. data/ui/examples/clock.rb +58 -0
  68. data/ui/examples/counter.rb +123 -0
  69. data/ui/examples/dynamic.rb +147 -0
  70. data/ui/examples/foobar.rb +236 -0
  71. data/ui/examples/stock.rb +115 -0
  72. data/ui/examples/stock_decider/option.rb +74 -0
  73. data/ui/examples/tic_tac_toe.rb +246 -0
  74. data/ui/lib/lib_hokusai.rb +425 -0
  75. data/ui/spec/hokusai/ast_spec.rb +88 -0
  76. data/ui/spec/hokusai/automation/keys_transcoder_spec.rb +50 -0
  77. data/ui/spec/hokusai/automation/selector_spec.rb +68 -0
  78. data/ui/spec/hokusai/block_spec.rb +126 -0
  79. data/ui/spec/hokusai/directives_spec.rb +327 -0
  80. data/ui/spec/hokusai/e2e/client_spec.rb +58 -0
  81. data/ui/spec/hokusai/e2e/meta_spec.rb +42 -0
  82. data/ui/spec/hokusai/publisher_spec.rb +38 -0
  83. data/ui/spec/hokusai/slots_spec.rb +150 -0
  84. data/ui/spec/hokusai/util/piece_table_spec.rb +90 -0
  85. data/ui/spec/hokusai_spec.rb +0 -0
  86. data/ui/spec/spec_helper.rb +30 -0
  87. data/ui/src/hokusai/ast.rb +446 -0
  88. data/ui/src/hokusai/automation/client.rb +167 -0
  89. data/ui/src/hokusai/automation/constants.rb +98 -0
  90. data/ui/src/hokusai/automation/converters/selector_converter.rb +61 -0
  91. data/ui/src/hokusai/automation/driver.rb +54 -0
  92. data/ui/src/hokusai/automation/driver_command_queue.rb +50 -0
  93. data/ui/src/hokusai/automation/driver_commands/base.rb +79 -0
  94. data/ui/src/hokusai/automation/driver_commands/get_attribute.rb +41 -0
  95. data/ui/src/hokusai/automation/driver_commands/invoke.rb +33 -0
  96. data/ui/src/hokusai/automation/driver_commands/locate.rb +48 -0
  97. data/ui/src/hokusai/automation/driver_commands/trigger_keyboard.rb +94 -0
  98. data/ui/src/hokusai/automation/driver_commands/trigger_mouse.rb +213 -0
  99. data/ui/src/hokusai/automation/keys_transcoder.rb +128 -0
  100. data/ui/src/hokusai/automation/selector.rb +39 -0
  101. data/ui/src/hokusai/automation/server.rb +114 -0
  102. data/ui/src/hokusai/automation.rb +3 -0
  103. data/ui/src/hokusai/backends/raylib/config.rb +47 -0
  104. data/ui/src/hokusai/backends/raylib/font.rb +113 -0
  105. data/ui/src/hokusai/backends/raylib/keys.rb +124 -0
  106. data/ui/src/hokusai/backends/raylib.rb +449 -0
  107. data/ui/src/hokusai/backends/sdl2/Monaco.ttf +0 -0
  108. data/ui/src/hokusai/backends/sdl2/color.rb +12 -0
  109. data/ui/src/hokusai/backends/sdl2/config.rb +31 -0
  110. data/ui/src/hokusai/backends/sdl2/font.rb +127 -0
  111. data/ui/src/hokusai/backends/sdl2/keys.rb +119 -0
  112. data/ui/src/hokusai/backends/sdl2.rb +529 -0
  113. data/ui/src/hokusai/block.rb +237 -0
  114. data/ui/src/hokusai/blocks/button.rb +100 -0
  115. data/ui/src/hokusai/blocks/checkbox.rb +51 -0
  116. data/ui/src/hokusai/blocks/circle.rb +28 -0
  117. data/ui/src/hokusai/blocks/clipped.rb +23 -0
  118. data/ui/src/hokusai/blocks/cursor.rb +49 -0
  119. data/ui/src/hokusai/blocks/dynamic.rb +37 -0
  120. data/ui/src/hokusai/blocks/empty.rb +10 -0
  121. data/ui/src/hokusai/blocks/hblock.rb +35 -0
  122. data/ui/src/hokusai/blocks/image.rb +18 -0
  123. data/ui/src/hokusai/blocks/input.rb +200 -0
  124. data/ui/src/hokusai/blocks/label.rb +39 -0
  125. data/ui/src/hokusai/blocks/panel.rb +126 -0
  126. data/ui/src/hokusai/blocks/rect.rb +24 -0
  127. data/ui/src/hokusai/blocks/scissor_begin.rb +18 -0
  128. data/ui/src/hokusai/blocks/scissor_end.rb +12 -0
  129. data/ui/src/hokusai/blocks/scrollbar.rb +103 -0
  130. data/ui/src/hokusai/blocks/selectable.rb +77 -0
  131. data/ui/src/hokusai/blocks/svg.rb +20 -0
  132. data/ui/src/hokusai/blocks/text.rb +214 -0
  133. data/ui/src/hokusai/blocks/titlebar/osx.rb +145 -0
  134. data/ui/src/hokusai/blocks/toggle.rb +55 -0
  135. data/ui/src/hokusai/blocks/vblock.rb +35 -0
  136. data/ui/src/hokusai/commands/base.rb +22 -0
  137. data/ui/src/hokusai/commands/circle.rb +47 -0
  138. data/ui/src/hokusai/commands/image.rb +45 -0
  139. data/ui/src/hokusai/commands/rect.rb +158 -0
  140. data/ui/src/hokusai/commands/scissor.rb +22 -0
  141. data/ui/src/hokusai/commands/text.rb +92 -0
  142. data/ui/src/hokusai/commands.rb +87 -0
  143. data/ui/src/hokusai/diff.rb +124 -0
  144. data/ui/src/hokusai/error.rb +3 -0
  145. data/ui/src/hokusai/event.rb +54 -0
  146. data/ui/src/hokusai/events/keyboard.rb +84 -0
  147. data/ui/src/hokusai/events/mouse.rb +172 -0
  148. data/ui/src/hokusai/font.rb +280 -0
  149. data/ui/src/hokusai/meta.rb +152 -0
  150. data/ui/src/hokusai/mounting/loop_entry.rb +230 -0
  151. data/ui/src/hokusai/mounting/mount_entry.rb +74 -0
  152. data/ui/src/hokusai/mounting/update_entry.rb +101 -0
  153. data/ui/src/hokusai/node.rb +98 -0
  154. data/ui/src/hokusai/node_mounter.rb +102 -0
  155. data/ui/src/hokusai/painter.rb +214 -0
  156. data/ui/src/hokusai/publisher.rb +32 -0
  157. data/ui/src/hokusai/style.rb +72 -0
  158. data/ui/src/hokusai/types.rb +266 -0
  159. data/ui/src/hokusai/util/clamping_iterator.rb +202 -0
  160. data/ui/src/hokusai/util/piece_table.rb +111 -0
  161. data/ui/src/hokusai/util/selection.rb +145 -0
  162. data/ui/src/hokusai.rb +120 -0
  163. data/ui/vendor/.gitkeep +0 -0
  164. data/vendor/.gitkeep +0 -0
  165. data/xmake.lua +192 -0
  166. metadata +222 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3db29811fb035ca8b4b414a76db501a1e8f8bd0f5ef0042f91764c23b5d3bef3
4
+ data.tar.gz: fe08efcaa824c1c01c7ad379e1723ca3f4db7e6687a7e548d485461b4aab0d4c
5
+ SHA512:
6
+ metadata.gz: a81fb41fcfe41bad854d8b077405353e63239e3a7257baa1e409163024b59e4db40460b9a932b4a1c9ae0914fcdb832bc49cb74470edd38a38fc6a88e873edae
7
+ data.tar.gz: 4522ec4b4b36a6ad422162fc28c96e4259a4712b33f1525d797904ad6019a2ff82637241a95b7893dfc43c2ff87d36c75fba74da794776d10e915d17ac33caa3
data/Dockerfile ADDED
@@ -0,0 +1,26 @@
1
+ FROM ruby:latest
2
+
3
+ ENV XMAKE_ROOT=y
4
+ RUN apt update -y && apt install -y software-properties-common curl
5
+ RUN curl -fsSL https://xmake.io/shget.text | bash
6
+ # RUN add-apt-repository ppa:xmake-io/xmake
7
+ RUN apt update -y
8
+ RUN apt install -y wget unzip make 7zip bash nodejs npm libgl1-mesa-dev libglew-dev libglfw3-dev
9
+
10
+ RUN mkdir -p /raylib-build
11
+ WORKDIR /raylib-build
12
+ RUN wget https://github.com/raysan5/raylib/releases/download/5.0/raylib-5.0_linux_amd64.tar.gz
13
+ RUN tar -xvf raylib-5.0_linux_amd64.tar.gz
14
+
15
+ RUN cp -rf raylib-5.0_linux_amd64/lib/* /usr/local/lib/.
16
+ RUN cp -rf raylib-5.0_linux_amd64/include/* /usr/local/include/.
17
+
18
+ RUN apt install -y xvfb
19
+
20
+ ENV DISPLAY=:99
21
+
22
+ RUN apt install -y cmake libxinerama-dev libxcursor-dev libxi-dev
23
+
24
+ ENTRYPOINT ["/bin/bash", "--init-file", "~/.xmake/profile", "-lc"]
25
+
26
+ CMD ["xmake"]
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source "https://www.rubygems.org"
2
+
3
+ gem "ffi", github: "ffi/ffi", submodules: true
4
+
5
+ group :development, :test do
6
+ gem "colorize"
7
+ gem "concurrent-ruby", require: "concurrent"
8
+ gem "memory_profiler"
9
+ gem "raylib-bindings"
10
+ gem "rerun"
11
+ gem "rest-client"
12
+ gem "rspec"
13
+ gem "sdl2-bindings"
14
+ gem "thin", "1.8.0"
15
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,91 @@
1
+ GIT
2
+ remote: https://github.com/ffi/ffi.git
3
+ revision: c128cede750242fe19945af8bd6c797728489ad5
4
+ submodules: true
5
+ specs:
6
+ ffi (1.17.0)
7
+
8
+ GEM
9
+ remote: https://www.rubygems.org/
10
+ specs:
11
+ colorize (1.1.0)
12
+ concurrent-ruby (1.3.4)
13
+ daemons (1.4.1)
14
+ diff-lcs (1.5.1)
15
+ domain_name (0.6.20240107)
16
+ eventmachine (1.2.7)
17
+ http-accept (1.7.0)
18
+ http-cookie (1.0.8)
19
+ domain_name (~> 0.5)
20
+ listen (3.9.0)
21
+ rb-fsevent (~> 0.10, >= 0.10.3)
22
+ rb-inotify (~> 0.9, >= 0.9.10)
23
+ logger (1.6.4)
24
+ memory_profiler (1.1.0)
25
+ mime-types (3.6.0)
26
+ logger
27
+ mime-types-data (~> 3.2015)
28
+ mime-types-data (3.2024.1203)
29
+ netrc (0.11.0)
30
+ rack (2.2.10)
31
+ raylib-bindings (0.7.9)
32
+ ffi (~> 1.16)
33
+ raylib-bindings (0.7.9-aarch64-linux)
34
+ ffi (~> 1.16)
35
+ raylib-bindings (0.7.9-arm64-darwin)
36
+ ffi (~> 1.16)
37
+ raylib-bindings (0.7.9-x86_64-darwin)
38
+ ffi (~> 1.16)
39
+ raylib-bindings (0.7.9-x86_64-linux)
40
+ ffi (~> 1.16)
41
+ rb-fsevent (0.11.2)
42
+ rb-inotify (0.11.1)
43
+ ffi (~> 1.0)
44
+ rerun (0.14.0)
45
+ listen (~> 3.0)
46
+ rest-client (2.1.0)
47
+ http-accept (>= 1.7.0, < 2.0)
48
+ http-cookie (>= 1.0.2, < 2.0)
49
+ mime-types (>= 1.16, < 4.0)
50
+ netrc (~> 0.8)
51
+ rspec (3.13.0)
52
+ rspec-core (~> 3.13.0)
53
+ rspec-expectations (~> 3.13.0)
54
+ rspec-mocks (~> 3.13.0)
55
+ rspec-core (3.13.2)
56
+ rspec-support (~> 3.13.0)
57
+ rspec-expectations (3.13.3)
58
+ diff-lcs (>= 1.2.0, < 2.0)
59
+ rspec-support (~> 3.13.0)
60
+ rspec-mocks (3.13.2)
61
+ diff-lcs (>= 1.2.0, < 2.0)
62
+ rspec-support (~> 3.13.0)
63
+ rspec-support (3.13.2)
64
+ sdl2-bindings (0.2.3)
65
+ ffi (~> 1.15)
66
+ thin (1.8.0)
67
+ daemons (~> 1.0, >= 1.0.9)
68
+ eventmachine (~> 1.0, >= 1.0.4)
69
+ rack (>= 1, < 3)
70
+
71
+ PLATFORMS
72
+ aarch64-linux
73
+ arm64-darwin
74
+ ruby
75
+ x86_64-darwin
76
+ x86_64-linux
77
+
78
+ DEPENDENCIES
79
+ colorize
80
+ concurrent-ruby
81
+ ffi!
82
+ memory_profiler
83
+ raylib-bindings
84
+ rerun
85
+ rest-client
86
+ rspec
87
+ sdl2-bindings
88
+ thin (= 1.8.0)
89
+
90
+ BUNDLED WITH
91
+ 2.5.22
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Trollio
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # Hokusai
2
+
3
+ Ruby port of Hokusai
4
+
5
+ ## Usage
6
+
7
+ Requirements:
8
+ * [xmake](https://xmake.io/#/) to build dependencies
9
+ * Ruby to run applications
10
+
11
+ Steps:
12
+ * Download project
13
+ * Install dependencies
14
+ * `bundle install`
15
+ * `xmake q tree-sitter`
16
+ * For Raylib
17
+ * `xmake q raylib`
18
+ * For SDL2
19
+ * `xmake q libsdl`
20
+ * `xmake q libsdl_gfx`
21
+ * `xmake q lbsdl_ttf`
22
+ * `xmake q libsdl_image`
23
+ * Build grammar and ast code
24
+ * `xmake b hokusai`
25
+ * Run specs
26
+ * `xmake b -g test`
27
+ * Run a demo
28
+ * `xmake demo counter`
data/ast/genheader ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env bash
2
+
3
+ cat include/hashmap.h src/core/ast.h src/core/hml.h