@pack/react 0.1.2 → 0.1.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/pack/pack-analytics.d.ts +16 -0
- package/dist/pack/pack-analytics.d.ts.map +1 -0
- package/dist/pack/pack-analytics.js +65 -0
- package/dist/pack/pack-context.d.ts +20 -0
- package/dist/pack/pack-context.d.ts.map +1 -0
- package/dist/pack/pack-context.js +10 -0
- package/dist/pack/pack-provider.d.ts +17 -0
- package/dist/pack/pack-provider.d.ts.map +1 -0
- package/dist/pack/pack-provider.js +18 -0
- package/dist/pack/preview-toast.d.ts +7 -0
- package/dist/pack/preview-toast.d.ts.map +1 -0
- package/dist/pack/preview-toast.js +85 -0
- package/dist/preview/pack-analytics.d.ts +16 -0
- package/dist/preview/pack-analytics.d.ts.map +1 -0
- package/dist/preview/pack-analytics.js +65 -0
- package/dist/preview/preview-provider.d.ts.map +1 -1
- package/dist/preview/preview-provider.js +2 -0
- package/dist/render-sections.d.ts.map +1 -1
- package/dist/render-sections.js +4 -1
- package/dist/use-customizer-shell.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type BrowserData = {
|
|
2
|
+
userAgent: string;
|
|
3
|
+
pathname: string;
|
|
4
|
+
query: string;
|
|
5
|
+
screen: string;
|
|
6
|
+
referrer: string;
|
|
7
|
+
hostname: string;
|
|
8
|
+
language: string;
|
|
9
|
+
locale: string;
|
|
10
|
+
userTimeZone: string;
|
|
11
|
+
connection: string;
|
|
12
|
+
deviceCategory: string;
|
|
13
|
+
href: string;
|
|
14
|
+
};
|
|
15
|
+
export declare function usePackTrack(): void;
|
|
16
|
+
//# sourceMappingURL=pack-analytics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pack-analytics.d.ts","sourceRoot":"","sources":["../../src/pack/pack-analytics.tsx"],"names":[],"mappings":"AAEA,MAAM,MAAM,WAAW,GAAG;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAiDF,wBAAgB,YAAY,SA0B3B"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
function getBrowserData() {
|
|
3
|
+
let userTimeZone;
|
|
4
|
+
let userLocale;
|
|
5
|
+
try {
|
|
6
|
+
userTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
7
|
+
userLocale =
|
|
8
|
+
navigator.languages && navigator.languages.length
|
|
9
|
+
? navigator.languages[0]
|
|
10
|
+
: navigator.userLanguage ||
|
|
11
|
+
navigator.language ||
|
|
12
|
+
navigator.browserLanguage ||
|
|
13
|
+
"unknown";
|
|
14
|
+
}
|
|
15
|
+
catch (error) { }
|
|
16
|
+
const connection = navigator.connection ||
|
|
17
|
+
navigator.mozConnection ||
|
|
18
|
+
navigator.webkitConnection;
|
|
19
|
+
const minWidth = 768;
|
|
20
|
+
// prettier-ignore
|
|
21
|
+
const hasTouchSupport = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
|
|
22
|
+
let deviceCategory = "desktop";
|
|
23
|
+
if (hasTouchSupport) {
|
|
24
|
+
const hasSmallScreen = window.screen.width < minWidth;
|
|
25
|
+
deviceCategory = hasSmallScreen ? "mobile" : "tablet";
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
userAgent: window.navigator.userAgent,
|
|
29
|
+
pathname: window.location.pathname,
|
|
30
|
+
query: window.location.search,
|
|
31
|
+
screen: `${window.screen.width}x${window.screen.height}`,
|
|
32
|
+
referrer: document.referrer,
|
|
33
|
+
hostname: window.location.hostname,
|
|
34
|
+
language: navigator.language,
|
|
35
|
+
locale: userLocale,
|
|
36
|
+
userTimeZone: userTimeZone || "unknown",
|
|
37
|
+
connection: connection?.effectiveType || "unknown",
|
|
38
|
+
deviceCategory,
|
|
39
|
+
href: window.location.href,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export function usePackTrack() {
|
|
43
|
+
const [pathname, setPathname] = useState();
|
|
44
|
+
const analytics = async () => {
|
|
45
|
+
const browserData = getBrowserData();
|
|
46
|
+
if (pathname === browserData.pathname)
|
|
47
|
+
return;
|
|
48
|
+
setPathname(browserData.pathname);
|
|
49
|
+
try {
|
|
50
|
+
await fetch("/pack/track", {
|
|
51
|
+
method: "POST",
|
|
52
|
+
headers: {
|
|
53
|
+
"Content-Type": "application/json",
|
|
54
|
+
},
|
|
55
|
+
body: JSON.stringify(getBrowserData()),
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
console.error("Error hit /pack/track: ", error.message);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
analytics();
|
|
64
|
+
}, [analytics]);
|
|
65
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
type PackContextValue = {
|
|
3
|
+
isPreview: boolean;
|
|
4
|
+
siteSettings: any;
|
|
5
|
+
customizerMeta?: {
|
|
6
|
+
overlay?: {
|
|
7
|
+
src?: string;
|
|
8
|
+
version?: string;
|
|
9
|
+
};
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
};
|
|
12
|
+
previewStorefrontSettings?: any;
|
|
13
|
+
setPreviewStorefrontSettings: (siteSettings: any) => void;
|
|
14
|
+
};
|
|
15
|
+
export declare const PackContext: import("react").Context<PackContextValue>;
|
|
16
|
+
export declare const usePackContext: () => PackContextValue;
|
|
17
|
+
export declare const PreviewContext: import("react").Context<PackContextValue>;
|
|
18
|
+
export declare const usePreviewContext: () => PackContextValue;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=pack-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pack-context.d.ts","sourceRoot":"","sources":["../../src/pack/pack-context.tsx"],"names":[],"mappings":";AAEA,KAAK,gBAAgB,GAAG;IACtB,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,GAAG,CAAC;IAClB,cAAc,CAAC,EAAE;QACf,OAAO,CAAC,EAAE;YACR,GAAG,CAAC,EAAE,MAAM,CAAC;YACb,OAAO,CAAC,EAAE,MAAM,CAAC;SAClB,CAAC;QACF,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;IACF,yBAAyB,CAAC,EAAE,GAAG,CAAC;IAChC,4BAA4B,EAAE,CAAC,YAAY,EAAE,GAAG,KAAK,IAAI,CAAC;CAC3D,CAAC;AAEF,eAAO,MAAM,WAAW,2CAKtB,CAAC;AAEH,eAAO,MAAM,cAAc,wBAAgC,CAAC;AAE5D,eAAO,MAAM,cAAc,2CAAc,CAAC;AAE1C,eAAO,MAAM,iBAAiB,wBAAiB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
export const PackContext = createContext({
|
|
3
|
+
isPreview: false,
|
|
4
|
+
setPreviewStorefrontSettings: () => { },
|
|
5
|
+
siteSettings: undefined,
|
|
6
|
+
customizerMeta: undefined,
|
|
7
|
+
});
|
|
8
|
+
export const usePackContext = () => useContext(PackContext);
|
|
9
|
+
export const PreviewContext = PackContext;
|
|
10
|
+
export const usePreviewContext = usePackContext;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
interface PackContentProps {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
siteSettings: any;
|
|
5
|
+
isPreviewModeEnabled?: boolean;
|
|
6
|
+
customizerMeta?: {
|
|
7
|
+
overlay?: {
|
|
8
|
+
src?: string;
|
|
9
|
+
version?: string;
|
|
10
|
+
};
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export declare function PackProvider({ children, isPreviewModeEnabled, siteSettings, customizerMeta, }: PackContentProps): React.JSX.Element;
|
|
15
|
+
export declare const PreviewProvider: typeof PackProvider;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=pack-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pack-provider.d.ts","sourceRoot":"","sources":["../../src/pack/pack-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AAKnD,UAAU,gBAAgB;IACxB,QAAQ,EAAE,SAAS,CAAC;IACpB,YAAY,EAAE,GAAG,CAAC;IAClB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,cAAc,CAAC,EAAE;QACf,OAAO,CAAC,EAAE;YACR,GAAG,CAAC,EAAE,MAAM,CAAC;YACb,OAAO,CAAC,EAAE,MAAM,CAAC;SAClB,CAAC;QACF,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;CACH;AAED,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,EACR,oBAAoB,EACpB,YAAY,EACZ,cAAc,GACf,EAAE,gBAAgB,qBAqBlB;AAED,eAAO,MAAM,eAAe,qBAAe,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { PackContext } from "./pack-context";
|
|
3
|
+
import { usePackTrack } from "./pack-analytics";
|
|
4
|
+
import { PreviewToast } from "./preview-toast";
|
|
5
|
+
export function PackProvider({ children, isPreviewModeEnabled, siteSettings, customizerMeta, }) {
|
|
6
|
+
const [previewStorefrontSettings, setPreviewStorefrontSettings] = useState();
|
|
7
|
+
usePackTrack();
|
|
8
|
+
return (React.createElement(PackContext.Provider, { value: {
|
|
9
|
+
isPreview: !!isPreviewModeEnabled,
|
|
10
|
+
previewStorefrontSettings,
|
|
11
|
+
setPreviewStorefrontSettings,
|
|
12
|
+
siteSettings,
|
|
13
|
+
customizerMeta,
|
|
14
|
+
} },
|
|
15
|
+
children,
|
|
16
|
+
React.createElement(PreviewToast, { isPreviewModeEnabled: !!isPreviewModeEnabled })));
|
|
17
|
+
}
|
|
18
|
+
export const PreviewProvider = PackProvider;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview-toast.d.ts","sourceRoot":"","sources":["../../src/pack/preview-toast.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAEnD,UAAU,iBAAiB;IACzB,oBAAoB,EAAE,OAAO,CAAC;CAC/B;AAsBD,eAAO,MAAM,YAAY,6BAA8B,iBAAiB,6BA+GvE,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
|
+
const Eye = (props) => {
|
|
3
|
+
return (React.createElement("svg", { width: 24, height: 24, viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props },
|
|
4
|
+
React.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M2.75 12c0-.338.136-.905.493-1.591a7.858 7.858 0 0 1 1.64-2.108C6.374 6.926 8.694 5.75 12 5.75c3.308 0 5.627 1.176 7.116 2.551a7.86 7.86 0 0 1 1.64 2.108c.358.686.494 1.253.494 1.591 0 .338-.136.905-.493 1.591a7.86 7.86 0 0 1-1.64 2.108c-1.49 1.375-3.81 2.551-7.117 2.551-3.308 0-5.627-1.176-7.116-2.551a7.858 7.858 0 0 1-1.64-2.108c-.358-.686-.494-1.253-.494-1.591ZM12 4.25c-3.692 0-6.373 1.324-8.134 2.949a9.356 9.356 0 0 0-1.953 2.517c-.424.814-.663 1.622-.663 2.284 0 .662.24 1.47.663 2.284a9.356 9.356 0 0 0 1.953 2.517C5.627 18.426 8.308 19.75 12 19.75s6.373-1.324 8.134-2.949a9.356 9.356 0 0 0 1.953-2.517c.424-.814.663-1.622.663-2.284 0-.662-.24-1.47-.663-2.284a9.355 9.355 0 0 0-1.953-2.517C18.373 5.574 15.692 4.25 12 4.25ZM9.75 12a2.25 2.25 0 1 1 4.5 0 2.25 2.25 0 0 1-4.5 0ZM12 8.25a3.75 3.75 0 1 0 0 7.5 3.75 3.75 0 0 0 0-7.5Z", fill: "currentColor" })));
|
|
5
|
+
};
|
|
6
|
+
export const PreviewToast = ({ isPreviewModeEnabled }) => {
|
|
7
|
+
const [showToast, setShowToast] = useState(false);
|
|
8
|
+
const exitPreviewMode = async () => {
|
|
9
|
+
try {
|
|
10
|
+
const response = await fetch("/api/edit", {
|
|
11
|
+
method: "POST",
|
|
12
|
+
headers: {
|
|
13
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
if (!response.ok) {
|
|
17
|
+
throw new Error(`HTTP error! Status: ${response.status}`);
|
|
18
|
+
}
|
|
19
|
+
window.location.reload();
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
console.error("Error exiting preview:", error.message);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
const isIframe = window.self !== window.top;
|
|
27
|
+
if (isPreviewModeEnabled && !isIframe) {
|
|
28
|
+
setShowToast(true);
|
|
29
|
+
}
|
|
30
|
+
}, [isPreviewModeEnabled]);
|
|
31
|
+
if (showToast) {
|
|
32
|
+
return (React.createElement("div", { style: {
|
|
33
|
+
position: "fixed",
|
|
34
|
+
zIndex: "2147483647",
|
|
35
|
+
left: "50%",
|
|
36
|
+
transform: "translateX(-50%)",
|
|
37
|
+
padding: "0 16px",
|
|
38
|
+
bottom: "16px",
|
|
39
|
+
width: "100%",
|
|
40
|
+
pointerEvents: "none",
|
|
41
|
+
} },
|
|
42
|
+
React.createElement("div", { style: {
|
|
43
|
+
margin: "0 auto",
|
|
44
|
+
pointerEvents: "auto",
|
|
45
|
+
maxWidth: "640px",
|
|
46
|
+
boxShadow: "0px 2px 10px 0px rgba(0, 0, 0, 0.10), 0px 0px 2px 0px rgba(0, 0, 0, 0.10)",
|
|
47
|
+
width: "100%",
|
|
48
|
+
padding: "8px 16px",
|
|
49
|
+
backgroundColor: "#1f2937",
|
|
50
|
+
color: "#f9fafb",
|
|
51
|
+
borderRadius: "8px",
|
|
52
|
+
display: "flex",
|
|
53
|
+
alignItems: "center",
|
|
54
|
+
fontFamily: '"Inter", sans-serif',
|
|
55
|
+
justifyContent: "space-between",
|
|
56
|
+
gap: "8px",
|
|
57
|
+
} },
|
|
58
|
+
React.createElement("div", { style: {
|
|
59
|
+
display: "flex",
|
|
60
|
+
alignItems: "center",
|
|
61
|
+
gap: "8px",
|
|
62
|
+
overflow: "hidden",
|
|
63
|
+
} },
|
|
64
|
+
React.createElement(Eye, { style: { width: 16, height: 16, minWidth: 16 } }),
|
|
65
|
+
React.createElement("p", { style: {
|
|
66
|
+
flex: 1,
|
|
67
|
+
fontSize: "14px",
|
|
68
|
+
lineHeight: "20px",
|
|
69
|
+
whiteSpace: "nowrap",
|
|
70
|
+
textOverflow: "ellipsis",
|
|
71
|
+
overflow: "hidden",
|
|
72
|
+
} }, "You are currently previewing your storefront with draft content")),
|
|
73
|
+
React.createElement("span", { role: "button", tabIndex: 0, onClick: exitPreviewMode, onKeyDown: (e) => {
|
|
74
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
75
|
+
exitPreviewMode();
|
|
76
|
+
}
|
|
77
|
+
}, style: {
|
|
78
|
+
cursor: "pointer",
|
|
79
|
+
fontSize: 13,
|
|
80
|
+
fontWeight: "500",
|
|
81
|
+
flexShrink: "0",
|
|
82
|
+
} }, "Exit preview mode"))));
|
|
83
|
+
}
|
|
84
|
+
return null;
|
|
85
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type BrowserData = {
|
|
2
|
+
userAgent: string;
|
|
3
|
+
pathname: string;
|
|
4
|
+
query: string;
|
|
5
|
+
screen: string;
|
|
6
|
+
referrer: string;
|
|
7
|
+
hostname: string;
|
|
8
|
+
language: string;
|
|
9
|
+
locale: string;
|
|
10
|
+
userTimeZone: string;
|
|
11
|
+
connection: string;
|
|
12
|
+
deviceCategory: string;
|
|
13
|
+
href: string;
|
|
14
|
+
};
|
|
15
|
+
export declare function usePackTrack(): void;
|
|
16
|
+
//# sourceMappingURL=pack-analytics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pack-analytics.d.ts","sourceRoot":"","sources":["../../src/preview/pack-analytics.tsx"],"names":[],"mappings":"AAEA,MAAM,MAAM,WAAW,GAAG;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAiDF,wBAAgB,YAAY,SA0B3B"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
function getBrowserData() {
|
|
3
|
+
let userTimeZone;
|
|
4
|
+
let userLocale;
|
|
5
|
+
try {
|
|
6
|
+
userTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
7
|
+
userLocale =
|
|
8
|
+
navigator.languages && navigator.languages.length
|
|
9
|
+
? navigator.languages[0]
|
|
10
|
+
: navigator.userLanguage ||
|
|
11
|
+
navigator.language ||
|
|
12
|
+
navigator.browserLanguage ||
|
|
13
|
+
"unknown";
|
|
14
|
+
}
|
|
15
|
+
catch (error) { }
|
|
16
|
+
const connection = navigator.connection ||
|
|
17
|
+
navigator.mozConnection ||
|
|
18
|
+
navigator.webkitConnection;
|
|
19
|
+
const minWidth = 768;
|
|
20
|
+
// prettier-ignore
|
|
21
|
+
const hasTouchSupport = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
|
|
22
|
+
let deviceCategory = "desktop";
|
|
23
|
+
if (hasTouchSupport) {
|
|
24
|
+
const hasSmallScreen = window.screen.width < minWidth;
|
|
25
|
+
deviceCategory = hasSmallScreen ? "mobile" : "tablet";
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
userAgent: window.navigator.userAgent,
|
|
29
|
+
pathname: window.location.pathname,
|
|
30
|
+
query: window.location.search,
|
|
31
|
+
screen: `${window.screen.width}x${window.screen.height}`,
|
|
32
|
+
referrer: document.referrer,
|
|
33
|
+
hostname: window.location.hostname,
|
|
34
|
+
language: navigator.language,
|
|
35
|
+
locale: userLocale,
|
|
36
|
+
userTimeZone: userTimeZone || "unknown",
|
|
37
|
+
connection: connection?.effectiveType || "unknown",
|
|
38
|
+
deviceCategory,
|
|
39
|
+
href: window.location.href,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export function usePackTrack() {
|
|
43
|
+
const [pathname, setPathname] = useState();
|
|
44
|
+
const analytics = async () => {
|
|
45
|
+
const browserData = getBrowserData();
|
|
46
|
+
if (pathname === browserData.pathname)
|
|
47
|
+
return;
|
|
48
|
+
setPathname(browserData.pathname);
|
|
49
|
+
try {
|
|
50
|
+
await fetch("/pack/track", {
|
|
51
|
+
method: "POST",
|
|
52
|
+
headers: {
|
|
53
|
+
"Content-Type": "application/json",
|
|
54
|
+
},
|
|
55
|
+
body: JSON.stringify(getBrowserData()),
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
console.error("Error hit /pack/track: ", error.message);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
analytics();
|
|
64
|
+
}, [analytics]);
|
|
65
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preview-provider.d.ts","sourceRoot":"","sources":["../../src/preview/preview-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"preview-provider.d.ts","sourceRoot":"","sources":["../../src/preview/preview-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AAKnD,UAAU,mBAAmB;IAC3B,QAAQ,EAAE,SAAS,CAAC;IACpB,YAAY,EAAE,GAAG,CAAC;IAClB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,cAAc,CAAC,EAAE;QACf,OAAO,CAAC,EAAE;YACR,GAAG,CAAC,EAAE,MAAM,CAAC;YACb,OAAO,CAAC,EAAE,MAAM,CAAC;SAClB,CAAC;QACF,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;CACH;AAED,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EACR,oBAAoB,EACpB,YAAY,EACZ,cAAc,GACf,EAAE,mBAAmB,qBAqBrB"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
|
+
import { usePackTrack } from "./pack-analytics";
|
|
2
3
|
import { PreviewContext } from "./preview-content";
|
|
3
4
|
import { PreviewToast } from "./preview-toast";
|
|
4
5
|
export function PreviewProvider({ children, isPreviewModeEnabled, siteSettings, customizerMeta, }) {
|
|
5
6
|
const [previewStorefrontSettings, setPreviewStorefrontSettings] = useState();
|
|
7
|
+
usePackTrack();
|
|
6
8
|
return (React.createElement(PreviewContext.Provider, { value: {
|
|
7
9
|
isPreview: !!isPreviewModeEnabled,
|
|
8
10
|
previewStorefrontSettings,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-sections.d.ts","sourceRoot":"","sources":["../src/render-sections.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6B,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"render-sections.d.ts","sourceRoot":"","sources":["../src/render-sections.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6B,MAAM,OAAO,CAAC;AA8ElD,wBAAgB,WAAW,CAAC,EAAE,OAAO,EAAE,EAAE,GAAG,OAM3C;AAED,wBAAgB,cAAc,CAAC,EAAE,OAAO,EAAE,EAAE,GAAG,4BAI9C"}
|
package/dist/render-sections.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { useEffect, useMemo } from "react";
|
|
2
|
+
import { useMatches } from "@remix-run/react";
|
|
2
3
|
import { useCustomizerShell } from "./use-customizer-shell";
|
|
3
4
|
import { usePreviewContext } from "./preview/preview-content";
|
|
4
5
|
import { sectionMap } from "./register-section";
|
|
@@ -27,8 +28,10 @@ function Sections({ sections }) {
|
|
|
27
28
|
}
|
|
28
29
|
function useRenderSections({ content }) {
|
|
29
30
|
const { isPreview, setPreviewStorefrontSettings, customizerMeta } = usePreviewContext();
|
|
31
|
+
const [root] = useMatches();
|
|
32
|
+
const { ENV } = root?.data;
|
|
30
33
|
const { content: liveContent, storefrontSettings } = useCustomizerShell({
|
|
31
|
-
environment:
|
|
34
|
+
environment: ENV?.PUBLIC_PACK_CONTENT_ENVIRONMENT,
|
|
32
35
|
isPreview,
|
|
33
36
|
sectionComponents: sectionMap,
|
|
34
37
|
data: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2
2
|
import { connectToParent, ErrorCode } from "penpal";
|
|
3
|
-
export const useCustomizerShell = ({ environment
|
|
3
|
+
export const useCustomizerShell = ({ environment, isPreview, sectionComponents, data = {}, storefrontSettingsSchema, }) => {
|
|
4
4
|
const windowLocationRef = useRef();
|
|
5
5
|
const [content, setContent] = useState(data.content);
|
|
6
6
|
const [storefrontSettings, setStorefrontSettings] = useState(null);
|