hyalite 0.1.1 → 0.2.0
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/Gemfile.lock +1 -1
- data/lib/hyalite.rb +3 -1
- data/{client → lib}/hyalite/adler32.rb +0 -0
- data/{client → lib}/hyalite/browser_event.rb +0 -0
- data/{client → lib}/hyalite/callback_queue.rb +0 -0
- data/{client → lib}/hyalite/component.rb +0 -0
- data/{client → lib}/hyalite/composite_component.rb +0 -0
- data/{client → lib}/hyalite/dom.rb +0 -0
- data/{client → lib}/hyalite/dom/body.rb +0 -0
- data/{client → lib}/hyalite/dom/collection.rb +0 -0
- data/{client → lib}/hyalite/dom/document.rb +0 -0
- data/{client → lib}/hyalite/dom/element.rb +0 -0
- data/{client → lib}/hyalite/dom/event.rb +0 -0
- data/{client → lib}/hyalite/dom/event/keyboard_event.rb +0 -0
- data/{client → lib}/hyalite/dom/event/mouse_event.rb +0 -0
- data/{client → lib}/hyalite/dom/node.rb +0 -0
- data/{client → lib}/hyalite/dom/text.rb +0 -0
- data/{client → lib}/hyalite/dom_component.rb +0 -0
- data/{client → lib}/hyalite/dom_operations.rb +0 -0
- data/{client → lib}/hyalite/dom_property.rb +0 -0
- data/{client → lib}/hyalite/dom_property_operations.rb +0 -0
- data/{client → lib}/hyalite/element.rb +0 -0
- data/{client → lib}/hyalite/event_dispatcher.rb +0 -0
- data/{client → lib}/hyalite/event_plugin/change_event_plugin.rb +0 -0
- data/{client → lib}/hyalite/event_plugin/event_plugin_registry.rb +0 -0
- data/{client → lib}/hyalite/event_plugin/simple_event_plugin.rb +0 -0
- data/{client → lib}/hyalite/input_wrapper.rb +0 -0
- data/{client → lib}/hyalite/instance_handles.rb +0 -0
- data/{client → lib}/hyalite/internal_component.rb +0 -0
- data/{client → lib}/hyalite/linked_value_utils.rb +0 -0
- data/{client → lib}/hyalite/logger.rb +0 -0
- data/lib/hyalite/main.rb +120 -1
- data/{client → lib}/hyalite/mount.rb +0 -0
- data/{client → lib}/hyalite/multi_children.rb +0 -0
- data/{client → lib}/hyalite/proxy_component.rb +0 -0
- data/{client → lib}/hyalite/reconcile_transaction.rb +0 -0
- data/{client → lib}/hyalite/reconciler.rb +0 -0
- data/{client → lib}/hyalite/short_hand.rb +0 -0
- data/{client → lib}/hyalite/synthetic_event.rb +0 -0
- data/{client → lib}/hyalite/text_component.rb +0 -0
- data/{client → lib}/hyalite/transaction.rb +0 -0
- data/{client → lib}/hyalite/try.rb +0 -0
- data/{client → lib}/hyalite/update_queue.rb +0 -0
- data/{client → lib}/hyalite/updates.rb +0 -0
- data/{client → lib}/hyalite/utils.rb +0 -0
- data/lib/hyalite/version.rb +1 -1
- metadata +44 -45
- data/client/hyalite.rb +0 -123
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ae6b1e6a2f77b3ca785171db8adcffcf67ec20a
|
4
|
+
data.tar.gz: 522297bc892600075409e06fcaad2f4b83afd324
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e91782a3f0991d6a0730ed4530d3528d8da93e52516d67b22b3135c4aaa77d478335a704af26e2240f5f1e86f9566688df947a83e18dc9378e56734e879dec4e
|
7
|
+
data.tar.gz: e16dbeca13e13b18fc8bce24ee6aa09acaffc26a69c324c3d3cdc8b5bbc997f914c14f544d438315224fd3d66b09941835731cf39fd9bb00d104aab324b51082
|
data/Gemfile.lock
CHANGED
data/lib/hyalite.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/lib/hyalite/main.rb
CHANGED
@@ -1,4 +1,123 @@
|
|
1
1
|
require 'opal'
|
2
|
+
require 'hyalite/logger'
|
3
|
+
require 'hyalite/transaction'
|
4
|
+
require 'hyalite/adler32'
|
5
|
+
require 'hyalite/mount'
|
6
|
+
require 'hyalite/element'
|
7
|
+
require 'hyalite/dom_component'
|
8
|
+
require 'hyalite/text_component'
|
9
|
+
require 'hyalite/dom'
|
2
10
|
|
3
|
-
|
11
|
+
module Hyalite
|
12
|
+
class << self
|
13
|
+
RESERVED_PROPS = [:key, :ref, :children]
|
4
14
|
|
15
|
+
def create_element(type, config = nil, *children)
|
16
|
+
key = nil
|
17
|
+
ref = nil
|
18
|
+
|
19
|
+
props = {}
|
20
|
+
|
21
|
+
if config
|
22
|
+
key = config[:key]
|
23
|
+
ref = config[:ref]
|
24
|
+
|
25
|
+
config.each do |name, value|
|
26
|
+
unless RESERVED_PROPS.include?(name)
|
27
|
+
props[name] = config[name];
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
props[:children] = case children.length
|
33
|
+
when 0
|
34
|
+
nil
|
35
|
+
when 1
|
36
|
+
children.first
|
37
|
+
else
|
38
|
+
children
|
39
|
+
end
|
40
|
+
|
41
|
+
ElementObject.new(type, key, ref, Hyalite.current_owner, props)
|
42
|
+
end
|
43
|
+
|
44
|
+
def fn(&block)
|
45
|
+
Class.new {
|
46
|
+
include Component
|
47
|
+
include Component::ShortHand
|
48
|
+
|
49
|
+
def self.render_proc=(proc)
|
50
|
+
@render_proc = proc
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.render_proc
|
54
|
+
@render_proc
|
55
|
+
end
|
56
|
+
|
57
|
+
def render
|
58
|
+
self.instance_exec(@props, &self.class.render_proc)
|
59
|
+
end
|
60
|
+
}.tap{|cl| cl.render_proc = block }
|
61
|
+
end
|
62
|
+
|
63
|
+
def instantiate_component(node)
|
64
|
+
node = EmptyComponent.empty_element if node.nil?
|
65
|
+
|
66
|
+
case node
|
67
|
+
when ElementObject
|
68
|
+
case node.type
|
69
|
+
when String
|
70
|
+
DOMComponent.new node
|
71
|
+
when Class
|
72
|
+
if node.type.include?(InternalComponent)
|
73
|
+
node.type.new
|
74
|
+
elsif node.type.include?(Component)
|
75
|
+
CompositeComponent.new node
|
76
|
+
else
|
77
|
+
raise "Encountered invalid type of Hyalite node. type: #{node.type}"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
when String, Numeric
|
81
|
+
TextComponent.new node
|
82
|
+
when EmptyComponent
|
83
|
+
CompositeComponent.new node
|
84
|
+
else
|
85
|
+
raise "Encountered invalid Hyalite node: #{node}"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def render(next_element, container, &block)
|
90
|
+
case container
|
91
|
+
when DOM::Node
|
92
|
+
Mount.render_subtree_into_container(next_element, container, &block)
|
93
|
+
when Enumerable
|
94
|
+
container.each {|node| render(next_element, node, &block) }
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def instance_map
|
99
|
+
@instance_map ||= {}
|
100
|
+
end
|
101
|
+
|
102
|
+
def current_owner(current_owner = nil)
|
103
|
+
if current_owner && block_given?
|
104
|
+
begin
|
105
|
+
@current_owner = current_owner
|
106
|
+
yield(@current_owner)
|
107
|
+
ensure
|
108
|
+
@current_owner = nil
|
109
|
+
end
|
110
|
+
else
|
111
|
+
@current_owner
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def find_dom_node(component_or_element)
|
116
|
+
return component_or_element if component_or_element.respond_to?(:node_type) && component_or_element.element?
|
117
|
+
|
118
|
+
if instance_map.has_key?(component_or_element)
|
119
|
+
return Mount.node(instance_map[component_or_element].root_node_id)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/lib/hyalite/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hyalite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- youchan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opal
|
@@ -67,49 +67,6 @@ files:
|
|
67
67
|
- LICENSE.txt
|
68
68
|
- README.md
|
69
69
|
- Rakefile
|
70
|
-
- client/hyalite.rb
|
71
|
-
- client/hyalite/adler32.rb
|
72
|
-
- client/hyalite/browser_event.rb
|
73
|
-
- client/hyalite/callback_queue.rb
|
74
|
-
- client/hyalite/component.rb
|
75
|
-
- client/hyalite/composite_component.rb
|
76
|
-
- client/hyalite/dom.rb
|
77
|
-
- client/hyalite/dom/body.rb
|
78
|
-
- client/hyalite/dom/collection.rb
|
79
|
-
- client/hyalite/dom/document.rb
|
80
|
-
- client/hyalite/dom/element.rb
|
81
|
-
- client/hyalite/dom/event.rb
|
82
|
-
- client/hyalite/dom/event/keyboard_event.rb
|
83
|
-
- client/hyalite/dom/event/mouse_event.rb
|
84
|
-
- client/hyalite/dom/node.rb
|
85
|
-
- client/hyalite/dom/text.rb
|
86
|
-
- client/hyalite/dom_component.rb
|
87
|
-
- client/hyalite/dom_operations.rb
|
88
|
-
- client/hyalite/dom_property.rb
|
89
|
-
- client/hyalite/dom_property_operations.rb
|
90
|
-
- client/hyalite/element.rb
|
91
|
-
- client/hyalite/event_dispatcher.rb
|
92
|
-
- client/hyalite/event_plugin/change_event_plugin.rb
|
93
|
-
- client/hyalite/event_plugin/event_plugin_registry.rb
|
94
|
-
- client/hyalite/event_plugin/simple_event_plugin.rb
|
95
|
-
- client/hyalite/input_wrapper.rb
|
96
|
-
- client/hyalite/instance_handles.rb
|
97
|
-
- client/hyalite/internal_component.rb
|
98
|
-
- client/hyalite/linked_value_utils.rb
|
99
|
-
- client/hyalite/logger.rb
|
100
|
-
- client/hyalite/mount.rb
|
101
|
-
- client/hyalite/multi_children.rb
|
102
|
-
- client/hyalite/proxy_component.rb
|
103
|
-
- client/hyalite/reconcile_transaction.rb
|
104
|
-
- client/hyalite/reconciler.rb
|
105
|
-
- client/hyalite/short_hand.rb
|
106
|
-
- client/hyalite/synthetic_event.rb
|
107
|
-
- client/hyalite/text_component.rb
|
108
|
-
- client/hyalite/transaction.rb
|
109
|
-
- client/hyalite/try.rb
|
110
|
-
- client/hyalite/update_queue.rb
|
111
|
-
- client/hyalite/updates.rb
|
112
|
-
- client/hyalite/utils.rb
|
113
70
|
- example/Gemfile
|
114
71
|
- example/Gemfile.lock
|
115
72
|
- example/app/application.rb
|
@@ -117,7 +74,49 @@ files:
|
|
117
74
|
- example/index.html.haml
|
118
75
|
- hyalite.gemspec
|
119
76
|
- lib/hyalite.rb
|
77
|
+
- lib/hyalite/adler32.rb
|
78
|
+
- lib/hyalite/browser_event.rb
|
79
|
+
- lib/hyalite/callback_queue.rb
|
80
|
+
- lib/hyalite/component.rb
|
81
|
+
- lib/hyalite/composite_component.rb
|
82
|
+
- lib/hyalite/dom.rb
|
83
|
+
- lib/hyalite/dom/body.rb
|
84
|
+
- lib/hyalite/dom/collection.rb
|
85
|
+
- lib/hyalite/dom/document.rb
|
86
|
+
- lib/hyalite/dom/element.rb
|
87
|
+
- lib/hyalite/dom/event.rb
|
88
|
+
- lib/hyalite/dom/event/keyboard_event.rb
|
89
|
+
- lib/hyalite/dom/event/mouse_event.rb
|
90
|
+
- lib/hyalite/dom/node.rb
|
91
|
+
- lib/hyalite/dom/text.rb
|
92
|
+
- lib/hyalite/dom_component.rb
|
93
|
+
- lib/hyalite/dom_operations.rb
|
94
|
+
- lib/hyalite/dom_property.rb
|
95
|
+
- lib/hyalite/dom_property_operations.rb
|
96
|
+
- lib/hyalite/element.rb
|
97
|
+
- lib/hyalite/event_dispatcher.rb
|
98
|
+
- lib/hyalite/event_plugin/change_event_plugin.rb
|
99
|
+
- lib/hyalite/event_plugin/event_plugin_registry.rb
|
100
|
+
- lib/hyalite/event_plugin/simple_event_plugin.rb
|
101
|
+
- lib/hyalite/input_wrapper.rb
|
102
|
+
- lib/hyalite/instance_handles.rb
|
103
|
+
- lib/hyalite/internal_component.rb
|
104
|
+
- lib/hyalite/linked_value_utils.rb
|
105
|
+
- lib/hyalite/logger.rb
|
120
106
|
- lib/hyalite/main.rb
|
107
|
+
- lib/hyalite/mount.rb
|
108
|
+
- lib/hyalite/multi_children.rb
|
109
|
+
- lib/hyalite/proxy_component.rb
|
110
|
+
- lib/hyalite/reconcile_transaction.rb
|
111
|
+
- lib/hyalite/reconciler.rb
|
112
|
+
- lib/hyalite/short_hand.rb
|
113
|
+
- lib/hyalite/synthetic_event.rb
|
114
|
+
- lib/hyalite/text_component.rb
|
115
|
+
- lib/hyalite/transaction.rb
|
116
|
+
- lib/hyalite/try.rb
|
117
|
+
- lib/hyalite/update_queue.rb
|
118
|
+
- lib/hyalite/updates.rb
|
119
|
+
- lib/hyalite/utils.rb
|
121
120
|
- lib/hyalite/version.rb
|
122
121
|
homepage: https://github.com/youchan/hyalite
|
123
122
|
licenses:
|
data/client/hyalite.rb
DELETED
@@ -1,123 +0,0 @@
|
|
1
|
-
require 'opal'
|
2
|
-
require 'hyalite/logger'
|
3
|
-
require 'hyalite/transaction'
|
4
|
-
require 'hyalite/adler32'
|
5
|
-
require 'hyalite/mount'
|
6
|
-
require 'hyalite/element'
|
7
|
-
require 'hyalite/dom_component'
|
8
|
-
require 'hyalite/text_component'
|
9
|
-
require 'hyalite/dom'
|
10
|
-
|
11
|
-
module Hyalite
|
12
|
-
class << self
|
13
|
-
RESERVED_PROPS = [:key, :ref, :children]
|
14
|
-
|
15
|
-
def create_element(type, config = nil, *children)
|
16
|
-
key = nil
|
17
|
-
ref = nil
|
18
|
-
|
19
|
-
props = {}
|
20
|
-
|
21
|
-
if config
|
22
|
-
key = config[:key]
|
23
|
-
ref = config[:ref]
|
24
|
-
|
25
|
-
config.each do |name, value|
|
26
|
-
unless RESERVED_PROPS.include?(name)
|
27
|
-
props[name] = config[name];
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
props[:children] = case children.length
|
33
|
-
when 0
|
34
|
-
nil
|
35
|
-
when 1
|
36
|
-
children.first
|
37
|
-
else
|
38
|
-
children
|
39
|
-
end
|
40
|
-
|
41
|
-
ElementObject.new(type, key, ref, Hyalite.current_owner, props)
|
42
|
-
end
|
43
|
-
|
44
|
-
def fn(&block)
|
45
|
-
Class.new {
|
46
|
-
include Component
|
47
|
-
include Component::ShortHand
|
48
|
-
|
49
|
-
def self.render_proc=(proc)
|
50
|
-
@render_proc = proc
|
51
|
-
end
|
52
|
-
|
53
|
-
def self.render_proc
|
54
|
-
@render_proc
|
55
|
-
end
|
56
|
-
|
57
|
-
def render
|
58
|
-
self.instance_exec(@props, &self.class.render_proc)
|
59
|
-
end
|
60
|
-
}.tap{|cl| cl.render_proc = block }
|
61
|
-
end
|
62
|
-
|
63
|
-
def instantiate_component(node)
|
64
|
-
node = EmptyComponent.empty_element if node.nil?
|
65
|
-
|
66
|
-
case node
|
67
|
-
when ElementObject
|
68
|
-
case node.type
|
69
|
-
when String
|
70
|
-
DOMComponent.new node
|
71
|
-
when Class
|
72
|
-
if node.type.include?(InternalComponent)
|
73
|
-
node.type.new
|
74
|
-
elsif node.type.include?(Component)
|
75
|
-
CompositeComponent.new node
|
76
|
-
else
|
77
|
-
raise "Encountered invalid type of Hyalite node. type: #{node.type}"
|
78
|
-
end
|
79
|
-
end
|
80
|
-
when String, Numeric
|
81
|
-
TextComponent.new node
|
82
|
-
when EmptyComponent
|
83
|
-
CompositeComponent.new node
|
84
|
-
else
|
85
|
-
raise "Encountered invalid Hyalite node: #{node}"
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
def render(next_element, container, &block)
|
90
|
-
case container
|
91
|
-
when DOM::Node
|
92
|
-
Mount.render_subtree_into_container(next_element, container, &block)
|
93
|
-
when Enumerable
|
94
|
-
container.each {|node| render(next_element, node, &block) }
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
def instance_map
|
99
|
-
@instance_map ||= {}
|
100
|
-
end
|
101
|
-
|
102
|
-
def current_owner(current_owner = nil)
|
103
|
-
if current_owner && block_given?
|
104
|
-
begin
|
105
|
-
@current_owner = current_owner
|
106
|
-
yield(@current_owner)
|
107
|
-
ensure
|
108
|
-
@current_owner = nil
|
109
|
-
end
|
110
|
-
else
|
111
|
-
@current_owner
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
def find_dom_node(component_or_element)
|
116
|
-
return component_or_element if component_or_element.respond_to?(:node_type) && component_or_element.element?
|
117
|
-
|
118
|
-
if instance_map.has_key?(component_or_element)
|
119
|
-
return Mount.node(instance_map[component_or_element].root_node_id)
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|