proscenium 0.25.3 → 0.26.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 +4 -4
- data/README.md +170 -23
- data/exe/proscenium +19 -0
- data/exe/psm +5 -0
- data/lib/proscenium/app_package.rb +90 -0
- data/lib/proscenium/builder.rb +221 -20
- data/lib/proscenium/bundled_gems.rb +103 -0
- data/lib/proscenium/cli/brackets.rb +66 -0
- data/lib/proscenium/cli/bun_linker.rb +79 -0
- data/lib/proscenium/cli/capabilities.json +29 -0
- data/lib/proscenium/cli/collisions.rb +94 -0
- data/lib/proscenium/cli/contexts.rb +133 -0
- data/lib/proscenium/cli/diff.rb +80 -0
- data/lib/proscenium/cli/error.rb +291 -0
- data/lib/proscenium/cli/gem_archive.rb +44 -0
- data/lib/proscenium/cli/gem_check.rb +150 -0
- data/lib/proscenium/cli/gitignore.rb +63 -0
- data/lib/proscenium/cli/inspect.rb +257 -0
- data/lib/proscenium/cli/install.rb +378 -0
- data/lib/proscenium/cli/manager.rb +323 -0
- data/lib/proscenium/cli/platform_variants.rb +82 -0
- data/lib/proscenium/cli/pnpm_approvals.rb +109 -0
- data/lib/proscenium/cli/pnpm_workspace.rb +149 -0
- data/lib/proscenium/cli/project_lock.rb +106 -0
- data/lib/proscenium/cli/registration.rb +140 -0
- data/lib/proscenium/cli/reporter.rb +103 -0
- data/lib/proscenium/cli/rules.rb +169 -0
- data/lib/proscenium/cli/runner.rb +142 -0
- data/lib/proscenium/cli/verify.rb +107 -0
- data/lib/proscenium/cli.rb +122 -0
- data/lib/proscenium/context_map.rb +181 -0
- data/lib/proscenium/css_module/transformer.rb +18 -3
- data/lib/proscenium/css_module.rb +5 -6
- data/lib/proscenium/dependency_context.rb +74 -0
- data/lib/proscenium/error.rb +10 -0
- data/lib/proscenium/helper.rb +38 -4
- data/lib/proscenium/importer.rb +53 -42
- data/lib/proscenium/manifest.rb +18 -23
- data/lib/proscenium/mapping_generation.rb +64 -0
- data/lib/proscenium/middleware/base.rb +5 -10
- data/lib/proscenium/middleware/chunks.rb +5 -0
- data/lib/proscenium/monkey.rb +51 -69
- data/lib/proscenium/railtie.rb +16 -0
- data/lib/proscenium/railties/assets.rake +2 -1
- data/lib/proscenium/resolver.rb +43 -11
- data/lib/proscenium/runtime/bootstrap.js +26 -6
- data/lib/proscenium/runtime/server.rb +57 -36
- data/lib/proscenium/side_load.rb +75 -18
- data/lib/proscenium/stale_contexts.rb +118 -0
- data/lib/proscenium/templates/rescues/build_error.html.erb +9 -7
- data/lib/proscenium/utils.rb +55 -0
- data/lib/proscenium/version.rb +1 -1
- data/lib/proscenium/yaml_tree.rb +48 -0
- data/lib/proscenium.rb +7 -4
- metadata +42 -13
- data/lib/proscenium/ext/proscenium +0 -0
- data/lib/proscenium/ext/proscenium.h +0 -113
- data/lib/proscenium/react-manager/index.jsx +0 -102
- data/lib/proscenium/react-manager/react.js +0 -2
- data/lib/proscenium/react_componentable.rb +0 -94
metadata
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: proscenium
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.26.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Joel Moss
|
|
8
|
-
bindir:
|
|
8
|
+
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
@@ -29,7 +29,7 @@ dependencies:
|
|
|
29
29
|
requirements:
|
|
30
30
|
- - ">="
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: 7.
|
|
32
|
+
version: 7.2.0
|
|
33
33
|
- - "<"
|
|
34
34
|
- !ruby/object:Gem::Version
|
|
35
35
|
version: '9.0'
|
|
@@ -39,34 +39,64 @@ dependencies:
|
|
|
39
39
|
requirements:
|
|
40
40
|
- - ">="
|
|
41
41
|
- !ruby/object:Gem::Version
|
|
42
|
-
version: 7.
|
|
42
|
+
version: 7.2.0
|
|
43
43
|
- - "<"
|
|
44
44
|
- !ruby/object:Gem::Version
|
|
45
45
|
version: '9.0'
|
|
46
46
|
email:
|
|
47
47
|
- joel@developwithstyle.com
|
|
48
|
-
executables:
|
|
48
|
+
executables:
|
|
49
|
+
- proscenium
|
|
50
|
+
- psm
|
|
49
51
|
extensions: []
|
|
50
52
|
extra_rdoc_files: []
|
|
51
53
|
files:
|
|
52
54
|
- CODE_OF_CONDUCT.md
|
|
53
55
|
- LICENSE.txt
|
|
54
56
|
- README.md
|
|
57
|
+
- exe/proscenium
|
|
58
|
+
- exe/psm
|
|
55
59
|
- lib/generators/proscenium/bun/bun_generator.rb
|
|
56
60
|
- lib/generators/proscenium/bun/templates/proscenium.preload.js
|
|
57
61
|
- lib/proscenium.rb
|
|
62
|
+
- lib/proscenium/app_package.rb
|
|
58
63
|
- lib/proscenium/builder.rb
|
|
59
64
|
- lib/proscenium/bundled_gems.rb
|
|
65
|
+
- lib/proscenium/cli.rb
|
|
66
|
+
- lib/proscenium/cli/brackets.rb
|
|
67
|
+
- lib/proscenium/cli/bun_linker.rb
|
|
68
|
+
- lib/proscenium/cli/capabilities.json
|
|
69
|
+
- lib/proscenium/cli/collisions.rb
|
|
70
|
+
- lib/proscenium/cli/contexts.rb
|
|
71
|
+
- lib/proscenium/cli/diff.rb
|
|
72
|
+
- lib/proscenium/cli/error.rb
|
|
73
|
+
- lib/proscenium/cli/gem_archive.rb
|
|
74
|
+
- lib/proscenium/cli/gem_check.rb
|
|
75
|
+
- lib/proscenium/cli/gitignore.rb
|
|
76
|
+
- lib/proscenium/cli/inspect.rb
|
|
77
|
+
- lib/proscenium/cli/install.rb
|
|
78
|
+
- lib/proscenium/cli/manager.rb
|
|
79
|
+
- lib/proscenium/cli/platform_variants.rb
|
|
80
|
+
- lib/proscenium/cli/pnpm_approvals.rb
|
|
81
|
+
- lib/proscenium/cli/pnpm_workspace.rb
|
|
82
|
+
- lib/proscenium/cli/project_lock.rb
|
|
83
|
+
- lib/proscenium/cli/registration.rb
|
|
84
|
+
- lib/proscenium/cli/reporter.rb
|
|
85
|
+
- lib/proscenium/cli/rules.rb
|
|
86
|
+
- lib/proscenium/cli/runner.rb
|
|
87
|
+
- lib/proscenium/cli/verify.rb
|
|
88
|
+
- lib/proscenium/context_map.rb
|
|
60
89
|
- lib/proscenium/css_module.rb
|
|
61
90
|
- lib/proscenium/css_module/path.rb
|
|
62
91
|
- lib/proscenium/css_module/transformer.rb
|
|
92
|
+
- lib/proscenium/dependency_context.rb
|
|
63
93
|
- lib/proscenium/ensure_loaded.rb
|
|
64
|
-
- lib/proscenium/
|
|
65
|
-
- lib/proscenium/ext/proscenium.h
|
|
94
|
+
- lib/proscenium/error.rb
|
|
66
95
|
- lib/proscenium/helper.rb
|
|
67
96
|
- lib/proscenium/importer.rb
|
|
68
97
|
- lib/proscenium/log_subscriber.rb
|
|
69
98
|
- lib/proscenium/manifest.rb
|
|
99
|
+
- lib/proscenium/mapping_generation.rb
|
|
70
100
|
- lib/proscenium/middleware.rb
|
|
71
101
|
- lib/proscenium/middleware/base.rb
|
|
72
102
|
- lib/proscenium/middleware/chunks.rb
|
|
@@ -77,18 +107,17 @@ files:
|
|
|
77
107
|
- lib/proscenium/monkey.rb
|
|
78
108
|
- lib/proscenium/railtie.rb
|
|
79
109
|
- lib/proscenium/railties/assets.rake
|
|
80
|
-
- lib/proscenium/react-manager/index.jsx
|
|
81
|
-
- lib/proscenium/react-manager/react.js
|
|
82
|
-
- lib/proscenium/react_componentable.rb
|
|
83
110
|
- lib/proscenium/resolver.rb
|
|
84
111
|
- lib/proscenium/runtime/bootstrap.js
|
|
85
112
|
- lib/proscenium/runtime/bun.js
|
|
86
113
|
- lib/proscenium/runtime/server.rb
|
|
87
114
|
- lib/proscenium/side_load.rb
|
|
88
115
|
- lib/proscenium/source_path.rb
|
|
116
|
+
- lib/proscenium/stale_contexts.rb
|
|
89
117
|
- lib/proscenium/templates/rescues/build_error.html.erb
|
|
90
118
|
- lib/proscenium/utils.rb
|
|
91
119
|
- lib/proscenium/version.rb
|
|
120
|
+
- lib/proscenium/yaml_tree.rb
|
|
92
121
|
homepage: https://github.com/joelmoss/proscenium
|
|
93
122
|
licenses:
|
|
94
123
|
- MIT
|
|
@@ -104,14 +133,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
104
133
|
requirements:
|
|
105
134
|
- - ">="
|
|
106
135
|
- !ruby/object:Gem::Version
|
|
107
|
-
version: 3.
|
|
136
|
+
version: 3.4.0
|
|
108
137
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
138
|
requirements:
|
|
110
139
|
- - ">="
|
|
111
140
|
- !ruby/object:Gem::Version
|
|
112
|
-
version:
|
|
141
|
+
version: 3.3.22
|
|
113
142
|
requirements: []
|
|
114
|
-
rubygems_version:
|
|
143
|
+
rubygems_version: 3.6.9
|
|
115
144
|
specification_version: 4
|
|
116
145
|
summary: The engine powering your Rails frontend
|
|
117
146
|
test_files: []
|
|
Binary file
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
/* Code generated by cmd/cgo; DO NOT EDIT. */
|
|
2
|
-
|
|
3
|
-
/* package joelmoss/proscenium */
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
#line 1 "cgo-builtin-export-prolog"
|
|
7
|
-
|
|
8
|
-
#include <stddef.h>
|
|
9
|
-
|
|
10
|
-
#ifndef GO_CGO_EXPORT_PROLOGUE_H
|
|
11
|
-
#define GO_CGO_EXPORT_PROLOGUE_H
|
|
12
|
-
|
|
13
|
-
#ifndef GO_CGO_GOSTRING_TYPEDEF
|
|
14
|
-
typedef struct { const char *p; ptrdiff_t n; } _GoString_;
|
|
15
|
-
extern size_t _GoStringLen(_GoString_ s);
|
|
16
|
-
extern const char *_GoStringPtr(_GoString_ s);
|
|
17
|
-
#endif
|
|
18
|
-
|
|
19
|
-
#endif
|
|
20
|
-
|
|
21
|
-
/* Start of preamble from import "C" comments. */
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
#line 3 "main.go"
|
|
25
|
-
|
|
26
|
-
#include <stdlib.h>
|
|
27
|
-
|
|
28
|
-
struct Result {
|
|
29
|
-
int success;
|
|
30
|
-
char* response;
|
|
31
|
-
char* contentHash;
|
|
32
|
-
};
|
|
33
|
-
struct ResolveResult {
|
|
34
|
-
int success;
|
|
35
|
-
char* urlPath;
|
|
36
|
-
char* absPath;
|
|
37
|
-
};
|
|
38
|
-
struct CompileResult {
|
|
39
|
-
int success;
|
|
40
|
-
char* messages;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
#line 1 "cgo-generated-wrapper"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
/* End of preamble from import "C" comments. */
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
/* Start of boilerplate cgo prologue. */
|
|
50
|
-
#line 1 "cgo-gcc-export-header-prolog"
|
|
51
|
-
|
|
52
|
-
#ifndef GO_CGO_PROLOGUE_H
|
|
53
|
-
#define GO_CGO_PROLOGUE_H
|
|
54
|
-
|
|
55
|
-
typedef signed char GoInt8;
|
|
56
|
-
typedef unsigned char GoUint8;
|
|
57
|
-
typedef short GoInt16;
|
|
58
|
-
typedef unsigned short GoUint16;
|
|
59
|
-
typedef int GoInt32;
|
|
60
|
-
typedef unsigned int GoUint32;
|
|
61
|
-
typedef long long GoInt64;
|
|
62
|
-
typedef unsigned long long GoUint64;
|
|
63
|
-
typedef GoInt64 GoInt;
|
|
64
|
-
typedef GoUint64 GoUint;
|
|
65
|
-
typedef size_t GoUintptr;
|
|
66
|
-
typedef float GoFloat32;
|
|
67
|
-
typedef double GoFloat64;
|
|
68
|
-
#ifdef _MSC_VER
|
|
69
|
-
#if !defined(__cplusplus) || _MSVC_LANG <= 201402L
|
|
70
|
-
#include <complex.h>
|
|
71
|
-
typedef _Fcomplex GoComplex64;
|
|
72
|
-
typedef _Dcomplex GoComplex128;
|
|
73
|
-
#else
|
|
74
|
-
#include <complex>
|
|
75
|
-
typedef std::complex<float> GoComplex64;
|
|
76
|
-
typedef std::complex<double> GoComplex128;
|
|
77
|
-
#endif
|
|
78
|
-
#else
|
|
79
|
-
typedef float _Complex GoComplex64;
|
|
80
|
-
typedef double _Complex GoComplex128;
|
|
81
|
-
#endif
|
|
82
|
-
|
|
83
|
-
/*
|
|
84
|
-
static assertion to make sure the file is being used on architecture
|
|
85
|
-
at least with matching size of GoInt.
|
|
86
|
-
*/
|
|
87
|
-
typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1];
|
|
88
|
-
|
|
89
|
-
#ifndef GO_CGO_GOSTRING_TYPEDEF
|
|
90
|
-
typedef _GoString_ GoString;
|
|
91
|
-
#endif
|
|
92
|
-
typedef void *GoMap;
|
|
93
|
-
typedef void *GoChan;
|
|
94
|
-
typedef struct { void *t; void *v; } GoInterface;
|
|
95
|
-
typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;
|
|
96
|
-
|
|
97
|
-
#endif
|
|
98
|
-
|
|
99
|
-
/* End of boilerplate cgo prologue. */
|
|
100
|
-
|
|
101
|
-
#ifdef __cplusplus
|
|
102
|
-
extern "C" {
|
|
103
|
-
#endif
|
|
104
|
-
|
|
105
|
-
extern void reset_config(void);
|
|
106
|
-
extern void free_cstr(char* ptr);
|
|
107
|
-
extern struct Result build_to_string(char* filePath, char* configJson);
|
|
108
|
-
extern struct ResolveResult resolve(char* filePath, char* configJson);
|
|
109
|
-
extern struct CompileResult compile(char* configJson);
|
|
110
|
-
|
|
111
|
-
#ifdef __cplusplus
|
|
112
|
-
}
|
|
113
|
-
#endif
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
const pathAttribute = "data-proscenium-component-path";
|
|
2
|
-
|
|
3
|
-
// Find components already in the DOM.
|
|
4
|
-
const elements = document.querySelectorAll(`[${pathAttribute}]`);
|
|
5
|
-
elements.length > 0 && init(elements);
|
|
6
|
-
|
|
7
|
-
new MutationObserver((mutationsList) => {
|
|
8
|
-
for (const { addedNodes } of mutationsList) {
|
|
9
|
-
for (const ele of addedNodes) {
|
|
10
|
-
if (ele.matches(`[${pathAttribute}]`)) {
|
|
11
|
-
init([ele]);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}).observe(document, {
|
|
16
|
-
subtree: true,
|
|
17
|
-
childList: true,
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
function init(elements) {
|
|
21
|
-
Array.from(elements, (element) => {
|
|
22
|
-
const path = element.dataset.prosceniumComponentPath;
|
|
23
|
-
const isLazy = "prosceniumComponentLazy" in element.dataset;
|
|
24
|
-
const props = JSON.parse(element.dataset.prosceniumComponentProps);
|
|
25
|
-
|
|
26
|
-
if (proscenium.env.RAILS_ENV === "development") {
|
|
27
|
-
console.groupCollapsed(
|
|
28
|
-
`[proscenium/react/manager] ${isLazy ? "💤" : "⚡️"} %o`,
|
|
29
|
-
path
|
|
30
|
-
);
|
|
31
|
-
console.log("element: %o", element);
|
|
32
|
-
console.log("props: %o", props);
|
|
33
|
-
console.groupEnd();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (isLazy) {
|
|
37
|
-
const observer = new IntersectionObserver((entries) => {
|
|
38
|
-
entries.forEach((entry) => {
|
|
39
|
-
if (entry.isIntersecting) {
|
|
40
|
-
observer.unobserve(element);
|
|
41
|
-
|
|
42
|
-
mount(element, path, props);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
observer.observe(element);
|
|
48
|
-
} else {
|
|
49
|
-
mount(element, path, props);
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Mounts component located at `path`, into the DOM `element`.
|
|
55
|
-
*
|
|
56
|
-
* The element at which the component is mounted must have the following data attributes:
|
|
57
|
-
*
|
|
58
|
-
* - `data-proscenium-component-path`: The URL path to the component's source file.
|
|
59
|
-
* - `data-proscenium-component-props`: JSON object of props to pass to the component.
|
|
60
|
-
* - `data-proscenium-component-lazy`: If present, will lazily load the component when in view
|
|
61
|
-
* using IntersectionObserver.
|
|
62
|
-
* - `data-proscenium-component-forward-children`: If the element should forward its `innerHTML`
|
|
63
|
-
* as the component's children prop.
|
|
64
|
-
*/
|
|
65
|
-
function mount(element, path, { children, ...props }) {
|
|
66
|
-
// For testing and simulation of slow connections.
|
|
67
|
-
// const sim = new Promise((resolve) => setTimeout(resolve, 5000));
|
|
68
|
-
|
|
69
|
-
const react = import("@rubygems/proscenium/react-manager/react");
|
|
70
|
-
const Component = import(path);
|
|
71
|
-
|
|
72
|
-
const forwardChildren =
|
|
73
|
-
"prosceniumComponentForwardChildren" in element.dataset &&
|
|
74
|
-
element.innerHTML !== "";
|
|
75
|
-
|
|
76
|
-
Promise.all([react, Component])
|
|
77
|
-
.then(([r, c]) => {
|
|
78
|
-
if (proscenium.env.RAILS_ENV === "development") {
|
|
79
|
-
console.groupCollapsed(
|
|
80
|
-
`[proscenium/react/manager] 🔥 %o mounted!`,
|
|
81
|
-
path
|
|
82
|
-
);
|
|
83
|
-
console.log("props: %o", props);
|
|
84
|
-
console.groupEnd();
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
let component;
|
|
88
|
-
if (forwardChildren) {
|
|
89
|
-
component = r.createElement(c.default, props, element.innerHTML);
|
|
90
|
-
} else if (children) {
|
|
91
|
-
component = r.createElement(c.default, props, children);
|
|
92
|
-
} else {
|
|
93
|
-
component = r.createElement(c.default, props);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
r.createRoot(element).render(component);
|
|
97
|
-
})
|
|
98
|
-
.catch((error) => {
|
|
99
|
-
console.error("[proscenium/react/manager] %o - %o", path, error);
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Proscenium
|
|
4
|
-
module ReactComponentable
|
|
5
|
-
extend ActiveSupport::Concern
|
|
6
|
-
|
|
7
|
-
included do
|
|
8
|
-
# @return [Hash] the props to pass to the React component.
|
|
9
|
-
attr_writer :props
|
|
10
|
-
|
|
11
|
-
# The HTML tag to use as the wrapping element for the component. You can reassign this in your
|
|
12
|
-
# component class to use a different tag:
|
|
13
|
-
#
|
|
14
|
-
# class MyComponent < Proscenium::ReactComponent
|
|
15
|
-
# self.root_tag = :span
|
|
16
|
-
# end
|
|
17
|
-
#
|
|
18
|
-
# @return [Symbol]
|
|
19
|
-
class_attribute :root_tag, instance_predicate: false, default: :div
|
|
20
|
-
|
|
21
|
-
# By default, the template block (content) of the component will be server rendered as normal.
|
|
22
|
-
# However, when React hydrates and takes control of the component, it's content will be
|
|
23
|
-
# replaced by React with the JavaScript rendered content. Enabling this option will forward
|
|
24
|
-
# the server rendered content as the `children` prop passed to the React component.
|
|
25
|
-
#
|
|
26
|
-
# @example
|
|
27
|
-
#
|
|
28
|
-
# const Component = ({ children }) => {
|
|
29
|
-
# return <div dangerouslySetInnerHTML={{ __html: children }} />
|
|
30
|
-
# }
|
|
31
|
-
#
|
|
32
|
-
# @return [Boolean]
|
|
33
|
-
class_attribute :forward_children, default: false
|
|
34
|
-
|
|
35
|
-
# Lazy load the component using IntersectionObserver?
|
|
36
|
-
#
|
|
37
|
-
# @return [Boolean]
|
|
38
|
-
class_attribute :lazy, default: false
|
|
39
|
-
|
|
40
|
-
class_attribute :loader
|
|
41
|
-
|
|
42
|
-
# @return [String] the URL path to the component manager.
|
|
43
|
-
class_attribute :manager, default: '/proscenium/react-manager/index.jsx'
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
class_methods do
|
|
47
|
-
def sideload(options)
|
|
48
|
-
Importer.import manager.to_s, sideloaded: true, **options, js: { type: 'module' }
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
# @param props: [Hash]
|
|
53
|
-
def initialize(lazy: self.class.lazy, loader: self.class.loader, props: {})
|
|
54
|
-
self.lazy = lazy
|
|
55
|
-
self.loader = loader
|
|
56
|
-
@props = props
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
# The absolute URL path to the javascript component.
|
|
60
|
-
def virtual_path
|
|
61
|
-
@virtual_path ||= Array(Resolver.resolve(self.class.source_path.sub_ext('.jsx').to_s))[0]
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
def props
|
|
65
|
-
@props ||= {}
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
private
|
|
69
|
-
|
|
70
|
-
def data_attributes
|
|
71
|
-
{
|
|
72
|
-
proscenium_component_path: Pathname.new(virtual_path).to_s,
|
|
73
|
-
proscenium_component_props: prepared_props,
|
|
74
|
-
proscenium_component_lazy: lazy
|
|
75
|
-
}.tap do |x|
|
|
76
|
-
x[:proscenium_component_forward_children] = true if forward_children?
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
def prepared_props
|
|
81
|
-
props.deep_transform_keys do |term|
|
|
82
|
-
# This ensures that the first letter after a slash is not capitalized.
|
|
83
|
-
string = term.to_s.split('/').map { |str| str.camelize :lower }.join('/')
|
|
84
|
-
|
|
85
|
-
# Reverses the effect of ActiveSupport::Inflector.camelize converting slashes into `::`.
|
|
86
|
-
string.gsub '::', '/'
|
|
87
|
-
end.to_json
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
def loader_component
|
|
91
|
-
render Loader::Component.new(loader, @html_class, data_attributes, tag: @html_tag)
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
end
|