superglue 2.0.0.alpha.10 → 2.0.0.beta.2
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/channels/superglue/streams/broadcasts.rb +4 -34
- data/app/helpers/superglue/streams_helper.rb +2 -2
- data/app/models/concerns/superglue/broadcastable.rb +10 -36
- data/lib/generators/superglue/install/install_generator.rb +193 -25
- data/lib/generators/superglue/install/templates/application.json.props +1 -3
- data/lib/generators/superglue/install/templates/bun/bun.config.deepkit.js +38 -0
- data/lib/generators/superglue/install/templates/bun/bun.config.js +34 -0
- data/lib/generators/superglue/install/templates/bun/bun.config.ts.js +34 -0
- data/lib/generators/superglue/install/templates/bun/page_to_page_mapping.js +10 -0
- data/lib/generators/superglue/install/templates/bun/page_to_page_mapping.ts +10 -0
- data/lib/generators/superglue/install/templates/js/application.jsx +24 -18
- data/lib/generators/superglue/install/templates/js/application_visit.js +31 -61
- data/lib/generators/superglue/install/templates/js/build.mjs +26 -0
- data/lib/generators/superglue/install/templates/js/flash.js +6 -47
- data/lib/generators/superglue/install/templates/js/layout.jsx +2 -2
- data/lib/generators/superglue/install/templates/rollup/page_to_page_mapping.js +9 -0
- data/lib/generators/superglue/install/templates/rollup/page_to_page_mapping.ts +9 -0
- data/lib/generators/superglue/install/templates/rollup/rollup.config.deepkit.js +37 -0
- data/lib/generators/superglue/install/templates/rollup/rollup.config.js +32 -0
- data/lib/generators/superglue/install/templates/rollup/rollup.config.ts.js +35 -0
- data/lib/generators/superglue/install/templates/stream.json.props +1 -3
- data/lib/generators/superglue/install/templates/ts/application.tsx +24 -18
- data/lib/generators/superglue/install/templates/ts/application_visit.ts +35 -64
- data/lib/generators/superglue/install/templates/ts/build.deepkit.mjs +27 -0
- data/lib/generators/superglue/install/templates/ts/build.mjs +26 -0
- data/lib/generators/superglue/install/templates/ts/flash.ts +16 -48
- data/lib/generators/superglue/install/templates/ts/layout.tsx +2 -2
- data/lib/generators/superglue/install/templates/ts/page_to_page_mapping.ts +3 -1
- data/lib/generators/superglue/install/templates/ts/tsconfig.json +2 -2
- data/lib/generators/superglue/install/templates/webpack/page_to_page_mapping.js +9 -0
- data/lib/generators/superglue/install/templates/webpack/page_to_page_mapping.ts +9 -0
- data/lib/generators/superglue/install/templates/webpack/webpack.config.deepkit.js +42 -0
- data/lib/generators/superglue/install/templates/webpack/webpack.config.js +40 -0
- data/lib/generators/superglue/install/templates/webpack/webpack.config.ts.js +40 -0
- data/lib/generators/superglue/view_collection/templates/js/edit.jsx +7 -6
- data/lib/generators/superglue/view_collection/templates/js/new.jsx +9 -8
- data/lib/generators/superglue/view_collection/templates/ts/edit.tsx +9 -8
- data/lib/generators/superglue/view_collection/templates/ts/new.tsx +10 -9
- data/lib/superglue/engine.rb +0 -1
- data/lib/superglue/rendering.rb +18 -4
- data/lib/superglue.rb +0 -10
- metadata +21 -8
- data/app/controllers/concerns/superglue/request_id_tracking.rb +0 -16
- data/app/models/superglue/debouncer.rb +0 -28
- data/app/models/superglue/thread_debouncer.rb +0 -30
- data/lib/generators/superglue/install/templates/js/store.js +0 -31
- data/lib/generators/superglue/install/templates/ts/store.ts +0 -35
|
@@ -1,50 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { receiveResponse, beforeVisit } from "@thoughtbot/superglue";
|
|
1
|
+
import { useFlash } from "@thoughtbot/superglue";
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Customize this type to match the flash keys your application uses.
|
|
5
|
+
*/
|
|
6
|
+
export type AppFlash = {
|
|
7
|
+
success?: string;
|
|
8
|
+
notice?: string;
|
|
9
|
+
alert?: string;
|
|
10
|
+
error?: string;
|
|
11
|
+
[key: string]: unknown;
|
|
12
|
+
};
|
|
5
13
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
reducers: {
|
|
12
|
-
clearFlash(state, { payload }: { payload: string }) {
|
|
13
|
-
const key = payload;
|
|
14
|
-
if (!key) {
|
|
15
|
-
return {};
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
delete state[key];
|
|
19
|
-
|
|
20
|
-
return {
|
|
21
|
-
...state,
|
|
22
|
-
};
|
|
23
|
-
},
|
|
24
|
-
flash(state, { payload }) {
|
|
25
|
-
return {
|
|
26
|
-
...state,
|
|
27
|
-
...payload,
|
|
28
|
-
};
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
extraReducers: (builder) => {
|
|
32
|
-
builder.addCase(beforeVisit, (_state, _action) => {
|
|
33
|
-
return {};
|
|
34
|
-
});
|
|
35
|
-
builder.addCase(receiveResponse, (state, action) => {
|
|
36
|
-
const { response } = action.payload;
|
|
37
|
-
|
|
38
|
-
if (response.slices) {
|
|
39
|
-
return {
|
|
40
|
-
...state,
|
|
41
|
-
...(response.slices.flash as FlashState),
|
|
42
|
-
};
|
|
43
|
-
} else {
|
|
44
|
-
return state;
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
export const { clearFlash, flash } = flashSlice.actions;
|
|
14
|
+
/**
|
|
15
|
+
* A typed wrapper around useFlash. Returns flash narrowed to
|
|
16
|
+
* your application's flash shape.
|
|
17
|
+
*/
|
|
18
|
+
export const useAppFlash = () => useFlash<AppFlash>();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, {ReactNode} from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import { useAppFlash } from '@javascript/flash'
|
|
3
3
|
|
|
4
4
|
export const Layout = ({children}: {children: ReactNode}) => {
|
|
5
|
-
const flash =
|
|
5
|
+
const flash = useAppFlash()
|
|
6
6
|
|
|
7
7
|
return (
|
|
8
8
|
<div>
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"strictPropertyInitialization": false,
|
|
8
8
|
"noUnusedLocals": true,
|
|
9
9
|
"noUnusedParameters": true,
|
|
10
|
-
"jsx": "
|
|
10
|
+
"jsx": "preserve",
|
|
11
11
|
"allowJs": false,
|
|
12
12
|
"target": "ES2021",
|
|
13
13
|
"allowSyntheticDefaultImports": true,
|
|
@@ -23,5 +23,5 @@
|
|
|
23
23
|
"include": [
|
|
24
24
|
"app/javascript/**/*",
|
|
25
25
|
"app/views/**/*"
|
|
26
|
-
]
|
|
26
|
+
]
|
|
27
27
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const pageIdentifierToPageComponent = {}
|
|
2
|
+
const context = require.context('../views', true, /\.jsx$/)
|
|
3
|
+
|
|
4
|
+
context.keys().forEach((key) => {
|
|
5
|
+
const identifier = key.replace('./', '').split('.')[0]
|
|
6
|
+
pageIdentifierToPageComponent[identifier] = context(key).default
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
export { pageIdentifierToPageComponent }
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const pageIdentifierToPageComponent: Record<string, React.ComponentType> = {}
|
|
2
|
+
const context = require.context('../views', true, /\.tsx$/)
|
|
3
|
+
|
|
4
|
+
context.keys().forEach((key: string) => {
|
|
5
|
+
const identifier = key.replace('./', '').split('.')[0]
|
|
6
|
+
pageIdentifierToPageComponent[identifier] = context(key).default
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
export { pageIdentifierToPageComponent }
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const path = require("path")
|
|
2
|
+
const webpack = require("webpack")
|
|
3
|
+
const { webpack: deepkitPlugin } = require("@thoughtbot/superglue/deepkit")
|
|
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' ? [] : [deepkitPlugin()])
|
|
41
|
+
]
|
|
42
|
+
}
|
|
@@ -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
|
+
entry: {
|
|
8
|
+
application: "./app/javascript/application.jsx"
|
|
9
|
+
},
|
|
10
|
+
module: {
|
|
11
|
+
rules: [
|
|
12
|
+
{
|
|
13
|
+
test: /\.[jt]sx?$/,
|
|
14
|
+
exclude: /node_modules/,
|
|
15
|
+
loader: "esbuild-loader",
|
|
16
|
+
options: {
|
|
17
|
+
target: "es2020"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
},
|
|
22
|
+
resolve: {
|
|
23
|
+
extensions: [".jsx", ".js", ".json", ".wasm"],
|
|
24
|
+
alias: {
|
|
25
|
+
"@javascript": path.resolve(__dirname, "app/javascript"),
|
|
26
|
+
"@views": path.resolve(__dirname, "app/views")
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
output: {
|
|
30
|
+
filename: "[name].js",
|
|
31
|
+
sourceMapFilename: "[file].map",
|
|
32
|
+
chunkFormat: "module",
|
|
33
|
+
path: path.resolve(__dirname, "app/assets/builds"),
|
|
34
|
+
},
|
|
35
|
+
plugins: [
|
|
36
|
+
new webpack.optimize.LimitChunkCountPlugin({
|
|
37
|
+
maxChunks: 1
|
|
38
|
+
})
|
|
39
|
+
]
|
|
40
|
+
}
|
|
@@ -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
|
+
entry: {
|
|
8
|
+
application: "./app/javascript/application.tsx"
|
|
9
|
+
},
|
|
10
|
+
module: {
|
|
11
|
+
rules: [
|
|
12
|
+
{
|
|
13
|
+
test: /\.[jt]sx?$/,
|
|
14
|
+
exclude: /node_modules/,
|
|
15
|
+
loader: "esbuild-loader",
|
|
16
|
+
options: {
|
|
17
|
+
target: "es2020"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
},
|
|
22
|
+
resolve: {
|
|
23
|
+
extensions: [".tsx", ".ts", ".jsx", ".js", ".json", ".wasm"],
|
|
24
|
+
alias: {
|
|
25
|
+
"@javascript": path.resolve(__dirname, "app/javascript"),
|
|
26
|
+
"@views": path.resolve(__dirname, "app/views")
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
output: {
|
|
30
|
+
filename: "[name].js",
|
|
31
|
+
sourceMapFilename: "[file].map",
|
|
32
|
+
chunkFormat: "module",
|
|
33
|
+
path: path.resolve(__dirname, "app/assets/builds"),
|
|
34
|
+
},
|
|
35
|
+
plugins: [
|
|
36
|
+
new webpack.optimize.LimitChunkCountPlugin({
|
|
37
|
+
maxChunks: 1
|
|
38
|
+
})
|
|
39
|
+
]
|
|
40
|
+
}
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
SubmitButton
|
|
9
9
|
} from '@javascript/components'
|
|
10
10
|
import { useContent } from '@thoughtbot/superglue'
|
|
11
|
-
import {
|
|
11
|
+
import { useAppFlash } from '@javascript/flash'
|
|
12
12
|
|
|
13
13
|
export default function <%= js_plural_table_name(:upper) %>Edit() {
|
|
14
14
|
const {
|
|
@@ -17,12 +17,13 @@ export default function <%= js_plural_table_name(:upper) %>Edit() {
|
|
|
17
17
|
<%= js_plural_table_name %>Path,
|
|
18
18
|
} = useContent()
|
|
19
19
|
|
|
20
|
-
const {
|
|
21
|
-
inputs,
|
|
22
|
-
form,
|
|
23
|
-
extras
|
|
20
|
+
const {
|
|
21
|
+
inputs,
|
|
22
|
+
form,
|
|
23
|
+
extras
|
|
24
24
|
} = <%= js_singular_table_name %>Form
|
|
25
|
-
const
|
|
25
|
+
const flash = useAppFlash()
|
|
26
|
+
const validationErrors = flash["<%= js_singular_table_name%>FormErrors"]
|
|
26
27
|
|
|
27
28
|
return (
|
|
28
29
|
<Layout>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import {
|
|
3
|
-
Form,
|
|
2
|
+
import {
|
|
3
|
+
Form,
|
|
4
4
|
Layout,
|
|
5
5
|
<%- attributes.each do |attr| -%>
|
|
6
6
|
<%= js_component(attr)%>,
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
SubmitButton
|
|
9
9
|
} from '@javascript/components'
|
|
10
10
|
import { useContent } from '@thoughtbot/superglue'
|
|
11
|
-
import {
|
|
11
|
+
import { useAppFlash } from '@javascript/flash'
|
|
12
12
|
|
|
13
13
|
export default function <%= js_plural_table_name(:upper) %>New() {
|
|
14
14
|
const {
|
|
@@ -16,12 +16,13 @@ export default function <%= js_plural_table_name(:upper) %>New() {
|
|
|
16
16
|
<%= js_plural_table_name %>Path
|
|
17
17
|
} = useContent()
|
|
18
18
|
|
|
19
|
-
const {
|
|
20
|
-
inputs,
|
|
21
|
-
form,
|
|
22
|
-
extras
|
|
19
|
+
const {
|
|
20
|
+
inputs,
|
|
21
|
+
form,
|
|
22
|
+
extras
|
|
23
23
|
} = <%= js_singular_table_name %>Form
|
|
24
|
-
const
|
|
24
|
+
const flash = useAppFlash()
|
|
25
|
+
const validationErrors = flash["<%= js_singular_table_name%>FormErrors"]
|
|
25
26
|
|
|
26
27
|
return (
|
|
27
28
|
<Layout>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import {
|
|
3
|
-
Form,
|
|
2
|
+
import {
|
|
3
|
+
Form,
|
|
4
4
|
FormProps,
|
|
5
5
|
Layout,
|
|
6
6
|
<%- attributes.each do |attr| -%>
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
RailsSubmitButtonProps
|
|
12
12
|
} from '@javascript/components'
|
|
13
13
|
import { useContent } from '@thoughtbot/superglue'
|
|
14
|
-
import {
|
|
14
|
+
import { useAppFlash } from '@javascript/flash'
|
|
15
15
|
|
|
16
16
|
type ContentProps = {
|
|
17
17
|
<%= js_singular_table_name %>Path: string
|
|
@@ -31,12 +31,13 @@ export default function <%= js_plural_table_name(:upper) %>Edit() {
|
|
|
31
31
|
<%= js_plural_table_name %>Path,
|
|
32
32
|
} = useContent<ContentProps>()
|
|
33
33
|
|
|
34
|
-
const {
|
|
35
|
-
inputs,
|
|
36
|
-
form,
|
|
37
|
-
extras
|
|
34
|
+
const {
|
|
35
|
+
inputs,
|
|
36
|
+
form,
|
|
37
|
+
extras
|
|
38
38
|
} = <%= js_singular_table_name %>Form
|
|
39
|
-
const
|
|
39
|
+
const flash = useAppFlash()
|
|
40
|
+
const validationErrors = flash["<%= js_singular_table_name%>FormErrors"]
|
|
40
41
|
|
|
41
42
|
return (
|
|
42
43
|
<Layout>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import {
|
|
3
|
-
Form,
|
|
2
|
+
import {
|
|
3
|
+
Form,
|
|
4
4
|
FormProps,
|
|
5
5
|
Layout,
|
|
6
6
|
<%- attributes.each do |attr| -%>
|
|
@@ -11,13 +11,13 @@ import {
|
|
|
11
11
|
RailsSubmitButtonProps
|
|
12
12
|
} from '@javascript/components'
|
|
13
13
|
import { useContent } from '@thoughtbot/superglue'
|
|
14
|
-
import {
|
|
14
|
+
import { useAppFlash } from '@javascript/flash'
|
|
15
15
|
|
|
16
16
|
type ContentProps = {
|
|
17
17
|
<%= js_plural_table_name %>Path: string
|
|
18
18
|
<%= js_singular_table_name %>Form: FormProps<{
|
|
19
19
|
<%- attributes.each do |attr| -%>
|
|
20
|
-
<%= attr.column_name.camelize(:lower)%>: <%=
|
|
20
|
+
<%= attr.column_name.camelize(:lower)%>: Rails<%= js_component(attr)%>Props
|
|
21
21
|
<%- end -%>
|
|
22
22
|
submit: RailsSubmitButtonProps
|
|
23
23
|
}>
|
|
@@ -28,12 +28,13 @@ export default function <%= js_plural_table_name(:upper) %>New() {
|
|
|
28
28
|
<%= js_singular_table_name %>Form,
|
|
29
29
|
<%= js_plural_table_name %>Path,
|
|
30
30
|
} = useContent<ContentProps>()
|
|
31
|
-
const {
|
|
32
|
-
inputs,
|
|
33
|
-
form,
|
|
34
|
-
extras
|
|
31
|
+
const {
|
|
32
|
+
inputs,
|
|
33
|
+
form,
|
|
34
|
+
extras
|
|
35
35
|
} = <%= js_singular_table_name %>Form
|
|
36
|
-
const
|
|
36
|
+
const flash = useAppFlash()
|
|
37
|
+
const validationErrors = flash["<%= js_singular_table_name%>FormErrors"]
|
|
37
38
|
|
|
38
39
|
return (
|
|
39
40
|
<Layout>
|
data/lib/superglue/engine.rb
CHANGED
data/lib/superglue/rendering.rb
CHANGED
|
@@ -25,14 +25,24 @@ module Superglue
|
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
@_render_options = options
|
|
28
|
-
_ensure_react_page!(options[:template], options[:prefixes])
|
|
28
|
+
_ensure_react_page!(options[:template], options[:prefixes]) if request.format.html?
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
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
|
|
32
35
|
super(options.merge(
|
|
33
36
|
template: _superglue_template,
|
|
34
37
|
prefixes: []
|
|
35
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
|
+
))
|
|
36
46
|
else
|
|
37
47
|
super
|
|
38
48
|
end
|
|
@@ -54,7 +64,11 @@ module Superglue
|
|
|
54
64
|
end
|
|
55
65
|
|
|
56
66
|
def _jsx_defaults
|
|
57
|
-
@_use_jsx_rendering_defaults && request.format.html?
|
|
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?
|
|
58
72
|
end
|
|
59
73
|
|
|
60
74
|
def _ensure_react_page!(template, prefixes)
|
data/lib/superglue.rb
CHANGED
|
@@ -10,8 +10,6 @@ module Superglue
|
|
|
10
10
|
|
|
11
11
|
mattr_accessor :draw_routes, default: true
|
|
12
12
|
|
|
13
|
-
thread_mattr_accessor :current_request_id
|
|
14
|
-
|
|
15
13
|
class << self
|
|
16
14
|
attr_writer :signed_stream_verifier_key
|
|
17
15
|
|
|
@@ -26,13 +24,5 @@ module Superglue
|
|
|
26
24
|
def signed_stream_verifier_key
|
|
27
25
|
@signed_stream_verifier_key or raise ArgumentError, 'Superglue requires a signed_stream_verifier_key'
|
|
28
26
|
end
|
|
29
|
-
|
|
30
|
-
def with_request_id(request_id)
|
|
31
|
-
old_request_id = current_request_id
|
|
32
|
-
self.current_request_id = request_id
|
|
33
|
-
yield
|
|
34
|
-
ensure
|
|
35
|
-
self.current_request_id = old_request_id
|
|
36
|
-
end
|
|
37
27
|
end
|
|
38
28
|
end
|
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.beta.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Johny Ho
|
|
@@ -35,14 +35,14 @@ dependencies:
|
|
|
35
35
|
requirements:
|
|
36
36
|
- - "~>"
|
|
37
37
|
- !ruby/object:Gem::Version
|
|
38
|
-
version: 1.0.0
|
|
38
|
+
version: 1.0.0
|
|
39
39
|
type: :runtime
|
|
40
40
|
prerelease: false
|
|
41
41
|
version_requirements: !ruby/object:Gem::Requirement
|
|
42
42
|
requirements:
|
|
43
43
|
- - "~>"
|
|
44
44
|
- !ruby/object:Gem::Version
|
|
45
|
-
version: 1.0.0
|
|
45
|
+
version: 1.0.0
|
|
46
46
|
- !ruby/object:Gem::Dependency
|
|
47
47
|
name: form_props
|
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -67,38 +67,51 @@ files:
|
|
|
67
67
|
- app/channels/superglue/streams/broadcasts.rb
|
|
68
68
|
- app/channels/superglue/streams/stream_name.rb
|
|
69
69
|
- app/channels/superglue/streams_channel.rb
|
|
70
|
-
- app/controllers/concerns/superglue/request_id_tracking.rb
|
|
71
70
|
- app/helpers/superglue/streams_helper.rb
|
|
72
71
|
- app/jobs/superglue/streams/action_broadcast_job.rb
|
|
73
72
|
- app/jobs/superglue/streams/broadcast_stream_job.rb
|
|
74
73
|
- app/models/concerns/superglue/broadcastable.rb
|
|
75
|
-
- app/models/superglue/debouncer.rb
|
|
76
|
-
- app/models/superglue/thread_debouncer.rb
|
|
77
74
|
- app/views/superglue/layouts/_stream_message.json.props
|
|
78
75
|
- app/views/superglue/layouts/stream.json.props
|
|
79
76
|
- lib/generators/superglue/install/install_generator.rb
|
|
80
77
|
- lib/generators/superglue/install/templates/application.json.props
|
|
78
|
+
- lib/generators/superglue/install/templates/bun/bun.config.deepkit.js
|
|
79
|
+
- lib/generators/superglue/install/templates/bun/bun.config.js
|
|
80
|
+
- lib/generators/superglue/install/templates/bun/bun.config.ts.js
|
|
81
|
+
- lib/generators/superglue/install/templates/bun/page_to_page_mapping.js
|
|
82
|
+
- lib/generators/superglue/install/templates/bun/page_to_page_mapping.ts
|
|
81
83
|
- lib/generators/superglue/install/templates/erb/superglue.html.erb
|
|
82
84
|
- lib/generators/superglue/install/templates/initializer.rb
|
|
83
85
|
- lib/generators/superglue/install/templates/js/application.jsx
|
|
84
86
|
- lib/generators/superglue/install/templates/js/application_visit.js
|
|
87
|
+
- lib/generators/superglue/install/templates/js/build.mjs
|
|
85
88
|
- lib/generators/superglue/install/templates/js/components.js
|
|
86
89
|
- lib/generators/superglue/install/templates/js/flash.js
|
|
87
90
|
- lib/generators/superglue/install/templates/js/inputs.jsx
|
|
88
91
|
- lib/generators/superglue/install/templates/js/jsconfig.json
|
|
89
92
|
- lib/generators/superglue/install/templates/js/layout.jsx
|
|
90
93
|
- lib/generators/superglue/install/templates/js/page_to_page_mapping.js
|
|
91
|
-
- lib/generators/superglue/install/templates/
|
|
94
|
+
- lib/generators/superglue/install/templates/rollup/page_to_page_mapping.js
|
|
95
|
+
- lib/generators/superglue/install/templates/rollup/page_to_page_mapping.ts
|
|
96
|
+
- lib/generators/superglue/install/templates/rollup/rollup.config.deepkit.js
|
|
97
|
+
- lib/generators/superglue/install/templates/rollup/rollup.config.js
|
|
98
|
+
- lib/generators/superglue/install/templates/rollup/rollup.config.ts.js
|
|
92
99
|
- lib/generators/superglue/install/templates/stream.json.props
|
|
93
100
|
- lib/generators/superglue/install/templates/ts/application.tsx
|
|
94
101
|
- lib/generators/superglue/install/templates/ts/application_visit.ts
|
|
102
|
+
- lib/generators/superglue/install/templates/ts/build.deepkit.mjs
|
|
103
|
+
- lib/generators/superglue/install/templates/ts/build.mjs
|
|
95
104
|
- lib/generators/superglue/install/templates/ts/components.ts
|
|
96
105
|
- lib/generators/superglue/install/templates/ts/flash.ts
|
|
97
106
|
- lib/generators/superglue/install/templates/ts/inputs.tsx
|
|
98
107
|
- lib/generators/superglue/install/templates/ts/layout.tsx
|
|
99
108
|
- lib/generators/superglue/install/templates/ts/page_to_page_mapping.ts
|
|
100
|
-
- lib/generators/superglue/install/templates/ts/store.ts
|
|
101
109
|
- lib/generators/superglue/install/templates/ts/tsconfig.json
|
|
110
|
+
- lib/generators/superglue/install/templates/webpack/page_to_page_mapping.js
|
|
111
|
+
- lib/generators/superglue/install/templates/webpack/page_to_page_mapping.ts
|
|
112
|
+
- lib/generators/superglue/install/templates/webpack/webpack.config.deepkit.js
|
|
113
|
+
- lib/generators/superglue/install/templates/webpack/webpack.config.js
|
|
114
|
+
- lib/generators/superglue/install/templates/webpack/webpack.config.ts.js
|
|
102
115
|
- lib/generators/superglue/scaffold/scaffold_generator.rb
|
|
103
116
|
- lib/generators/superglue/scaffold_controller/scaffold_controller_generator.rb
|
|
104
117
|
- lib/generators/superglue/view_collection/templates/js/edit.jsx
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# This file was ported from the amazing folks at turbo-rails
|
|
2
|
-
# You can find its MIT License here: https://github.com/hotwired/turbo-rails/blob/main/MIT-LICENSE
|
|
3
|
-
|
|
4
|
-
module Superglue::RequestIdTracking
|
|
5
|
-
extend ActiveSupport::Concern
|
|
6
|
-
|
|
7
|
-
included do
|
|
8
|
-
around_action :superglue_tracking_request_id
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
private
|
|
12
|
-
|
|
13
|
-
def superglue_tracking_request_id(&block)
|
|
14
|
-
Superglue.with_request_id(request.headers["X-Superglue-Request-Id"], &block)
|
|
15
|
-
end
|
|
16
|
-
end
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# This file was ported from the amazing folks at turbo-rails
|
|
2
|
-
# You can find its MIT License here: https://github.com/hotwired/turbo-rails/blob/main/MIT-LICENSE
|
|
3
|
-
|
|
4
|
-
class Superglue::Debouncer
|
|
5
|
-
attr_reader :delay, :scheduled_task
|
|
6
|
-
|
|
7
|
-
DEFAULT_DELAY = 0.5
|
|
8
|
-
|
|
9
|
-
def initialize(delay: DEFAULT_DELAY)
|
|
10
|
-
@delay = delay
|
|
11
|
-
@scheduled_task = nil
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def debounce(&block)
|
|
15
|
-
scheduled_task&.cancel unless scheduled_task&.complete?
|
|
16
|
-
@scheduled_task = Concurrent::ScheduledTask.execute(delay, &block)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def wait
|
|
20
|
-
scheduled_task&.wait(wait_timeout)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
private
|
|
24
|
-
|
|
25
|
-
def wait_timeout
|
|
26
|
-
delay + 1
|
|
27
|
-
end
|
|
28
|
-
end
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
# This file was ported from the amazing folks at turbo-rails
|
|
2
|
-
# You can find its MIT License here: https://github.com/hotwired/turbo-rails/blob/main/MIT-LICENSE
|
|
3
|
-
|
|
4
|
-
class Superglue::ThreadDebouncer
|
|
5
|
-
delegate :wait, to: :debouncer
|
|
6
|
-
|
|
7
|
-
def self.for(key, delay: Superglue::Debouncer::DEFAULT_DELAY)
|
|
8
|
-
Thread.current[key] ||= new(key, Thread.current, delay: delay)
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
private_class_method :new
|
|
12
|
-
|
|
13
|
-
def initialize(key, thread, delay:)
|
|
14
|
-
@key = key
|
|
15
|
-
@debouncer = Superglue::Debouncer.new(delay: delay)
|
|
16
|
-
@thread = thread
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def debounce
|
|
20
|
-
debouncer.debounce do
|
|
21
|
-
yield.tap do
|
|
22
|
-
thread[key] = nil
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
private
|
|
28
|
-
|
|
29
|
-
attr_reader :key, :debouncer, :thread
|
|
30
|
-
end
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { configureStore } from "@reduxjs/toolkit"
|
|
2
|
-
import { useDispatch, useSelector, useStore } from "react-redux"
|
|
3
|
-
import { flashSlice } from "./slices/flash"
|
|
4
|
-
import {
|
|
5
|
-
beforeVisit,
|
|
6
|
-
beforeFetch,
|
|
7
|
-
beforeRemote,
|
|
8
|
-
rootReducer
|
|
9
|
-
} from "@thoughtbot/superglue"
|
|
10
|
-
|
|
11
|
-
const { pages, superglue, fragments } = rootReducer
|
|
12
|
-
|
|
13
|
-
export const store = configureStore({
|
|
14
|
-
devTools: process.env.NODE_ENV !== "production",
|
|
15
|
-
middleware: getDefaultMiddleware =>
|
|
16
|
-
getDefaultMiddleware({
|
|
17
|
-
serializableCheck: {
|
|
18
|
-
ignoredActions: [beforeFetch.type, beforeVisit.type, beforeRemote.type]
|
|
19
|
-
}
|
|
20
|
-
}),
|
|
21
|
-
reducer: {
|
|
22
|
-
superglue,
|
|
23
|
-
pages,
|
|
24
|
-
flash: flashSlice.reducer,
|
|
25
|
-
fragments,
|
|
26
|
-
}
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
export const useAppDispatch = useDispatch.withTypes()
|
|
30
|
-
export const useAppSelector = useSelector.withTypes()
|
|
31
|
-
export const useAppStore = useStore.withTypes()
|