proscenium 0.11.0.pre.9-arm64-darwin → 0.11.0.pre.11-arm64-darwin
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/proscenium/css_module/transformer.rb +19 -11
- data/lib/proscenium/css_module.rb +10 -1
- data/lib/proscenium/ext/proscenium +0 -0
- data/lib/proscenium/helper.rb +9 -3
- data/lib/proscenium/libs/react-manager/index.jsx +15 -6
- data/lib/proscenium/phlex/css_modules.rb +27 -1
- data/lib/proscenium/phlex.rb +0 -1
- data/lib/proscenium/version.rb +1 -1
- metadata +3 -4
- data/lib/proscenium/phlex/page.rb +0 -62
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa886294c46353e120b898e38963617da263d56ecc12bd5e5a6f4cdfac6f18f2
|
4
|
+
data.tar.gz: 7f7b6a3910688e5d5ed63c72b542f30153f35b48293d5fac00afefc6161f7488
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 532bc19aed316eb0d4f201a5a7b1a4525f33fde7caf9987c4ffb194179db24dfc05f586e9b2d6d3901a083598ea5c314c599d6ec8761c08b1606145230ffef2a
|
7
|
+
data.tar.gz: f119ae6fccadd08598bbc7c5b0e452d5544b755a9f7c51989247867f1bafb28206f6a941909b46f443524442403ddc5f89363b42299ec40cab50eeab1d352661
|
@@ -9,7 +9,8 @@ module Proscenium
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def initialize(source_path)
|
12
|
-
@source_path = source_path
|
12
|
+
return unless (@source_path = source_path)
|
13
|
+
|
13
14
|
@source_path = Pathname.new(@source_path) unless @source_path.is_a?(Pathname)
|
14
15
|
@source_path = @source_path.sub_ext(FILE_EXT) unless @source_path.to_s.end_with?(FILE_EXT)
|
15
16
|
end
|
@@ -37,6 +38,7 @@ module Proscenium
|
|
37
38
|
# @return [Array<String>] the transformed CSS module names.
|
38
39
|
def class_names(*names, require_prefix: true)
|
39
40
|
names.map do |name|
|
41
|
+
original_name = name.dup
|
40
42
|
name = name.to_s if name.is_a?(Symbol)
|
41
43
|
|
42
44
|
if name.include?('/')
|
@@ -50,25 +52,31 @@ module Proscenium
|
|
50
52
|
path, name = name.split('@')
|
51
53
|
end
|
52
54
|
|
53
|
-
class_name! name, path: "#{path}#{FILE_EXT}"
|
55
|
+
class_name! name, original_name, path: "#{path}#{FILE_EXT}"
|
54
56
|
elsif name.start_with?('@')
|
55
|
-
class_name! name[1..]
|
57
|
+
class_name! name[1..], original_name
|
56
58
|
else
|
57
|
-
require_prefix ? name : class_name!(name)
|
59
|
+
require_prefix ? name : class_name!(name, original_name)
|
58
60
|
end
|
59
61
|
end
|
60
62
|
end
|
61
63
|
|
62
|
-
def class_name!(name, path: @source_path)
|
64
|
+
def class_name!(name, original_name, path: @source_path)
|
65
|
+
unless path
|
66
|
+
raise Proscenium::CssModule::TransformError.new(original_name, 'CSS module path not given')
|
67
|
+
end
|
68
|
+
|
63
69
|
resolved_path = Resolver.resolve(path.to_s)
|
64
70
|
digest = Importer.import(resolved_path)
|
65
71
|
|
66
|
-
|
67
|
-
if
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
+
transformed_name = name.to_s
|
73
|
+
transformed_name = if transformed_name.start_with?('_')
|
74
|
+
"_#{transformed_name[1..]}-#{digest}"
|
75
|
+
else
|
76
|
+
"#{transformed_name}-#{digest}"
|
77
|
+
end
|
78
|
+
|
79
|
+
[transformed_name, resolved_path]
|
72
80
|
end
|
73
81
|
end
|
74
82
|
end
|
@@ -6,11 +6,20 @@ module Proscenium::CssModule
|
|
6
6
|
autoload :Path
|
7
7
|
autoload :Transformer
|
8
8
|
|
9
|
+
class TransformError < StandardError
|
10
|
+
def initialize(name, additional_msg = nil)
|
11
|
+
msg = "Failed to transform CSS module `#{name}`"
|
12
|
+
msg << ' - ' << additional_msg if additional_msg
|
13
|
+
|
14
|
+
super msg
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
9
18
|
# Accepts one or more CSS class names, and transforms them into CSS module names.
|
10
19
|
#
|
11
20
|
# @param name [String,Symbol,Array<String,Symbol>]
|
12
21
|
def css_module(*names)
|
13
|
-
cssm.class_names(*names, require_prefix: false).join
|
22
|
+
cssm.class_names(*names, require_prefix: false).map { |name, _| name }.join(' ')
|
14
23
|
end
|
15
24
|
|
16
25
|
private
|
Binary file
|
data/lib/proscenium/helper.rb
CHANGED
@@ -22,7 +22,9 @@ module Proscenium
|
|
22
22
|
# @param name [String,Symbol,Array<String,Symbol>]
|
23
23
|
def css_module(*names)
|
24
24
|
path = Pathname.new(@lookup_context.find(@virtual_path).identifier).sub_ext('')
|
25
|
-
CssModule::Transformer.new(path).class_names(*names, require_prefix: false).
|
25
|
+
CssModule::Transformer.new(path).class_names(*names, require_prefix: false).map do |name, _|
|
26
|
+
name
|
27
|
+
end.join(' ')
|
26
28
|
end
|
27
29
|
|
28
30
|
def include_stylesheets(**options)
|
@@ -75,10 +77,14 @@ module Proscenium
|
|
75
77
|
|
76
78
|
if extract_lazy_scripts
|
77
79
|
content_for :proscenium_lazy_scripts do
|
78
|
-
|
80
|
+
tag.script type: 'application/json', id: 'prosceniumLazyScripts' do
|
81
|
+
raw scripts.to_json
|
82
|
+
end
|
79
83
|
end
|
80
84
|
else
|
81
|
-
out <<
|
85
|
+
out << tag.script(type: 'application/json', id: 'prosceniumLazyScripts') do
|
86
|
+
raw scripts.to_json
|
87
|
+
end
|
82
88
|
end
|
83
89
|
else
|
84
90
|
Importer.each_javascript(delete: true) do |path, _|
|
@@ -1,7 +1,16 @@
|
|
1
|
-
|
1
|
+
window.Proscenium = window.Proscenium || { lazyScripts: {} };
|
2
|
+
|
3
|
+
const element = document.querySelector("#prosceniumLazyScripts");
|
4
|
+
if (element) {
|
5
|
+
const scripts = JSON.parse(element.text);
|
6
|
+
window.Proscenium.lazyScripts = {
|
7
|
+
...window.Proscenium.lazyScripts,
|
8
|
+
...scripts,
|
9
|
+
};
|
10
|
+
}
|
2
11
|
|
3
|
-
|
4
|
-
elements.length > 0 && init();
|
12
|
+
const elements = document.querySelectorAll("[data-proscenium-component-path]");
|
13
|
+
elements.length > 0 && init(elements);
|
5
14
|
|
6
15
|
function init() {
|
7
16
|
/**
|
@@ -20,12 +29,12 @@ function init() {
|
|
20
29
|
// For testing and simulation of slow connections.
|
21
30
|
// const sim = new Promise((resolve) => setTimeout(resolve, 5000));
|
22
31
|
|
23
|
-
if (!
|
24
|
-
throw `[proscenium/react/manager] Cannot load component ${path} (not found in
|
32
|
+
if (!window.Proscenium.lazyScripts[path]) {
|
33
|
+
throw `[proscenium/react/manager] Cannot load component ${path} (not found in Proscenium.lazyScripts)`;
|
25
34
|
}
|
26
35
|
|
27
36
|
const react = import("@proscenium/react-manager/react");
|
28
|
-
const Component = import(window.
|
37
|
+
const Component = import(window.Proscenium.lazyScripts[path].outpath);
|
29
38
|
|
30
39
|
const forwardChildren =
|
31
40
|
"prosceniumComponentForwardChildren" in element.dataset &&
|
@@ -6,6 +6,28 @@ module Proscenium
|
|
6
6
|
|
7
7
|
def self.included(base)
|
8
8
|
base.extend CssModule::Path
|
9
|
+
base.extend ClassMethods
|
10
|
+
end
|
11
|
+
|
12
|
+
module ClassMethods
|
13
|
+
# Set of CSS module paths that have been resolved after being transformed from 'class' HTML
|
14
|
+
# attributes. See #process_attributes. This is here because Phlex caches attributes. Which
|
15
|
+
# means while the CSS class names will be transformed, any resolved paths will be lost in
|
16
|
+
# subsequent requests.
|
17
|
+
attr_accessor :resolved_css_module_paths
|
18
|
+
end
|
19
|
+
|
20
|
+
def before_template
|
21
|
+
self.class.resolved_css_module_paths ||= Concurrent::Set.new
|
22
|
+
super
|
23
|
+
end
|
24
|
+
|
25
|
+
def after_template
|
26
|
+
self.class.resolved_css_module_paths.each do |path|
|
27
|
+
Proscenium::Importer.import path
|
28
|
+
end
|
29
|
+
|
30
|
+
super
|
9
31
|
end
|
10
32
|
|
11
33
|
# Resolve and side load any CSS modules in the "class" attributes, where a CSS module is a class
|
@@ -44,7 +66,11 @@ module Proscenium
|
|
44
66
|
def process_attributes(**attributes)
|
45
67
|
if attributes.key?(:class) && (attributes[:class] = tokens(attributes[:class])).include?('@')
|
46
68
|
names = attributes[:class].is_a?(Array) ? attributes[:class] : attributes[:class].split
|
47
|
-
|
69
|
+
|
70
|
+
attributes[:class] = cssm.class_names(*names).map do |name, path|
|
71
|
+
self.class.resolved_css_module_paths << path if path
|
72
|
+
name
|
73
|
+
end
|
48
74
|
end
|
49
75
|
|
50
76
|
attributes
|
data/lib/proscenium/phlex.rb
CHANGED
data/lib/proscenium/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: proscenium
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.0.pre.
|
4
|
+
version: 0.11.0.pre.11
|
5
5
|
platform: arm64-darwin
|
6
6
|
authors:
|
7
7
|
- Joel Moss
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-10-
|
11
|
+
date: 2023-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -112,7 +112,6 @@ files:
|
|
112
112
|
- lib/proscenium/monkey.rb
|
113
113
|
- lib/proscenium/phlex.rb
|
114
114
|
- lib/proscenium/phlex/css_modules.rb
|
115
|
-
- lib/proscenium/phlex/page.rb
|
116
115
|
- lib/proscenium/phlex/react_component.rb
|
117
116
|
- lib/proscenium/railtie.rb
|
118
117
|
- lib/proscenium/react_componentable.rb
|
@@ -149,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
148
|
- !ruby/object:Gem::Version
|
150
149
|
version: 1.3.1
|
151
150
|
requirements: []
|
152
|
-
rubygems_version: 3.4.
|
151
|
+
rubygems_version: 3.4.20
|
153
152
|
signing_key:
|
154
153
|
specification_version: 4
|
155
154
|
summary: The engine powering your Rails frontend
|
@@ -1,62 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'phlex/rails'
|
4
|
-
|
5
|
-
# Include this in your view for additional logic for rendering a full HTML page, usually from a
|
6
|
-
# controller.
|
7
|
-
module Proscenium::Phlex::Page
|
8
|
-
include Phlex::Rails::Helpers::CSPMetaTag
|
9
|
-
include Phlex::Rails::Helpers::CSRFMetaTags
|
10
|
-
include Phlex::Rails::Helpers::FaviconLinkTag
|
11
|
-
include Phlex::Rails::Helpers::PreloadLinkTag
|
12
|
-
include Phlex::Rails::Helpers::StyleSheetLinkTag
|
13
|
-
include Phlex::Rails::Helpers::ActionCableMetaTag
|
14
|
-
include Phlex::Rails::Helpers::AutoDiscoveryLinkTag
|
15
|
-
include Phlex::Rails::Helpers::JavaScriptIncludeTag
|
16
|
-
include Phlex::Rails::Helpers::JavaScriptImportMapTags
|
17
|
-
include Phlex::Rails::Helpers::JavaScriptImportModuleTag
|
18
|
-
|
19
|
-
def self.included(klass)
|
20
|
-
klass.extend(Phlex::Rails::Layout::Interface)
|
21
|
-
end
|
22
|
-
|
23
|
-
def template(&block)
|
24
|
-
doctype
|
25
|
-
html do
|
26
|
-
head
|
27
|
-
body(&block)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
private
|
32
|
-
|
33
|
-
def after_template
|
34
|
-
super
|
35
|
-
@_buffer.gsub!('<!-- [SIDE_LOAD_STYLESHEETS] -->', capture { include_stylesheets })
|
36
|
-
end
|
37
|
-
|
38
|
-
def page_title
|
39
|
-
Rails.application.class.name.deconstantize
|
40
|
-
end
|
41
|
-
|
42
|
-
def head
|
43
|
-
super do
|
44
|
-
title { page_title }
|
45
|
-
|
46
|
-
yield if block_given?
|
47
|
-
|
48
|
-
csp_meta_tag
|
49
|
-
csrf_meta_tags
|
50
|
-
|
51
|
-
comment { '[SIDE_LOAD_STYLESHEETS]' }
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def body
|
56
|
-
super do
|
57
|
-
yield if block_given?
|
58
|
-
|
59
|
-
include_javascripts type: :module, defer: true
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|