salvia 0.2.1 → 0.2.2
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/lib/salvia/helpers/island.rb +3 -14
- data/lib/salvia/server/dev_server.rb +2 -2
- data/lib/salvia/ssr.rb +26 -0
- data/lib/salvia/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b6e25508aa23c2f3708cc4d21c403d3e265a996a8dd1d84ee818750f473d1638
|
|
4
|
+
data.tar.gz: c5c6c5f90dae32b27cbddcc6e137b5b28cdb5c03a399efd256534bcba5649fb0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9a2dba842f6307da35f3e5b58048fb9ccb75cb781bad7d6a030dae69f2fa70c9c8cddb1db2dc097e7021a17c7bfadf4f75c598d1f4ac9ccb3fd93a559513e1eb
|
|
7
|
+
data.tar.gz: 6d00ac1ad82848de874eeb3347c0c590c7e89a0a82569c6db16a94578ea9093ce1caf3f100d341af219f03eed66d662357312261b4bb4ead910e6f6069199b29
|
|
@@ -74,7 +74,9 @@ module Salvia
|
|
|
74
74
|
# @example ハイドレーションを無効化 (静的 HTML のみ)
|
|
75
75
|
# <%= island "StaticCard", title: "Hello", hydrate: false %>
|
|
76
76
|
#
|
|
77
|
+
# @deprecated Use Salvia::SSR.render in controller instead.
|
|
77
78
|
def island(name, props = {}, options = {})
|
|
79
|
+
warn "[DEPRECATION] `island` helper is deprecated. Please use `Salvia::SSR.render` in your controller (API Mode) instead."
|
|
78
80
|
tag_name = options.delete(:tag) || :div
|
|
79
81
|
|
|
80
82
|
# デフォルトの hydrate 値を決定
|
|
@@ -148,20 +150,7 @@ module Salvia
|
|
|
148
150
|
# @option options [Boolean] :doctype <!DOCTYPE html> を付与するか (デフォルト: true)
|
|
149
151
|
# @return [String] 完全な HTML 文字列
|
|
150
152
|
def ssr(name, props = {}, options = {})
|
|
151
|
-
|
|
152
|
-
html = Salvia::SSR.render(name, props)
|
|
153
|
-
|
|
154
|
-
# <head> がある場合、Import Map を自動注入
|
|
155
|
-
if html.include?("</head>")
|
|
156
|
-
import_map_html = salvia_import_map
|
|
157
|
-
html = html.sub("</head>", "#{import_map_html}</head>")
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
result = html
|
|
161
|
-
if options.fetch(:doctype, true)
|
|
162
|
-
result = "<!DOCTYPE html>\n" + result
|
|
163
|
-
end
|
|
164
|
-
|
|
153
|
+
result = Salvia::SSR.render_page(name, props, options)
|
|
165
154
|
result.respond_to?(:html_safe) ? result.html_safe : result
|
|
166
155
|
end
|
|
167
156
|
|
|
@@ -40,9 +40,9 @@ module Salvia
|
|
|
40
40
|
return serve_islands_js
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
-
# Remove
|
|
43
|
+
# Remove extension to find source (supports .js, .tsx, .ts, .jsx)
|
|
44
44
|
# Also handle requests without extension (from import map resolution)
|
|
45
|
-
base_name = path_info.sub(/\.js$/, "")
|
|
45
|
+
base_name = path_info.sub(/\.(js|tsx|ts|jsx)$/, "")
|
|
46
46
|
|
|
47
47
|
source_path = resolve_source_path(base_name)
|
|
48
48
|
|
data/lib/salvia/ssr.rb
CHANGED
|
@@ -89,6 +89,32 @@ module Salvia
|
|
|
89
89
|
current_adapter.render(component_name, props)
|
|
90
90
|
end
|
|
91
91
|
|
|
92
|
+
# ページコンポーネントをレンダリング (Import Map 注入 + DOCTYPE)
|
|
93
|
+
# @param component_name [String] コンポーネント名
|
|
94
|
+
# @param props [Hash] プロパティ
|
|
95
|
+
# @param options [Hash] オプション
|
|
96
|
+
# @return [String] 完全な HTML 文字列
|
|
97
|
+
def render_page(component_name, props = {}, options = {})
|
|
98
|
+
html = render(component_name, props)
|
|
99
|
+
|
|
100
|
+
# <head> がある場合、Import Map を自動注入
|
|
101
|
+
if html.include?("</head>")
|
|
102
|
+
map = Salvia::Core::ImportMap.generate
|
|
103
|
+
import_map_html = <<~HTML
|
|
104
|
+
<script type="importmap">
|
|
105
|
+
#{map.to_json}
|
|
106
|
+
</script>
|
|
107
|
+
HTML
|
|
108
|
+
html = html.sub("</head>", "#{import_map_html}</head>")
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
if options.fetch(:doctype, true)
|
|
112
|
+
html = "<!DOCTYPE html>\n" + html
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
html
|
|
116
|
+
end
|
|
117
|
+
|
|
92
118
|
# コンポーネントを登録
|
|
93
119
|
def register_component(name, code)
|
|
94
120
|
ensure_configured!
|
data/lib/salvia/version.rb
CHANGED