@thoughtbot/superglue 0.50.0 → 0.51.0
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/.babelrc.js +18 -0
- package/.prettierrc +5 -0
- package/.prettierrc.json +5 -0
- package/LICENSE +21 -0
- package/{action_creators → dist/action_creators}/requests.js +10 -0
- package/{components → dist/components}/Nav.js +1 -1
- package/dist/package.json +53 -0
- package/{utils → dist/utils}/url.js +15 -48
- package/package.json +11 -1
- package/thoughtbot-superglue-0.50.0.tgz +0 -0
- /package/{README.md → dist/README.md} +0 -0
- /package/{action_creators → dist/action_creators}/index.js +0 -0
- /package/{actions.js → dist/actions.js} +0 -0
- /package/{config.js → dist/config.js} +0 -0
- /package/{index.js → dist/index.js} +0 -0
- /package/{middleware.js → dist/middleware.js} +0 -0
- /package/{reducers → dist/reducers}/index.js +0 -0
- /package/{utils → dist/utils}/helpers.js +0 -0
- /package/{utils → dist/utils}/immutability.js +0 -0
- /package/{utils → dist/utils}/index.js +0 -0
- /package/{utils → dist/utils}/react.js +0 -0
- /package/{utils → dist/utils}/request.js +0 -0
- /package/{utils → dist/utils}/ujs.js +0 -0
- /package/{utils → dist/utils}/window.js +0 -0
package/.babelrc.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
plugins: [
|
|
3
|
+
["transform-react-remove-prop-types", {removeImport: true}]
|
|
4
|
+
],
|
|
5
|
+
presets: [
|
|
6
|
+
[
|
|
7
|
+
"@babel/preset-env",
|
|
8
|
+
{
|
|
9
|
+
useBuiltIns: "entry",
|
|
10
|
+
corejs: "2",
|
|
11
|
+
loose: true,
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
[
|
|
15
|
+
"@babel/preset-react"
|
|
16
|
+
],
|
|
17
|
+
],
|
|
18
|
+
};
|
package/.prettierrc
ADDED
package/.prettierrc.json
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016-2021 Johny Ho
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -90,6 +90,8 @@ function remote(path, _temp) {
|
|
|
90
90
|
fetchArgs: fetchArgs
|
|
91
91
|
}));
|
|
92
92
|
return fetch.apply(void 0, fetchArgs).then(_utils.parseResponse).then(function (_ref2) {
|
|
93
|
+
var _pages$currentPageKey;
|
|
94
|
+
|
|
93
95
|
var rsp = _ref2.rsp,
|
|
94
96
|
json = _ref2.json;
|
|
95
97
|
|
|
@@ -103,6 +105,14 @@ function remote(path, _temp) {
|
|
|
103
105
|
rsp: rsp,
|
|
104
106
|
fetchArgs: fetchArgs
|
|
105
107
|
});
|
|
108
|
+
var willReplaceCurrent = pageKey == currentPageKey;
|
|
109
|
+
var existingId = (_pages$currentPageKey = pages[currentPageKey]) == null ? void 0 : _pages$currentPageKey.componentIdentifier;
|
|
110
|
+
var receivedId = json.componentIdentifier;
|
|
111
|
+
|
|
112
|
+
if (willReplaceCurrent && !!existingId && existingId != receivedId) {
|
|
113
|
+
console.warn("You're about replace an existing page located at pages[\"" + currentPageKey + "\"]\nthat has the componentIdentifier \"" + existingId + "\" with the contents of a\nreceived page that has a componentIdentifier of \"" + receivedId + "\".\n\nThis can happen if you're using data-sg-remote or remote but your response\nredirected to a completely different page. Since remote requests do not\nnavigate or change the current page component, your current page component may\nreceive a shape that is unexpected and cause issues with rendering.\n\nConsider using data-sg-visit, the visit function, or redirect_back.");
|
|
114
|
+
}
|
|
115
|
+
|
|
106
116
|
var page = beforeSave(pages[pageKey], json);
|
|
107
117
|
return dispatch((0, _index.saveAndProcessPage)(pageKey, page)).then(function () {
|
|
108
118
|
meta.pageKey = pageKey;
|
|
@@ -222,7 +222,7 @@ var Nav = /*#__PURE__*/function (_React$Component) {
|
|
|
222
222
|
var reminder = '';
|
|
223
223
|
|
|
224
224
|
if (!identifier) {
|
|
225
|
-
reminder = 'Did you forget to add `json.
|
|
225
|
+
reminder = 'Did you forget to add `json.componentIdentifier` in your application.json.props layout?';
|
|
226
226
|
}
|
|
227
227
|
|
|
228
228
|
var error = new Error("Superglue Nav component was looking for " + identifier + " but could not find it in your mapping. " + reminder);
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@thoughtbot/superglue",
|
|
3
|
+
"version": "0.51.0",
|
|
4
|
+
"description": "Use a vanilla Rails with React and Redux",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/thoughtbot/superglue.git"
|
|
8
|
+
},
|
|
9
|
+
"author": "Johny Ho",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/thoughtbot/superglue/issues"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://github.com/thoughtbot/superglue#readme",
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@babel/cli": "^7.14.3",
|
|
17
|
+
"@babel/core": "^7.14.3",
|
|
18
|
+
"@babel/preset-env": "^7.14.4",
|
|
19
|
+
"@babel/preset-react": "^7.13.13",
|
|
20
|
+
"core-js": "^2.6.12",
|
|
21
|
+
"enzyme": "^3.11.0",
|
|
22
|
+
"enzyme-adapter-react-16": "^1.15.6",
|
|
23
|
+
"eslint": "^7.28.0",
|
|
24
|
+
"eslint-config-prettier": "^8.3.0",
|
|
25
|
+
"eslint-plugin-prettier": "^3.4.0",
|
|
26
|
+
"eslint-plugin-react": "^7.24.0",
|
|
27
|
+
"fetch-headers": "^2.0.0",
|
|
28
|
+
"fetch-mock": "^9.11.0",
|
|
29
|
+
"history": "^5.3.0",
|
|
30
|
+
"jest": "^27.0.4",
|
|
31
|
+
"node-fetch": "^2.6.1",
|
|
32
|
+
"prettier": "^2.3.1",
|
|
33
|
+
"prop-types": "^15.7.2",
|
|
34
|
+
"react": "^16.4.0",
|
|
35
|
+
"react-dom": "^16.4.0",
|
|
36
|
+
"react-redux": "^7.2.4",
|
|
37
|
+
"redux": "^4.1.0",
|
|
38
|
+
"redux-mock-store": "^1.5.4",
|
|
39
|
+
"redux-thunk": "^2.3.0"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"history": "^5.3.0",
|
|
43
|
+
"react": ">=16",
|
|
44
|
+
"react-redux": ">=7.2",
|
|
45
|
+
"redux": ">=4.1",
|
|
46
|
+
"redux-thunk": ">=2.3"
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"abortcontroller-polyfill": "^1.7.3",
|
|
50
|
+
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
|
|
51
|
+
"url-parse": "^1.5.1"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -8,8 +8,7 @@ exports.pathQueryHash = pathQueryHash;
|
|
|
8
8
|
exports.pathWithoutBZParams = pathWithoutBZParams;
|
|
9
9
|
exports.removePropsAt = removePropsAt;
|
|
10
10
|
exports.urlToPageKey = urlToPageKey;
|
|
11
|
-
exports.
|
|
12
|
-
exports.withMimeBust = withMimeBust;
|
|
11
|
+
exports.withFormatJson = withFormatJson;
|
|
13
12
|
exports.withoutBusters = withoutBusters;
|
|
14
13
|
exports.withoutHash = withoutHash;
|
|
15
14
|
|
|
@@ -17,10 +16,6 @@ var _urlParse = _interopRequireDefault(require("url-parse"));
|
|
|
17
16
|
|
|
18
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
18
|
|
|
20
|
-
var uniqueId = function uniqueId() {
|
|
21
|
-
return Math.random().toString(36).substring(2, 10);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
19
|
function pathQuery(url) {
|
|
25
20
|
var _parse = new _urlParse["default"](url, {}),
|
|
26
21
|
pathname = _parse.pathname,
|
|
@@ -44,43 +39,17 @@ function hasPropsAt(url) {
|
|
|
44
39
|
return !!query['props_at'];
|
|
45
40
|
}
|
|
46
41
|
|
|
47
|
-
function
|
|
48
|
-
url = new _urlParse["default"](url, {}, true);
|
|
49
|
-
|
|
50
|
-
if (Object.prototype.hasOwnProperty.call(url.query, '_')) {
|
|
51
|
-
return url.toString();
|
|
52
|
-
} else {
|
|
53
|
-
url.query['_'] = uniqueId();
|
|
54
|
-
return url.toString();
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function withMimeBust(url) {
|
|
42
|
+
function withFormatJson(url) {
|
|
59
43
|
url = new _urlParse["default"](url, {}, true);
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return url.toString();
|
|
63
|
-
} else {
|
|
64
|
-
url.query['__'] = '0';
|
|
65
|
-
return url.toString();
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function withoutBusters(url) {
|
|
70
|
-
url = new _urlParse["default"](url, {}, true);
|
|
71
|
-
var query = url.query;
|
|
72
|
-
delete query['__'];
|
|
73
|
-
delete query['_'];
|
|
74
|
-
url.query = query;
|
|
75
|
-
return pathQuery(url.toString());
|
|
44
|
+
url.query['format'] = 'json';
|
|
45
|
+
return url.toString();
|
|
76
46
|
}
|
|
77
47
|
|
|
78
48
|
function pathWithoutBZParams(url) {
|
|
79
49
|
url = new _urlParse["default"](url, {}, true);
|
|
80
50
|
var query = url.query;
|
|
81
|
-
delete query['__'];
|
|
82
|
-
delete query['_'];
|
|
83
51
|
delete query['props_at'];
|
|
52
|
+
delete query['format'];
|
|
84
53
|
url.query = query;
|
|
85
54
|
return pathQueryHash(url.toString());
|
|
86
55
|
}
|
|
@@ -96,9 +65,8 @@ function removePropsAt(url) {
|
|
|
96
65
|
function urlToPageKey(url) {
|
|
97
66
|
url = new _urlParse["default"](url, {}, true);
|
|
98
67
|
var query = url.query;
|
|
99
|
-
delete query['__'];
|
|
100
|
-
delete query['_'];
|
|
101
68
|
delete query['props_at'];
|
|
69
|
+
delete query['format'];
|
|
102
70
|
url.query = query;
|
|
103
71
|
return pathQuery(url.toString());
|
|
104
72
|
}
|
|
@@ -109,17 +77,16 @@ function withoutHash(url) {
|
|
|
109
77
|
return url.toString();
|
|
110
78
|
}
|
|
111
79
|
|
|
112
|
-
function
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
if (opts.cacheRequest) {
|
|
120
|
-
formats.push(withAntiCache);
|
|
121
|
-
}
|
|
80
|
+
function withoutBusters(url) {
|
|
81
|
+
url = new _urlParse["default"](url, {}, true);
|
|
82
|
+
var query = url.query;
|
|
83
|
+
delete query['format'];
|
|
84
|
+
url.query = query;
|
|
85
|
+
return pathQuery(url.toString());
|
|
86
|
+
}
|
|
122
87
|
|
|
88
|
+
function formatForXHR(url) {
|
|
89
|
+
var formats = [withoutHash, withFormatJson];
|
|
123
90
|
return formats.reduce(function (memo, f) {
|
|
124
91
|
return f(memo);
|
|
125
92
|
}, url);
|
package/package.json
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thoughtbot/superglue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.51.0",
|
|
4
4
|
"description": "Use a vanilla Rails with React and Redux",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"test": "jest",
|
|
7
|
+
"lint": "eslint lib",
|
|
8
|
+
"clean": "rm -rf ./dist",
|
|
9
|
+
"copy:package": "cat ./package.json | jq 'del(.scripts)' > dist/package.json",
|
|
10
|
+
"copy:readme": "cp ../README.md dist/",
|
|
11
|
+
"build:index": "babel lib -d dist",
|
|
12
|
+
"build": "npm run clean && npm run build:index && npm run copy:package && npm run copy:readme",
|
|
13
|
+
"prepublishOnly": "npm run build"
|
|
14
|
+
},
|
|
5
15
|
"repository": {
|
|
6
16
|
"type": "git",
|
|
7
17
|
"url": "git+https://github.com/thoughtbot/superglue.git"
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|