proscenium 0.17.0-x86_64-darwin → 0.18.0-x86_64-darwin

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: cac05c7b04ae00a23bc5fdc756e2f84d0d4ab609e31ca778220a3eba54cfd70b
4
- data.tar.gz: 966043dd74d150e12197bced913b99a321610e5ec83e841a0798c603965eb8a5
3
+ metadata.gz: fa9fefe60949e0c21e8600e4a1cb774a8481131b9c42554dbb0bba6cead0b55d
4
+ data.tar.gz: ada8262d355d7e821594be722bd6a3af05d5dd432030665092bb2100a65e1a0f
5
5
  SHA512:
6
- metadata.gz: 185036c0585134b3552865161c064c6bfb585c6183e3563c66c865b84c98013a8cd829ea5dddc43d57980bf4c84153d38c6582b08ee32130e3cacd76a021e27d
7
- data.tar.gz: 5419b3db81eb4bdbe31ea330dcb87580aa9d695b0d5bcb7f924833cf6801e1420f36bef3b0d79a548f901fc926b93ebf00861efe4c73275c46ce2a343103f740
6
+ metadata.gz: a716d12562730c277b619bf975ef0e2d0ff7fecda0aae4263b3e8c9f5b0dcda2252ed96e9e0121fdf225503c2886d01e8d706bd17b6a19eee2ff55fe20d1fbfb
7
+ data.tar.gz: 06dd69d0842e29817bb694614a46ccb2658a8e42f65064c918c38574d5d1b105a18e2b223f3aafdbcc7e8bc3a3c39057d945debcb07cc499e98739cd447fa908
data/README.md CHANGED
@@ -890,7 +890,7 @@ bundle exec rake compile:local
890
890
  We have tests for both Ruby and Go. To run the Ruby tests:
891
891
 
892
892
  ```bash
893
- bundle exec sus
893
+ bin/test
894
894
  ```
895
895
 
896
896
  To run the Go tests:
Binary file
@@ -21,12 +21,10 @@ module Proscenium
21
21
  # /app/javascript.
22
22
  def compute_asset_path(path, options = {})
23
23
  if %i[javascript stylesheet].include?(options[:type])
24
- if !path.start_with?("./", "../")
25
- path.prepend DEFAULT_RAILS_ASSET_PATHS[options[:type]]
26
- end
24
+ path.prepend DEFAULT_RAILS_ASSET_PATHS[options[:type]] unless path.start_with?('./', '../')
27
25
 
28
26
  result = Proscenium::Builder.build_to_path(path, base_url: request.base_url)
29
- return result.split("::").last.delete_prefix "public"
27
+ return result.split('::').last.delete_prefix 'public'
30
28
  end
31
29
 
32
30
  super
@@ -61,7 +59,7 @@ module Proscenium
61
59
  end
62
60
 
63
61
  def include_stylesheets
64
- '<!-- [PROSCENIUM_STYLESHEETS] -->'.html_safe
62
+ SideLoad::CSS_COMMENT.html_safe
65
63
  end
66
64
  alias side_load_stylesheets include_stylesheets
67
65
  deprecate side_load_stylesheets: 'Use `include_stylesheets` instead', deprecator: Deprecator.new
@@ -70,7 +68,7 @@ module Proscenium
70
68
  #
71
69
  # @return [String] the HTML tags for the javascripts.
72
70
  def include_javascripts
73
- '<!-- [PROSCENIUM_LAZY_SCRIPTS] --><!-- [PROSCENIUM_JAVASCRIPTS] -->'.html_safe
71
+ (SideLoad::LAZY_COMMENT + SideLoad::JS_COMMENT).html_safe
74
72
  end
75
73
  alias side_load_javascripts include_javascripts
76
74
  deprecate side_load_javascripts: 'Use `include_javascripts` instead', deprecator: Deprecator.new
@@ -2,6 +2,10 @@
2
2
 
3
3
  module Proscenium
4
4
  class SideLoad
5
+ JS_COMMENT = '<!-- [PROSCENIUM_JAVASCRIPTS] -->'
6
+ CSS_COMMENT = '<!-- [PROSCENIUM_STYLESHEETS] -->'
7
+ LAZY_COMMENT = '<!-- [PROSCENIUM_LAZY_SCRIPTS] -->'
8
+
5
9
  module Controller
6
10
  def self.included(child)
7
11
  child.class_eval do
@@ -23,7 +27,13 @@ module Proscenium
23
27
  def capture_and_replace_proscenium_stylesheets
24
28
  return if response_body.nil?
