turbo_reflex 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Dockerfile +24 -0
- data/Gemfile.lock +1 -1
- data/README.md +4 -4
- data/app/assets/builds/{turbo_reflex.min.js → turbo_reflex.js} +1 -1
- data/app/assets/builds/{turbo_reflex.min.js.map → turbo_reflex.js.map} +0 -0
- data/docker-compose.yml +23 -0
- data/lib/turbo_reflex/version.rb +1 -1
- data/package.json +3 -3
- data/yarn-error.log +3033 -0
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23acc8c0bf8fb08c15028a42e61cf6d8f38bc183f55aff948d5c9dda00d38d8d
|
4
|
+
data.tar.gz: 411477ecc70f44c14e588aefba477ef35f5c86dd5fce02c551c6418a95782b46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7b9dd0a13ff4fda3312fa53560949b4dded8f38f9f4d1097998462cadd77de768c90b11e2a54fd2a7c99c15ea1e2045888129c0567dac0159b79b902384b596
|
7
|
+
data.tar.gz: e1fbe9d9ba34e0452c97d5d0547a55188d2584ab0f12b5545eb562714316fcef21b59c5a16cc274ff205fbf9fb264925970deb6edd612bc7810d493dc5222f8d
|
data/Dockerfile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
FROM ruby:3.1.2-alpine
|
2
|
+
|
3
|
+
RUN apk add --no-cache --update \
|
4
|
+
bash \
|
5
|
+
build-base \
|
6
|
+
htop \
|
7
|
+
less \
|
8
|
+
libc6-compat \
|
9
|
+
libsass \
|
10
|
+
linux-headers \
|
11
|
+
nodejs \
|
12
|
+
sqlite \
|
13
|
+
sqlite-dev \
|
14
|
+
sqlite-libs \
|
15
|
+
tzdata
|
16
|
+
|
17
|
+
COPY . /turbo_reflex
|
18
|
+
WORKDIR /turbo_reflex
|
19
|
+
|
20
|
+
RUN rm /turbo_reflex/Gemfile.lock && \
|
21
|
+
gem update --system && \
|
22
|
+
bundle --jobs 3 --verbose
|
23
|
+
|
24
|
+
CMD cd test/dummy && bundle exec rails s
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -117,14 +117,14 @@ TurboReflex is a lightweight Turbo Frame extension... which means that reactivit
|
|
117
117
|
|
118
118
|
```diff
|
119
119
|
# Gemfile
|
120
|
-
+gem "turbo_reflex", "~> 0.0.
|
120
|
+
+gem "turbo_reflex", "~> 0.0.3"
|
121
121
|
```
|
122
122
|
|
123
123
|
```diff
|
124
124
|
# package.json
|
125
125
|
"dependencies": {
|
126
126
|
"@hotwired/turbo-rails": ">=7.1",
|
127
|
-
+ "turbo_reflex": "^0.0.
|
127
|
+
+ "turbo_reflex": "^0.0.3"
|
128
128
|
```
|
129
129
|
|
130
130
|
*Be sure to install the __same version__ of the Ruby and JavaScript libraries.*
|
@@ -163,7 +163,7 @@ This example illustrates how to use TurboReflex to manage upvotes on a Post.
|
|
163
163
|
```erb
|
164
164
|
<!-- app/views/posts/show.html.erb -->
|
165
165
|
<%= turbo_frame_tag dom_id(@post) do %>
|
166
|
-
<a href="#" data-turbo-reflex="
|
166
|
+
<a href="#" data-turbo-reflex="PostReflex#upvote">Upvote</a>
|
167
167
|
Upvote Count: <%= @post.votes >
|
168
168
|
<% end %>
|
169
169
|
```
|
@@ -172,7 +172,7 @@ This example illustrates how to use TurboReflex to manage upvotes on a Post.
|
|
172
172
|
|
173
173
|
```ruby
|
174
174
|
# app/reflexes/posts_reflex.rb
|
175
|
-
class
|
175
|
+
class PostReflex < TurboReflex::Base
|
176
176
|
def upvote
|
177
177
|
Post.find(controller.params[:id]).increment! :votes
|
178
178
|
end
|
@@ -1,2 +1,2 @@
|
|
1
1
|
var l={beforeStart:"turbo-reflex:before-start",start:"turbo-reflex:start",finish:"turbo-reflex:finish",error:"turbo-reflex:error",missingFrameId:"turbo-reflex:missing-frame-id",missingFrame:"turbo-reflex:missing-frame",missingFrameSrc:"turbo-reflex:missing-frame-src"};function y(t,e=document,r={}){let n=new CustomEvent(t,{detail:r,cancelable:!0,bubbles:!0});e.dispatchEvent(n)}function F(){Object.values(l).forEach(t=>console.log(t))}var o={...l,dispatch:y,logEventNames:F};var u={};addEventListener("turbo:before-fetch-response",t=>{let e=t.target;u[e.id]=e.src;let{turboReflexActive:r,turboReflexElementId:n}=e.dataset;if(!r)return;let s=document.getElementById(n);delete e.dataset.turboReflexActive,delete e.dataset.turboReflexElementId,o.dispatch(o.finish,s||document,{frame:e,element:s||"Unknown! Missing id attribute."})});addEventListener("turbo:frame-load",t=>{let e=t.target;e.dataset.turboReflexSrc=u[e.id]||e.src||e.dataset.turboReflexSrc,delete u[e.id]});var L={get token(){return document.getElementById("turbo-reflex-token").getAttribute("content")}},c=L;function m(t){return t.closest("[data-turbo-reflex]")}function S(t){return t.closest("turbo-frame")}function b(t){let e=t.dataset.turboReflexFrame||t.dataset.turboFrame;if(!e){let r=S(t);r&&(e=r.id)}return e||(console.error("The reflex element does not specify a frame!","Please move the reflex element inside a <turbo-frame> or set the 'data-turbo-reflex-frame' or 'data-turbo-frame' attribute.",t),o.dispatch(o.missingFrameId,t,{element:t})),e}function g(t){let e=document.getElementById(t);return e||(console.error(`The frame '${t}' does not exist!`),o.dispatch(o.missingFrame,document,{id:t})),e}function x(t){let e=t.dataset.turboReflexSrc||t.src;return e||(console.error(`The the 'src' for <turbo-frame id='${t.id}'> is unknown!`,"TurboReflex uses 'src' to (re)render frame content after the reflex is invoked.","Please set the 'src' or 'data-turbo-reflex-src' attribute on the <turbo-frame> element.",t),o.dispatch(o.missingFrameSrc,t,{frame:t})),e}function k(t,e={}){if(t.tagName.toLowerCase()!=="select")return e.value=t.value;if(!t.multiple)return e.value=t.options[t.selectedIndex].value;e.values=Array.from(t.options).reduce((r,n)=>(n.selected&&r.push(n.value),r),[])}function v(t){let e=Array.from(t.attributes).reduce((r,n)=>(r[n.name]=n.value,r),{});return e.tag=t.tagName,e.checked=t.checked,e.disabled=t.disabled,k(t,e),e}var a={},h;function p(t){h=t}function f(t,e){a[t]=e,document.addEventListener(t,h,!0)}function E(t,e){return e=e.toLowerCase(),a[t].includes(e)||!Object.values(a).flat().includes(e)&&a[t].includes("*")}function R(){console.log(a)}addEventListener("turbo:before-fetch-request",t=>{let e=t.target,{turboReflexActive:r}=e.dataset;if(!r)return;let{fetchOptions:n}=t.detail;n.headers["Turbo-Reflex"]=c.token});function I(t){let e=document.createElement("a");return e.href=t,new URL(e)}function A(t,e={}){e.token=c.token;let r=document.createElement("input");r.type="hidden",r.name="turbo_reflex",r.value=JSON.stringify(e),t.appendChild(r)}function C(t){let e,r,n,s;try{if(e=m(t.target),!e||!E(t.type,e.tagName)||(o.dispatch(o.beforeStart,e,{element:e}),r=b(e),!r)||(n=g(r),!n)||(s=x(n),!s))return;let i={frameId:r,element:v(e)};if(o.dispatch(o.start,e,{element:e,frameId:r,frame:n,frameSrc:s,payload:i}),n.dataset.turboReflexActive=!0,n.dataset.turboReflexElementId=e.id,e.tagName.toLowerCase()==="form")return A(e,i);t.preventDefault();let d=I(s);d.searchParams.set("turbo_reflex",JSON.stringify(i)),n.src=d.toString()}catch(i){console.error("TurboReflex encountered an unexpected error!",{element:e,frameId:r,frame:n,frameSrc:s,target:t.target},i),o.dispatch(o.error,e||document,{element:e,frameId:r,frame:n,frameSrc:s,error:i})}}p(C);f("change",["input","select","textarea"]);f("submit",["form"]);f("click",["*"]);var M={registerEvent:f,logRegisteredEvents:R,logLifecycleEventNames:o.logEventNames};export{M as default};
|
2
|
-
//# sourceMappingURL=turbo_reflex.
|
2
|
+
//# sourceMappingURL=turbo_reflex.js.map
|
File without changes
|
data/docker-compose.yml
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
version: "3.9"
|
2
|
+
|
3
|
+
services:
|
4
|
+
demo:
|
5
|
+
build: .
|
6
|
+
image: turbo_reflex
|
7
|
+
container_name: turbo_reflex
|
8
|
+
working_dir: /turbo_reflex
|
9
|
+
tty: true
|
10
|
+
stdin_open: true
|
11
|
+
restart: unless-stopped
|
12
|
+
environment:
|
13
|
+
RAILS_ENV: development
|
14
|
+
expose:
|
15
|
+
- 3000
|
16
|
+
command: >
|
17
|
+
/bin/bash -c "rm -f tmp/pids/server.pid &&
|
18
|
+
rm -f Gemfile.lock &&
|
19
|
+
bundle --jobs 3 --verbose &&
|
20
|
+
bin/rails log:clear &&
|
21
|
+
bin/rails db:create db:migrate &&
|
22
|
+
bin/rails s --binding=0.0.0.0 --port=3000"
|
23
|
+
|
data/lib/turbo_reflex/version.rb
CHANGED
data/package.json
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
{
|
2
2
|
"name": "turbo_reflex",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.2",
|
4
4
|
"description": "Reflexes for Turbo Frames that help you build robust reactive applications",
|
5
|
-
"main": "app/
|
5
|
+
"main": "app/javascript/turbo_reflex.js",
|
6
6
|
"repository": "https://github.com/hopsoft/turbo_reflex",
|
7
7
|
"author": "Nate Hopkins (hopsoft) <natehop@gmail.com>",
|
8
8
|
"license": "MIT",
|
@@ -15,6 +15,6 @@
|
|
15
15
|
"prettier-standard": "^16.4.1"
|
16
16
|
},
|
17
17
|
"scripts": {
|
18
|
-
"build": "esbuild app/javascript/turbo_reflex.js --bundle --minify --sourcemap --format=esm --outfile=app/assets/builds/turbo_reflex.
|
18
|
+
"build": "esbuild app/javascript/turbo_reflex.js --bundle --minify --sourcemap --format=esm --outfile=app/assets/builds/turbo_reflex.js"
|
19
19
|
}
|
20
20
|
}
|