isorun 0.1.8-x86_64-linux → 0.1.10-x86_64-linux

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b7fbac84c4db38f693ab09b2e841b9c8ef840cfeb50d212d1123d147e6bc8ff
4
- data.tar.gz: bfa169c65285f23465e5016eb8b0e5a8700cad33e966ecaaa8e7bf101ed15bb2
3
+ metadata.gz: 216ea619017f0f5b07c05c3d91359ed86025028cd31bd3e5477485aa7d4e1dad
4
+ data.tar.gz: 8524b6d922bf41e48416cfacb7e7114b83aaa32e17dfa143b1dca924d6d5c1f2
5
5
  SHA512:
6
- metadata.gz: 426b9460bfda7af56298427b522808a0816506799895ea4f6adf57836ad259622e056b040d860e4c568a7a01d749496d65255aa45014fe02276b3ba27e32f7c6
7
- data.tar.gz: 85d72159f954e240c8d68d1c415e5f07e751df504a23310f4305eba9f47c5d90d44b61ed42c92c536fe3b2b40d0ea85e9deba2e4b9811bf150dc67ed83453712
6
+ metadata.gz: f95053349ea4cc5491957e3ce68ac3b7a534a86b5dd1047fe33b82b926292c90344847c150a157a613ff25c73d223dfc92e5638417e0926b0a08bb12b39fb5b4
7
+ data.tar.gz: c54384ad627e4f44440bb16e068482965a6efc177d32b6d282fc9c19f028d69ccddbf7304cb9291f694dc7c65cd6288e883dd33ba2001be175cf270a28f397b8
@@ -14,10 +14,13 @@ module Isorun
14
14
  # </body>
15
15
  # </html>
16
16
  #
17
+ # @see https://api.rubyonrails.org/v5.1/classes/ActionView/Helpers/TagHelper.html#method-i-tag
17
18
  # @param id [String] An ID representing both, the asset bundle, and by
18
19
  # convention, the target node (e.g. `<div id="my_app">`)
20
+ # @param [Hash] options All valid tag options can also passed as options
21
+ # to this method
19
22
  # @return [String]
20
- def isorun_app(id) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
23
+ def isorun_app(id, options = nil) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
21
24
  ActiveSupport::Notifications.instrument "start.render.isorun", { ts: Time.current }
22
25
 
23
26
  module_path = Isorun.config.module_resolver.call(id)
@@ -43,7 +46,10 @@ module Isorun
43
46
  end
44
47
 
45
48
  html = if ssr_html.present?
46
- tag.div id: id do
49
+ options ||= {}
50
+ options[:id] = id
51
+
52
+ tag.div(**options) do
47
53
  ssr_html.html_safe # rubocop:disable Rails/OutputSafety
48
54
  end
49
55
  else
