superglue 2.0.0.alpha.11 → 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 +192 -33
- 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/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 +1 -2
- 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/tsconfig.json +1 -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 +9 -8
- data/lib/superglue/engine.rb +0 -1
- data/lib/superglue.rb +0 -10
- metadata +17 -7
- 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/esbuild/plugin.js +0 -43
- 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>
|
|
@@ -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,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_plural_table_name %>Path: string
|
|
@@ -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.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
|
|
@@ -67,19 +67,20 @@ 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
|
-
- lib/generators/superglue/install/templates/esbuild/plugin.js
|
|
83
84
|
- lib/generators/superglue/install/templates/initializer.rb
|
|
84
85
|
- lib/generators/superglue/install/templates/js/application.jsx
|
|
85
86
|
- lib/generators/superglue/install/templates/js/application_visit.js
|
|
@@ -90,18 +91,27 @@ files:
|
|
|
90
91
|
- lib/generators/superglue/install/templates/js/jsconfig.json
|
|
91
92
|
- lib/generators/superglue/install/templates/js/layout.jsx
|
|
92
93
|
- lib/generators/superglue/install/templates/js/page_to_page_mapping.js
|
|
93
|
-
- 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
|
|
94
99
|
- lib/generators/superglue/install/templates/stream.json.props
|
|
95
100
|
- lib/generators/superglue/install/templates/ts/application.tsx
|
|
96
101
|
- lib/generators/superglue/install/templates/ts/application_visit.ts
|
|
102
|
+
- lib/generators/superglue/install/templates/ts/build.deepkit.mjs
|
|
97
103
|
- lib/generators/superglue/install/templates/ts/build.mjs
|
|
98
104
|
- lib/generators/superglue/install/templates/ts/components.ts
|
|
99
105
|
- lib/generators/superglue/install/templates/ts/flash.ts
|
|
100
106
|
- lib/generators/superglue/install/templates/ts/inputs.tsx
|
|
101
107
|
- lib/generators/superglue/install/templates/ts/layout.tsx
|
|
102
108
|
- lib/generators/superglue/install/templates/ts/page_to_page_mapping.ts
|
|
103
|
-
- lib/generators/superglue/install/templates/ts/store.ts
|
|
104
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
|
|
105
115
|
- lib/generators/superglue/scaffold/scaffold_generator.rb
|
|
106
116
|
- lib/generators/superglue/scaffold_controller/scaffold_controller_generator.rb
|
|
107
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,43 +0,0 @@
|
|
|
1
|
-
import * as ts from "typescript";
|
|
2
|
-
import { cwd } from "process";
|
|
3
|
-
import { declarationTransformer, transformer } from "@deepkit/type-compiler";
|
|
4
|
-
import { readFile } from "fs/promises";
|
|
5
|
-
|
|
6
|
-
export default function deepkitType(options = {}){
|
|
7
|
-
return {
|
|
8
|
-
name: "Deepkit",
|
|
9
|
-
setup(build) {
|
|
10
|
-
const transformers = options.transformers || {
|
|
11
|
-
before: [transformer],
|
|
12
|
-
after: [declarationTransformer],
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
build.onLoad({ filter: /\.tsx?$/ }, async (args) => {
|
|
16
|
-
const configFilePath = options.tsConfig || cwd() + "/tsconfig.json";
|
|
17
|
-
|
|
18
|
-
const code = await readFile(args.path, { encoding: 'utf8' });
|
|
19
|
-
const transformed = ts.transpileModule(code, {
|
|
20
|
-
compilerOptions: Object.assign(
|
|
21
|
-
{
|
|
22
|
-
target: ts.ScriptTarget.ESNext,
|
|
23
|
-
module: ts.ModuleKind.ESNext,
|
|
24
|
-
sourceMap: false,
|
|
25
|
-
skipDefaultLibCheck: true,
|
|
26
|
-
skipLibCheck: true,
|
|
27
|
-
configFilePath,
|
|
28
|
-
},
|
|
29
|
-
options || {},
|
|
30
|
-
),
|
|
31
|
-
fileName: args.path,
|
|
32
|
-
moduleName: args.namespace,
|
|
33
|
-
transformers,
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
return {
|
|
37
|
-
contents: transformed.outputText,
|
|
38
|
-
loader: args.path.endsWith('.tsx') ? 'tsx' : 'ts'
|
|
39
|
-
};
|
|
40
|
-
});
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
}
|
|
@@ -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()
|
|
@@ -1,35 +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 type AppDispatch = typeof store.dispatch;
|
|
30
|
-
export type RootState = ReturnType<typeof store.getState>;
|
|
31
|
-
export type AppStore = typeof store;
|
|
32
|
-
|
|
33
|
-
export const useAppDispatch = useDispatch.withTypes<AppDispatch>();
|
|
34
|
-
export const useAppSelector = useSelector.withTypes<RootState>();
|
|
35
|
-
export const useAppStore = useStore.withTypes<AppStore>();
|