turbo_ready 0.0.1 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d874913424577d763aad4fcc948b8527f85f0ac27b47b81a520f4dd6c999a6a0
4
- data.tar.gz: ec9feee0db78ef6f8affa77a67e9420849e830d6cd861e081e4d59b6d2f7287e
3
+ metadata.gz: b07e0ce9c51b2f3bc6fab5d95f97266115e1faa7347aae49650e3218f21c9d65
4
+ data.tar.gz: 589586d61a2c1845dbbabdf19a5ab13b03ef3c06b9ebe7522edab8cdfa9ac9dd
5
5
  SHA512:
6
- metadata.gz: 25ba8ba8685ecb0d9a63ae5a509b146e089ced8fad07a3b754d24cfc2bd853fdab55ff1da776c0145dc49b57178c0ffdcf7a7710ce1d02d3eafaa047f2b6289e
7
- data.tar.gz: 546fbda6d1bc72701d45e1c84925893e9d8c88c56521983fb693e7162861e9a929b9b7c0c66ea1e9525540f4cbf4d45bdbe770ea275019724714fadbf41f8b17
6
+ metadata.gz: 1c49feb4f8599ce6cd57021fca945fc72df43b9e71202a6c03f4bd7b64f948d09eb8bb7788e5a0fb43a614a37f4ddc210fa919ae79e8437f178a1ced9a76edf2
7
+ data.tar.gz: b2ad53e8b8799c804f5cfd87dbb5920166943029d524da9a48df8b91f2e23d31fda431e89a047763301ef205d0930bf56e12402b5dfaaa919a366cf702fca1c9
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- turbo_ready (0.0.1)
5
- rails (>= 7.0)
4
+ turbo_ready (0.0.4)
5
+ rails (>= 6.1)
6
6
  turbo-rails (>= 1.1)
7
7
 
8
8
  GEM
@@ -132,6 +132,8 @@ GEM
132
132
  racc (~> 1.4)
133
133
  nokogiri (1.13.8-arm64-darwin)
134
134
  racc (~> 1.4)
135
+ nokogiri (1.13.8-x86_64-linux)
136
+ racc (~> 1.4)
135
137
  parallel (1.22.1)
136
138
  parser (3.1.2.1)
137
139
  ast (~> 2.4.1)
@@ -237,6 +239,7 @@ GEM
237
239
  PLATFORMS
238
240
  aarch64-linux-musl
239
241
  arm64-darwin-21
242
+ x86_64-linux
240
243
 
241
244
  DEPENDENCIES
242
245
  magic_frozen_string_literal
data/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
  </h1>
9
9
  <p align="center">
10
10
  <a href="http://blog.codinghorror.com/the-best-code-is-no-code-at-all/" target="_blank">
11
- <img alt="Lines of Code" src="https://img.shields.io/badge/lines_of_code-275-brightgreen.svg?style=flat" />
11
+ <img alt="Lines of Code" src="https://img.shields.io/badge/lines_of_code-278-brightgreen.svg?style=flat" />
12
12
  </a>
13
13
  <a href="https://github.com/testdouble/standard" target="_blank">
14
14
  <img alt="Ruby Code Style" src="https://img.shields.io/badge/Ruby_Code_Style-standard-brightgreen.svg" />
@@ -16,6 +16,9 @@
16
16
  <a href="https://github.com/sheerun/prettier-standard" target="_blank">
17
17
  <img alt="JavaScript Code Style" src="https://img.shields.io/badge/JavaScript_Code_Style-prettier_standard-ff69b4.svg" />
18
18
  </a>
19
+ <a href="https://bundlephobia.com/package/turbo_ready" target="_blank">
20
+ <img alt="npm bundle size" src="https://img.shields.io/bundlephobia/minzip/turbo_ready?label=minified%20size">
21
+ </a>
19
22
  </p>
20
23
  </p>
21
24
 
