lookbook 1.5.2 → 2.0.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -24
- data/app/assets/lookbook/css/lookbook.css +9 -0
- data/app/assets/lookbook/css/themes/blue.css +7 -0
- data/app/assets/lookbook/css/themes/green.css +7 -0
- data/app/assets/lookbook/css/themes/indigo.css +7 -0
- data/app/assets/lookbook/css/themes/rose.css +7 -0
- data/app/assets/lookbook/css/themes/zinc.css +7 -0
- data/app/assets/lookbook/css/tooltip.css +9 -6
- data/app/assets/lookbook/img/lucide-sprite.svg +4960 -0
- data/app/assets/lookbook/js/app.js +22 -4
- data/app/assets/lookbook/js/helpers/dom.js +4 -7
- data/app/assets/lookbook/js/helpers/string.js +4 -11
- data/app/assets/lookbook/js/{embed.js → iframe.js} +0 -0
- data/app/assets/lookbook/js/index.js +61 -0
- data/app/assets/lookbook/js/lib/lookbook.js +113 -0
- data/app/assets/lookbook/js/lib/tippy.js +1 -0
- data/app/assets/lookbook/js/lookbook-core.js +1 -0
- data/app/assets/lookbook/js/lookbook.js +2 -61
- data/app/components/lookbook/base_component.rb +3 -1
- data/app/components/lookbook/button/component.html.erb +13 -24
- data/app/components/lookbook/button/component.js +13 -3
- data/app/components/lookbook/button/component.rb +16 -25
- data/app/components/lookbook/code/component.rb +0 -2
- data/app/components/lookbook/copy_button/component.html.erb +4 -4
- data/app/components/lookbook/copy_button/component.rb +6 -3
- data/app/components/lookbook/debug_menu/component.html.erb +1 -0
- data/app/components/lookbook/debug_menu/component.rb +12 -1
- data/app/components/lookbook/display_options/editor/component.html.erb +1 -1
- data/app/components/lookbook/display_options/field/component.css +0 -26
- data/app/components/lookbook/display_options/field/component.html.erb +1 -1
- data/app/components/lookbook/embed/component.html.erb +6 -51
- data/app/components/lookbook/embed/component.rb +17 -16
- data/app/components/lookbook/embed/inspector/component.html.erb +102 -0
- data/app/components/lookbook/embed/inspector/component.js +46 -0
- data/app/components/lookbook/embed/inspector/component.rb +64 -0
- data/app/components/lookbook/embed_code_dropdown/component.css +12 -0
- data/app/components/lookbook/embed_code_dropdown/component.html.erb +19 -0
- data/app/components/lookbook/embed_code_dropdown/component.js +26 -0
- data/app/components/lookbook/embed_code_dropdown/component.rb +41 -0
- data/app/components/lookbook/header/component.html.erb +6 -5
- data/app/components/lookbook/header/component.rb +5 -1
- data/app/components/lookbook/icon/component.html.erb +1 -1
- data/app/components/lookbook/icon_button/component.html.erb +20 -0
- data/app/components/lookbook/icon_button/component.rb +46 -0
- data/app/components/lookbook/nav/component.html.erb +0 -1
- data/app/components/lookbook/nav/entity/component.rb +2 -2
- data/app/components/lookbook/nav/item/component.rb +1 -1
- data/app/components/lookbook/params/editor/component.rb +1 -0
- data/app/components/lookbook/prose/component.rb +1 -3
- data/app/components/lookbook/tabs/component.html.erb +2 -2
- data/app/components/lookbook/tabs/component.js +1 -1
- data/app/components/lookbook/tag_component.rb +2 -1
- data/app/components/lookbook/text_button/component.html.erb +26 -0
- data/app/components/lookbook/text_button/component.rb +42 -0
- data/app/components/lookbook/toolbar/component.html.erb +1 -1
- data/app/components/lookbook/viewport/component.rb +0 -4
- data/app/controllers/concerns/lookbook/targetable_concern.rb +24 -19
- data/app/controllers/concerns/lookbook/with_panels_concern.rb +30 -0
- data/app/controllers/concerns/lookbook/with_preview_controller_concern.rb +4 -3
- data/app/controllers/lookbook/application_controller.rb +9 -12
- data/app/controllers/lookbook/embeds_controller.rb +148 -0
- data/app/controllers/lookbook/inspector_controller.rb +3 -22
- data/app/controllers/lookbook/page_controller.rb +7 -6
- data/app/controllers/lookbook/pages_controller.rb +3 -4
- data/app/controllers/lookbook/preview_controller.rb +17 -0
- data/app/controllers/lookbook/previews_controller.rb +21 -20
- data/app/helpers/lookbook/application_helper.rb +3 -19
- data/app/views/layouts/lookbook/application.html.erb +85 -60
- data/app/views/layouts/lookbook/embed.html.erb +16 -0
- data/app/views/layouts/lookbook/shell.html.erb +1 -1
- data/app/views/layouts/lookbook/skeleton.html.erb +13 -8
- data/app/views/lookbook/embeds/show.html.erb +12 -0
- data/app/views/lookbook/inspector/panels/_notes.html.erb +1 -1
- data/app/views/lookbook/inspector/panels/_output.html.erb +3 -3
- data/app/views/lookbook/inspector/panels/_source.html.erb +6 -6
- data/app/views/lookbook/inspector/show.html.erb +130 -123
- data/app/views/lookbook/pages/show.html.erb +81 -34
- data/app/views/lookbook/partials/_iframe_content_scripts.html.erb +1 -0
- data/app/views/lookbook/partials/_user_styles.html.erb +5 -0
- data/app/views/lookbook/{preview.html.erb → previews/group.html.erb} +7 -7
- data/app/views/lookbook/previews/preview.html.erb +5 -0
- data/app/views/lookbook/previews/show.html.erb +1 -0
- data/config/app.yml +31 -16
- data/config/panels.yml +23 -25
- data/config/routes.rb +3 -1
- data/config/tags.yml +6 -2
- data/lib/lookbook/cable/cable.rb +53 -0
- data/{app/channels/lookbook → lib/lookbook/cable}/connection.rb +0 -0
- data/{app/channels/lookbook → lib/lookbook/cable}/reload_channel.rb +0 -0
- data/lib/lookbook/engine.rb +109 -87
- data/lib/lookbook/entities/collections/entity_collection.rb +11 -6
- data/lib/lookbook/entities/collections/page_collection.rb +33 -8
- data/lib/lookbook/entities/collections/preview_collection.rb +42 -17
- data/lib/lookbook/entities/collections/render_target_collection.rb +4 -0
- data/lib/lookbook/entities/collections/scenario_collection.rb +4 -0
- data/lib/lookbook/entities/concerns/{annotatable.rb → annotatable_entity.rb} +7 -6
- data/lib/lookbook/entities/concerns/{inspectable.rb → inspectable_entity.rb} +2 -1
- data/lib/lookbook/entities/concerns/{locatable.rb → locatable_entity.rb} +8 -14
- data/lib/lookbook/entities/concerns/navigable_entity.rb +44 -0
- data/lib/lookbook/entities/entity.rb +7 -2
- data/lib/lookbook/entities/{page.rb → page_entity.rb} +10 -6
- data/lib/lookbook/entities/{page_section.rb → page_section_entity.rb} +1 -1
- data/lib/lookbook/entities/preview_entity.rb +99 -0
- data/lib/lookbook/entities/renderable_entity.rb +50 -0
- data/lib/lookbook/entities/rendered_scenario_entity.rb +53 -0
- data/lib/lookbook/entities/scenario_entity.rb +116 -0
- data/lib/lookbook/entities/scenario_group_entity.rb +57 -0
- data/lib/lookbook/error.rb +5 -5
- data/lib/lookbook/file_watcher.rb +19 -35
- data/lib/lookbook/helpers/class_names_helper.rb +28 -0
- data/lib/lookbook/helpers/page_helper.rb +18 -0
- data/{app/helpers/lookbook → lib/lookbook/helpers}/preview_helper.rb +3 -0
- data/lib/lookbook/helpers/ui_elements_helper.rb +115 -0
- data/lib/lookbook/preview.rb +79 -0
- data/lib/lookbook/preview_controller_actions.rb +45 -0
- data/lib/lookbook/preview_parser.rb +4 -2
- data/lib/lookbook/reloaders.rb +71 -0
- data/lib/lookbook/runtime_context.rb +49 -0
- data/lib/lookbook/services/data/resolvers/data_resolver.rb +4 -6
- data/lib/lookbook/services/entities/entity_tree_builder.rb +6 -6
- data/lib/lookbook/services/list_resolver.rb +35 -0
- data/lib/lookbook/services/markdown_renderer.rb +12 -2
- data/lib/lookbook/services/priority_prefix_parser.rb +16 -0
- data/lib/lookbook/services/urls/search_param_encoder.rb +16 -0
- data/lib/lookbook/services/urls/search_param_parser.rb +7 -6
- data/lib/lookbook/stores/config_store.rb +16 -16
- data/lib/lookbook/stores/input_store.rb +1 -3
- data/lib/lookbook/stores/panel_store.rb +28 -50
- data/lib/lookbook/support/deprecation.rb +5 -0
- data/lib/lookbook/support/errors/preview_template_error.rb +7 -0
- data/lib/lookbook/support/evented_file_update_checker.rb +69 -0
- data/lib/lookbook/support/null_websocket.rb +9 -0
- data/lib/lookbook/support/store.rb +9 -0
- data/lib/lookbook/support/tree_node.rb +7 -7
- data/lib/lookbook/support/utils/path_utils.rb +7 -1
- data/lib/lookbook/support/utils/utils.rb +8 -0
- data/lib/lookbook/tags/{position_tag.rb → priority_tag.rb} +4 -4
- data/lib/lookbook/tags/renders_tag.rb +4 -0
- data/lib/lookbook/tags/tag_provider.rb +3 -0
- data/lib/lookbook/tags/type_tag.rb +7 -0
- data/lib/lookbook/tags/yard_tag.rb +1 -2
- data/lib/lookbook/version.rb +1 -1
- data/lib/lookbook/websocket.rb +6 -53
- data/lib/lookbook.rb +179 -53
- data/public/lookbook-assets/css/lookbook.css +137 -83
- data/public/lookbook-assets/css/lookbook.css.map +1 -1
- data/public/lookbook-assets/css/themes/blue.css +7 -0
- data/public/lookbook-assets/css/themes/blue.css.map +1 -1
- data/public/lookbook-assets/css/themes/green.css +7 -0
- data/public/lookbook-assets/css/themes/green.css.map +1 -1
- data/public/lookbook-assets/css/themes/indigo.css +7 -0
- data/public/lookbook-assets/css/themes/indigo.css.map +1 -1
- data/public/lookbook-assets/css/themes/rose.css +7 -0
- data/public/lookbook-assets/css/themes/rose.css.map +1 -1
- data/public/lookbook-assets/css/themes/zinc.css +7 -0
- data/public/lookbook-assets/css/themes/zinc.css.map +1 -1
- data/public/lookbook-assets/img/lucide-sprite.svg +4960 -0
- data/public/lookbook-assets/js/embed.js +1363 -842
- data/public/lookbook-assets/js/embed.js.map +1 -1
- data/public/lookbook-assets/js/iframe.js +906 -0
- data/public/lookbook-assets/js/iframe.js.map +1 -0
- data/public/lookbook-assets/js/index.js +13567 -0
- data/public/lookbook-assets/js/index.js.map +1 -0
- data/public/lookbook-assets/js/lookbook-core.js +85 -0
- data/public/lookbook-assets/js/lookbook-core.js.map +1 -0
- data/public/lookbook-assets/js/lookbook.js +143 -12733
- data/public/lookbook-assets/js/lookbook.js.map +1 -1
- data/public/lookbook-assets/lookbook-esm.js +1427 -0
- data/public/lookbook-assets/lookbook-esm.js.map +1 -0
- data/public/lookbook-assets/lookbook-global.js +1427 -0
- data/public/lookbook-assets/lookbook-global.js.map +1 -0
- data/public/lookbook-assets/lookbook.js +1427 -0
- data/public/lookbook-assets/lookbook.js.map +1 -0
- metadata +80 -72
- data/app/components/lookbook/embed/component.js +0 -39
- data/app/helpers/lookbook/component_helper.rb +0 -84
- data/app/helpers/lookbook/output_helper.rb +0 -19
- data/app/helpers/lookbook/page_helper.rb +0 -34
- data/app/views/layouts/lookbook/inspector.html.erb +0 -7
- data/app/views/layouts/lookbook/page.html.erb +0 -53
- data/app/views/layouts/lookbook/standalone.html.erb +0 -5
- data/lib/lookbook/entities/collections/component_collection.rb +0 -4
- data/lib/lookbook/entities/collections/preview_example_collection.rb +0 -4
- data/lib/lookbook/entities/component.rb +0 -31
- data/lib/lookbook/entities/concerns/navigable.rb +0 -43
- data/lib/lookbook/entities/preview.rb +0 -87
- data/lib/lookbook/entities/preview_example.rb +0 -104
- data/lib/lookbook/entities/preview_group.rb +0 -52
- data/lib/lookbook/preview_actions.rb +0 -43
- data/lib/lookbook/process.rb +0 -21
- data/lib/lookbook/rendered_example.rb +0 -37
- data/lib/lookbook/services/position_prefix_parser.rb +0 -16
- data/lib/lookbook/services/urls/search_param_builder.rb +0 -13
- data/lib/lookbook/tags/component_tag.rb +0 -13
@@ -44,8 +44,7 @@ module Lookbook
|
|
44
44
|
TagOptionsParser.call(@text, {
|
45
45
|
file: host_file,
|
46
46
|
base_dir: host_file&.dirname,
|
47
|
-
eval_context: host_class_instance
|
48
|
-
permit_eval: Lookbook.config.preview_params_options_eval
|
47
|
+
eval_context: host_class_instance
|
49
48
|
})
|
50
49
|
else
|
51
50
|
[{}, @text]
|
data/lib/lookbook/version.rb
CHANGED
data/lib/lookbook/websocket.rb
CHANGED
@@ -1,60 +1,13 @@
|
|
1
1
|
module Lookbook
|
2
2
|
class Websocket
|
3
|
-
|
3
|
+
class << self
|
4
|
+
def new(mount_path, **kwargs)
|
5
|
+
require_relative "./cable/cable"
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
logger.info "Initializing websocket"
|
10
|
-
|
11
|
-
if Gem::Version.new(Rails.version) >= Gem::Version.new(6.0)
|
12
|
-
@server = ActionCable::Server::Base.new config: cable_config
|
13
|
-
else
|
14
|
-
@server = ActionCable::Server::Base.new
|
15
|
-
@server.config = cable_config
|
7
|
+
Cable.new(mount_path, **kwargs)
|
8
|
+
rescue LoadError
|
9
|
+
NullWebsocket.new
|
16
10
|
end
|
17
11
|
end
|
18
|
-
|
19
|
-
def broadcast(message, payload = nil)
|
20
|
-
logger.debug message.to_s
|
21
|
-
server.broadcast(message.to_s, payload.to_h)
|
22
|
-
end
|
23
|
-
|
24
|
-
def mount_path
|
25
|
-
"/cable"
|
26
|
-
end
|
27
|
-
|
28
|
-
def full_mount_path
|
29
|
-
"#{engine_mount_path}/#{mount_path}".gsub("//", "/")
|
30
|
-
end
|
31
|
-
|
32
|
-
def mountable?
|
33
|
-
true
|
34
|
-
end
|
35
|
-
|
36
|
-
alias_method :mounted?, :mountable?
|
37
|
-
|
38
|
-
def self.noop
|
39
|
-
NullWebsocket.new
|
40
|
-
end
|
41
|
-
|
42
|
-
protected
|
43
|
-
|
44
|
-
def cable_config
|
45
|
-
cable = ActionCable::Server::Configuration.new
|
46
|
-
cable.cable = {adapter: "async"}.with_indifferent_access
|
47
|
-
cable.mount_path = nil
|
48
|
-
cable.connection_class = -> { Lookbook::Connection }
|
49
|
-
cable.logger = logger
|
50
|
-
cable
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
class NullWebsocket < NullObject
|
55
|
-
def mountable?
|
56
|
-
false
|
57
|
-
end
|
58
|
-
alias_method :mounted?, :mountable?
|
59
12
|
end
|
60
13
|
end
|
data/lib/lookbook.rb
CHANGED
@@ -7,34 +7,193 @@ loader.push_dir("#{__dir__}/lookbook", namespace: Lookbook)
|
|
7
7
|
loader.collapse("#{__dir__}/lookbook/*")
|
8
8
|
loader.collapse("#{__dir__}/lookbook/*/*")
|
9
9
|
loader.collapse("#{__dir__}/lookbook/*/*/*")
|
10
|
+
loader.ignore("#{__dir__}/lookbook/support/evented_file_update_checker.rb")
|
11
|
+
loader.ignore("#{__dir__}/lookbook/cable")
|
10
12
|
loader.setup
|
11
13
|
|
14
|
+
# The Lookbook application entry point.
|
15
|
+
#
|
16
|
+
# @api public
|
12
17
|
module Lookbook
|
13
18
|
class << self
|
19
|
+
# Returns the installed Lookbook version
|
20
|
+
#
|
21
|
+
# @example :erb
|
22
|
+
# <p>Using Lookbook v<%= Lookbook.version %></p>
|
23
|
+
#
|
24
|
+
# @return [String] Version number string
|
14
25
|
def version
|
15
26
|
Lookbook::VERSION
|
16
27
|
end
|
17
28
|
|
29
|
+
# Provides access to the Lookbook config store
|
30
|
+
#
|
31
|
+
# @example :ruby
|
32
|
+
# Lookbook.config.project_title = "MyApp"
|
33
|
+
#
|
34
|
+
# @return [ConfigStore] The config store object
|
18
35
|
def config
|
19
36
|
@_config ||= ConfigStore.init_from_config
|
20
37
|
end
|
21
38
|
|
22
|
-
|
23
|
-
|
39
|
+
# Get an array of component preview objects
|
40
|
+
#
|
41
|
+
# @return [Array<PreviewEntity>] Array of preview entities
|
42
|
+
def previews
|
43
|
+
Engine.previews.to_a
|
24
44
|
end
|
25
45
|
|
26
|
-
|
27
|
-
|
46
|
+
# Get an array of documentation page objects
|
47
|
+
#
|
48
|
+
# @return [Array<PageEntity>] Array of page entities
|
49
|
+
def pages
|
50
|
+
Engine.pages.to_a
|
28
51
|
end
|
29
52
|
|
53
|
+
# Get the global data store instance
|
54
|
+
#
|
55
|
+
# @return [Store] The global data store instance
|
30
56
|
def data
|
31
57
|
@_data ||= Store.new
|
32
58
|
end
|
33
59
|
|
60
|
+
# Replace the global data store contents
|
61
|
+
#
|
62
|
+
# @param new_data [Hash] Hash of data to store
|
63
|
+
# @return [Store] The global data store instance
|
34
64
|
def data=(new_data)
|
35
65
|
@_data = Store.new(new_data)
|
36
66
|
end
|
37
67
|
|
68
|
+
# @!group Params
|
69
|
+
|
70
|
+
# Add a custom `@param` tag input type
|
71
|
+
#
|
72
|
+
# @param name [Symbol] Unique input type name
|
73
|
+
# @param partial_path [String] Path to the partial template used to render the input
|
74
|
+
# @param opts [Hash] Set of default options to be passed to the input. Any supplied param options will override these values
|
75
|
+
def add_input_type(name, partial_path, opts = {})
|
76
|
+
Engine.inputs.add_input(name, partial_path, opts)
|
77
|
+
end
|
78
|
+
|
79
|
+
# @!endgroup
|
80
|
+
|
81
|
+
# @!group Inspector Panels
|
82
|
+
|
83
|
+
# Add a custom inspector panel
|
84
|
+
#
|
85
|
+
# @example :ruby
|
86
|
+
# Lookbook.add_panel(:info, "panels/info", {
|
87
|
+
# label: "Extra Info"
|
88
|
+
# })
|
89
|
+
#
|
90
|
+
# @param name [Symbol, String] Unique panel name
|
91
|
+
# @param partial_path [String] Path to the partial template used to render the panel
|
92
|
+
# @param opts [Hash] Set of panel options
|
93
|
+
# @option opts [String] :label The text to be displayed in the panel tab
|
94
|
+
# @option opts [String] :hotkey [Keyboard shortcut](https://alpinejs.dev/directives/on#keyboard-events) used to switch to the panel
|
95
|
+
# @option opts [Boolean] :disabled Disabled tabs are still accessible but are greyed out in the UI
|
96
|
+
# @option opts [String] :copy If present, the panel will display a copy button that copies the value of this property to the clipboard when clicked
|
97
|
+
# @option opts [Hash] :locals A hash of local variables that will be passed to the panel when it is rendered
|
98
|
+
def add_panel(name, partial_path, opts = {})
|
99
|
+
Engine.panels.add_panel(name, partial_path, opts)
|
100
|
+
end
|
101
|
+
|
102
|
+
# Edit the properties of an existing inspector panel
|
103
|
+
#
|
104
|
+
# @example :ruby
|
105
|
+
# Lookbook.update_panel(:notes, {
|
106
|
+
# label: "Usage Info",
|
107
|
+
# hotkey: "u",
|
108
|
+
# })
|
109
|
+
#
|
110
|
+
# @param name [Symbol, String] Name of target panel
|
111
|
+
# @param opts [Hash] Set of panel options
|
112
|
+
# @option opts [String] :label The text to be displayed in the panel tab
|
113
|
+
# @option opts [String] :hotkey [Keyboard shortcut](https://alpinejs.dev/directives/on#keyboard-events) used to switch to the panel
|
114
|
+
# @option opts [Boolean] :disabled Disabled tabs are still accessible but are greyed out in the UI
|
115
|
+
# @option opts [String] :copy If present, the panel will display a copy button that copies the value of this property to the clipboard when clicked
|
116
|
+
# @option opts [Hash] :locals A hash of local variables that will be passed to the panel when it is rendered
|
117
|
+
def update_panel(name, opts)
|
118
|
+
Engine.panels.update_panel(name, opts)
|
119
|
+
end
|
120
|
+
|
121
|
+
# Remove a panel from the inspector
|
122
|
+
#
|
123
|
+
# @example :ruby
|
124
|
+
# Lookbook.remove_panel(:notes)
|
125
|
+
#
|
126
|
+
# @param name [Symbol, String] Name of target panel
|
127
|
+
def remove_panel(name)
|
128
|
+
Engine.panels.remove_panel(name)
|
129
|
+
end
|
130
|
+
|
131
|
+
# @!endgroup
|
132
|
+
|
133
|
+
# @!group Custom Tags
|
134
|
+
|
135
|
+
# Add a custom tag
|
136
|
+
#
|
137
|
+
# @param name [Symbol, String] Tag name
|
138
|
+
# @param args [Array<Symbol>] Array of argument names
|
139
|
+
# @yield [tag] The custom tag instance
|
140
|
+
def add_tag(name, args = nil, &block)
|
141
|
+
Engine.tags.add_tag(name, {
|
142
|
+
named_args: args.to_a,
|
143
|
+
after_parse: block
|
144
|
+
})
|
145
|
+
end
|
146
|
+
|
147
|
+
# @!endgroup
|
148
|
+
|
149
|
+
# @!group Lifecycle Callbacks
|
150
|
+
|
151
|
+
# Add a callback to run after app initialization.
|
152
|
+
#
|
153
|
+
# @example :ruby
|
154
|
+
# Lookbook.after_initialize do |app|
|
155
|
+
# puts "Lookbook has started!"
|
156
|
+
# end
|
157
|
+
#
|
158
|
+
# @yield [app] Lookbook app
|
159
|
+
def after_initialize(&block)
|
160
|
+
Engine.hooks.add_hook(:after_initialize, block)
|
161
|
+
end
|
162
|
+
|
163
|
+
# Add a callback to run before Lookbook shuts down
|
164
|
+
#
|
165
|
+
# @yield [app] Lookbook app
|
166
|
+
def before_exit(&block)
|
167
|
+
Engine.hooks.add_hook(:before_exit, block)
|
168
|
+
end
|
169
|
+
|
170
|
+
# Add a callback to run when a change to a watched
|
171
|
+
# file occurs. Only called when an evented file watcher is being
|
172
|
+
# used to detect changes.
|
173
|
+
#
|
174
|
+
# @yield [app, changes] Lookbook app and hash of files changed, added & removed
|
175
|
+
def after_change(&block)
|
176
|
+
Engine.hooks.add_hook(:after_change, block)
|
177
|
+
end
|
178
|
+
|
179
|
+
# @!endgroup
|
180
|
+
|
181
|
+
# @api private
|
182
|
+
def broadcast(event_name, data = {})
|
183
|
+
Engine.websocket&.broadcast(event_name.to_s, data)
|
184
|
+
end
|
185
|
+
|
186
|
+
# @api private
|
187
|
+
def engine
|
188
|
+
Engine
|
189
|
+
end
|
190
|
+
|
191
|
+
# @api private
|
192
|
+
def configure
|
193
|
+
yield(config)
|
194
|
+
end
|
195
|
+
|
196
|
+
# @api private
|
38
197
|
def logger
|
39
198
|
@_logger ||= if Rails.logger.present? && config.log_use_rails_logger
|
40
199
|
Rails.logger
|
@@ -45,12 +204,20 @@ module Lookbook
|
|
45
204
|
end
|
46
205
|
end
|
47
206
|
|
207
|
+
# @api private
|
48
208
|
def debug_data
|
49
209
|
{
|
50
210
|
version: version,
|
51
211
|
env: Rails.env.to_s,
|
52
212
|
config: [
|
53
213
|
config.to_h,
|
214
|
+
{
|
215
|
+
dependencies: {
|
216
|
+
actioncable: Engine.runtime_context.actioncable_installed?,
|
217
|
+
listen: Engine.runtime_context.listen_installed?,
|
218
|
+
view_component: config.using_view_component
|
219
|
+
}
|
220
|
+
},
|
54
221
|
{panels: Engine.panels.to_h},
|
55
222
|
{inputs: Engine.inputs.to_h},
|
56
223
|
{tags: Engine.tags.to_h}
|
@@ -58,56 +225,15 @@ module Lookbook
|
|
58
225
|
}
|
59
226
|
end
|
60
227
|
|
61
|
-
|
62
|
-
|
63
|
-
|
228
|
+
alias_method :define_param_input, :add_input_type
|
229
|
+
alias_method :define_panel, :add_panel
|
230
|
+
alias_method :amend_panel, :update_panel
|
231
|
+
alias_method :define_tag, :add_tag
|
64
232
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
def broadcast(event_name, data = {})
|
70
|
-
Engine.websocket&.broadcast(event_name.to_s, data)
|
71
|
-
end
|
72
|
-
|
73
|
-
def theme
|
74
|
-
@_theme ||= Lookbook::Theme.new(config.ui_theme, config.ui_theme_overrides)
|
75
|
-
end
|
76
|
-
|
77
|
-
def define_param_input(*args)
|
78
|
-
Engine.inputs.add_input(*args)
|
79
|
-
end
|
80
|
-
|
81
|
-
def define_panel(name, *args)
|
82
|
-
Engine.panels.add_panel(name, :drawer, *args)
|
83
|
-
end
|
84
|
-
|
85
|
-
def amend_panel(*args)
|
86
|
-
Engine.panels.update_panel(*args)
|
87
|
-
end
|
88
|
-
|
89
|
-
def remove_panel(name)
|
90
|
-
Engine.panels.remove_panel(name)
|
91
|
-
end
|
92
|
-
|
93
|
-
def define_tag(name, args = nil, &block)
|
94
|
-
Engine.tags.add_tag(name, {
|
95
|
-
named_args: args.to_a,
|
96
|
-
after_parse: block
|
97
|
-
})
|
98
|
-
end
|
99
|
-
|
100
|
-
def after_initialize(&block)
|
101
|
-
Engine.hooks.add_hook(:after_initialize, block)
|
102
|
-
end
|
103
|
-
|
104
|
-
def before_exit(&block)
|
105
|
-
Engine.hooks.add_hook(:before_exit, block)
|
106
|
-
end
|
107
|
-
|
108
|
-
def after_change(&block)
|
109
|
-
Engine.hooks.add_hook(:after_change, block)
|
110
|
-
end
|
233
|
+
deprecate define_param_input: :add_input_type, deprecator: Deprecation
|
234
|
+
deprecate define_panel: :add_panel, deprecator: Deprecation
|
235
|
+
deprecate amend_panel: :update_panel, deprecator: Deprecation
|
236
|
+
deprecate define_tag: :add_tag, deprecator: Deprecation
|
111
237
|
end
|
112
238
|
end
|
113
239
|
|