shinkansen-gears 1.0.56 → 1.0.59

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shinkansen-gears",
3
- "version": "1.0.56",
3
+ "version": "1.0.59",
4
4
  "description": "Shinkansen Gears",
5
5
  "keywords": [
6
6
  "Shinkansen",
@@ -13,7 +13,6 @@
13
13
  ],
14
14
  "main": "./src/index.cjs",
15
15
  "type": "module",
16
- "types": "/src/index.d.mts",
17
16
  "author": "Jonathan Perry for Modern Poacher Limited <modernpoacher@modernpoacher.com>",
18
17
  "license": "MIT",
19
18
  "engines": {
@@ -32,7 +31,7 @@
32
31
  "pregulp": "npm run nvm",
33
32
  "gulp": "gulp --color",
34
33
  "prelint": "npm run nvm",
35
- "lint": "cross-env NODE_ENV=production eslint . .storybook --ext .mjs --ext .cjs --ext .jsx --ext .mts",
34
+ "lint": "cross-env NODE_ENV=production eslint . .storybook --ext .mjs --ext .cjs --ext .jsx --ext .mts --ext .cts",
36
35
  "lint:fix": "npm run lint -- --fix",
37
36
  "pretest": "npm run nvm",
38
37
  "test": "cross-env NODE_ENV=test jest --collect-coverage false --verbose --run-in-band",
@@ -54,16 +53,16 @@
54
53
  "@babel/preset-env": "^7.21.5",
55
54
  "@babel/preset-react": "^7.18.6",
56
55
  "@babel/register": "^7.21.0",
57
- "@modernpoacher/design-system": "1.0.6",
58
- "@modernpoacher/hooks": "^1.0.396",
56
+ "@modernpoacher/design-system": "1.0.7",
57
+ "@modernpoacher/hooks": "^1.0.397",
59
58
  "@sequencemedia/gulp": "^1.0.7",
60
59
  "@storybook/addon-actions": "6.5.12",
61
60
  "@storybook/addon-essentials": "6.5.12",
62
61
  "@storybook/addon-links": "6.5.12",
63
62
  "@storybook/react": "6.5.12",
64
63
  "@types/react": "^18.2.6",
65
- "@typescript-eslint/eslint-plugin": "^5.59.2",
66
- "@typescript-eslint/parser": "^5.59.2",
64
+ "@typescript-eslint/eslint-plugin": "^5.59.5",
65
+ "@typescript-eslint/parser": "^5.59.5",
67
66
  "autoprefixer": "^10.4.14",
68
67
  "babel-plugin-module-resolver": "^5.0.0",
69
68
  "core-js": "^3.30.2",
@@ -104,10 +103,12 @@
104
103
  "regenerator-runtime": "^0.13.11",
105
104
  "rimraf": "^5.0.0",
106
105
  "sass": "^1.62.1",
107
- "shinkansen-rails": "^1.0.32",
106
+ "shinkansen-rails": "1.0.34",
108
107
  "vinyl-paths": "^5.0.0"
109
108
  },
