rails-markup 1.4.3 → 1.4.4

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.
@@ -0,0 +1,91 @@
1
+ Object.assign(RailsMarkupToolbar, {
2
+ init(opts = {}) {
3
+ const previousPathname = this._currentPathname;
4
+ const previousPageUrl = this._currentPageUrl;
5
+ const currentPageUrl = this._pageUrl();
6
+ this.endpoint = opts.endpoint || "/feedback/api";
7
+ this.accent = opts.accent || "indigo";
8
+ this.position = opts.position || "bl";
9
+ this.size = opts.size || "default";
10
+ this.fabVisible = opts.fabVisible !== false;
11
+ this.enableScreenshots = opts.enableScreenshots !== false;
12
+ this.legacyStorageEndpoint = opts.legacyStorageEndpoint || this.legacyStorageEndpoint;
13
+ this.healthIntervalMs = (opts.healthInterval || 60) * 1000;
14
+
15
+ if (document.getElementById("rm-toolbar-root")) {
16
+ if (currentPageUrl !== this._currentPageUrl) this._onTurboNavigate();
17
+ return;
18
+ }
19
+
20
+ if (previousPathname && previousPathname !== window.location.pathname) this._deactivateMode();
21
+ if (previousPageUrl && previousPageUrl !== currentPageUrl && previousPathname === window.location.pathname) this._deactivateMode();
22
+ this._currentPathname = window.location.pathname;
23
+ this._currentPageUrl = currentPageUrl;
24
+ this._injectStyles();
25
+ this._injectDOM();
26
+ this._bindEvents();
27
+ this._loadFromStorage();
28
+ this._checkHealth();
29
+ if (!this.healthInterval) this.healthInterval = setInterval(() => this._checkHealth(), this.healthIntervalMs);
30
+ if (!this._boundVisibilityChange) {
31
+ this._boundVisibilityChange = () => this._onVisibilityChange();
32
+ document.addEventListener("visibilitychange", this._boundVisibilityChange);
33
+ }
34
+ if (!this._boundOnline) {
35
+ this._boundOnline = () => this._onOnline();
36
+ window.addEventListener("online", this._boundOnline);
37
+ }
38
+ this._renderPins();
39
+ this._updateCount();
40
+ if (previousPageUrl && previousPageUrl !== this._currentPageUrl && this.serverOnline) this._initSession();
41
+ },
42
+ destroy() {
43
+ this._closeAllMenus();
44
+ this._deactivateMode();
45
+ if (this.sseSource) { this.sseSource.close(); this.sseSource = null; }
46
+ if (this.healthInterval) { clearInterval(this.healthInterval); this.healthInterval = null; }
47
+ if (this._outboxFlushTimer) { clearTimeout(this._outboxFlushTimer); this._outboxFlushTimer = null; }
48
+ if (this._syncRetryTimer) { clearTimeout(this._syncRetryTimer); this._syncRetryTimer = null; }
49
+ this._outboxFlushScheduled = false;
50
+ if (this._boundVisibilityChange) {
51
+ document.removeEventListener("visibilitychange", this._boundVisibilityChange);
52
+ this._boundVisibilityChange = null;
53
+ }
54
+ if (this._boundOnline) {
55
+ window.removeEventListener("online", this._boundOnline);
56
+ this._boundOnline = null;
57
+ }
58
+ if (this._boundKeyDown) {
59
+ document.removeEventListener("keydown", this._boundKeyDown, true);
60
+ this._boundKeyDown = null;
61
+ }
62
+ if (this._onResize) window.removeEventListener("resize", this._onResize);
63
+ if (this._onScroll) window.removeEventListener("scroll", this._onScroll);
64
+ if (this._boundTurboFrame) {
65
+ document.removeEventListener("turbo:frame-render", this._boundTurboFrame);
66
+ this._boundTurboFrame = null;
67
+ }
68
+ if (this._boundMenuDocClick) {
69
+ document.removeEventListener("click", this._boundMenuDocClick);
70
+ this._boundMenuDocClick = null;
71
+ }
72
+ if (this._boundMenuViewportChange) {
73
+ document.getElementById("rm-panel-list")
74
+ ?.removeEventListener("scroll", this._boundMenuViewportChange);
75
+ window.removeEventListener("resize", this._boundMenuViewportChange);
76
+ window.removeEventListener("scroll", this._boundMenuViewportChange);
77
+ this._boundMenuViewportChange = null;
78
+ }
79
+ this._onResize = null;
80
+ this._onScroll = null;
81
+ const root = document.getElementById("rm-toolbar-root");
82
+ if (root) root.remove();
83
+ const pins = document.getElementById("rm-pins-container");
84
+ if (pins) pins.remove();
85
+ const styles = document.getElementById("rm-toolbar-styles");
86
+ if (styles) styles.remove();
87
+ },
88
+ });
89
+
90
+ global.RailsMarkupToolbar = RailsMarkupToolbar;
91
+ })(typeof window !== "undefined" ? window : this);
@@ -7,7 +7,7 @@
7
7
  annotations) after a logout Turbo visit whose new body omits the partial. %>
