superglue 2.0.0.beta.3 → 2.0.0.rc.1
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/app/views/application/_humid.html.erb +1 -0
- data/lib/generators/superglue/install/install_generator.rb +222 -82
- data/lib/generators/superglue/install/templates/bun/bun.config.deepkit.js +5 -7
- data/lib/generators/superglue/install/templates/bun/bun.config.js +5 -7
- data/lib/generators/superglue/install/templates/bun/bun.config.ts.js +5 -7
- data/lib/generators/superglue/install/templates/bun/bun.config.typia.js +37 -0
- data/lib/generators/superglue/install/templates/bun/page_to_page_mapping.js +1 -1
- data/lib/generators/superglue/install/templates/bun/page_to_page_mapping.ts +1 -1
- data/lib/generators/superglue/install/templates/humid_initializer.rb +47 -0
- data/lib/generators/superglue/install/templates/js/application.jsx +8 -3
- data/lib/generators/superglue/install/templates/js/build.mjs +14 -3
- data/lib/generators/superglue/install/templates/js/page_to_page_mapping.js +9 -32
- data/lib/generators/superglue/install/templates/rollup/page_to_page_mapping.js +1 -1
- data/lib/generators/superglue/install/templates/rollup/page_to_page_mapping.ts +1 -1
- data/lib/generators/superglue/install/templates/rollup/rollup.config.deepkit.js +1 -1
- data/lib/generators/superglue/install/templates/rollup/rollup.config.js +2 -2
- data/lib/generators/superglue/install/templates/rollup/rollup.config.ts.js +2 -2
- data/lib/generators/superglue/install/templates/rollup/rollup.config.typia.js +38 -0
- data/lib/generators/superglue/install/templates/ssr/bun.build_ssr.js +37 -0
- data/lib/generators/superglue/install/templates/ssr/esbuild.build_ssr.mjs +37 -0
- data/lib/generators/superglue/install/templates/ssr/rollup.build_ssr.config.js +42 -0
- data/lib/generators/superglue/install/templates/ssr/server_rendering.jsx +22 -0
- data/lib/generators/superglue/install/templates/ssr/server_rendering.tsx +26 -0
- data/lib/generators/superglue/install/templates/ssr/shim.js +8490 -0
- data/lib/generators/superglue/install/templates/ssr/webpack.build_ssr.js +40 -0
- data/lib/generators/superglue/install/templates/ts/application.tsx +9 -4
- data/lib/generators/superglue/install/templates/ts/build.deepkit.mjs +13 -2
- data/lib/generators/superglue/install/templates/ts/build.mjs +14 -3
- data/lib/generators/superglue/install/templates/ts/build.typia.mjs +39 -0
- data/lib/generators/superglue/install/templates/ts/page_to_page_mapping.ts +11 -33
- data/lib/generators/superglue/install/templates/ts/tsconfig.json +1 -0
- data/lib/generators/superglue/install/templates/webpack/page_to_page_mapping.js +1 -1
- data/lib/generators/superglue/install/templates/webpack/page_to_page_mapping.ts +1 -1
- data/lib/generators/superglue/install/templates/webpack/webpack.config.typia.js +42 -0
- data/lib/generators/superglue/scaffold_controller/scaffold_controller_generator.rb +0 -3
- data/lib/generators/superglue/view_collection/view_collection_generator.rb +5 -3
- data/lib/superglue/engine.rb +25 -4
- data/lib/superglue/rendering.rb +8 -69
- data/lib/superglue.rb +1 -1
- metadata +38 -13
- data/lib/generators/superglue/install/templates/erb/superglue.html.erb +0 -5
- data/lib/superglue/resolver.rb +0 -58
- /data/lib/generators/superglue/view_collection/templates/js/{edit.jsx → edit.html.jsx} +0 -0
- /data/lib/generators/superglue/view_collection/templates/js/{index.jsx → index.html.jsx} +0 -0
- /data/lib/generators/superglue/view_collection/templates/js/{new.jsx → new.html.jsx} +0 -0
- /data/lib/generators/superglue/view_collection/templates/js/{show.jsx → show.html.jsx} +0 -0
- /data/lib/generators/superglue/view_collection/templates/ts/{edit.tsx → edit.html.tsx} +0 -0
- /data/lib/generators/superglue/view_collection/templates/ts/{index.tsx → index.html.tsx} +0 -0
- /data/lib/generators/superglue/view_collection/templates/ts/{new.tsx → new.html.tsx} +0 -0
- /data/lib/generators/superglue/view_collection/templates/ts/{show.tsx → show.html.tsx} +0 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const path = require("path")
|
|
2
|
+
const webpack = require("webpack")
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
mode: "production",
|
|
6
|
+
devtool: "source-map",
|
|
7
|
+
target: "web",
|
|
8
|
+
entry: {
|
|
9
|
+
server_rendering: ["./app/javascript/server_rendering.jsx"]
|
|
10
|
+
},
|
|
11
|
+
module: {
|
|
12
|
+
rules: [
|
|
13
|
+
{
|
|
14
|
+
test: /\.[jt]sx?$/,
|
|
15
|
+
exclude: /node_modules/,
|
|
16
|
+
loader: "esbuild-loader",
|
|
17
|
+
options: {
|
|
18
|
+
target: "es2020"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
resolve: {
|
|
24
|
+
extensions: [".tsx", ".ts", ".jsx", ".js", ".json"],
|
|
25
|
+
alias: {
|
|
26
|
+
"@javascript": path.resolve(__dirname, "app/javascript"),
|
|
27
|
+
"@views": path.resolve(__dirname, "app/views")
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
output: {
|
|
31
|
+
filename: "[name].js",
|
|
32
|
+
sourceMapFilename: "[file].map",
|
|
33
|
+
path: path.resolve(__dirname, "app/assets/builds"),
|
|
34
|
+
},
|
|
35
|
+
plugins: [
|
|
36
|
+
new webpack.optimize.LimitChunkCountPlugin({
|
|
37
|
+
maxChunks: 1
|
|
38
|
+
})
|
|
39
|
+
]
|
|
40
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { createRoot } from "react-dom/client";
|
|
2
|
+
import { createRoot, hydrateRoot } from "react-dom/client";
|
|
3
3
|
import { createApp, SaveResponse } from "@thoughtbot/superglue";
|
|
4
4
|
import { buildVisitAndRemote } from "./application_visit";
|
|
5
5
|
import { pageIdentifierToPageComponent } from "./page_to_page_mapping";
|
|
@@ -31,16 +31,21 @@ if (typeof window !== "undefined" && window.SUPERGLUE_INITIAL_PAGE_STATE) {
|
|
|
31
31
|
mapping: pageIdentifierToPageComponent,
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
-
const
|
|
35
|
-
root.render(
|
|
34
|
+
const app = (
|
|
36
35
|
<div onClick={ujs.onClick} onSubmit={ujs.onSubmit}>
|
|
37
36
|
<Provider>
|
|
38
37
|
<Layout>
|
|
39
38
|
<Outlet />
|
|
40
39
|
</Layout>
|
|
41
40
|
</Provider>
|
|
42
|
-
</div
|
|
41
|
+
</div>
|
|
43
42
|
);
|
|
43
|
+
|
|
44
|
+
if (appEl.hasChildNodes()) {
|
|
45
|
+
hydrateRoot(appEl, app);
|
|
46
|
+
} else {
|
|
47
|
+
createRoot(appEl).render(app);
|
|
48
|
+
}
|
|
44
49
|
}
|
|
45
50
|
});
|
|
46
51
|
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import * as esbuild from 'esbuild'
|
|
2
|
+
import { watch } from 'fs'
|
|
3
|
+
import { default as importGlob } from 'esbuild-plugin-import-glob'
|
|
4
|
+
const importGlobPlugin = importGlob.default
|
|
2
5
|
import { esbuild as deepkitPlugin } from '@thoughtbot/superglue/deepkit'
|
|
3
6
|
|
|
4
7
|
const isWatch = process.argv.includes('--watch')
|
|
@@ -12,15 +15,23 @@ const buildOptions = {
|
|
|
12
15
|
format: 'esm',
|
|
13
16
|
outdir: 'app/assets/builds',
|
|
14
17
|
publicPath: '/assets',
|
|
15
|
-
plugins: process.env.NODE_ENV === 'production' ? [] : [deepkitPlugin()],
|
|
18
|
+
plugins: process.env.NODE_ENV === 'production' ? [importGlobPlugin()] : [importGlobPlugin(), deepkitPlugin()],
|
|
16
19
|
metafile: true,
|
|
17
20
|
conditions: process.env.NODE_ENV === 'production' ? ['production'] : [],
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
if (isWatch) {
|
|
21
|
-
|
|
24
|
+
let ctx = await esbuild.context(buildOptions)
|
|
22
25
|
await ctx.watch()
|
|
23
26
|
console.log('Watching for changes...')
|
|
27
|
+
|
|
28
|
+
watch('app/views', { recursive: true }, async (event, filename) => {
|
|
29
|
+
if (event === 'rename' && /\.[jt]sx$/.test(filename)) {
|
|
30
|
+
await ctx.dispose()
|
|
31
|
+
ctx = await esbuild.context(buildOptions)
|
|
32
|
+
await ctx.watch()
|
|
33
|
+
}
|
|
34
|
+
})
|
|
24
35
|
} else {
|
|
25
36
|
const result = await esbuild.build(buildOptions)
|
|
26
37
|
console.log(await esbuild.analyzeMetafile(result.metafile))
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import * as esbuild from 'esbuild'
|
|
2
|
+
import { watch } from 'fs'
|
|
3
|
+
import { default as importGlob } from 'esbuild-plugin-import-glob'
|
|
4
|
+
const importGlobPlugin = importGlob.default
|
|
2
5
|
|
|
3
6
|
const isWatch = process.argv.includes('--watch')
|
|
4
7
|
|
|
@@ -11,16 +14,24 @@ const buildOptions = {
|
|
|
11
14
|
format: 'esm',
|
|
12
15
|
outdir: 'app/assets/builds',
|
|
13
16
|
publicPath: '/assets',
|
|
14
|
-
plugins: [],
|
|
17
|
+
plugins: [importGlobPlugin()],
|
|
15
18
|
metafile: true,
|
|
16
19
|
conditions: process.env.NODE_ENV === 'production' ? ['production'] : [],
|
|
17
20
|
}
|
|
18
21
|
|
|
19
22
|
if (isWatch) {
|
|
20
|
-
|
|
23
|
+
let ctx = await esbuild.context(buildOptions)
|
|
21
24
|
await ctx.watch()
|
|
22
25
|
console.log('Watching for changes...')
|
|
26
|
+
|
|
27
|
+
watch('app/views', { recursive: true }, async (event, filename) => {
|
|
28
|
+
if (event === 'rename' && /\.[jt]sx$/.test(filename)) {
|
|
29
|
+
await ctx.dispose()
|
|
30
|
+
ctx = await esbuild.context(buildOptions)
|
|
31
|
+
await ctx.watch()
|
|
32
|
+
}
|
|
33
|
+
})
|
|
23
34
|
} else {
|
|
24
35
|
const result = await esbuild.build(buildOptions)
|
|
25
36
|
console.log(await esbuild.analyzeMetafile(result.metafile))
|
|
26
|
-
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as esbuild from 'esbuild'
|
|
2
|
+
import { watch } from 'fs'
|
|
3
|
+
import { default as importGlob } from 'esbuild-plugin-import-glob'
|
|
4
|
+
const importGlobPlugin = importGlob.default
|
|
5
|
+
import ttsc from '@ttsc/unplugin'
|
|
6
|
+
const ttscPlugin = ttsc.esbuild
|
|
7
|
+
|
|
8
|
+
const isWatch = process.argv.includes('--watch')
|
|
9
|
+
|
|
10
|
+
const buildOptions = {
|
|
11
|
+
entryPoints: [
|
|
12
|
+
'app/javascript/application.tsx',
|
|
13
|
+
],
|
|
14
|
+
bundle: true,
|
|
15
|
+
sourcemap: true,
|
|
16
|
+
format: 'esm',
|
|
17
|
+
outdir: 'app/assets/builds',
|
|
18
|
+
publicPath: '/assets',
|
|
19
|
+
plugins: process.env.NODE_ENV === 'production' ? [importGlobPlugin()] : [importGlobPlugin(), ttscPlugin()],
|
|
20
|
+
metafile: true,
|
|
21
|
+
conditions: process.env.NODE_ENV === 'production' ? ['production'] : [],
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (isWatch) {
|
|
25
|
+
let ctx = await esbuild.context(buildOptions)
|
|
26
|
+
await ctx.watch()
|
|
27
|
+
console.log('Watching for changes...')
|
|
28
|
+
|
|
29
|
+
watch('app/views', { recursive: true }, async (event, filename) => {
|
|
30
|
+
if (event === 'rename' && /\.[jt]sx$/.test(filename)) {
|
|
31
|
+
await ctx.dispose()
|
|
32
|
+
ctx = await esbuild.context(buildOptions)
|
|
33
|
+
await ctx.watch()
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
} else {
|
|
37
|
+
const result = await esbuild.build(buildOptions)
|
|
38
|
+
console.log(await esbuild.analyzeMetafile(result.metafile))
|
|
39
|
+
}
|
|
@@ -1,35 +1,13 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import * as pages from '../views/**/*.{tsx,jsx}'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
// to register any new page level component you create. If you are using the
|
|
6
|
-
// scaffold, it will auto append the identifers for you.
|
|
7
|
-
//
|
|
8
|
-
// For example:
|
|
9
|
-
//
|
|
10
|
-
// const pageIdentifierToPageComponent = {
|
|
11
|
-
// 'posts/new': PostNew
|
|
12
|
-
// };
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
// If you are using a build tool that supports globbing, you can automatically
|
|
16
|
-
// populate `pageIdentiferToPageComponent`. For example, if you are using vite,
|
|
17
|
-
// you can use the following snippet instead of manually importing.
|
|
18
|
-
//
|
|
19
|
-
// ```
|
|
20
|
-
// const pageIdentifierToPageComponent = {}
|
|
21
|
-
// const pages = import.meta.glob('../views/**/*.tsx', {eager: true})
|
|
22
|
-
//
|
|
23
|
-
// for (const key in pages) {
|
|
24
|
-
// if (pages.hasOwnProperty(key)) {
|
|
25
|
-
// const identifier = key.replace("../views/", "").split('.')[0];
|
|
26
|
-
// pageIdentifierToPageComponent[identifier] = pages[key].default;
|
|
27
|
-
// }
|
|
28
|
-
// }
|
|
29
|
-
// ```
|
|
30
|
-
//
|
|
31
|
-
const pageIdentifierToPageComponent = {
|
|
32
|
-
// Add your mappings here
|
|
33
|
-
};
|
|
4
|
+
const pageIdentifierToPageComponent: Record<string, React.ComponentType> = {}
|
|
34
5
|
|
|
35
|
-
|
|
6
|
+
for (let i = 0; i < pages.filenames.length; i++) {
|
|
7
|
+
const identifier = pages.filenames[i]
|
|
8
|
+
.replace('../views/', '')
|
|
9
|
+
.split('.')[0]
|
|
10
|
+
pageIdentifierToPageComponent[identifier] = pages.default[i].default
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { pageIdentifierToPageComponent }
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const pageIdentifierToPageComponent: Record<string, React.ComponentType> = {}
|
|
2
|
-
const context = require.context('../views', true, /\.
|
|
2
|
+
const context = require.context('../views', true, /\.[jt]sx$/)
|
|
3
3
|
|
|
4
4
|
context.keys().forEach((key: string) => {
|
|
5
5
|
const identifier = key.replace('./', '').split('.')[0]
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const path = require("path")
|
|
2
|
+
const webpack = require("webpack")
|
|
3
|
+
const ttscPlugin = require("@ttsc/unplugin").default.webpack
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
mode: "production",
|
|
7
|
+
devtool: "source-map",
|
|
8
|
+
entry: {
|
|
9
|
+
application: "./app/javascript/application.tsx"
|
|
10
|
+
},
|
|
11
|
+
module: {
|
|
12
|
+
rules: [
|
|
13
|
+
{
|
|
14
|
+
test: /\.[jt]sx?$/,
|
|
15
|
+
exclude: /node_modules/,
|
|
16
|
+
loader: "esbuild-loader",
|
|
17
|
+
options: {
|
|
18
|
+
target: "es2020"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
resolve: {
|
|
24
|
+
extensions: [".tsx", ".ts", ".jsx", ".js", ".json", ".wasm"],
|
|
25
|
+
alias: {
|
|
26
|
+
"@javascript": path.resolve(__dirname, "app/javascript"),
|
|
27
|
+
"@views": path.resolve(__dirname, "app/views")
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
output: {
|
|
31
|
+
filename: "[name].js",
|
|
32
|
+
sourceMapFilename: "[file].map",
|
|
33
|
+
chunkFormat: "module",
|
|
34
|
+
path: path.resolve(__dirname, "app/assets/builds"),
|
|
35
|
+
},
|
|
36
|
+
plugins: [
|
|
37
|
+
new webpack.optimize.LimitChunkCountPlugin({
|
|
38
|
+
maxChunks: 1
|
|
39
|
+
}),
|
|
40
|
+
...(process.env.NODE_ENV === 'production' ? [] : [ttscPlugin()])
|
|
41
|
+
]
|
|
42
|
+
}
|
|
@@ -27,9 +27,6 @@ module Superglue
|
|
|
27
27
|
def create_controller_files
|
|
28
28
|
controller_file = File.join("app/controllers", controller_class_path, "#{controller_file_name}_controller.rb")
|
|
29
29
|
template "controller.rb", controller_file
|
|
30
|
-
inject_into_file controller_file, after: /ApplicationController$/ do
|
|
31
|
-
"\n before_action :use_jsx_rendering_defaults"
|
|
32
|
-
end
|
|
33
30
|
end
|
|
34
31
|
|
|
35
32
|
# Replaces template_engine (and its default erb), with view_collection
|
|
@@ -54,9 +54,11 @@ module Superglue
|
|
|
54
54
|
|
|
55
55
|
component_name = [plural_table_name, action].map(&:camelcase).join
|
|
56
56
|
|
|
57
|
+
js_ext = options["typescript"] ? "html.tsx" : "html.jsx"
|
|
58
|
+
|
|
57
59
|
if match_file(app_js, /pageIdentifierToPageComponent = {$/)
|
|
58
60
|
prepend_to_file app_js do
|
|
59
|
-
"import #{component_name} from '#{view_path}/#{controller_file_path}/#{action}'\n"
|
|
61
|
+
"import #{component_name} from '#{view_path}/#{controller_file_path}/#{action}.#{js_ext}'\n"
|
|
60
62
|
end
|
|
61
63
|
|
|
62
64
|
inject_into_file app_js, after: /pageIdentifierToPageComponent = {$/ do
|
|
@@ -141,11 +143,11 @@ module Superglue
|
|
|
141
143
|
end
|
|
142
144
|
|
|
143
145
|
def filename_with_jsx_extensions(name)
|
|
144
|
-
[name, :jsx].join(".")
|
|
146
|
+
[name, :html, :jsx].join(".")
|
|
145
147
|
end
|
|
146
148
|
|
|
147
149
|
def filename_with_tsx_extensions(name)
|
|
148
|
-
[name, :tsx].join(".")
|
|
150
|
+
[name, :html, :tsx].join(".")
|
|
149
151
|
end
|
|
150
152
|
|
|
151
153
|
def filename_with_html_extensions(name)
|
data/lib/superglue/engine.rb
CHANGED
|
@@ -41,13 +41,34 @@ module Superglue
|
|
|
41
41
|
next if self != ActionController::Base
|
|
42
42
|
|
|
43
43
|
include Controller
|
|
44
|
-
|
|
45
|
-
prepend_view_path(
|
|
46
|
-
Superglue::Resolver.new(Rails.root.join("app/views"))
|
|
47
|
-
)
|
|
48
44
|
end
|
|
49
45
|
end
|
|
50
46
|
|
|
47
|
+
initializer "superglue.template_handlers" do
|
|
48
|
+
handler = ->(template, source) {
|
|
49
|
+
if template.format == :html
|
|
50
|
+
<<~RUBY
|
|
51
|
+
controller.instance_variable_set(:@_active_template_virtual_path, "#{template.virtual_path}")
|
|
52
|
+
ctx = controller._ssr_context_block&.call
|
|
53
|
+
if ctx
|
|
54
|
+
controller.response.set_header("X-Superglue-SSR", "1")
|
|
55
|
+
render(partial: "humid", locals: { ssr_context: ctx }).strip.html_safe
|
|
56
|
+
else
|
|
57
|
+
if Rails.env.local?
|
|
58
|
+
Rails.logger.warn "[Superglue] #{template.virtual_path}.html.#{template.handler} rendered without SSR. Set ssr_context in your controller to enable it."
|
|
59
|
+
end
|
|
60
|
+
""
|
|
61
|
+
end
|
|
62
|
+
RUBY
|
|
63
|
+
else
|
|
64
|
+
"''"
|
|
65
|
+
end
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
ActionView::Template.register_template_handler :tsx, handler
|
|
69
|
+
ActionView::Template.register_template_handler :jsx, handler
|
|
70
|
+
end
|
|
71
|
+
|
|
51
72
|
initializer "superglue.helpers" do
|
|
52
73
|
ActiveSupport.on_load(:action_controller) do
|
|
53
74
|
helper Superglue::StreamsHelper
|
data/lib/superglue/rendering.rb
CHANGED
|
@@ -2,92 +2,31 @@ require "active_support/concern"
|
|
|
2
2
|
|
|
3
3
|
module Superglue
|
|
4
4
|
module Rendering
|
|
5
|
-
class UnsupportedOption < StandardError; end
|
|
6
|
-
|
|
7
5
|
extend ActiveSupport::Concern
|
|
8
6
|
|
|
9
7
|
included do |base|
|
|
10
|
-
base.class_attribute :
|
|
8
|
+
base.class_attribute :_ssr_context_block, instance_accessor: true, default: nil
|
|
11
9
|
end
|
|
12
10
|
|
|
13
11
|
class_methods do
|
|
14
|
-
def
|
|
15
|
-
self.
|
|
12
|
+
def ssr_context(&block)
|
|
13
|
+
self._ssr_context_block = block
|
|
16
14
|
end
|
|
17
15
|
end
|
|
18
16
|
|
|
19
|
-
def
|
|
20
|
-
if
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if options.keys.intersect? [:file, :partial, :body, :plain, :html, :inline]
|
|
24
|
-
raise UnsupportedOption.new("`template:` and `action:` are the only options supported with `use_jsx_rendering_defaults`")
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
@_render_options = options
|
|
28
|
-
_ensure_react_page!(options[:template], options[:prefixes]) if request.format.html?
|
|
29
|
-
|
|
30
|
-
target_template_exists = template_exists?(options[:template], options[:prefixes], false)
|
|
31
|
-
|
|
32
|
-
if request.format.html? && !target_template_exists
|
|
33
|
-
# this uses the default superglue html template, which is super basic so
|
|
34
|
-
# we don't' need to create a separate one for each view
|
|
35
|
-
super(options.merge(
|
|
36
|
-
template: _superglue_template,
|
|
37
|
-
prefixes: []
|
|
38
|
-
))
|
|
39
|
-
elsif request.format.json? && !target_template_exists
|
|
40
|
-
# This fixes an issue with rendering json direclty but teh template doesn't exist
|
|
41
|
-
# we still want ot see the layout rendered
|
|
42
|
-
super(options.merge(
|
|
43
|
-
inline: "",
|
|
44
|
-
layout: _layout_for_option(true)
|
|
45
|
-
))
|
|
46
|
-
else
|
|
47
|
-
super
|
|
48
|
-
end
|
|
17
|
+
def default_render
|
|
18
|
+
if request.format.json? && !template_exists?(action_name, _prefixes, false)
|
|
19
|
+
render inline: "", layout: true
|
|
49
20
|
else
|
|
50
21
|
super
|
|
51
22
|
end
|
|
52
23
|
end
|
|
53
24
|
|
|
54
|
-
def
|
|
55
|
-
|
|
56
|
-
@_capture_options_before_render = true
|
|
57
|
-
end
|
|
58
|
-
|
|
25
|
+
def _render_template(options = {})
|
|
26
|
+
@_render_options ||= options
|
|
59
27
|
super
|
|
60
28
|
end
|
|
61
29
|
|
|
62
|
-
def use_jsx_rendering_defaults
|
|
63
|
-
@_use_jsx_rendering_defaults = true
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def _jsx_defaults
|
|
67
|
-
@_use_jsx_rendering_defaults && (request.format.html? || request.format.json?)
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
def _props_defaults
|
|
71
|
-
@_use_jsx_rendering_defaults && request.format.json?
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
def _ensure_react_page!(template, prefixes)
|
|
75
|
-
found_template = lookup_context.find(template, prefixes, false, [], formats: [], handlers: [], variants: [], locale: [])
|
|
76
|
-
## This variable was created for props_template to pick up
|
|
77
|
-
@_active_template_virtual_path = found_template.virtual_path
|
|
78
|
-
found_template
|
|
79
|
-
rescue ActionView::MissingTemplate => e
|
|
80
|
-
raise ActionView::MissingTemplate.new(e.paths, e.path, e.prefixes, e.partial, "extension JSX or TSX")
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
def default_render
|
|
84
|
-
if _jsx_defaults
|
|
85
|
-
render
|
|
86
|
-
else
|
|
87
|
-
super
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
|
|
91
30
|
def render_props
|
|
92
31
|
if @_render_options
|
|
93
32
|
options = @_render_options
|
data/lib/superglue.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: superglue
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0.0.
|
|
4
|
+
version: 2.0.0.rc.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Johny Ho
|
|
@@ -15,7 +15,7 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - ">="
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: '
|
|
18
|
+
version: '8.0'
|
|
19
19
|
- - "<"
|
|
20
20
|
- !ruby/object:Gem::Version
|
|
21
21
|
version: '9.0'
|
|
@@ -25,7 +25,7 @@ dependencies:
|
|
|
25
25
|
requirements:
|
|
26
26
|
- - ">="
|
|
27
27
|
- !ruby/object:Gem::Version
|
|
28
|
-
version: '
|
|
28
|
+
version: '8.0'
|
|
29
29
|
- - "<"
|
|
30
30
|
- !ruby/object:Gem::Version
|
|
31
31
|
version: '9.0'
|
|
@@ -57,6 +57,20 @@ dependencies:
|
|
|
57
57
|
- - "~>"
|
|
58
58
|
- !ruby/object:Gem::Version
|
|
59
59
|
version: '0.2'
|
|
60
|
+
- !ruby/object:Gem::Dependency
|
|
61
|
+
name: humid
|
|
62
|
+
requirement: !ruby/object:Gem::Requirement
|
|
63
|
+
requirements:
|
|
64
|
+
- - "~>"
|
|
65
|
+
- !ruby/object:Gem::Version
|
|
66
|
+
version: '1.1'
|
|
67
|
+
type: :runtime
|
|
68
|
+
prerelease: false
|
|
69
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
70
|
+
requirements:
|
|
71
|
+
- - "~>"
|
|
72
|
+
- !ruby/object:Gem::Version
|
|
73
|
+
version: '1.1'
|
|
60
74
|
description: Rails integration for SuperglueJS
|
|
61
75
|
email: jho406@gmail.com
|
|
62
76
|
executables: []
|
|
@@ -71,6 +85,7 @@ files:
|
|
|
71
85
|
- app/jobs/superglue/streams/action_broadcast_job.rb
|
|
72
86
|
- app/jobs/superglue/streams/broadcast_stream_job.rb
|
|
73
87
|
- app/models/concerns/superglue/broadcastable.rb
|
|
88
|
+
- app/views/application/_humid.html.erb
|
|
74
89
|
- app/views/superglue/layouts/_stream_message.json.props
|
|
75
90
|
- app/views/superglue/layouts/stream.json.props
|
|
76
91
|
- lib/generators/superglue/install/install_generator.rb
|
|
@@ -78,9 +93,10 @@ files:
|
|
|
78
93
|
- lib/generators/superglue/install/templates/bun/bun.config.deepkit.js
|
|
79
94
|
- lib/generators/superglue/install/templates/bun/bun.config.js
|
|
80
95
|
- lib/generators/superglue/install/templates/bun/bun.config.ts.js
|
|
96
|
+
- lib/generators/superglue/install/templates/bun/bun.config.typia.js
|
|
81
97
|
- lib/generators/superglue/install/templates/bun/page_to_page_mapping.js
|
|
82
98
|
- lib/generators/superglue/install/templates/bun/page_to_page_mapping.ts
|
|
83
|
-
- lib/generators/superglue/install/templates/
|
|
99
|
+
- lib/generators/superglue/install/templates/humid_initializer.rb
|
|
84
100
|
- lib/generators/superglue/install/templates/initializer.rb
|
|
85
101
|
- lib/generators/superglue/install/templates/js/application.jsx
|
|
86
102
|
- lib/generators/superglue/install/templates/js/application_visit.js
|
|
@@ -96,11 +112,20 @@ files:
|
|
|
96
112
|
- lib/generators/superglue/install/templates/rollup/rollup.config.deepkit.js
|
|
97
113
|
- lib/generators/superglue/install/templates/rollup/rollup.config.js
|
|
98
114
|
- lib/generators/superglue/install/templates/rollup/rollup.config.ts.js
|
|
115
|
+
- lib/generators/superglue/install/templates/rollup/rollup.config.typia.js
|
|
116
|
+
- lib/generators/superglue/install/templates/ssr/bun.build_ssr.js
|
|
117
|
+
- lib/generators/superglue/install/templates/ssr/esbuild.build_ssr.mjs
|
|
118
|
+
- lib/generators/superglue/install/templates/ssr/rollup.build_ssr.config.js
|
|
119
|
+
- lib/generators/superglue/install/templates/ssr/server_rendering.jsx
|
|
120
|
+
- lib/generators/superglue/install/templates/ssr/server_rendering.tsx
|
|
121
|
+
- lib/generators/superglue/install/templates/ssr/shim.js
|
|
122
|
+
- lib/generators/superglue/install/templates/ssr/webpack.build_ssr.js
|
|
99
123
|
- lib/generators/superglue/install/templates/stream.json.props
|
|
100
124
|
- lib/generators/superglue/install/templates/ts/application.tsx
|
|
101
125
|
- lib/generators/superglue/install/templates/ts/application_visit.ts
|
|
102
126
|
- lib/generators/superglue/install/templates/ts/build.deepkit.mjs
|
|
103
127
|
- lib/generators/superglue/install/templates/ts/build.mjs
|
|
128
|
+
- lib/generators/superglue/install/templates/ts/build.typia.mjs
|
|
104
129
|
- lib/generators/superglue/install/templates/ts/components.ts
|
|
105
130
|
- lib/generators/superglue/install/templates/ts/flash.ts
|
|
106
131
|
- lib/generators/superglue/install/templates/ts/inputs.tsx
|
|
@@ -112,27 +137,27 @@ files:
|
|
|
112
137
|
- lib/generators/superglue/install/templates/webpack/webpack.config.deepkit.js
|
|
113
138
|
- lib/generators/superglue/install/templates/webpack/webpack.config.js
|
|
114
139
|
- lib/generators/superglue/install/templates/webpack/webpack.config.ts.js
|
|
140
|
+
- lib/generators/superglue/install/templates/webpack/webpack.config.typia.js
|
|
115
141
|
- lib/generators/superglue/scaffold/scaffold_generator.rb
|
|
116
142
|
- lib/generators/superglue/scaffold_controller/scaffold_controller_generator.rb
|
|
117
|
-
- lib/generators/superglue/view_collection/templates/js/edit.jsx
|
|
118
|
-
- lib/generators/superglue/view_collection/templates/js/index.jsx
|
|
119
|
-
- lib/generators/superglue/view_collection/templates/js/new.jsx
|
|
120
|
-
- lib/generators/superglue/view_collection/templates/js/show.jsx
|
|
143
|
+
- lib/generators/superglue/view_collection/templates/js/edit.html.jsx
|
|
144
|
+
- lib/generators/superglue/view_collection/templates/js/index.html.jsx
|
|
145
|
+
- lib/generators/superglue/view_collection/templates/js/new.html.jsx
|
|
146
|
+
- lib/generators/superglue/view_collection/templates/js/show.html.jsx
|
|
121
147
|
- lib/generators/superglue/view_collection/templates/props/_form.json.props
|
|
122
148
|
- lib/generators/superglue/view_collection/templates/props/edit.json.props
|
|
123
149
|
- lib/generators/superglue/view_collection/templates/props/index.json.props
|
|
124
150
|
- lib/generators/superglue/view_collection/templates/props/new.json.props
|
|
125
151
|
- lib/generators/superglue/view_collection/templates/props/show.json.props
|
|
126
|
-
- lib/generators/superglue/view_collection/templates/ts/edit.tsx
|
|
127
|
-
- lib/generators/superglue/view_collection/templates/ts/index.tsx
|
|
128
|
-
- lib/generators/superglue/view_collection/templates/ts/new.tsx
|
|
129
|
-
- lib/generators/superglue/view_collection/templates/ts/show.tsx
|
|
152
|
+
- lib/generators/superglue/view_collection/templates/ts/edit.html.tsx
|
|
153
|
+
- lib/generators/superglue/view_collection/templates/ts/index.html.tsx
|
|
154
|
+
- lib/generators/superglue/view_collection/templates/ts/new.html.tsx
|
|
155
|
+
- lib/generators/superglue/view_collection/templates/ts/show.html.tsx
|
|
130
156
|
- lib/generators/superglue/view_collection/view_collection_generator.rb
|
|
131
157
|
- lib/superglue.rb
|
|
132
158
|
- lib/superglue/engine.rb
|
|
133
159
|
- lib/superglue/helpers.rb
|
|
134
160
|
- lib/superglue/rendering.rb
|
|
135
|
-
- lib/superglue/resolver.rb
|
|
136
161
|
homepage: https://github.com/thoughtbot/superglue_rails/
|
|
137
162
|
licenses:
|
|
138
163
|
- MIT
|