reactionview 0.4.1 → 0.6.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/README.md +22 -39
- data/app/assets/javascripts/reactionview-dev-tools.esm.js +59495 -2633
- data/app/assets/javascripts/reactionview-dev-tools.esm.js.map +1 -1
- data/app/assets/javascripts/reactionview-dev-tools.umd.js +59476 -2617
- data/app/assets/javascripts/reactionview-dev-tools.umd.js.map +1 -1
- data/app/assets/javascripts/reactionview.esm.js +26 -0
- data/app/assets/javascripts/reactionview.esm.js.map +1 -0
- data/lib/generators/reactionview/install_generator.rb +39 -4
- data/lib/reactionview/asset_manifest.rb +1 -1
- data/lib/reactionview/config.rb +99 -4
- data/lib/reactionview/importmap.rb +3 -0
- data/lib/reactionview/instrumentation.rb +143 -0
- data/lib/reactionview/railtie.rb +117 -5
- data/lib/reactionview/slots/dev_compiler.rb +25 -0
- data/lib/reactionview/slots/rendering.rb +157 -0
- data/lib/reactionview/slots/resolver.rb +27 -0
- data/lib/reactionview/slots/state_overrides.rb +68 -0
- data/lib/reactionview/slots.rb +38 -0
- data/lib/reactionview/template/dependencies.rb +90 -0
- data/lib/reactionview/template/handlers/erb.rb +25 -1
- data/lib/reactionview/template/handlers/herb/herb.rb +69 -57
- data/lib/reactionview/template/handlers/herb.rb +188 -13
- data/lib/reactionview/template/local_template.rb +37 -6
- data/lib/reactionview/template/partial_resolver.rb +90 -0
- data/lib/reactionview/version.rb +1 -1
- data/lib/reactionview.rb +13 -0
- data/reactionview.gemspec +3 -2
- metadata +30 -11
|
@@ -3,19 +3,50 @@
|
|
|
3
3
|
module ReActionView
|
|
4
4
|
class Template
|
|
5
5
|
module LocalTemplate
|
|
6
|
+
FRAMEWORK_TEMPLATE_SEGMENT = "/action_dispatch/middleware/templates/" #: String
|
|
7
|
+
|
|
6
8
|
private
|
|
7
9
|
|
|
10
|
+
def framework_template?(template)
|
|
11
|
+
return false unless template.respond_to?(:identifier) && template.identifier
|
|
12
|
+
|
|
13
|
+
template.identifier.to_s.include?(FRAMEWORK_TEMPLATE_SEGMENT)
|
|
14
|
+
end
|
|
15
|
+
|
|
8
16
|
def local_template?(template)
|
|
9
|
-
|
|
10
|
-
|
|
17
|
+
identifier = template_identifier(template)
|
|
18
|
+
|
|
19
|
+
return true unless identifier
|
|
20
|
+
|
|
21
|
+
app_root = application_root
|
|
22
|
+
dependencies = Dependencies.current
|
|
23
|
+
|
|
24
|
+
return false if under?(identifier, dependencies.engine_roots)
|
|
25
|
+
return false if under?(identifier, dependencies.gem_paths_outside(app_root))
|
|
26
|
+
return true if under?(identifier, dependencies.app_view_paths)
|
|
27
|
+
return true unless app_root
|
|
11
28
|
|
|
12
|
-
|
|
29
|
+
under?(identifier, [app_root])
|
|
13
30
|
end
|
|
14
31
|
|
|
15
|
-
def
|
|
16
|
-
return
|
|
32
|
+
def template_identifier(template)
|
|
33
|
+
return nil unless template.respond_to?(:identifier)
|
|
34
|
+
|
|
35
|
+
identifier = template.identifier
|
|
36
|
+
|
|
37
|
+
return nil if identifier.nil? || identifier.to_s.empty?
|
|
38
|
+
|
|
39
|
+
File.expand_path(identifier.to_s)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def application_root
|
|
43
|
+
return nil unless defined?(::Rails) && ::Rails.respond_to?(:root) && ::Rails.root
|
|
44
|
+
|
|
45
|
+
"#{File.expand_path(::Rails.root.to_s).chomp("/")}/"
|
|
46
|
+
end
|
|
17
47
|
|
|
18
|
-
|
|
48
|
+
def under?(identifier, prefixes)
|
|
49
|
+
prefixes.any? { |prefix| identifier.start_with?(prefix) }
|
|
19
50
|
end
|
|
20
51
|
end
|
|
21
52
|
end
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ReActionView
|
|
4
|
+
class Template
|
|
5
|
+
# Answers a render's partial name with the file Rails would render, across every view path the
|
|
6
|
+
# application has registered.
|
|
7
|
+
#
|
|
8
|
+
# Herb resolves partials while it compiles, to check that a render names a template that
|
|
9
|
+
# exists, to inline one, and to read the states a caller binds through `state:`. On its own it
|
|
10
|
+
# looks under a single view root, which is a fair description of an application and wrong for
|
|
11
|
+
# everything around it. Rails has the application's own paths, its engines' and its gems' all
|
|
12
|
+
# registered, in an order the application controls, and `shared/album_card` may live in any of
|
|
13
|
+
# them.
|
|
14
|
+
#
|
|
15
|
+
# This asks Herb's own resolver once per registered path, in the order Rails registered them,
|
|
16
|
+
# so the file is the one Rails would have found and the identifier is the one that file's own
|
|
17
|
+
# compile reports for itself. That last part is what a state binding keys on, so the two sides
|
|
18
|
+
# of a binding agree by construction.
|
|
19
|
+
#
|
|
20
|
+
class PartialResolver
|
|
21
|
+
#: () -> PartialResolver
|
|
22
|
+
def self.current
|
|
23
|
+
@current ||= new
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
#: () -> void
|
|
27
|
+
def self.reset!
|
|
28
|
+
@current = nil
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
#: (?project_path: untyped, ?view_paths: Array[String]?) -> void
|
|
32
|
+
def initialize(project_path: nil, view_paths: nil)
|
|
33
|
+
@project_path = project_path
|
|
34
|
+
@view_paths = view_paths
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
#: (String, ?from: untyped, ?format: String?) -> untyped
|
|
38
|
+
def resolve(name, from: nil, format: nil)
|
|
39
|
+
resolvers.each do |resolver|
|
|
40
|
+
found = resolver.resolve(name, from: from, format: format)
|
|
41
|
+
|
|
42
|
+
return found if found
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
nil
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
#: (String, ?from: untyped) -> Array[untyped]
|
|
49
|
+
def candidates(name, from: nil)
|
|
50
|
+
resolvers.flat_map { |resolver| resolver.candidates(name, from: from) }.uniq
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
#: (String, ?from: untyped, ?limit: Integer) -> Array[String]
|
|
54
|
+
def similar(name, from: nil, limit: 3)
|
|
55
|
+
resolvers.flat_map { |resolver| resolver.similar(name, from: from, limit: limit) }.uniq.first(limit)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
#: (untyped) -> String
|
|
59
|
+
def identifier_for(path)
|
|
60
|
+
resolvers.first.identifier_for(path)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
private
|
|
64
|
+
|
|
65
|
+
#: () -> Array[untyped]
|
|
66
|
+
def resolvers
|
|
67
|
+
dependencies = @view_paths ? nil : Dependencies.current
|
|
68
|
+
|
|
69
|
+
unless dependencies.equal?(@dependencies)
|
|
70
|
+
@dependencies = dependencies
|
|
71
|
+
@resolvers = nil
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
@resolvers ||= roots(dependencies).map { |root| ::Herb::Analysis::PartialResolver.new(project_path, view_root: root) }
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
#: (untyped) -> Array[String?]
|
|
78
|
+
def roots(dependencies)
|
|
79
|
+
paths = @view_paths || dependencies.view_paths
|
|
80
|
+
|
|
81
|
+
paths.empty? ? [nil] : paths
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
#: () -> untyped
|
|
85
|
+
def project_path
|
|
86
|
+
@project_path ||= ::ReActionView.config.project_path
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
data/lib/reactionview/version.rb
CHANGED
data/lib/reactionview.rb
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "active_support/deprecation"
|
|
4
|
+
|
|
3
5
|
require_relative "reactionview/version"
|
|
4
6
|
require_relative "reactionview/config"
|
|
5
7
|
|
|
@@ -17,6 +19,14 @@ require_relative "reactionview/config"
|
|
|
17
19
|
|
|
18
20
|
# require_relative "reactionview/source_annotation_extractor"
|
|
19
21
|
|
|
22
|
+
require_relative "reactionview/slots"
|
|
23
|
+
require_relative "reactionview/slots/resolver"
|
|
24
|
+
require_relative "reactionview/slots/rendering"
|
|
25
|
+
require_relative "reactionview/slots/state_overrides"
|
|
26
|
+
require_relative "reactionview/slots/dev_compiler"
|
|
27
|
+
|
|
28
|
+
require_relative "reactionview/template/dependencies"
|
|
29
|
+
require_relative "reactionview/template/partial_resolver"
|
|
20
30
|
require_relative "reactionview/template/local_template"
|
|
21
31
|
|
|
22
32
|
require_relative "reactionview/template/handlers/erb"
|
|
@@ -26,4 +36,7 @@ require_relative "reactionview/template/handlers/herb/herb"
|
|
|
26
36
|
require_relative "reactionview/railtie" if defined?(Rails::Railtie)
|
|
27
37
|
|
|
28
38
|
module ReActionView
|
|
39
|
+
def self.deprecator
|
|
40
|
+
@deprecator ||= ::ActiveSupport::Deprecation.new("1.0", "ReActionView")
|
|
41
|
+
end
|
|
29
42
|
end
|
data/reactionview.gemspec
CHANGED
|
@@ -36,6 +36,7 @@ Gem::Specification.new do |spec|
|
|
|
36
36
|
spec.require_paths = ["lib"]
|
|
37
37
|
|
|
38
38
|
spec.add_dependency "actionview", ">= 7.0"
|
|
39
|
-
spec.add_dependency "cruise"
|
|
40
|
-
spec.add_dependency "herb", ">= 0.
|
|
39
|
+
spec.add_dependency "cruise", ">= 0.3.0"
|
|
40
|
+
spec.add_dependency "herb", ">= 0.11.0"
|
|
41
|
+
spec.add_dependency "websocket", "~> 1.2"
|
|
41
42
|
end
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: reactionview
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Marco Roth
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: actionview
|
|
@@ -29,22 +29,19 @@ dependencies:
|
|
|
29
29
|
requirements:
|
|
30
30
|
- - ">="
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version:
|
|
32
|
+
version: 0.3.0
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
37
|
- - ">="
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version:
|
|
39
|
+
version: 0.3.0
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
41
41
|
name: herb
|
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
|
43
43
|
requirements:
|
|
44
44
|
- - ">="
|
|
45
|
-
- !ruby/object:Gem::Version
|
|
46
|
-
version: 0.10.4
|
|
47
|
-
- - "<"
|
|
48
45
|
- !ruby/object:Gem::Version
|
|
49
46
|
version: 0.11.0
|
|
50
47
|
type: :runtime
|
|
@@ -52,11 +49,22 @@ dependencies:
|
|
|
52
49
|
version_requirements: !ruby/object:Gem::Requirement
|
|
53
50
|
requirements:
|
|
54
51
|
- - ">="
|
|
55
|
-
- !ruby/object:Gem::Version
|
|
56
|
-
version: 0.10.4
|
|
57
|
-
- - "<"
|
|
58
52
|
- !ruby/object:Gem::Version
|
|
59
53
|
version: 0.11.0
|
|
54
|
+
- !ruby/object:Gem::Dependency
|
|
55
|
+
name: websocket
|
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - "~>"
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '1.2'
|
|
61
|
+
type: :runtime
|
|
62
|
+
prerelease: false
|
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - "~>"
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '1.2'
|
|
60
68
|
description: An ActionView-compatible ERB engine with modern DX - re-imagined with
|
|
61
69
|
Herb.
|
|
62
70
|
email:
|
|
@@ -72,18 +80,29 @@ files:
|
|
|
72
80
|
- app/assets/javascripts/reactionview-dev-tools.esm.js.map
|
|
73
81
|
- app/assets/javascripts/reactionview-dev-tools.umd.js
|
|
74
82
|
- app/assets/javascripts/reactionview-dev-tools.umd.js.map
|
|
83
|
+
- app/assets/javascripts/reactionview.esm.js
|
|
84
|
+
- app/assets/javascripts/reactionview.esm.js.map
|
|
75
85
|
- lib/generators/reactionview/install_generator.rb
|
|
76
86
|
- lib/reaction_view.rb
|
|
77
87
|
- lib/reactionview.rb
|
|
78
88
|
- lib/reactionview/asset_manifest.rb
|
|
79
89
|
- lib/reactionview/config.rb
|
|
90
|
+
- lib/reactionview/importmap.rb
|
|
91
|
+
- lib/reactionview/instrumentation.rb
|
|
80
92
|
- lib/reactionview/middleware/asset_manifest_check.rb
|
|
81
93
|
- lib/reactionview/railtie.rb
|
|
94
|
+
- lib/reactionview/slots.rb
|
|
95
|
+
- lib/reactionview/slots/dev_compiler.rb
|
|
96
|
+
- lib/reactionview/slots/rendering.rb
|
|
97
|
+
- lib/reactionview/slots/resolver.rb
|
|
98
|
+
- lib/reactionview/slots/state_overrides.rb
|
|
82
99
|
- lib/reactionview/stale_asset_manifest_error.rb
|
|
100
|
+
- lib/reactionview/template/dependencies.rb
|
|
83
101
|
- lib/reactionview/template/handlers/erb.rb
|
|
84
102
|
- lib/reactionview/template/handlers/herb.rb
|
|
85
103
|
- lib/reactionview/template/handlers/herb/herb.rb
|
|
86
104
|
- lib/reactionview/template/local_template.rb
|
|
105
|
+
- lib/reactionview/template/partial_resolver.rb
|
|
87
106
|
- lib/reactionview/version.rb
|
|
88
107
|
- reactionview.gemspec
|
|
89
108
|
- sig/reactionview.rbs
|
|
@@ -109,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
109
128
|
- !ruby/object:Gem::Version
|
|
110
129
|
version: '0'
|
|
111
130
|
requirements: []
|
|
112
|
-
rubygems_version:
|
|
131
|
+
rubygems_version: 4.0.6
|
|
113
132
|
specification_version: 4
|
|
114
133
|
summary: An ActionView-compatible ERB engine with modern DX - re-imagined with Herb.
|
|
115
134
|
test_files: []
|