stimulus-rails 0.3.8 → 0.3.9
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f291e5c1c237cc6c6358da9753353f40f3f7bad4c97ace2626a2c030ec8101a
|
4
|
+
data.tar.gz: 14f486833999a5ba37ea05143091a0ff186cc78c998a5fc59bd37d2dfc7c7b0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb8ca5dcda94fbf1f68ca45aa8037c2d8b11424b35ffae3af25dd8d9973954a8abbee2369aa62e54d2e881d58640ce07d39107c75d8c12edf7f9b8b9696b835f
|
7
|
+
data.tar.gz: 68f78448fd30aa9ba5703ec8e20089811c4732ded2e9323c325920e68af65ab40d851022013846808b4cb50ced6e352a57b5830c9cec812cb185312a17524eab
|
@@ -1,14 +1,21 @@
|
|
1
1
|
import { Application } from "@hotwired/stimulus"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
function registerControllersFrom(under) {
|
4
|
+
const paths = Object.keys(importmap).filter(path => path.match(new RegExp(`^${under}/.*_controller$`)))
|
5
|
+
paths.forEach(path => registerControllerFromPath(path, under))
|
6
|
+
}
|
7
7
|
|
8
|
-
|
9
|
-
const name = path.replace(
|
8
|
+
function registerControllerFromPath(path, under) {
|
9
|
+
const name = path.replace(`${under}/`, "").replace("_controller", "").replace(/\//g, "--").replace(/_/g, "-")
|
10
10
|
|
11
11
|
import(path)
|
12
12
|
.then(module => application.register(name, module.default))
|
13
|
-
.catch(error => console.log(`Failed to
|
14
|
-
}
|
13
|
+
.catch(error => console.log(`Failed to register controller: ${name} (${path})`, error))
|
14
|
+
}
|
15
|
+
|
16
|
+
const application = Application.start()
|
17
|
+
const importmap = JSON.parse(document.querySelector("script[type=importmap]").text).imports
|
18
|
+
|
19
|
+
registerControllersFrom("controllers")
|
20
|
+
|
21
|
+
export { application, registerControllersFrom }
|
@@ -22,6 +22,6 @@ if IMPORTMAP_PATH.exist?
|
|
22
22
|
after: "Rails.application.config.importmap.draw do\n"
|
23
23
|
else
|
24
24
|
say <<~INSTRUCTIONS, :red
|
25
|
-
You must add @
|
25
|
+
You must add @hotwired/stimulus and @hotwired/stimulus-importmap-autoloader to your importmap to reference them via ESM.
|
26
26
|
INSTRUCTIONS
|
27
27
|
end
|
data/lib/stimulus/version.rb
CHANGED
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stimulus-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Stephenson
|
8
8
|
- Javan Mahkmali
|
9
9
|
- David Heinemeier Hansson
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-08-
|
13
|
+
date: 2021-08-25 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
- - ">="
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
version: 6.0.0
|
29
|
-
description:
|
29
|
+
description:
|
30
30
|
email: david@loudthinking.com
|
31
31
|
executables: []
|
32
32
|
extensions: []
|
@@ -53,7 +53,7 @@ licenses:
|
|
53
53
|
metadata:
|
54
54
|
homepage_uri: https://stimulus.hotwired.dev
|
55
55
|
source_code_uri: https://github.com/hotwired/stimulus-rails
|
56
|
-
post_install_message:
|
56
|
+
post_install_message:
|
57
57
|
rdoc_options: []
|
58
58
|
require_paths:
|
59
59
|
- lib
|
@@ -69,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
69
|
version: '0'
|
70
70
|
requirements: []
|
71
71
|
rubygems_version: 3.1.4
|
72
|
-
signing_key:
|
72
|
+
signing_key:
|
73
73
|
specification_version: 4
|
74
74
|
summary: A modest JavaScript framework for the HTML you already have.
|
75
75
|
test_files: []
|