atome 0.5.5.9.1 → 0.5.6.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +9 -2
  3. data/documentation/deep learning/basic_infos.txt +9 -17
  4. data/exe/atome +13 -13
  5. data/lib/atome/atome.rb +5 -6
  6. data/lib/atome/eve.rb +0 -0
  7. data/lib/atome/extensions/atome.rb +52 -0
  8. data/lib/atome/genesis/generators/atome.rb +3 -0
  9. data/lib/atome/genesis/generators/communication.rb +7 -2
  10. data/lib/atome/genesis/generators/geometry.rb +0 -3
  11. data/lib/atome/genesis/generators/spatial.rb +19 -40
  12. data/lib/atome/genesis/generators/utility.rb +16 -12
  13. data/lib/atome/genesis/genesis.rb +2 -1
  14. data/lib/atome/genesis/sparkle.rb +5 -2
  15. data/lib/atome/helpers/essentials.rb +9 -9
  16. data/lib/atome/helpers/utilities.rb +26 -0
  17. data/lib/atome/kernel/ruby +0 -0
  18. data/lib/atome/presets/atome.rb +4 -1
  19. data/lib/atome/version.rb +2 -1
  20. data/lib/atome.rb +1 -1
  21. data/lib/atome_relative.rb +1 -1
  22. data/lib/renderers/html/geometry.rb +30 -18
  23. data/lib/renderers/html/html.rb +11 -1
  24. data/lib/renderers/html/identity.rb +2 -1
  25. data/lib/renderers/html/spatial.rb +6 -7
  26. data/server/atome_server.rb +148 -0
  27. data/server/atome_server_wasm.rb +112 -0
  28. data/server/capture.rb +10 -0
  29. data/server/config.ru +13 -0
  30. data/src/css/style.css +162 -0
  31. data/src-tauri/.gitignore +4 -0
  32. data/src-tauri/Cargo.toml +27 -0
  33. data/src-tauri/build.rs +3 -0
  34. data/src-tauri/icons/128x128.png +0 -0
  35. data/src-tauri/icons/128x128@2x.png +0 -0
  36. data/src-tauri/icons/32x32.png +0 -0
  37. data/src-tauri/icons/Square107x107Logo.png +0 -0
  38. data/src-tauri/icons/Square142x142Logo.png +0 -0
  39. data/src-tauri/icons/Square150x150Logo.png +0 -0
  40. data/src-tauri/icons/Square284x284Logo.png +0 -0
  41. data/src-tauri/icons/Square30x30Logo.png +0 -0
  42. data/src-tauri/icons/Square310x310Logo.png +0 -0
  43. data/src-tauri/icons/Square44x44Logo.png +0 -0
  44. data/src-tauri/icons/Square71x71Logo.png +0 -0
  45. data/src-tauri/icons/Square89x89Logo.png +0 -0
  46. data/src-tauri/icons/StoreLogo.png +0 -0
  47. data/src-tauri/icons/icon.icns +0 -0
  48. data/src-tauri/icons/icon.ico +0 -0
  49. data/src-tauri/icons/icon.png +0 -0
  50. data/src-tauri/src/main.rs +71 -0
  51. data/src-tauri/tauri.conf.json +70 -0
  52. data/src-wasm/wasm/wasi-vfs-osx_arm +0 -0
  53. data/src-wasm/wasm/wasi-vfs-osx_x86 +0 -0
  54. data/src-wasm/wasm/wasi-vfs-unix +0 -0
  55. data/src-wasm/wasm/wasi-vfs.exe +0 -0
  56. data/vendor/assets/application/examples/center.rb +2 -3
  57. data/vendor/assets/application/examples/compute.rb +1 -1
  58. data/vendor/assets/application/examples/css.rb +6 -0
  59. data/vendor/assets/application/examples/int8.rb +4 -1
  60. data/vendor/assets/application/examples/selected.rb +6 -0
  61. data/vendor/assets/application/examples/sub_atome_manipulation.rb +19 -0
  62. data/vendor/assets/application/examples/test.rb +19 -12
  63. data/vendor/assets/application/examples/unit.rb +1 -1
  64. data/vendor/assets/application/index.rb +1 -1
  65. data/vendor/assets/server/atome_server.rb +178 -33
  66. data/vendor/assets/src/index_server.html +2 -0
  67. data/vendor/assets/src/index_server_wasm.html +1 -0
  68. data/vendor/assets/src/js/atome/atome_helpers/communication.js +2 -4
  69. metadata +38 -12
  70. data/vendor/assets/application/required_example.rb +0 -1
  71. data/vendor/assets/application/test.rb +0 -29
  72. data/vendor/assets/application/works/photos.rb +0 -672
  73. data/vendor/assets/application/works/photos2.rb +0 -218
  74. data/vendor/assets/application/works/photos3.rb +0 -343
  75. data/vendor/assets/application/works/photos4.rb +0 -34
  76. data/vendor/assets/application/works/photos6.rb +0 -6
  77. data/vendor/assets/application/works/vie.rb +0 -196
  78. /data/{vendor/assets/application/works/trigga.rb → Guardfile} +0 -0
  79. /data/vendor/assets/application/examples/{presets.rb → preset.rb} +0 -0
