svelte-on-rails 0.0.39 → 0.0.41

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: eb472d80d06965ddd24db87e7cf9599fe336e3a14c78becd7051adb0c96fa0bf
4
- data.tar.gz: 1a5edd038b6c9b59b851cca3f456c396f8108185cca247da8e337a2e7873e108
3
+ metadata.gz: 683e0e4881fc72969224d9792ba06ff4049c19adbcf55bc8e0ba817ba4be48d4
4
+ data.tar.gz: 6a9ed00119ddbdb2b9a095458b010150ecd938d751e9112b26629343bc782656
5
5
  SHA512:
6
- metadata.gz: a18f23eacd2aaee32e55214adedfbe7c9a1ab13836bc609883b2c19242a3be9221c904ab6e6f5a615ed41fdf410a3231176e68528477c2af9efbf7ee2a44a6bb
7
- data.tar.gz: 01d5e459f2e1b73c5a95dd30c7759d9772b2549c08fe2a08c25c37b4cfacf7595d3ffc9ad29f98a4b925147bef8729aaecb092ba402d8bd659df7fba28b75c73
6
+ metadata.gz: a166ff91777a7969f50874feb855c522aeac968dae0c6f1659b92ced9ac461683cbac34eee6f3999b961db6669732dbcbea41d3f659f621a3c198fc6b3204e76
7
+ data.tar.gz: dd7c49785a50f484c936fbac6f5a8000fc46d6fc7165113c55a7e437b4b2ac20a05a1da4d9311b24d8757d307fa14061c35b2fdf607614502bd6ff24aa0ee948
@@ -207,7 +207,7 @@ module SvelteOnRails
207
207
  templates.each do |t|
208
208
  templates_folder = File.expand_path("../../../templates", __dir__)
209
209
  template_root = templates_folder + '/' + t
210
- raise "ERROR: Template «#{t}» not found:\n#{template_root}" unless File.directory?(template_root)
210
+ raise "ERROR: Template «#{t}» not found:\n«#{template_root}»" unless File.directory?(template_root)
211
211
 
212
212
  files = Dir.glob(template_root + '/**/*').select { |e| File.file? e }
213
213
  files.each do |f|
