tina4ruby 3.11.19 → 3.11.35

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.
@@ -714,55 +714,10 @@ module Tina4
714
714
  <span style="color:#ffeb3b;">req:#{request_id}</span>
715
715
  <span style="color:#90caf9;">#{route_count} routes</span>
716
716
  <span style="color:#888;">Ruby #{RUBY_VERSION}</span>
717
- <a href="#" onclick="window.__tina4ToggleOverlay(event)" style="color:#ef9a9a;margin-left:auto;text-decoration:none;cursor:pointer;">Dashboard &#8599;</a>
717
+ <a href="#" onclick="(function(e){e.preventDefault();var p=document.getElementById('tina4-dev-panel');if(p){p.style.display=p.style.display==='none'?'block':'none';return;}var c=document.createElement('div');c.id='tina4-dev-panel';c.style.cssText='position:fixed;top:3rem;left:0;right:0;bottom:2rem;z-index:99998;transition:all 0.2s';var f=document.createElement('iframe');f.src='/__dev';f.style.cssText='width:100%;height:100%;border:1px solid #CC342D;border-radius:0.5rem;box-shadow:0 8px 32px rgba(0,0,0,0.5);background:#0f172a';c.appendChild(f);document.body.appendChild(c);})(event)" style="color:#ef9a9a;margin-left:auto;text-decoration:none;cursor:pointer;">Dashboard &#8599;</a>
718
718
  <span onclick="this.parentElement.style.display='none'" style="cursor:pointer;color:#888;margin-left:8px;">&#10005;</span>
719
719
  </div>
720
720
  <script>
