Module: ReactManifest
- Defined in:
- lib/react_manifest.rb,
lib/react_manifest/railtie.rb,
lib/react_manifest/scanner.rb,
lib/react_manifest/version.rb,
lib/react_manifest/watcher.rb,
lib/react_manifest/reporter.rb,
lib/react_manifest/generator.rb,
lib/react_manifest/view_helpers.rb,
lib/react_manifest/configuration.rb,
lib/react_manifest/dependency_map.rb,
lib/react_manifest/layout_patcher.rb,
lib/react_manifest/tree_classifier.rb,
lib/react_manifest/application_analyzer.rb,
lib/react_manifest/application_migrator.rb,
lib/react_manifest/sprockets_manifest_patcher.rb
Defined Under Namespace
Modules: ViewHelpers, Watcher Classes: ApplicationAnalyzer, ApplicationMigrator, Configuration, DependencyMap, Generator, LayoutPatcher, Railtie, Reporter, Scanner, SprocketsManifestPatcher, TreeClassifier
Constant Summary collapse
- VERSION =
"0.2.18".freeze
Class Method Summary collapse
- .configuration ⇒ Object
- .configure {|configuration| ... } ⇒ Object
- .reset! ⇒ Object
-
.resolve_bundle_for_component(component_name) ⇒ Object
Resolve a controller bundle from a React component symbol.
-
.resolve_bundles(ctrl_name) ⇒ Object
Returns the ordered list of bundle logical names for a given controller.
-
.resolve_bundles_for_component(component_name) ⇒ Object
Resolve all controller bundles needed for a React component symbol.
Class Method Details
.configuration ⇒ Object
20 21 22 |
# File 'lib/react_manifest.rb', line 20 def configuration @configuration ||= Configuration.new end |
.configure {|configuration| ... } ⇒ Object
24 25 26 |
# File 'lib/react_manifest.rb', line 24 def configure yield configuration end |
.reset! ⇒ Object
28 29 30 |
# File 'lib/react_manifest.rb', line 28 def reset! @configuration = nil end |
.resolve_bundle_for_component(component_name) ⇒ Object
Resolve a controller bundle from a React component symbol.
This is primarily used to support react-rails ‘react_component` calls, where the requested component name is known and may not align 1:1 with controller_path-derived bundle names.
67 68 69 |
# File 'lib/react_manifest.rb', line 67 def resolve_bundle_for_component(component_name) resolve_bundles_for_component(component_name).last end |
.resolve_bundles(ctrl_name) ⇒ Object
Returns the ordered list of bundle logical names for a given controller. Used by the react_bundle_tag view helper.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/react_manifest.rb', line 34 def resolve_bundles(ctrl_name) config = configuration bundles = [] # 1. Shared bundle always first shared = resolve_bundle_reference(config, config.shared_bundle) bundles << shared if shared # 2. always_include bundles (e.g. ux_main) config.always_include.each do |b| resolved = resolve_bundle_reference(config, b) bundles << resolved if resolved && !bundles.include?(resolved) end # 3. Controller-specific bundle # Try fully-namespaced first: admin/users → ux_admin_users # Then drop segments: ux_admin controller_candidates(ctrl_name).each do |candidate| resolved = resolve_bundle_reference(config, candidate) if resolved && !bundles.include?(resolved) bundles << resolved break end end bundles end |
.resolve_bundles_for_component(component_name) ⇒ Object
Resolve all controller bundles needed for a React component symbol. Includes transitive controller-bundle dependencies inferred from component symbol usage across ux/app/* directories.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/react_manifest.rb', line 74 def resolve_bundles_for_component(component_name) name = component_name.to_s return [] if name.empty? config = configuration maps = component_maps(config) root_bundle = maps[:symbol_to_bundle][name] return [] unless root_bundle ordered = [] visiting = Set.new visited = Set.new walk = lambda do |bundle_name| return if visited.include?(bundle_name) || visiting.include?(bundle_name) visiting << bundle_name maps[:bundle_dependencies].fetch(bundle_name, Set.new).each { |dep| walk.call(dep) } visiting.delete(bundle_name) visited << bundle_name ordered << bundle_name end walk.call(root_bundle) ordered.filter_map { |bundle_name| resolve_bundle_reference(config, bundle_name) } end |