@sequencemedia/react-redux-render 2.3.52 → 2.3.53
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.
- package/babel.config.cjs +3 -1
- package/eslint.config.mjs +147 -0
- package/index.d.mts +10 -0
- package/package.json +17 -5
- package/src/index.d.cts +5 -0
- package/src/index.d.mts +5 -0
- package/src/index.mjs +30 -16
- package/src/react-dom-server.cjs +3 -1
- package/src/react-dom-server.d.cts +4 -0
- package/src/react-dom-server.d.mts +10 -0
- package/src/react-dom-server.jsx +31 -19
- package/tsconfig.json +25 -0
package/babel.config.cjs
CHANGED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import globals from 'globals'
|
|
2
|
+
import standard from '@sequencemedia/eslint-config-standard/configs/recommended/merge'
|
|
3
|
+
import typescript from '@sequencemedia/eslint-config-typescript/configs/recommended/merge'
|
|
4
|
+
import babelParser from '@babel/eslint-parser'
|
|
5
|
+
import typescriptParser from '@typescript-eslint/parser'
|
|
6
|
+
import reactPlugin from 'eslint-plugin-react'
|
|
7
|
+
|
|
8
|
+
const reactParserOptions = {
|
|
9
|
+
ecmaFeatures: {
|
|
10
|
+
jsx: true
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const reactPlugins = {
|
|
15
|
+
react: reactPlugin
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const reactRules = {
|
|
19
|
+
'no-unused-vars': [
|
|
20
|
+
'error',
|
|
21
|
+
{
|
|
22
|
+
varsIgnorePattern: 'React'
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
quotes: [
|
|
26
|
+
'error',
|
|
27
|
+
'single'
|
|
28
|
+
],
|
|
29
|
+
'jsx-quotes': [
|
|
30
|
+
'error',
|
|
31
|
+
'prefer-single'
|
|
32
|
+
],
|
|
33
|
+
'react/jsx-indent': [
|
|
34
|
+
'error',
|
|
35
|
+
2,
|
|
36
|
+
{
|
|
37
|
+
checkAttributes: true,
|
|
38
|
+
indentLogicalExpressions: true
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const reactSettings = {
|
|
44
|
+
react: {
|
|
45
|
+
version: 'detect'
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default [
|
|
50
|
+
{
|
|
51
|
+
ignores: [
|
|
52
|
+
'coverage'
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
/**
|
|
56
|
+
* React config for all `jsx` files
|
|
57
|
+
*/
|
|
58
|
+
{
|
|
59
|
+
...reactPlugin.configs.flat.recommended,
|
|
60
|
+
settings: {
|
|
61
|
+
...reactSettings
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
/**
|
|
65
|
+
* Standard config
|
|
66
|
+
*/
|
|
67
|
+
standard({
|
|
68
|
+
files: [
|
|
69
|
+
'**/*.{mjs,cjs,mts,cts}'
|
|
70
|
+
],
|
|
71
|
+
ignores: [
|
|
72
|
+
'src',
|
|
73
|
+
'test'
|
|
74
|
+
],
|
|
75
|
+
languageOptions: {
|
|
76
|
+
globals: {
|
|
77
|
+
...globals.node
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}),
|
|
81
|
+
standard({
|
|
82
|
+
files: [
|
|
83
|
+
'src/**/*.{mjs,cjs,mts,cts}'
|
|
84
|
+
],
|
|
85
|
+
languageOptions: {
|
|
86
|
+
globals: {
|
|
87
|
+
...globals.node
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}),
|
|
91
|
+
standard({
|
|
92
|
+
files: [
|
|
93
|
+
'test/**/*.{mjs,cjs,mts,cts}'
|
|
94
|
+
],
|
|
95
|
+
languageOptions: {
|
|
96
|
+
globals: {
|
|
97
|
+
...globals.mocha
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}),
|
|
101
|
+
/**
|
|
102
|
+
* Standard config for all `jsx` files
|
|
103
|
+
*/
|
|
104
|
+
standard({
|
|
105
|
+
files: [
|
|
106
|
+
'src/**/*.jsx'
|
|
107
|
+
],
|
|
108
|
+
languageOptions: {
|
|
109
|
+
parser: babelParser,
|
|
110
|
+
parserOptions: {
|
|
111
|
+
...reactParserOptions,
|
|
112
|
+
project: null
|
|
113
|
+
},
|
|
114
|
+
globals: {
|
|
115
|
+
...globals.browser
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
plugins: {
|
|
119
|
+
...reactPlugins
|
|
120
|
+
}, // @ts-expect-error Storybook
|
|
121
|
+
rules: {
|
|
122
|
+
...reactRules
|
|
123
|
+
},
|
|
124
|
+
settings: {
|
|
125
|
+
...reactSettings
|
|
126
|
+
}
|
|
127
|
+
}),
|
|
128
|
+
/**
|
|
129
|
+
* TypeScript config
|
|
130
|
+
*/
|
|
131
|
+
typescript({
|
|
132
|
+
files: [
|
|
133
|
+
'**/*.{mts,cts}'
|
|
134
|
+
],
|
|
135
|
+
languageOptions: {
|
|
136
|
+
parser: typescriptParser,
|
|
137
|
+
parserOptions: {
|
|
138
|
+
projectService: true,
|
|
139
|
+
project: 'tsconfig.json'
|
|
140
|
+
},
|
|
141
|
+
globals: {
|
|
142
|
+
...globals.node,
|
|
143
|
+
ReactReduxRenderTypes: 'readonly'
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
})
|
|
147
|
+
]
|
package/index.d.mts
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sequencemedia/react-redux-render",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.53",
|
|
4
4
|
"description": "React Render",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"React",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
],
|
|
13
13
|
"main": "./src/index.mjs",
|
|
14
14
|
"type": "module",
|
|
15
|
+
"types": "./index.d.mts",
|
|
15
16
|
"author": {
|
|
16
17
|
"name": "Jonathan Perry for Sequence Media Limited",
|
|
17
18
|
"email": "jonathanperry@sequencemedia.net",
|
|
@@ -26,7 +27,7 @@
|
|
|
26
27
|
"url": "git://github.com/sequencemedia/react-redux-render.git"
|
|
27
28
|
},
|
|
28
29
|
"scripts": {
|
|
29
|
-
"lint": "eslint
|
|
30
|
+
"lint": "eslint",
|
|
30
31
|
"lint:fix": "npm run lint -- --fix",
|
|
31
32
|
"prepare": "husky",
|
|
32
33
|
"test": "NODE_ENV=test mocha test --recursive --verbose"
|
|
@@ -37,16 +38,27 @@
|
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
40
|
"@babel/core": "^7.26.9",
|
|
40
|
-
"@babel/eslint-parser": "^7.26.
|
|
41
|
+
"@babel/eslint-parser": "^7.26.10",
|
|
41
42
|
"@babel/preset-env": "^7.26.9",
|
|
42
43
|
"@babel/preset-react": "^7.26.3",
|
|
43
44
|
"@babel/register": "^7.25.9",
|
|
45
|
+
"@sequencemedia/eslint-config-standard": "^0.2.42",
|
|
46
|
+
"@sequencemedia/eslint-config-typescript": "^0.1.60",
|
|
44
47
|
"@sequencemedia/sinon-chai": "^0.0.131",
|
|
48
|
+
"@types/babel__register": "^7.17.3",
|
|
49
|
+
"@types/debug": "^4.1.12",
|
|
50
|
+
"@types/prop-types": "^15.7.14",
|
|
51
|
+
"@types/react": "^19.0.10",
|
|
52
|
+
"@types/react-dom": "^19.0.4",
|
|
53
|
+
"@types/react-redux": "^7.1.34",
|
|
54
|
+
"@types/redux": "^3.6.31",
|
|
55
|
+
"@typescript-eslint/eslint-plugin": "^8.26.1",
|
|
56
|
+
"@typescript-eslint/parser": "^8.26.1",
|
|
45
57
|
"chai": "^5.2.0",
|
|
46
58
|
"core-js": "^3.41.0",
|
|
47
|
-
"eslint": "
|
|
48
|
-
"eslint-config-standard": "^17.1.0",
|
|
59
|
+
"eslint": "^9.22.0",
|
|
49
60
|
"eslint-plugin-react": "^7.37.4",
|
|
61
|
+
"globals": "^16.0.0",
|
|
50
62
|
"husky": "^9.1.7",
|
|
51
63
|
"mocha": "^11.1.0",
|
|
52
64
|
"prop-types": "^15.8.1",
|
package/src/index.d.cts
ADDED
package/src/index.d.mts
ADDED
package/src/index.mjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* @typedef {import('redux').Store} Store
|
|
3
|
+
* @typedef {ReactReduxRenderTypes.ComponentType} ComponentType
|
|
4
|
+
* @typedef {ReactReduxRenderTypes.PropsType} PropsType
|
|
3
5
|
*/
|
|
4
6
|
|
|
5
7
|
import debug from 'debug'
|
|
@@ -14,25 +16,37 @@ const log = debug('@sequencemedia/react-redux-render')
|
|
|
14
16
|
log('`react-redux-render` is awake')
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
19
|
+
* @param {Store} store
|
|
20
|
+
* @param {ComponentType} Component
|
|
21
|
+
* @param {PropsType} props
|
|
22
|
+
* @returns {string}
|
|
21
23
|
*/
|
|
22
|
-
export
|
|
24
|
+
export function renderToString (store, Component, props = {}) {
|
|
25
|
+
return (
|
|
26
|
+
getReactDOMServerRenderToString(store, Component, props)
|
|
27
|
+
)
|
|
28
|
+
}
|
|
23
29
|
|
|
24
30
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
31
|
+
* @param {Store} store
|
|
32
|
+
* @param {ComponentType} Component
|
|
33
|
+
* @param {PropsType} props
|
|
34
|
+
* @returns {string}
|
|
29
35
|
*/
|
|
30
|
-
export
|
|
36
|
+
export function renderToStaticMarkup (store, Component, props = {}) {
|
|
37
|
+
return (
|
|
38
|
+
getReactDOMServerRenderToStaticMarkup(store, Component, props)
|
|
39
|
+
)
|
|
40
|
+
}
|
|
31
41
|
|
|
32
42
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
43
|
+
* @param {Store} store
|
|
44
|
+
* @param {ComponentType} Component
|
|
45
|
+
* @param {PropsType} props
|
|
46
|
+
* @returns {string}
|
|
37
47
|
*/
|
|
38
|
-
export
|
|
48
|
+
export function render (store, Component, props = {}) {
|
|
49
|
+
return (
|
|
50
|
+
getReactDOMServerRenderToString(store, Component, props)
|
|
51
|
+
)
|
|
52
|
+
}
|
package/src/react-dom-server.cjs
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Store } from 'redux'
|
|
2
|
+
|
|
3
|
+
declare module '#react-redux-render/react-dom-server' {
|
|
4
|
+
type ComponentType = ReactReduxRenderTypes.ComponentType
|
|
5
|
+
type PropsType = ReactReduxRenderTypes.PropsType
|
|
6
|
+
|
|
7
|
+
export function getReactDOMServerRenderToString (store: Store, Component: ComponentType, props: PropsType): string
|
|
8
|
+
|
|
9
|
+
export function getReactDOMServerRenderToStaticMarkup (store: Store, Component: ComponentType, props: PropsType): string
|
|
10
|
+
}
|
package/src/react-dom-server.jsx
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* @typedef {import('redux').Store} Store
|
|
3
|
+
* @typedef {ReactReduxRenderTypes.ComponentType} ComponentType
|
|
4
|
+
* @typedef {ReactReduxRenderTypes.PropsType} PropsType
|
|
5
|
+
*
|
|
6
|
+
* @typedef {{
|
|
7
|
+
* props: PropsType
|
|
8
|
+
* }} PropsException
|
|
9
|
+
*
|
|
10
|
+
* @typedef {{
|
|
11
|
+
* e: unknown
|
|
12
|
+
* }} Exception
|
|
3
13
|
*/
|
|
4
14
|
|
|
5
15
|
import debug from 'debug'
|
|
@@ -15,17 +25,21 @@ const log = debug('@sequencemedia/react-redux-render')
|
|
|
15
25
|
log('`react-redux-render` is awake')
|
|
16
26
|
|
|
17
27
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
28
|
+
* @param {Error} e
|
|
29
|
+
* @param {PropsException | Exception} data
|
|
30
|
+
* @returns A boom object
|
|
21
31
|
*/
|
|
22
|
-
|
|
32
|
+
function badImplementation (e, data) {
|
|
33
|
+
return (
|
|
34
|
+
Boom.boomify(e, { statusCode: 500, message: 'Rendering exception', data })
|
|
35
|
+
)
|
|
36
|
+
}
|
|
23
37
|
|
|
24
38
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
39
|
+
* @param {Store} store
|
|
40
|
+
* @param {ComponentType} Component
|
|
41
|
+
* @param {PropsType} props
|
|
42
|
+
* @returns {string}
|
|
29
43
|
*/
|
|
30
44
|
export function getReactDOMServerRenderToString (store, Component, props) {
|
|
31
45
|
try {
|
|
@@ -37,17 +51,16 @@ export function getReactDOMServerRenderToString (store, Component, props) {
|
|
|
37
51
|
</Provider>
|
|
38
52
|
)
|
|
39
53
|
} catch (e) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
throw badImplementation(e, { props })
|
|
54
|
+
if (e instanceof Error) throw badImplementation(e, { props })
|
|
55
|
+
throw badImplementation(new Error('Exception'), { e })
|
|
43
56
|
}
|
|
44
57
|
}
|
|
45
58
|
|
|
46
59
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
60
|
+
* @param {Store} store
|
|
61
|
+
* @param {ComponentType} Component
|
|
62
|
+
* @param {PropsType} props
|
|
63
|
+
* @returns {string}
|
|
51
64
|
*/
|
|
52
65
|
export function getReactDOMServerRenderToStaticMarkup (store, Component, props) {
|
|
53
66
|
try {
|
|
@@ -59,8 +72,7 @@ export function getReactDOMServerRenderToStaticMarkup (store, Component, props)
|
|
|
59
72
|
</Provider>
|
|
60
73
|
)
|
|
61
74
|
} catch (e) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
throw badImplementation(e, { props })
|
|
75
|
+
if (e instanceof Error) throw badImplementation(e, { props })
|
|
76
|
+
throw badImplementation(new Error('Exception'), { e })
|
|
65
77
|
}
|
|
66
78
|
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "NodeNext",
|
|
4
|
+
"target": "ESNext",
|
|
5
|
+
"allowJs": true,
|
|
6
|
+
"checkJs": true,
|
|
7
|
+
"noEmit": true,
|
|
8
|
+
"strict": true,
|
|
9
|
+
"jsx": "react",
|
|
10
|
+
"paths": {
|
|
11
|
+
"#react-redux-render": [
|
|
12
|
+
"./src/index.mjs"
|
|
13
|
+
],
|
|
14
|
+
"#react-redux-render/react-dom-server": [
|
|
15
|
+
"./src/react-dom-server.cjs"
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"include": [
|
|
20
|
+
"."
|
|
21
|
+
],
|
|
22
|
+
"exclude": [
|
|
23
|
+
"test"
|
|
24
|
+
]
|
|
25
|
+
}
|