isorun 0.1.8-arm64-darwin → 0.1.9-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/vite_app_helper.rb +72 -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: 202586b1207093a6ecadaedc79e87fa5fe7afc0274e865b8c47468f2b8726cb8
|
4
|
+
data.tar.gz: 99ce36eaa4e1013e0248e63f059b57615e27fbb85c0c45d533d5c963f52db762
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ae092708376ea0222a4de3a342a225fba041743f5af1f100b3298c216c5e12718023e2f87c285facda5f791f278b7e5e5350df11eeec49a5c19f514f26b2ec4
|
7
|
+
data.tar.gz: 215a38982a0e02ac2369d46e4e7249afbf97a10f07b8e6f45b74f2e58cbfe7deb0abc1d1ccec1657b68b33a2efdd6137f118c0c06e458c675ba4022dfc595469
|
@@ -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"
|
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.9
|
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-01-
|
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,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: []
|