@pack/react 0.1.3 → 0.1.4-ab-test.1

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/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { RenderSections, useSections } from "./render-sections";
2
- import { PreviewProvider } from "./preview/preview-provider";
3
- import { usePreviewContext } from "./preview/preview-content";
2
+ import { PackProvider, PreviewProvider } from "./pack/pack-provider";
3
+ import { usePackContext, usePreviewContext } from "./pack/pack-context";
4
4
  import { useSiteSettings } from "./use-site-settings";
5
5
  import { useOverlayScript } from "./use-overlay-script";
6
6
  import { registerSection } from "./register-section";
7
7
  import { registerStorefrontSettingsSchema } from "./register-storefront-settings-schema";
8
- export { registerSection, registerStorefrontSettingsSchema, usePreviewContext, useSiteSettings, useOverlayScript, PreviewProvider, RenderSections, useSections, };
8
+ export { registerSection, registerStorefrontSettingsSchema, usePackContext, usePreviewContext, useSiteSettings, useOverlayScript, PackProvider, PreviewProvider, RenderSections, useSections, };
9
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,gCAAgC,EAAE,MAAM,uCAAuC,CAAC;AAEzF,OAAO,EACL,eAAe,EACf,gCAAgC,EAChC,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,WAAW,GACZ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,gCAAgC,EAAE,MAAM,uCAAuC,CAAC;AAEzF,OAAO,EACL,eAAe,EACf,gCAAgC,EAChC,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,cAAc,EACd,WAAW,GACZ,CAAC"}
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { RenderSections, useSections } from "./render-sections";
2
- import { PreviewProvider } from "./preview/preview-provider";
3
- import { usePreviewContext } from "./preview/preview-content";
2
+ import { PackProvider, PreviewProvider } from "./pack/pack-provider";
3
+ import { usePackContext, usePreviewContext } from "./pack/pack-context";
4
4
  import { useSiteSettings } from "./use-site-settings";
5
5
  import { useOverlayScript } from "./use-overlay-script";
6
6
  import { registerSection } from "./register-section";
7
7
  import { registerStorefrontSettingsSchema } from "./register-storefront-settings-schema";
8
- export { registerSection, registerStorefrontSettingsSchema, usePreviewContext, useSiteSettings, useOverlayScript, PreviewProvider, RenderSections, useSections, };
8
+ export { registerSection, registerStorefrontSettingsSchema, usePackContext, usePreviewContext, useSiteSettings, useOverlayScript, PackProvider, PreviewProvider, RenderSections, useSections, };
@@ -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,22 @@
1
+ /// <reference types="react" />
2
+ type PackCustomizerMeta = {
3
+ environment?: string;
4
+ overlay?: {
5
+ src?: string;
6
+ version?: string;
7
+ };
8
+ [key: string]: any;
9
+ };
10
+ export type PackContextValue = {
11
+ isPreview: boolean;
12
+ siteSettings: any;
13
+ customizerMeta?: PackCustomizerMeta | null;
14
+ previewStorefrontSettings?: any;
15
+ setPreviewStorefrontSettings: (siteSettings: any) => void;
16
+ };
17
+ export declare const PackContext: import("react").Context<PackContextValue>;
18
+ export declare const usePackContext: () => PackContextValue;
19
+ export declare const PreviewContext: import("react").Context<PackContextValue>;
20
+ export declare const usePreviewContext: () => PackContextValue;
21
+ export {};
22
+ //# 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,kBAAkB,GAAG;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE;QACR,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,GAAG,CAAC;IAClB,cAAc,CAAC,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAC3C,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,12 @@
1
+ import React, { ReactNode } from "react";
2
+ import { PackContextValue } from "./pack-context";
3
+ interface PackContentProps {
4
+ children: ReactNode;
5
+ siteSettings: any;
6
+ isPreviewModeEnabled?: boolean;
7
+ customizerMeta?: PackContextValue["customizerMeta"];
8
+ }
9
+ export declare function PackProvider({ children, isPreviewModeEnabled, siteSettings, customizerMeta, }: PackContentProps): React.JSX.Element;
10
+ export declare const PreviewProvider: typeof PackProvider;
11
+ export {};
12
+ //# 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;AACnD,OAAO,EAAe,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAI/D,UAAU,gBAAgB;IACxB,QAAQ,EAAE,SAAS,CAAC;IACpB,YAAY,EAAE,GAAG,CAAC;IAClB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,cAAc,CAAC,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;CACrD;AAED,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,EACR,oBAAoB,EACpB,YAAY,EACZ,cAAc,GACf,EAAE,gBAAgB,qBAqBlB;AAED,eAAO,MAAM,eAAe,qBAAe,CAAC"}
@@ -1,11 +1,11 @@
1
1
  import React, { useState } from "react";
2
+ import { PackContext } from "./pack-context";
2
3
  import { usePackTrack } from "./pack-analytics";
3
- import { PreviewContext } from "./preview-content";
4
4
  import { PreviewToast } from "./preview-toast";
