shinkansen-pantograph 1.4.0 → 1.4.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.
package/index.d.mts CHANGED
@@ -1,15 +1,16 @@
1
1
  declare global {
2
2
  namespace PantographTypes {
3
3
  export type ResourceType = Record<string, unknown> | Record<string, never>
4
+ export type RedirectType = Record<string, ResourceType> | Record<string, never>
4
5
 
5
6
  export interface ActionType {
6
7
  type?: string
7
8
  }
8
9
 
9
- export type StateType = Record<string, unknown> | Record<string, never>
10
+ export type StateType = Record<string, { redirect?: RedirectType }> | Record<string, never>
10
11
 
11
12
  export interface RouteType {
12
- pathname: string
13
+ pathname?: string
13
14
  }
14
15
 
15
16
  export interface RedirectToAlphaParams {
@@ -39,7 +40,7 @@ declare global {
39
40
  }
40
41
 
41
42
  export interface RedirectToParams {
42
- redirect?: ResourceType
43
+ redirect?: RedirectType
43
44
  route: RouteType
44
45
  }
45
46
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shinkansen-pantograph",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
4
4
  "description": "Shinkansen Pantograph",
5
5
  "keywords": [
6
6
  "Shinkansen",
@@ -41,12 +41,10 @@
41
41
  },
42
42
  "devDependencies": {
43
43
  "@babel/core": "^7.26.9",
44
- "@babel/eslint-parser": "^7.26.8",
45
44
  "@babel/preset-env": "^7.26.9",
46
- "@babel/preset-react": "^7.26.3",
47
45
  "@babel/register": "^7.25.9",
48
- "@sequencemedia/eslint-config-standard": "^0.2.35",
49
- "@sequencemedia/eslint-config-typescript": "^0.1.50",
46
+ "@sequencemedia/eslint-config-standard": "^0.2.36",
47
+ "@sequencemedia/eslint-config-typescript": "^0.1.51",
50
48
  "@sequencemedia/sinon-chai": "^0.0.124",
51
49
  "@types/babel__register": "^7.17.3",
52
50
  "@types/chai": "^5.0.1",
@@ -54,6 +52,7 @@
54
52
  "@types/mocha": "^10.0.10",
55
53
  "@types/sinon": "^17.0.4",
56
54
  "chai": "^5.2.0",
55
+ "core-js": "^3.41.0",
57
56
  "cross-env": "^7.0.3",
58
57
  "eslint": "^9.21.0",
59
58
  "globals": "^16.0.0",
@@ -68,13 +67,15 @@
68
67
  "require": "./src/index.cjs",
69
68
  "import": "./src/index.mjs"
70
69
  },
71
- "#pantograph/pantograph": "./src/pantograph/index.mjs"
70
+ "#pantograph/pantograph": "./src/pantograph/index.mjs",
71
+ "#pantograph/pantograph/*": "./src/pantograph/*.mjs"
72
72
  },
73
73
  "exports": {
74
74
  ".": {
75
75
  "require": "./src/index.cjs",
76
76
  "import": "./src/index.mjs"
77
77
  },
78
- "./pantograph": "./src/pantograph/index.mjs"
78
+ "./pantograph": "./src/pantograph/index.mjs",
79
+ "./pantograph/*": "./src/pantograph/*.mjs"
79
80
  }
80
81
  }
package/src/index.cjs CHANGED
@@ -11,7 +11,9 @@ const log = debug('shinkansen-pantograph')
11
11
  log('`shinkansen` is awake')
12
12
 
13
13
  const {
14
- default: Pantograph // @ts-expect-error MJS
14
+ default: Pantograph,
15
+ graphite // @ts-expect-error MJS
15
16
  } = require('./pantograph/index.mjs')
16
17
 
17
18
  module.exports.Pantograph = Pantograph
19
+ module.exports.graphite = graphite
package/src/index.d.cts CHANGED
@@ -1,2 +1,4 @@
1
- // @ts-expect-error MJS
2
- export { default as Pantograph } from '#pantograph/pantograph'
1
+ export {
2
+ default as Pantograph,
3
+ graphite // @ts-expect-error MJS
4
+ } from '#pantograph/pantograph'
package/src/index.d.mts CHANGED
@@ -1 +1,4 @@
1
- export { default as Pantograph } from '#pantograph/pantograph'
1
+ export {
2
+ default as Pantograph,
3
+ graphite
4
+ } from '#pantograph/pantograph'
package/src/index.mjs CHANGED
@@ -4,4 +4,7 @@ const log = debug('shinkansen-pantograph')
4
4
 
5
5
  log('`shinkansen` is awake')
6
6
 
7
- export { default as Pantograph } from './pantograph/index.mjs'
7
+ export {
8
+ default as Pantograph,
9
+ graphite
10
+ } from './pantograph/index.mjs'
@@ -1,29 +1,27 @@
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
1
+ type RedirectToAlphaParams = PantographTypes.RedirectToAlphaParams
2
+ type RedirectToOmegaParams = PantographTypes.RedirectToOmegaParams
3
+ type RedirectToEmbarkParams = PantographTypes.RedirectToEmbarkParams
4
+ type RedirectToDebarkParams = PantographTypes.RedirectToDebarkParams
5
+ type RedirectToConfirmParams = PantographTypes.RedirectToConfirmParams
6
+ type RedirectToParams = PantographTypes.RedirectToParams
7
+ type RedirectFromAlphaParams = PantographTypes.RedirectFromAlphaParams
8
+ type RedirectFromOmegaParams = PantographTypes.RedirectFromOmegaParams
9
+ type RedirectFromEmbarkParams = PantographTypes.RedirectFromEmbarkParams
10
+ type RedirectFromDebarkParams = PantographTypes.RedirectFromDebarkParams
11
+ type RedirectFromConfirmParams = PantographTypes.RedirectFromConfirmParams
12
+ type GraphiteParams = PantographTypes.GraphiteParams
13
13
 
14
- declare const pantograph: Record<string, Record<string, string>>
14
+ export function getRedirectToAlpha (params: RedirectToAlphaParams): string | undefined
15
+ export function getRedirectToOmega (params: RedirectToOmegaParams): string | undefined
16
+ export function getRedirectToEmbark (params: RedirectToEmbarkParams): string | undefined
17
+ export function getRedirectToDebark (params: RedirectToDebarkParams): string | undefined
18
+ export function getRedirectToConfirm (params: RedirectToConfirmParams): string | undefined
19
+ export function getRedirectTo (params: RedirectToParams): string | undefined
20
+ export function getRedirectFromAlpha (params: RedirectFromAlphaParams): string | undefined
21
+ export function getRedirectFromOmega (params: RedirectFromOmegaParams): string | undefined
22
+ export function getRedirectFromEmbark (params: RedirectFromEmbarkParams): string | undefined
23
+ export function getRedirectFromDebark (params: RedirectFromDebarkParams): string | undefined
24
+ export function getRedirectFromConfirm (params: RedirectFromConfirmParams): string | undefined
25
+ export function graphite (params: GraphiteParams) : string | undefined
15
26
 
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
28
-
29
- export default pantograph
27
+ export { default } from './pantograph.mjs'
@@ -57,7 +57,7 @@ const ROUTE = {}
57
57
 
58
58
  /**
59
59
  * @param {RedirectToAlphaParams} params
60
- * @returns {string | undefined}
60
+ * @returns {string | undefined | void}
61
61
  */
62
62
  export function getRedirectToAlpha ({ alpha, route }) {
63
63
  log('getRedirectToAlpha')
@@ -72,7 +72,7 @@ export function getRedirectToAlpha ({ alpha, route }) {
72
72
 
73
73
  /**
74
74
  * @param {RedirectToOmegaParams} params
75
- * @returns {string | undefined}
75
+ * @returns {string | undefined | void}
76
76
  */
77
77
  export function getRedirectToOmega ({ alpha, omega, route }) {
78
78
  log('getRedirectToOmega')
@@ -87,7 +87,7 @@ export function getRedirectToOmega ({ alpha, omega, route }) {
87
87
 
88
88
  /**
89
89
  * @param {RedirectToEmbarkParams} params
90
- * @returns {string | undefined}
90
+ * @returns {string | undefined | void}
91
91
  */
92
92
  export function getRedirectToEmbark ({ embark, route }) {
93
93
  log('getRedirectToEmbark')
@@ -102,7 +102,7 @@ export function getRedirectToEmbark ({ embark, route }) {
102
102
 
103
103
  /**
104
104
  * @param {RedirectToDebarkParams} params
105
- * @returns {string | undefined}
105
+ * @returns {string | undefined | void}
106
106
  */
107
107
  export function getRedirectToDebark ({ debark, route }) {
108
108
  log('getRedirectToDebark')
@@ -117,7 +117,7 @@ export function getRedirectToDebark ({ debark, route }) {
117
117
 
118
118
  /**
119
119
  * @param {RedirectToConfirmParams} params
120
- * @returns {string | undefined}
120
+ * @returns {string | undefined | void}
121
121
  */
122
122
  export function getRedirectToConfirm ({ confirm, route }) {
123
123
  log('getRedirectToDebark')
@@ -132,7 +132,7 @@ export function getRedirectToConfirm ({ confirm, route }) {
132
132
 
133
133
  /**
134
134
  * @param {RedirectToParams} params
135
- * @returns {string | undefined}
135
+ * @returns {string | undefined | void}
136
136
  */
137
137
  export function getRedirectTo ({
138
138
  redirect: {
@@ -153,7 +153,7 @@ export function getRedirectTo ({
153
153
  } else if (debark) {
154
154
  return getRedirectToDebark({ debark, route })
155
155
  } else if (confirm) {
156
- return getRedirectToDebark({ confirm, route })
156
+ return getRedirectToConfirm({ confirm, route })
157
157
  } else if (alpha) { // can appear on its own
158
158
  return getRedirectToAlpha({ alpha, route })
159
159
  } else if (omega) { // can not appear on its own
@@ -163,7 +163,7 @@ export function getRedirectTo ({
163
163
 
164
164
  /**
165
165
  * @param {RedirectFromAlphaParams} params
166
- * @returns {string | undefined}
166
+ * @returns {string | undefined | void}
167
167
  */
168
168
  export function getRedirectFromAlpha ({ state: { [Signals.ALPHA]: { redirect } = {} } = {}, route }) {
169
169
  log('getRedirectFromAlpha')
@@ -173,7 +173,7 @@ export function getRedirectFromAlpha ({ state: { [Signals.ALPHA]: { redirect } =
173
173
 
174
174
  /**
175
175
  * @param {RedirectFromOmegaParams} params
176
- * @returns {string | undefined}
176
+ * @returns {string | undefined | void}
177
177
  */
178
178
 
179
179
  export function getRedirectFromOmega ({ state: { [Signals.OMEGA]: { redirect } = {} } = {}, route }) {
@@ -184,7 +184,7 @@ export function getRedirectFromOmega ({ state: { [Signals.OMEGA]: { redirect } =
184
184
 
185
185
  /**
186
186
  * @param {RedirectFromEmbarkParams} params
187
- * @returns {string | undefined}
187
+ * @returns {string | undefined | void}
188
188
  */
189
189
  export function getRedirectFromEmbark ({ state: { [Signals.EMBARK]: { redirect } = {} } = {}, route }) {
190
190
  log('getRedirectFromEmbark')
@@ -194,7 +194,7 @@ export function getRedirectFromEmbark ({ state: { [Signals.EMBARK]: { redirect }
194
194
 
195
195
  /**
196
196
  * @param {RedirectFromDebarkParams} params
197
- * @returns {string | undefined}
197
+ * @returns {string | undefined | void}
198
198
  */
199
199
  export function getRedirectFromDebark ({ state: { [Signals.DEBARK]: { redirect } = {} } = {}, route }) {
200
200
  log('getRedirectFromDebark')
@@ -204,7 +204,7 @@ export function getRedirectFromDebark ({ state: { [Signals.DEBARK]: { redirect }
204
204
 
205
205
  /**
206
206
  * @param {RedirectFromConfirmParams} params
207
- * @returns {string | undefined}
207
+ * @returns {string | undefined | void}
208
208
  */
209
209
  export function getRedirectFromConfirm ({ state: { [Signals.CONFIRM]: { redirect } = {} } = {}, route }) {
210
210
  log('getRedirectFromConfirm')
@@ -214,7 +214,7 @@ export function getRedirectFromConfirm ({ state: { [Signals.CONFIRM]: { redirect
214
214
 
215
215
  /**
216
216
  * @param {GraphiteParams} params
217
- * @returns {string | undefined}
217
+ * @returns {string | undefined | void}
218
218
  */
219
219
  export function graphite ({ action: { type } = ACTION, state = STATE, route = ROUTE }) {
220
220
  switch (type) {
@@ -1,8 +1,8 @@
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
1
+ type AlphaType = PantographTypes.Pantograph.AlphaType
2
+ type OmegaType = PantographTypes.Pantograph.OmegaType
3
+ type EmbarkType = PantographTypes.Pantograph.EmbarkType
4
+ type DebarkType = PantographTypes.Pantograph.DebarkType
5
+ type ConfirmType = PantographTypes.Pantograph.ConfirmType
6
6
 
7
7
  export declare const ALPHA: AlphaType
8
8
  export declare const OMEGA: OmegaType
@@ -8,7 +8,7 @@
8
8
 
9
9
  import debug from 'debug'
10
10
 
11
- const log = debug('shinkansen-pantograph/pantograph')
11
+ const log = debug('shinkansen-pantograph/pantograph/pantograph')
12
12
 
13
13
  log('`shinkansen` is awake')
14
14
 
package/tsconfig.json CHANGED
@@ -7,6 +7,18 @@
7
7
  "noEmit": true,
8
8
  "strict": true,
9
9
  "isolatedModules": true,
10
- "baseUrl": "."
10
+ "baseUrl": ".",
11
+ "paths": {
12
+ "#pantograph": [
13
+ "src/index.cjs",
14
+ "src/index.mjs"
15
+ ],
16
+ "#pantograph/pantograph": [
17
+ "src/pantograph/index.mjs"
18
+ ],
19
+ "#pantograph/pantograph/pantograph": [
20
+ "src/pantograph/pantograph.mjs"
21
+ ]
22
+ }
11
23
  }
12
24
  }