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