@thoughtbot/superglue 0.53.2 → 0.53.3

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 CHANGED
@@ -7,7 +7,8 @@
7
7
  Use classic Rails to build rich React Redux applications with **NO APIs** and
8
8
  **NO client-side routing**.
9
9
 
10
- [![Build Status](https://circleci.com/gh/thoughtbot/superglue.svg?style=shield)](https://circleci.com/gh/thoughtbot/superglue)
10
+ [![Test superglue_js](https://github.com/thoughtbot/superglue/actions/workflows/build_js.yml/badge.svg)](https://github.com/thoughtbot/superglue/actions/workflows/build_js.yml)
11
+ [![Test superglue_rails](https://github.com/thoughtbot/superglue/actions/workflows/build_rails.yml/badge.svg)](https://github.com/thoughtbot/superglue/actions/workflows/build_rails.yml)
11
12
 
12
13
  Superglue makes React and Redux as productive as Hotwire, Turbo and Stimulus.
13
14
  Its inspired by Turbolinks and designed to feel like a natural extension of
package/actions.js CHANGED
@@ -2,29 +2,16 @@
2
2
 
3
3
  exports.__esModule = true;
4
4
  exports.UPDATE_FRAGMENTS = exports.SUPERGLUE_ERROR = exports.SET_CSRF_TOKEN = exports.SAVE_RESPONSE = exports.REMOVE_PAGE = exports.HISTORY_CHANGE = exports.HANDLE_GRAFT = exports.GRAFTING_SUCCESS = exports.GRAFTING_ERROR = exports.COPY_PAGE = exports.BEFORE_VISIT = exports.BEFORE_REMOTE = exports.BEFORE_FETCH = void 0;
5
- var BEFORE_FETCH = '@@superglue/BEFORE_FETCH';
6
- exports.BEFORE_FETCH = BEFORE_FETCH;
7
- var BEFORE_VISIT = '@@superglue/BEFORE_VISIT';
8
- exports.BEFORE_VISIT = BEFORE_VISIT;
9
- var BEFORE_REMOTE = '@@superglue/BEFORE_REMOTE';
10
- exports.BEFORE_REMOTE = BEFORE_REMOTE;
11
- var SAVE_RESPONSE = '@@superglue/SAVE_RESPONSE';
12
- exports.SAVE_RESPONSE = SAVE_RESPONSE;
13
- var HANDLE_GRAFT = '@@superglue/HANDLE_GRAFT';
14
- exports.HANDLE_GRAFT = HANDLE_GRAFT;
15
- var SUPERGLUE_ERROR = '@@superglue/ERROR';
16
- exports.SUPERGLUE_ERROR = SUPERGLUE_ERROR;
17
- var GRAFTING_ERROR = '@@superglue/GRAFTING_ERROR';
18
- exports.GRAFTING_ERROR = GRAFTING_ERROR;
19
- var GRAFTING_SUCCESS = '@@superglue/GRAFTING_SUCCESS';
20
- exports.GRAFTING_SUCCESS = GRAFTING_SUCCESS;
21
- var HISTORY_CHANGE = '@@superglue/HISTORY_CHANGE';
22
- exports.HISTORY_CHANGE = HISTORY_CHANGE;
23
- var SET_CSRF_TOKEN = '@@superglue/SET_CSRF_TOKEN';
24
- exports.SET_CSRF_TOKEN = SET_CSRF_TOKEN;
25
- var REMOVE_PAGE = '@@superglue/REMOVE_PAGE';
26
- exports.REMOVE_PAGE = REMOVE_PAGE;
27
- var COPY_PAGE = '@@superglue/COPY_PAGE';
28
- exports.COPY_PAGE = COPY_PAGE;
29
- var UPDATE_FRAGMENTS = '@@superglue/UPDATE_FRAGMENTS';
30
- exports.UPDATE_FRAGMENTS = UPDATE_FRAGMENTS;
5
+ var BEFORE_FETCH = exports.BEFORE_FETCH = '@@superglue/BEFORE_FETCH';
6
+ var BEFORE_VISIT = exports.BEFORE_VISIT = '@@superglue/BEFORE_VISIT';
7
+ var BEFORE_REMOTE = exports.BEFORE_REMOTE = '@@superglue/BEFORE_REMOTE';
8
+ var SAVE_RESPONSE = exports.SAVE_RESPONSE = '@@superglue/SAVE_RESPONSE';
9
+ var HANDLE_GRAFT = exports.HANDLE_GRAFT = '@@superglue/HANDLE_GRAFT';
10
+ var SUPERGLUE_ERROR = exports.SUPERGLUE_ERROR = '@@superglue/ERROR';
11
+ var GRAFTING_ERROR = exports.GRAFTING_ERROR = '@@superglue/GRAFTING_ERROR';
12
+ var GRAFTING_SUCCESS = exports.GRAFTING_SUCCESS = '@@superglue/GRAFTING_SUCCESS';
13
+ var HISTORY_CHANGE = exports.HISTORY_CHANGE = '@@superglue/HISTORY_CHANGE';
14
+ var SET_CSRF_TOKEN = exports.SET_CSRF_TOKEN = '@@superglue/SET_CSRF_TOKEN';
15
+ var REMOVE_PAGE = exports.REMOVE_PAGE = '@@superglue/REMOVE_PAGE';
16
+ var COPY_PAGE = exports.COPY_PAGE = '@@superglue/COPY_PAGE';
17
+ var UPDATE_FRAGMENTS = exports.UPDATE_FRAGMENTS = '@@superglue/UPDATE_FRAGMENTS';
package/components/Nav.js CHANGED
@@ -255,5 +255,4 @@ var Nav = /*#__PURE__*/function (_React$Component) {
255
255
  return Nav;
256
256
  }(_react["default"].Component);
257
257
 
258
- var _default = Nav;
259
- exports["default"] = _default;
258
+ var _default = exports["default"] = Nav;
package/config.js CHANGED
@@ -2,8 +2,7 @@
2
2
 
3
3
  exports.__esModule = true;
4
4
  exports.config = void 0;
5
- var config = {
5
+ var config = exports.config = {
6
6
  baseUrl: '',
7
7
  maxPages: 20
8
- };
9
- exports.config = config;
8
+ };
package/index.js CHANGED
@@ -134,7 +134,7 @@ var NotImplementedError = /*#__PURE__*/function (_Error) {
134
134
  return NotImplementedError;
135
135
  }( /*#__PURE__*/_wrapNativeSuper(Error));
136
136
 
137
- var ApplicationBase = /*#__PURE__*/function (_React$Component) {
137
+ var ApplicationBase = exports.ApplicationBase = /*#__PURE__*/function (_React$Component) {
138
138
  _inheritsLoose(ApplicationBase, _React$Component);
139
139
 
140
140
  function ApplicationBase(props) {
@@ -262,6 +262,4 @@ var ApplicationBase = /*#__PURE__*/function (_React$Component) {
262
262
  };
263
263
 
264
264
  return ApplicationBase;
265
- }(_react["default"].Component);
266
-
267
- exports.ApplicationBase = ApplicationBase;
265
+ }(_react["default"].Component);
package/middleware.js CHANGED
@@ -13,7 +13,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
13
13
 
14
14
  var actionValues = Object.values(actions);
15
15
 
16
- var fragmentMiddleware = function fragmentMiddleware(store) {
16
+ var fragmentMiddleware = exports.fragmentMiddleware = function fragmentMiddleware(store) {
17
17
  return function (next) {
18
18
  return function (action) {
19
19
  var prevState = store.getState();
@@ -75,6 +75,4 @@ var fragmentMiddleware = function fragmentMiddleware(store) {
75
75
  return nextAction;
76
76
  };
77
77
  };
78
- };
79
-
80
- exports.fragmentMiddleware = fragmentMiddleware;
78
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thoughtbot/superglue",
3
- "version": "0.53.2",
3
+ "version": "0.53.3",
4
4
  "description": "Use a vanilla Rails with React and Redux",
5
5
  "repository": {
6
6
  "type": "git",
package/reducers/index.js CHANGED
@@ -257,8 +257,7 @@ function superglueReducer(state, action) {
257
257
  return Object.assign({}, meta);
258
258
  }
259
259
 
260
- var rootReducer = {
260
+ var rootReducer = exports.rootReducer = {
261
261
  superglue: superglueReducer,
262
262
  pages: pageReducer
263
- };
264
- exports.rootReducer = rootReducer;
263
+ };
@@ -23,7 +23,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
23
23
  // Then, modified to respect the id=0 keypath
24
24
  var isSearchable = /^[\da-zA-Z\-_=.]+$/;
25
25
 
26
- var KeyPathError = /*#__PURE__*/function (_Error) {
26
+ var KeyPathError = exports.KeyPathError = /*#__PURE__*/function (_Error) {
27
27
  _inheritsLoose(KeyPathError, _Error);
28
28
 
29
29
  function KeyPathError(message) {
@@ -37,8 +37,6 @@ var KeyPathError = /*#__PURE__*/function (_Error) {
37
37
  return KeyPathError;
38
38
  }( /*#__PURE__*/_wrapNativeSuper(Error));
39
39
 
40
- exports.KeyPathError = KeyPathError;
41
-
42
40
  function getIn(obj, path) {
43
41
  var keyPath = normalizeKeyPath(path);
44
42
  var result = obj;
package/utils/react.js CHANGED
@@ -35,15 +35,13 @@ function mapStateToProps(state, ownProps) {
35
35
  });
36
36
  }
37
37
 
38
- var mapDispatchToProps = {
38
+ var mapDispatchToProps = exports.mapDispatchToProps = {
39
39
  saveAndProcessPage: _action_creators.saveAndProcessPage,
40
40
  copyPage: _action_creators.copyPage
41
41
  };
42
- exports.mapDispatchToProps = mapDispatchToProps;
43
- var mapDispatchToPropsIncludingVisitAndRemote = {
42
+ var mapDispatchToPropsIncludingVisitAndRemote = exports.mapDispatchToPropsIncludingVisitAndRemote = {
44
43
  visit: _action_creators.visit,
45
44
  remote: _action_creators.remote,
46
45
  saveAndProcessPage: _action_creators.saveAndProcessPage,
47
46
  copyPage: _action_creators.copyPage
48
- };
49
- exports.mapDispatchToPropsIncludingVisitAndRemote = mapDispatchToPropsIncludingVisitAndRemote;
47
+ };
package/utils/request.js CHANGED
@@ -73,21 +73,25 @@ function argsForFetch(getState, pathQuery, _temp) {
73
73
  accept: jsAccept,
74
74
  'x-requested-with': 'XMLHttpRequest',
75
75
  'x-superglue-request': true
76
- });
76
+ }); // This needs to be done better. This is saying to
77
+ // remove the content-type header from UJS form
78
+ // submissions.
79
+
80
+ var fromUJSForm = headers['content-type'] === null;
77
81
 
78
82
  if (method != 'GET' && method != 'HEAD') {
79
- if (headers['content-type'] === null) {
80
- delete headers['content-type'];
81
- } else {
82
- headers['content-type'] = 'application/json';
83
- }
83
+ headers['content-type'] = 'application/json';
84
+ }
85
+
86
+ if (fromUJSForm) {
87
+ delete headers['content-type'];
84
88
  }
85
89
 
86
90
  if (currentState.csrfToken) {
87
91
  headers['x-csrf-token'] = currentState.csrfToken;
88
92
  }
89
93
 
90
- var href = new _urlParse["default"](pathQuery, _config.config.baseUrl || {}, false).href;
94
+ var fetchPath = new _urlParse["default"]((0, _url.formatForXHR)(pathQuery), _config.config.baseUrl || {}, false);
91
95
  var credentials = 'same-origin';
92
96
 
93
97
  if (!(method == 'GET' || method == 'HEAD')) {
@@ -109,10 +113,16 @@ function argsForFetch(getState, pathQuery, _temp) {
109
113
  }
110
114
 
111
115
  if (method == 'GET' || method == 'HEAD') {
116
+ if (options.body instanceof FormData) {
117
+ var allData = new URLSearchParams(options.body).toString(); // fetchPath will always have atleast /?format=json
118
+
119
+ fetchPath.query = fetchPath.query + '&' + allData;
120
+ }
121
+
112
122
  delete options.body;
113
123
  }
114
124
 
115
- return [(0, _url.formatForXHR)(href), options];
125
+ return [fetchPath.toString(), options];
116
126
  }
117
127
 
118
128
  function extractJSON(rsp) {
package/utils/ujs.js CHANGED
@@ -5,7 +5,7 @@ exports.ujsHandlers = exports.HandlerBuilder = void 0;
5
5
 
6
6
  var _url = require("./url");
7
7
 
8
- var HandlerBuilder = /*#__PURE__*/function () {
8
+ var HandlerBuilder = exports.HandlerBuilder = /*#__PURE__*/function () {
9
9
  function HandlerBuilder(_ref) {
10
10
  var ujsAttributePrefix = _ref.ujsAttributePrefix,
11
11
  visit = _ref.visit,
@@ -116,9 +116,7 @@ var HandlerBuilder = /*#__PURE__*/function () {
116
116
  return HandlerBuilder;
117
117
  }();
118
118
 
119
- exports.HandlerBuilder = HandlerBuilder;
120
-
121
- var ujsHandlers = function ujsHandlers(_ref2) {
119
+ var ujsHandlers = exports.ujsHandlers = function ujsHandlers(_ref2) {
122
120
  var navigatorRef = _ref2.navigatorRef,
123
121
  store = _ref2.store,
124
122
  ujsAttributePrefix = _ref2.ujsAttributePrefix,
@@ -132,6 +130,4 @@ var ujsHandlers = function ujsHandlers(_ref2) {
132
130
  ujsAttributePrefix: ujsAttributePrefix
133
131
  });
134
132
  return builder.handlers();
135
- };
136
-
137
- exports.ujsHandlers = ujsHandlers;
133
+ };