@@ -210,7 +210,16 @@ class HTML
210
210
  end
211
211
 
212
212
  def connect(params, &bloc)
213
- JS.eval("atomeJS.connect('ws://#{params}')")
213
+ type= params[:type]
214
+ server= params[:address]
215
+ user=params[:user]
216
+ pass=params[:pass]
217
+ atomes=params[:atomes]
218
+ particles=params[:particles]
219
+ JS.eval("atomeJS.connect('#{type}','#{server}','#{user}','#{pass}',#{atomes.to_json},#{particles.to_json})")
220
+ #
221
+ # JS.eval("atomeJS.connect('ws://#{server}')")
222
+ # @original_atome.message(:helloworld)
214
223
  end
215
224
 
216
225
  def send_message(message)
@@ -1475,6 +1484,7 @@ class HTML
1475
1484
 
1476
1485
  def center(options, attach)
1477
1486
  @center_options = options
1487
+
1478
1488
  @parent = grab(attach)
1479
1489
 
1480
1490
  apply_centering(@center_options, @parent)
@@ -42,7 +42,8 @@ new({ method: :type, type: :string, specific: :color, renderer: :html }) do
42
42
  end
43
43
 
44
44
  new({ method: :data, type: :string, specific: :text, renderer: :html }) do |params|
45
- js[:innerHTML] = if language
45
+
46
+ js[:innerHTML] = if int8[language]
46
47
  int8[language].to_s
47
48
  else
48
49
  params.to_s
@@ -1,24 +1,23 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  new({ method: :left, type: :integer, renderer: :html }) do |params|
4
- unit = @unit[:left] || :px
4
+ unit = @unit[:left] || :px if params.is_a? Numeric
5
5
  js[:style][:left] = "#{params}#{unit}"
6
6
  end
7
7
 
8
8
  new({ method: :top, type: :integer, renderer: :html }) do |params|
9
- unit = @unit[:top] || :px
10
- # alert unit
9
+ unit = @unit[:top] || :px if params.is_a? Numeric
11
10
  js[:style][:top] = "#{params}#{unit}"
12
11
  end
13
12
  new({ method: :bottom, type: :integer, renderer: :html }) do |params|
14
- unit = @unit[:bottom] || :px
15
- js[:style][:bottom] = "#{params}#{unit}"
13
+ unit = @unit[:bottom] || :px if params.is_a? Numeric
14
+ js[:style][:bottom] = "#{params}#{unit}"
16
15
  end
17
16
 
18
17
  new({ method: :right, type: :integer, renderer: :html }) do |params|
19
- unit = @unit[:right] || :px
18
+ unit = @unit[:right] || :px if params.is_a? Numeric
20
19
 
21
- js[:style][:right] = "#{params}#{unit}"
20
+ js[:style][:right] = "#{params}#{unit}"
22
21
  end
23
22
 
24
23
  new({ method: :top, type: :integer, renderer: :html, specific: :shadow })