25
29
  return if response_body.first.blank? || !Proscenium::Importer.css_imported?
26
- return unless response_body.first.include? '<!-- [PROSCENIUM_STYLESHEETS] -->'
30
+
31
+ included_comment = response_body.first.include?(CSS_COMMENT)
32
+ fragments = if (fragment_header = request.headers['X-Fragment'])
33
+ fragment_header.split
34
+ end
35
+
36
+ return if !fragments && !included_comment
27
37
 
28
38
  imports = Proscenium::Importer.imported.dup
29
39
  paths_to_build = []
@@ -44,12 +54,17 @@ module Proscenium
44
54
 
45
55
  import = imports[inpath]
46
56
  opts = import[:css].is_a?(Hash) ? import[:css] : {}
57
+ opts[:preload_links_header] = false if fragments
47
58
  opts[:data] ||= {}
48
59
  opts[:data][:original_href] = inpath
49
60
  out << helpers.stylesheet_link_tag(outpath, extname: false, **opts)
50
61
  end
51
62
 
52
- response_body.first.gsub! '<!-- [PROSCENIUM_STYLESHEETS] -->', out.join.html_safe
63
+ if fragments
64
+ response_body.first.prepend out.join.html_safe
65
+ elsif included_comment
66
+ response_body.first.gsub! CSS_COMMENT, out.join.html_safe
67
+ end
53
68
  end
54
69
 
55
70
  def capture_and_replace_proscenium_javascripts
@@ -65,7 +80,13 @@ module Proscenium
65
80
  result = Proscenium::Builder.build_to_path(paths_to_build.join(';'),
66
81
  base_url: helpers.request.base_url)
67
82
 
68
- if response_body.first.include? '<!-- [PROSCENIUM_JAVASCRIPTS] -->'
83
+ included_js_comment = response_body.first.include?(JS_COMMENT)
84
+ included_lazy_comment = response_body.first.include?(LAZY_COMMENT)
85
+ fragments = if (fragment_header = request.headers['X-Fragment'])
86
+ fragment_header.split
87
+ end
88
+
89
+ if fragments || included_js_comment
69
90
  out = []
70
91
  scripts = {}
71
92
  result.split(';').each do |x|
@@ -79,14 +100,19 @@ module Proscenium
79
100
  scripts[inpath] = import.merge(outpath:)
80
101
  else
81
102
  opts = import[:js].is_a?(Hash) ? import[:js] : {}
103
+ opts[:preload_links_header] = false if fragments
82
104
  out << helpers.javascript_include_tag(outpath, extname: false, **opts)
83
105
  end
84
106
  end
85
107
 
86
- response_body.first.gsub! '<!-- [PROSCENIUM_JAVASCRIPTS] -->', out.join.html_safe
108
+ if fragments
109
+ response_body.first.prepend out.join.html_safe
110
+ elsif included_js_comment
111
+ response_body.first.gsub! JS_COMMENT, out.join.html_safe
112
+ end
87
113
  end
88
114
 
89
- return unless response_body.first.include? '<!-- [PROSCENIUM_LAZY_SCRIPTS] -->'
115
+ return if !fragments && !included_lazy_comment
90
116
 
91
117
  lazy_script = ''
92
118
  if scripts.present?
@@ -96,7 +122,11 @@ module Proscenium
96
122
  end
97
123
  end
98
124
 
99
- response_body.first.gsub! '<!-- [PROSCENIUM_LAZY_SCRIPTS] -->', lazy_script
125
+ if fragments
126
+ response_body.first.prepend lazy_script
127
+ elsif included_lazy_comment
128
+ response_body.first.gsub! LAZY_COMMENT, lazy_script
129
+ end
100
130
  end
101
131
  end
102
132
 
