view_component 4.0.0.alpha7 → 4.0.0.rc1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8be3a213c479ad3bc1cb82fad0a04b6b9a3f424a4995e0162e447c50cd6b0ef9
4
- data.tar.gz: a7744949cc46b57628a55e78bb0bd766f048f140c8ca1769c271032e9d648176
3
+ metadata.gz: 7a112fdf735637f91b77151d96244fac83f0d78141df7a2a0ff8f2d72d0df2d0
4
+ data.tar.gz: 39c33408d7f256dc0da92edb17ca18460d776e6f1be89ba63d28e3ea102f8ba9
5
5
  SHA512:
6
- metadata.gz: 13776ebd6447652ce0ad682a40bc70a4141b6b2db8690c32d7191828adbe9fd16ec8d30775007b29ff4c71bc559317cc56b60c94ab2af67ef4d259ea89ec3220
7
- data.tar.gz: 2463587d1336f2b30e17e51f728526157c27752adb66bbc3703d20b68326d20eb734ee2990c7583866723ba3d927564d22ea6ddd9c0a70e515264043ce1d08d6
6
+ metadata.gz: b4c4f99335d6c2be623f1bd167e3d27567a7093acb388be1c245a6652423e4cc0ee8a16946da2d5ca9d35dd0283fecb1647888def129ec6fb75b82f427379558
7
+ data.tar.gz: 0ccb738fb45917ee49886ad2b1359a9bd3d98bf86d7e25f81422cffa5390514fe45d254a1e2d5900b6aa5649f428fa512d6a26c6d486d67546da8729dcc0d26f
data/docs/CHANGELOG.md CHANGED
@@ -10,6 +10,81 @@ nav_order: 6
10
10
 
11
11
  ## main
12
12
 
