Class: Zui::TreeShaker
- Inherits:
-
Object
- Object
- Zui::TreeShaker
- Defined in:
- lib/zui/tree_shaker.rb
Defined Under Namespace
Classes: Report
Constant Summary collapse
- CONFIG_FILE =
".zui-bundle.json"- EXCLUDED_SOURCE_DIRECTORIES =
%w[.git dist node_modules spec test tmp vendor].freeze
- EXCLUDED_SOURCE_FILES =
%w[config.rb].freeze
- BASE_COMPONENTS =
%i[container].freeze
- RUBY_ONLY_DSL_METHODS =
%w[animation state].freeze
- COMPONENT_DISPATCH_METHODS =
%w[component dynamic qml_component send public_send widget].freeze
- BASE_QML_MODULES =
%w[ QML QtCore QtQml QtQml.Models QtQml.WorkerScript QtQuick QtQuick.Window QtQuick.Controls QtQuick.Controls.impl QtQuick.Controls.Basic QtQuick.Controls.Basic.impl QtQuick.Controls.Fusion QtQuick.Controls.Fusion.impl QtQuick.Layouts QtQuick.Templates ].freeze
- IMAGE_COMPONENTS =
%i[ alert_dialog animated_image avatar border_image carousel image menu navigation_rail tab_button vector_animation vector_image ].freeze
- NETWORK_COMPONENTS =
(IMAGE_COMPONENTS + %i[audio media_player video]).freeze
- TEXT_INPUT_COMPONENTS =
%i[ color_picker date_picker double_spin_box file_picker folder_picker font_picker number_field password_field search_field spin_box text_area text_field time_picker ].freeze
Instance Method Summary collapse
-
#initialize(project:, framework:, native:, platform: Platform.current) ⇒ TreeShaker
constructor
A new instance of TreeShaker.
- #shake! ⇒ Object
Constructor Details
#initialize(project:, framework:, native:, platform: Platform.current) ⇒ TreeShaker
Returns a new instance of TreeShaker.
48 49 50 51 52 53 54 |
# File 'lib/zui/tree_shaker.rb', line 48 def initialize(project:, framework:, native:, platform: Platform.current) @project = File.(project) @framework = File.(framework) @native = File.(native) @platform = platform.assert_supported! @warnings = [] end |
Instance Method Details
#shake! ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/zui/tree_shaker.rb', line 56 def shake! before_bytes = tree_bytes(@framework) + tree_bytes(@native) components, adapters = analyze_components prune_framework(adapters) imports = qml_imports(Dir[File.join(@framework, "**", "*.qml")]) qml_modules = prune_native_qml(imports) prune_native_plugins(components, qml_modules) prune_translations prune_native_libraries update_client_manifest(components, qml_modules) after_bytes = tree_bytes(@framework) + tree_bytes(@native) Report.new(components: components.sort, qml_modules: qml_modules.sort, before_bytes:, after_bytes:, warnings: @warnings.dup.freeze) end |