8
8
  <span id="rm-toolbar-gate" hidden aria-hidden="true"></span>
9
9
  <script>
10
- <%== File.read(File.expand_path("../../../assets/javascripts/rails_markup/toolbar.js", __dir__)) %>
10
+ <%== RailsMarkup::ToolbarSource.script %>
11
11
  </script>
12
12
  <script>
13
13
  (function() {
@@ -7,12 +7,5 @@ module RailsMarkup
7
7
  initializer "rails_markup.configuration" do
8
8
  RailsMarkup.configuration # ensure defaults are set
9
9
  end
10
-
11
- initializer "rails_markup.assets" do |app|
12
- if app.config.respond_to?(:assets)
13
- # toolbar.js is inlined via the toolbar partial, no separate asset needed
14
- app.config.assets.precompile += %w[rails_markup/toolbar.js]
15
- end
16
- end
17
10
  end
18
11
  end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsMarkup
4
+ module ToolbarSource
5
+ DIR = File.expand_path("../../app/assets/javascripts/rails_markup/toolbar", __dir__)
6
+
7
+ def self.script
8
+ # Re-read every call in development so editing a toolbar/ module shows up
9
+ # without a restart (matches the old single-file File.read). Memoize only
10
+ # where the source can't change under a running process.
11
+ return build if defined?(Rails) && Rails.env.development?
12
+
13
+ @script ||= build
14
+ end
15
+
16
+ def self.build
17
+ Dir.glob(File.join(DIR, "*.js")).sort.map { |file| File.read(file) }.join("\n")
18
+ end
19
+
20
+ def self.reset!
21
+ @script = nil
22
+ end
23
+ end
24
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsMarkup
4
- VERSION = "1.4.3"
4
+ VERSION = "1.4.4"
5
5
  end
data/lib/rails_markup.rb CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require_relative "rails_markup/version"
4
4
  require_relative "rails_markup/configuration"
5
+ require_relative "rails_markup/toolbar_source"
5
6
  require_relative "rails_markup/store"
6
7
  require_relative "rails_markup/http_store_proxy"
7
8
  require_relative "rails_markup/http_server"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-markup
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.3
4
+ version: 1.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - InventList
@@ -118,7 +118,14 @@ extra_rdoc_files: []
118
118
  files:
119
119
  - LICENSE
120
120
  - README.md
121
- - app/assets/javascripts/rails_markup/toolbar.js
121
+ - app/assets/javascripts/rails_markup/toolbar/00-core.js
122
+ - app/assets/javascripts/rails_markup/toolbar/10-styles.js
123
+ - app/assets/javascripts/rails_markup/toolbar/20-dom.js
124
+ - app/assets/javascripts/rails_markup/toolbar/30-menu.js
125
+ - app/assets/javascripts/rails_markup/toolbar/40-events.js
126
+ - app/assets/javascripts/rails_markup/toolbar/50-sync.js
127
+ - app/assets/javascripts/rails_markup/toolbar/60-render.js
128
+ - app/assets/javascripts/rails_markup/toolbar/90-init.js
122
129
  - app/controllers/rails_markup/annotations_controller.rb
123
130
  - app/controllers/rails_markup/application_controller.rb
124
131
  - app/controllers/rails_markup/dashboard_controller.rb
@@ -160,6 +167,7 @@ files:
160
167
  - lib/rails_markup/mcp_server.rb
161
168
  - lib/rails_markup/server.rb
162
169
  - lib/rails_markup/store.rb
170
+ - lib/rails_markup/toolbar_source.rb
163
171
  - lib/rails_markup/version.rb
164
172
  - lib/tasks/rails_markup_client_uuids.rake
165
173
  homepage: https://github.com/nauman/rails-markup