studio-engine 0.93.0 → 0.94.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/CHANGELOG.md +61 -0
- data/app/javascript/studio/alpine_shims.js +45 -0
- data/app/javascript/studio/alpine_stores.js +82 -0
- data/app/javascript/studio/application.js +37 -0
- data/app/javascript/studio/controllers/nav_collapse_controller.js +28 -0
- data/app/javascript/studio/head_chrome.js +79 -0
- data/app/javascript/studio/nav_collapse.js +238 -0
- data/app/javascript/studio/pinned_stack.js +306 -0
- data/app/javascript/studio/vendor/stimulus.js +5 -0
- data/app/views/layouts/_navbar.html.erb +14 -6
- data/app/views/layouts/studio/_head.html.erb +59 -567
- data/config/importmap.rb +14 -3
- data/lib/studio/engine.rb +26 -0
- data/lib/studio/version.rb +1 -1
- metadata +9 -1
data/config/importmap.rb
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
# The engine's importmap pins, drawn into every host by the studio.importmap
|
|
2
2
|
# initializer (lib/studio/engine.rb) before the host's own config/importmap.rb.
|
|
3
3
|
#
|
|
4
|
-
# One `pin` per module under app/javascript/studio, named "studio/<name>"
|
|
5
|
-
#
|
|
4
|
+
# One `pin` per module under app/javascript/studio, named "studio/<name>". Only
|
|
5
|
+
# the boot graph is preloaded (Studio::Engine.javascript_boot_graph: the modules
|
|
6
|
+
# studio/application imports, which every page runs); any other module is
|
|
7
|
+
# fetched only when something imports it.
|
|
8
|
+
#
|
|
9
|
+
# A vendored library (studio/vendor/) is pinned under its package name only:
|
|
10
|
+
# "@hotwired/stimulus" is the engine's Stimulus. A host that pins its own
|
|
11
|
+
# (stimulus-rails) wins, and the engine's controllers run on that copy.
|
|
6
12
|
#
|
|
7
13
|
# `pin`, not `pin_all_from`, so a host can override one: importmap-rails expands
|
|
8
14
|
# a pin_all_from directory AFTER every plain pin, so a directory pin would beat
|
|
9
15
|
# the host's own `pin` of the same name. Plain pins are last-drawn-wins, and the
|
|
10
16
|
# host's map is drawn last.
|
|
17
|
+
boot = Studio::Engine.javascript_boot_graph
|
|
11
18
|
Studio::Engine.javascript_module_logical_paths.each do |logical_path|
|
|
12
|
-
|
|
19
|
+
next if logical_path.start_with?("studio/vendor/")
|
|
20
|
+
|
|
21
|
+
name = logical_path.delete_suffix(".js")
|
|
22
|
+
pin name, to: logical_path, preload: boot.include?(name)
|
|
13
23
|
end
|
|
24
|
+
pin "@hotwired/stimulus", to: "studio/vendor/stimulus.js", preload: true
|
data/lib/studio/engine.rb
CHANGED
|
@@ -165,6 +165,32 @@ module Studio
|
|
|
165
165
|
.sort
|
|
166
166
|
end
|
|
167
167
|
|
|
168
|
+
# The engine's browser boot, which layouts/studio/_head imports on every page.
|
|
169
|
+
JAVASCRIPT_BOOT_MODULE = "studio/application"
|
|
170
|
+
|
|
171
|
+
# A static `import ... from "x"` or `import "x"`, across lines.
|
|
172
|
+
JAVASCRIPT_STATIC_IMPORT = /^\s*import\s+(?:[\w$*{}\s,]+?\s+from\s+)?["']([^"']+)["']/
|
|
173
|
+
|
|
174
|
+
# Every "studio/<name>" module the boot imports statically, followed through
|
|
175
|
+
# their own imports. config/importmap.rb preloads exactly these, so the boot
|
|
176
|
+
# costs one round trip and a page still fetches no other engine module until
|
|
177
|
+
# it imports one. Derived from the import statements, so a controller the boot
|
|
178
|
+
# registers is preloaded by being imported.
|
|
179
|
+
def self.javascript_boot_graph
|
|
180
|
+
base = File.expand_path("../../app/javascript", __dir__)
|
|
181
|
+
graph = []
|
|
182
|
+
queue = [JAVASCRIPT_BOOT_MODULE]
|
|
183
|
+
while (name = queue.shift)
|
|
184
|
+
path = File.join(base, "#{name}.js")
|
|
185
|
+
next if graph.include?(name) || !File.file?(path)
|
|
186
|
+
|
|
187
|
+
graph << name
|
|
188
|
+
imports = File.read(path).scan(JAVASCRIPT_STATIC_IMPORT).flatten
|
|
189
|
+
queue.concat(imports.select { |dependency| dependency.start_with?("studio/") })
|
|
190
|
+
end
|
|
191
|
+
graph.sort
|
|
192
|
+
end
|
|
193
|
+
|
|
168
194
|
# Logical asset paths ("studio/local_path.js") for every ES module the
|
|
169
195
|
# engine pins (config/importmap.rb).
|
|
170
196
|
def self.javascript_module_logical_paths
|
data/lib/studio/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: studio-engine
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.94.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alex McRitchie
|
|
@@ -409,7 +409,15 @@ files:
|
|
|
409
409
|
- app/helpers/studio_navbar_helper.rb
|
|
410
410
|
- app/helpers/studio_sidebar_helper.rb
|
|
411
411
|
- app/helpers/studio_theme_helper.rb
|
|
412
|
+
- app/javascript/studio/alpine_shims.js
|
|
413
|
+
- app/javascript/studio/alpine_stores.js
|
|
414
|
+
- app/javascript/studio/application.js
|
|
415
|
+
- app/javascript/studio/controllers/nav_collapse_controller.js
|
|
416
|
+
- app/javascript/studio/head_chrome.js
|
|
412
417
|
- app/javascript/studio/local_path.js
|
|
418
|
+
- app/javascript/studio/nav_collapse.js
|
|
419
|
+
- app/javascript/studio/pinned_stack.js
|
|
420
|
+
- app/javascript/studio/vendor/stimulus.js
|
|
413
421
|
- app/jobs/error_log_cleanup_job.rb
|
|
414
422
|
- app/jobs/studio/email_delivery_job.rb
|
|
415
423
|
- app/mailers/application_mailer.rb
|