playbook_ui 16.2.0.pre.alpha.iconfixes14577 → 16.2.0.pre.alpha.iconfixes14578

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4658800f5f85c4198d6f5396e8e51de4ac4440c905ee8b1d687dd635b9116fde
4
- data.tar.gz: 5575760a10fb40d744d6af0979941b6b8139ddaa03b8816c7b86904a34814245
3
+ metadata.gz: 7ea3eb503ddb54ca40d789a5d83867846c64bfb055c359b3fe0ee5997f9e33dd
4
+ data.tar.gz: 2404e05c9718ede9c7b72290b31d3e45e16d60bc66aad702bf6f6d042f1a7bf2
5
5
  SHA512:
6
- metadata.gz: d2e9025088024e65f25ac470260585c78ef7ec59651100f1360bf1f548e587cfa37dc566710c37748928919705fa4ce20a1333a4fb7ca27a09318288ea10e65e
7
- data.tar.gz: 8f78b511d51ae7912e9e5caad1bb8d9f25158776f63f481cd05969631818306c63e6357dd950567bef10c673398b7379a411be44a06aa35375e9aa15926e4f2c
6
+ metadata.gz: 0ca2b19d3e4c25c13d1d7fe866f56fded40ae2aa264f1606fdad81210f115b19240317b6eb501de0451455acd1b020679cbb88226e105a2994b1b70a992840ee
7
+ data.tar.gz: 46a15f5b53ae54799987907fc916344790c9d35cbaf5b033530b1e30e1f58476cac3ed8fd938ca614a8ecce3b016c0a11d0cc0c211fb48258ee9a28cb9874f28
@@ -8,6 +8,7 @@ module Playbook
8
8
  module PbIcon
9
9
  class Icon < Playbook::KitBase
10
10
  ICON_PATH_DEV_CACHE_TTL_SECONDS = 2
11
+ ICON_PATH_PROD_CACHE_TTL_SECONDS = 60
11
12
 
12
13
  prop :border, type: Playbook::Props::Boolean,
13
14
  default: false
@@ -148,7 +149,6 @@ module Playbook
148
149
  # Class-level caches
149
150
  class << self
150
151
  @cache_mutex = Mutex.new
151
- attr_reader :cache_mutex
152
152
 
153
153
  # Cache aliases.json across the process, but invalidate when the file changes (dev-safe)
154
154
  def icon_alias_map
@@ -205,7 +205,7 @@ module Playbook
205
205
  {}
206
206
  end
207
207
 
208
- @icon_path_index_checked_at = monotonic_now if Rails.env.development?
208
+ @icon_path_index_checked_at = monotonic_now
209
209
  end
210
210
 
211
211
  @icon_path_index
@@ -213,6 +213,10 @@ module Playbook
213
213
 
214
214
  private
215
215
 
216
+ def cache_mutex
217
+ @cache_mutex ||= Mutex.new
218
+ end
219
+
216
220
  def alias_cache_fresh?
217
221
  return false unless defined?(@icon_alias_map)
218
222
 
@@ -229,9 +233,10 @@ module Playbook
229
233
 
230
234
  return true unless Rails.application.config.respond_to?(:icon_path)
231
235
 
232
- # In development, skip expensive tree digest checks for a short window
233
- # This keeps hot-reload behavior while avoiding per-render full scans
234
- return true if Rails.env.development? && within_dev_icon_index_ttl?
236
+ # In development and production, skip re-checks for a short TTL window
237
+ # to avoid repeated tree scans on hot paths.
238
+ return true if Rails.env.development? && within_icon_index_ttl?(ICON_PATH_DEV_CACHE_TTL_SECONDS)
239
+ return true if Rails.env.production? && within_icon_index_ttl?(ICON_PATH_PROD_CACHE_TTL_SECONDS)
235
240
 
236
241
  root = Rails.root.join(Rails.application.config.icon_path)
237
242
  fresh = icon_path_cache_key(root) == @icon_path_index_cache_key
@@ -241,10 +246,10 @@ module Playbook
241
246
  false
242
247
  end
243
248
 
244
- def within_dev_icon_index_ttl?
249
+ def within_icon_index_ttl?(ttl_seconds)
245
250
  return false unless defined?(@icon_path_index_checked_at)
246
251
 
247
- (monotonic_now - @icon_path_index_checked_at) < ICON_PATH_DEV_CACHE_TTL_SECONDS
252
+ (monotonic_now - @icon_path_index_checked_at) < ttl_seconds
248
253
  rescue
249
254
  false
250
255
  end
@@ -254,14 +259,18 @@ module Playbook
254
259
  end
255
260
 
256
261
  def icon_path_cache_key(root)
257
- return safe_mtime(root) unless Rails.env.development?
262
+ return safe_mtime(root) unless Rails.env.development? || Rails.env.production?
258
263
 
259
264
  digest = Digest::SHA1.new
260
265
  root_prefix = "#{root}/"
261
266
 
262
267
  Dir.glob(File.join(root.to_s, "**", "*.svg")).sort.each do |path|
263
- stat = File.stat(path)
264
268
  digest << path.delete_prefix(root_prefix)
269
+ next unless Rails.env.development?
270
+
271
+ # Development tracks file metadata for rapid local edits.
272
+ # Production only needs path-set change detection during periodic checks.
273
+ stat = File.stat(path)
265
274
  digest << stat.mtime.to_f.to_s
266
275
  digest << stat.size.to_s
267
276
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Playbook
4
4
  PREVIOUS_VERSION = "16.2.0"
5
- VERSION = "16.2.0.pre.alpha.iconfixes14577"
5
+ VERSION = "16.2.0.pre.alpha.iconfixes14578"
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: playbook_ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 16.2.0.pre.alpha.iconfixes14577
4
+ version: 16.2.0.pre.alpha.iconfixes14578
5
5
  platform: ruby
6
6
  authors:
7
7
  - Power UX