@loczer/storefront-sdk 0.163.0 → 0.164.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StorefrontProvider.d.ts","sourceRoot":"","sources":["../src/StorefrontProvider.tsx"],"names":[],"mappings":"AAKA,OAAO,EAIL,KAAK,sBAAsB,EAC5B,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAiC,KAAK,uBAAuB,EAAE,MAAM,qBAAqB,CAAA;AAEjG,OAAO,EAGL,KAAK,gBAAgB,EACrB,KAAK,WAAW,EACjB,MAAM,gBAAgB,CAAA;AAGvB,KAAK,sBAAsB,GAAG;IAC5B,SAAS,EAAE,MAAM,CAAA;IACjB,uBAAuB,EAAE,uBAAuB,CAAA;IAChD,KAAK,EAAE,WAAW,EAAE,CAAA;IACpB,WAAW,EAAE,gBAAgB,EAAE,CAAA;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,EAAE,sBAAsB,CAAA;CACjC,CAAA;AAKD,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"StorefrontProvider.d.ts","sourceRoot":"","sources":["../src/StorefrontProvider.tsx"],"names":[],"mappings":"AAKA,OAAO,EAIL,KAAK,sBAAsB,EAC5B,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAiC,KAAK,uBAAuB,EAAE,MAAM,qBAAqB,CAAA;AAEjG,OAAO,EAGL,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAC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C;AAED,wBAAgB,8BAA8B,IAAI,sBAAsB,CAGvE;AAED,wBAAgB,qBAAqB;;;EAGpC"}
|
|
@@ -1,95 +1,96 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { useLoaderData as
|
|
4
|
-
import { apiClient as
|
|
5
|
-
import { Layout as
|
|
6
|
-
import { I18nProvider as
|
|
7
|
-
import { storefrontConfigurationSchema as
|
|
8
|
-
import { ROUTE as
|
|
9
|
-
import { toStorefrontBikeProducts as
|
|
10
|
-
const
|
|
11
|
-
const t = typeof
|
|
1
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as v, useContext as k } from "react";
|
|
3
|
+
import { useLoaderData as C } from "@rpcbase/router";
|
|
4
|
+
import { apiClient as S } from "@rpcbase/client";
|
|
5
|
+
import { Layout as L } from "./components/Layout/index.js";
|
|
6
|
+
import { I18nProvider as P, resolveStorefrontI18nRequestLanguage as _, detectStorefrontI18nLanguage as R } from "./i18n/I18nProvider.js";
|
|
7
|
+
import { storefrontConfigurationSchema as b } from "./storefrontSchemas.js";
|
|
8
|
+
import { ROUTE as B, responseSchema as E } from "./lib/storefrontProducts.js";
|
|
9
|
+
import { toStorefrontBikeProducts as I, toStorefrontAccessoryProducts as O } from "./lib/products.js";
|
|
10
|
+
const y = {}, u = v(void 0), j = (async ({ ctx: o, params: r }) => {
|
|
11
|
+
const t = typeof r.storeSlug == "string" ? r.storeSlug.trim().toLowerCase() : "";
|
|
12
12
|
if (!t) throw new Response("Store not found", { status: 404, statusText: "Store not found" });
|
|
13
13
|
try {
|
|
14
|
-
const
|
|
15
|
-
if (
|
|
14
|
+
const n = S.get(B, { storeSlug: t }, o).then((e) => ({ ok: !0, productsResponse: e })).catch((e) => ({ ok: !1, productsError: e })), a = await S.get("/api/public/storefront/config", { storeSlug: t }, o), g = typeof a == "object" && a !== null ? a : {};
|
|
15
|
+
if (g.success !== !0)
|
|
16
16
|
throw new Response("Store not found", { status: 404, statusText: "Store not found" });
|
|
17
|
-
const
|
|
18
|
-
if (!
|
|
19
|
-
throw console.error("Invalid storefront config received",
|
|
20
|
-
let
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
17
|
+
const s = b.safeParse(g.storefrontConfiguration);
|
|
18
|
+
if (!s.success)
|
|
19
|
+
throw console.error("Invalid storefront config received", s.error.flatten()), new Response("Storefront config invalid", { status: 500 });
|
|
20
|
+
let d = [], p = [];
|
|
21
|
+
const c = await n;
|
|
22
|
+
if (!c.ok)
|
|
23
|
+
console.error("Error fetching storefront products:", c.productsError);
|
|
24
|
+
else {
|
|
25
|
+
const e = E.safeParse(c.productsResponse);
|
|
26
|
+
if (!e.success)
|
|
27
|
+
console.error("Invalid storefront products received", e.error.flatten());
|
|
28
|
+
else if (!e.data.success)
|
|
29
|
+
console.error("Storefront products unavailable", e.data.message ?? "Unknown error");
|
|
27
30
|
else {
|
|
28
|
-
const
|
|
29
|
-
|
|
31
|
+
const w = e.data.products;
|
|
32
|
+
d = I(w?.bikes ?? []), p = O(w?.accessories ?? []);
|
|
30
33
|
}
|
|
31
|
-
} catch (a) {
|
|
32
|
-
console.error("Error fetching storefront products:", a);
|
|
33
34
|
}
|
|
34
|
-
const l =
|
|
35
|
+
const l = s.data.workspace?.languages ?? null, m = s.data.workspace?.workspaceLanguage ?? null, h = o?.req ? _({
|
|
35
36
|
cookieHeader: o.req.headers?.cookie,
|
|
36
37
|
acceptLanguageHeader: o.req.headers?.["accept-language"],
|
|
37
38
|
configuredLanguages: l,
|
|
38
|
-
configuredFallbackLanguage:
|
|
39
|
-
}) :
|
|
39
|
+
configuredFallbackLanguage: m
|
|
40
|
+
}) : R(l, m);
|
|
40
41
|
return {
|
|
41
42
|
storeSlug: t,
|
|
42
|
-
storefrontConfiguration:
|
|
43
|
-
bikes:
|
|
44
|
-
accessories:
|
|
43
|
+
storefrontConfiguration: s.data,
|
|
44
|
+
bikes: d,
|
|
45
|
+
accessories: p,
|
|
45
46
|
language: h
|
|
46
47
|
};
|
|
47
|
-
} catch (
|
|
48
|
-
throw
|
|
48
|
+
} catch (n) {
|
|
49
|
+
throw n instanceof Response ? n : (console.error("Error fetching storefront config:", n), new Response("Storefront config unavailable", { status: 500 }));
|
|
49
50
|
}
|
|
50
51
|
});
|
|
51
|
-
function
|
|
52
|
-
const o =
|
|
53
|
-
return /* @__PURE__ */
|
|
54
|
-
|
|
52
|
+
function F() {
|
|
53
|
+
const o = C(), r = y, t = typeof r?.RB_PUBLIC_MAPBOX_TOKEN == "string" && r.RB_PUBLIC_MAPBOX_TOKEN.trim().length > 0 ? r.RB_PUBLIC_MAPBOX_TOKEN : void 0;
|
|
54
|
+
return /* @__PURE__ */ i(u.Provider, { value: { ...o, mapboxToken: t }, children: /* @__PURE__ */ i(
|
|
55
|
+
P,
|
|
55
56
|
{
|
|
56
57
|
initialLanguage: o.language,
|
|
57
58
|
configuredLanguages: o.storefrontConfiguration.workspace?.languages,
|
|
58
59
|
configuredFallbackLanguage: o.storefrontConfiguration.workspace?.workspaceLanguage,
|
|
59
|
-
children: /* @__PURE__ */
|
|
60
|
+
children: /* @__PURE__ */ i(L, { storefrontConfiguration: o.storefrontConfiguration })
|
|
60
61
|
}
|
|
61
62
|
) });
|
|
62
63
|
}
|
|
63
|
-
function
|
|
64
|
-
const o =
|
|
64
|
+
function f() {
|
|
65
|
+
const o = k(u);
|
|
65
66
|
if (o === void 0)
|
|
66
67
|
throw new Error("must be used within the provider");
|
|
67
68
|
return o;
|
|
68
69
|
}
|
|
69
|
-
function F() {
|
|
70
|
-
return S(i);
|
|
71
|
-
}
|
|
72
70
|
function H() {
|
|
73
|
-
|
|
71
|
+
return k(u);
|
|
72
|
+
}
|
|
73
|
+
function D() {
|
|
74
|
+
const { storefrontConfiguration: o } = f();
|
|
74
75
|
return {
|
|
75
76
|
config: o,
|
|
76
77
|
storefrontConfiguration: o
|
|
77
78
|
};
|
|
78
79
|
}
|
|
79
|
-
function
|
|
80
|
-
const { storefrontConfiguration: o } =
|
|
80
|
+
function W() {
|
|
81
|
+
const { storefrontConfiguration: o } = f();
|
|
81
82
|
return o.workspace?.workspaceLanguage ?? "en";
|
|
82
83
|
}
|
|
83
|
-
function
|
|
84
|
-
const { bikes: o, accessories:
|
|
85
|
-
return { bikes: o, accessories:
|
|
84
|
+
function z() {
|
|
85
|
+
const { bikes: o, accessories: r } = f();
|
|
86
|
+
return { bikes: o, accessories: r };
|
|
86
87
|
}
|
|
87
88
|
export {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
89
|
+
F as default,
|
|
90
|
+
j as loader,
|
|
91
|
+
H as useOptionalStorefront,
|
|
92
|
+
f as useStorefront,
|
|
93
|
+
D as useStorefrontConfig,
|
|
94
|
+
z as useStorefrontProducts,
|
|
95
|
+
W as useStorefrontWorkspaceLanguage
|
|
95
96
|
};
|