isorun 0.1.8-arm64-darwin → 0.1.10-arm64-darwin
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/isorun/app_helper.rb +8 -2
- data/app/helpers/isorun/vite_app_helper.rb +78 -0
- data/ext/isorun/Cargo.toml +11 -11
- data/ext/isorun/src/js/worker.rs +3 -3
- 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/resolver.rb +4 -0
- data/lib/isorun/version.rb +1 -1
- metadata +12 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8500ad6077f9dd90991581e56e19f00b4ec5c7b740342d88e84f3a5f77587ef5
|
4
|
+
data.tar.gz: 44e38cf5a0eaffeeeec54852e1af7600d63af31e2f89f3828362de87c797e326
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9595bdc80fcfa5ddb881110c0be58745c8e2cf1dc02ca696972ad99f98062c2a9af0824ea43bc73cff0093046bd6c53406ccf498c68051be5e33caca8ed008ff
|
7
|
+
data.tar.gz: d75c541a4253bf22b6326b9978e972f7aaa8d18fbb734caaa53271c4da9347e24ec99fe7e294dfd5954aa2de927fd938fdcdcd95cd635bfc2efc116bc18a78f2
|
@@ -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
|
-
|
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
|
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.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.
|
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"
|
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];
|
@@ -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 =
|
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
|
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.10
|
5
5
|
platform: arm64-darwin
|
6
6
|
authors:
|
7
7
|
- Hannes Moser
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
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.bundle
|
172
176
|
- lib/isorun/3.0/isorun.bundle
|
173
177
|
- lib/isorun/3.1/isorun.bundle
|
178
|
+
- lib/isorun/3.2/isorun.bundle
|
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.
|
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.
|
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: []
|