@@ -0,0 +1,78 @@
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
+ # @see https://api.rubyonrails.org/v5.1/classes/ActionView/Helpers/TagHelper.html#method-i-tag
19
+ # @param [String] id An ID representing both, the asset bundle, and by
20
+ # convention, the target node (e.g. `<div id="my_app">`)
21
+ # @param [Hash] options All valid tag options can also passed as options
22
+ # to this method
23
+ # @return [String]
24
+ def isorun_vite_app(id, options = nil)
25
+ ActiveSupport::Notifications.instrument "start.render.isorun", { ts: Time.current }
26
+
27
+ # if id has a file extension, we extract the extension and reduce the ID
28
+ # to the basename
29
+ extension = (File.extname(id) || ".js").delete_prefix(".")
30
+ id = File.basename(id, ".*")
31
+
32
+ module_path = Isorun.config.module_resolver.call(id)
33
+
34
+ ssr_html = Isorun::Context.create(receiver: Isorun.config.receiver) do |context|
35
+ render_context = { environment: Rails.env.to_s }
36
+ render_function = context.import.from(module_path)
37
+
38
+ if render_function.blank?
39
+ Rails.logger.warn("[ISORUN] the requested app does not exist or " \
40
+ "does not have a server entrypoint. Please " \
41
+ "check if an asset with filename " + "
42
+ `public/vite-ssr/ssr.js` exists.")
43
+ return ""
44
+ end
45
+
46
+ html = render_function.call(render_context)
47
+
48
+ ActiveSupport::Notifications.instrument "finish.render.isorun", { ts: Time.current }
49
+ ActiveSupport::Notifications.instrument "stats.isorun", Isorun.stats
50
+
51
+ html
52
+ end
53
+
54
+ html = if ssr_html.present?
55
+ options ||= {}
56
+ options[:id] = id
57
+
58
+ tag.div(**options) do
59
+ ssr_html.html_safe # rubocop:disable Rails/OutputSafety
60
+ end
61
+ else
62
+ Rails.logger.warn("[ISORUN] The server-side rendered result is empty.")
63
+ ""
64
+ end
65
+
66
+ html += "\n"
67
+ case extension
68
+ when "js", "jsx"
69
+ html += vite_javascript_tag("#{id}.#{extension}")
70
+ when "ts", "tsx"
71
+ html += vite_typescript_tag("#{id}.#{extension}")
72
+ else
73
+ Rails.logger.warn("[ISORUN] unsupported client application extension: `#{extension}`")
74
+ end
75
+ html.html_safe # rubocop:disable Rails/OutputSafety
76
+ end
77
+ end
78
+ end
@@ -1,26 +1,26 @@
1
1
  [package]
2
2
  name = "isorun"
3
- version = "0.1.8"
3
+ version = "0.1.10"
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.83.0"
11
- deno_core = "0.165.0"
12
- deno_fetch = "0.107.0"
13
- deno_runtime = "0.91.0"
14
- deno_url = "0.83.0"
15
- deno_web = "0.114.0"
16
- deno_webidl = "0.83.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 = "5220756ca0ab4f2bc32d38310c26f7dda2be9bd6" }
18
+ magnus = { git = "https://github.com/eliias/magnus", rev = "75e2ba89d12af8c51d2bbbb137da2eac3fc966e3" }
19
19
  tokio = { version = "1.21.1", features = ["full"] }
20
- v8 = "0.60.0"
20
+ v8 = "0.60.1"
21
21
 
22
22
  [dev-dependencies]
23
- magnus = { git = "https://github.com/eliias/magnus", rev = "5220756ca0ab4f2bc32d38310c26f7dda2be9bd6", features = ["embed"] }
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 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::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];
@@ -263,7 +263,7 @@ impl Default for Worker {
263
263
 
264
264
  let main_module =
265
265
  deno_core::resolve_path(&js_path.to_string_lossy()).unwrap();
266
- let permissions = Permissions::allow_all();
266
+ let permissions = PermissionsContainer::allow_all();
267
267
  let mut worker = MainWorker::bootstrap_from_options(
268
268
  main_module.clone(),
269
269
  permissions,
Binary file
Binary file
Binary file
Binary file
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Isorun
4
- VERSION = "0.1.8"
4
+ VERSION = "0.1.10"
5
5
  end
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.8
4
+ version: 0.1.10
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - Hannes Moser
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-13 00:00:00.000000000 Z
11
+ date: 2023-02-03 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,7 @@ dependencies:
52
54
  - - "~>"
53
55
  - !ruby/object:Gem::Version
54
56
  version: 0.9.46
57
+ force_ruby_platform: false
55
58
  - !ruby/object:Gem::Dependency
56
59
  name: rails
57
60
  requirement: !ruby/object:Gem::Requirement
@@ -153,6 +156,7 @@ files:
153
156
  - README.md
154
157
  - Rakefile
155
158
  - app/helpers/isorun/app_helper.rb
159
+ - app/helpers/isorun/vite_app_helper.rb
156
160
  - ext/isorun/Cargo.lock
157
161
  - ext/isorun/Cargo.toml
158
162
  - ext/isorun/extconf.rb
@@ -171,6 +175,7 @@ files:
171
175
  - lib/isorun/2.7/isorun.so
172
176
  - lib/isorun/3.0/isorun.so
173
177
  - lib/isorun/3.1/isorun.so
178
+ - lib/isorun/3.2/isorun.so
174
179
  - lib/isorun/config.rb
175
180
  - lib/isorun/config/abstract_builder.rb
176
181
  - lib/isorun/config/option.rb
@@ -191,7 +196,7 @@ metadata:
191
196
  changelog_uri: https://github.com/eliias/isorun
192
197
  documentation_uri: https://eliias.github.io/isorun
193
198
  rubygems_mfa_required: 'true'
194
- post_install_message:
199
+ post_install_message:
195
200
  rdoc_options: []
196
201
  require_paths:
197
202
  - lib
@@ -202,15 +207,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
202
207
  version: '2.7'
203
208
  - - "<"
204
209
  - !ruby/object:Gem::Version
205
- version: 3.2.dev
210
+ version: 3.3.dev
206
211
  required_rubygems_version: !ruby/object:Gem::Requirement
207
212
  requirements:
208
213
  - - ">="
209
214
  - !ruby/object:Gem::Version
210
215
  version: '0'
211
216
  requirements: []
212
- rubygems_version: 3.3.22
213
- signing_key:
217
+ rubygems_version: 3.4.4
218
+ signing_key:
214
219
  specification_version: 4
215
220
  summary: Run JavaScript applications in your Rails application.
216
221
  test_files: []