eddev 0.2.3 → 0.2.6

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.
@@ -68,11 +68,13 @@ function BrowserRouter(props) {
68
68
  setIsLoading(true);
69
69
  }
70
70
  (0, remoteProps_1.fetchProps)(pending.url).then(function (data) {
71
+ console.log("FETCHED", data);
71
72
  var view = views_1.default[data.view];
73
+ var nextUrl = data.canonical || pending.url;
72
74
  var finish = function () {
73
75
  var _a, _b;
74
76
  setState({
75
- url: pending.url,
77
+ url: nextUrl,
76
78
  data: data,
77
79
  });
78
80
  // setData(data)
@@ -86,7 +88,7 @@ function BrowserRouter(props) {
86
88
  setIsLoading(false);
87
89
  if (!pending.popped) {
88
90
  history.replaceState({ scrollPosition: (_b = document.scrollingElement) === null || _b === void 0 ? void 0 : _b.scrollTop }, "", document.location.href);
89
- history.pushState({}, "", pending.url);
91
+ history.pushState({}, "", nextUrl);
90
92
  }
91
93
  };
92
94
  if (view && view.preload) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eddev",
3
- "version": "0.2.3",
3
+ "version": "0.2.6",
4
4
  "main": "./index.js",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -8,6 +8,8 @@ export interface RouteData {
8
8
  viewType: "react" | "html";
9
9
  viewData: any;
10
10
  appData: any;
11
+ redirect?: string;
12
+ canonical?: string;
11
13
  meta?: {
12
14
  head: ParsedRouteTags;
13
15
  footer: ParsedRouteTags;
@@ -78,6 +78,13 @@ function fetchProps(url) {
78
78
  promise = fetch(requestUrl)
79
79
  .then(function (response) { return response.json(); })
80
80
  .then(function (data) {
81
+ if (data.redirect) {
82
+ var redirect_1 = data.redirect;
83
+ return fetchProps(redirect_1).then(function (data) {
84
+ data.canonical = redirect_1;
85
+ return data;
86
+ });
87
+ }
81
88
  delete pending[cacheKey];
82
89
  cache[cacheKey] = data;
83
90
  return data;
@@ -21,6 +21,7 @@
21
21
  "@components/*": ["components/*"],
22
22
  "@views/*": ["views/*"],
23
23
  "@hooks/*": ["hooks/*"],
24
+ "@utils/*": ["utils/*"],
24
25
  "@queries/*": ["hooks/queries/*"],
25
26
  "@theme": ["theme.css.tsx"],
26
27
  "@wordpress/components": ["null.ts"],