@@ -35,15 +38,16 @@ turbo_stream.invoke "console.log", "Hello World!"
35
38
 
36
39
  - [Why TurboReady?](#why-turboready)
37
40
  - [Discord Community](#discord-community)
38
- - [A Word of Caution ⚠️](#a-word-of-caution-)
39
- - [Sponsor](#sponsor)
41
+ - [Sponsors](#sponsors)
40
42
  - [Dependencies](#dependencies)
41
43
  - [Installation](#installation)
42
44
  - [Setup](#setup)
43
45
  - [Usage](#usage)
44
46
  - [Endless Possibilities](#endless-possibilities)
45
47
  - [Advanced Usage](#advanced-usage)
48
+ - [Extending Behavior](#extending-behavior)
46
49
  - [Public API](#public-api)
50
+ - [A Word of Caution](#a-word-of-caution)
47
51
  - [Releasing](#releasing)
48
52
  - [License](#license)
49
53
 
@@ -58,33 +62,16 @@ considerable number of use cases and you should push Streams as far as possible
58
62
 
59
63
  If you discover that CRUD isn't enough, TurboReady covers pretty much everything else.
60
64
 
61
- ## Discord Community
65
+ ## Community
62
66
 
63
67
  Please join nearly 2000 of us on [Discord](https://discord.gg/stimulus-reflex) for support getting started,
64
- as well as active discussions around Rails, Hotwire, Stimulus, Turbo (Drive, Frames, Streams), TurboReady, CableReady, and StimulusReflex.
68
+ as well as active discussions around Rails, Hotwire, Stimulus, Turbo (Drive, Frames, Streams), TurboReady, CableReady, StimulusReflex, ViewComponent, Phlex, and more.
65
69
 
66
70
  ![](https://img.shields.io/discord/629472241427415060)
67
71
 
68
72
  Stop by #newcomers and introduce yourselves!
69
73
 
70
- ## A Word of Caution ⚠️
71
-
72
- Manually orchestrating DOM activity gets tedious fast.
73
- **Don't abuse this superpower!**
74
-
75
- > With great power comes great responsibility. *-Uncle Ben*
76
-
77
- This library is an extremely sharp tool. 🔪
78
- Consider it a low-level building block that can be used to craft additional libraries with
79
- great [DX](https://en.wikipedia.org/wiki/User_experience#Developer_experience)
80
- like [CableReady](https://github.com/stimulusreflex/cable_ready)
81
- and [StimulusReflex](https://github.com/stimulusreflex/stimulus_reflex).
82
-
83
- Restrict your direct application usage to DOM manipulations that fall outside the purview of
84
- [Turbo's official actions](https://turbo.hotwired.dev/reference/streams#the-seven-actions)...
85
- *and for Pete's sake, don't overdo it and find yourself maintaining spaghetti code reminicent of the jQuery days.*
86
-
87
- ## Sponsor
74
+ ## Sponsors
88
75
 
89
76
  <p align="center">
90
77
  <em>Proudly sponsored by</em>
@@ -97,7 +84,7 @@ Restrict your direct application usage to DOM manipulations that fall outside th
97
84
 
98
85
  ## Dependencies
99
86
 
100
- - [rails](https://rubygems.org/gems/rails) `>=7.0`
87
+ - [rails](https://rubygems.org/gems/rails) `>=6.1`
101
88
  - [turbo-rails](https://rubygems.org/gems/turbo-rails) `>=1.1`
102
89
  - [@hotwired/turbo-rails](https://yarnpkg.com/package/@hotwired/turbo-rails) `>=7.2.0-beta.2`
103
90
 
@@ -131,11 +118,11 @@ yarn add "turbo_ready@VERSION --exact"
131
118
  ## Usage
132
119
 
133
120
  Manipulate the DOM from anywhere you use [official Turbo Streams](https://turbo.hotwired.dev/handbook/streams#integration-with-server-side-frameworks).
134
- Namely, [ActiveRecord Models](https://github.com/hotwired/turbo-rails/blob/main/app/models/concerns/turbo/broadcastable.rb),
135
- [Controllers](https://github.com/hotwired/turbo-rails/blob/main/app/models/concerns/turbo/broadcastable.rb),
136
- and [View Templates](https://github.com/hotwired/turbo-rails/blob/main/app/models/concerns/turbo/broadcastable.rb).
121
+ Namely, [**M**odels](https://github.com/hotwired/turbo-rails/blob/main/app/models/concerns/turbo/broadcastable.rb),
122
+ [**V**iews](https://github.com/hotwired/turbo-rails/blob/main/app/models/concerns/turbo/broadcastable.rb),
123
+ and [**C**ontrollers](https://github.com/hotwired/turbo-rails/blob/main/app/models/concerns/turbo/broadcastable.rb).
137
124
 
138
- You can also **chain invocations.** ❤️
125
+ You can **chain invocations.** ❤️
139
126
 
140
127
  ```ruby
141
128
  turbo_stream
@@ -146,7 +133,7 @@ turbo_stream
146
133
  ```
147
134
 
148
135
  You can use [dot notation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_accessors#dot_notation)
149
- or a [selector](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll)... or even **use them together!** 🤯
136
+ or [selectors](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll)... and can even combine them!** 🤯
150
137
 
151
138
  Can I dispatch events? **You bet!** ⚡️
152
139
 
@@ -165,9 +152,28 @@ MDN has your back... [learn about the DOM and web APIs here.](https://developer.
165
152
 
166
153
  ## Advanced Usage
167
154
 
168
- Want to extend things further with some custom functionality? **Let's do it.** 🔌
155
+ You can use symbols and [snake case](https://en.wikipedia.org/wiki/Snake_case) when invoking DOM functionality.
156
+ It'll implicitly convert to [camel case](https://en.wikipedia.org/wiki/Camel_case). 💎
157
+
158
+ ```ruby
159
+ turbo_stream
160
+ .invoke(:animate, [{opacity: 0}, {opacity: 1}], 2000)
161
+ .invoke(:dispatch_event, {detail: {converts_to_camel_case: true}})
162
+ .flush
163
+ ```
164
+
165
+ Need to opt out of camelize? No problem... just disable it.
166
+
167
+ ```ruby
168
+ turbo_stream.invoke :contrived_demo, camelize: false
169
+ ```
170
+
171
+ ### Extending Behavior
172
+
173
+ Want to extend things with custom functionality? **Let's do it.** 🔌
169
174
 
170
175
  ```js
176
+ // JavaScript
171
177
  import morphdom from 'morphdom'
172
178
 
173
179
  window.MyNamespace = {
@@ -178,24 +184,9 @@ window.MyNamespace = {
178
184
  ```
179
185
 
180
186
  ```ruby
181
- turbo_stream.invoke "MyNamespace.morph", "#demo", "<div id='demo'><p>You've changed...</p></div>", {childrenOnly: true}
182
- ```
183
-
184
- **But this doesn't look like Ruby...** well then, just use symbols and
185
- [snake case](https://en.wikipedia.org/wiki/Snake_case) when invoking DOM functionality.
186
- It'll implicitly convert to [camel case](https://en.wikipedia.org/wiki/Camel_case).
187
-
188
- ```ruby
187
+ # Ruby
189
188
  turbo_stream
190
- .invoke(:animate, [{opacity: 0}, {opacity: 1}], 2000)
191
- .invoke(:dispatch_event, {detail: {converts_camel_case: true}})
192
- .flush
193
- ```
194
-
195
- Need to opt out of camelize? No problem... just disable it.
196
-
197
- ```ruby
198
- turbo_stream.invoke :contrived_demo, camelize: false
189
+ .invoke "MyNamespace.morph", "#demo", "<div id='demo'><p>You've changed...</p></div>", {childrenOnly: true}
199
190
  ```
200
191
 
201
192
  ## Public API
@@ -204,6 +195,7 @@ There's only one method to consider, `invoke` defined in the
204
195
  [tag builder](https://github.com/hopsoft/turbo_ready/blob/main/lib/turbo_ready/tag_builder.rb).
205
196
 
206
197
  ```ruby
198
+ # Ruby
207
199
  turbo_stream
208
200
  .invoke(method, *args, selector: nil, camelize: true, id: nil)
209
201
  # | | | | |
@@ -221,6 +213,23 @@ turbo_stream
221
213
 
222
214
  **NOTE:** The JavaScript method will be invoked on all matching elements when a `selector` is passed.
223
215
 
216
+ ## A Word of Caution
217
+
218
+ Manually orchestrating DOM activity gets tedious fast.
219
+ **⚠️ Don't abuse this superpower!**
220
+
221
+ > With great power comes great responsibility. *-Uncle Ben*
222
+
223
+ This library is an extremely sharp tool. 🔪
224
+ Consider it a low-level building block that can be used to craft additional libraries with
225
+ great [DX](https://en.wikipedia.org/wiki/User_experience#Developer_experience)
226
+ like [CableReady](https://github.com/stimulusreflex/cable_ready)
227
+ and [StimulusReflex](https://github.com/stimulusreflex/stimulus_reflex).
228
+
229
+ Restrict your direct application usage to DOM manipulation that falls outside the purview of
230
+ [Turbo's official actions](https://turbo.hotwired.dev/reference/streams#the-seven-actions)...
231
+ *and for Pete's sake, don't overdo it and find yourself maintaining spaghetti code reminiscent of the jQuery days.*
232
+
224
233
  ## Releasing
225
234
 
226
235
  1. Run `yarn` and `bundle` to pick up the latest
@@ -1,2 +1,2 @@
1
- function l(){let n=JSON.parse(this.templateContent.textContent),{id:h,method:a,args:i,receiver:c,selector:r}=n,t=[self];switch(r&&(t=Array.from(document.querySelectorAll(r))),c&&(t=t.map(o=>{let e=o,s=c.split(".");for(;s.length>0;)e=e[s.shift()];return e})),a){case"dispatchEvent":let o=new CustomEvent(i[0],i[1]||{});t.forEach(e=>e.dispatchEvent(o));break;default:t.forEach(e=>e[a].apply(e,i))}}var f={initialize:n=>n.invoke=l};export{f as default};
1
+ function l(){let n=JSON.parse(this.templateContent.textContent),{id:h,method:c,args:i,receiver:a,selector:r}=n,t=[self];switch(r&&(t=Array.from(document.querySelectorAll(r))),a&&(t=t.map(o=>{let e=o,s=a.split(".");for(;s.length>0;)e=e[s.shift()];return e})),c){case"dispatchEvent":let o=new CustomEvent(i[0],i[1]||{});t.forEach(e=>e.dispatchEvent(o));break;default:t.forEach(e=>e[c].apply(e,i))}}function f(n){n.invoke=l}var p={initialize:f};export{p as default};
2
2
  //# sourceMappingURL=turbo_ready.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../javascript/turbo_ready.js"],
4
- "sourcesContent": ["function invoke () {\n const payload = JSON.parse(this.templateContent.textContent)\n const { id, method, args, receiver, selector } = payload\n let receivers = [self]\n if (selector) receivers = Array.from(document.querySelectorAll(selector))\n\n if (receiver) {\n receivers = receivers.map(r => {\n let context = r\n const chain = receiver.split('.')\n while (chain.length > 0) context = context[chain.shift()]\n return context\n })\n }\n\n switch (method) {\n case 'dispatchEvent':\n const evt = new CustomEvent(args[0], args[1] || {})\n receivers.forEach(r => r.dispatchEvent(evt))\n break\n default:\n receivers.forEach(r => r[method].apply(r, args))\n }\n}\n\nexport default {\n initialize: streamActions => (streamActions.invoke = invoke)\n}\n"],
5
- "mappings": "AAAA,SAASA,GAAU,CACjB,IAAMC,EAAU,KAAK,MAAM,KAAK,gBAAgB,WAAW,EACrD,CAAE,GAAAC,EAAI,OAAAC,EAAQ,KAAAC,EAAM,SAAAC,EAAU,SAAAC,CAAS,EAAIL,EAC7CM,EAAY,CAAC,IAAI,EAYrB,OAXID,IAAUC,EAAY,MAAM,KAAK,SAAS,iBAAiBD,CAAQ,CAAC,GAEpED,IACFE,EAAYA,EAAU,IAAIC,GAAK,CAC7B,IAAIC,EAAUD,EACRE,EAAQL,EAAS,MAAM,GAAG,EAChC,KAAOK,EAAM,OAAS,GAAGD,EAAUA,EAAQC,EAAM,MAAM,GACvD,OAAOD,CACT,CAAC,GAGKN,OACD,gBACH,IAAMQ,EAAM,IAAI,YAAYP,EAAK,GAAIA,EAAK,IAAM,CAAC,CAAC,EAClDG,EAAU,QAAQC,GAAKA,EAAE,cAAcG,CAAG,CAAC,EAC3C,cAEAJ,EAAU,QAAQC,GAAKA,EAAEL,GAAQ,MAAMK,EAAGJ,CAAI,CAAC,EAErD,CAEA,IAAOQ,EAAQ,CACb,WAAYC,GAAkBA,EAAc,OAASb,CACvD",
6
- "names": ["invoke", "payload", "id", "method", "args", "receiver", "selector", "receivers", "r", "context", "chain", "evt", "turbo_ready_default", "streamActions"]
4
+ "sourcesContent": ["function invoke () {\n const payload = JSON.parse(this.templateContent.textContent)\n const { id, method, args, receiver, selector } = payload\n let receivers = [self]\n if (selector) receivers = Array.from(document.querySelectorAll(selector))\n\n if (receiver) {\n receivers = receivers.map(r => {\n let context = r\n const chain = receiver.split('.')\n while (chain.length > 0) context = context[chain.shift()]\n return context\n })\n }\n\n switch (method) {\n case 'dispatchEvent':\n const evt = new CustomEvent(args[0], args[1] || {})\n receivers.forEach(r => r.dispatchEvent(evt))\n break\n default:\n receivers.forEach(r => r[method].apply(r, args))\n }\n}\n\nfunction initialize (streamActions) {\n streamActions.invoke = invoke\n}\n\nexport default { initialize }\n"],
5
+ "mappings": "AAAA,SAASA,GAAU,CACjB,IAAMC,EAAU,KAAK,MAAM,KAAK,gBAAgB,WAAW,EACrD,CAAE,GAAAC,EAAI,OAAAC,EAAQ,KAAAC,EAAM,SAAAC,EAAU,SAAAC,CAAS,EAAIL,EAC7CM,EAAY,CAAC,IAAI,EAYrB,OAXID,IAAUC,EAAY,MAAM,KAAK,SAAS,iBAAiBD,CAAQ,CAAC,GAEpED,IACFE,EAAYA,EAAU,IAAIC,GAAK,CAC7B,IAAIC,EAAUD,EACRE,EAAQL,EAAS,MAAM,GAAG,EAChC,KAAOK,EAAM,OAAS,GAAGD,EAAUA,EAAQC,EAAM,MAAM,GACvD,OAAOD,CACT,CAAC,GAGKN,OACD,gBACH,IAAMQ,EAAM,IAAI,YAAYP,EAAK,GAAIA,EAAK,IAAM,CAAC,CAAC,EAClDG,EAAU,QAAQC,GAAKA,EAAE,cAAcG,CAAG,CAAC,EAC3C,cAEAJ,EAAU,QAAQC,GAAKA,EAAEL,GAAQ,MAAMK,EAAGJ,CAAI,CAAC,EAErD,CAEA,SAASQ,EAAYC,EAAe,CAClCA,EAAc,OAASb,CACzB,CAEA,IAAOc,EAAQ,CAAE,WAAAF,CAAW",
6
+ "names": ["invoke", "payload", "id", "method", "args", "receiver", "selector", "receivers", "r", "context", "chain", "evt", "initialize", "streamActions", "turbo_ready_default"]
7
7
  }
@@ -23,6 +23,8 @@ function invoke () {
23
23
  }
24
24
  }
25
25
 
26
- export default {
27
- initialize: streamActions => (streamActions.invoke = invoke)
26
+ function initialize (streamActions) {
27
+ streamActions.invoke = invoke
28
28
  }
29
+
30
+ export default { initialize }
@@ -5,6 +5,7 @@ module TurboReady
5
5
  attr_reader :ruby_string, :turbo_ready_tag_builder
6
6
 
7
7
  delegate_missing_to :ruby_string
8
+ delegate :to_s, to: :ruby_string
8
9
 
9
10
  def initialize(ruby_string, turbo_ready_tag_builder:)
10
11
  @ruby_string = ruby_string
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TurboReady
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.4"
5
5
  end
data/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "turbo_ready",
3
- "version": "0.0.1",
4
- "description": "Take full control of the DOM with TurboStreams",
3
+ "version": "0.0.3",
4
+ "description": "Take full control of the DOM with Turbo Streams",
5
5
  "main": "app/assets/builds/turbo_ready.js",
6
6
  "repository": "https://github.com/hopsoft/turbo_ready",
7
7
  "author": "Nate Hopkins (hopsoft) <natehop@gmail.com>",
data/turbo_ready.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ["Nate Hopkins (hopsoft)"]
9
9
  spec.email = ["natehop@gmail.com"]
10
10
  spec.homepage = "https://github.com/hopsoft/turbo_ready"
11
- spec.summary = "Take full control of the DOM with TurboStreams"
11
+ spec.summary = "Take full control of the DOM with Turbo Streams"
12
12
  spec.description = spec.summary
13
13
  spec.license = "MIT"
14
14
 
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
 
19
19
  spec.files = Dir["lib/**/*.rb", "app/**/*", "bin/*", "[A-Z]*"]
20
20
 
21
- spec.add_dependency "rails", ">= 7.0"
21
+ spec.add_dependency "rails", ">= 6.1"
22
22
  spec.add_dependency "turbo-rails", ">= 1.1"
23
23
 
24
24
  spec.add_development_dependency "magic_frozen_string_literal"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turbo_ready
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nate Hopkins (hopsoft)
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '7.0'
19
+ version: '6.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '7.0'
26
+ version: '6.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: turbo-rails
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -94,7 +94,7 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
- description: Take full control of the DOM with TurboStreams
97
+ description: Take full control of the DOM with Turbo Streams
98
98
  email:
99
99
  - natehop@gmail.com
100
100
  executables: []
@@ -109,6 +109,7 @@ files:
109
109
  - Rakefile
110
110
  - app/assets/builds/turbo_ready.js
111
111
  - app/assets/builds/turbo_ready.js.map
112
+ - app/assets/images/turbo-ready-logo.jpg
112
113
  - app/assets/images/turbo-ready-logo.png
113
114
  - app/assets/images/turbo-ready-logo.svg
114
115
  - app/javascript/turbo_ready.js
@@ -149,5 +150,5 @@ requirements: []
149
150
  rubygems_version: 3.3.7
150
151
  signing_key:
151
152
  specification_version: 4
152
- summary: Take full control of the DOM with TurboStreams
153
+ summary: Take full control of the DOM with Turbo Streams
153
154
  test_files: []