stimulus-rails 0.2.3 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -1
- data/README.md +7 -11
- data/app/assets/javascripts/{stimulus/loaders/autoloader.js → stimulus-autoloader.js} +2 -2
- data/app/assets/javascripts/{stimulus/libraries/stimulus.js → stimulus.js} +0 -0
- data/app/assets/javascripts/{stimulus/libraries/stimulus@2.js → stimulus@2.js} +0 -0
- data/lib/install/app/assets/javascripts/controllers/hello_controller.js +1 -1
- data/lib/install/app/assets/javascripts/controllers/index.js +4 -4
- data/lib/install/stimulus_with_asset_pipeline.rb +5 -21
- data/lib/install/stimulus_with_webpacker.rb +4 -3
- data/lib/stimulus/engine.rb +9 -12
- data/lib/stimulus/version.rb +1 -1
- data/lib/tasks/stimulus_tasks.rake +3 -1
- metadata +8 -15
- data/app/assets/javascripts/stimulus/libraries/es-module-shims.js +0 -1
- data/app/assets/javascripts/stimulus/libraries/es-module-shims@0.7.1.js +0 -475
- data/app/assets/javascripts/stimulus/manifest.js +0 -2
- data/app/helpers/stimulus/stimulus_helper.rb +0 -10
- data/lib/install/app/assets/javascripts/importmap.json.erb +0 -5
- data/lib/install/application.js +0 -1
- data/lib/stimulus/importmap_helper.rb +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 593f2770e2f1bcd18ce6dcf32cc62a13ca4eaa57e0837ef62f34f5a57acb9be9
|
4
|
+
data.tar.gz: ae9a0e02e14c4c9e5c6923bb63db6c2ab38fdd3f797dbc0d892f8195ccedd16b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28cd6d3b4341198e2f5006c4426c2d68122c4a1e5d88c9d6034d3912587bf795fed1b347b4c1bf81c3cc1c9f8bcf26fb40049a15be638614f162685bd1109cee
|
7
|
+
data.tar.gz: 7bec8ac3c36d819e6bbba72734cb85fbf32f4fd05dbcbe6b7ea743fb67e963b3af69d590b356f283820d072b06d6f89c427dd563664f6d28de9cf4de5541a136
|
data/MIT-LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
# Stimulus for Rails
|
2
2
|
|
3
|
-
[Stimulus](https://stimulus.
|
3
|
+
[Stimulus](https://stimulus.hotwired.dev) is a JavaScript framework with modest ambitions. It doesn’t seek to take over your entire front-end in fact, it’s not concerned with rendering HTML at all. Instead, it’s designed to augment your HTML with just enough behavior to make it shine. Stimulus pairs beautifully with Turbo to provide a complete solution for fast, compelling applications with a minimal amount of effort. Together they form the core of [Hotwire](https://hotwired.dev).
|
4
4
|
|
5
|
-
Stimulus for Rails makes it easy to use this modest framework with the asset pipeline and ES6/ESM in the browser. It
|
5
|
+
Stimulus for Rails makes it easy to use this modest framework with the asset pipeline and ES6/ESM in the browser. It relies on `importmap-rails` to make stimulus available via ESM. Make sure to install this first!
|
6
6
|
|
7
|
-
If you want to use Stimulus with a bundler, you should use [Webpacker](https://github.com/rails/webpacker) instead. This gem is purely intended for those who wish to use Stimulus with the asset pipeline using ESM in the browser.
|
8
7
|
|
9
8
|
## Installation
|
10
9
|
|
@@ -15,9 +14,9 @@ If you want to use Stimulus with a bundler, you should use [Webpacker](https://g
|
|
15
14
|
If using the asset pipeline to manage JavaScript, the last command will:
|
16
15
|
|
17
16
|
1. Create an example controller in `app/assets/javascripts/controllers/hello_controller.js`.
|
18
|
-
2. Append
|
19
|
-
|
20
|
-
|
17
|
+
2. Append `import "@hotwired/stimulus-autoloader"` to your `app/assets/javascripts/application.js` entrypoint.
|
18
|
+
|
19
|
+
Make sure you've already installed `importmap-rails` and that it's referenced before `stimulus-rails` (or `hotwire-rails`) in your Gemfile.
|
21
20
|
|
22
21
|
If using Webpacker to manage JavaScript, the last command will:
|
23
22
|
|
@@ -26,9 +25,10 @@ If using Webpacker to manage JavaScript, the last command will:
|
|
26
25
|
3. Create an example controller in `app/javascripts/controllers/hello_controller.js`.
|
27
26
|
4. Install the Stimulus NPM package.
|
28
27
|
|
28
|
+
|
29
29
|
## Usage
|
30
30
|
|
31
|
-
With the
|
31
|
+
With the installation done, you'll automatically have activated Stimulus through the controller autoloader. You can now easily add new Stimulus controllers that'll be loaded via ESM dynamic imports.
|
32
32
|
|
33
33
|
For example, a more advanced `hello_controller` could look like this:
|
34
34
|
|
@@ -62,10 +62,6 @@ And it'll be activated and registered automatically when encountering the data-c
|
|
62
62
|
|
63
63
|
That's it!
|
64
64
|
|
65
|
-
You can add additional libraries needed by your controllers in `app/assets/javascripts/libraries` using the `library@1.0.0.js` naming convention. These libraries will be added to the dynamically generated [importmap](https://github.com/WICG/import-maps) (a shim is included with the `stimulus_include_tags`), so you can reference `cookies@0.5.6.js` as `import Cookie from "cookies"`.
|
66
|
-
|
67
|
-
The libraries must be made for ESM. See https://skypack.dev where you can either directly reference libraries or download them and use them with the ESM conversion.
|
68
|
-
|
69
65
|
|
70
66
|
## License
|
71
67
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Application } from "stimulus"
|
1
|
+
import { Application } from "@hotwired/stimulus"
|
2
2
|
|
3
3
|
const application = Application.start()
|
4
4
|
const { controllerAttribute } = application.schema
|
@@ -23,7 +23,7 @@ function loadController(name) {
|
|
23
23
|
}
|
24
24
|
|
25
25
|
function controllerFilename(name) {
|
26
|
-
return
|
26
|
+
return `controllers/${name.replace(/--/g, "/").replace(/-/g, "_")}_controller`
|
27
27
|
}
|
28
28
|
|
29
29
|
function registerController(name, module) {
|
File without changes
|
File without changes
|
@@ -1,9 +1,9 @@
|
|
1
1
|
// Load all the controllers within this directory and all subdirectories.
|
2
|
-
// Controller files must be named *_controller.js.
|
2
|
+
// Controller files must be named *_controller.js or *_controller.ts.
|
3
3
|
|
4
4
|
import { Application } from "stimulus"
|
5
5
|
import { definitionsFromContext } from "stimulus/webpack-helpers"
|
6
6
|
|
7
|
-
|
8
|
-
const context = require.context("controllers", true, /_controller\.js$/)
|
9
|
-
|
7
|
+
window.Stimulus = Application.start()
|
8
|
+
const context = require.context("controllers", true, /_controller\.(js|ts)$/)
|
9
|
+
Stimulus.load(definitionsFromContext(context))
|
@@ -1,23 +1,7 @@
|
|
1
|
-
|
2
|
-
directory "#{__dir__}/app/assets/javascripts", "app/assets/javascripts"
|
3
|
-
empty_directory_with_keep_file "app/assets/javascripts/libraries"
|
1
|
+
APP_JS_ROOT = Rails.root.join("app/assets/javascripts")
|
4
2
|
|
5
|
-
say "
|
6
|
-
append_to_file
|
3
|
+
say "Import Stimulus autoloader in existing app/assets/javascripts/application.js"
|
4
|
+
append_to_file APP_JS_ROOT.join("application.js"), %(import "@hotwired/stimulus-autoloader"\n)
|
7
5
|
|
8
|
-
|
9
|
-
|
10
|
-
if APPLICATION_LAYOUT_PATH.exist?
|
11
|
-
say "Add Stimulus include tags in application layout"
|
12
|
-
insert_into_file Rails.root.join("app/views/layouts/application.html.erb").to_s, "\n <%= stimulus_include_tags %>", before: /\s*<\/head>/
|
13
|
-
else
|
14
|
-
say "Default application.html.erb is missing!", :red
|
15
|
-
say " Add <%= stimulus_include_tags %> within the <head> tag in your custom layout."
|
16
|
-
end
|
17
|
-
|
18
|
-
say "Turn off development debug mode"
|
19
|
-
comment_lines Rails.root.join("config/environments/development.rb"), /config.assets.debug = true/
|
20
|
-
|
21
|
-
say "Turn off rack-mini-profiler"
|
22
|
-
comment_lines Rails.root.join("Gemfile"), /rack-mini-profiler/
|
23
|
-
run "bin/bundle", capture: true
|
6
|
+
say "Creating controllers directory"
|
7
|
+
copy_file "#{__dir__}/app/assets/javascripts/controllers/hello_controller.js", APP_JS_ROOT.join("controllers/hello_controller.js")
|
@@ -1,10 +1,11 @@
|
|
1
1
|
say "Appending Stimulus setup code to #{Webpacker.config.source_entry_path}/application.js"
|
2
|
-
append_to_file "#{Webpacker.config.source_entry_path}/application.js"
|
3
|
-
"\n" + open("#{__dir__}/application.js").read
|
4
|
-
end
|
2
|
+
append_to_file "#{Webpacker.config.source_entry_path}/application.js", %(\nimport "controllers")
|
5
3
|
|
6
4
|
say "Creating controllers directory"
|
7
5
|
directory "#{__dir__}/app/assets/javascripts/controllers", "#{Webpacker.config.source_path}/controllers"
|
8
6
|
|
7
|
+
say "Using Stimulus NPM package"
|
8
|
+
gsub_file "#{Webpacker.config.source_path}/controllers/hello_controller.js", /@hotwired\//, ''
|
9
|
+
|
9
10
|
say "Installing all Stimulus dependencies"
|
10
11
|
run "yarn add stimulus"
|
data/lib/stimulus/engine.rb
CHANGED
@@ -1,20 +1,17 @@
|
|
1
|
-
require "stimulus/importmap_helper"
|
2
|
-
|
3
1
|
module Stimulus
|
4
2
|
class Engine < ::Rails::Engine
|
5
|
-
config.autoload_once_paths = %w( #{root}/app/helpers )
|
6
|
-
|
7
3
|
initializer "stimulus.assets" do
|
8
|
-
Rails.application.config.assets
|
9
|
-
|
10
|
-
|
11
|
-
initializer "stimulus.helpers" do
|
12
|
-
ActiveSupport.on_load(:action_controller_base) do
|
13
|
-
helper Stimulus::StimulusHelper
|
4
|
+
if Rails.application.config.respond_to?(:assets)
|
5
|
+
Rails.application.config.assets.precompile += %w( stimulus stimulus-autoloader )
|
14
6
|
end
|
7
|
+
end
|
15
8
|
|
16
|
-
|
17
|
-
|
9
|
+
initializer "stimulus.importmap" do
|
10
|
+
if Rails.application.config.respond_to?(:importmap)
|
11
|
+
Rails.application.config.importmap.paths.tap do |paths|
|
12
|
+
paths.asset "@hotwired/stimulus", path: "stimulus.js"
|
13
|
+
paths.asset "@hotwired/stimulus-autoloader", path: "stimulus-autoloader.js"
|
14
|
+
end
|
18
15
|
end
|
19
16
|
end
|
20
17
|
end
|
data/lib/stimulus/version.rb
CHANGED
@@ -5,8 +5,10 @@ namespace :stimulus do
|
|
5
5
|
task :install do
|
6
6
|
if defined?(Webpacker::Engine)
|
7
7
|
Rake::Task["stimulus:install:webpacker"].invoke
|
8
|
-
|
8
|
+
elsif defined?(Importmap)
|
9
9
|
Rake::Task["stimulus:install:asset_pipeline"].invoke
|
10
|
+
else
|
11
|
+
puts "You must either be running Webpacker or importmap-rails to use this gem."
|
10
12
|
end
|
11
13
|
end
|
12
14
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stimulus-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Stephenson
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-
|
13
|
+
date: 2021-08-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -35,29 +35,22 @@ files:
|
|
35
35
|
- MIT-LICENSE
|
36
36
|
- README.md
|
37
37
|
- Rakefile
|
38
|
-
- app/assets/javascripts/stimulus
|
39
|
-
- app/assets/javascripts/stimulus
|
40
|
-
- app/assets/javascripts/stimulus
|
41
|
-
- app/assets/javascripts/stimulus/libraries/stimulus@2.js
|
42
|
-
- app/assets/javascripts/stimulus/loaders/autoloader.js
|
43
|
-
- app/assets/javascripts/stimulus/manifest.js
|
44
|
-
- app/helpers/stimulus/stimulus_helper.rb
|
38
|
+
- app/assets/javascripts/stimulus-autoloader.js
|
39
|
+
- app/assets/javascripts/stimulus.js
|
40
|
+
- app/assets/javascripts/stimulus@2.js
|
45
41
|
- lib/install/app/assets/javascripts/controllers/hello_controller.js
|
46
42
|
- lib/install/app/assets/javascripts/controllers/index.js
|
47
|
-
- lib/install/app/assets/javascripts/importmap.json.erb
|
48
|
-
- lib/install/application.js
|
49
43
|
- lib/install/stimulus_with_asset_pipeline.rb
|
50
44
|
- lib/install/stimulus_with_webpacker.rb
|
51
45
|
- lib/stimulus-rails.rb
|
52
46
|
- lib/stimulus/engine.rb
|
53
|
-
- lib/stimulus/importmap_helper.rb
|
54
47
|
- lib/stimulus/version.rb
|
55
48
|
- lib/tasks/stimulus_tasks.rake
|
56
|
-
homepage: https://stimulus.
|
49
|
+
homepage: https://stimulus.hotwired.dev
|
57
50
|
licenses:
|
58
51
|
- MIT
|
59
52
|
metadata:
|
60
|
-
homepage_uri: https://stimulus.
|
53
|
+
homepage_uri: https://stimulus.hotwired.dev
|
61
54
|
source_code_uri: https://github.com/hotwired/stimulus-rails
|
62
55
|
post_install_message:
|
63
56
|
rdoc_options: []
|
@@ -74,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
74
67
|
- !ruby/object:Gem::Version
|
75
68
|
version: '0'
|
76
69
|
requirements: []
|
77
|
-
rubygems_version: 3.1.
|
70
|
+
rubygems_version: 3.1.4
|
78
71
|
signing_key:
|
79
72
|
specification_version: 4
|
80
73
|
summary: A modest JavaScript framework for the HTML you already have.
|
@@ -1 +0,0 @@
|
|
1
|
-
//= require ./es-module-shims@0.7.1.js
|
@@ -1,475 +0,0 @@
|
|
1
|
-
/* ES Module Shims 0.5.0 */
|
2
|
-
(function () {
|
3
|
-
'use strict';
|
4
|
-
|
5
|
-
const resolvedPromise = Promise.resolve();
|
6
|
-
|
7
|
-
let baseUrl;
|
8
|
-
|
9
|
-
function createBlob (source) {
|
10
|
-
return URL.createObjectURL(new Blob([source], { type: 'application/javascript' }));
|
11
|
-
}
|
12
|
-
|
13
|
-
const hasDocument = typeof document !== 'undefined';
|
14
|
-
|
15
|
-
// support browsers without dynamic import support (eg Firefox 6x)
|
16
|
-
let dynamicImport;
|
17
|
-
try {
|
18
|
-
dynamicImport = (0, eval)('u=>import(u)');
|
19
|
-
}
|
20
|
-
catch (e) {
|
21
|
-
if (hasDocument) {
|
22
|
-
self.addEventListener('error', e => importShim.e = e.error);
|
23
|
-
dynamicImport = blobUrl => {
|
24
|
-
const topLevelBlobUrl = createBlob(
|
25
|
-
`import*as m from'${blobUrl}';self.importShim.l=m;self.importShim.e=null`
|
26
|
-
);
|
27
|
-
const s = document.createElement('script');
|
28
|
-
s.type = 'module';
|
29
|
-
s.src = topLevelBlobUrl;
|
30
|
-
document.head.appendChild(s);
|
31
|
-
return new Promise((resolve, reject) => {
|
32
|
-
s.addEventListener('load', () => {
|
33
|
-
document.head.removeChild(s);
|
34
|
-
importShim.e ? reject(importShim.e) : resolve(importShim.l, baseUrl);
|
35
|
-
});
|
36
|
-
});
|
37
|
-
};
|
38
|
-
}
|
39
|
-
}
|
40
|
-
|
41
|
-
if (hasDocument) {
|
42
|
-
const baseEl = document.querySelector('base[href]');
|
43
|
-
if (baseEl)
|
44
|
-
baseUrl = baseEl.href;
|
45
|
-
}
|
46
|
-
|
47
|
-
if (!baseUrl && typeof location !== 'undefined') {
|
48
|
-
baseUrl = location.href.split('#')[0].split('?')[0];
|
49
|
-
const lastSepIndex = baseUrl.lastIndexOf('/');
|
50
|
-
if (lastSepIndex !== -1)
|
51
|
-
baseUrl = baseUrl.slice(0, lastSepIndex + 1);
|
52
|
-
}
|
53
|
-
|
54
|
-
let esModuleShimsSrc;
|
55
|
-
if (hasDocument) {
|
56
|
-
esModuleShimsSrc = document.currentScript && document.currentScript.src;
|
57
|
-
}
|
58
|
-
|
59
|
-
const backslashRegEx = /\\/g;
|
60
|
-
function resolveIfNotPlainOrUrl (relUrl, parentUrl) {
|
61
|
-
// strip off any trailing query params or hashes
|
62
|
-
parentUrl = parentUrl && parentUrl.split('#')[0].split('?')[0];
|
63
|
-
if (relUrl.indexOf('\\') !== -1)
|
64
|
-
relUrl = relUrl.replace(backslashRegEx, '/');
|
65
|
-
// protocol-relative
|
66
|
-
if (relUrl[0] === '/' && relUrl[1] === '/') {
|
67
|
-
return parentUrl.slice(0, parentUrl.indexOf(':') + 1) + relUrl;
|
68
|
-
}
|
69
|
-
// relative-url
|
70
|
-
else if (relUrl[0] === '.' && (relUrl[1] === '/' || relUrl[1] === '.' && (relUrl[2] === '/' || relUrl.length === 2 && (relUrl += '/')) ||
|
71
|
-
relUrl.length === 1 && (relUrl += '/')) ||
|
72
|
-
relUrl[0] === '/') {
|
73
|
-
const parentProtocol = parentUrl.slice(0, parentUrl.indexOf(':') + 1);
|
74
|
-
// Disabled, but these cases will give inconsistent results for deep backtracking
|
75
|
-
//if (parentUrl[parentProtocol.length] !== '/')
|
76
|
-
// throw new Error('Cannot resolve');
|
77
|
-
// read pathname from parent URL
|
78
|
-
// pathname taken to be part after leading "/"
|
79
|
-
let pathname;
|
80
|
-
if (parentUrl[parentProtocol.length + 1] === '/') {
|
81
|
-
// resolving to a :// so we need to read out the auth and host
|
82
|
-
if (parentProtocol !== 'file:') {
|
83
|
-
pathname = parentUrl.slice(parentProtocol.length + 2);
|
84
|
-
pathname = pathname.slice(pathname.indexOf('/') + 1);
|
85
|
-
}
|
86
|
-
else {
|
87
|
-
pathname = parentUrl.slice(8);
|
88
|
-
}
|
89
|
-
}
|
90
|
-
else {
|
91
|
-
// resolving to :/ so pathname is the /... part
|
92
|
-
pathname = parentUrl.slice(parentProtocol.length + (parentUrl[parentProtocol.length] === '/'));
|
93
|
-
}
|
94
|
-
|
95
|
-
if (relUrl[0] === '/')
|
96
|
-
return parentUrl.slice(0, parentUrl.length - pathname.length - 1) + relUrl;
|
97
|
-
|
98
|
-
// join together and split for removal of .. and . segments
|
99
|
-
// looping the string instead of anything fancy for perf reasons
|
100
|
-
// '../../../../../z' resolved to 'x/y' is just 'z'
|
101
|
-
const segmented = pathname.slice(0, pathname.lastIndexOf('/') + 1) + relUrl;
|
102
|
-
|
103
|
-
const output = [];
|
104
|
-
let segmentIndex = -1;
|
105
|
-
for (let i = 0; i < segmented.length; i++) {
|
106
|
-
// busy reading a segment - only terminate on '/'
|
107
|
-
if (segmentIndex !== -1) {
|
108
|
-
if (segmented[i] === '/') {
|
109
|
-
output.push(segmented.slice(segmentIndex, i + 1));
|
110
|
-
segmentIndex = -1;
|
111
|
-
}
|
112
|
-
}
|
113
|
-
|
114
|
-
// new segment - check if it is relative
|
115
|
-
else if (segmented[i] === '.') {
|
116
|
-
// ../ segment
|
117
|
-
if (segmented[i + 1] === '.' && (segmented[i + 2] === '/' || i + 2 === segmented.length)) {
|
118
|
-
output.pop();
|
119
|
-
i += 2;
|
120
|
-
}
|
121
|
-
// ./ segment
|
122
|
-
else if (segmented[i + 1] === '/' || i + 1 === segmented.length) {
|
123
|
-
i += 1;
|
124
|
-
}
|
125
|
-
else {
|
126
|
-
// the start of a new segment as below
|
127
|
-
segmentIndex = i;
|
128
|
-
}
|
129
|
-
}
|
130
|
-
// it is the start of a new segment
|
131
|
-
else {
|
132
|
-
segmentIndex = i;
|
133
|
-
}
|
134
|
-
}
|
135
|
-
// finish reading out the last segment
|
136
|
-
if (segmentIndex !== -1)
|
137
|
-
output.push(segmented.slice(segmentIndex));
|
138
|
-
return parentUrl.slice(0, parentUrl.length - pathname.length) + output.join('');
|
139
|
-
}
|
140
|
-
}
|
141
|
-
|
142
|
-
/*
|
143
|
-
* Import maps implementation
|
144
|
-
*
|
145
|
-
* To make lookups fast we pre-resolve the entire import map
|
146
|
-
* and then match based on backtracked hash lookups
|
147
|
-
*
|
148
|
-
*/
|
149
|
-
function resolveUrl (relUrl, parentUrl) {
|
150
|
-
return resolveIfNotPlainOrUrl(relUrl, parentUrl) || (relUrl.indexOf(':') !== -1 ? relUrl : resolveIfNotPlainOrUrl('./' + relUrl, parentUrl));
|
151
|
-
}
|
152
|
-
|
153
|
-
function resolveAndComposePackages (packages, outPackages, baseUrl, parentMap) {
|
154
|
-
for (let p in packages) {
|
155
|
-
const resolvedLhs = resolveIfNotPlainOrUrl(p, baseUrl) || p;
|
156
|
-
let target = packages[p];
|
157
|
-
if (typeof target !== 'string')
|
158
|
-
continue;
|
159
|
-
const mapped = resolveImportMap(parentMap, resolveIfNotPlainOrUrl(target, baseUrl) || target, baseUrl);
|
160
|
-
if (mapped) {
|
161
|
-
outPackages[resolvedLhs] = mapped;
|
162
|
-
continue;
|
163
|
-
}
|
164
|
-
targetWarning(p, packages[p], 'bare specifier did not resolve');
|
165
|
-
}
|
166
|
-
}
|
167
|
-
|
168
|
-
function resolveAndComposeImportMap (json, baseUrl, parentMap) {
|
169
|
-
const outMap = { imports: Object.assign({}, parentMap.imports), scopes: Object.assign({}, parentMap.scopes), depcache: Object.assign({}, parentMap.depcache) };
|
170
|
-
|
171
|
-
if (json.imports)
|
172
|
-
resolveAndComposePackages(json.imports, outMap.imports, baseUrl, parentMap,);
|
173
|
-
|
174
|
-
if (json.scopes)
|
175
|
-
for (let s in json.scopes) {
|
176
|
-
const resolvedScope = resolveUrl(s, baseUrl);
|
177
|
-
resolveAndComposePackages(json.scopes[s], outMap.scopes[resolvedScope] || (outMap.scopes[resolvedScope] = {}), baseUrl, parentMap);
|
178
|
-
}
|
179
|
-
|
180
|
-
if (json.depcache)
|
181
|
-
for (let d in json.depcache) {
|
182
|
-
const resolvedDepcache = resolveUrl(d, baseUrl);
|
183
|
-
outMap.depcache[resolvedDepcache] = json.depcache[d];
|
184
|
-
}
|
185
|
-
|
186
|
-
return outMap;
|
187
|
-
}
|
188
|
-
|
189
|
-
function getMatch (path, matchObj) {
|
190
|
-
if (matchObj[path])
|
191
|
-
return path;
|
192
|
-
let sepIndex = path.length;
|
193
|
-
do {
|
194
|
-
const segment = path.slice(0, sepIndex + 1);
|
195
|
-
if (segment in matchObj)
|
196
|
-
return segment;
|
197
|
-
} while ((sepIndex = path.lastIndexOf('/', sepIndex - 1)) !== -1)
|
198
|
-
}
|
199
|
-
|
200
|
-
function applyPackages (id, packages) {
|
201
|
-
const pkgName = getMatch(id, packages);
|
202
|
-
if (pkgName) {
|
203
|
-
const pkg = packages[pkgName];
|
204
|
-
if (pkg === null) return;
|
205
|
-
if (id.length > pkgName.length && pkg[pkg.length - 1] !== '/')
|
206
|
-
targetWarning(pkgName, pkg, "should have a trailing '/'");
|
207
|
-
else
|
208
|
-
return pkg + id.slice(pkgName.length);
|
209
|
-
}
|
210
|
-
}
|
211
|
-
|
212
|
-
function targetWarning (match, target, msg) {
|
213
|
-
console.warn("Package target " + msg + ", resolving target '" + target + "' for " + match);
|
214
|
-
}
|
215
|
-
|
216
|
-
function resolveImportMap (importMap, resolvedOrPlain, parentUrl) {
|
217
|
-
let scopeUrl = parentUrl && getMatch(parentUrl, importMap.scopes);
|
218
|
-
while (scopeUrl) {
|
219
|
-
const packageResolution = applyPackages(resolvedOrPlain, importMap.scopes[scopeUrl]);
|
220
|
-
if (packageResolution)
|
221
|
-
return packageResolution;
|
222
|
-
scopeUrl = getMatch(scopeUrl.slice(0, scopeUrl.lastIndexOf('/')), importMap.scopes);
|
223
|
-
}
|
224
|
-
return applyPackages(resolvedOrPlain, importMap.imports) || resolvedOrPlain.indexOf(':') !== -1 && resolvedOrPlain;
|
225
|
-
}
|
226
|
-
|
227
|
-
/* es-module-lexer 0.3.26 */
|
228
|
-
const A=1===new Uint8Array(new Uint16Array([1]).buffer)[0];function parse(E,g="@"){if(!B)return init.then(()=>parse(E));const I=E.length+1,D=(B.__heap_base.value||B.__heap_base)+4*I-B.memory.buffer.byteLength;D>0&&B.memory.grow(Math.ceil(D/65536));const w=B.sa(I-1);if((A?C:Q)(E,new Uint16Array(B.memory.buffer,w,I)),!B.parse())throw Object.assign(new Error(`Parse error ${g}:${E.slice(0,B.e()).split("\n").length}:${B.e()-E.lastIndexOf("\n",B.e()-1)}`),{idx:B.e()});const L=[],k=[];for(;B.ri();)L.push({s:B.is(),e:B.ie(),ss:B.ss(),se:B.se(),d:B.id()});for(;B.re();)k.push(E.slice(B.es(),B.ee()));return [L,k,!!B.f()]}function Q(A,Q){const C=A.length;let B=0;for(;B<C;){const C=A.charCodeAt(B);Q[B++]=(255&C)<<8|C>>>8;}}function C(A,Q){const C=A.length;let B=0;for(;B<C;)Q[B]=A.charCodeAt(B++);}let B;const init=WebAssembly.compile((E="AGFzbQEAAAABWAxgAX8Bf2AEf39/fwBgAn9/AGAAAX9gAABgBn9/f39/fwF/YAR/f39/A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BACEHAkAgAC8BCiAGRw0AIAAvAQggBUcNACAALwEGIARHDQAgAC8BBCADRw0AIAAvAQIgAkcNACAALwEAIAFGIQcLIAcLUwEBf0EAIQgCQCAALwEMIAdHDQAgAC8BCiAGRw0AIAAvAQggBUcNACAALwEGIARHDQAgAC8BBCADRw0AIAAvAQIgAkcNACAALwEAIAFGIQgLIAgLCx8CAEGACAsCAAAAQYQICxABAAAAAgAAAAAEAABwOAAA","function"==typeof atob?Uint8Array.from(atob(E),A=>A.charCodeAt(0)):Buffer.from(E,"base64"))).then(WebAssembly.instantiate).then(({exports:A})=>{B=A;});var E;
|
229
|
-
|
230
|
-
let id = 0;
|
231
|
-
const registry = {};
|
232
|
-
|
233
|
-
async function loadAll (load, seen) {
|
234
|
-
if (load.b || seen[load.u])
|
235
|
-
return;
|
236
|
-
seen[load.u] = 1;
|
237
|
-
await load.L;
|
238
|
-
return Promise.all(load.d.map(dep => loadAll(dep, seen)));
|
239
|
-
}
|
240
|
-
|
241
|
-
let waitingForImportMapsInterval;
|
242
|
-
let firstTopLevelProcess = true;
|
243
|
-
async function topLevelLoad (url, source) {
|
244
|
-
if (waitingForImportMapsInterval > 0) {
|
245
|
-
clearTimeout(waitingForImportMapsInterval);
|
246
|
-
waitingForImportMapsInterval = 0;
|
247
|
-
}
|
248
|
-
if (firstTopLevelProcess) {
|
249
|
-
firstTopLevelProcess = false;
|
250
|
-
processScripts();
|
251
|
-
}
|
252
|
-
await importMapPromise;
|
253
|
-
await init;
|
254
|
-
const load = getOrCreateLoad(url, source);
|
255
|
-
const seen = {};
|
256
|
-
await loadAll(load, seen);
|
257
|
-
lastLoad = undefined;
|
258
|
-
resolveDeps(load, seen);
|
259
|
-
const module = await dynamicImport(load.b);
|
260
|
-
// if the top-level load is a shell, run its update function
|
261
|
-
if (load.s)
|
262
|
-
(await dynamicImport(load.s)).u$_(module);
|
263
|
-
return module;
|
264
|
-
}
|
265
|
-
|
266
|
-
async function importShim$1 (id, parentUrl) {
|
267
|
-
return topLevelLoad(resolve(id, parentUrl || baseUrl));
|
268
|
-
}
|
269
|
-
|
270
|
-
self.importShim = importShim$1;
|
271
|
-
|
272
|
-
const meta = {};
|
273
|
-
|
274
|
-
const edge = navigator.userAgent.match(/Edge\/\d\d\.\d+$/);
|
275
|
-
|
276
|
-
async function importMetaResolve (id, parentUrl = this.url) {
|
277
|
-
await importMapPromise;
|
278
|
-
return resolve(id, `${parentUrl}`);
|
279
|
-
}
|
280
|
-
|
281
|
-
Object.defineProperties(importShim$1, {
|
282
|
-
m: { value: meta },
|
283
|
-
l: { value: undefined, writable: true },
|
284
|
-
e: { value: undefined, writable: true }
|
285
|
-
});
|
286
|
-
importShim$1.fetch = url => fetch(url);
|
287
|
-
importShim$1.skip = /^https?:\/\/(cdn\.pika\.dev|dev\.jspm\.io|jspm\.dev)\//;
|
288
|
-
importShim$1.load = processScripts;
|
289
|
-
importShim$1.onerror = (e) => {
|
290
|
-
throw e;
|
291
|
-
};
|
292
|
-
|
293
|
-
let lastLoad;
|
294
|
-
function resolveDeps (load, seen) {
|
295
|
-
if (load.b || !seen[load.u])
|
296
|
-
return;
|
297
|
-
seen[load.u] = 0;
|
298
|
-
|
299
|
-
for (const dep of load.d)
|
300
|
-
resolveDeps(dep, seen);
|
301
|
-
|
302
|
-
// "execution"
|
303
|
-
const source = load.S;
|
304
|
-
// edge doesnt execute sibling in order, so we fix this up by ensuring all previous executions are explicit dependencies
|
305
|
-
let resolvedSource = edge && lastLoad ? `import '${lastLoad}';` : '';
|
306
|
-
|
307
|
-
const [imports] = load.a;
|
308
|
-
|
309
|
-
if (!imports.length) {
|
310
|
-
resolvedSource += source;
|
311
|
-
}
|
312
|
-
else {
|
313
|
-
// once all deps have loaded we can inline the dependency resolution blobs
|
314
|
-
// and define this blob
|
315
|
-
let lastIndex = 0, depIndex = 0;
|
316
|
-
for (const { s: start, e: end, d: dynamicImportIndex } of imports) {
|
317
|
-
// dependency source replacements
|
318
|
-
if (dynamicImportIndex === -1) {
|
319
|
-
const depLoad = load.d[depIndex++];
|
320
|
-
let blobUrl = depLoad.b;
|
321
|
-
if (!blobUrl) {
|
322
|
-
// circular shell creation
|
323
|
-
if (!(blobUrl = depLoad.s)) {
|
324
|
-
blobUrl = depLoad.s = createBlob(`export function u$_(m){${
|
325
|
-
depLoad.a[1].map(
|
326
|
-
name => name === 'default' ? `$_default=m.default` : `${name}=m.${name}`
|
327
|
-
).join(',')
|
328
|
-
}}${
|
329
|
-
depLoad.a[1].map(name =>
|
330
|
-
name === 'default' ? `let $_default;export{$_default as default}` : `export let ${name}`
|
331
|
-
).join(';')
|
332
|
-
}\n//# sourceURL=${depLoad.r}?cycle`);
|
333
|
-
}
|
334
|
-
}
|
335
|
-
// circular shell execution
|
336
|
-
else if (depLoad.s) {
|
337
|
-
resolvedSource += source.slice(lastIndex, start - 1) + '/*' + source.slice(start - 1, end + 1) + '*/' + source.slice(start - 1, start) + blobUrl + source[end] + `;import*as m$_${depIndex} from'${depLoad.b}';import{u$_ as u$_${depIndex}}from'${depLoad.s}';u$_${depIndex}(m$_${depIndex})`;
|
338
|
-
lastIndex = end + 1;
|
339
|
-
depLoad.s = undefined;
|
340
|
-
continue;
|
341
|
-
}
|
342
|
-
resolvedSource += source.slice(lastIndex, start - 1) + '/*' + source.slice(start - 1, end + 1) + '*/' + source.slice(start - 1, start) + blobUrl;
|
343
|
-
lastIndex = end;
|
344
|
-
}
|
345
|
-
// import.meta
|
346
|
-
else if (dynamicImportIndex === -2) {
|
347
|
-
meta[load.r] = { url: load.r, resolve: importMetaResolve };
|
348
|
-
resolvedSource += source.slice(lastIndex, start) + 'importShim.m[' + JSON.stringify(load.r) + ']';
|
349
|
-
lastIndex = end;
|
350
|
-
}
|
351
|
-
// dynamic import
|
352
|
-
else {
|
353
|
-
resolvedSource += source.slice(lastIndex, dynamicImportIndex + 6) + 'Shim(' + source.slice(start, end) + ', ' + JSON.stringify(load.r);
|
354
|
-
lastIndex = end;
|
355
|
-
}
|
356
|
-
}
|
357
|
-
|
358
|
-
resolvedSource += source.slice(lastIndex);
|
359
|
-
}
|
360
|
-
|
361
|
-
let sourceMappingResolved = '';
|
362
|
-
const sourceMappingIndex = resolvedSource.lastIndexOf('//# sourceMappingURL=');
|
363
|
-
if (sourceMappingIndex > -1) {
|
364
|
-
const sourceMappingEnd = resolvedSource.indexOf('\n',sourceMappingIndex);
|
365
|
-
const sourceMapping = resolvedSource.slice(sourceMappingIndex, sourceMappingEnd > -1 ? sourceMappingEnd : undefined);
|
366
|
-
sourceMappingResolved = `\n//# sourceMappingURL=` + resolveUrl(sourceMapping.slice(21), load.r);
|
367
|
-
}
|
368
|
-
load.b = lastLoad = createBlob(resolvedSource + sourceMappingResolved + '\n//# sourceURL=' + load.r);
|
369
|
-
load.S = undefined;
|
370
|
-
}
|
371
|
-
|
372
|
-
function getOrCreateLoad (url, source) {
|
373
|
-
let load = registry[url];
|
374
|
-
if (load)
|
375
|
-
return load;
|
376
|
-
|
377
|
-
load = registry[url] = {
|
378
|
-
// url
|
379
|
-
u: url,
|
380
|
-
// response url
|
381
|
-
r: undefined,
|
382
|
-
// fetchPromise
|
383
|
-
f: undefined,
|
384
|
-
// source
|
385
|
-
S: undefined,
|
386
|
-
// linkPromise
|
387
|
-
L: undefined,
|
388
|
-
// analysis
|
389
|
-
a: undefined,
|
390
|
-
// deps
|
391
|
-
d: undefined,
|
392
|
-
// blobUrl
|
393
|
-
b: undefined,
|
394
|
-
// shellUrl
|
395
|
-
s: undefined,
|
396
|
-
};
|
397
|
-
|
398
|
-
const depcache = importMap.depcache[url];
|
399
|
-
if (depcache)
|
400
|
-
depcache.forEach(depUrl => getOrCreateLoad(resolve(depUrl, url)));
|
401
|
-
|
402
|
-
load.f = (async () => {
|
403
|
-
if (!source) {
|
404
|
-
const res = await importShim$1.fetch(url);
|
405
|
-
if (!res.ok)
|
406
|
-
throw new Error(`${res.status} ${res.statusText} ${res.url}`);
|
407
|
-
load.r = res.url;
|
408
|
-
const contentType = res.headers.get('content-type');
|
409
|
-
if (contentType.match(/^(text|application)\/(x-)?javascript(;|$)/))
|
410
|
-
source = await res.text();
|
411
|
-
else
|
412
|
-
throw new Error(`Unknown Content-Type "${contentType}"`);
|
413
|
-
}
|
414
|
-
try {
|
415
|
-
load.a = parse(source, load.u);
|
416
|
-
}
|
417
|
-
catch (e) {
|
418
|
-
console.warn(e);
|
419
|
-
load.a = [[], []];
|
420
|
-
}
|
421
|
-
load.S = source;
|
422
|
-
return load.a[0].filter(d => d.d === -1).map(d => source.slice(d.s, d.e));
|
423
|
-
})();
|
424
|
-
|
425
|
-
load.L = load.f.then(async deps => {
|
426
|
-
load.d = await Promise.all(deps.map(async depId => {
|
427
|
-
const resolved = resolve(depId, load.r || load.u);
|
428
|
-
if (importShim$1.skip.test(resolved))
|
429
|
-
return { b: resolved };
|
430
|
-
const depLoad = getOrCreateLoad(resolved);
|
431
|
-
await depLoad.f;
|
432
|
-
return depLoad;
|
433
|
-
}));
|
434
|
-
});
|
435
|
-
|
436
|
-
return load;
|
437
|
-
}
|
438
|
-
|
439
|
-
let importMap = { imports: {}, scopes: {}, depcache: {} };
|
440
|
-
let importMapPromise = resolvedPromise;
|
441
|
-
|
442
|
-
if (hasDocument) {
|
443
|
-
processScripts();
|
444
|
-
waitingForImportMapsInterval = setInterval(processScripts, 20);
|
445
|
-
}
|
446
|
-
|
447
|
-
async function processScripts () {
|
448
|
-
if (waitingForImportMapsInterval > 0 && document.readyState !== 'loading') {
|
449
|
-
clearTimeout(waitingForImportMapsInterval);
|
450
|
-
waitingForImportMapsInterval = 0;
|
451
|
-
}
|
452
|
-
for (const script of document.querySelectorAll('script[type="module-shim"],script[type="importmap-shim"]')) {
|
453
|
-
if (script.ep) // ep marker = script processed
|
454
|
-
return;
|
455
|
-
if (script.type === 'module-shim') {
|
456
|
-
await topLevelLoad(script.src || `${baseUrl}?${id++}`, !script.src && script.innerHTML).catch(e => importShim$1.onerror(e));
|
457
|
-
}
|
458
|
-
else {
|
459
|
-
importMapPromise = importMapPromise.then(async () =>
|
460
|
-
importMap = resolveAndComposeImportMap(script.src ? await (await fetch(script.src)).json() : JSON.parse(script.innerHTML), script.src || baseUrl, importMap)
|
461
|
-
);
|
462
|
-
}
|
463
|
-
script.ep = true;
|
464
|
-
}
|
465
|
-
}
|
466
|
-
|
467
|
-
function resolve (id, parentUrl) {
|
468
|
-
return resolveImportMap(importMap, resolveIfNotPlainOrUrl(id, parentUrl) || id, parentUrl) || throwUnresolved(id, parentUrl);
|
469
|
-
}
|
470
|
-
|
471
|
-
function throwUnresolved (id, parentUrl) {
|
472
|
-
throw Error("Unable to resolve specifier '" + id + (parentUrl ? "' from " + parentUrl : "'"));
|
473
|
-
}
|
474
|
-
|
475
|
-
}());
|
@@ -1,10 +0,0 @@
|
|
1
|
-
module Stimulus::StimulusHelper
|
2
|
-
def stimulus_include_tags
|
3
|
-
safe_join [
|
4
|
-
javascript_include_tag("stimulus/libraries/es-module-shims", type: "module"),
|
5
|
-
tag.script(type: "importmap-shim", src: asset_path("importmap.json")),
|
6
|
-
javascript_include_tag("stimulus/libraries/stimulus", type: "module-shim"),
|
7
|
-
javascript_include_tag("stimulus/loaders/autoloader", type: "module-shim")
|
8
|
-
], "\n"
|
9
|
-
end
|
10
|
-
end
|
data/lib/install/application.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
import "controllers"
|
@@ -1,33 +0,0 @@
|
|
1
|
-
module Stimulus::ImportmapHelper
|
2
|
-
def importmap_list_with_stimulus_from(*paths)
|
3
|
-
[ %("stimulus": "#{asset_path("stimulus/libraries/stimulus")}"), importmap_list_from(*paths) ].reject(&:blank?).join(",\n")
|
4
|
-
end
|
5
|
-
|
6
|
-
def importmap_list_from(*paths)
|
7
|
-
Array(paths).flat_map do |path|
|
8
|
-
if (absolute_path = absolute_root_of(path)).exist?
|
9
|
-
find_javascript_files_in_tree(absolute_path).collect do |filename|
|
10
|
-
module_filename = filename.relative_path_from(absolute_path)
|
11
|
-
module_name = importmap_module_name_from(module_filename)
|
12
|
-
module_path = asset_path(absolute_path.basename.join(module_filename))
|
13
|
-
|
14
|
-
%("#{module_name}": "#{module_path}")
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end.compact.join(",\n")
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
# Strip off the extension and any versioning data for an absolute module name.
|
22
|
-
def importmap_module_name_from(filename)
|
23
|
-
filename.to_s.remove(filename.extname).split("@").first
|
24
|
-
end
|
25
|
-
|
26
|
-
def find_javascript_files_in_tree(path)
|
27
|
-
Dir[path.join("**/*.js{,m}")].collect { |file| Pathname.new(file) }.select(&:file?)
|
28
|
-
end
|
29
|
-
|
30
|
-
def absolute_root_of(path)
|
31
|
-
(pathname = Pathname.new(path)).absolute? ? pathname : Rails.root.join(path)
|
32
|
-
end
|
33
|
-
end
|