opal-vite 0.3.15 → 0.3.16

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: 3ff5610634e2852d6053397650789a4873d1dfa2faf891c634503849531a0a0c
4
- data.tar.gz: f8169727ae99fb3faa4f9bd75e48786b667b1ad2c4cd261a985b411c60bbea6c
3
+ metadata.gz: 3c20b89cec58a20be779bfbfd9bbffdf4c2dc337fa654e82791d346130a8f8f1
4
+ data.tar.gz: a51c0fe478c873b9aacd5df3080d06b3173cafa5b7b08225be113cb24471b90d
5
5
  SHA512:
6
- metadata.gz: 485d95f570220009668240c82cf363dbf092b743601045b78820c1b0628f041d4b1bda86393eaac16156261cd794190d062392f2303af0338b89646658f3c62c
7
- data.tar.gz: e2970ff1eaaa5828ccc128f564aab1a1ce8b628300d480731aae8f6eaee6df094c2253940914b39049ebc5424efd188c316bfed4af0bba3a90c1fdc42e8d7d44
6
+ metadata.gz: e270c06cdd81265b491f9f51b55493438138029d3cd106e482870542dd4479a355cae65042b017c18c2943311f1cd83b45137bd0332bcc685c182fe82556a6ad
7
+ data.tar.gz: 874b556449b4603cdf752af695f4cfa60b42d9b659d0d17b1e786748d14f345b5e967c343f7d3aa36913944391dd026320ad3f8ca9b7ce524731ddcabc80c333
@@ -126,6 +126,10 @@ module Opal
126
126
  end
127
127
  end
128
128
 
129
+ # opal-vite's own opal/ directory holds the built-in concerns; it is
130
+ # on $LOAD_PATH like any gem, so drop it here when they are disabled.
131
+ gem_opal_paths.delete(File.expand_path(Opal::Vite.opal_lib_path)) unless @include_concerns
132
+
129
133
  # Add opal directories FIRST so they take priority over lib directories
130
134
  # This ensures that 'require "inesita"' finds opal/inesita.rb before lib/inesita.rb
131
135
  gem_opal_paths.uniq.each do |path|
@@ -224,6 +224,22 @@ module Opal
224
224
  js_poll_until(js_condition, timeout: timeout, error_message: "Condition not met: #{js_condition}")
225
225
  end
226
226
 
227
+ # Wait until every Stimulus controller declared on the page is connected
228
+ # (expects the Application on window.Stimulus). Checking for elements or
229
+ # targets is not enough: they are in the static HTML before Opal has
230
+ # registered the controllers, so tests could act before connect() ran.
231
+ # @param timeout [Integer] Maximum wait time in seconds
232
+ def wait_for_stimulus_connected(timeout: DEFAULT_TIMEOUT)
233
+ js_poll_until(<<~JS.strip, timeout: timeout, error_message: "Stimulus controllers not connected within #{timeout}s")
234
+ (typeof Stimulus !== 'undefined') &&
235
+ Array.from(document.querySelectorAll('[data-controller]')).every(function(el) {
236
+ return el.getAttribute('data-controller').split(/\\s+/).filter(Boolean).every(function(id) {
237
+ return !!Stimulus.getControllerForElementAndIdentifier(el, id);
238
+ });
239
+ })
240
+ JS
241
+ end
242
+
227
243
  # Wait for DOM to be stable (no pending mutations)
228
244
  # Uses MutationObserver setup in JS with Ruby-based polling
229
245
  # @param timeout [Integer] Maximum wait time in seconds
@@ -1,5 +1,5 @@
1
1
  module Opal
2
2
  module Vite
3
- VERSION = "0.3.15"
3
+ VERSION = "0.3.16"
4
4
  end
5
5
  end
data/lib/opal-vite.rb CHANGED
@@ -24,7 +24,8 @@ module Opal
24
24
  # Returns the path to the opal/ directory in this gem
25
25
  # Contains built-in concerns like StimulusHelpers
26
26
  def opal_lib_path
27
- File.expand_path('../../opal', __dir__)
27
+ # This file is lib/opal-vite.rb, so opal/ is one level up
28
+ File.expand_path('../opal', __dir__)
28
29
  end
29
30
 
30
31
  # CLI entry point for compilation
@@ -217,7 +217,10 @@ module OpalVite
217
217
  # button({ onClick: set_count.with { |c| c + 1 } }, '+')
218
218
  def with(&block)
219
219
  setter_fn = @setter_fn
220
- `function() {
220
+ # Opal emits a multi-line x-string as a statement (no implicit
221
+ # return), and a bare anonymous function statement is a
222
+ # JavaScript syntax error, so return explicitly.
223
+ `return function() {
221
224
  #{setter_fn}(function(current) {
222
225
  return #{block.call(`current`)};
223
226
  });
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opal-vite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.15
4
+ version: 0.3.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - stofu1234