interfacets 0.9.99 → 0.99999
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/LICENSE +9 -17
- data/lib/interfacets/client/actor.rb +2 -1
- data/lib/interfacets/client/assets.rb +77 -64
- data/lib/interfacets/client/bus.rb +28 -9
- data/lib/interfacets/client/channels/api.rb +138 -39
- data/lib/interfacets/client/channels/audio.rb +13 -10
- data/lib/interfacets/client/channels/base.rb +2 -2
- data/lib/interfacets/client/channels/pubsub.rb +69 -0
- data/lib/interfacets/client/channels/react/builder.rb +42 -72
- data/lib/interfacets/client/channels/react/channel.rb +7 -5
- data/lib/interfacets/client/channels/react/evaluator.rb +6 -4
- data/lib/interfacets/client/channels/timer.rb +8 -7
- data/lib/interfacets/client/channels/url.rb +39 -6
- data/lib/interfacets/client/registry.rb +3 -2
- data/lib/interfacets/client/slots.rb +45 -0
- data/lib/interfacets/client/system.rb +20 -15
- data/lib/interfacets/client/template.rb +90 -0
- data/lib/interfacets/client/utils/mruby_patches.rb +7 -3
- data/lib/interfacets/client/utils/open_struct.rb +2 -4
- data/lib/interfacets/component_registry.rb +34 -29
- data/lib/interfacets/component_schema_parser.rb +8 -4
- data/lib/interfacets/mruby/build_config.rb +8 -4
- data/lib/interfacets/mruby/entrypoint.rb +2 -2
- data/lib/interfacets/server/api.rb +44 -7
- data/lib/interfacets/server/assets.rb +58 -23
- data/lib/interfacets/server/basic_router.rb +29 -19
- data/lib/interfacets/server/bus.rb +5 -6
- data/lib/interfacets/server/registry.rb +17 -10
- data/lib/interfacets/shared/basic_routable.rb +7 -4
- data/lib/interfacets/shared/entities/bus.rb +619 -185
- data/lib/interfacets/shared/entities/changeset.rb +432 -0
- data/lib/interfacets/shared/entities/collection_proxy.rb +132 -72
- data/lib/interfacets/shared/entities/specs/handlers.rb +58 -37
- data/lib/interfacets/shared/entities/specs.rb +184 -18
- data/lib/interfacets/shared/entity.rb +113 -23
- data/lib/interfacets/shared/entity_dsl.rb +138 -20
- data/lib/interfacets/shared/facet.rb +128 -68
- data/lib/interfacets/shared/generated_store.rb +69 -34
- data/lib/interfacets/shared/refreshable.rb +85 -0
- data/lib/interfacets/shared/utils.rb +36 -32
- data/lib/interfacets/shared/validations.rb +746 -26
- data/lib/interfacets/shared/view.rb +74 -28
- data/lib/interfacets/test/component_registry.rb +31 -12
- data/lib/interfacets/test/js/inline_bus.rb +51 -25
- data/lib/interfacets/test/js/nodo_bus.rb +21 -10
- data/lib/interfacets/test/js/receivers/api.rb +14 -12
- data/lib/interfacets/test/js/receivers/audio.rb +61 -0
- data/lib/interfacets/test/js/receivers/pubsub.rb +50 -0
- data/lib/interfacets/test/js/receivers/react/node/xml_parser.rb +33 -5
- data/lib/interfacets/test/js/receivers/react/node.rb +69 -15
- data/lib/interfacets/test/js/receivers/react.rb +13 -4
- data/lib/interfacets/test/js/receivers/timer.rb +12 -8
- data/lib/interfacets/test/js/receivers/url.rb +47 -11
- data/lib/interfacets/test/ui_simulator.rb +88 -18
- data/lib/interfacets/test/validation_engine.rb +82 -49
- data/lib/interfacets/test.rb +1 -3
- data/lib/interfacets/version.rb +1 -1
- data/lib/interfacets.rb +11 -3
- metadata +31 -28
- data/.rubocop.yml +0 -180
- data/.tmp +0 -5
- data/LICENSE.txt +0 -21
- data/Rakefile +0 -14
- data/lib/interfacets/client/channels/page_visibility.rb +0 -21
- data/lib/interfacets/client/channels/react/dom.rb +0 -91
- data/lib/interfacets/client/channels/speech_to_text.rb +0 -100
- data/lib/interfacets/client/config.rb +0 -22
- data/lib/interfacets/client/delegator.rb +0 -37
- data/lib/interfacets/server/assets/facet.rb +0 -63
- data/lib/interfacets/server/config.rb +0 -87
- data/lib/interfacets/server/facets/deserializer.rb +0 -25
- data/lib/interfacets/server/facets/schema/serializer.rb +0 -54
- data/lib/interfacets/server/facets/serializer.rb +0 -50
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Interfacets
|
|
4
|
-
module Server
|
|
5
|
-
module Assets
|
|
6
|
-
class Facet
|
|
7
|
-
def self.register(klass:, assets:)
|
|
8
|
-
assets[klass.name] = new(klass).code
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
attr_reader :klass
|
|
12
|
-
def initialize(klass)
|
|
13
|
-
@klass = klass
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def code
|
|
17
|
-
# nest it all so names resolve
|
|
18
|
-
*mods, klass_name = klass.name.split("::")
|
|
19
|
-
|
|
20
|
-
headers = []
|
|
21
|
-
footers = []
|
|
22
|
-
|
|
23
|
-
current_mod = ""
|
|
24
|
-
mods.each do |mod_name|
|
|
25
|
-
current_mod += "::#{mod_name}"
|
|
26
|
-
type = current_mod.constantize.is_a?(Class) ? :class : :module
|
|
27
|
-
headers << "#{type} #{mod_name}"
|
|
28
|
-
footers << "end"
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
headers << "class #{klass_name}"
|
|
32
|
-
headers << " include Interfacets::Shared::Facet"
|
|
33
|
-
footers << "end"
|
|
34
|
-
|
|
35
|
-
<<~TXT
|
|
36
|
-
#{headers.join("\n")}
|
|
37
|
-
|
|
38
|
-
include Interfacets::Shared::Facets::Schema
|
|
39
|
-
|
|
40
|
-
view_spec #{write_source(klass.client_config.view.block)}
|
|
41
|
-
|
|
42
|
-
entity_spec #{write_source(klass.client_config.api.block)}
|
|
43
|
-
|
|
44
|
-
client_spec #{write_source(klass.client_config.entity.block)}
|
|
45
|
-
#{footers.join("\n")}
|
|
46
|
-
TXT
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
private
|
|
50
|
-
|
|
51
|
-
def write_source(block)
|
|
52
|
-
return unless block
|
|
53
|
-
|
|
54
|
-
RubyVM::AbstractSyntaxTree
|
|
55
|
-
.of(block, keep_script_lines: true)
|
|
56
|
-
.source
|
|
57
|
-
.strip
|
|
58
|
-
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
end
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Interfacets
|
|
4
|
-
module Server
|
|
5
|
-
class Config
|
|
6
|
-
attr_reader :registry
|
|
7
|
-
attr_accessor(
|
|
8
|
-
:mount_point,
|
|
9
|
-
:host,
|
|
10
|
-
)
|
|
11
|
-
|
|
12
|
-
def initialize(
|
|
13
|
-
mount_point:,
|
|
14
|
-
registry:,
|
|
15
|
-
assets:
|
|
16
|
-
)
|
|
17
|
-
@mount_point = mount_point
|
|
18
|
-
@registry = registry
|
|
19
|
-
@assets = assets
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def bundled_assets
|
|
23
|
-
dirs = @assets.map(&:to_s)
|
|
24
|
-
|
|
25
|
-
facets = (
|
|
26
|
-
@registry
|
|
27
|
-
.values
|
|
28
|
-
.map { Object.const_get(_1) }
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
Interfacets::Server::Assets.bundle(dirs:, facets:)
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def schema
|
|
35
|
-
@facet_registry
|
|
36
|
-
.values
|
|
37
|
-
.map { Object.const_get(_1) }
|
|
38
|
-
.then {
|
|
39
|
-
Interfacets::Shared::Facets::Schema::Serializer
|
|
40
|
-
.call(facets: _1)
|
|
41
|
-
}
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def register_facet(name, class_or_class_name)
|
|
45
|
-
# if klass.name is nil, then just use the class reference
|
|
46
|
-
@facet_registry[name] = class_or_class_name
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def all_facets
|
|
50
|
-
@facet_registry.keys.map { facet(_1) }
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def default_facet
|
|
54
|
-
build_facet(facet_uid: @default_facet)
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
def facet(name)
|
|
58
|
-
klass_name = (
|
|
59
|
-
if @facet_registry.key?(name)
|
|
60
|
-
@facet_registry.fetch(name)
|
|
61
|
-
elsif @facet_registry.values.include?(name)
|
|
62
|
-
name
|
|
63
|
-
else
|
|
64
|
-
raise("unknown facet_class: #{name}")
|
|
65
|
-
end
|
|
66
|
-
)
|
|
67
|
-
|
|
68
|
-
klass_name.constantize
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def ingest_facet(data)
|
|
72
|
-
Facets::Deserializer.call(data:, config: self)
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
def build_facet(facet_uid: nil, name: nil, id: nil, query: {})
|
|
76
|
-
if name
|
|
77
|
-
facet(name).build(id, query:)
|
|
78
|
-
elsif @facet_registry.key?(facet_uid)
|
|
79
|
-
facet(facet_uid).build(nil, query:)
|
|
80
|
-
else
|
|
81
|
-
*name, id = facet_uid.split("/")
|
|
82
|
-
facet(name.join("/")).build(id, query:)
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
end
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Interfacets
|
|
4
|
-
module Server
|
|
5
|
-
module Facets
|
|
6
|
-
class Deserializer
|
|
7
|
-
class << self
|
|
8
|
-
def call(data:, config:)
|
|
9
|
-
facet_class_name = data.fetch("facet_class")
|
|
10
|
-
attributes = data.fetch("attributes")
|
|
11
|
-
|
|
12
|
-
facet = (
|
|
13
|
-
config
|
|
14
|
-
.facet(facet_class_name)
|
|
15
|
-
.build(attributes.fetch("id"))
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
facet.entity.ingest(attributes)
|
|
19
|
-
facet
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Interfacets
|
|
4
|
-
module Server
|
|
5
|
-
module Facets
|
|
6
|
-
module Schema
|
|
7
|
-
class Serializer
|
|
8
|
-
def self.call(...)
|
|
9
|
-
new(...).call
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
private attr_reader(:facets, :schema)
|
|
13
|
-
def initialize(facets:)
|
|
14
|
-
@facets = facets
|
|
15
|
-
@schema = { views: {}, entities: {}, apis: {} }
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def call
|
|
19
|
-
facets.each do |facet|
|
|
20
|
-
config = facet.client_config
|
|
21
|
-
|
|
22
|
-
schema[:views][config.view.name] = {
|
|
23
|
-
body: write_source(config.view.block),
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
schema[:entities][config.entity.name] = {
|
|
27
|
-
api_type: config.api.name,
|
|
28
|
-
body: write_source(config.entity.block),
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
schema[:apis][config.api.name] = {
|
|
32
|
-
body: write_source(config.api.block),
|
|
33
|
-
}
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
schema
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
private
|
|
40
|
-
|
|
41
|
-
def write_source(block)
|
|
42
|
-
return unless block
|
|
43
|
-
|
|
44
|
-
RubyVM::AbstractSyntaxTree
|
|
45
|
-
.of(block, keep_script_lines: true)
|
|
46
|
-
.source
|
|
47
|
-
.then { block.is_a?(UnboundMethod) ? _1 : "lambda #{_1}" }
|
|
48
|
-
.strip
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Interfacets
|
|
4
|
-
module Server
|
|
5
|
-
module Facets
|
|
6
|
-
class Serializer
|
|
7
|
-
def self.call(...)
|
|
8
|
-
new(...).call
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
attr_reader :facet, :mount_point
|
|
12
|
-
def initialize(facet, mount_point)
|
|
13
|
-
@facet = facet
|
|
14
|
-
@mount_point = mount_point
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def call
|
|
18
|
-
{
|
|
19
|
-
id: facet.entity.id,
|
|
20
|
-
facet_class: facet.class.name,
|
|
21
|
-
attributes: facet.entity.serialize,
|
|
22
|
-
}
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def attributes(entity)
|
|
26
|
-
entity
|
|
27
|
-
.attribute_specs
|
|
28
|
-
.each_with_object({}) { |(name, _attribute), json|
|
|
29
|
-
# refactor this, shouldn't be attributes...
|
|
30
|
-
# next if attribute.is_a?(Facets::Attributes::ClientEvent)
|
|
31
|
-
# next if attribute.is_a?(Facets::Attributes::ServerEvent)
|
|
32
|
-
# next if attribute.is_a?(Facets::Attributes::Inherit)
|
|
33
|
-
|
|
34
|
-
value = entity.public_send(name)
|
|
35
|
-
|
|
36
|
-
json[name] = (
|
|
37
|
-
if value.is_a?(Array)
|
|
38
|
-
value.map { _1.is_a?(Entity) || _1.is_a?(Facet::Handler) ? attributes(_1) : _1 }
|
|
39
|
-
elsif value.is_a?(Entity) || value.is_a?(Facet::Handler)
|
|
40
|
-
attributes(value)
|
|
41
|
-
else
|
|
42
|
-
value
|
|
43
|
-
end
|
|
44
|
-
)
|
|
45
|
-
}
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|