isorun 0.1.7-x86_64-darwin → 0.1.9-x86_64-darwin
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 +4 -4
 - data/Rakefile +2 -2
 - data/app/helpers/isorun/app_helper.rb +20 -6
 - data/app/helpers/isorun/vite_app_helper.rb +72 -0
 - data/ext/isorun/Cargo.toml +11 -11
 - data/ext/isorun/src/isorun/context.rs +13 -7
 - data/ext/isorun/src/isorun/function.rs +5 -5
 - data/ext/isorun/src/isorun/module.rs +5 -4
 - data/ext/isorun/src/isorun/utils.rs +66 -0
 - data/ext/isorun/src/js/worker.rs +4 -3
 - data/ext/isorun/src/lib.rs +11 -0
 - data/lib/isorun/2.7/isorun.bundle +0 -0
 - data/lib/isorun/3.0/isorun.bundle +0 -0
 - data/lib/isorun/3.1/isorun.bundle +0 -0
 - data/lib/isorun/3.2/isorun.bundle +0 -0
 - data/lib/isorun/context.rb +49 -5
 - data/lib/isorun/engine.rb +0 -1
 - data/lib/isorun/resolver.rb +4 -0
 - data/lib/isorun/version.rb +1 -1
 - metadata +61 -11
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: '045309e2bebe24468befe3b77fff185b201da5bfbbac2e085d92fbe9499d3062'
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 5358e3731ab58c9c7b606a72e0d59308d736adc283e35ad3059a1d8066c15b6d
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 5954fe17877449d65813377f931bc6a1e3df04fec3425934bcdbc499b1c6a03643cc38c772853766d030eed713fe85c3c2880ca6bf66c05a4bb2c1c0637385b6
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 322a650b2631c9e8248fc265a4011dc1c77b82f548a6ce6f901047303c7160ab101fc8e176f3652c35741349c24fea55653c5c6a479e77166599e3fe3a255068
         
     | 
    
        data/Rakefile
    CHANGED
    
    | 
         @@ -6,7 +6,7 @@ require "rake/testtask" 
     | 
|
| 
       6 
6 
     | 
    
         
             
            require "rake/extensiontask"
         
     | 
| 
       7 
7 
     | 
    
         
             
            require "rb_sys"
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
            cross_rubies = %w[3.1.0 3.0.0 2.7.0]
         
     | 
| 
      
 9 
     | 
    
         
            +
            cross_rubies = %w[3.2.0 3.1.0 3.0.0 2.7.0]
         
     | 
| 
       10 
