actionview-svelte-handler 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/svelte/handler.rb +1 -1
- data/lib/svelte/js/builder.js +7 -32
- data/lib/svelte/templates/island.html.erb +3 -1
- data/lib/svelte/version.rb +1 -1
- data/lib/ts/builder.ts +7 -37
- 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: 8922d6a1d3f8de0c4b5791db1ebff8a91fb7b9ca87c9cad43da53983774a501e
|
4
|
+
data.tar.gz: 23b8c4d8349c796d36ac0df28682c7e2fa7a409ab1d080a0f307076c6b0f548d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ca3596dad051fb946f5f086c742a6270ff21e780123bb64f7a9fd6442fcd28ec784096cd9af26bdf08d97819ae9c2b8846b583aa0ae6af9a1bbdcf807bcd9fa
|
7
|
+
data.tar.gz: fa4d376aceaf9edbd5d997f51654f7249799907e4bb6194d9c7ecb3e0066870571b5f8be55c101c1f32f7045941baa3b0b2524ef994a2c99eff4c7d4542f428c
|
data/Gemfile.lock
CHANGED
data/lib/svelte/handler.rb
CHANGED
@@ -59,7 +59,7 @@ module Svelte
|
|
59
59
|
|
60
60
|
content_for(:head, (result.dig(:server, :head) || "").html_safe)
|
61
61
|
|
62
|
-
ERB.new(File.read("#{Svelte.gem_dir}/lib/svelte/templates/island.html.erb")).result_with_hash({ result:, locals: local_assigns, digest: "#{digest}", bind: binding })
|
62
|
+
ERB.new(File.read("#{Svelte.gem_dir}/lib/svelte/templates/island.html.erb")).result_with_hash({ result:, locals: local_assigns, digest: "#{digest}", bind: binding }).html_safe
|
63
63
|
|
64
64
|
end
|
65
65
|
RUBY
|
data/lib/svelte/js/builder.js
CHANGED
@@ -56,18 +56,14 @@ class Builder {
|
|
56
56
|
} else {
|
57
57
|
entry = `
|
58
58
|
import App from "${this.path}";
|
59
|
-
import { hydrate } from "svelte";
|
59
|
+
import { hydrate, flushSync } from "svelte";
|
60
60
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
})
|
66
|
-
|
67
|
-
app.flushSync();
|
68
|
-
}
|
61
|
+
hydrate(App, {
|
62
|
+
target: document.getElementById("hydratee-${this.digest}"),
|
63
|
+
props: JSON.parse('${JSON.stringify(this.props)}')
|
64
|
+
})
|
69
65
|
|
70
|
-
|
66
|
+
flushSync();
|
71
67
|
`;
|
72
68
|
}
|
73
69
|
const bundle = (await (await rollup({
|
@@ -133,32 +129,11 @@ class Builder {
|
|
133
129
|
});
|
134
130
|
return `//# sourceMappingURL=${bundle[0].map.toUrl()}
|
135
131
|
//# sourceURL=${path.relative(this.path, this.root) + "/" + path.relative(this.root, this.path)}
|
136
|
-
${bundle[0].code}`.trim();
|
132
|
+
${bundle[0].code}`.trim().replace(/\n.*$/, "");
|
137
133
|
}
|
138
134
|
async client() {
|
139
135
|
return this.compiled?.client || await this.bundle("dom");
|
140
136
|
}
|
141
|
-
// standardizeClient (code: string): string {
|
142
|
-
// const ast = recast.parse(code)
|
143
|
-
// let name: string | undefined
|
144
|
-
// recast.visit(ast, {
|
145
|
-
// visitExportNamedDeclaration: (path) => {
|
146
|
-
// const stagingName: any = path.node?.specifiers?.[0].local?.name
|
147
|
-
// name = typeof stagingName !== 'string' ? '' : stagingName
|
148
|
-
// path.prune()
|
149
|
-
// return false
|
150
|
-
// }
|
151
|
-
// })
|
152
|
-
// recast.visit(ast, {
|
153
|
-
// visitIdentifier: (path) => {
|
154
|
-
// if (path.node.name === name) {
|
155
|
-
// path.node.name = 'App'
|
156
|
-
// }
|
157
|
-
// return false
|
158
|
-
// }
|
159
|
-
// })
|
160
|
-
// return recast.print(ast).code
|
161
|
-
// }s
|
162
137
|
async server() {
|
163
138
|
const output = this.compiled?.server || await this.bundle("ssr");
|
164
139
|
const { html, css, head } = importFromStringSync(output).default;
|
data/lib/svelte/version.rb
CHANGED
data/lib/ts/builder.ts
CHANGED
@@ -95,18 +95,14 @@ class Builder {
|
|
95
95
|
} else {
|
96
96
|
entry = `
|
97
97
|
import App from "${this.path}";
|
98
|
-
import { hydrate } from "svelte";
|
98
|
+
import { hydrate, flushSync } from "svelte";
|
99
99
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
})
|
105
|
-
|
106
|
-
app.flushSync();
|
107
|
-
}
|
100
|
+
hydrate(App, {
|
101
|
+
target: document.getElementById("hydratee-${this.digest}"),
|
102
|
+
props: JSON.parse('${JSON.stringify(this.props)}')
|
103
|
+
})
|
108
104
|
|
109
|
-
|
105
|
+
flushSync();
|
110
106
|
`
|
111
107
|
}
|
112
108
|
|
@@ -171,7 +167,7 @@ class Builder {
|
|
171
167
|
return path.relative(this.path, this.root) + "/" + path.relative(this.root, el)
|
172
168
|
})
|
173
169
|
|
174
|
-
return `//# sourceMappingURL=${bundle[0].map!.toUrl()}\n//# sourceURL=${path.relative(this.path, this.root) + "/" + path.relative(this.root, this.path) }\n${bundle[0].code}`.trim()
|
170
|
+
return `//# sourceMappingURL=${bundle[0].map!.toUrl()}\n//# sourceURL=${path.relative(this.path, this.root) + "/" + path.relative(this.root, this.path) }\n${bundle[0].code}`.trim().replace(/\n.*$/, '')
|
175
171
|
}
|
176
172
|
|
177
173
|
async client (): Promise<string> {
|
@@ -180,32 +176,6 @@ class Builder {
|
|
180
176
|
)
|
181
177
|
}
|
182
178
|
|
183
|
-
// standardizeClient (code: string): string {
|
184
|
-
// const ast = recast.parse(code)
|
185
|
-
|
186
|
-
// let name: string | undefined
|
187
|
-
|
188
|
-
// recast.visit(ast, {
|
189
|
-
// visitExportNamedDeclaration: (path) => {
|
190
|
-
// const stagingName: any = path.node?.specifiers?.[0].local?.name
|
191
|
-
// name = typeof stagingName !== 'string' ? '' : stagingName
|
192
|
-
// path.prune()
|
193
|
-
// return false
|
194
|
-
// }
|
195
|
-
// })
|
196
|
-
|
197
|
-
// recast.visit(ast, {
|
198
|
-
// visitIdentifier: (path) => {
|
199
|
-
// if (path.node.name === name) {
|
200
|
-
// path.node.name = 'App'
|
201
|
-
// }
|
202
|
-
// return false
|
203
|
-
// }
|
204
|
-
// })
|
205
|
-
|
206
|
-
// return recast.print(ast).code
|
207
|
-
// }s
|
208
|
-
|
209
179
|
async server (): Promise<{ output: string, html: string, css: string, head: string }> {
|
210
180
|
const output = this.compiled?.server || (await this.bundle('ssr')) // eslint-disable-line
|
211
181
|
|