721
- // Overlay open/toggle helper + auto-restore. Persist the dev-admin
722
- // iframe's open/closed state across parent reloads so saving a
723
- // file doesn't lose the user's dev-admin context. Cross-framework
724
- // parity with PHP / Python / Node — same localStorage key.
725
- (function(){
726
- var STATE_KEY = 'tina4_dev_overlay_open';
727
- function buildOverlay() {
728
- var c = document.createElement('div');
729
- c.id = 'tina4-dev-panel';
730
- c.style.cssText = 'position:fixed;top:3rem;left:0;right:0;bottom:2rem;z-index:99998;transition:all 0.2s';
731
- var f = document.createElement('iframe');
732
- f.src = '/__dev';
733
- f.style.cssText = 'width:100%;height:100%;border:1px solid #CC342D;border-radius:0.5rem;box-shadow:0 8px 32px rgba(0,0,0,0.5);background:#0f172a';
734
- c.appendChild(f);
735
- document.body.appendChild(c);
736
- return c;
737
- }
738
- window.__tina4ToggleOverlay = function(e) {
739
- if (e) e.preventDefault();
740
- var p = document.getElementById('tina4-dev-panel');
741
- if (p) {
742
- var hide = p.style.display !== 'none';
743
- p.style.display = hide ? 'none' : 'block';
744
- try { localStorage.setItem(STATE_KEY, hide ? '0' : '1'); } catch (_) {}
745
- return;
746
- }
747
- buildOverlay();
748
- try { localStorage.setItem(STATE_KEY, '1'); } catch (_) {}
749
- };
750
- function restoreIfOpen() {
751
- try {
752
- if (location.pathname.indexOf('/__dev') === 0) return;
753
- if (localStorage.getItem(STATE_KEY) === '1' && !document.getElementById('tina4-dev-panel')) {
754
- buildOverlay();
755
- }
756
- } catch (_) {}
757
- }
758
- if (document.readyState === 'loading') {
759
- document.addEventListener('DOMContentLoaded', restoreIfOpen);
760
- } else {
761
- restoreIfOpen();
762
- }
763
- })();
764
- </script>
765
- <script>
766
721
  function tina4VersionModal(){
767
722
  var m=document.getElementById('tina4-ver-modal');
768
723
  if(m.style.display==='block'){m.style.display='none';return;}
@@ -151,9 +151,6 @@ module Tina4
151
151
  self
152
152
  end
153
153
 
154
- # Render a Frond/Twig template file with data and return self. Tries
155
- # the user template directory first, falling back to the framework's
156
- # built-in templates. Sets the response body to the rendered HTML.
157
154
  def render(template_path, data = {}, status: 200, template_dir: nil)
158
155
  @status_code = status
159
156
  @headers["content-type"] = HTML_CONTENT_TYPE
@@ -53,16 +53,6 @@ module Tina4
53
53
  end
54
54
  end
55
55
 
56
- # Stop background tasks
57
- if defined?(Tina4::Background)
58
- begin
59
- Tina4::Background.stop_all
60
- Tina4::Log.info("Background tasks stopped")
61
- rescue => e
62
- Tina4::Log.error("Error stopping background tasks: #{e.message}")
63
- end
64
- end
65
-
66
56
  # Close database connections
67
57
  if Tina4.database
68
58
  begin
data/lib/tina4/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tina4
4
- VERSION = "3.11.19"
4
+ VERSION = "3.11.35"
5
5
  end
data/lib/tina4.rb CHANGED
@@ -35,14 +35,11 @@ require_relative "tina4/cors"
35
35
  require_relative "tina4/rate_limiter"
36
36
  require_relative "tina4/health"
37
37
  require_relative "tina4/shutdown"
38
- require_relative "tina4/background"
39
38
  require_relative "tina4/localization"
40
39
  require_relative "tina4/container"
41
40
  require_relative "tina4/queue"
42
41
  require_relative "tina4/service_runner"
43
42
  require_relative "tina4/events"
44
- require_relative "tina4/plan"
45
- require_relative "tina4/project_index"
46
43
  require_relative "tina4/dev_admin"
47
44
  require_relative "tina4/messenger"
48
45
  require_relative "tina4/dev_mailbox"
@@ -53,7 +50,6 @@ require_relative "tina4/response_cache"
53
50
  require_relative "tina4/html_element"
54
51
  require_relative "tina4/error_overlay"
55
52
  require_relative "tina4/test_client"
56
- require_relative "tina4/docs"
57
53
  require_relative "tina4/mcp"
58
54
 
59
55
  module Tina4
@@ -387,16 +383,6 @@ module Tina4
387
383
  Tina4::ServiceRunner.register(name, nil, options, &block)
388
384
  end
389
385
 
390
- # Register a periodic background task.
391
- # Mirrors Python's tina4_python.core.server.background(fn, interval) and
392
- # PHP's $app->background($callback, $interval).
393
- #
394
- # Tina4.background(interval: 5.0) { drain_queue }
395
- # Tina4.background(method(:health_check), interval: 30.0)
396
- def background(callback = nil, interval: 1.0, &block)
397
- Tina4::Background.register(callback, interval: interval, &block)
398
- end
399
-
400
386
  # DI container shortcuts
401
387
  def register(name, instance = nil, &block)
402
388
  Tina4::Container.register(name, instance, &block)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tina4ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.11.19
4
+ version: 3.11.35
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tina4 Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-04-25 00:00:00.000000000 Z
11
+ date: 2026-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -281,7 +281,6 @@ files:
281
281
  - lib/tina4/api.rb
282
282
  - lib/tina4/auth.rb
283
283
  - lib/tina4/auto_crud.rb
284
- - lib/tina4/background.rb
285
284
  - lib/tina4/cache.rb
286
285
  - lib/tina4/cli.rb
287
286
  - lib/tina4/constants.rb
@@ -295,7 +294,6 @@ files:
295
294
  - lib/tina4/dev.rb
296
295
  - lib/tina4/dev_admin.rb
297
296
  - lib/tina4/dev_mailbox.rb
298
- - lib/tina4/docs.rb
299
297
  - lib/tina4/drivers/firebird_driver.rb
300
298
  - lib/tina4/drivers/mongodb_driver.rb
301
299
  - lib/tina4/drivers/mssql_driver.rb
@@ -335,8 +333,6 @@ files:
335
333
  - lib/tina4/middleware.rb
336
334
  - lib/tina4/migration.rb
337
335
  - lib/tina4/orm.rb
338
- - lib/tina4/plan.rb
339
- - lib/tina4/project_index.rb
340
336
  - lib/tina4/public/css/tina4.css
341
337
  - lib/tina4/public/css/tina4.min.css
342
338
  - lib/tina4/public/favicon.ico
@@ -1,81 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Tina4
4
- # Periodic background task registry.
5
- #
6
- # Matches Python's `tina4_python.core.server.background(fn, interval)` and
7
- # PHP's `$app->background($callback, $interval)` — a callback that runs
8
- # periodically alongside the server lifecycle.
9
- #
10
- # Ruby has no asyncio event loop, so each task runs in its own thread.
11
- # The GIL keeps it cooperative-enough for the periodic work this is meant
12
- # for (queue draining, health checks, simulators). Errors in the callback
13
- # are caught and logged so they don't kill the thread.
14
- module Background
15
- class << self
16
- # Register a periodic callback.
17
- #
18
- # @param callback [#call, nil] Object responding to `call` with no args.
19
- # @param interval [Float] Seconds between invocations (default 1.0).
20
- # @param block [Proc] Optional block (used if callback is nil).
21
- # @return [Hash] The registered task descriptor.
22
- def register(callback = nil, interval: 1.0, &block)
23
- cb = callback || block
24
- raise ArgumentError, "background requires a callback or block" if cb.nil?
25
- raise ArgumentError, "callback must respond to :call" unless cb.respond_to?(:call)
26
-
27
- task = { callback: cb, interval: interval.to_f, thread: nil, running: false }
28
- mutex.synchronize { tasks << task }
29
- start_task(task)
30
- task
31
- end
32
-
33
- # All registered task descriptors. Tests use this for introspection.
34
- def tasks
35
- @tasks ||= []
36
- end
37
-
38
- # Stop and join every running task. Called on graceful shutdown.
39
- def stop_all(timeout: 2.0)
40
- snapshot = mutex.synchronize { tasks.dup }
41
- snapshot.each { |task| stop_task(task, timeout: timeout) }
42
- mutex.synchronize { tasks.clear }
43
- end
44
-
45
- # Stop a single task. Used by tests that register, fire, then stop.
46
- def stop_task(task, timeout: 2.0)
47
- task[:running] = false
48
- thread = task[:thread]
49
- return unless thread
50
-
51
- thread.join(timeout) || thread.kill
52
- task[:thread] = nil
53
- end
54
-
55
- private
56
-
57
- def mutex
58
- @mutex ||= Mutex.new
59
- end
60
-
61
- def start_task(task)
62
- task[:running] = true
63
- task[:thread] = Thread.new do
64
- while task[:running]
65
- sleep task[:interval]
66
- break unless task[:running]
67
-
68
- begin
69
- task[:callback].call
70
- rescue => e
71
- # Never let a callback error kill the thread — next interval still fires.
72
- if defined?(Tina4::Log) && Tina4::Log.respond_to?(:error)
73
- Tina4::Log.error("background task error: #{e.class}: #{e.message}")
74
- end
75
- end
76
- end
77
- end
78
- end
79
- end
80
- end
81
- end