10 
     | 
    
         
             
            cross_platforms = %w[
         
     | 
| 
       11 
11 
     | 
    
         
             
              arm64-darwin
         
     | 
| 
       12 
12 
     | 
    
         
             
              x86_64-darwin
         
     | 
| 
         @@ -72,7 +72,7 @@ begin 
     | 
|
| 
       72 
72 
     | 
    
         | 
| 
       73 
73 
     | 
    
         
             
              YARD::Rake::YardocTask.new
         
     | 
| 
       74 
74 
     | 
    
         | 
| 
       75 
     | 
    
         
            -
              task docs 
     | 
| 
      
 75 
     | 
    
         
            +
              task :docs do
         
     | 
| 
       76 
76 
     | 
    
         
             
                `yard server --reload`
         
     | 
| 
       77 
77 
     | 
    
         
             
              end
         
     | 
| 
       78 
78 
     | 
    
         
             
            rescue LoadError
         
     | 
| 
         @@ -2,10 +2,27 @@ 
     | 
|
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            module Isorun
         
     | 
| 
       4 
4 
     | 
    
         
             
              module AppHelper
         
     | 
| 
      
 5 
     | 
    
         
            +
                # The isorun_app helper is the most convenient way to server-side render
         
     | 
| 
      
 6 
     | 
    
         
            +
                # a JavaScript application, including state extraction and automatic
         
     | 
| 
      
 7 
     | 
    
         
            +
                # rehydration. The helper tries to render the application and will also
         
     | 
| 
      
 8 
     | 
    
         
            +
                # inject the client-side code immediately after the rendered result.
         
     | 
| 
      
 9 
     | 
    
         
            +
                #
         
     | 
| 
      
 10 
     | 
    
         
            +
                # @example Renders a JavaScript application
         
     | 
| 
      
 11 
     | 
    
         
            +
                #   <html>
         
     | 
| 
      
 12 
     | 
    
         
            +
                #   <body>
         
     | 
| 
      
 13 
     | 
    
         
            +
                #     <%= isorun_app("my_app") %>
         
     | 
| 
      
 14 
     | 
    
         
            +
                #   </body>
         
     | 
| 
      
 15 
     | 
    
         
            +
                #   </html>
         
     | 
| 
      
 16 
     | 
    
         
            +
                #
         
     | 
| 
      
 17 
     | 
    
         
            +
                # @param id [String] An ID representing both, the asset bundle, and by
         
     | 
| 
      
 18 
     | 
    
         
            +
                #   convention, the target node (e.g. `<div id="my_app">`)
         
     | 
| 
      
 19 
     | 
    
         
            +
                # @return [String]
         
     | 
| 
       5 
20 
     | 
    
         
             
                def isorun_app(id) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
         
     | 
| 
      
 21 
     | 
    
         
            +
                  ActiveSupport::Notifications.instrument "start.render.isorun", { ts: Time.current }
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
       6 
23 
     | 
    
         
             
                  module_path = Isorun.config.module_resolver.call(id)
         
     | 
| 
       7 
24 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
                  ssr_html = Isorun::Context.create do |context|
         
     | 
| 
      
 25 
     | 
    
         
            +
                  ssr_html = Isorun::Context.create(receiver: Isorun.config.receiver) do |context|
         
     | 
| 
       9 
26 
     | 
    
         
             
                    render_context = { environment: Rails.env.to_s }
         
     | 
| 
       10 
27 
     | 
    
         
             
                    render_function = context.import.from(module_path)
         
     | 
| 
       11 
28 
     | 
    
         | 
| 
         @@ -17,13 +34,10 @@ module Isorun 
     | 
|
| 
       17 
34 
     | 
    
         
             
                      return ""
         
     | 
| 
       18 
35 
     | 
    
         
             
                    end
         
     | 
| 
       19 
36 
     | 
    
         | 
| 
       20 
     | 
    
         
            -
                    # set receiver to allow calling into Ruby from JavaScript
         
     | 
| 
       21 
     | 
    
         
            -
                    context.receiver = Isorun.config.receiver
         
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
37 
     | 
    
         
             
                    html = render_function.call(render_context)
         
     | 
| 
       24 
38 
     | 
    
         | 
| 
       25 
     | 
    
         
            -
                     
     | 
| 
       26 
     | 
    
         
            -
                     
     | 
| 
      
 39 
     | 
    
         
            +
                    ActiveSupport::Notifications.instrument "finish.render.isorun", { ts: Time.current }
         
     | 
| 
      
 40 
     | 
    
         
            +
                    ActiveSupport::Notifications.instrument "stats.isorun", Isorun.stats
         
     | 
| 
       27 
41 
     | 
    
         | 
| 
       28 
42 
     | 
    
         
             
                    html
         
     | 
| 
       29 
43 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -0,0 +1,72 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Isorun
         
     | 
| 
      
 4 
     | 
    
         
            +
              module ViteAppHelper
         
     | 
| 
      
 5 
     | 
    
         
            +
                # The isorun_vite_app helper is the most convenient way to server-side
         
     | 
| 
      
 6 
     | 
    
         
            +
                # render a JavaScript application built with vite, including state
         
     | 
| 
      
 7 
     | 
    
         
            +
                # extraction and automatic rehydration. The helper tries to render the
         
     | 
| 
      
 8 
     | 
    
         
            +
                # application and will also inject the client-side code immediately after
         
     | 
| 
      
 9 
     | 
    
         
            +
                # the rendered result.
         
     | 
| 
      
 10 
     | 
    
         
            +
                #
         
     | 
| 
      
 11 
     | 
    
         
            +
                # @example Renders a JavaScript application
         
     | 
| 
      
 12 
     | 
    
         
            +
                #   <html>
         
     | 
| 
      
 13 
     | 
    
         
            +
                #   <body>
         
     | 
| 
      
 14 
     | 
    
         
            +
                #     <%= isorun_vite_app("my_app") %>
         
     | 
| 
      
 15 
     | 
    
         
            +
                #   </body>
         
     | 
| 
      
 16 
     | 
    
         
            +
                #   </html>
         
     | 
| 
      
 17 
     | 
    
         
            +
                #
         
     | 
| 
      
 18 
     | 
    
         
            +
                # @param id [String] An ID representing both, the asset bundle, and by
         
     | 
| 
      
 19 
     | 
    
         
            +
                #   convention, the target node (e.g. `<div id="my_app">`)
         
     | 
| 
      
 20 
     | 
    
         
            +
                # @return [String]
         
     | 
| 
      
 21 
     | 
    
         
            +
                def isorun_vite_app(id) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
         
     | 
| 
      
 22 
     | 
    
         
            +
                  ActiveSupport::Notifications.instrument "start.render.isorun", { ts: Time.current }
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                  # if id has a file extension, we extract the extension and reduce the ID
         
     | 
| 
      
 25 
     | 
    
         
            +
                  # to the basename
         
     | 
| 
      
 26 
     | 
    
         
            +
                  extension = (File.extname(id) || ".js").delete_prefix(".")
         
     | 
| 
      
 27 
     | 
    
         
            +
                  id = File.basename(id, ".*")
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                  module_path = Isorun.config.module_resolver.call(id)
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                  ssr_html = Isorun::Context.create(receiver: Isorun.config.receiver) do |context|
         
     | 
| 
      
 32 
     | 
    
         
            +
                    render_context = { environment: Rails.env.to_s }
         
     | 
| 
      
 33 
     | 
    
         
            +
                    render_function = context.import.from(module_path)
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                    if render_function.blank?
         
     | 
| 
      
 36 
     | 
    
         
            +
                      Rails.logger.warn("[ISORUN] the requested app does not exist or " \
         
     | 
| 
      
 37 
     | 
    
         
            +
                                        "does not have a server entrypoint. Please " \
         
     | 
| 
      
 38 
     | 
    
         
            +
                                        "check if an asset with filename " + "
         
     | 
| 
      
 39 
     | 
    
         
            +
                                           `public/vite-ssr/ssr.js` exists.")
         
     | 
| 
      
 40 
     | 
    
         
            +
                      return ""
         
     | 
| 
      
 41 
     | 
    
         
            +
                    end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                    html = render_function.call(render_context)
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                    ActiveSupport::Notifications.instrument "finish.render.isorun", { ts: Time.current }
         
     | 
| 
      
 46 
     | 
    
         
            +
                    ActiveSupport::Notifications.instrument "stats.isorun", Isorun.stats
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                    html
         
     | 
| 
      
 49 
     | 
    
         
            +
                  end
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
                  html = if ssr_html.present?
         
     | 
| 
      
 52 
     | 
    
         
            +
                           tag.div id: id do
         
     | 
| 
      
 53 
     | 
    
         
            +
                             ssr_html.html_safe # rubocop:disable Rails/OutputSafety
         
     | 
| 
      
 54 
     | 
    
         
            +
                           end
         
     | 
| 
      
 55 
     | 
    
         
            +
                         else
         
     | 
| 
      
 56 
     | 
    
         
            +
                           Rails.logger.warn("[ISORUN] The server-side rendered result is empty.")
         
     | 
| 
      
 57 
     | 
    
         
            +
                           ""
         
     | 
| 
      
 58 
     | 
    
         
            +
                         end
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
                  html += "\n"
         
     | 
| 
      
 61 
     | 
    
         
            +
                  case extension
         
     | 
| 
      
 62 
     | 
    
         
            +
                  when "js", "jsx"
         
     | 
| 
      
 63 
     | 
    
         
            +
                    html += vite_javascript_tag("#{id}.#{extension}")
         
     | 
| 
      
 64 
     | 
    
         
            +
                  when "ts", "tsx"
         
     | 
| 
      
 65 
     | 
    
         
            +
                    html += vite_typescript_tag("#{id}.#{extension}")
         
     | 
| 
      
 66 
     | 
    
         
            +
                  else
         
     | 
| 
      
 67 
     | 
    
         
            +
                    Rails.logger.warn("[ISORUN] unsupported client application extension: `#{extension}`")
         
     | 
| 
      
 68 
     | 
    
         
            +
                  end
         
     | 
| 
      
 69 
     | 
    
         
            +
                  html.html_safe # rubocop:disable Rails/OutputSafety
         
     | 
| 
      
 70 
     | 
    
         
            +
                end
         
     | 
| 
      
 71 
     | 
    
         
            +
              end
         
     | 
| 
      
 72 
     | 
    
         
            +
            end
         
     | 
    
        data/ext/isorun/Cargo.toml
    CHANGED
    
    | 
         @@ -1,26 +1,26 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            [package]
         
     | 
| 
       2 
2 
     | 
    
         
             
            name = "isorun"
         
     | 
| 
       3 
     | 
    
         
            -
            version = "0.1. 
     | 
| 
      
 3 
     | 
    
         
            +
            version = "0.1.9"
         
     | 
| 
       4 
4 
     | 
    
         
             
            edition = "2021"
         
     | 
| 
       5 
5 
     | 
    
         
             
            authors = ["Hannes Moser <box@hannesmoser.at>"]
         
     | 
| 
       6 
6 
     | 
    
         
             
            homepage = "https://github.com/eliias/isorun"
         
     | 
| 
       7 
7 
     | 
    
         
             
            repository = "https://github.com/eliias/isorun"
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         
             
            [dependencies]
         
     | 
| 
       10 
     | 
    
         
            -
            deno_console = "0. 
     | 
| 
       11 
     | 
    
         
            -
            deno_core = "0. 
     | 
| 
       12 
     | 
    
         
            -
            deno_fetch = "0. 
     | 
| 
       13 
     | 
    
         
            -
            deno_runtime = "0. 
     | 
| 
       14 
     | 
    
         
            -
            deno_url = "0. 
     | 
| 
       15 
     | 
    
         
            -
            deno_web = "0. 
     | 
| 
       16 
     | 
    
         
            -
            deno_webidl = "0. 
     | 
| 
      
 10 
     | 
    
         
            +
            deno_console = "0.86.0"
         
     | 
| 
      
 11 
     | 
    
         
            +
            deno_core = "0.168.0"
         
     | 
| 
      
 12 
     | 
    
         
            +
            deno_fetch = "0.110.0"
         
     | 
| 
      
 13 
     | 
    
         
            +
            deno_runtime = "0.94.0"
         
     | 
| 
      
 14 
     | 
    
         
            +
            deno_url = "0.86.0"
         
     | 
| 
      
 15 
     | 
    
         
            +
            deno_web = "0.117.0"
         
     | 
| 
      
 16 
     | 
    
         
            +
            deno_webidl = "0.86.0"
         
     | 
| 
       17 
17 
     | 
    
         
             
            lazy_static = "1.4.0"
         
     | 
| 
       18 
     | 
    
         
            -
            magnus = { git = "https://github.com/eliias/magnus", rev = " 
     | 
| 
      
 18 
     | 
    
         
            +
            magnus = { git = "https://github.com/eliias/magnus", rev = "75e2ba89d12af8c51d2bbbb137da2eac3fc966e3" }
         
     | 
| 
       19 
19 
     | 
    
         
             
            tokio = { version = "1.21.1", features = ["full"] }
         
     | 
| 
       20 
     | 
    
         
            -
            v8 = "0.60. 
     | 
| 
      
 20 
     | 
    
         
            +
            v8 = "0.60.1"
         
     | 
| 
       21 
21 
     | 
    
         | 
| 
       22 
22 
     | 
    
         
             
            [dev-dependencies]
         
     | 
| 
       23 
     | 
    
         
            -
            magnus = { git = "https://github.com/eliias/magnus", rev = " 
     | 
| 
      
 23 
     | 
    
         
            +
            magnus = { git = "https://github.com/eliias/magnus", rev = "75e2ba89d12af8c51d2bbbb137da2eac3fc966e3", features = ["embed"] }
         
     | 
| 
       24 
24 
     | 
    
         | 
| 
       25 
25 
     | 
    
         
             
            [lib]
         
     | 
| 
       26 
26 
     | 
    
         
             
            name = "isorun"
         
     | 
| 
         @@ -3,7 +3,7 @@ use crate::js::module::Module; 
     | 
|
| 
       3 
3 
     | 
    
         
             
            use crate::js::worker::WORKER;
         
     | 
| 
       4 
4 
     | 
    
         
             
            use deno_core::JsRealm;
         
     | 
| 
       5 
5 
     | 
    
         
             
            use magnus::block::Proc;
         
     | 
| 
       6 
     | 
    
         
            -
            use magnus::Error;
         
     | 
| 
      
 6 
     | 
    
         
            +
            use magnus::{exception, Error};
         
     | 
| 
       7 
7 
     | 
    
         
             
            use std::cell::RefCell;
         
     | 
| 
       8 
8 
     | 
    
         
             
            use std::rc::Rc;
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
         @@ -19,7 +19,10 @@ impl Context { 
     | 
|
| 
       19 
19 
     | 
    
         
             
                        .with(|worker| worker.create_realm())
         
     | 
| 
       20 
20 
     | 
    
         
             
                        .map(|realm| Context(Rc::new(RefCell::from(realm))))
         
     | 
| 
       21 
21 
     | 
    
         
             
                        .map_err(|_error| {
         
     | 
| 
       22 
     | 
    
         
            -
                            Error:: 
     | 
| 
      
 22 
     | 
    
         
            +
                            Error::new(
         
     | 
| 
      
 23 
     | 
    
         
            +
                                exception::runtime_error(),
         
     | 
| 
      
 24 
     | 
    
         
            +
                                "cannot create JavaScript context",
         
     | 
| 
      
 25 
     | 
    
         
            +
                            )
         
     | 
| 
       23 
26 
     | 
    
         
             
                        })
         
     | 
| 
       24 
27 
     | 
    
         
             
                }
         
     | 
| 
       25 
28 
     | 
    
         | 
| 
         @@ -41,11 +44,14 @@ impl Context { 
     | 
|
| 
       41 
44 
     | 
    
         
             
                        })
         
     | 
| 
       42 
45 
     | 
    
         
             
                        .map(|module| isorun::Module(RefCell::from(module)))
         
     | 
| 
       43 
46 
     | 
    
         
             
                        .map_err(|error| {
         
     | 
| 
       44 
     | 
    
         
            -
                            Error:: 
     | 
| 
       45 
     | 
    
         
            -
                                 
     | 
| 
       46 
     | 
    
         
            -
                                 
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
      
 47 
     | 
    
         
            +
                            Error::new(
         
     | 
| 
      
 48 
     | 
    
         
            +
                                exception::runtime_error(),
         
     | 
| 
      
 49 
     | 
    
         
            +
                                format!(
         
     | 
| 
      
 50 
     | 
    
         
            +
                                    "cannot load module: `{}`: {}",
         
     | 
| 
      
 51 
     | 
    
         
            +
                                    path.as_str(),
         
     | 
| 
      
 52 
     | 
    
         
            +
                                    error
         
     | 
| 
      
 53 
     | 
    
         
            +
                                ),
         
     | 
| 
      
 54 
     | 
    
         
            +
                            )
         
     | 
| 
       49 
55 
     | 
    
         
             
                        })
         
     | 
| 
       50 
56 
     | 
    
         
             
                }
         
     | 
| 
       51 
57 
     | 
    
         
             
            }
         
     | 
| 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            use crate::js;
         
     | 
| 
       2 
2 
     | 
    
         
             
            use crate::js::worker::WORKER;
         
     | 
| 
       3 
     | 
    
         
            -
            use magnus::Error;
         
     | 
| 
      
 3 
     | 
    
         
            +
            use magnus::{exception, Error};
         
     | 
| 
       4 
4 
     | 
    
         
             
            use std::cell::RefCell;
         
     | 
| 
       5 
5 
     | 
    
         
             
            use std::ops::Deref;
         
     | 
| 
       6 
6 
     | 
    
         
             
            use v8::{Global, Value};
         
     | 
| 
         @@ -28,10 +28,10 @@ impl Function { 
     | 
|
| 
       28 
28 
     | 
    
         | 
| 
       29 
29 
     | 
    
         
             
                        let result =
         
     | 
| 
       30 
30 
     | 
    
         
             
                            self.0.borrow().call(v8_args.as_slice()).map_err(|error| {
         
     | 
| 
       31 
     | 
    
         
            -
                                Error:: 
     | 
| 
       32 
     | 
    
         
            -
                                     
     | 
| 
       33 
     | 
    
         
            -
                                    error
         
     | 
| 
       34 
     | 
    
         
            -
                                ) 
     | 
| 
      
 31 
     | 
    
         
            +
                                Error::new(
         
     | 
| 
      
 32 
     | 
    
         
            +
                                    exception::runtime_error(),
         
     | 
| 
      
 33 
     | 
    
         
            +
                                    format!("cannot call function: {}", error),
         
     | 
| 
      
 34 
     | 
    
         
            +
                                )
         
     | 
| 
       35 
35 
     | 
    
         
             
                            });
         
     | 
| 
       36 
36 
     | 
    
         | 
| 
       37 
37 
     | 
    
         
             
                        result
         
     | 
| 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            use crate::isorun::function::Function;
         
     | 
| 
       2 
2 
     | 
    
         
             
            use crate::js;
         
     | 
| 
       3 
     | 
    
         
            -
            use magnus::Error;
         
     | 
| 
      
 3 
     | 
    
         
            +
            use magnus::{exception, Error};
         
     | 
| 
       4 
4 
     | 
    
         
             
            use std::cell::RefCell;
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
            #[magnus::wrap(class = "Isorun::Module")]
         
     | 
| 
         @@ -19,9 +19,10 @@ impl Module { 
     | 
|
| 
       19 
19 
     | 
    
         
             
                    export_name: String,
         
     | 
| 
       20 
20 
     | 
    
         
             
                ) -> Result<magnus::Value, Error> {
         
     | 
| 
       21 
21 
     | 
    
         
             
                    let module = self.0.borrow();
         
     | 
| 
       22 
     | 
    
         
            -
                    let module_item = 
     | 
| 
       23 
     | 
    
         
            -
                        .import(export_name.as_str())
         
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
      
 22 
     | 
    
         
            +
                    let module_item =
         
     | 
| 
      
 23 
     | 
    
         
            +
                        module.import(export_name.as_str()).map_err(|error| {
         
     | 
| 
      
 24 
     | 
    
         
            +
                            Error::new(exception::runtime_error(), format!("{}", error))
         
     | 
| 
      
 25 
     | 
    
         
            +
                        })?;
         
     | 
| 
       25 
26 
     | 
    
         | 
| 
       26 
27 
     | 
    
         
             
                    match module_item {
         
     | 
| 
       27 
28 
     | 
    
         
             
                        js::module_item::ModuleItem::Value(v) => Ok(v.to_ruby().unwrap()),
         
     | 
| 
         @@ -1,3 +1,4 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            use crate::js::worker::WORKER;
         
     | 
| 
       1 
2 
     | 
    
         
             
            use deno_core::error::AnyError;
         
     | 
| 
       2 
3 
     | 
    
         
             
            use magnus::r_hash::ForEach;
         
     | 
| 
       3 
4 
     | 
    
         
             
            use magnus::value::{Qfalse, Qtrue};
         
     | 
| 
         @@ -5,6 +6,7 @@ use magnus::{ 
     | 
|
| 
       5 
6 
     | 
    
         
             
                Integer, RArray, RFloat, RHash, RString, RStruct, Symbol, Value, QFALSE,
         
     | 
| 
       6 
7 
     | 
    
         
             
                QNIL, QTRUE,
         
     | 
| 
       7 
8 
     | 
    
         
             
            };
         
     | 
| 
      
 9 
     | 
    
         
            +
            use std::collections::HashMap;
         
     | 
| 
       8 
10 
     | 
    
         
             
            use v8::{Array, GetPropertyNamesArgs, Global, HandleScope, Local, Object};
         
     | 
| 
       9 
11 
     | 
    
         | 
| 
       10 
12 
     | 
    
         
             
            pub fn convert_v8_to_ruby(
         
     | 
| 
         @@ -157,3 +159,67 @@ pub fn convert_ruby_to_v8<'s>( 
     | 
|
| 
       157 
159 
     | 
    
         | 
| 
       158 
160 
     | 
    
         
             
                Ok(v8::null(scope).into())
         
     | 
| 
       159 
161 
     | 
    
         
             
            }
         
     | 
| 
      
 162 
     | 
    
         
            +
             
     | 
| 
      
 163 
     | 
    
         
            +
            pub(crate) fn low_memory_notification() {
         
     | 
| 
      
 164 
     | 
    
         
            +
                WORKER.with(|worker| {
         
     | 
| 
      
 165 
     | 
    
         
            +
                    let mut worker = worker.worker.borrow_mut();
         
     | 
| 
      
 166 
     | 
    
         
            +
                    worker.js_runtime.v8_isolate().low_memory_notification();
         
     | 
| 
      
 167 
     | 
    
         
            +
                });
         
     | 
| 
      
 168 
     | 
    
         
            +
            }
         
     | 
| 
      
 169 
     | 
    
         
            +
             
     | 
| 
      
 170 
     | 
    
         
            +
            pub(crate) fn stats() -> RHash {
         
     | 
| 
      
 171 
     | 
    
         
            +
                WORKER.with(|worker| {
         
     | 
| 
      
 172 
     | 
    
         
            +
                    let mut worker = worker.worker.borrow_mut();
         
     | 
| 
      
 173 
     | 
    
         
            +
             
     | 
| 
      
 174 
     | 
    
         
            +
                    let heap_stats = &mut Default::default();
         
     | 
| 
      
 175 
     | 
    
         
            +
                    worker
         
     | 
| 
      
 176 
     | 
    
         
            +
                        .js_runtime
         
     | 
| 
      
 177 
     | 
    
         
            +
                        .v8_isolate()
         
     | 
| 
      
 178 
     | 
    
         
            +
                        .get_heap_statistics(heap_stats);
         
     | 
| 
      
 179 
     | 
    
         
            +
             
     | 
| 
      
 180 
     | 
    
         
            +
                    let current_thread = std::thread::current();
         
     | 
| 
      
 181 
     | 
    
         
            +
                    let thread = HashMap::from([(
         
     | 
| 
      
 182 
     | 
    
         
            +
                        "thread_id",
         
     | 
| 
      
 183 
     | 
    
         
            +
                        format!("{:?}", current_thread.id()),
         
     | 
| 
      
 184 
     | 
    
         
            +
                    )]);
         
     | 
| 
      
 185 
     | 
    
         
            +
             
     | 
| 
      
 186 
     | 
    
         
            +
                    let heap = HashMap::from([
         
     | 
| 
      
 187 
     | 
    
         
            +
                        ("external_memory", heap_stats.external_memory()),
         
     | 
| 
      
 188 
     | 
    
         
            +
                        ("heap_size_limit", heap_stats.heap_size_limit()),
         
     | 
| 
      
 189 
     | 
    
         
            +
                        ("malloced_memory", heap_stats.malloced_memory()),
         
     | 
| 
      
 190 
     | 
    
         
            +
                        (
         
     | 
| 
      
 191 
     | 
    
         
            +
                            "number_of_detached_contexts",
         
     | 
| 
      
 192 
     | 
    
         
            +
                            heap_stats.number_of_detached_contexts(),
         
     | 
| 
      
 193 
     | 
    
         
            +
                        ),
         
     | 
| 
      
 194 
     | 
    
         
            +
                        (
         
     | 
| 
      
 195 
     | 
    
         
            +
                            "number_of_native_contexts",
         
     | 
| 
      
 196 
     | 
    
         
            +
                            heap_stats.number_of_native_contexts(),
         
     | 
| 
      
 197 
     | 
    
         
            +
                        ),
         
     | 
| 
      
 198 
     | 
    
         
            +
                        ("peak_malloced_memory", heap_stats.peak_malloced_memory()),
         
     | 
| 
      
 199 
     | 
    
         
            +
                        ("total_available_size", heap_stats.total_available_size()),
         
     | 
| 
      
 200 
     | 
    
         
            +
                        (
         
     | 
| 
      
 201 
     | 
    
         
            +
                            "total_global_handles_size",
         
     | 
| 
      
 202 
     | 
    
         
            +
                            heap_stats.total_global_handles_size(),
         
     | 
| 
      
 203 
     | 
    
         
            +
                        ),
         
     | 
| 
      
 204 
     | 
    
         
            +
                        ("total_heap_size", heap_stats.total_heap_size()),
         
     | 
| 
      
 205 
     | 
    
         
            +
                        (
         
     | 
| 
      
 206 
     | 
    
         
            +
                            "total_heap_size_executable",
         
     | 
| 
      
 207 
     | 
    
         
            +
                            heap_stats.total_heap_size_executable(),
         
     | 
| 
      
 208 
     | 
    
         
            +
                        ),
         
     | 
| 
      
 209 
     | 
    
         
            +
                        ("total_physical_size", heap_stats.total_physical_size()),
         
     | 
| 
      
 210 
     | 
    
         
            +
                        (
         
     | 
| 
      
 211 
     | 
    
         
            +
                            "used_global_handles_size",
         
     | 
| 
      
 212 
     | 
    
         
            +
                            heap_stats.used_global_handles_size(),
         
     | 
| 
      
 213 
     | 
    
         
            +
                        ),
         
     | 
| 
      
 214 
     | 
    
         
            +
                        ("used_heap_size", heap_stats.used_heap_size()),
         
     | 
| 
      
 215 
     | 
    
         
            +
                    ]);
         
     | 
| 
      
 216 
     | 
    
         
            +
             
     | 
| 
      
 217 
     | 
    
         
            +
                    let h = RHash::new();
         
     | 
| 
      
 218 
     | 
    
         
            +
                    h.aset("current_thread", RHash::from_iter(thread))
         
     | 
| 
      
 219 
     | 
    
         
            +
                        .expect("cannot set stats for current_thread");
         
     | 
| 
      
 220 
     | 
    
         
            +
                    h.aset("heap", RHash::from_iter(heap))
         
     | 
| 
      
 221 
     | 
    
         
            +
                        .expect("cannot set stats for heap");
         
     | 
| 
      
 222 
     | 
    
         
            +
             
     | 
| 
      
 223 
     | 
    
         
            +
                    h
         
     | 
| 
      
 224 
     | 
    
         
            +
                })
         
     | 
| 
      
 225 
     | 
    
         
            +
            }
         
     | 
    
        data/ext/isorun/src/js/worker.rs
    CHANGED
    
    | 
         @@ -3,7 +3,7 @@ use deno_core::error::AnyError; 
     | 
|
| 
       3 
3 
     | 
    
         
             
            use deno_core::serde_v8::from_v8;
         
     | 
| 
       4 
4 
     | 
    
         
             
            use deno_core::{op, serde_v8, Extension, FsModuleLoader, JsRealm, ModuleId};
         
     | 
| 
       5 
5 
     | 
    
         
             
            use deno_runtime::deno_broadcast_channel::InMemoryBroadcastChannel;
         
     | 
| 
       6 
     | 
    
         
            -
            use deno_runtime::permissions:: 
     | 
| 
      
 6 
     | 
    
         
            +
            use deno_runtime::permissions::PermissionsContainer;
         
     | 
| 
       7 
7 
     | 
    
         
             
            use deno_runtime::worker::{MainWorker, WorkerOptions};
         
     | 
| 
       8 
8 
     | 
    
         
             
            use deno_runtime::BootstrapOptions;
         
     | 
| 
       9 
9 
     | 
    
         
             
            use deno_web::BlobStore;
         
     | 
| 
         @@ -207,7 +207,7 @@ impl Default for Worker { 
     | 
|
| 
       207 
207 
     | 
    
         
             
                        todo!("Web workers are not supported in the example");
         
     | 
| 
       208 
208 
     | 
    
         
             
                    });
         
     | 
| 
       209 
209 
     | 
    
         | 
| 
       210 
     | 
    
         
            -
                    let extension_send = Extension::builder()
         
     | 
| 
      
 210 
     | 
    
         
            +
                    let extension_send = Extension::builder("isorun")
         
     | 
| 
       211 
211 
     | 
    
         
             
                        .ops(vec![op_send_to_ruby::decl()])
         
     | 
| 
       212 
212 
     | 
    
         
             
                        .build();
         
     | 
| 
       213 
213 
     | 
    
         
             
                    let mut extensions = vec![extension_send];
         
     | 
| 
         @@ -229,6 +229,7 @@ impl Default for Worker { 
     | 
|
| 
       229 
229 
     | 
    
         
             
                            inspect: false,
         
     | 
| 
       230 
230 
     | 
    
         
             
                        },
         
     | 
| 
       231 
231 
     | 
    
         
             
                        extensions: std::mem::take(&mut extensions),
         
     | 
| 
      
 232 
     | 
    
         
            +
                        extensions_with_js: Default::default(),
         
     | 
| 
       232 
233 
     | 
    
         
             
                        startup_snapshot: None,
         
     | 
| 
       233 
234 
     | 
    
         
             
                        unsafely_ignore_certificate_errors: None,
         
     | 
| 
       234 
235 
     | 
    
         
             
                        root_cert_store: None,
         
     | 
| 
         @@ -262,7 +263,7 @@ impl Default for Worker { 
     | 
|
| 
       262 
263 
     | 
    
         | 
| 
       263 
264 
     | 
    
         
             
                    let main_module =
         
     | 
| 
       264 
265 
     | 
    
         
             
                        deno_core::resolve_path(&js_path.to_string_lossy()).unwrap();
         
     | 
| 
       265 
     | 
    
         
            -
                    let permissions =  
     | 
| 
      
 266 
     | 
    
         
            +
                    let permissions = PermissionsContainer::allow_all();
         
     | 
| 
       266 
267 
     | 
    
         
             
                    let mut worker = MainWorker::bootstrap_from_options(
         
     | 
| 
       267 
268 
     | 
    
         
             
                        main_module.clone(),
         
     | 
| 
       268 
269 
     | 
    
         
             
                        permissions,
         
     | 
    
        data/ext/isorun/src/lib.rs
    CHANGED
    
    | 
         @@ -1,4 +1,6 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            use self::isorun::utils::stats;
         
     | 
| 
       1 
2 
     | 
    
         
             
            use crate::isorun::context::Context;
         
     | 
| 
      
 3 
     | 
    
         
            +
            use crate::isorun::utils::low_memory_notification;
         
     | 
| 
       2 
4 
     | 
    
         
             
            use isorun::function::Function;
         
     | 
| 
       3 
5 
     | 
    
         
             
            use isorun::module::Module;
         
     | 
| 
       4 
6 
     | 
    
         
             
            use magnus::{define_module, function, method, Error, Module as M, Object};
         
     | 
| 
         @@ -10,6 +12,15 @@ mod js; 
     | 
|
| 
       10 
12 
     | 
    
         
             
            fn init() -> Result<(), Error> {
         
     | 
| 
       11 
13 
     | 
    
         
             
                let root = define_module("Isorun").expect("cannot define module: Isorun");
         
     | 
| 
       12 
14 
     | 
    
         | 
| 
      
 15 
     | 
    
         
            +
                root.define_module_function("stats", function!(stats, 0))
         
     | 
| 
      
 16 
     | 
    
         
            +
                    .expect("cannot define module function: stats");
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                root.define_module_function(
         
     | 
| 
      
 19 
     | 
    
         
            +
                    "low_memory_notification",
         
     | 
| 
      
 20 
     | 
    
         
            +
                    function!(low_memory_notification, 0),
         
     | 
| 
      
 21 
     | 
    
         
            +
                )
         
     | 
| 
      
 22 
     | 
    
         
            +
                .expect("cannot define module function: low_memory_notification");
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
       13 
24 
     | 
    
         
             
                let context = root
         
     | 
| 
       14 
25 
     | 
    
         
             
                    .define_class("Context", Default::default())
         
     | 
| 
       15 
26 
     | 
    
         
             
                    .expect("cannot define class: Isorun::Context");
         
     | 
| 
         Binary file 
     | 
| 
         Binary file 
     | 
| 
         Binary file 
     | 
| 
         Binary file 
     | 
    
        data/lib/isorun/context.rb
    CHANGED
    
    | 
         @@ -10,7 +10,10 @@ module Isorun 
     | 
|
| 
       10 
10 
     | 
    
         
             
                    @export_names = export_names
         
     | 
| 
       11 
11 
     | 
    
         
             
                  end
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
      
 13 
     | 
    
         
            +
                  # Specify the module to import from
         
     | 
| 
       13 
14 
     | 
    
         
             
                  def from(module_path)
         
     | 
| 
      
 15 
     | 
    
         
            +
                    module_path = module_path.to_s if module_path.is_a? Pathname
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
       14 
17 
     | 
    
         
             
                    mod = load(module_path)
         
     | 
| 
       15 
18 
     | 
    
         
             
                    imports = export_names.map { |export_name| mod.import(export_name) }
         
     | 
| 
       16 
19 
     | 
    
         
             
                    return imports.first if imports.size == 1
         
     | 
| 
         @@ -23,7 +26,7 @@ module Isorun 
     | 
|
| 
       23 
26 
     | 
    
         
             
                  CACHE_KEY = "isorun_module_path_mtime"
         
     | 
| 
       24 
27 
     | 
    
         
             
                  private_constant :CACHE_KEY
         
     | 
| 
       25 
28 
     | 
    
         | 
| 
       26 
     | 
    
         
            -
                  def load(module_path)
         
     | 
| 
      
 29 
     | 
    
         
            +
                  def load(module_path) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
         
     | 
| 
       27 
30 
     | 
    
         
             
                    return context.load(module_path) if Rails.env.production?
         
     | 
| 
       28 
31 
     | 
    
         | 
| 
       29 
32 
     | 
    
         
             
                    key = module_path.parameterize
         
     | 
| 
         @@ -41,10 +44,14 @@ module Isorun 
     | 
|
| 
       41 
44 
     | 
    
         
             
                    # map to URI scheme to allow adding a timestamp to bust module cache
         
     | 
| 
       42 
45 
     | 
    
         
             
                    module_path = "file://#{module_path}?t=#{mtime}"
         
     | 
| 
       43 
46 
     | 
    
         | 
| 
       44 
     | 
    
         
            -
                     
     | 
| 
      
 47 
     | 
    
         
            +
                    if cache_miss
         
     | 
| 
      
 48 
     | 
    
         
            +
                      ActiveSupport::Notifications.instrument "load.module.isorun", { path: module_path }
         
     | 
| 
      
 49 
     | 
    
         
            +
                      return context.load(module_path)
         
     | 
| 
      
 50 
     | 
    
         
            +
                    end
         
     | 
| 
       45 
51 
     | 
    
         | 
| 
       46 
52 
     | 
    
         
             
                    Rails.cache.write("#{CACHE_KEY}:#{key}", mtime) if prev_mtime < mtime
         
     | 
| 
       47 
53 
     | 
    
         | 
| 
      
 54 
     | 
    
         
            +
                    ActiveSupport::Notifications.instrument "load.module.isorun", { path: module_path }
         
     | 
| 
       48 
55 
     | 
    
         
             
                    context.load(module_path)
         
     | 
| 
       49 
56 
     | 
    
         
             
                  end
         
     | 
| 
       50 
57 
     | 
    
         
             
                end
         
     | 
| 
         @@ -52,11 +59,30 @@ module Isorun 
     | 
|
| 
       52 
59 
     | 
    
         
             
                private_constant :Import
         
     | 
| 
       53 
60 
     | 
    
         | 
| 
       54 
61 
     | 
    
         
             
                class << self
         
     | 
| 
       55 
     | 
    
         
            -
                   
     | 
| 
      
 62 
     | 
    
         
            +
                  # Creates a new context and yields the context as the first argument to
         
     | 
| 
      
 63 
     | 
    
         
            +
                  # the block.
         
     | 
| 
      
 64 
     | 
    
         
            +
                  #
         
     | 
| 
      
 65 
     | 
    
         
            +
                  # @example Creates a new context, imports the default as function
         
     | 
| 
      
 66 
     | 
    
         
            +
                  #   result = Isorun::Context.create do |context|
         
     | 
| 
      
 67 
     | 
    
         
            +
                  #     func = context.import.from(module_path)
         
     | 
| 
      
 68 
     | 
    
         
            +
                  #     func.call("Hello, World!")
         
     | 
| 
      
 69 
     | 
    
         
            +
                  #   end
         
     | 
| 
      
 70 
     | 
    
         
            +
                  #
         
     | 
| 
      
 71 
     | 
    
         
            +
                  # @yield [context] The newly created JavaScript context
         
     | 
| 
      
 72 
     | 
    
         
            +
                  # @yieldparam [Isorun::Context] context
         
     | 
| 
      
 73 
     | 
    
         
            +
                  # @yieldreturn [Object, nil] An optional return value from the execution context
         
     | 
| 
      
 74 
     | 
    
         
            +
                  def create(options = default_options, &block)
         
     | 
| 
       56 
75 
     | 
    
         
             
                    raise "[Isorun::Context] block missing when creating context" unless block
         
     | 
| 
       57 
76 
     | 
    
         | 
| 
       58 
77 
     | 
    
         
             
                    context = Isorun::Context.new
         
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
                    context.receiver = options[:receiver] if options[:receiver].present?
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
                    result = yield(context)
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
                    context.receiver = nil if options[:receiver].present?
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
                    result
         
     | 
| 
       60 
86 
     | 
    
         
             
                  end
         
     | 
| 
       61 
87 
     | 
    
         | 
| 
       62 
88 
     | 
    
         
             
                  # @!method new()
         
     | 
| 
         @@ -66,11 +92,28 @@ module Isorun 
     | 
|
| 
       66 
92 
     | 
    
         | 
| 
       67 
93 
     | 
    
         
             
                  def default_options
         
     | 
| 
       68 
94 
     | 
    
         
             
                    {
         
     | 
| 
       69 
     | 
    
         
            -
                      receiver:  
     | 
| 
      
 95 
     | 
    
         
            +
                      receiver: nil
         
     | 
| 
       70 
96 
     | 
    
         
             
                    }
         
     | 
| 
       71 
97 
     | 
    
         
             
                  end
         
     | 
| 
       72 
98 
     | 
    
         
             
                end
         
     | 
| 
       73 
99 
     | 
    
         | 
| 
      
 100 
     | 
    
         
            +
                # Specify items you want to import from the module. If none is specified,
         
     | 
| 
      
 101 
     | 
    
         
            +
                # the default export is taken.
         
     | 
| 
      
 102 
     | 
    
         
            +
                #
         
     | 
| 
      
 103 
     | 
    
         
            +
                # @example Import default export
         
     | 
| 
      
 104 
     | 
    
         
            +
                #   result = Isorun::Context.create do |context|
         
     | 
| 
      
 105 
     | 
    
         
            +
                #     item = context.import.from(module_path)
         
     | 
| 
      
 106 
     | 
    
         
            +
                #   end
         
     | 
| 
      
 107 
     | 
    
         
            +
                #
         
     | 
| 
      
 108 
     | 
    
         
            +
                # @example Import default export explicitly
         
     | 
| 
      
 109 
     | 
    
         
            +
                #   result = Isorun::Context.create do |context|
         
     | 
| 
      
 110 
     | 
    
         
            +
                #     item = context.import(:default).from(module_path)
         
     | 
| 
      
 111 
     | 
    
         
            +
                #   end
         
     | 
| 
      
 112 
     | 
    
         
            +
                #
         
     | 
| 
      
 113 
     | 
    
         
            +
                # @example Import various exports
         
     | 
| 
      
 114 
     | 
    
         
            +
                #   result = Isorun::Context.create do |context|
         
     | 
| 
      
 115 
     | 
    
         
            +
                #     hello, world = context.import(:hello, :world).from(module_path)
         
     | 
| 
      
 116 
     | 
    
         
            +
                #   end
         
     | 
| 
       74 
117 
     | 
    
         
             
                def import(*export_names)
         
     | 
| 
       75 
118 
     | 
    
         
             
                  export_names = [*export_names].map(&:to_s)
         
     | 
| 
       76 
119 
     | 
    
         
             
                  export_names = [:default.to_s] if export_names.empty?
         
     | 
| 
         @@ -78,6 +121,7 @@ module Isorun 
     | 
|
| 
       78 
121 
     | 
    
         
             
                end
         
     | 
| 
       79 
122 
     | 
    
         | 
| 
       80 
123 
     | 
    
         
             
                # @!method receiver=(receiver)
         
     | 
| 
      
 124 
     | 
    
         
            +
                #
         
     | 
| 
       81 
125 
     | 
    
         
             
                # @param receiver [Proc, nil]
         
     | 
| 
       82 
126 
     | 
    
         
             
                # @return [Isorun::Context] the newly created context
         
     | 
| 
       83 
127 
     | 
    
         
             
              end
         
     | 
    
        data/lib/isorun/engine.rb
    CHANGED
    
    
    
        data/lib/isorun/resolver.rb
    CHANGED
    
    | 
         @@ -10,6 +10,10 @@ module Isorun 
     | 
|
| 
       10 
10 
     | 
    
         
             
                  end
         
     | 
| 
       11 
11 
     | 
    
         
             
                }
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
      
 13 
     | 
    
         
            +
                SSR_VITE_APP_RESOLVER = lambda { |_bundle_id|
         
     | 
| 
      
 14 
     | 
    
         
            +
                  Rails.public_path.join("vite-ssr/ssr.js").to_s
         
     | 
| 
      
 15 
     | 
    
         
            +
                }
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
       13 
17 
     | 
    
         
             
                SIMPLE_RESOLVER = lambda { |bundle_id|
         
     | 
| 
       14 
18 
     | 
    
         
             
                  if Rails.env.development?
         
     | 
| 
       15 
19 
     | 
    
         
             
                    Rails.root.join("app", "assets", "builds", "#{bundle_id}.js").to_s
         
     | 
    
        data/lib/isorun/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: isorun
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.9
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: x86_64-darwin
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Hannes Moser
         
     | 
| 
       8 
     | 
    
         
            -
            autorequire:
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2023-01-31 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: railties
         
     | 
| 
         @@ -24,6 +24,7 @@ dependencies: 
     | 
|
| 
       24 
24 
     | 
    
         
             
                - - ">="
         
     | 
| 
       25 
25 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       26 
26 
     | 
    
         
             
                    version: 6.0.0
         
     | 
| 
      
 27 
     | 
    
         
            +
              force_ruby_platform: false
         
     | 
| 
       27 
28 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       28 
29 
     | 
    
         
             
              name: rake
         
     | 
| 
       29 
30 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -38,6 +39,7 @@ dependencies: 
     | 
|
| 
       38 
39 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       39 
40 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       40 
41 
     | 
    
         
             
                    version: '13.0'
         
     | 
| 
      
 42 
     | 
    
         
            +
              force_ruby_platform: false
         
     | 
| 
       41 
43 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       42 
44 
     | 
    
         
             
              name: rb_sys
         
     | 
| 
       43 
45 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -52,6 +54,21 @@ dependencies: 
     | 
|
| 
       52 
54 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       53 
55 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       54 
56 
     | 
    
         
             
                    version: 0.9.46
         
     | 
| 
      
 57 
     | 
    
         
            +
              force_ruby_platform: false
         
     | 
| 
      
 58 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 59 
     | 
    
         
            +
              name: rails
         
     | 
| 
      
 60 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 61 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 62 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 63 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 64 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 65 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 66 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 67 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 68 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 69 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 70 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 71 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
       55 
72 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       56 
73 
     | 
    
         
             
              name: rake-compiler
         
     | 
| 
       57 
74 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -80,6 +97,20 @@ dependencies: 
     | 
|
| 
       80 
97 
     | 
    
         
             
                - - ">="
         
     | 
| 
       81 
98 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       82 
99 
     | 
    
         
             
                    version: '0'
         
     | 
| 
      
 100 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 101 
     | 
    
         
            +
              name: rspec
         
     | 
| 
      
 102 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 103 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 104 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 105 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 106 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 107 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 108 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 109 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 110 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 111 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 112 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 113 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
       83 
114 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       84 
115 
     | 
    
         
             
              name: rspec-rails
         
     | 
| 
       85 
116 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -94,10 +125,27 @@ dependencies: 
     | 
|
| 
       94 
125 
     | 
    
         
             
                - - ">="
         
     | 
| 
       95 
126 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       96 
127 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       97 
     | 
    
         
            -
             
     | 
| 
       98 
     | 
    
         
            -
               
     | 
| 
       99 
     | 
    
         
            -
               
     | 
| 
       100 
     | 
    
         
            -
             
     | 
| 
      
 128 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 129 
     | 
    
         
            +
              name: simplecov
         
     | 
| 
      
 130 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 131 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 132 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 133 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 134 
     | 
    
         
            +
                    version: 0.22.0
         
     | 
| 
      
 135 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 136 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 137 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 138 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 139 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 140 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 141 
     | 
    
         
            +
                    version: 0.22.0
         
     | 
| 
      
 142 
     | 
    
         
            +
            description: |
         
     | 
| 
      
 143 
     | 
    
         
            +
              Import ECMAScript modules into Ruby and use values and functions like
         
     | 
| 
      
 144 
     | 
    
         
            +
              JavaScript is part of Ruby. Enables easy to set up server-side rendering for
         
     | 
| 
      
 145 
     | 
    
         
            +
              modern frontend stacks.
         
     | 
| 
      
 146 
     | 
    
         
            +
             
     | 
| 
      
 147 
     | 
    
         
            +
              Isorun embeds v8 into Ruby via a native extension built with Rust and
         
     | 
| 
      
 148 
     | 
    
         
            +
              deno_core.
         
     | 
| 
       101 
149 
     | 
    
         
             
            email:
         
     | 
| 
       102 
150 
     | 
    
         
             
            - box@hannesmoser.at
         
     | 
| 
       103 
151 
     | 
    
         
             
            executables: []
         
     | 
| 
         @@ -108,6 +156,7 @@ files: 
     | 
|
| 
       108 
156 
     | 
    
         
             
            - README.md
         
     | 
| 
       109 
157 
     | 
    
         
             
            - Rakefile
         
     | 
| 
       110 
158 
     | 
    
         
             
            - app/helpers/isorun/app_helper.rb
         
     | 
| 
      
 159 
     | 
    
         
            +
            - app/helpers/isorun/vite_app_helper.rb
         
     | 
| 
       111 
160 
     | 
    
         
             
            - ext/isorun/Cargo.lock
         
     | 
| 
       112 
161 
     | 
    
         
             
            - ext/isorun/Cargo.toml
         
     | 
| 
       113 
162 
     | 
    
         
             
            - ext/isorun/extconf.rb
         
     | 
| 
         @@ -126,6 +175,7 @@ files: 
     | 
|
| 
       126 
175 
     | 
    
         
             
            - lib/isorun/2.7/isorun.bundle
         
     | 
| 
       127 
176 
     | 
    
         
             
            - lib/isorun/3.0/isorun.bundle
         
     | 
| 
       128 
177 
     | 
    
         
             
            - lib/isorun/3.1/isorun.bundle
         
     | 
| 
      
 178 
     | 
    
         
            +
            - lib/isorun/3.2/isorun.bundle
         
     | 
| 
       129 
179 
     | 
    
         
             
            - lib/isorun/config.rb
         
     | 
| 
       130 
180 
     | 
    
         
             
            - lib/isorun/config/abstract_builder.rb
         
     | 
| 
       131 
181 
     | 
    
         
             
            - lib/isorun/config/option.rb
         
     | 
| 
         @@ -146,7 +196,7 @@ metadata: 
     | 
|
| 
       146 
196 
     | 
    
         
             
              changelog_uri: https://github.com/eliias/isorun
         
     | 
| 
       147 
197 
     | 
    
         
             
              documentation_uri: https://eliias.github.io/isorun
         
     | 
| 
       148 
198 
     | 
    
         
             
              rubygems_mfa_required: 'true'
         
     | 
| 
       149 
     | 
    
         
            -
            post_install_message:
         
     | 
| 
      
 199 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
       150 
200 
     | 
    
         
             
            rdoc_options: []
         
     | 
| 
       151 
201 
     | 
    
         
             
            require_paths:
         
     | 
| 
       152 
202 
     | 
    
         
             
            - lib
         
     | 
| 
         @@ -157,15 +207,15 @@ required_ruby_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       157 
207 
     | 
    
         
             
                  version: '2.7'
         
     | 
| 
       158 
208 
     | 
    
         
             
              - - "<"
         
     | 
| 
       159 
209 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       160 
     | 
    
         
            -
                  version: 3. 
     | 
| 
      
 210 
     | 
    
         
            +
                  version: 3.3.dev
         
     | 
| 
       161 
211 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       162 
212 
     | 
    
         
             
              requirements:
         
     | 
| 
       163 
213 
     | 
    
         
             
              - - ">="
         
     | 
| 
       164 
214 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       165 
215 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       166 
216 
     | 
    
         
             
            requirements: []
         
     | 
| 
       167 
     | 
    
         
            -
            rubygems_version: 3. 
     | 
| 
       168 
     | 
    
         
            -
            signing_key:
         
     | 
| 
      
 217 
     | 
    
         
            +
            rubygems_version: 3.4.4
         
     | 
| 
      
 218 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
       169 
219 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       170 
220 
     | 
    
         
             
            summary: Run JavaScript applications in your Rails application.
         
     | 
| 
       171 
221 
     | 
    
         
             
            test_files: []
         
     |