fenetre 0.1.0
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 +7 -0
- data/README.md +83 -0
- data/Rakefile +33 -0
- data/app/assets/javascripts/fenetre/application.js +14 -0
- data/app/assets/javascripts/fenetre/controllers/index.js +19 -0
- data/app/assets/javascripts/fenetre/controllers/video_chat_controller.js +662 -0
- data/app/assets/javascripts/fenetre/vendor/stimulus.min.js +2588 -0
- data/app/assets/javascripts/fenetre/vendor/stimulus.umd.js +2588 -0
- data/app/assets/javascripts/fenetre.js +10 -0
- data/app/assets/javascripts/stimulus/stimulus.min.js +2588 -0
- data/app/assets/stylesheets/fenetre/video_chat.css +225 -0
- data/app/channels/fenetre/video_chat_channel.rb +164 -0
- data/app/helpers/fenetre/video_chat_helper.rb +97 -0
- data/app/javascript/controllers/fenetre/video_chat_controller.js +662 -0
- data/app/javascript/test/test_runner.js +15 -0
- data/app/javascript/test/video_chat_controller_test.js +215 -0
- data/config/importmap.rb +24 -0
- data/lib/fenetre/engine.rb +190 -0
- data/lib/fenetre/version.rb +5 -0
- data/lib/fenetre/video_chat_channel.rb +36 -0
- data/lib/fenetre.rb +9 -0
- data/lib/tasks/javascript_test.rake +69 -0
- metadata +262 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7d742e322e7ed6c94bc26878f732121911872fef3823dea593eb4141ee9c1280
|
4
|
+
data.tar.gz: a6e1d6633311adf8c02aacd849cbfa262e3d50e9d1810504a1ac8bbb649c5e72
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 04e8007aae26b6c7d48d9071cd6faef061152e62c38907f346101538ff5581fa52104e20a41ccea712984b53682302f7f4e2c7ada1283253cde2aa6d7606ec36
|
7
|
+
data.tar.gz: d50582f711a81470a52739c95691a31e72529e9236dc68738489699cee5869284d4bbd81153c6be70498e772ef54e29fe7c7f52c5e3b70186994e30e8e8819a0
|
data/README.md
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
# Fenetre
|
2
|
+
|
3
|
+
[](https://github.com/andrewfader/fenetre/actions)
|
4
|
+
[](coverage/index.html)
|
5
|
+
|
6
|
+
A Rails engine that adds WebRTC video chat to your app using ActionCable, Stimulus, and Turbo.
|
7
|
+
|
8
|
+
## Setup
|
9
|
+
|
10
|
+
Fenetre automatically handles most of the necessary setup when used with `importmap-rails`:
|
11
|
+
|
12
|
+
- Mounting the Action Cable server at `/cable` (if not already mounted).
|
13
|
+
- Making the Stimulus controllers available via the import map.
|
14
|
+
- Making the view helper available.
|
15
|
+
|
16
|
+
**Important:**
|
17
|
+
- Your host application **must** use `importmap-rails`.
|
18
|
+
- Your host application's `app/javascript/application.js` should load Stimulus controllers (e.g., contain `import "./controllers"`).
|
19
|
+
|
20
|
+
Add the video chat container helper to any view where you want the chat interface:
|
21
|
+
|
22
|
+
```erb
|
23
|
+
<%# Assuming you have `room_id` and `current_user` available %>
|
24
|
+
<%= fenetre_video_chat_container(room_id, current_user.id) %>
|
25
|
+
```
|
26
|
+
|
27
|
+
This renders a complete video chat UI. The necessary Stimulus controller (`fenetre--video-chat`) will be automatically loaded.
|
28
|
+
|
29
|
+
### Room Options
|
30
|
+
|
31
|
+
Customize the video chat experience using options:
|
32
|
+
|
33
|
+
```erb
|
34
|
+
<%= fenetre_video_chat_container(
|
35
|
+
room_id,
|
36
|
+
current_user.id,
|
37
|
+
theme: 'light', # 'dark' (default) or 'light'
|
38
|
+
# Add other options as needed based on helper definition
|
39
|
+
) %>
|
40
|
+
```
|
41
|
+
|
42
|
+
### JavaScript Interaction (Optional)
|
43
|
+
|
44
|
+
While Fenetre works out-of-the-box, you can interact with the Stimulus controller (`fenetre--video-chat`) for advanced customization:
|
45
|
+
|
46
|
+
```javascript
|
47
|
+
// In your application's JavaScript or another Stimulus controller
|
48
|
+
import { Controller } from '@hotwired/stimulus'
|
49
|
+
|
50
|
+
export default class extends Controller {
|
51
|
+
connect() {
|
52
|
+
const fenetreElement = this.element.querySelector('[data-controller="fenetre--video-chat"]');
|
53
|
+
if (fenetreElement) {
|
54
|
+
const fenetreController = this.application.getControllerForElementAndIdentifier(fenetreElement, 'fenetre--video-chat');
|
55
|
+
// Now you can interact with fenetreController if needed
|
56
|
+
console.log('Fenetre controller found:', fenetreController);
|
57
|
+
|
58
|
+
// Example: Listen for custom events (if implemented in the controller)
|
59
|
+
// fenetreElement.addEventListener('fenetre:user-joined', (event) => {
|
60
|
+
// console.log(`User ${event.detail.userId} joined`);
|
61
|
+
// });
|
62
|
+
}
|
63
|
+
}
|
64
|
+
}
|
65
|
+
```
|
66
|
+
|
67
|
+
## Styling
|
68
|
+
|
69
|
+
The default styling is included automatically. You can override the CSS classes for custom themes:
|
70
|
+
|
71
|
+
```css
|
72
|
+
/* Example overrides */
|
73
|
+
.fenetre-video-chat-container {
|
74
|
+
border: 2px solid blue;
|
75
|
+
}
|
76
|
+
|
77
|
+
.fenetre-theme-light .fenetre-chat-messages {
|
78
|
+
background-color: #f0f0f0;
|
79
|
+
}
|
80
|
+
```
|
81
|
+
## License
|
82
|
+
|
83
|
+
MIT
|
data/Rakefile
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rake/testtask'
|
5
|
+
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
7
|
+
t.libs << 'test'
|
8
|
+
t.libs << 'lib'
|
9
|
+
t.test_files = FileList['test/**/*_test.rb']
|
10
|
+
end
|
11
|
+
|
12
|
+
# Add RuboCop task
|
13
|
+
begin
|
14
|
+
require 'rubocop/rake_task'
|
15
|
+
RuboCop::RakeTask.new(:rubocop) do |task|
|
16
|
+
task.options = ['--display-cop-names']
|
17
|
+
end
|
18
|
+
rescue LoadError
|
19
|
+
desc 'Run RuboCop'
|
20
|
+
task :rubocop do
|
21
|
+
abort 'RuboCop is not available. Run `bundle install` to install it.'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# Add Coverage task
|
26
|
+
desc 'Generate test coverage report'
|
27
|
+
task :coverage do
|
28
|
+
ENV['COVERAGE'] = 'true'
|
29
|
+
Rake::Task['test'].invoke
|
30
|
+
end
|
31
|
+
|
32
|
+
# Run tests with coverage by default
|
33
|
+
task default: %i[rubocop coverage]
|
@@ -0,0 +1,14 @@
|
|
1
|
+
// This serves as an entry point for Fenetre JavaScript
|
2
|
+
// It's meant to be pinned in the importmap for use by the host application
|
3
|
+
|
4
|
+
// Re-export the main fenetre module
|
5
|
+
import "./fenetre.js"
|
6
|
+
|
7
|
+
// Load the controllers entrypoint using a relative path
|
8
|
+
import "./controllers/index.js"
|
9
|
+
|
10
|
+
// Export a basic API for the host application to use
|
11
|
+
export const Fenetre = {
|
12
|
+
version: "1.0.0",
|
13
|
+
// Add more public API methods as needed
|
14
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
// This file loads all Stimulus controllers in the fenetre engine
|
2
|
+
// It's referenced by the importmap
|
3
|
+
|
4
|
+
import { Application } from "../vendor/stimulus.umd.js"
|
5
|
+
import VideoChatController from "./video_chat_controller.js"
|
6
|
+
|
7
|
+
const application = Application.start();
|
8
|
+
|
9
|
+
// Register controllers with Stimulus
|
10
|
+
application.register("fenetre--video-chat", VideoChatController)
|
11
|
+
|
12
|
+
// Expose the Stimulus application globally for testing and debugging
|
13
|
+
// This allows tests to access controllers through window.Stimulus.application
|
14
|
+
if (typeof window !== 'undefined') {
|
15
|
+
window.Stimulus = window.Stimulus || {};
|
16
|
+
window.Stimulus.application = application;
|
17
|
+
}
|
18
|
+
|
19
|
+
export { application };
|