Module: Everywhere

Defined in:
lib/everywhere.rb,
lib/everywhere/s3.rb,
lib/everywhere/ui.rb,
lib/everywhere/cli.rb,
lib/everywhere/png.rb,
lib/everywhere/boot.rb,
lib/everywhere/icon.rb,
lib/everywhere/paths.rb,
lib/everywhere/config.rb,
lib/everywhere/engine.rb,
lib/everywhere/ignore.rb,
lib/everywhere/raster.rb,
lib/everywhere/blake2b.rb,
lib/everywhere/receipt.rb,
lib/everywhere/version.rb,
lib/everywhere/database.rb,
lib/everywhere/minisign.rb,
lib/everywhere/shellout.rb,
lib/everywhere/framework.rb,
lib/everywhere/simulator.rb,
lib/everywhere/log_filter.rb,
lib/everywhere/builders/ios.rb,
lib/everywhere/commands/dev.rb,
lib/everywhere/commands/icon.rb,
lib/everywhere/commands/logs.rb,
lib/everywhere/native_helper.rb,
lib/everywhere/commands/build.rb,
lib/everywhere/commands/clean.rb,
lib/everywhere/commands/doctor.rb,
lib/everywhere/platform/client.rb,
lib/everywhere/update_manifest.rb,
lib/everywhere/commands/install.rb,
lib/everywhere/commands/publish.rb,
lib/everywhere/commands/release.rb,
lib/everywhere/platform/snapshot.rb,
lib/everywhere/commands/shell_dir.rb,
lib/everywhere/platform/credentials.rb,
lib/everywhere/mobile_config_endpoint.rb,
lib/everywhere/commands/platform/build.rb,
lib/everywhere/commands/platform/login.rb,
lib/everywhere/commands/updates_keygen.rb,
lib/everywhere/commands/platform/logout.rb,
lib/everywhere/commands/platform/runner.rb,
lib/everywhere/mobile_configs_controller.rb,
lib/everywhere/commands/platform/auth_status.rb

Defined Under Namespace

Modules: Blake2b, Builders, CLI, Commands, Database, Icon, Minisign, NativeHelper, PNG, Paths, Platform, Shellout, Simulator, UI, UpdateManifest Classes: Boot, Config, Configuration, Engine, Error, Framework, Ignore, LogFilter, MobileConfigEndpoint, MobileConfigsController, Raster, Receipt, S3

Constant Summary collapse

VERSION =
"0.3.0"
BRIDGE_VERSION =

Version of the @rubyeverywhere/bridge JS this gem ships. bridge/ in the gem IS the npm package (served to Rails apps by Everywhere::Engine, vendored to public/ for Sinatra/Hanami), so its package.json is the single source of truth. The build receipt records it; it versions independently of the CLI.

File.read(
  File.expand_path("../../bridge/package.json", __dir__)
)[/"version":\s*"([^"]+)"/, 1]

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.tabs_filter=(value) ⇒ Object (writeonly)

Test/reset hook.



59
60
61
# File 'lib/everywhere/config.rb', line 59

def tabs_filter=(value)
  @tabs_filter = value
end

Class Method Details

.boot!(root:) ⇒ Object



161
162
163
# File 'lib/everywhere/boot.rb', line 161

def self.boot!(root:)
  Boot.call(root: root)
end

.configObject



40
41
42
# File 'lib/everywhere.rb', line 40

def config
  @config ||= Configuration.new
end

.configure {|config| ... } ⇒ Object

Yields:



44
45
46
# File 'lib/everywhere.rb', line 44

def configure
  yield config
end

.filter_tabs(&block) ⇒ Object

Register a per-request filter for the mobile tab bar. The block receives the resolved tab list ([{ "title" =>, "path" =>, "icon" => }, …]) and the current request, and returns the subset to show — return [] to hide the tab bar entirely (the shell falls back to single-screen navigation).

It runs inside the mobile config endpoint, which shares the app's session and cookies, so it can branch on auth or any request state:

# config/initializers/everywhere.rb
Everywhere.filter_tabs do |tabs, request|
request.session[:user_id] ? tabs : []
end

Live like the rest of the config: the shell re-reads it on launch and on every foreground, so a sign-in shows the tabs on next foreground — no rebuild, no app-store release.



23
24
25
# File 'lib/everywhere/config.rb', line 23

def filter_tabs(&block)
  @tabs_filter = block
end

.mobile_reset_html(to) ⇒ Object

The tiny page served at /everywhere/reset. Auth flows redirect the native app here so it resets cleanly (fresh web views, re-fetched tabs) before continuing — the standard Hotwire Native "reset the app" pattern. It talks to the shell's control channel directly (no bridge/importmap dependency); in a plain browser it just forwards to the target. to is constrained to a same-origin path.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/everywhere/config.rb', line 41

def mobile_reset_html(to)
  require "json"
  target = to.to_s
  target = "/" unless target.start_with?("/") && !target.start_with?("//")
  encoded = target.to_json

  <<~HTML
    <!DOCTYPE html><html><head><meta charset="utf-8"><title>One moment…</title>
    <meta name="viewport" content="width=device-width,initial-scale=1"></head>
    <body><script>
    (function(){var to=#{encoded};
    var ch=window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.everywhereControl;
    if(ch){ch.postMessage({action:"reset",to:to});}else{window.location.replace(to);}})();
    </script></body></html>
  HTML
end

.reset_config!Object

Test/reset seam.



49
50
51
# File 'lib/everywhere.rb', line 49

def reset_config!
  @config = Configuration.new
end

.resolve_tabs(tabs, request) ⇒ Object

Apply the registered filter (identity when none is set). Always returns an Array so a stray nil/scalar from a block can't break serialization.



29
30
31
32
33
# File 'lib/everywhere/config.rb', line 29

def resolve_tabs(tabs, request)
  return tabs unless @tabs_filter

  Array(@tabs_filter.call(tabs, request))
end