live_cable 0.1.1 → 0.1.2

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: 20702ab1185b4176ee5c141e8d3aebf94f84c1125ea4dff99d77f1e811d291be
4
- data.tar.gz: 0c98c9fb64b5cd6c0beb7c42d7a941f146159b176bcd1b794d4054387cfcd333
3
+ metadata.gz: e0376ac919c3ed29e3c63181364e512f51aa39aeeb84f1b8a0584b42e1c89985
4
+ data.tar.gz: 8bb42eb86866bddf18fb83e0a16770c4ddb48c3ec22524b680e272d155e22431
5
5
  SHA512:
6
- metadata.gz: 7d5fee026e4323afaa5341089f016e0444e830ad29cf06b2279a2861173bf7294c204a4429b5d02bc814e0a2a44abbfaad040fc6f6edd3979e990808f6c835bd
7
- data.tar.gz: 1d59e9aa056f2a088f395214105a973c80d6d43ac354b31a9ac313db3fb9465e1773aeaa83017bc95be81b2f9ee91c0f00b8a1d7155e587411a51c675a9b43b4
6
+ metadata.gz: 4f95c867c6f65a85ceca7fad4c23cc572bc1cfb6c90e008ebb24403dbc7624cd9977ae711bc133484612b0e3ac16440f3d18bf365c656c8d537f009387dfd0fe
7
+ data.tar.gz: 01d716fd63f39335bbaaed9aa8b0643f5b9a1493b9f1ca449635b4aa7f3cecc6d67992f31503412cbba6fd53860778918627430365af614b8598beb0666306b4
data/README.md CHANGED
@@ -48,14 +48,32 @@ end
48
48
 
49
49
  ## JavaScript Setup
50
50
 
51
- ### 1. Register the LiveController
51
+ LiveCable works with both **importmap-rails** (default for Rails 7+) and **JavaScript bundlers** (esbuild, Vite, webpack, Rollup via jsbundling-rails or vite_ruby).
52
52
 
53
- Register the `LiveController` in your Stimulus application (`app/javascript/controllers/application.js`):
53
+ ### Using importmap-rails (default)
54
+
55
+ The gem automatically pins all necessary modules when you install it. No additional setup is needed.
56
+
57
+ ### Using a JavaScript bundler (yarn/npm)
58
+
59
+ Install the npm package:
60
+
61
+ ```bash
62
+ yarn add @isometriks/live_cable
63
+ # or
64
+ npm install @isometriks/live_cable
65
+ ```
66
+
67
+ This will also install the required peer dependencies (`@rails/actioncable`, `@hotwired/stimulus`, and `morphdom`).
68
+
69
+ ### Register the LiveController
70
+
71
+ Register the `LiveController` in your Stimulus application (`app/javascript/controllers/application.js`). The imports are the same regardless of whether you use importmap or a bundler:
54
72
 
55
73
  ```javascript
56
74
  import { Application } from "@hotwired/stimulus"
57
- import LiveController from "live_cable_controller"
58
- import "live_cable" // Automatically starts DOM observer
75
+ import LiveController from "@isometriks/live_cable/controller"
76
+ import "@isometriks/live_cable" // Automatically starts DOM observer
59
77
 
60
78
  const application = Application.start()
61
79
  application.register("live", LiveController)
@@ -69,9 +87,9 @@ If you want to call LiveCable actions from your own Stimulus controllers, add th
69
87
 
70
88
  ```javascript
71
89
  import { Application, Controller } from "@hotwired/stimulus"
72
- import LiveController from "live_cable_controller"
73
- import LiveCableBlessing from "live_cable_blessing"
74
- import "live_cable" // Automatically starts DOM observer
90
+ import LiveController from "@isometriks/live_cable/controller"
91
+ import LiveCableBlessing from "@isometriks/live_cable/blessing"
92
+ import "@isometriks/live_cable" // Automatically starts DOM observer
75
93
 
76
94
  // Enable the blessing for all controllers
77
95
  Controller.blessings = [
@@ -1,5 +1,5 @@
1
1
  import { Controller } from "@hotwired/stimulus"
2
- import SubscriptionManager from "live_cable_subscriptions"
2
+ import SubscriptionManager from "@isometriks/live_cable/subscriptions"
3
3
 
4
4
  export default class extends Controller {
5
5
  static values = {
@@ -1,6 +1,6 @@
1
- import LiveObserver from 'live_cable_observer'
2
- import SubscriptionManager from 'live_cable_subscriptions'
3
- import DOM from 'live_cable_dom'
1
+ import LiveObserver from '@isometriks/live_cable/observer'
2
+ import SubscriptionManager from '@isometriks/live_cable/subscriptions'
3
+ import DOM from '@isometriks/live_cable/dom'
4
4
 
5
5
  const observer = new LiveObserver()
6
6
  observer.start()
@@ -1,4 +1,4 @@
1
- import LiveController from "live_cable_controller"
1
+ import LiveController from "@isometriks/live_cable/controller"
2
2
 
3
3
  export default function LiveCableBlessing(constructor) {
4
4
  Object.assign(constructor.prototype, {
@@ -1,4 +1,4 @@
1
- import DOM from "live_cable_dom"
1
+ import DOM from "@isometriks/live_cable/dom"
2
2
 
3
3
  /**
4
4
  * LiveCable DOM Observer
@@ -20,7 +20,7 @@
20
20
 
21
21
  import { createConsumer } from "@rails/actioncable"
22
22
  import morphdom from "morphdom"
23
- import DOM from "live_cable_dom"
23
+ import DOM from "@isometriks/live_cable/dom"
24
24
 
25
25
  const consumer = createConsumer()
26
26
 
data/config/importmap.rb CHANGED
@@ -3,9 +3,9 @@
3
3
  pin '@rails/actioncable', to: 'actioncable.esm.js'
4
4
  pin 'morphdom', to: 'https://ga.jspm.io/npm:morphdom@2.7.8/dist/morphdom-esm.js'
5
5
 
6
- pin 'live_cable_controller', to: 'controllers/live_controller.js'
7
- pin 'live_cable_blessing', to: 'live_cable_blessing.js'
8
- pin 'live_cable_subscriptions', to: 'subscriptions.js'
9
- pin 'live_cable_observer', to: 'observer.js'
10
- pin 'live_cable_dom', to: 'dom.js'
11
- pin 'live_cable', to: 'live_cable.js'
6
+ pin '@isometriks/live_cable/controller', to: 'controllers/live_controller.js'
7
+ pin '@isometriks/live_cable/blessing', to: 'live_cable_blessing.js'
8
+ pin '@isometriks/live_cable/subscriptions', to: 'subscriptions.js'
9
+ pin '@isometriks/live_cable/observer', to: 'observer.js'
10
+ pin '@isometriks/live_cable/dom', to: 'dom.js'
11
+ pin '@isometriks/live_cable', to: 'live_cable.js'
@@ -12,8 +12,10 @@ module LiveCable
12
12
  warn("[LiveCable Warning] #{live_component_dir} does not exist for components.")
13
13
  end
14
14
 
15
- # Add LiveCable to importmap
16
- app.config.importmap.paths << root.join('config/importmap.rb')
15
+ # Add LiveCable to importmap (skip when using jsbundling/npm)
16
+ if app.config.respond_to?(:importmap)
17
+ app.config.importmap.paths << root.join('config/importmap.rb')
18
+ end
17
19
  end
18
20
 
19
21
  initializer 'live_cable.assets_precompile' do |app|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LiveCable
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: live_cable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Craig Blanchette