@devgateway/dvz-ui-react 1.5.2 → 1.5.4
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/dist/cjs/conf/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _={REACT_APP_WP_API:process.env.VITE_REACT_APP_WP_API??"/wp/wp-json",REACT_APP_API_ROOT:process.env.VITE_REACT_APP_API_ROOT??
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _={REACT_APP_WP_API:process.env.VITE_REACT_APP_WP_API??"/wp/wp-json",REACT_APP_API_ROOT:process.env.VITE_REACT_APP_API_ROOT??null,GA_CODE:process.env.VITE_REACT_APP_GA_CODE??"",DEFAULT_LOCALE:process.env.VITE_REACT_APP_DEFAULT_LOCALE??"en"};exports.Config=_;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("../../conf/index.js"),y=require("../../api/commons.js");function f(t){return JSON.parse(JSON.stringify(t))}const l=process.env.VITE_REACT_APP_API_ROOT||S.Config.REACT_APP_API_ROOT||"",p={},g={},$=3*60*1e3;function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("../../conf/index.js"),y=require("../../api/commons.js");function f(t){return JSON.parse(JSON.stringify(t))}const l=process.env.VITE_REACT_APP_API_ROOT||S.Config.REACT_APP_API_ROOT||null,A=typeof window<"u"?window.location.origin:"",p={},g={},$=3*60*1e3;function C(t){return Object.keys(t).map(n=>encodeURIComponent(n)+"="+encodeURIComponent(t[n])).join("&")}function O(t,n=!1){const e=t,r=Date.now();if(g[e]&&r-g[e].timestamp<$)return Promise.resolve(f(g[e].data));if(p[e])return p[e].then(f);const c=y.get(t,{}).then(a=>(g[e]={data:a,timestamp:Date.now()},n?{data:f(a),meta:g[e].meta}:f(a))).finally(()=>{delete p[e]});return p[e]=c,c}const q=({app:t,params:n})=>{const e=`${l||A}/api/${t}/categories${n?"?"+C(n):""}`;return O(e)},I=({source:t,app:n,params:e})=>{const r=`${l||A}/api/${n}/stats/${t}${e?"?"+C(e):""}`;return O(r)},E=({postType:t,taxonomy:n,category:e,taxonomyFilters:r,before:c,perPage:a,page:T,locale:_,after:m})=>{const h=`${S.Config.REACT_APP_WP_API}/wp/v2/${t}`,i=new URLSearchParams,d=new Map,w=(s,o)=>{if(!s||o==null)return;const u=d.get(s)||[];Array.isArray(o)?o.forEach(P=>{P!=null&&u.push(String(P))}):u.push(String(o)),d.set(s,u)};r&&r instanceof Map&&r.forEach((s,o)=>{w(o,s)}),d.forEach((s,o)=>{const u=Array.from(new Set(s));i.set(o,u.join(","))}),c&&i.append("before",c.toISOString()),a&&i.append("per_page",a.toString()),i.append("page",T.toString()),i.append("locale",_),m&&i.append("after",m.toISOString());const R=i.toString().replace(/%2C/g,",");return y.get(`${h}?${R}`,{})};exports.getCategories=q;exports.getCustomPosts=E;exports.getData=I;
|
package/dist/esm/conf/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const _ = {
|
|
2
2
|
REACT_APP_WP_API: process.env.VITE_REACT_APP_WP_API ?? "/wp/wp-json",
|
|
3
|
-
REACT_APP_API_ROOT: process.env.VITE_REACT_APP_API_ROOT ??
|
|
3
|
+
REACT_APP_API_ROOT: process.env.VITE_REACT_APP_API_ROOT ?? null,
|
|
4
4
|
GA_CODE: process.env.VITE_REACT_APP_GA_CODE ?? "",
|
|
5
5
|
DEFAULT_LOCALE: process.env.VITE_REACT_APP_DEFAULT_LOCALE ?? "en"
|
|
6
6
|
};
|
|
@@ -1,48 +1,48 @@
|
|
|
1
1
|
import { Config as S } from "../../conf/index.js";
|
|
2
|
-
import { get as
|
|
3
|
-
function
|
|
4
|
-
return JSON.parse(JSON.stringify(
|
|
2
|
+
import { get as y } from "../../api/commons.js";
|
|
3
|
+
function p(n) {
|
|
4
|
+
return JSON.parse(JSON.stringify(n));
|
|
5
5
|
}
|
|
6
|
-
const
|
|
7
|
-
function
|
|
8
|
-
return Object.keys(
|
|
6
|
+
const g = process.env.VITE_REACT_APP_API_ROOT || S.REACT_APP_API_ROOT || null, A = typeof window < "u" ? window.location.origin : "", l = {}, f = {}, C = 3 * 60 * 1e3;
|
|
7
|
+
function O(n) {
|
|
8
|
+
return Object.keys(n).map((t) => encodeURIComponent(t) + "=" + encodeURIComponent(n[t])).join("&");
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
const e =
|
|
12
|
-
if (
|
|
13
|
-
return Promise.resolve(f
|
|
14
|
-
if (
|
|
15
|
-
return
|
|
16
|
-
const c =
|
|
17
|
-
delete
|
|
10
|
+
function _(n, t = !1) {
|
|
11
|
+
const e = n, r = Date.now();
|
|
12
|
+
if (f[e] && r - f[e].timestamp < C)
|
|
13
|
+
return Promise.resolve(p(f[e].data));
|
|
14
|
+
if (l[e])
|
|
15
|
+
return l[e].then(p);
|
|
16
|
+
const c = y(n, {}).then((a) => (f[e] = { data: a, timestamp: Date.now() }, t ? { data: p(a), meta: f[e].meta } : p(a))).finally(() => {
|
|
17
|
+
delete l[e];
|
|
18
18
|
});
|
|
19
|
-
return
|
|
19
|
+
return l[e] = c, c;
|
|
20
20
|
}
|
|
21
|
-
const
|
|
22
|
-
const e = `${
|
|
23
|
-
return
|
|
24
|
-
},
|
|
25
|
-
const
|
|
26
|
-
return
|
|
27
|
-
},
|
|
28
|
-
const R = `${S.REACT_APP_WP_API}/wp/v2/${
|
|
29
|
-
if (!s ||
|
|
30
|
-
const u =
|
|
31
|
-
Array.isArray(
|
|
32
|
-
|
|
33
|
-
}) : u.push(String(
|
|
21
|
+
const E = ({ app: n, params: t }) => {
|
|
22
|
+
const e = `${g || A}/api/${n}/categories${t ? "?" + O(t) : ""}`;
|
|
23
|
+
return _(e);
|
|
24
|
+
}, U = ({ source: n, app: t, params: e }) => {
|
|
25
|
+
const r = `${g || A}/api/${t}/stats/${n}${e ? "?" + O(e) : ""}`;
|
|
26
|
+
return _(r);
|
|
27
|
+
}, D = ({ postType: n, taxonomy: t, category: e, taxonomyFilters: r, before: c, perPage: a, page: h, locale: w, after: m }) => {
|
|
28
|
+
const R = `${S.REACT_APP_WP_API}/wp/v2/${n}`, i = new URLSearchParams(), d = /* @__PURE__ */ new Map(), T = (s, o) => {
|
|
29
|
+
if (!s || o == null) return;
|
|
30
|
+
const u = d.get(s) || [];
|
|
31
|
+
Array.isArray(o) ? o.forEach((P) => {
|
|
32
|
+
P != null && u.push(String(P));
|
|
33
|
+
}) : u.push(String(o)), d.set(s, u);
|
|
34
34
|
};
|
|
35
|
-
|
|
36
|
-
T(
|
|
37
|
-
}),
|
|
35
|
+
r && r instanceof Map && r.forEach((s, o) => {
|
|
36
|
+
T(o, s);
|
|
37
|
+
}), d.forEach((s, o) => {
|
|
38
38
|
const u = Array.from(new Set(s));
|
|
39
|
-
i.set(
|
|
40
|
-
}), c && i.append("before", c.toISOString()), a && i.append("per_page", a.toString()), i.append("page",
|
|
39
|
+
i.set(o, u.join(","));
|
|
40
|
+
}), c && i.append("before", c.toISOString()), a && i.append("per_page", a.toString()), i.append("page", h.toString()), i.append("locale", w), m && i.append("after", m.toISOString());
|
|
41
41
|
const $ = i.toString().replace(/%2C/g, ",");
|
|
42
|
-
return
|
|
42
|
+
return y(`${R}?${$}`, {});
|
|
43
43
|
};
|
|
44
44
|
export {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
E as getCategories,
|
|
46
|
+
D as getCustomPosts,
|
|
47
|
+
U as getData
|
|
48
48
|
};
|