barefoot_js 0.30.6 → 0.31.1

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/barefoot_js.rb +28 -3
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ca797efa51cecb1fa7eb049f0689fa0fff77996e0d97ccee9102639c359f13f7
4
- data.tar.gz: eba717d9c886f1569ce5882a9ef43b5ebcf5a444da4dcd050f51e6a3009cad45
3
+ metadata.gz: 841d425170f237886abbf80655e034407423bd4c83155e483a865e88a58d30f7
4
+ data.tar.gz: dc574f17801cb8f47374d5c6425044b4a269d5e9a56f487e9afd5c03c8b6dfdb
5
5
  SHA512:
6
- metadata.gz: 4cc5ee0e33f116f6142cc85a41be5f28b62ccdfaa07781570f8db776f6bb438e158ecad23dd56366ea0764625d31bdaef0a0918d9cbd6f803f4277ff1fbbb9a5
7
- data.tar.gz: 85d238ab63966d116da0ba390b990ae2088a3010d6a866f0a06302b159af3ba46fa1d04012ce2c4b836649384a75504ad2d91edca99df18f2682825df2ebf63b
6
+ metadata.gz: 12d1c33985041681040fdec85c926f09a936453a42d1e9b5dbefda6a19b816dc14f63cd7cc5d51353d5923d3a617a34644ed42b0f6dab07ee37850c0fa75c0d8
7
+ data.tar.gz: 5882a9f69b44fa318d39e3ea62aa04a2a654a6111c52f01099c548cf68ec8daa6f5433d3e46cd666bce4604464fd9f568af666773c3abc09f8871b69b0b1da54
data/lib/barefoot_js.rb CHANGED
@@ -68,6 +68,8 @@ module BarefootJS
68
68
  bf_accessor :backend
69
69
  bf_accessor :_scripts, default: -> { [] }
70
70
  bf_accessor :_script_seen, default: -> { {} }
71
+ bf_accessor :_preloads, default: -> { [] }
72
+ bf_accessor :_preload_seen, default: -> { {} }
71
73
  bf_accessor :_scope_id
72
74
  bf_accessor :_is_child, default: -> { false }
73
75
  bf_accessor :_bf_parent
@@ -217,8 +219,28 @@ module BarefootJS
217
219
  _scripts.push(path)
218
220
  end
219
221
 
222
+ # Register a `<link rel="modulepreload">` hint (mirrors `register_script`
223
+ # exactly: same dedup-by-path set, same insertion-order array, same
224
+ # lifetime/reset semantics, same no-output-string return so the compiled
225
+ # ERB template's `<% bf.register_preload(...) %>` produces no bytes
226
+ # where it sits). The `<link>` itself is only ever emitted by `scripts`
227
+ # below, never here -- a preload registration must never inject a node
228
+ # into a component's own template output (see the previous attempt's
229
+ # regression this guards against).
230
+ def register_preload(path)
231
+ return if _preload_seen.key?(path)
232
+
233
+ _preload_seen[path] = true
234
+ _preloads.push(path)
235
+ end
236
+
237
+ # Emits preload hints BEFORE script tags -- a hint that arrives after
238
+ # the script it describes is useless. Same escaping (none; paths are
239
+ # caller-trusted resolved URLs) as the script tags below.
220
240
  def scripts
221
- _scripts.map { |path| %(<script type="module" src="#{path}"></script>) }.join("\n")
241
+ preload_tags = _preloads.map { |path| %(<link rel="modulepreload" crossorigin href="#{path}">) }
242
+ script_tags = _scripts.map { |path| %(<script type="module" src="#{path}"></script>) }
243
+ (preload_tags + script_tags).join("\n")
222
244
  end
223
245
 
224
246
  # -----------------------------------------------------------------
@@ -255,8 +277,9 @@ module BarefootJS
255
277
  # Bulk registration from build manifest
256
278
  # -----------------------------------------------------------------
257
279
  #
258
- # `bf build` emits dist/templates/manifest.json describing every
259
- # component the page might invoke. This walks that manifest and
280
+ # `vite build` (via `@barefootjs/erb/vite`'s `barefoot()` plugin) emits
281
+ # dist/templates/manifest.json describing every component the page
282
+ # might invoke. This walks that manifest and
260
283
  # registers one child renderer per UI registry entry (`ui/<name>/index`
261
284
  # -> slot key `<name>`), seeding each child's template vars from the
262
285
  # manifest's statically-derived `ssrDefaults` (prop destructure
@@ -300,6 +323,8 @@ module BarefootJS
300
323
  child_bf._child_renderers(parent._child_renderers)
301
324
  child_bf._scripts(parent._scripts)
302
325
  child_bf._script_seen(parent._script_seen)
326
+ child_bf._preloads(parent._preloads)
327
+ child_bf._preload_seen(parent._preload_seen)
303
328
 
304
329
  extra =
305
330
  if sig_init
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: barefoot_js
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.30.6
4
+ version: 0.31.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - kobaken
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-08-04 00:00:00.000000000 Z
11
+ date: 2026-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tzinfo