shinkansen-pantograph 1.3.355 → 1.4.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.
- package/README.md +16 -10
- package/babel.config.cjs +1 -12
- package/eslint.config.mjs +73 -0
- package/index.d.mts +133 -0
- package/jsconfig.json +5 -0
- package/package.json +21 -14
- package/src/index.cjs +1 -1
- package/src/index.d.cts +2 -0
- package/src/index.d.mts +1 -3
- package/src/pantograph/index.d.mts +26 -21
- package/src/pantograph/index.mjs +80 -7
- package/src/pantograph/pantograph.d.mts +21 -0
- package/src/pantograph/pantograph.mjs +23 -0
- package/tsconfig.json +2 -1
package/README.md
CHANGED
|
@@ -12,19 +12,25 @@ import {
|
|
|
12
12
|
} from 'shinkansen-pantograph'
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
*Pantograph* exposes constants to be used by *Redux* actions and reducers, and the method `graphite` to raise *React Router* navigation events in middleware.
|
|
16
|
-
|
|
17
15
|
```javascript
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
import Pantograph, {
|
|
17
|
+
getRedirectToAlpha,
|
|
18
|
+
getRedirectToOmega,
|
|
19
|
+
getRedirectToEmbark,
|
|
20
|
+
getRedirectToDebark,
|
|
21
|
+
getRedirectToConfirm,
|
|
22
|
+
getRedirectFromAlpha,
|
|
23
|
+
getRedirectFromOmega,
|
|
24
|
+
getRedirectFromEmbark,
|
|
25
|
+
getRedirectFromDebark,
|
|
26
|
+
getRedirectFromConfirm,
|
|
27
|
+
getRedirectTo,
|
|
28
|
+
graphite
|
|
29
|
+
} from 'shinkansen-pantograph/pantograph'
|
|
26
30
|
```
|
|
27
31
|
|
|
32
|
+
*Pantograph* exposes constants to be used by *Redux* actions and reducers and the method `graphite` to resolve *React Router* paths from *Zashiki* route resource objects.
|
|
33
|
+
|
|
28
34
|
## See also
|
|
29
35
|
|
|
30
36
|
- [Gears](https://github.com/modernpoacher/shinkansen-gears)
|
package/babel.config.cjs
CHANGED
|
@@ -38,23 +38,12 @@ const presets = [
|
|
|
38
38
|
]
|
|
39
39
|
]
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
[
|
|
43
|
-
'module-resolver', {
|
|
44
|
-
alias: {
|
|
45
|
-
'shinkansen-pantograph/pantograph': './src/pantograph/index.mjs',
|
|
46
|
-
'shinkansen-pantograph': './src/index.cjs'
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
]
|
|
50
|
-
]
|
|
51
|
-
|
|
41
|
+
// @ts-expect-error
|
|
52
42
|
module.exports = (api) => {
|
|
53
43
|
if (api) api.cache.using(env)
|
|
54
44
|
|
|
55
45
|
return {
|
|
56
46
|
presets,
|
|
57
|
-
plugins,
|
|
58
47
|
ignore: [
|
|
59
48
|
/node_modules\/(?!shinkansen|@modernpoacher)/
|
|
60
49
|
]
|
|
@@ -0,0 +1,73 @@
|
|
|
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
|
+
|
|
5
|
+
export default [
|
|
6
|
+
/**
|
|
7
|
+
* Standard config
|
|
8
|
+
*/
|
|
9
|
+
standard({
|
|
10
|
+
files: [
|
|
11
|
+
'**/*.{mjs,cjs,mts,cts}'
|
|
12
|
+
],
|
|
13
|
+
ignores: [
|
|
14
|
+
'src',
|
|
15
|
+
'test'
|
|
16
|
+
],
|
|
17
|
+
languageOptions: {
|
|
18
|
+
globals: {
|
|
19
|
+
...globals.node
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}),
|
|
23
|
+
standard({
|
|
24
|
+
files: [
|
|
25
|
+
'src/**/*.{mjs,cjs,mts,cts}'
|
|
26
|
+
],
|
|
27
|
+
languageOptions: {
|
|
28
|
+
globals: {
|
|
29
|
+
...globals.browser
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}),
|
|
33
|
+
standard({
|
|
34
|
+
files: [
|
|
35
|
+
'test/**/*.{mjs,cjs,mts,cts}'
|
|
36
|
+
],
|
|
37
|
+
languageOptions: {
|
|
38
|
+
globals: {
|
|
39
|
+
...globals.mocha
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}),
|
|
43
|
+
/**
|
|
44
|
+
* TypeScript config
|
|
45
|
+
*/
|
|
46
|
+
typescript({
|
|
47
|
+
files: [
|
|
48
|
+
'**/*.{mts,cts}'
|
|
49
|
+
],
|
|
50
|
+
ignores: [
|
|
51
|
+
'src',
|
|
52
|
+
'test'
|
|
53
|
+
],
|
|
54
|
+
languageOptions: {
|
|
55
|
+
globals: {
|
|
56
|
+
...globals.node,
|
|
57
|
+
PantographTypes: 'readonly'
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}),
|
|
61
|
+
typescript({
|
|
62
|
+
files: [
|
|
63
|
+
'src/**/*.{mts,cts}',
|
|
64
|
+
'test/**/*.{mts,cts}'
|
|
65
|
+
],
|
|
66
|
+
languageOptions: {
|
|
67
|
+
globals: {
|
|
68
|
+
...globals.browser,
|
|
69
|
+
PantographTypes: 'readonly'
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
]
|
package/index.d.mts
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
namespace PantographTypes {
|
|
3
|
+
export type ResourceType = Record<string, unknown> | Record<string, never>
|
|
4
|
+
|
|
5
|
+
export interface ActionType {
|
|
6
|
+
type?: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type StateType = Record<string, unknown> | Record<string, never>
|
|
10
|
+
|
|
11
|
+
export interface RouteType {
|
|
12
|
+
pathname: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface RedirectToAlphaParams {
|
|
16
|
+
alpha: ResourceType
|
|
17
|
+
route: RouteType
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface RedirectToOmegaParams {
|
|
21
|
+
alpha: ResourceType
|
|
22
|
+
omega: ResourceType
|
|
23
|
+
route: RouteType
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface RedirectToEmbarkParams {
|
|
27
|
+
embark: ResourceType
|
|
28
|
+
route: RouteType
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface RedirectToDebarkParams {
|
|
32
|
+
debark: ResourceType
|
|
33
|
+
route: RouteType
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface RedirectToConfirmParams {
|
|
37
|
+
confirm: ResourceType
|
|
38
|
+
route: RouteType
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface RedirectToParams {
|
|
42
|
+
redirect?: ResourceType
|
|
43
|
+
route: RouteType
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface RedirectFromAlphaParams {
|
|
47
|
+
state: StateType
|
|
48
|
+
route: RouteType
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface RedirectFromOmegaParams {
|
|
52
|
+
state: StateType
|
|
53
|
+
route: RouteType
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface RedirectFromEmbarkParams {
|
|
57
|
+
state: StateType
|
|
58
|
+
route: RouteType
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface RedirectFromDebarkParams {
|
|
62
|
+
state: StateType
|
|
63
|
+
route: RouteType
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface RedirectFromConfirmParams {
|
|
67
|
+
state: StateType
|
|
68
|
+
route: RouteType
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface GraphiteParams {
|
|
72
|
+
action: ActionType
|
|
73
|
+
state: StateType
|
|
74
|
+
route: RouteType
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export namespace Pantograph {
|
|
78
|
+
export interface AlphaType {
|
|
79
|
+
ERROR: string
|
|
80
|
+
ROUTE: string
|
|
81
|
+
MOUNT: string
|
|
82
|
+
FETCH: string
|
|
83
|
+
STORE: string
|
|
84
|
+
QUERY: string
|
|
85
|
+
CHANGE: string
|
|
86
|
+
SUBMIT: string
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface OmegaType {
|
|
90
|
+
ERROR: string
|
|
91
|
+
ROUTE: string
|
|
92
|
+
MOUNT: string
|
|
93
|
+
FETCH: string
|
|
94
|
+
STORE: string
|
|
95
|
+
QUERY: string
|
|
96
|
+
CHANGE: string
|
|
97
|
+
SUBMIT: string
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface EmbarkType {
|
|
101
|
+
ERROR: string
|
|
102
|
+
ROUTE: string
|
|
103
|
+
MOUNT: string
|
|
104
|
+
FETCH: string
|
|
105
|
+
STORE: string
|
|
106
|
+
CHANGE: string
|
|
107
|
+
SUBMIT: string
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface DebarkType {
|
|
111
|
+
ERROR: string
|
|
112
|
+
ROUTE: string
|
|
113
|
+
MOUNT: string
|
|
114
|
+
FETCH: string
|
|
115
|
+
STORE: string
|
|
116
|
+
CHANGE: string
|
|
117
|
+
SUBMIT: string
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export interface ConfirmType {
|
|
121
|
+
ERROR: string
|
|
122
|
+
ROUTE: string
|
|
123
|
+
MOUNT: string
|
|
124
|
+
FETCH: string
|
|
125
|
+
STORE: string
|
|
126
|
+
CHANGE: string
|
|
127
|
+
SUBMIT: string
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export {}
|
package/jsconfig.json
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shinkansen-pantograph",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "Shinkansen Pantograph",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Shinkansen",
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
"React",
|
|
12
12
|
"Router"
|
|
13
13
|
],
|
|
14
|
-
"main": "./src/index.
|
|
14
|
+
"main": "./src/index.mjs",
|
|
15
15
|
"type": "module",
|
|
16
|
-
"types": "./
|
|
16
|
+
"types": "./index.d.mts",
|
|
17
17
|
"author": {
|
|
18
18
|
"name": "Jonathan Perry for Modern Poacher Limited",
|
|
19
19
|
"email": "modernpoacher@modernpoacher.com",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"url": "git+ssh://git@github.com/modernpoacher/shinkansen-pantograph.git"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
|
-
"lint": "eslint .
|
|
31
|
+
"lint": "eslint .",
|
|
32
32
|
"lint:fix": "npm run lint -- --fix",
|
|
33
33
|
"nvm": "bash nvm.sh",
|
|
34
34
|
"prelint": "npm run nvm",
|
|
@@ -43,26 +43,33 @@
|
|
|
43
43
|
"@babel/core": "^7.26.9",
|
|
44
44
|
"@babel/eslint-parser": "^7.26.8",
|
|
45
45
|
"@babel/preset-env": "^7.26.9",
|
|
46
|
+
"@babel/preset-react": "^7.26.3",
|
|
46
47
|
"@babel/register": "^7.25.9",
|
|
48
|
+
"@sequencemedia/eslint-config-standard": "^0.2.36",
|
|
49
|
+
"@sequencemedia/eslint-config-typescript": "^0.1.51",
|
|
47
50
|
"@sequencemedia/sinon-chai": "^0.0.124",
|
|
48
|
-
"@types/
|
|
49
|
-
"@
|
|
50
|
-
"@
|
|
51
|
-
"
|
|
51
|
+
"@types/babel__register": "^7.17.3",
|
|
52
|
+
"@types/chai": "^5.0.1",
|
|
53
|
+
"@types/debug": "^4.1.12",
|
|
54
|
+
"@types/mocha": "^10.0.10",
|
|
55
|
+
"@types/sinon": "^17.0.4",
|
|
52
56
|
"chai": "^5.2.0",
|
|
53
|
-
"core-js": "^3.40.0",
|
|
54
57
|
"cross-env": "^7.0.3",
|
|
55
|
-
"eslint": "
|
|
56
|
-
"
|
|
57
|
-
"eslint-config-standard": "^17.1.0",
|
|
58
|
-
"eslint-import-resolver-babel-module": "^5.3.2",
|
|
58
|
+
"eslint": "^9.21.0",
|
|
59
|
+
"globals": "^16.0.0",
|
|
59
60
|
"husky": "^9.1.7",
|
|
60
61
|
"mocha": "^11.1.0",
|
|
61
|
-
"rimraf": "^6.0.1",
|
|
62
62
|
"shinkansen-rails": "1.0.293",
|
|
63
63
|
"shinkansen-signals": "1.1.222",
|
|
64
64
|
"sinon": "^19.0.2"
|
|
65
65
|
},
|
|
66
|
+
"imports": {
|
|
67
|
+
"#pantograph": {
|
|
68
|
+
"require": "./src/index.cjs",
|
|
69
|
+
"import": "./src/index.mjs"
|
|
70
|
+
},
|
|
71
|
+
"#pantograph/pantograph": "./src/pantograph/index.mjs"
|
|
72
|
+
},
|
|
66
73
|
"exports": {
|
|
67
74
|
".": {
|
|
68
75
|
"require": "./src/index.cjs",
|
package/src/index.cjs
CHANGED
package/src/index.d.cts
ADDED
package/src/index.d.mts
CHANGED
|
@@ -1,24 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export type RedirectToAlphaParams = PantographTypes.RedirectToAlphaParams
|
|
2
|
+
export type RedirectToOmegaParams = PantographTypes.RedirectToOmegaParams
|
|
3
|
+
export type RedirectToEmbarkParams = PantographTypes.RedirectToEmbarkParams
|
|
4
|
+
export type RedirectToDebarkParams = PantographTypes.RedirectToDebarkParams
|
|
5
|
+
export type RedirectToConfirmParams = PantographTypes.RedirectToConfirmParams
|
|
6
|
+
export type RedirectToParams = PantographTypes.RedirectToParams
|
|
7
|
+
export type RedirectFromAlphaParams = PantographTypes.RedirectFromAlphaParams
|
|
8
|
+
export type RedirectFromOmegaParams = PantographTypes.RedirectFromOmegaParams
|
|
9
|
+
export type RedirectFromEmbarkParams = PantographTypes.RedirectFromEmbarkParams
|
|
10
|
+
export type RedirectFromDebarkParams = PantographTypes.RedirectFromDebarkParams
|
|
11
|
+
export type RedirectFromConfirmParams = PantographTypes.RedirectFromConfirmParams
|
|
12
|
+
export type GraphiteParams = PantographTypes.GraphiteParams
|
|
3
13
|
|
|
4
|
-
|
|
5
|
-
pathname: string
|
|
6
|
-
}
|
|
14
|
+
declare const pantograph: Record<string, Record<string, string>>
|
|
7
15
|
|
|
8
|
-
|
|
16
|
+
export function getRedirectToAlpha (alpha: RedirectToAlphaParams): string | undefined
|
|
17
|
+
export function getRedirectToOmega (omega: RedirectToOmegaParams): string | undefined
|
|
18
|
+
export function getRedirectToEmbark (embark: RedirectToEmbarkParams): string | undefined
|
|
19
|
+
export function getRedirectToDebark (debark: RedirectToDebarkParams): string | undefined
|
|
20
|
+
export function getRedirectToConfirm (confirm: RedirectToConfirmParams): string | undefined
|
|
21
|
+
export function getRedirectTo (to: RedirectToParams): string | undefined
|
|
22
|
+
export function getRedirectFromAlpha (alpha: RedirectFromAlphaParams): string | undefined
|
|
23
|
+
export function getRedirectFromOmega (omega: RedirectFromOmegaParams): string | undefined
|
|
24
|
+
export function getRedirectFromEmbark (embark: RedirectFromEmbarkParams): string | undefined
|
|
25
|
+
export function getRedirectFromDebark (debark: RedirectFromDebarkParams): string | undefined
|
|
26
|
+
export function getRedirectFromConfirm (confirm: RedirectFromConfirmParams): string | undefined
|
|
27
|
+
export function graphite (params: GraphiteParams): string | undefined
|
|
9
28
|
|
|
10
|
-
|
|
11
|
-
export function getRedirectToOmega (omega: { omega: Record<string, unknown>, route: RouteType }): React.JSX.Element | null
|
|
12
|
-
export function getRedirectToEmbark (embark: { embark: Record<string, unknown>, route: RouteType }): React.JSX.Element | null
|
|
13
|
-
export function getRedirectToDebark (debark: { debark: Record<string, unknown>, route: RouteType }): React.JSX.Element | null
|
|
14
|
-
export function getRedirectToConfirm (confirm: { confirm: Record<string, unknown>, route: RouteType }): React.JSX.Element | null
|
|
15
|
-
export function getRedirectTo (to: { redirect?: Record<string, unknown>, route: RouteType }): React.JSX.Element | null
|
|
16
|
-
export function getRedirectFromAlpha (alpha: { state: Record<string, unknown>, route: RouteType }): React.JSX.Element | null
|
|
17
|
-
export function getRedirectFromOmega (omega: { state: Record<string, unknown>, route: RouteType }): React.JSX.Element | null
|
|
18
|
-
export function getRedirectFromEmbark (embark: { state: Record<string, unknown>, route: RouteType }): React.JSX.Element | null
|
|
19
|
-
export function getRedirectFromDebark (debark: { state: Record<string, unknown>, route: string }): React.JSX.Element | null
|
|
20
|
-
export function getRedirectFromConfirm (confirm: { state: Record<string, unknown>, route: RouteType }): React.JSX.Element | null
|
|
21
|
-
export function graphite (params: { action: Record<string, unknown>, state: Record<string, unknown>, route: RouteType }): undefined
|
|
22
|
-
|
|
23
|
-
export default pantograph
|
|
24
|
-
}
|
|
29
|
+
export default pantograph
|
package/src/pantograph/index.mjs
CHANGED
|
@@ -1,18 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef
|
|
3
|
-
*
|
|
4
|
-
* }
|
|
2
|
+
* @typedef {PantographTypes.ActionType} ActionType
|
|
3
|
+
* @typedef {PantographTypes.StateType} StateType
|
|
4
|
+
* @typedef {PantographTypes.RouteType} RouteType
|
|
5
|
+
*
|
|
6
|
+
* @typedef {PantographTypes.RedirectToAlphaParams} RedirectToAlphaParams
|
|
7
|
+
* @typedef {PantographTypes.RedirectToOmegaParams} RedirectToOmegaParams
|
|
8
|
+
* @typedef {PantographTypes.RedirectToEmbarkParams} RedirectToEmbarkParams
|
|
9
|
+
* @typedef {PantographTypes.RedirectToDebarkParams} RedirectToDebarkParams
|
|
10
|
+
* @typedef {PantographTypes.RedirectToConfirmParams} RedirectToConfirmParams
|
|
11
|
+
* @typedef {PantographTypes.RedirectToParams} RedirectToParams
|
|
12
|
+
*
|
|
13
|
+
* @typedef {PantographTypes.RedirectFromAlphaParams} RedirectFromAlphaParams
|
|
14
|
+
* @typedef {PantographTypes.RedirectFromOmegaParams} RedirectFromOmegaParams
|
|
15
|
+
* @typedef {PantographTypes.RedirectFromEmbarkParams} RedirectFromEmbarkParams
|
|
16
|
+
* @typedef {PantographTypes.RedirectFromDebarkParams} RedirectFromDebarkParams
|
|
17
|
+
* @typedef {PantographTypes.RedirectFromConfirmParams} RedirectFromConfirmParams
|
|
18
|
+
* @typedef {PantographTypes.GraphiteParams} GraphiteParams
|
|
5
19
|
*/
|
|
6
|
-
import debug from 'debug'
|
|
7
20
|
|
|
8
|
-
import
|
|
9
|
-
Rails
|
|
10
|
-
} from 'shinkansen-rails'
|
|
21
|
+
import debug from 'debug'
|
|
11
22
|
|
|
12
23
|
import {
|
|
13
24
|
Signals
|
|
14
25
|
} from 'shinkansen-signals'
|
|
15
26
|
|
|
27
|
+
import {
|
|
28
|
+
Rails
|
|
29
|
+
} from 'shinkansen-rails'
|
|
30
|
+
|
|
16
31
|
import pantograph, {
|
|
17
32
|
ALPHA,
|
|
18
33
|
OMEGA,
|
|
@@ -25,12 +40,25 @@ const log = debug('shinkansen-pantograph/pantograph')
|
|
|
25
40
|
|
|
26
41
|
log('`shinkansen` is awake')
|
|
27
42
|
|
|
43
|
+
/**
|
|
44
|
+
* @type {ActionType}
|
|
45
|
+
*/
|
|
28
46
|
const ACTION = {}
|
|
29
47
|
|
|
48
|
+
/**
|
|
49
|
+
* @type {StateType}
|
|
50
|
+
*/
|
|
30
51
|
const STATE = {}
|
|
31
52
|
|
|
53
|
+
/**
|
|
54
|
+
* @type {RouteType}
|
|
55
|
+
*/
|
|
32
56
|
const ROUTE = {}
|
|
33
57
|
|
|
58
|
+
/**
|
|
59
|
+
* @param {RedirectToAlphaParams} params
|
|
60
|
+
* @returns {string | undefined}
|
|
61
|
+
*/
|
|
34
62
|
export function getRedirectToAlpha ({ alpha, route }) {
|
|
35
63
|
log('getRedirectToAlpha')
|
|
36
64
|
|
|
@@ -42,6 +70,10 @@ export function getRedirectToAlpha ({ alpha, route }) {
|
|
|
42
70
|
if (pathname !== currentPathname) return pathname
|
|
43
71
|
}
|
|
44
72
|
|
|
73
|
+
/**
|
|
74
|
+
* @param {RedirectToOmegaParams} params
|
|
75
|
+
* @returns {string | undefined}
|
|
76
|
+
*/
|
|
45
77
|
export function getRedirectToOmega ({ alpha, omega, route }) {
|
|
46
78
|
log('getRedirectToOmega')
|
|
47
79
|
|
|
@@ -53,6 +85,10 @@ export function getRedirectToOmega ({ alpha, omega, route }) {
|
|
|
53
85
|
if (pathname !== currentPathname) return pathname
|
|
54
86
|
}
|
|
55
87
|
|
|
88
|
+
/**
|
|
89
|
+
* @param {RedirectToEmbarkParams} params
|
|
90
|
+
* @returns {string | undefined}
|
|
91
|
+
*/
|
|
56
92
|
export function getRedirectToEmbark ({ embark, route }) {
|
|
57
93
|
log('getRedirectToEmbark')
|
|
58
94
|
|
|
@@ -64,6 +100,10 @@ export function getRedirectToEmbark ({ embark, route }) {
|
|
|
64
100
|
if (pathname !== currentPathname) return pathname
|
|
65
101
|
}
|
|
66
102
|
|
|
103
|
+
/**
|
|
104
|
+
* @param {RedirectToDebarkParams} params
|
|
105
|
+
* @returns {string | undefined}
|
|
106
|
+
*/
|
|
67
107
|
export function getRedirectToDebark ({ debark, route }) {
|
|
68
108
|
log('getRedirectToDebark')
|
|
69
109
|
|
|
@@ -75,6 +115,10 @@ export function getRedirectToDebark ({ debark, route }) {
|
|
|
75
115
|
if (pathname !== currentPathname) return pathname
|
|
76
116
|
}
|
|
77
117
|
|
|
118
|
+
/**
|
|
119
|
+
* @param {RedirectToConfirmParams} params
|
|
120
|
+
* @returns {string | undefined}
|
|
121
|
+
*/
|
|
78
122
|
export function getRedirectToConfirm ({ confirm, route }) {
|
|
79
123
|
log('getRedirectToDebark')
|
|
80
124
|
|
|
@@ -86,6 +130,10 @@ export function getRedirectToConfirm ({ confirm, route }) {
|
|
|
86
130
|
if (pathname !== currentPathname) return pathname
|
|
87
131
|
}
|
|
88
132
|
|
|
133
|
+
/**
|
|
134
|
+
* @param {RedirectToParams} params
|
|
135
|
+
* @returns {string | undefined}
|
|
136
|
+
*/
|
|
89
137
|
export function getRedirectTo ({
|
|
90
138
|
redirect: {
|
|
91
139
|
[Signals.ALPHA]: alpha,
|
|
@@ -113,36 +161,61 @@ export function getRedirectTo ({
|
|
|
113
161
|
}
|
|
114
162
|
}
|
|
115
163
|
|
|
164
|
+
/**
|
|
165
|
+
* @param {RedirectFromAlphaParams} params
|
|
166
|
+
* @returns {string | undefined}
|
|
167
|
+
*/
|
|
116
168
|
export function getRedirectFromAlpha ({ state: { [Signals.ALPHA]: { redirect } = {} } = {}, route }) {
|
|
117
169
|
log('getRedirectFromAlpha')
|
|
118
170
|
|
|
119
171
|
if (redirect) return getRedirectTo({ redirect, route })
|
|
120
172
|
}
|
|
121
173
|
|
|
174
|
+
/**
|
|
175
|
+
* @param {RedirectFromOmegaParams} params
|
|
176
|
+
* @returns {string | undefined}
|
|
177
|
+
*/
|
|
178
|
+
|
|
122
179
|
export function getRedirectFromOmega ({ state: { [Signals.OMEGA]: { redirect } = {} } = {}, route }) {
|
|
123
180
|
log('getRedirectFromOmega')
|
|
124
181
|
|
|
125
182
|
if (redirect) return getRedirectTo({ redirect, route })
|
|
126
183
|
}
|
|
127
184
|
|
|
185
|
+
/**
|
|
186
|
+
* @param {RedirectFromEmbarkParams} params
|
|
187
|
+
* @returns {string | undefined}
|
|
188
|
+
*/
|
|
128
189
|
export function getRedirectFromEmbark ({ state: { [Signals.EMBARK]: { redirect } = {} } = {}, route }) {
|
|
129
190
|
log('getRedirectFromEmbark')
|
|
130
191
|
|
|
131
192
|
if (redirect) return getRedirectTo({ redirect, route })
|
|
132
193
|
}
|
|
133
194
|
|
|
195
|
+
/**
|
|
196
|
+
* @param {RedirectFromDebarkParams} params
|
|
197
|
+
* @returns {string | undefined}
|
|
198
|
+
*/
|
|
134
199
|
export function getRedirectFromDebark ({ state: { [Signals.DEBARK]: { redirect } = {} } = {}, route }) {
|
|
135
200
|
log('getRedirectFromDebark')
|
|
136
201
|
|
|
137
202
|
if (redirect) return getRedirectTo({ redirect, route })
|
|
138
203
|
}
|
|
139
204
|
|
|
205
|
+
/**
|
|
206
|
+
* @param {RedirectFromConfirmParams} params
|
|
207
|
+
* @returns {string | undefined}
|
|
208
|
+
*/
|
|
140
209
|
export function getRedirectFromConfirm ({ state: { [Signals.CONFIRM]: { redirect } = {} } = {}, route }) {
|
|
141
210
|
log('getRedirectFromConfirm')
|
|
142
211
|
|
|
143
212
|
if (redirect) return getRedirectTo({ redirect, route })
|
|
144
213
|
}
|
|
145
214
|
|
|
215
|
+
/**
|
|
216
|
+
* @param {GraphiteParams} params
|
|
217
|
+
* @returns {string | undefined}
|
|
218
|
+
*/
|
|
146
219
|
export function graphite ({ action: { type } = ACTION, state = STATE, route = ROUTE }) {
|
|
147
220
|
switch (type) {
|
|
148
221
|
case OMEGA.ROUTE:
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type AlphaType = PantographTypes.Pantograph.AlphaType
|
|
2
|
+
export type OmegaType = PantographTypes.Pantograph.OmegaType
|
|
3
|
+
export type EmbarkType = PantographTypes.Pantograph.EmbarkType
|
|
4
|
+
export type DebarkType = PantographTypes.Pantograph.DebarkType
|
|
5
|
+
export type ConfirmType = PantographTypes.Pantograph.ConfirmType
|
|
6
|
+
|
|
7
|
+
export declare const ALPHA: AlphaType
|
|
8
|
+
export declare const OMEGA: OmegaType
|
|
9
|
+
export declare const EMBARK: EmbarkType
|
|
10
|
+
export declare const DEBARK: DebarkType
|
|
11
|
+
export declare const CONFIRM: ConfirmType
|
|
12
|
+
|
|
13
|
+
declare const pantograph: {
|
|
14
|
+
ALPHA: AlphaType
|
|
15
|
+
OMEGA: OmegaType
|
|
16
|
+
EMBARK: EmbarkType
|
|
17
|
+
DEBARK: DebarkType
|
|
18
|
+
CONFIRM: ConfirmType
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default pantograph
|
|
@@ -1,9 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {PantographTypes.Pantograph.AlphaType} AlphaType
|
|
3
|
+
* @typedef {PantographTypes.Pantograph.OmegaType} OmegaType
|
|
4
|
+
* @typedef {PantographTypes.Pantograph.EmbarkType} EmbarkType
|
|
5
|
+
* @typedef {PantographTypes.Pantograph.DebarkType} DebarkType
|
|
6
|
+
* @typedef {PantographTypes.Pantograph.ConfirmType} ConfirmType
|
|
7
|
+
*/
|
|
8
|
+
|
|
1
9
|
import debug from 'debug'
|
|
2
10
|
|
|
3
11
|
const log = debug('shinkansen-pantograph/pantograph')
|
|
4
12
|
|
|
5
13
|
log('`shinkansen` is awake')
|
|
6
14
|
|
|
15
|
+
/**
|
|
16
|
+
* @type {AlphaType}
|
|
17
|
+
*/
|
|
7
18
|
export const ALPHA = {
|
|
8
19
|
ERROR: 'ALPHA_ERROR',
|
|
9
20
|
ROUTE: 'ALPHA_ROUTE',
|
|
@@ -15,6 +26,9 @@ export const ALPHA = {
|
|
|
15
26
|
SUBMIT: 'ALPHA_SUBMIT'
|
|
16
27
|
}
|
|
17
28
|
|
|
29
|
+
/**
|
|
30
|
+
* @type {OmegaType}
|
|
31
|
+
*/
|
|
18
32
|
export const OMEGA = {
|
|
19
33
|
ERROR: 'OMEGA_ERROR',
|
|
20
34
|
ROUTE: 'OMEGA_ROUTE',
|
|
@@ -26,6 +40,9 @@ export const OMEGA = {
|
|
|
26
40
|
SUBMIT: 'OMEGA_SUBMIT'
|
|
27
41
|
}
|
|
28
42
|
|
|
43
|
+
/**
|
|
44
|
+
* @type {EmbarkType}
|
|
45
|
+
*/
|
|
29
46
|
export const EMBARK = {
|
|
30
47
|
ERROR: 'EMBARK_ERROR',
|
|
31
48
|
ROUTE: 'EMBARK_ROUTE',
|
|
@@ -36,6 +53,9 @@ export const EMBARK = {
|
|
|
36
53
|
SUBMIT: 'EMBARK_SUBMIT'
|
|
37
54
|
}
|
|
38
55
|
|
|
56
|
+
/**
|
|
57
|
+
* @type {DebarkType}
|
|
58
|
+
*/
|
|
39
59
|
export const DEBARK = {
|
|
40
60
|
ERROR: 'DEBARK_ERROR',
|
|
41
61
|
ROUTE: 'DEBARK_ROUTE',
|
|
@@ -46,6 +66,9 @@ export const DEBARK = {
|
|
|
46
66
|
SUBMIT: 'DEBARK_SUBMIT'
|
|
47
67
|
}
|
|
48
68
|
|
|
69
|
+
/**
|
|
70
|
+
* @type {ConfirmType}
|
|
71
|
+
*/
|
|
49
72
|
export const CONFIRM = {
|
|
50
73
|
ERROR: 'CONFIRM_ERROR',
|
|
51
74
|
ROUTE: 'CONFIRM_ROUTE',
|