13
+ ## 4.0.0.rc1
14
+
15
+ Almost six years after releasing [v1.0.0](https://github.com/ViewComponent/view_component/releases/tag/v1.0.0), we're proud to ship the first release candidate of ViewComponent 4. This release marks a shift towards a Long Term Support model for the project, having reached significant feature maturity. While contributions are always welcome, we're unlikely to accept further breaking changes or major feature additions.
16
+
17
+ Please report any issues at [https://github.com/ViewComponent/view_component/issues](https://github.com/ViewComponent/view_component/issues).
18
+
19
+ ### Breaking changes (production)
20
+
21
+ * Remove dependency on `ActionView::Base`, eliminating the need for capture compatibility patch. In some edge cases, this change may require switching to use the `helpers.` proxy.
22
+ * Require [non-EOL](https://endoflife.date/rails) Rails (`>= 7.1.0`) and Ruby (`>= 3.2.0`).
23
+ * Remove `render_component` and `render` monkey patch configured with `render_monkey_patch_enabled`.
24
+ * Remove deprecated `use_helper(s)`. Use `include MyHelper` or `helpers.` proxy instead.
25
+ * Support compatibility with `Dry::Initializer`. As a result, `EmptyOrInvalidInitializerError` will no longer be raised.
26
+ * Remove default initializer from `ViewComponent::Base`. Previously, `ViewComponent::Base` defined a catch-all initializer that allowed components without an initializer defined to be passed arbitrary arguments.
27
+ * Remove `use_deprecated_instrumentation_name` configuration option. Events will always use `render.view_component` name.
28
+ * Remove unnecessary `#format` methods that returned `nil`.
29
+ * Remove support for variant names containing `.` to be consistent with Rails.
30
+ * Rename internal methods to have `__vc_` prefix if they shouldn't be used by consumers. Make internal constants private. Make `Collection#components`, `Slotable#register_polymorphic_slot` private. Remove unused `ComponentError` class.
31
+ * Use ActionView's `lookup_context` for picking templates instead of the request format.
32
+
33
+ 3.15 added support for using templates that match the request format, that is if `/resource.csv` is requested then
34
+ ViewComponents would pick `_component.csv.erb` over `_component.html.erb`.
35
+
36
+ With this release, the request format is no longer considered and instead ViewComponent will use the Rails logic for picking the most appropriate template type, that is the csv template will be used if it matches the `Accept` header or because the controller uses a `respond_to` block to pick the response format.
37
+
38
+ ### Breaking changes (dev/test)
39
+
40
+ * Rename `config.generate.component_parent_class` to `config.generate.parent_class`.
41
+ * Remove `config.test_controller` in favor of `vc_test_controller_class` test helper method.
42
+ * `config.component_parent_class` is now `config.generate.component_parent_class`, moving the generator-specific option to the generator configuration namespace.
43
+ * Move previews-related configuration (`enabled`, `route`, `paths`, `default_layout`, `controller`) to under `previews` namespace.
44
+ * `config.view_component_path` is now `config.generate.path`, as components have long since been able to exist in any directory.
45
+ * `--inline` generator option now generates inline template. Use `--call` to generate `#call` method.
46
+ * Remove broken integration with `rails stats` that ignored components outside of `app/components`.
47
+ * Remove `preview_source` functionality. Consider using [Lookbook](https://lookbook.build/) instead.
48
+ * Use `Nokogiri::HTML5` instead of `Nokogiri::HTML4` for test helpers.
49
+ * Move generators to a ViewComponent namespace.
50
+
51
+ Before, ViewComponent generators pollute the generator namespace with a bunch of top level items, and claim the generic "component" name.
52
+
53
+ Now, generators live in a "view_component" module/namespace, so what was before `rails g
54
+ component` is now `rails g view_component:component`.
55
+
56
+ ### New features
57
+
58
+ * Add `SystemSpecHelpers` for use with RSpec.
59
+ * Add support for including `Turbo::StreamsHelper`.
60
+ * Add template annotations for components with `def call`.
61
+ * Graduate `SlotableDefault` to be included by default.
62
+ * Add `#current_template` accessor and `Template#path` for diagnostic usage.
63
+ * Reduce string allocations during compilation.
64
+
65
+ ### Bug fixes
66
+
67
+ * Fix bug where virtual path wasn't reset, breaking translations outside of components.
68
+ * Fix bug where `config.previews.enabled` didn't function properly in production environments.
69
+ * Fix bug where response format wasn't set, which caused issues with Turbo Frames.
70
+ * Fix bug in `SlotableDefault` where default couldn't be overridden when content was passed as a block.
71
+ * Fix bug where request-aware helpers didn't work outside of the request context.
72
+ * `ViewComponentsSystemTestController` shouldn't be useable outside of test environment
73
+
74
+ ### Non-functional changes
75
+
76
+ * Remove unnecessary usage of `ruby2_keywords`.
77
+ * Remove unnecessary `respond_to` checks.
78
+ * Require MFA when publishing to RubyGems.
79
+ * Clean up project dependencies, relaxing versions of development gems.
80
+ * Add test case for absolute URL path helpers in mailers.
81
+ * Update documentation on performance to reflect more representative benchmark showing 2-3x speed increase over partials.
82
+ * Add documentation note about instrumentation negatively affecting performance.
83
+ * Remove unnecessary ENABLE_RELOADING test suite flag.
84
+ * `config.previews.default_layout` should default to nil.
85
+ * Add test coverage for uncovered code.
86
+ * Test against `turbo-rails` `v2` and `rspec-rails` `v7`.
87
+
13
88
  ## 4.0.0.alpha7
14
89
 
15
90
  * BREAKING: Remove deprecated `use_helper(s)`. Use `include MyHelper` or `helpers.` proxy instead.
@@ -24,7 +99,7 @@ nav_order: 6
24
99
 
25
100
  *Joel Hawksley*
26
101
 
27
- * Fix bug where `config.previews.enabled` did not function properly in production environments.
102
+ * Fix bug where `config.previews.enabled` didn't function properly in production environments.
28
103
 
29
104
  *Joel Hawksley*
30
105
 
@@ -159,11 +234,11 @@ This release makes the following breaking changes:
159
234
 
160
235
  * BREAKING: Use ActionView's `lookup_context` for picking templates instead of the request format.
161
236
 
162
- 3.15 added support for using templates that match the request format, i.e. if `/resource.csv` is requested then
237
+ 3.15 added support for using templates that match the request format, that is if `/resource.csv` is requested then
163
238
  ViewComponents would pick `_component.csv.erb` over `_component.html.erb`.
164
239
 
165
240
  With this release, the request format is no longer considered and instead ViewComponent will use the Rails logic
166
- for picking the most appropriate template type, i.e. the csv template will be used if it matches the `Accept` header
241
+ for picking the most appropriate template type, that is the csv template will be used if it matches the `Accept` header
167
242
  or because the controller uses a `respond_to` block to pick the response format.
168
243
 
169
244
  *Stephen Nelson*
@@ -172,11 +247,11 @@ This release makes the following breaking changes:
172
247
 
173
248
  *Joel Hawksley*
174
249
 
175
- * Fix bug where request-aware helpers did not work outside of the request context.
250
+ * Fix bug where request-aware helpers didn't work outside of the request context.
176
251
 
177
252
  *Joel Hawksley*, *Stephen Nelson*
178
253
 
179
- * `ViewComponentsSystemTestController` should not be useable outside of test environment
254
+ * `ViewComponentsSystemTestController` shouldn't be useable outside of test environment
180
255
 
181
256
  *Joel Hawksley*, *Stephen Nelson*
182
257
 
@@ -108,6 +108,7 @@ module ViewComponent
108
108
  self.class.__vc_compile(raise_errors: true)
109
109
 
110
110
  @view_context = view_context
111
+ old_virtual_path = view_context.instance_variable_get(:@virtual_path)
111
112
  self.__vc_original_view_context ||= view_context
112
113
 
113
114
  @output_buffer = view_context.output_buffer
@@ -140,6 +141,8 @@ module ViewComponent
140
141
  value = nil
141
142
 
142
143
  @output_buffer.with_buffer do
144
+ @view_context.instance_variable_set(:@virtual_path, virtual_path)
145
+
143
146
  rendered_template = render_template_for(@__vc_requested_details).to_s
144
147
 
145
148
  # Avoid allocating new string when output_preamble and output_postamble are blank
@@ -160,6 +163,7 @@ module ViewComponent
160
163
  ""
161
164
  end
162
165
  ensure
166
+ view_context.instance_variable_set(:@virtual_path, old_virtual_path)
163
167
  @current_template = old_current_template
164
168
  end
165
169
 
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ViewComponent
4
+ module SystemSpecHelpers
5
+ include SystemTestHelpers
6
+
7
+ def page
8
+ Capybara.current_session
9
+ end
10
+ end
11
+ end
@@ -98,9 +98,8 @@ module ViewComponent
98
98
  @component.silence_redefinition_of_method(call_method_name)
99
99
 
100
100
  # rubocop:disable Style/EvalWithLocation
101
- @component.class_eval <<~RUBY, @path, @lineno - 1
101
+ @component.class_eval <<~RUBY, @path, @lineno
102
102
  def #{call_method_name}
103
- @view_context.instance_variable_set(:@virtual_path, virtual_path)
104
103
  #{compiled_source}
105
104
  end
106
105
  RUBY
@@ -5,7 +5,7 @@ module ViewComponent
5
5
  MAJOR = 4
6
6
  MINOR = 0
7
7
  PATCH = 0
8
- PRE = "alpha7"
8
+ PRE = "rc1"
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join(".")
11
11
  end
@@ -18,6 +18,7 @@ module ViewComponent
18
18
 
19
19
  if Rails.env.test?
20
20
  autoload :TestHelpers
21
+ autoload :SystemSpecHelpers
21
22
  autoload :SystemTestHelpers
22
23
  autoload :TestCase
23
24
  autoload :SystemTestCase
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: view_component
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0.alpha7
4
+ version: 4.0.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ViewComponent Team
@@ -75,6 +75,7 @@ files:
75
75
  - lib/view_component/request_details.rb
76
76
  - lib/view_component/slot.rb
77
77
  - lib/view_component/slotable.rb
78
+ - lib/view_component/system_spec_helpers.rb
78
79
  - lib/view_component/system_test_case.rb
79
80
  - lib/view_component/system_test_helpers.rb
80
81
  - lib/view_component/template.rb
@@ -88,6 +89,7 @@ licenses:
88
89
  - MIT
89
90
  metadata:
90
91
  allowed_push_host: https://rubygems.org
92
+ rubygems_mfa_required: 'true'
91
93
  source_code_uri: https://github.com/viewcomponent/view_component
92
94
  changelog_uri: https://github.com/ViewComponent/view_component/blob/main/docs/CHANGELOG.md
93
95
  rdoc_options: []