110
109
  "imports": {
110
+ "#gears-reverse": "./src/gears/reverse/index.cjs",
111
+ "#gears": "./src/gears/index.cjs",
111
112
  "#build/gulp/build/*": "./build/gulp/build/*.mjs",
112
113
  "#build/gulp/build": "./build/gulp/build/index.mjs",
113
114
  "#build/gulp/transform": "./build/gulp/transform/index.mjs",
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @typedef {import('shinkansen-gears/gears/forward').ForwardProps} ForwardProps
3
+ */
4
+
1
5
  import React from 'react'
2
6
  import PropTypes from 'prop-types'
3
7
 
@@ -5,6 +9,10 @@ import {
5
9
  Link
6
10
  } from 'react-router-dom'
7
11
 
12
+ /**
13
+ * @param {ForwardProps}
14
+ * @returns {React.JSX.Element}
15
+ */
8
16
  function Forward ({ pathname }) {
9
17
  const key = pathname.concat('-forward')
10
18
  const to = {
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @typedef {import('shinkansen-gears/gears').GearsProps} GearsProps
3
+ * @typedef {import('shinkansen-gears/gears').GearsState} GearsState
4
+ */
5
+
1
6
  import React, { Component } from 'react'
2
7
  import PropTypes from 'prop-types'
3
8
  import Immutable from 'immutable'
@@ -10,8 +15,7 @@ import Reverse from './reverse/index.jsx'
10
15
  import Forward from './forward/index.jsx'
11
16
 
12
17
  /**
13
- * @param {{} | void} reverse
14
- * @param {string | void} pattern
18
+ * @type {(reverse: {}, pattern: string | void): React.JSX.Element | null}
15
19
  */
16
20
  export function renderReverse (reverse, pattern) {
17
21
  if (Rails.go(reverse, pattern)) {
@@ -28,8 +32,7 @@ export function renderReverse (reverse, pattern) {
28
32
  }
29
33
 
30
34
  /**
31
- * @param {{} | void} forward
32
- * @param {string | void} pattern
35
+ * @type {(reverse: {}, pattern: string | void): React.JSX.Element | null}
33
36
  */
34
37
  export function renderForward (forward, pattern) {
35
38
  if (Rails.go(forward, pattern)) {
@@ -46,13 +49,17 @@ export function renderForward (forward, pattern) {
46
49
  }
47
50
 
48
51
  export default class Gears extends Component {
52
+ /**
53
+ * @type {GearsState}
54
+ */
49
55
  state = {} // define state
50
56
 
51
57
  /**
52
58
  * Convert latest 'props' to an Immutable.Map() and store in 'state'
53
59
  *
54
- * @param {{reverse: Immutable.Map<{}, {}>, forward: Immutable.Map<{}, {}>}} props Latest props
55
- * @param {{reverse: Immutable.Map<{}, {}>, forward: Immutable.Map<{}, {}>}} state Current state
60
+ * @param {GearsProps} props Latest props
61
+ * @param {GearsState} state Current state
62
+ * @returns {GearsState} Derived state
56
63
  */
57
64
  static getDerivedStateFromProps ({ reverse, forward }, { reverse: R, forward: F }) {
58
65
  const r = Immutable.Map(reverse)
@@ -67,8 +74,9 @@ export default class Gears extends Component {
67
74
  /**
68
75
  * Compare latest 'props' and 'state' for changes to 'pattern', 'reverse' or 'forward'
69
76
  *
70
- * @param {Object} props Latest props
71
- * @param {Object} state Current state
77
+ * @param {{ pattern: string }} props Latest props
78
+ * @param {GearsState} state Current state
79
+ * @returns {boolean}
72
80
  */
73
81
  shouldComponentUpdate ({ pattern }, state) {
74
82
  const {
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @typedef {import('shinkansen-gears/gears/reverse').ReverseProps} ReverseProps
3
+ */
4
+
1
5
  import React from 'react'
2
6
  import PropTypes from 'prop-types'
3
7
 
@@ -5,6 +9,10 @@ import {
5
9
  Link
6
10
  } from 'react-router-dom'
7
11
 
12
+ /**
13
+ * @param {ReverseProps}
14
+ * @returns {React.JSX.Element}
15
+ */
8
16
  function Reverse ({ pathname }) {
9
17
  const key = pathname.concat('-reverse')
10
18
  const to = {
package/src/index.mjs CHANGED
@@ -1,5 +1,9 @@
1
1
  import debug from 'debug'
2
2
 
3
+ /**
4
+ * @typedef {import('shinkansen-gears').Gears} Gears
5
+ */
6
+
3
7
  const log = debug('shinkansen-gears')
4
8
 
5
9
  log('`shinkansen` is awake')
package/jsconfig.json DELETED
@@ -1,11 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "baseUrl": "./",
4
- "paths": {
5
- "shinkansen-sprockets/*": [
6
- "src/*",
7
- "stories/*"
8
- ]
9
- }
10
- }
11
- }
@@ -1,9 +0,0 @@
1
- import React from 'react'
2
-
3
- type ForwardProps = {
4
- pathname: string
5
- }
6
-
7
- type ForwardComponent = React.Component<ForwardProps>
8
-
9
- export default ForwardComponent
@@ -1,18 +0,0 @@
1
- import React from 'react'
2
-
3
- import ReverseComponent from './reverse/index.mjs'
4
- import ForwardComponent from './forward/index.mjs'
5
-
6
- type GearsProps = {
7
- reverse: {},
8
- forward: {},
9
- pattern: string
10
- }
11
-
12
- type GearsComponent = React.ComponentClass<GearsProps>
13
-
14
- declare const Gears: GearsComponent
15
-
16
- export function renderReverse (reverse: {}, pattern: string | void): ReverseComponent | null
17
- export function renderForward (forward: {}, pattern: string | void): ForwardComponent | null
18
- export default Gears
@@ -1,9 +0,0 @@
1
- import React from 'react'
2
-
3
- type ReverseProps = {
4
- pathname: string
5
- }
6
-
7
- type ReverseComponent = React.Component<ReverseProps>
8
-
9
- export default ReverseComponent
package/src/index.d.mts DELETED
@@ -1,5 +0,0 @@
1
- import type GearsComponent from './gears/index.mjs'
2
-
3
- declare module 'shinkansen-gears' {
4
- export const Gears: typeof GearsComponent
5
- }
package/tsconfig.json DELETED
@@ -1,22 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "module": "es2020",
4
- "target": "es2020",
5
- "moduleResolution": "node",
6
- "noEmit": true,
7
- "strict": true,
8
- "isolatedModules": true,
9
- "noImplicitAny": true,
10
- "allowSyntheticDefaultImports": true,
11
- "jsx": "react",
12
- "baseUrl": "./",
13
- "paths": {
14
- "shinkansen-sprockets/*": [
15
- "src/*"
16
- ]
17
- }
18
- },
19
- "include": [
20
- "src/*"
21
- ]
22
- }