Top Level Namespace

Defined Under Namespace

Modules: Color, Essentials, JS, Molecule, ObjectExtension Classes: Atome, Black_matter, CssProxy, Genesis, HTML, Headless, Object, Universe

Constant Summary collapse

A =

the constant A is used to access alla atomes methods

Atome.new(
  { renderers: default_render, id: :atome, type: :element, tag: { system: true } }
)

Instance Method Summary collapse

Instance Method Details

#alert(val) ⇒ Object

main add on



4
5
6
7
8
# File 'lib/platform_specific/opal/extensions/object.rb', line 4

def alert(val)
  val = val.to_s
  escaped_val = val.gsub("'", "\\\\'")
  JS.eval("alert('#{escaped_val}')")
end

#atome_genesisObject

the method below init the user



145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/atome/genesis/sparkle.rb', line 145

def atome_genesis
  atome_infos
  server = Universe.current_server
  server ||= 'disconnected'
  puts "server: #{server}"
  return unless server.start_with?('http') && Atome::host.to_sym != :tauri
  Universe.connected = true
  A.server({ address: 'localhost:9292', type: 'ws' })
  A.init_websocket do |msg|
    puts "websocket initialised #{msg}"
  end
  Universe.allow_sync = true
end

#atome_infosObject

atome infos



106
107
108
109
110
111
112
113
114
115
116
# File 'lib/atome/genesis/sparkle.rb', line 106

def atome_infos
  puts "atome version: #{Atome::VERSION}"
  puts "device identity: #{Atome::aui}"
  puts "application identity: #{Universe.app_identity}"
  puts "host framework: #{Atome::host}"
  puts "engine: #{Universe.engine}"
  puts "users: #{Universe.users}"
  puts "current user: #{Universe.current_user}"
  puts "machine: #{Universe.current_machine}"
  puts "connected: #{Universe.connected}"
end

#attachment_common(child_id, parents_id, direction, &user_proc) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/atome/genesis/particles/hierarchy.rb', line 10

def attachment_common(child_id, parents_id, direction, &user_proc)

  parent_found = grab(parents_id)
  if direction == :attach
    if parent_found
      parent_found.fasten ||= []
      parent_found.fasten.push(@id) unless parent_found.fasten.include?(@id)
      detach_child(self)
      render(:attach, parents_id, &user_proc)
    end
  else
    child_found = grab(child_id)
    child_found.attach(parents_id)
    child_found.render(:attach, parents_id, &user_proc)
  end
end

#delete_recursive(atome_id, force = false) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/atome/genesis/particles/utility.rb', line 2

def delete_recursive(atome_id, force=false)
  return if grab(atome_id).tag && (grab(atome_id).tag[:persistent] || grab(atome_id).tag[:system]) unless force
  touch(false)
  parent_id_found = grab(atome_id).attach
  parent_found = grab(parent_id_found)
  new_array = parent_found.fasten.dup
  new_array.delete(atome_id)
  parent_found.instance_variable_set('@fasten', new_array)
  grab(atome_id).fasten.each do |atome_id_found|
    delete_recursive(atome_id_found, force)
  end
  grab(atome_id).render(:delete, { :recursive => true })
  grab(atome_id).touch(false)
  Universe.delete(grab(atome_id).aid)
end

#detach_child(child) ⇒ Object



2
3
4
5
6
7
8
# File 'lib/atome/genesis/particles/hierarchy.rb', line 2

def detach_child(child)
  return unless child.attach

  parent = grab(child.attach)
  parent.fasten.delete(@id)

end

#extract_rgb_alpha(color_string) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/atome/genesis/particles/property.rb', line 3

def extract_rgb_alpha(color_string)
  match_data = color_string.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)/)
  red = match_data[1].to_i
  green = match_data[2].to_i
  blue = match_data[3].to_i
  alpha = match_data[4] ? match_data[4].to_f : nil
  { red: red, green: green, blue: blue, alpha: alpha }

end

#init_databaseObject

this method is call from JS (atome/communication) at WS connection



160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# File 'lib/atome/genesis/sparkle.rb', line 160

def init_database
  # we init the db file eDen
  A.sync({ action: :init_db, data: { database: :eDen } }) do |data|
    Universe.database_ready = data[:data][:message] == 'database_ready'
  end
  # now we populate the DB
  A.sync({ action: :create_db_table, data: { table: :user, type: :string } }) do |_db_state|
  end
  A.sync({ action: :create_db_table, data: { table: :atome } }) do |_db_state|
  end

  A.sync({ action: :create_db_table, data: { table: :history } }) do |_db_state|
  end

  A.sync({ action: :create_db_column, data: { table: :user, column: :email, type: :string, unique: true } }) do |_db_state|
  end
  A.sync({ action: :create_db_column, data: { table: :user, column: :password, type: :string } }) do |_db_state|
  end
  A.sync({ action: :create_db_column, data: { table: :history, column: :aid, type: :string } }) do |_db_state|
  end
  A.sync({ action: :create_db_column, data: { table: :history, column: :particle, type: :string } }) do |_db_state|
  end
  A.sync({ action: :create_db_column, data: { table: :history, column: :value, type: :string } }) do |_db_state|
  end
  A.sync({ action: :create_db_column, data: { table: :history, column: :date, type: :datetime } }) do |_db_state|
  end

  # now we send localstorage content to the server
  Atome.send_localstorage_content

end

#Native(obj) ⇒ Object

dummy object to allow code parity with Opal when using Native Object with wasm



10
11
12
# File 'lib/platform_specific/wasm/atome_wasm_extensions.rb', line 10

def Native(obj)
  obj
end

#receptor(msg) ⇒ Object

method below are used for communication with native core



31
32
33
34
# File 'lib/atome/genesis/particles/communication.rb', line 31

def receptor(msg)
  parsed = JSON.parse(msg)
  A.controller_code[:controller].call(parsed)
end

#touch_handle_non_hash_params(params, user_bloc) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/atome/genesis/particles/event.rb', line 51

def touch_handle_non_hash_params(params, user_bloc)
  case params
  when true, :touch, :tap
    (@touch_code[:tap] ||= []) << user_bloc
    :tap
  when :down
    (@touch_code[:down] ||= []) << user_bloc
    :down
  when :up
    (@touch_code[:up] ||= []) << user_bloc
    :up
  when :long
    (@touch_code[:hold] ||= []) << user_bloc
    :long
  when :double
    (@touch_code[:doubletap] ||= []) << user_bloc
    :double
  when false
    (@touch_code[:remove] ||= []) << user_bloc
    :remove
  else
    (@touch_code[:tap] ||= []) << user_bloc
    :tap
  end
end

#user_loginObject



192
193
194
195
196
197
198
199
200
201
# File 'lib/atome/genesis/sparkle.rb', line 192

def 
  password = Black_matter.password
  sync({ action: :authentication, data: { email: '[email protected]' } }) do |email|
    puts "email received : #{email}"
  end
  sync({ action: :authorization, data: { password: password } }) do |pass|
    puts "password received : #{pass}"
  end

end