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 +4 -4
- data/app/pb_kits/playbook/pb_icon/icon.rb +18 -9
- data/lib/playbook/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7ea3eb503ddb54ca40d789a5d83867846c64bfb055c359b3fe0ee5997f9e33dd
|
|
4
|
+
data.tar.gz: 2404e05c9718ede9c7b72290b31d3e45e16d60bc66aad702bf6f6d042f1a7bf2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
|
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
|
|
233
|
-
#
|
|
234
|
-
return true if Rails.env.development? &&
|
|
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
|
|
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) <
|
|
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
|
data/lib/playbook/version.rb
CHANGED