@@ -0,0 +1,6 @@
1
+ class SvelteOnRailsHelloWorldController < ApplicationController
2
+
3
+ def index
4
+ end
5
+
6
+ end
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.0.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. --><path d="M256 224C238.3 224 223.1 238.4 223.1 256S238.3 288 256 288c17.62 0 32-14.38 32-32C287.9 238.4 273.6 224 256 224zM471.2 128c-15.62-27.75-49.62-41.38-93.11-41.38c-9.499 .125-18.87 .75-28.25 2C327.1 34.38 293.5 0 256 0S184.9 34.38 162.1 88.62c-9.374-1.25-18.75-1.875-28.25-2C90.39 86.62 56.4 100.2 40.78 128c-18.75 33.5-6.499 80.62 27.62 128c-34.12 47.38-46.37 94.5-27.62 128c15.62 27.75 49.62 41.38 93.11 41.38c9.499-.125 18.87-.75 28.25-2C184.9 477.6 218.5 512 256 512s71.12-34.38 93.86-88.63c9.374 1.25 18.75 1.875 28.25 2c43.49 0 77.49-13.62 93.11-41.38c18.75-33.5 6.499-80.63-27.62-128C477.7 208.6 489.1 161.5 471.2 128zM256 48c14.37 0 32.12 18.12 47.12 50C287.1 102.4 271.4 107.8 256 114.1c-15.37-6.375-31.12-11.76-47.12-16.14C223.9 66.12 241.6 48 256 48zM133.9 377.4c-26.5 0-46.74-6.625-52.74-17.38c-7.124-12.75-.5-37.63 18.62-66.63C111.4 305.2 123.8 316.5 136.8 327c2.25 16.5 5.374 33 9.624 49.13C142.3 376.4 137.9 377.4 133.9 377.4zM136.8 185C123.8 195.5 111.4 206.8 99.77 218.6C80.65 189.6 74.02 164.8 81.15 152c5.999-10.75 26.25-17.38 52.74-17.38c3.1 0 8.374 1 12.5 1.25C142.1 152 139 168.5 136.8 185zM256 464c-14.37 0-32.12-18.12-47.12-49.1C224.9 409.6 240.6 404.2 256 397.9c15.37 6.375 31.12 11.76 47.12 16.14C288.1 445.9 270.4 464 256 464zM256 352c-52.99 0-95.99-43-95.99-96S203 160 256 160s95.99 43 95.99 96S308.1 352 256 352zM430.9 360c-5.999 10.75-26.25 17.38-52.74 17.38c-3.1 0-8.374-1-12.5-1.25C369.9 360 372.1 343.5 375.2 327c12.1-10.5 25.37-21.75 36.1-33.63C431.4 322.4 437.1 347.2 430.9 360zM412.2 218.6C400.6 206.8 388.2 195.5 375.2 185C372.1 168.5 369.9 152 365.6 135.9c4.125-.25 8.499-1.25 12.5-1.25c26.5 0 46.74 6.625 52.74 17.38C437.1 164.8 431.4 189.6 412.2 218.6z"/></svg>
@@ -0,0 +1,3 @@
1
+ <svg width="100" height="50" xmlns="http://www.w3.org/2000/svg">
2
+ <text x="10" y="30" font-family="Arial, sans-serif" font-size="24" fill="black">svg</text>
3
+ </svg>
@@ -0,0 +1,14 @@
1
+ <script>
2
+ export let notice
3
+ let ary = ['item-1', 'item-2', 'item-3']
4
+ </script>
5
+
6
+ <template lang="pug">
7
+ h1 Hello, Pug!
8
+ p {notice}
9
+ ul
10
+ <!-- The | Syntax is a workaround for situations where pug integration in svelte is not working really well-->
11
+ | {#each ary as item}
12
+ | <li>{item}</li>
13
+ | {/each}
14
+ </template>
@@ -0,0 +1,66 @@
1
+ <script>
2
+ import svgRaw from '../../images/svg.svg?raw'
3
+ //import svg from '../../images/svg.svg'
4
+ import png from '../../images/check-circle-green.png'
5
+ import Nested from './sub/NestedComponent.svelte'
6
+ import {nestedJavascriptFunction} from '../nestedJavascript.js'
7
+ export let items
8
+ let count = 0;
9
+
10
+ function increment() {
11
+ count += 1;
12
+ }
13
+ </script>
14
+
15
+ <span class="svelte-component-wrapper">
16
+ <h1>Svelte is here!!</h1>
17
+
18
+ <hr/>
19
+ <p>click the button and check if the component is alive</p>
20
+ <button on:click={increment}>Increment: {count}</button>
21
+
22
+ <hr/>
23
+ <ul>
24
+ {#each items as item}
25
+ <li>{item}</li>
26
+ {/each}
27
+ </ul>
28
+
29
+ <hr/>
30
+ <span class="wrap-svg">{@html svgRaw}</span>
31
+ <!-- <img alt="svg ERROR" src={svg} />-->
32
+ <img alt="png ERROR" src={png} />
33
+
34
+ <hr/>
35
+ <Nested />
36
+
37
+ <hr/>
38
+ <p>{nestedJavascriptFunction()}</p>
39
+ </span>
40
+
41
+ <style>
42
+ button {
43
+ background-color: darkred;
44
+ color: white;
45
+ padding: 10px;
46
+ border: none;
47
+ cursor: pointer;
48
+ }
49
+
50
+ .svelte-component-wrapper {
51
+ border: 1px solid black;
52
+ padding: 10px;
53
+ margin: 10px;
54
+ background-color: #efefef;
55
+ display: inline-block;
56
+ box-shadow: 2px 3px 16px -1px rgba(0, 0, 0, 0.75);
57
+ -webkit-box-shadow: 2px 3px 16px -1px rgba(0, 0, 0, 0.75);
58
+ -moz-box-shadow: 2px 3px 16px -1px rgba(0, 0, 0, 0.75);
59
+ }
60
+ img, .wrap-svg {
61
+ display: inline-block;
62
+ width: 30px;
63
+ height: 30px;
64
+ margin: 30px;
65
+ }
66
+ </style>
@@ -0,0 +1,3 @@
1
+ export function nestedJavascriptFunction() {
2
+ return 'nestedJavascript!';
3
+ }
@@ -0,0 +1,3 @@
1
+ export function nestedJavascriptFunction() {
2
+ return 'nestedJavascript («toggled»)';
3
+ }
@@ -0,0 +1,5 @@
1
+ <p>Example view</p>
2
+
3
+ <%= svelte_component "SvelteOnRailsHelloWorld", items: ['attributes', 'are', 'parsed'] %>
4
+ <%= svelte_component "Pug", ssr: true, notice: "Pug is rendered server-side" %>
5
+ <%= svelte_component "Pug", ssr: false, notice: "Pug is rendered client-side" %>
@@ -0,0 +1,18 @@
1
+
2
+ import { initializeSvelteComponents, cleanupSvelteComponents } from '@csedl/svelte-on-rails';
3
+
4
+ const components = import.meta.glob('/javascript/components/**/*.svelte', { eager: true });
5
+ const componentsRoot = '/javascript/components';
6
+
7
+ // Initialize Svelte components
8
+ initializeSvelteComponents(componentsRoot, components, true);
9
+
10
+ // Turbo event listener for page load
11
+ document.addEventListener('turbo:load', () => {
12
+ initializeSvelteComponents(componentsRoot, components, true);
13
+ });
14
+
15
+ // Turbo event listener for cleanup before page cache
16
+ document.addEventListener('turbo:before-cache', () => {
17
+ cleanupSvelteComponents(false);
18
+ });
@@ -0,0 +1,23 @@
1
+ frontend_folder: "app/frontend"
2
+ # the entrypoint that is your web root, example for vite: where @ points to
3
+ # relative to Rails.root
4
+
5
+ components_folder: "javascript/components"
6
+ # relative to frontend_folder
7
+ # where your svelte components are located
8
+
9
+ ssr: :auto
10
+ # options: true, false, :auto
11
+ # :auto: render server side if request is initial request (works only with turbo, because it checks for the X-Turbo-Request-ID header)
12
+ # when not server-side rendered the components must be built as custom elements, see node-package @csedl/svelte-on-rails
13
+
14
+ development:
15
+ watch_changes: true
16
+ # Check on every request if any file within the svelte components folder have changed, for recompiling
17
+ # Case sensitive path checking, even the file system is case insensitive
18
+ # Make sure this ist set to tue for development and test, but not for production
19
+
20
+ test:
21
+ watch_changes: true
22
+
23
+ production:
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: svelte-on-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.39
4
+ version: 0.0.41
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Sedlmair
@@ -52,6 +52,18 @@ files:
52
52
  - lib/svelte_on_rails/renderer/utils.js
53
53
  - lib/svelte_on_rails/view_helpers.rb
54
54
  - lib/tasks/svelte_on_rails_tasks.rake
55
+ - templates/rails_vite_hello_world/app/controllers/svelte_on_rails_hello_world_controller.rb
56
+ - templates/rails_vite_hello_world/app/frontend/images/atom.svg
57
+ - templates/rails_vite_hello_world/app/frontend/images/check-circle-green.png
58
+ - templates/rails_vite_hello_world/app/frontend/images/svg.svg
59
+ - templates/rails_vite_hello_world/app/frontend/javascript/components/Pug.svelte
60
+ - templates/rails_vite_hello_world/app/frontend/javascript/components/SvelteOnRailsHelloWorld.svelte
61
+ - templates/rails_vite_hello_world/app/frontend/javascript/components/sub/NestedComponent.svelte
62
+ - templates/rails_vite_hello_world/app/frontend/javascript/nestedJavascript.js
63
+ - templates/rails_vite_hello_world/app/frontend/javascript/nestedJavascriptToggled.js
64
+ - templates/rails_vite_hello_world/app/views/svelte_on_rails_hello_world/index.html.erb
65
+ - templates/svelte_on_rails_vite_base/app/frontend/initializers/svelte.js
66
+ - templates/svelte_on_rails_vite_base/config/svelte_on_rails.yml
55
67
  homepage: https://gitlab.com/sedl/svelte-on-rails
56
68
  licenses:
57
69
  - MIT