cable_ready 5.0.0.rc2 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/app/assets/javascripts/cable_ready.js +1 -1
- data/app/assets/javascripts/cable_ready.umd.js +1 -1
- data/{lib → app/models/concerns}/cable_ready/updatable/memory_cache_debounce_adapter.rb +2 -0
- data/app/models/concerns/cable_ready/updatable.rb +1 -1
- data/cable_ready.gemspec +1 -1
- data/lib/cable_ready/version.rb +1 -1
- data/lib/cable_ready.rb +0 -2
- data/lib/generators/cable_ready/templates/app/javascript/channels/consumer.js.tt +6 -0
- data/lib/generators/cable_ready/templates/app/javascript/channels/index.js.esbuild.tt +4 -0
- data/lib/generators/cable_ready/templates/app/javascript/channels/index.js.importmap.tt +2 -0
- data/lib/generators/cable_ready/templates/app/javascript/channels/index.js.shakapacker.tt +5 -0
- data/lib/generators/cable_ready/templates/app/javascript/channels/index.js.vite.tt +1 -0
- data/lib/generators/cable_ready/templates/app/javascript/channels/index.js.webpacker.tt +5 -0
- data/lib/generators/cable_ready/templates/app/javascript/config/cable_ready.js.tt +4 -0
- data/lib/generators/cable_ready/templates/app/javascript/config/index.js.tt +1 -0
- data/lib/generators/cable_ready/templates/app/javascript/config/mrujs.js.tt +9 -0
- data/lib/generators/cable_ready/templates/app/javascript/controllers/%file_name%_controller.js.tt +38 -0
- data/lib/generators/cable_ready/templates/app/javascript/controllers/application.js.tt +11 -0
- data/lib/generators/cable_ready/templates/app/javascript/controllers/index.js.esbuild.tt +7 -0
- data/lib/generators/cable_ready/templates/app/javascript/controllers/index.js.importmap.tt +5 -0
- data/lib/generators/cable_ready/templates/app/javascript/controllers/index.js.shakapacker.tt +5 -0
- data/lib/generators/cable_ready/templates/app/javascript/controllers/index.js.vite.tt +5 -0
- data/lib/generators/cable_ready/templates/app/javascript/controllers/index.js.webpacker.tt +5 -0
- data/lib/generators/cable_ready/templates/esbuild.config.mjs.tt +94 -0
- data/package.json +1 -1
- metadata +22 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ba59c02e54e924e8c187c22a6f4025775c6de9b7732ffab37e46e9992088a95
|
4
|
+
data.tar.gz: f064e043e65174039dc33f28278436058b1999fb9feecae60d2c880b58385d57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df84a551ce0d77685c67c60914a020290d89cbd429df12be9bba5bd5031beac2d595f6863bbc624476b0d8e00f25483c327bf00c78108208704aa4940efbeadf
|
7
|
+
data.tar.gz: 0f8222d6fd31691bf60bf3d695478e6a982c1c7471a278a4881ff6cb62e50b6caf22894ee66a9d37222c0aadf0634c3631a2540a459b2b50b72ae0e6d29caab3
|
data/Gemfile.lock
CHANGED
@@ -2,7 +2,7 @@ import morphdom from "morphdom";
|
|
2
2
|
|
3
3
|
var name = "cable_ready";
|
4
4
|
|
5
|
-
var version = "5.0.0
|
5
|
+
var version = "5.0.0";
|
6
6
|
|
7
7
|
var description = "CableReady helps you create great real-time user experiences by making it simple to trigger client-side DOM changes from server-side Ruby.";
|
8
8
|
|
@@ -4,7 +4,7 @@
|
|
4
4
|
})(this, (function(exports, morphdom) {
|
5
5
|
"use strict";
|
6
6
|
var name = "cable_ready";
|
7
|
-
var version = "5.0.0
|
7
|
+
var version = "5.0.0";
|
8
8
|
var description = "CableReady helps you create great real-time user experiences by making it simple to trigger client-side DOM changes from server-side Ruby.";
|
9
9
|
var keywords = [ "ruby", "rails", "websockets", "actioncable", "cable", "ssr", "stimulus_reflex", "client-side", "dom" ];
|
10
10
|
var homepage = "https://cableready.stimulusreflex.com";
|
@@ -6,7 +6,7 @@ module CableReady
|
|
6
6
|
module Updatable
|
7
7
|
extend ::ActiveSupport::Concern
|
8
8
|
|
9
|
-
mattr_accessor :debounce_adapter, default: MemoryCacheDebounceAdapter.instance
|
9
|
+
mattr_accessor :debounce_adapter, default: ::CableReady::Updatable::MemoryCacheDebounceAdapter.instance
|
10
10
|
|
11
11
|
included do |base|
|
12
12
|
if defined?(ActiveRecord) && base < ActiveRecord::Base
|
data/cable_ready.gemspec
CHANGED
data/lib/cable_ready/version.rb
CHANGED
data/lib/cable_ready.rb
CHANGED
@@ -0,0 +1,6 @@
|
|
1
|
+
// Action Cable provides the framework to deal with WebSockets in Rails.
|
2
|
+
// You can generate new channels where WebSocket features live using the `bin/rails generate channel` command.
|
3
|
+
|
4
|
+
import { createConsumer } from '@rails/actioncable'
|
5
|
+
|
6
|
+
export default createConsumer()
|
@@ -0,0 +1 @@
|
|
1
|
+
const channels = import.meta.globEager('./**/*_channel.js')
|
@@ -0,0 +1 @@
|
|
1
|
+
import './cable_ready'
|
data/lib/generators/cable_ready/templates/app/javascript/controllers/%file_name%_controller.js.tt
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
import { Controller } from '@hotwired/stimulus'
|
2
|
+
import CableReady from 'cable_ready'
|
3
|
+
|
4
|
+
export default class extends Controller {
|
5
|
+
static values = { id: Number }
|
6
|
+
|
7
|
+
connect () {
|
8
|
+
if (this.preview) return
|
9
|
+
if (this.application.consumer) {
|
10
|
+
this.channel = this.application.consumer.subscriptions.create(
|
11
|
+
{
|
12
|
+
channel: '<%= class_name %>Channel',
|
13
|
+
id: this.idValue
|
14
|
+
},
|
15
|
+
{
|
16
|
+
received (data) {
|
17
|
+
if (data.cableReady) CableReady.perform(data.operations)
|
18
|
+
}
|
19
|
+
}
|
20
|
+
)
|
21
|
+
} else {
|
22
|
+
console.error(
|
23
|
+
`The "<%= class_name.underscore.dasherize %>" Stimulus controller requires an Action Cable consumer.\nPlease set 'application.consumer = consumer' in your application.js.`
|
24
|
+
)
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
disconnect () {
|
29
|
+
this.channel.unsubscribe()
|
30
|
+
}
|
31
|
+
|
32
|
+
get preview () {
|
33
|
+
return (
|
34
|
+
document.documentElement.hasAttribute('data-turbolinks-preview') ||
|
35
|
+
document.documentElement.hasAttribute('data-turbo-preview')
|
36
|
+
)
|
37
|
+
}
|
38
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { Application } from "@hotwired/stimulus"
|
2
|
+
import consumer from "../channels/consumer"
|
3
|
+
|
4
|
+
const application = Application.start()
|
5
|
+
|
6
|
+
// Configure Stimulus development experience
|
7
|
+
application.debug = false
|
8
|
+
application.consumer = consumer
|
9
|
+
window.Stimulus = application
|
10
|
+
|
11
|
+
export { application }
|
@@ -0,0 +1,94 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
|
3
|
+
// Esbuild is configured with 3 modes:
|
4
|
+
//
|
5
|
+
// `yarn build` - Build JavaScript and exit
|
6
|
+
// `yarn build --watch` - Rebuild JavaScript on change
|
7
|
+
// `yarn build --reload` - Reloads page when views, JavaScript, or stylesheets change
|
8
|
+
//
|
9
|
+
// Minify is enabled when "RAILS_ENV=production"
|
10
|
+
// Sourcemaps are enabled in non-production environments
|
11
|
+
|
12
|
+
import * as esbuild from "esbuild"
|
13
|
+
import path from "path"
|
14
|
+
import rails from "esbuild-rails"
|
15
|
+
import chokidar from "chokidar"
|
16
|
+
import http from "http"
|
17
|
+
import { setTimeout } from "timers/promises"
|
18
|
+
|
19
|
+
const clients = []
|
20
|
+
|
21
|
+
const entryPoints = [
|
22
|
+
"application.js"
|
23
|
+
]
|
24
|
+
|
25
|
+
const watchDirectories = [
|
26
|
+
"./app/javascript/**/*.js",
|
27
|
+
"./app/views/**/*.html.erb",
|
28
|
+
"./app/assets/builds/**/*.css", // Wait for cssbundling changes
|
29
|
+
]
|
30
|
+
|
31
|
+
const config = {
|
32
|
+
absWorkingDir: path.join(process.cwd(), "app/javascript"),
|
33
|
+
bundle: true,
|
34
|
+
entryPoints: entryPoints,
|
35
|
+
minify: process.env.RAILS_ENV == "production",
|
36
|
+
outdir: path.join(process.cwd(), "app/assets/builds"),
|
37
|
+
plugins: [rails()],
|
38
|
+
sourcemap: process.env.RAILS_ENV != "production"
|
39
|
+
}
|
40
|
+
|
41
|
+
async function buildAndReload() {
|
42
|
+
// Foreman & Overmind assign a separate PORT for each process
|
43
|
+
const port = parseInt(process.env.PORT)
|
44
|
+
const context = await esbuild.context({
|
45
|
+
...config,
|
46
|
+
banner: {
|
47
|
+
js: ` (() => new EventSource("http://localhost:${port}").onmessage = () => location.reload())();`,
|
48
|
+
}
|
49
|
+
})
|
50
|
+
|
51
|
+
// Reload uses an HTTP server as an even stream to reload the browser
|
52
|
+
http.createServer((req, res) => {
|
53
|
+
return clients.push(
|
54
|
+
res.writeHead(200, {
|
55
|
+
"Content-Type": "text/event-stream",
|
56
|
+
"Cache-Control": "no-cache",
|
57
|
+
"Access-Control-Allow-Origin": "*",
|
58
|
+
Connection: "keep-alive",
|
59
|
+
})
|
60
|
+
)
|
61
|
+
}).listen(port)
|
62
|
+
|
63
|
+
await context.rebuild()
|
64
|
+
console.log("[reload] initial build succeeded")
|
65
|
+
|
66
|
+
let ready = false
|
67
|
+
chokidar.watch(watchDirectories).on("ready", () => {
|
68
|
+
console.log("[reload] ready")
|
69
|
+
ready = true
|
70
|
+
}).on("all", async (event, path) => {
|
71
|
+
if (ready === false) return
|
72
|
+
|
73
|
+
if (path.includes("javascript")) {
|
74
|
+
try {
|
75
|
+
await setTimeout(20)
|
76
|
+
await context.rebuild()
|
77
|
+
console.log("[reload] build succeeded")
|
78
|
+
} catch (error) {
|
79
|
+
console.error("[reload] build failed", error)
|
80
|
+
}
|
81
|
+
}
|
82
|
+
clients.forEach((res) => res.write("data: update\n\n"))
|
83
|
+
clients.length = 0
|
84
|
+
})
|
85
|
+
}
|
86
|
+
|
87
|
+
if (process.argv.includes("--reload")) {
|
88
|
+
buildAndReload()
|
89
|
+
} else if (process.argv.includes("--watch")) {
|
90
|
+
let context = await esbuild.context({...config, logLevel: 'info'})
|
91
|
+
context.watch()
|
92
|
+
} else {
|
93
|
+
esbuild.build(config)
|
94
|
+
}
|
data/package.json
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cable_ready
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.0
|
4
|
+
version: 5.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Hopkins
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -214,6 +214,7 @@ files:
|
|
214
214
|
- app/models/concerns/cable_ready/updatable.rb
|
215
215
|
- app/models/concerns/cable_ready/updatable/collection_updatable_callbacks.rb
|
216
216
|
- app/models/concerns/cable_ready/updatable/collections_registry.rb
|
217
|
+
- app/models/concerns/cable_ready/updatable/memory_cache_debounce_adapter.rb
|
217
218
|
- app/models/concerns/cable_ready/updatable/model_updatable_callbacks.rb
|
218
219
|
- app/models/concerns/extend_has_many.rb
|
219
220
|
- bin/console
|
@@ -235,11 +236,27 @@ files:
|
|
235
236
|
- lib/cable_ready/operation_builder.rb
|
236
237
|
- lib/cable_ready/sanity_checker.rb
|
237
238
|
- lib/cable_ready/stream_identifier.rb
|
238
|
-
- lib/cable_ready/updatable/memory_cache_debounce_adapter.rb
|
239
239
|
- lib/cable_ready/version.rb
|
240
240
|
- lib/cable_ready_helper.rb
|
241
241
|
- lib/generators/cable_ready/channel_generator.rb
|
242
|
+
- lib/generators/cable_ready/templates/app/javascript/channels/consumer.js.tt
|
243
|
+
- lib/generators/cable_ready/templates/app/javascript/channels/index.js.esbuild.tt
|
244
|
+
- lib/generators/cable_ready/templates/app/javascript/channels/index.js.importmap.tt
|
245
|
+
- lib/generators/cable_ready/templates/app/javascript/channels/index.js.shakapacker.tt
|
246
|
+
- lib/generators/cable_ready/templates/app/javascript/channels/index.js.vite.tt
|
247
|
+
- lib/generators/cable_ready/templates/app/javascript/channels/index.js.webpacker.tt
|
248
|
+
- lib/generators/cable_ready/templates/app/javascript/config/cable_ready.js.tt
|
249
|
+
- lib/generators/cable_ready/templates/app/javascript/config/index.js.tt
|
250
|
+
- lib/generators/cable_ready/templates/app/javascript/config/mrujs.js.tt
|
251
|
+
- lib/generators/cable_ready/templates/app/javascript/controllers/%file_name%_controller.js.tt
|
252
|
+
- lib/generators/cable_ready/templates/app/javascript/controllers/application.js.tt
|
253
|
+
- lib/generators/cable_ready/templates/app/javascript/controllers/index.js.esbuild.tt
|
254
|
+
- lib/generators/cable_ready/templates/app/javascript/controllers/index.js.importmap.tt
|
255
|
+
- lib/generators/cable_ready/templates/app/javascript/controllers/index.js.shakapacker.tt
|
256
|
+
- lib/generators/cable_ready/templates/app/javascript/controllers/index.js.vite.tt
|
257
|
+
- lib/generators/cable_ready/templates/app/javascript/controllers/index.js.webpacker.tt
|
242
258
|
- lib/generators/cable_ready/templates/config/initializers/cable_ready.rb
|
259
|
+
- lib/generators/cable_ready/templates/esbuild.config.mjs.tt
|
243
260
|
- lib/install/action_cable.rb
|
244
261
|
- lib/install/broadcaster.rb
|
245
262
|
- lib/install/bundle.rb
|
@@ -277,9 +294,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
277
294
|
version: 2.7.0
|
278
295
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
279
296
|
requirements:
|
280
|
-
- - "
|
297
|
+
- - ">="
|
281
298
|
- !ruby/object:Gem::Version
|
282
|
-
version:
|
299
|
+
version: '0'
|
283
300
|
requirements: []
|
284
301
|
rubygems_version: 3.4.1
|
285
302
|
signing_key:
|