5
- export function PreviewProvider({ children, isPreviewModeEnabled, siteSettings, customizerMeta, }) {
5
+ export function PackProvider({ children, isPreviewModeEnabled, siteSettings, customizerMeta, }) {
6
6
  const [previewStorefrontSettings, setPreviewStorefrontSettings] = useState();
7
7
  usePackTrack();
8
- return (React.createElement(PreviewContext.Provider, { value: {
8
+ return (React.createElement(PackContext.Provider, { value: {
9
9
  isPreview: !!isPreviewModeEnabled,
10
10
  previewStorefrontSettings,
11
11
  setPreviewStorefrontSettings,
@@ -15,3 +15,4 @@ export function PreviewProvider({ children, isPreviewModeEnabled, siteSettings,
15
15
  children,
16
16
  React.createElement(PreviewToast, { isPreviewModeEnabled: !!isPreviewModeEnabled })));
17
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"}
@@ -14,7 +14,7 @@ export const PreviewToast = ({ isPreviewModeEnabled }) => {
14
14
  },
15
15
  });
16
16
  if (!response.ok) {
17
- throw new Error(`HTTP error! Status: ${response.status}`);
17
+ throw new Error(`ERR_RE_API_ERROR: HTTP error! Status: ${response.status} Doc: https://docs.packdigital.com/err/ERR_RE_API_ERROR`);
18
18
  }
19
19
  window.location.reload();
20
20
  }
@@ -1,7 +1,7 @@
1
1
  export const sectionMap = new Map();
2
2
  export function registerSection(section, config) {
3
3
  if (typeof section !== "function") {
4
- throw new Error(`The section "${config.name}" is not a valid React component.`);
4
+ throw new Error(`ERR_RE_RENDER_SECTION: The section "${config.name}" is not a valid React component. Doc: https://docs.packdigital.com/err/ERR_RE_RENDER_SECTION`);
5
5
  }
6
6
  sectionMap.set(config.name, section);
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"render-sections.d.ts","sourceRoot":"","sources":["../src/render-sections.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6B,MAAM,OAAO,CAAC;AAuElD,wBAAgB,WAAW,CAAC,EAAE,OAAO,EAAE,EAAE,GAAG,OAM3C;AAED,wBAAgB,cAAc,CAAC,EAAE,OAAO,EAAE,EAAE,GAAG,4BAI9C"}
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"}
@@ -1,6 +1,7 @@
1
1
  import React, { useEffect, useMemo } from "react";
2
+ import { useMatches } from "@remix-run/react";
2
3
  import { useCustomizerShell } from "./use-customizer-shell";
3
- import { usePreviewContext } from "./preview/preview-content";
4
+ import { usePackContext } from "./pack/pack-context";
4
5
  import { sectionMap } from "./register-section";
5
6
  import { storefrontSettingsSchema } from "./register-storefront-settings-schema";
6
7
  import { useOverlayScript } from "./use-overlay-script";
@@ -26,18 +27,20 @@ function Sections({ sections }) {
26
27
  return React.createElement(React.Fragment, null, renderedSections);
27
28
  }
28
29
  function useRenderSections({ content }) {
29
- const { isPreview, setPreviewStorefrontSettings, customizerMeta } = usePreviewContext();
30
+ const { isPreview, setPreviewStorefrontSettings, customizerMeta } = usePackContext();
31
+ const [root] = useMatches();
32
+ const { ENV } = root?.data;
30
33
  const { content: liveContent, storefrontSettings } = useCustomizerShell({
31
- environment: "production",
34
+ environment: ENV?.PUBLIC_PACK_CONTENT_ENVIRONMENT,
32
35
  isPreview,
33
36
  sectionComponents: sectionMap,
34
37
  data: {
35
38
  content,
36
- template: content.template?.type,
37
- templateType: content.template?.type,
38
- handle: content.handle,
39
- title: content.title,
40
- description: content.description,
39
+ template: content?.template?.type,
40
+ templateType: content?.template?.type,
41
+ handle: content?.handle,
42
+ title: content?.title,
43
+ description: content?.description,
41
44
  },
42
45
  storefrontSettingsSchema,
43
46
  });
@@ -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 = "production", isPreview, sectionComponents, data = {}, storefrontSettingsSchema, }) => {
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);
@@ -1,4 +1,4 @@
1
- import { usePreviewContext } from "./preview/preview-content";
1
+ import { usePreviewContext } from "./pack/pack-context";
2
2
  export const useSiteSettings = () => {
3
3
  const { isPreview, previewStorefrontSettings, siteSettings } = usePreviewContext();
4
4
  let isIframe = false;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pack/react",
3
3
  "description": "React",
4
- "version": "0.1.3",
4
+ "version": "0.1.4-ab-test.1",
5
5
  "exports": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "engines": {
@@ -1 +0,0 @@
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"}
@@ -1,18 +0,0 @@
1
- /// <reference types="react" />
2
- type PreviewContextValue = {
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 PreviewContext: import("react").Context<PreviewContextValue>;
16
- export declare const usePreviewContext: () => PreviewContextValue;
17
- export {};
18
- //# sourceMappingURL=preview-content.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"preview-content.d.ts","sourceRoot":"","sources":["../../src/preview/preview-content.tsx"],"names":[],"mappings":";AAEA,KAAK,mBAAmB,GAAG;IACzB,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,cAAc,8CAKzB,CAAC;AAEH,eAAO,MAAM,iBAAiB,2BAAmC,CAAC"}
@@ -1,8 +0,0 @@
1
- import { createContext, useContext } from "react";
2
- export const PreviewContext = createContext({
3
- isPreview: false,
4
- setPreviewStorefrontSettings: () => { },
5
- siteSettings: undefined,
6
- customizerMeta: undefined,
7
- });
8
- export const usePreviewContext = () => useContext(PreviewContext);
@@ -1,16 +0,0 @@
1
- import React, { ReactNode } from "react";
2
- interface PreviewContentProps {
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 PreviewProvider({ children, isPreviewModeEnabled, siteSettings, customizerMeta, }: PreviewContentProps): React.JSX.Element;
15
- export {};
16
- //# sourceMappingURL=preview-provider.d.ts.map
@@ -1 +0,0 @@
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 +0,0 @@
1
- {"version":3,"file":"preview-toast.d.ts","sourceRoot":"","sources":["../../src/preview/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"}
File without changes
File without changes
File without changes