actionview-svelte-handler 0.8.0 → 0.8.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fa87ed29fb4384fb377c10cf448128bc375891b09f4c4e5cc27e9ed61cca05f8
4
- data.tar.gz: 29a5cc3725715e988248c8a34ff81828455ead0d654006ca9beced87a4654017
3
+ metadata.gz: 8922d6a1d3f8de0c4b5791db1ebff8a91fb7b9ca87c9cad43da53983774a501e
4
+ data.tar.gz: 23b8c4d8349c796d36ac0df28682c7e2fa7a409ab1d080a0f307076c6b0f548d
5
5
  SHA512:
6
- metadata.gz: ef8416ff83fcfb265e32508a18f6461d360312384c1b230717cce0913e646939d014683ee86df0e25e5ad48d51720192b084693d835b70eb9456d617058cb59d
7
- data.tar.gz: 2c1af7eda9cfed6602c2aa7d2994efd94a535d75812a018348ec32bea9028a66474763f53bf0b0c6d249c456b6be848156dfca72b01cf8d33312eee1139139f6
6
+ metadata.gz: 2ca3596dad051fb946f5f086c742a6270ff21e780123bb64f7a9fd6442fcd28ec784096cd9af26bdf08d97819ae9c2b8846b583aa0ae6af9a1bbdcf807bcd9fa
7
+ data.tar.gz: fa4d376aceaf9edbd5d997f51654f7249799907e4bb6194d9c7ecb3e0066870571b5f8be55c101c1f32f7045941baa3b0b2524ef994a2c99eff4c7d4542f428c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- actionview-svelte-handler (0.8.0)
4
+ actionview-svelte-handler (0.8.1)
5
5
  rails (~> 7.0)
6
6
  zeitwerk (~> 2)
7
7
 
@@ -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
@@ -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
- function hydrateApp() {
62
- const app = hydrate(App, {
63
- target: document.getElementById("hydratee-${this.digest}"),
64
- props: JSON.parse('${JSON.stringify(this.props)}')
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
- export default hydrateApp;
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;
@@ -7,6 +7,8 @@
7
7
  <%= result.dig(:server, :css) %>
8
8
  </style>
9
9
  <template data-island>
10
- <script type="module">(<%= result.dig(:client).strip %>)();</script>
10
+ <script type="module">
11
+ <%= result.dig(:client).strip %>
12
+ </script>
11
13
  </template>
12
14
  </is-land>
@@ -1,3 +1,3 @@
1
1
  module Svelte
2
- VERSION = "0.8.0"
2
+ VERSION = "0.8.1"
3
3
  end
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
- function hydrateApp() {
101
- const app = hydrate(App, {
102
- target: document.getElementById("hydratee-${this.digest}"),
103
- props: JSON.parse('${JSON.stringify(this.props)}')
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
- export default hydrateApp;
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionview-svelte-handler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - reesericci