datastar 1.0.0.beta.2 → 1.0.0.beta.3

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: 23de694fa3da7ad6bd9cc78a02851ec22ab16f5d16e475beb9bc175569fbce02
4
- data.tar.gz: eab01bb873a350c595dcdaddddb722ea2a69aef584b86f1bab5309f61764a699
3
+ metadata.gz: 55282db68817596fd27726daa87179e08fcddb3b8deaea5826161d54f7a850cb
4
+ data.tar.gz: '0864d609f3afa0c950d357f396973b7882c6f834f56c112e4765e3dfc7add400'
5
5
  SHA512:
6
- metadata.gz: 3f386d1039d1a9fc53b698ce9d4390f595dcf1dfec1166c03d7bb1fa17ec87c062089386151cc7d1ea6117e4b8350d6d819458215b3f305bc3e756f1a691dba2
7
- data.tar.gz: 88e7e8505d1640151bcd494aca0000b3ee5d935f0ad426b937372d6c93b8191e5a2b4838e0ed86a58eeab11e5a5e66e92a92841967812f4095564ebc39adbf36
6
+ metadata.gz: 1712f02ea8b4d5def9d04381062f35135eb3213863b63536a35d8322b3880efb917acfb5dde900be7181ea2576b825791b301bd392a649bd799784aa93fbf28d
7
+ data.tar.gz: 4e268347627b41ec8c7506891adbf7c95f32d10d16c4ed3f5e33192f624660456d9a1712dee71921af18390c7998f1755a48a2cc73701a298036fce8ab1a48de
data/README.md CHANGED
@@ -165,7 +165,7 @@ end
165
165
  Register server-side code to run when the connection is closed by the client
166
166
 
167
167
  ```ruby
168
- datastar.on_client_connect do
168
+ datastar.on_client_disconnect do
169
169
  puts 'A user has disconnected connected'
170
170
  end
171
171
  ```
@@ -178,7 +178,7 @@ Register server-side code to run when the connection is closed by the server.
178
178
  Ie when the served is done streaming without errors.
179
179
 
180
180
  ```ruby
181
- datastar.on_server_connect do
181
+ datastar.on_server_disconnect do
182
182
  puts 'Server is done streaming'
183
183
  end
184
184
  ```
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'thread'
4
+ require 'logger'
4
5
 
5
6
  module Datastar
6
7
  # The default executor based on Ruby threads
@@ -30,17 +31,19 @@ module Datastar
30
31
  # You'd normally do this on app initialization
31
32
  # For example in a Rails initializer
32
33
  class Configuration
33
- NOOP_CALLBACK = ->(_error) {}
34
34
  RACK_FINALIZE = ->(_view_context, response) { response.finish }
35
35
  DEFAULT_HEARTBEAT = 3
36
36
 
37
- attr_accessor :executor, :error_callback, :finalize, :heartbeat
37
+ attr_accessor :executor, :error_callback, :finalize, :heartbeat, :logger
38
38
 
39
39
  def initialize
40
40
  @executor = ThreadExecutor.new
41
- @error_callback = NOOP_CALLBACK
42
41
  @finalize = RACK_FINALIZE
43
42
  @heartbeat = DEFAULT_HEARTBEAT
43
+ @logger = Logger.new(STDOUT)
44
+ @error_callback = proc do |e|
45
+ @logger.error("#{e.class} (#{e.message}):\n#{e.backtrace.join("\n")}")
46
+ end
44
47
  end
45
48
 
46
49
  def on_error(callable = nil, &block)
@@ -4,10 +4,7 @@
4
4
  module Datastar
5
5
  module Consts
6
6
  DATASTAR_KEY = 'datastar'
7
- VERSION = '1.0.0-beta.5'
8
-
9
- # The default duration for settling during fragment merges. Allows for CSS transitions to complete.
10
- DEFAULT_FRAGMENTS_SETTLE_DURATION = 300
7
+ VERSION = '1.0.0-beta.11'
11
8
 
12
9
  # The default duration for retrying SSE on connection reset. This is part of the underlying retry mechanism of SSE.
13
10
  DEFAULT_SSE_RETRY_DURATION = 1000
@@ -57,7 +54,6 @@ module Datastar
57
54
  # Dataline literals.
58
55
  SELECTOR_DATALINE_LITERAL = 'selector'
59
56
  MERGE_MODE_DATALINE_LITERAL = 'mergeMode'
60
- SETTLE_DURATION_DATALINE_LITERAL = 'settleDuration'
61
57
  FRAGMENTS_DATALINE_LITERAL = 'fragments'
62
58
  USE_VIEW_TRANSITION_DATALINE_LITERAL = 'useViewTransition'
63
59
  SIGNALS_DATALINE_LITERAL = 'signals'
@@ -14,6 +14,8 @@ module Datastar
14
14
  initializer 'datastar' do |_app|
15
15
  Datastar.config.finalize = FINALIZE
16
16
 
17
+ Datastar.config.logger = Rails.logger
18
+
17
19
  Datastar.config.executor = if config.active_support.isolation_level == :fiber
18
20
  require 'datastar/rails_async_executor'
19
21
  RailsAsyncExecutor.new
@@ -17,7 +17,6 @@ module Datastar
17
17
  'retry' => Consts::DEFAULT_SSE_RETRY_DURATION,
18
18
  Consts::AUTO_REMOVE_DATALINE_LITERAL => Consts::DEFAULT_EXECUTE_SCRIPT_AUTO_REMOVE,
19
19
  Consts::MERGE_MODE_DATALINE_LITERAL => Consts::DEFAULT_FRAGMENT_MERGE_MODE,
20
- Consts::SETTLE_DURATION_DATALINE_LITERAL => Consts::DEFAULT_FRAGMENTS_SETTLE_DURATION,
21
20
  Consts::USE_VIEW_TRANSITION_DATALINE_LITERAL => Consts::DEFAULT_FRAGMENTS_USE_VIEW_TRANSITIONS,
22
21
  Consts::ONLY_IF_MISSING_DATALINE_LITERAL => Consts::DEFAULT_MERGE_SIGNALS_ONLY_IF_MISSING,
23
22
  }.freeze
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Datastar
4
- VERSION = '1.0.0.beta.2'
4
+ VERSION = '1.0.0.beta.3'
5
5
  end
metadata CHANGED
@@ -1,28 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datastar
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta.2
4
+ version: 1.0.0.beta.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ismael Celis
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-02-12 00:00:00.000000000 Z
10
+ date: 2025-06-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rack
14
14
  requirement: !ruby/object:Gem::Requirement
15
15
  requirements:
16
- - - "~>"
16
+ - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: '3.0'
18
+ version: 3.1.14
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
- - - "~>"
23
+ - - ">="
24
24
  - !ruby/object:Gem::Version
25
- version: '3.0'
25
+ version: 3.1.14
26
26
  email:
27
27
  - ismaelct@gmail.com
28
28
  executables: []