@csedl/svelte-on-rails 12.0.2 → 12.1.0
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.
package/package.json
CHANGED
package/src/config.js
CHANGED
|
@@ -17,7 +17,7 @@ export const SvelteOnRails = {
|
|
|
17
17
|
debugLog("lazyComponents not set: falling back to default «import.meta.glob(['/**/*.svelte'], {eager: false, import: 'default'})»");
|
|
18
18
|
components = _defaultComponents;
|
|
19
19
|
} else {
|
|
20
|
-
debugLog(`
|
|
20
|
+
debugLog(`using given lazyComponents`);
|
|
21
21
|
components = _lazyComponents
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -28,7 +28,7 @@ export const SvelteOnRails = {
|
|
|
28
28
|
throw new Error(`[svelte-on-rails] Component not found: «${componentKey}»\nAvailable imported Components are:\n\n+++\n • ${Object.keys(components).join('\n • ')}\n+++\n`);
|
|
29
29
|
//return;
|
|
30
30
|
} else {
|
|
31
|
-
debugLog(`
|
|
31
|
+
debugLog(`Component found: ${componentKey}`);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
// load and validate component
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import {Controller} from "@hotwired/stimulus"
|
|
2
2
|
import {initializeSvelteComponent} from "./initializeSvelteComponent.js";
|
|
3
3
|
import {cleanupSvelteComponent} from "./cleanupSvelteComponent.js";
|
|
4
|
+
import {debugLog} from "../logger.js";
|
|
4
5
|
|
|
5
6
|
export default class extends Controller {
|
|
6
7
|
|
|
7
8
|
connect() {
|
|
8
9
|
|
|
9
|
-
console.log('SVELTE CONNECT')
|
|
10
|
-
|
|
11
10
|
const stat = this.element.getAttribute('data-svelte-status');
|
|
12
|
-
if (stat === 'do-not-hydrate-
|
|
11
|
+
if (stat === 'do-not-hydrate-me') {
|
|
12
|
+
debugLog(`Skipping hydration of component ${this.element.getAttribute('data-component')}`);
|
|
13
|
+
return
|
|
14
|
+
};
|
|
13
15
|
|
|
14
16
|
initializeSvelteComponent(this.element, false).then(r => {});
|
|
15
17
|
|
package/src/utils.js
CHANGED
|
@@ -4,7 +4,8 @@ export function componentRenderError(component, error, ssr = false) {
|
|
|
4
4
|
const ssrHint = 'This is Server Side rendered. When Hydrated, you will see a more detailed error message.'
|
|
5
5
|
|
|
6
6
|
return (`
|
|
7
|
-
<div
|
|
7
|
+
<div class="svelte-on-rails-component-error${ssr ? '-server-side' : ''}"
|
|
8
|
+
style="
|
|
8
9
|
padding: 1.5rem;
|
|
9
10
|
margin: 1rem 0;
|
|
10
11
|
border: 2px solid #ef4444;
|
|
@@ -13,12 +14,17 @@ export function componentRenderError(component, error, ssr = false) {
|
|
|
13
14
|
border-radius: 0.5rem;
|
|
14
15
|
font-family: system-ui, sans-serif;
|
|
15
16
|
">
|
|
16
|
-
<strong style="font-size: 1.2em;">Component failed to render</strong>
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
<strong style="font-size: 1.2em;">Component failed to render${ssr ? ' server-side' : ''}</strong>
|
|
18
|
+
|
|
19
|
+
<p class="error-message"
|
|
20
|
+
style="margin: 0.4rem 0 0.4rem;"
|
|
21
|
+
>
|
|
19
22
|
${error.message || 'Unknown rendering error'}
|
|
20
23
|
</p>
|
|
21
|
-
|
|
24
|
+
<div style="display: block;">
|
|
25
|
+
<code style="margin: 0.75rem 0 0;">${component}</code><br>
|
|
26
|
+
</div>
|
|
27
|
+
<small style="color: #7f1d1d; opacity: 0.8; margin-top: 1rem; display: block;">
|
|
22
28
|
${ssr ? ssrHint : hint}
|
|
23
29
|
</small>
|
|
24
30
|
</div>
|