@@ -1,6 +1,6 @@
1
1
  @layer proscenium-ui-component {
2
2
  /*
3
- * Custom properties:
3
+ * Properties:
4
4
  *
5
5
  * --puiBreadcrumbs--link-color: LinkText;
6
6
  * --puiBreadcrumbs--link-hover-color: HighlightText;
@@ -1,28 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'literal'
4
+
3
5
  module Proscenium::UI
4
6
  class Breadcrumbs::Component < Component
7
+ extend Literal::Properties
5
8
  include Phlex::Rails::Helpers::URLFor
6
9
 
7
10
  # The path (route) to use as the HREF for the home segment. Defaults to `:root`.
8
- option :home_path, Types::String | Types::Symbol, default: -> { :root }
11
+ prop :home_path, _Union(String, Symbol), default: -> { :root }
9
12
 
10
13
  # Assign false to hide the home segment.
11
- option :with_home, Types::Bool, default: -> { true }
12
-
13
- # One or more class name(s) for the base div element which will be appended to the default.
14
- option :class, Types::Coercible::String | Types::Array.of(Types::Coercible::String),
15
- as: :class_name, default: -> { [] }
16
-
17
- # One or more class name(s) for the base div element which will replace the default. If both
18
- # `class` and `class!` are provided, all values will be merged. Defaults to `:@base`.
19
- option :class!, Types::Coercible::String | Types::Array.of(Types::Coercible::String),
20
- as: :class_name_override, default: -> { :@base }
14
+ prop :with_home, _Boolean, default: -> { true }
21
15
 
22
16
  def view_template
23
- div class: [*class_name_override, *class_name] do
17
+ div class: :@base do
24
18
  ol do
25
- if with_home
19
+ if @with_home
26
20
  li do
27
21
  home_template
28
22
  end
@@ -48,7 +42,7 @@ module Proscenium::UI
48
42
  # super { 'hello' }
49
43
  # end
50
44
  def home_template(&block)
51
- a(href: url_for(home_path)) do
45
+ a(href: url_for(@home_path)) do
52
46
  if block
53
47
  yield
54
48
  else
@@ -1,11 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dry-initializer'
4
-
5
3
  module Proscenium::UI
6
4
  class Component < Proscenium::Phlex
7
5
  self.abstract_class = true
8
-
9
- extend Dry::Initializer
10
6
  end
11
7
  end
data/lib/proscenium/ui.rb CHANGED
@@ -1,14 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dry-types'
4
-
5
3
  module Proscenium::UI
6
4
  extend ActiveSupport::Autoload
7
5
 
8
6
  autoload :Component
9
7
  autoload :Breadcrumbs
10
-
11
- module Types
12
- include Dry.Types()
13
- end
14
8
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Proscenium
4
- VERSION = '0.17.0'
4
+ VERSION = '0.18.0'
5
5
  end
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.17.0
4
+ version: 0.18.0
5
5
  platform: x86_64-darwin
6
6
  authors:
7
7
  - Joel Moss
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-29 00:00:00.000000000 Z
11
+ date: 2024-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -30,34 +30,6 @@ dependencies:
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '8.0'
33
- - !ruby/object:Gem::Dependency
34
- name: dry-initializer
35
- requirement: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - "~>"
38
- - !ruby/object:Gem::Version
39
- version: '3.1'
40
- type: :runtime
41
- prerelease: false
42
- version_requirements: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - "~>"
45
- - !ruby/object:Gem::Version
46
- version: '3.1'
47
- - !ruby/object:Gem::Dependency
48
- name: dry-types
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - "~>"
52
- - !ruby/object:Gem::Version
53
- version: '1.7'
54
- type: :runtime
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - "~>"
59
- - !ruby/object:Gem::Version
60
- version: '1.7'
61
33
  - !ruby/object:Gem::Dependency
62
34
  name: ffi
63
35
  requirement: !ruby/object:Gem::Requirement
@@ -73,33 +45,33 @@ dependencies:
73
45
  - !ruby/object:Gem::Version
74
46
  version: 1.17.0
75
47
  - !ruby/object:Gem::Dependency
76
- name: oj
48
+ name: literal
77
49
  requirement: !ruby/object:Gem::Requirement
78
50
  requirements:
79
51
  - - "~>"
80
52
  - !ruby/object:Gem::Version
81
- version: '3.13'
53
+ version: '1.0'
82
54
  type: :runtime
83
55
  prerelease: false
84
56
  version_requirements: !ruby/object:Gem::Requirement
85
57
  requirements:
86
58
  - - "~>"
87
59
  - !ruby/object:Gem::Version
88
- version: '3.13'
60
+ version: '1.0'
89
61
  - !ruby/object:Gem::Dependency
90
- name: phlex-rails
62
+ name: oj
91
63
  requirement: !ruby/object:Gem::Requirement
92
64
  requirements:
93
65
  - - "~>"
94
66
  - !ruby/object:Gem::Version
95
- version: 1.2.1
67
+ version: '3.13'
96
68
  type: :runtime
97
69
  prerelease: false
98
70
  version_requirements: !ruby/object:Gem::Requirement
99
71
  requirements:
100
72
  - - "~>"
101
73
  - !ruby/object:Gem::Version
102
- version: 1.2.1
74
+ version: '3.13'
103
75
  - !ruby/object:Gem::Dependency
104
76
  name: railties
105
77
  requirement: !ruby/object:Gem::Requirement