turbo_ready 0.0.2 → 0.0.5

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: 2d5f99ef840d096ab4458b6db45d5a6c23095682bbcbc5e38abfc35fb5c8d10f
4
- data.tar.gz: d8b9c54b756d76a34c3ed8da778e10cd9984e204db3a6112409f8d0a69b8d382
3
+ metadata.gz: 49adf06ca42cd8446e06096b63f685f0ccd145309e0b7a3a44b3f6a3814888cf
4
+ data.tar.gz: '01680461dbe9c06341d3f37e7376ead03a961edcd5793d121db60c436f768352'
5
5
  SHA512:
6
- metadata.gz: 73c9b0777e7d94cc56cbe1ac85365dd668f50e416906720e1e86c328e6e9eefea14644d27db2be9da804a3ca905de712105079cf00a19494d65462738d839fd2
7
- data.tar.gz: e79069264ecaba47c22be128d505221f80ef9f88c38a36419692c3415895450ff600b8920bcd18c2d1259608269575f9f544ccd41d6d0b293705c7f9400e46a8
6
+ metadata.gz: 22bf305821c44a16923d89bbd7a5844a15a6e39b331d76011199ee062cfcbfd32fa06b44bbbaaa8f794fbffbec733aef44e07d14dcbf81146f208b8ec2238bc0
7
+ data.tar.gz: c7b3acb2078e06f0455f17d068796550304c2989a8d3c03d1d1e8c729a90f4811eec9dc854a7d195abf9da02c4e0b6237a1474550b79453ace208e1cea1510cb
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- turbo_ready (0.0.2)
4
+ turbo_ready (0.0.5)
5
5
  rails (>= 6.1)
6
6
  turbo-rails (>= 1.1)
7
7
 
@@ -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
 
@@ -96,13 +99,7 @@ yarn add "turbo_ready@VERSION --exact"
96
99
 
97
100
  ## Setup
98
101
 
99
- 1. Create a Rails intializer and patch Turbo.
100
-
101
- ```ruby
102
- # config/initializers/turbo_ready.rb
103
- TurboReady.patch! # Adds TurboReady stream actions to Turbo
104
- ```
105
- 2. Import and intialize TurboReady in your JavaScript application.
102
+ 1. Import and intialize TurboReady in your JavaScript application.
106
103
 
107
104
  ```js
108
105
  // app/javascript/application.js
@@ -225,7 +222,7 @@ and [StimulusReflex](https://github.com/stimulusreflex/stimulus_reflex).
225
222
 
226
223
  Restrict your direct application usage to DOM manipulation that falls outside the purview of
227
224
  [Turbo's official actions](https://turbo.hotwired.dev/reference/streams#the-seven-actions)...
228
- *and for Pete's sake, don't overdo it and find yourself maintaining spaghetti code reminiscent of the jQuery days.*
225
+ *don't overdo it and find yourself maintaining spaghetti code reminiscent of the jQuery days.*
229
226
 
230
227
  ## Releasing
231
228
 
@@ -1,2 +1,2 @@
1
- function l(){let r=JSON.parse(this.templateContent.textContent),{id:h,method:o,args:n,receiver:c,selector:a}=r,e=[self];switch(a&&(e=Array.from(document.querySelectorAll(a))),c&&(e=e.map(i=>{let t=i,s=c.split(".");for(;s.length>0;)t=t[s.shift()];return t})),o){case"dispatchEvent":let i=new CustomEvent(n[0],n[1]||{});e.forEach(t=>t.dispatchEvent(i));break;default:e.forEach(t=>t[o].apply(t,n))}}function f(){streamActions.invoke=l}var p={initialize:f};export{p 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\nfunction initialize () {\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,GAAc,CACrB,cAAc,OAASZ,CACzB,CAEA,IAAOa,EAAQ,CAAE,WAAAD,CAAW",
6
- "names": ["invoke", "payload", "id", "method", "args", "receiver", "selector", "receivers", "r", "context", "chain", "evt", "initialize", "turbo_ready_default"]
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,7 +23,7 @@ function invoke () {
23
23
  }
24
24
  }
25
25
 
26
- function initialize () {
26
+ function initialize (streamActions) {
27
27
  streamActions.invoke = invoke
28
28
  }
29
29
 
@@ -2,5 +2,11 @@
2
2
 
3
3
  module TurboReady
4
4
  class Railtie < ::Rails::Railtie
5
+ initializer "turbo_ready.patch" do
6
+ ::ActiveSupport.on_load(:action_cable) do
7
+ # Adds TurboReady stream actions to Turbo
8
+ TurboReady.patch!
9
+ end
10
+ end
5
11
  end
6
12
  end
@@ -31,5 +31,7 @@ module TurboReady
31
31
  ensure
32
32
  turbo_ready_tags.clear
33
33
  end
34
+
35
+ alias_method :to_s, :flush
34
36
  end
35
37
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TurboReady
4
- VERSION = "0.0.2"
4
+ VERSION = "0.0.5"
5
5
  end
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "turbo_ready",
3
- "version": "0.0.1",
3
+ "version": "0.0.4",
4
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",
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.2
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nate Hopkins (hopsoft)