@@ -0,0 +1,148 @@
1
+ # frozen_string_literal: true
2
+
3
+ # atome server
4
+ require 'em/pure_ruby' if RUBY_PLATFORM == 'x64-mingw32'
5
+ require 'fileutils'
6
+ require '../src/utilities/aui'
7
+ require 'digest/sha2'
8
+ require 'faye/websocket'
9
+ require 'geocoder'
10
+ require 'json'
11
+ require 'mail'
12
+ require 'net/ping'
13
+ require 'roda'
14
+ require 'rufus-scheduler'
15
+ require 'securerandom'
16
+ require 'sequel'
17
+
18
+ class EDen
19
+ def self.terminal(cmd,option,ws,value, user, pass)
20
+ `#{cmd}`
21
+ end
22
+
23
+ def self.file(source, operation,ws,value,user, pass)
24
+ file_content= File.send(operation, source, value).to_s
25
+ file_content = file_content.gsub("'", "\"")
26
+ "=> operation: #{operation}, source: #{source} , content : #{file_content},"
27
+ end
28
+ # return_message = EDen.safe_send(action_requested, message,option, current_user, user_pass)
29
+
30
+ def self.safe_send(method_name, *args)
31
+ method_sym = method_name.to_sym
32
+ eden_methods = EDen.singleton_methods(false) - Object.singleton_methods
33
+ if eden_methods.include?(method_sym)
34
+ send(method_sym, *args)
35
+ else
36
+ "forbidden action: #{method_name}"
37
+ end
38
+ end
39
+ end
40
+
41
+ Faye::WebSocket.load_adapter('puma')
42
+
43
+ class String
44
+ def is_json?
45
+ begin
46
+ !JSON.parse(self).nil?
47
+ rescue
48
+ false
49
+ end
50
+ end
51
+ end
52
+
53
+ class Database
54
+ def self.connect_database
55
+ if File.exist?("eden.sqlite3")
56
+ eden = Sequel.connect("sqlite://eden.sqlite3")
57
+ else
58
+ eden = Sequel.connect("sqlite://eden.sqlite3")
59
+ eden.create_table :atome do
60
+ primary_key :atome_id
61
+ String :aui
62
+ String :id
63
+ String :type
64
+ String :name
65
+ String :content
66
+ String :position
67
+ String :dimension
68
+ String :color
69
+ String :right
70
+ String :effect
71
+ String :shadow
72
+ String :border
73
+ String :fill
74
+ Float :x
75
+ Float :xx
76
+ Float :y
77
+ Float :yy
78
+ Float :z
79
+ Float :zz
80
+ Float :width
81
+ Float :height
82
+ Float :depth
83
+ end
84
+
85
+ end
86
+ eden
87
+ end
88
+
89
+ end
90
+
91
+ class App < Roda
92
+
93
+ # comment below when test will be done
94
+ File.delete("./eden.sqlite3") if File.exist?("./eden.sqlite3")
95
+ eden = Database.connect_database
96
+ items = eden[:atome]
97
+
98
+ # populate the table
99
+ items.insert(name: 'abc', width: rand * 100)
100
+ items.insert(name: 'def', width: rand * 100)
101
+ items.insert(name: 'ghi', width: rand * 100)
102
+ puts "Item count: #{items.count}"
103
+ puts "The average price is: #{items.avg(:width)}"
104
+ index_content = File.read("../src/index_server.html")
105
+
106
+ opts[:root] = '../src'
107
+ plugin :static, %w[/css /js /medias], root: '../src'
108
+ route do |r|
109
+ r.root do
110
+ if Faye::WebSocket.websocket?(r.env)
111
+ ws = Faye::WebSocket.new(r.env)
112
+ ws.on :open do |event|
113
+ ws.send('server ready'.to_json)
114
+ ws.send('asking for synchro data'.to_json)
115
+ end
116
+
117
+ ws.on(:message) do |event|
118
+ json_string = event.data.gsub(/(\w+):/) { "\"#{$1}\":" }.gsub('=>', ':')
119
+ full_data = JSON.parse(json_string)
120
+
121
+ message = full_data['message']
122
+ action_requested = full_data['action']
123
+ value= full_data['value']
124
+ option= full_data['option']
125
+ current_user = full_data['user']
126
+ user_pass = full_data['pass']['global']
127
+ # if action_requested == :request
128
+ # request (message)
129
+ # end
130
+ return_message = EDen.safe_send(action_requested, message,option,ws,value, current_user, user_pass)
131
+ # else
132
+ # return_message = "no action msg: #{full_data}"
133
+ # end
134
+ ws.send(return_message.to_json)
135
+ end
136
+
137
+ ws.on(:close) do |event|
138
+ puts "server closed with status #{event.code}"
139
+ end
140
+ ws.rack_response
141
+ end
142
+
143
+ index_content
144
+ end
145
+
146
+ end
147
+
148
+ end
@@ -0,0 +1,112 @@
1
+ # frozen_string_literal: true
2
+
3
+ # atome server
4
+ require 'em/pure_ruby' if RUBY_PLATFORM == 'x64-mingw32'
5
+ require '../src/utilities/aui'
6
+ require 'digest/sha2'
7
+ require 'faye/websocket'
8
+ require 'geocoder'
9
+ require 'json'
10
+ require 'mail'
11
+ require 'net/ping'
12
+ require 'roda'
13
+ require 'rufus-scheduler'
14
+ require 'securerandom'
15
+ require 'sequel'
16
+
17
+ Faye::WebSocket.load_adapter('puma') # Utilisez l'adaptateur 'thin' pour Faye
18
+
19
+ class String
20
+ def is_json?
21
+ begin
22
+ !JSON.parse(self).nil?
23
+ rescue
24
+ false
25
+ end
26
+ end
27
+ end
28
+
29
+ class Database
30
+ def self.connect_database
31
+ if File.exist?("eden.sqlite3")
32
+ eden = Sequel.connect("sqlite://eden.sqlite3")
33
+ else
34
+ eden = Sequel.connect("sqlite://eden.sqlite3")
35
+ eden.create_table :atome do
36
+ primary_key :atome_id
37
+ String :aui
38
+ String :id
39
+ String :type
40
+ String :name
41
+ String :content
42
+ String :position
43
+ String :dimension
44
+ String :color
45
+ String :right
46
+ String :effect
47
+ String :shadow
48
+ String :border
49
+ String :fill
50
+ Float :x
51
+ Float :xx
52
+ Float :y
53
+ Float :yy
54
+ Float :z
55
+ Float :zz
56
+ Float :width
57
+ Float :height
58
+ Float :depth
59
+ end
60
+
61
+ end
62
+ eden
63
+ end
64
+
65
+ end
66
+
67
+ class App < Roda
68
+ # comment below when test will be done
69
+ File.delete("./eden.sqlite3") if File.exist?("./eden.sqlite3")
70
+ eden = Database.connect_database
71
+ items = eden[:atome]
72
+
73
+ # populate the table
74
+ items.insert(name: 'abc', width: rand * 100)
75
+ items.insert(name: 'def', width: rand * 100)
76
+ items.insert(name: 'ghi', width: rand * 100)
77
+
78
+ puts "Item count: #{items.count}"
79
+
80
+ puts "The average price is: #{items.avg(:width)}"
81
+
82
+ index_content = File.read("../src/index_server.html")
83
+
84
+ opts[:root] = '../src'
85
+ plugin :static, %w[/css /js /medias], root: '../src'
86
+ route do |r|
87
+ r.root do
88
+ if Faye::WebSocket.websocket?(r.env)
89
+ ws = Faye::WebSocket.new(r.env)
90
+
91
+ ws.on :open do |event|
92
+ ws.send('server ready'.to_json)
93
+ ws.send('asking for synchro data'.to_json)
94
+ end
95
+
96
+ ws.on(:message) do |event|
97
+ #TODO : encode event on both client and server
98
+ ws.send(event.data.reverse.to_json) # Envoie le message inversé au client
99
+ end
100
+
101
+ ws.on(:close) do |event|
102
+ puts "server closed with status #{event.code}"
103
+ end
104
+ ws.rack_response
105
+ end
106
+
107
+ index_content
108
+ end
109
+
110
+ end
111
+
112
+ end
data/server/capture.rb ADDED
@@ -0,0 +1,10 @@
1
+ path = ARGV[0]
2
+ name = ARGV[1]
3
+
4
+ File.open("#{path}#{name}.txt", 'w') do |f|
5
+ f.write("Le chemin ; #{path}!\n")
6
+ f.write("Le nom du fichier #{name}\n")
7
+ end
8
+
9
+ # `gphoto2 --capture-image-and-download --filename "../src/medias/images/photos/verif.jpg"`
10
+ `gphoto2 --capture-image-and-download --filename "#{path}#{name}.jpg"`
data/server/config.ru ADDED
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'roda'
4
+ require 'rack/unreloader'
5
+
6
+ # Unreloader = Rack::Unreloader.new(subclasses: %w[Roda]) { App }
7
+ # Unreloader.require './atome_server.rb'
8
+ # run Unreloader
9
+ # uncomment to allow code reloading
10
+ # uncomment below for prod or comment to allow code reloading
11
+ require './atome_server.rb'
12
+ run App.app.freeze
13
+
data/src/css/style.css ADDED
@@ -0,0 +1,162 @@
1
+ * {
2
+ -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
3
+ }
4
+
5
+ html, body {
6
+
7
+ font-family: system-ui, -apple-system, -apple-system-font, 'Segoe UI', 'Roboto', sans-serif;
8
+ font-size: 12px;
9
+ margin: 0;
10
+ padding: 0;
11
+ background: rgba(39, 39, 39, 1);
12
+ overflow: hidden;
13
+ -webkit-overflow-scrolling: touch;
14
+ width: 100%;
15
+ height: 100%;
16
+ z-index: 0;
17
+ color: lightgray;
18
+ }
19
+ pre {
20
+ min-width: 100px;
21
+ margin: 0;
22
+ padding: 0;
23
+ }
24
+
25
+
26
+ .matrix{
27
+ background-color: blue;
28
+ border-radius: 9px;
29
+ display: grid;
30
+ grid-template-columns: repeat(4, 1fr);
31
+ flex-direction: column;
32
+ gap: 12px;
33
+ padding: 3px;
34
+ }
35
+ /*.matrix_element{*/
36
+ /* background-color: rebeccapurple;*/
37
+ /* width: 100%;*/
38
+ /* height: 29px;*/
39
+ /* border-radius: 59px;*/
40
+ /* display: flex;*/
41
+ /* justify-content: center;*/
42
+ /* align-items: center;*/
43
+ /* flex-direction: column;*/
44
+ /* margin-bottom: 20px;*/
45
+ /* padding: 0px*/
46
+ /*}*/
47
+
48
+ #view {
49
+ left: 0px;
50
+ font-size: 25px;
51
+ right: 0px;
52
+ top: 0px;
53
+ bottom: 0px;
54
+ width: auto;
55
+ /*display: block;*/
56
+ height: auto;
57
+ overflow: hidden;
58
+ position: absolute;
59
+ -webkit-overflow-scrolling: touch;
60
+ }
61
+
62
+
63
+ .ui-selected {
64
+ border: #00bb00 solid 3px;
65
+ }
66
+
67
+ .ui-selecting {
68
+ border: orange solid 3px;
69
+ }
70
+
71
+ .selected {
72
+ outline: 2px dashed white;
73
+ background-color: #00bb00;
74
+ }
75
+
76
+ .atome {
77
+ will-change: transform;
78
+ cursor: default;
79
+ pointer-events: auto;
80
+ caret-color: white;
81
+ outline: none;
82
+ -webkit-user-select: none;
83
+ -moz-user-select: none;
84
+ user-select: none;
85
+ position: absolute;
86
+ display: inline-block;
87
+ background-size: 100%;
88
+ background-repeat: no-repeat;
89
+ -webkit-overflow-scrolling: touch;
90
+ -webkit-user-drag: none;
91
+ caret-shape: bar;
92
+ overflow: visible;
93
+ }
94
+
95
+ .text {
96
+ /*-webkit-text-fill-color: transparent;*/
97
+ /*-webkit-background-clip: text;*/
98
+ word-wrap: break-word;
99
+ white-space: pre-wrap;
100
+ position: relative;
101
+ }
102
+
103
+ .center {
104
+ display: flex;
105
+ justify-content: center;
106
+ align-items: center;
107
+ position: absolute;
108
+ transform: translate(-50%, -50%);
109
+ }
110
+
111
+ .center_vertical {
112
+ display: flex;
113
+ align-items: center;
114
+ position: absolute;
115
+ transform: translateY(-50%);
116
+ }
117
+
118
+ .center_horizontal{
119
+ display: flex;
120
+ justify-content: center;
121
+ position: absolute;
122
+ transform: translateX(-50%);
123
+ }
124
+
125
+ .e_align_h_left {
126
+ text-align: left;
127
+ }
128
+
129
+ .e_align_h_right {
130
+ text-align: right;
131
+ }
132
+
133
+ .e_align_h_center {
134
+ text-align: center;
135
+ }
136
+
137
+ .el_align_h {
138
+ text-align: justify;
139
+ }
140
+
141
+ .el_align_v {
142
+ display: flex;
143
+ align-items: center;
144
+ }
145
+
146
+
147
+ .el_align_v_bottom {
148
+ display: flex;
149
+ align-items: flex-end;
150
+ }
151
+
152
+ /*::selection {*/
153
+ /* color: transparent;*/
154
+ /* background: none;*/
155
+ /*}*/
156
+ /*!* For Mozilla Firefox *!*/
157
+ /*::-moz-selection {*/
158
+ /* color: transparent;*/
159
+ /* background: none;*/
160
+ /*}*/
161
+
162
+
@@ -0,0 +1,4 @@
1
+ # Generated by Cargo
2
+ # will have compiled files and executables
3
+ /target/
4
+
@@ -0,0 +1,27 @@
1
+ [package]
2
+ name = "atome"
3
+ version = "0.0.0"
4
+ description = "A Tauri App"
5
+ authors = ["you"]
6
+ license = ""
7
+ repository = ""
8
+ edition = "2021"
9
+ rust-version = "1.57"
10
+
11
+ # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
12
+
13
+ [build-dependencies]
14
+ tauri-build = {version = "1.2", features = [] }
15
+
16
+ [dependencies]
17
+ serde_json = "1.0"
18
+ serde = { version = "1.0", features = ["derive"] }
19
+ tauri = {version = "1.5", features = ["api-all"] }
20
+
21
+ [features]
22
+ # by default Tauri runs in production mode
23
+ # when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is an URL
24
+ default = [ "custom-protocol" ]
25
+ # this feature is used used for production builds where `devPath` points to the filesystem
26
+ # DO NOT remove this
27
+ custom-protocol = [ "tauri/custom-protocol" ]
@@ -0,0 +1,3 @@
1
+ fn main() {
2
+ tauri_build::build()
3
+ }
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,71 @@
1
+ use std::process::Command;
2
+ use std::str;
3
+ use std::fs;
4
+
5
+ // Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
6
+ #[tauri::command]
7
+ fn greet(name: &str) -> String {
8
+ format!("Hello, {}! You've been greeted from Rust!", name)
9
+ }
10
+
11
+ #[tauri::command]
12
+ fn execute_command(command: &str) -> Result<String, String> {
13
+ match Command::new("sh")
14
+ .arg("-c")
15
+ .arg(command)
16
+ .output()
17
+ {
18
+ Ok(output) => {
19
+ if output.status.success() {
20
+ Ok(str::from_utf8(&output.stdout).unwrap().to_string())
21
+ } else {
22
+ Err(str::from_utf8(&output.stderr).unwrap().to_string())
23
+ }
24
+ }
25
+ Err(error) => Err(error.to_string()),
26
+ }
27
+ }
28
+
29
+ #[tauri::command]
30
+ fn read_file(file_path: &str) -> Result<String, String> {
31
+ let content = match fs::read_to_string(file_path) {
32
+ Ok(content) => content,
33
+ Err(_) => return Err("Failed to read file.".to_string()),
34
+ };
35
+ Ok(content)
36
+ }
37
+
38
+ #[tauri::command]
39
+ fn write_file(file_path: &str, content: &str) -> Result<(), String> {
40
+ let path = std::path::Path::new(file_path);
41
+ match fs::write(path, content) {
42
+ Ok(_) => Ok(()),
43
+ Err(_) => Err("Failed to write to the file.".to_string()),
44
+ }
45
+ }
46
+
47
+ // Nouvelle commande pour lister le contenu du répertoire
48
+ #[tauri::command]
49
+ fn list_directory_content(directory_path: String) -> Result<Vec<String>, String> {
50
+ let path = std::path::Path::new(&directory_path);
51
+ match fs::read_dir(path) {
52
+ Ok(entries) => {
53
+ let entries: Vec<String> = entries
54
+ .filter_map(|entry| {
55
+ entry.ok().and_then(|e| {
56
+ e.path().file_name().and_then(std::ffi::OsStr::to_str).map(|s| s.to_owned())
57
+ })
58
+ })
59
+ .collect();
60
+ Ok(entries)
61
+ }
62
+ Err(_) => Err("Failed to read directory.".to_string()),
63
+ }
64
+ }
65
+
66
+ fn main() {
67
+ tauri::Builder::default()
68
+ .invoke_handler(tauri::generate_handler![greet, execute_command, read_file, write_file, list_directory_content])
69
+ .run(tauri::generate_context!())
70
+ .expect("error while running tauri application");
71
+ }