@okendo/shopify-hydrogen 0.0.2 → 0.0.3
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/esnext/components/OkendoProvider.server.d.ts +4 -4
- package/dist/esnext/components/OkendoProvider.server.js +34 -16
- package/dist/esnext/components/OkendoProvider.server.js.map +1 -1
- package/dist/esnext/components/OkendoReviewsWidget.server.js +13 -11
- package/dist/esnext/components/OkendoReviewsWidget.server.js.map +1 -1
- package/dist/esnext/components/OkendoStarRating.server.js +10 -7
- package/dist/esnext/components/OkendoStarRating.server.js.map +1 -1
- package/dist/esnext/components/OkendoWidget.client.d.ts +3 -3
- package/dist/esnext/components/OkendoWidget.client.js +2 -3
- package/dist/esnext/components/OkendoWidget.client.js.map +1 -1
- package/dist/esnext/index.d.ts +1 -0
- package/dist/esnext/index.js +1 -0
- package/dist/esnext/index.js.map +1 -1
- package/dist/esnext/shared/errorUtils.d.ts +3 -0
- package/dist/esnext/shared/errorUtils.js +10 -0
- package/dist/esnext/shared/errorUtils.js.map +1 -0
- package/dist/esnext/shared/index.d.ts +3 -0
- package/dist/esnext/shared/index.js +4 -0
- package/dist/esnext/shared/index.js.map +1 -0
- package/dist/esnext/shared/requestUtils.d.ts +12 -0
- package/dist/esnext/shared/requestUtils.js +11 -0
- package/dist/esnext/shared/requestUtils.js.map +1 -0
- package/dist/node/plugin/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import React from
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ServerComponentRequest } from '@shopify/hydrogen/dist/esnext/framework/Hydration/ServerComponentRequest.server';
|
|
2
3
|
import type { ReviewWithProductPublic } from '@okendo/reviews-common';
|
|
3
|
-
export declare const OkendoContext: React.Context<{}>;
|
|
4
4
|
export declare const OkendoProvider: React.FunctionComponent<OkendoProviderProps>;
|
|
5
5
|
interface OkendoProviderProps {
|
|
6
|
-
children: React.ReactNode;
|
|
7
|
-
subscriberId: string;
|
|
8
6
|
apiDomain?: string;
|
|
9
7
|
cdnDomain?: string;
|
|
10
8
|
productUrlFormatOverride?: (product: Pick<ReviewWithProductPublic, 'productHandle' | 'productId' | 'variantId'>) => string;
|
|
9
|
+
request: ServerComponentRequest;
|
|
10
|
+
subscriberId: string;
|
|
11
11
|
}
|
|
12
12
|
export {};
|
|
@@ -1,23 +1,41 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import parse from
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import parse from 'html-react-parser';
|
|
3
|
+
import { fetchSync, useShopQuery, gql, CacheMinutes } from '@shopify/hydrogen';
|
|
4
|
+
import { Head } from '@shopify/hydrogen/client';
|
|
5
|
+
import { okendoError, setInOkendoRequestContext } from '../shared';
|
|
6
6
|
const kDefaultOkendoApiDomain = 'api.okendo.io/v1';
|
|
7
7
|
const kDefaultOkendoCdnDomain = 'd3hw6dc1ow8pp2.cloudfront.net';
|
|
8
|
-
export const OkendoContext = React.createContext(kDefaultContext);
|
|
9
8
|
export const OkendoProvider = (props) => {
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
const { apiDomain, cdnDomain, productUrlFormatOverride, request, subscriberId } = props;
|
|
10
|
+
// Download subscriber widget plus settings.
|
|
12
11
|
const url = `https://${apiDomain !== null && apiDomain !== void 0 ? apiDomain : kDefaultOkendoApiDomain}/stores/${subscriberId}/widget_plus_settings`;
|
|
13
|
-
const
|
|
12
|
+
const settingsResponse = fetchSync(url, { preload: true });
|
|
13
|
+
if (!settingsResponse.response.ok) {
|
|
14
|
+
console.error(okendoError('Failed to retrieve subscriber settings. Please check your environment variables.'));
|
|
15
|
+
setInOkendoRequestContext(request, 'setupFailed', true);
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const { cssVariables, customCss, reviewsHeaderConfig, starSymbols } = settingsResponse.json();
|
|
14
19
|
const cssVariablesNormalized = cssVariables.replace('<style id="oke-css-vars">', '').replace('</style>', '');
|
|
15
|
-
const customCssNormalized = customCss
|
|
20
|
+
const customCssNormalized = customCss ? customCss.replace('<style id="oke-reviews-custom-css">', '').replace('</style>', '') : '';
|
|
21
|
+
// Download contents of widget initialisation script.
|
|
22
|
+
const initScriptResponse = fetchSync(`https://${cdnDomain !== null && cdnDomain !== void 0 ? cdnDomain : kDefaultOkendoCdnDomain}/reviews-widget-plus/js/okendo-reviews.js`, {
|
|
23
|
+
cache: CacheMinutes(),
|
|
24
|
+
preload: true
|
|
25
|
+
});
|
|
26
|
+
if (!initScriptResponse.response.ok) {
|
|
27
|
+
console.error(okendoError('Failed to retrieve widget initialization script.'));
|
|
28
|
+
setInOkendoRequestContext(request, 'setupFailed', true);
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
const initScriptContents = initScriptResponse.text();
|
|
32
|
+
// Set up product URL formatter.
|
|
16
33
|
const productUrlFormatter = typeof productUrlFormatOverride === 'function'
|
|
17
34
|
? productUrlFormatOverride
|
|
18
35
|
: (product) => (product === null || product === void 0 ? void 0 : product.productHandle)
|
|
19
36
|
? `/products/${product.productHandle}/${product.variantId ? '?variantId=' + product.variantId : ''}`
|
|
20
37
|
: undefined;
|
|
38
|
+
// Get pre-rendered style settings.
|
|
21
39
|
const query = gql `
|
|
22
40
|
query metafields {
|
|
23
41
|
shop {
|
|
@@ -31,9 +49,10 @@ export const OkendoProvider = (props) => {
|
|
|
31
49
|
query: query,
|
|
32
50
|
preload: true
|
|
33
51
|
});
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
52
|
+
const preRenderStyleTags = (widgetPreRenderStyleTags === null || widgetPreRenderStyleTags === void 0 ? void 0 : widgetPreRenderStyleTags.value) ? parse(widgetPreRenderStyleTags.value) : '';
|
|
53
|
+
if (!preRenderStyleTags) {
|
|
54
|
+
console.warn(okendoError('Failed to retrieve pre-rendered widget style settings.'));
|
|
55
|
+
}
|
|
37
56
|
return (React.createElement(React.Fragment, null,
|
|
38
57
|
React.createElement(Head, null,
|
|
39
58
|
React.createElement("script", { id: "oke-reviews-settings", type: "application/json" }, JSON.stringify(reviewsHeaderConfig)),
|
|
@@ -42,8 +61,7 @@ export const OkendoProvider = (props) => {
|
|
|
42
61
|
React.createElement("meta", { name: "oke:subscriber_id", content: subscriberId }),
|
|
43
62
|
React.createElement("script", null, initScriptContents),
|
|
44
63
|
productUrlFormatter && React.createElement("script", { type: "text/javascript" }, `window.okeProductUrlFormatter = ${productUrlFormatter}`)),
|
|
45
|
-
|
|
46
|
-
parse(starSymbols)
|
|
47
|
-
children));
|
|
64
|
+
preRenderStyleTags,
|
|
65
|
+
parse(starSymbols)));
|
|
48
66
|
};
|
|
49
67
|
//# sourceMappingURL=OkendoProvider.server.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OkendoProvider.server.js","sourceRoot":"","sources":["../../../src/components/OkendoProvider.server.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,MAAM,mBAAmB,CAAC;AACtC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"OkendoProvider.server.js","sourceRoot":"","sources":["../../../src/components/OkendoProvider.server.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,MAAM,mBAAmB,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAKhD,OAAO,EAAE,WAAW,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAEnE,MAAM,uBAAuB,GAAG,kBAAkB,CAAC;AACnD,MAAM,uBAAuB,GAAG,+BAA+B,CAAC;AAEhE,MAAM,CAAC,MAAM,cAAc,GAAiD,CAAC,KAAK,EAAsB,EAAE;IACtG,MAAM,EAAE,S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AAS;YACxD,mBAAmB,IAAI,+BAAO,EAAE,EAAC,wBAAwB,IAAE,mBAAmB,CAAS;YACxF,8BAAM,IAAI,EAAC,mBAAmB,EAAC,OAAO,EAAE,YAAY,GAAI;YACxD,oCAAS,kBAAkB,CAAU;YACpC,mBAAmB,IAAI,gCAAQ,IAAI,EAAC,iBAAiB,IAAE,mCAAmC,mBAAmB,EAAE,CAAU,CACvH;QACN,kBAAkB;QAClB,KAAK,CAAC,WAAW,CAAC,CACpB,CACN,CAAC;AACN,CAAC,CAAA","sourcesContent":["import React from 'react';\nimport parse from 'html-react-parser';\nimport { fetchSync, useShopQuery, gql, CacheMinutes } from '@shopify/hydrogen';\nimport { Head } from '@shopify/hydrogen/client';\nimport { ServerComponentRequest } from '@shopify/hydrogen/dist/esnext/framework/Hydration/ServerComponentRequest.server';\nimport type { Metafield } from '@shopify/hydrogen/dist/esnext/storefront-api-types';\nimport type { ReviewsAPIPublic, ReviewWithProductPublic } from '@okendo/reviews-common';\n\nimport { okendoError, setInOkendoRequestContext } from '../shared';\n\nconst kDefaultOkendoApiDomain = 'api.okendo.io/v1';\nconst kDefaultOkendoCdnDomain = 'd3hw6dc1ow8pp2.cloudfront.net';\n\nexport const OkendoProvider: React.FunctionComponent<OkendoProviderProps> = (props): JSX.Element | null => {\n const { apiDomain, cdnDomain, productUrlFormatOverride, request, subscriberId } = props;\n\n // Download subscriber widget plus settings.\n const url = `https://${apiDomain ?? kDefaultOkendoApiDomain}/stores/${subscriberId}/widget_plus_settings`;\n const settingsResponse = fetchSync(url, { preload: true });\n\n if (!settingsResponse.response.ok) {\n console.error(okendoError('Failed to retrieve subscriber settings. Please check your environment variables.'));\n setInOkendoRequestContext(request, 'setupFailed', true);\n return null;\n }\n\n const { cssVariables, customCss, reviewsHeaderConfig, starSymbols } = settingsResponse.json() as ReviewsAPIPublic.Reviews.WidgetPlusSettings.Get.Response;\n const cssVariablesNormalized = cssVariables.replace('<style id=\"oke-css-vars\">', '').replace('</style>', '');\n const customCssNormalized = customCss ? customCss.replace('<style id=\"oke-reviews-custom-css\">', '').replace('</style>', '') : '';\n\n // Download contents of widget initialisation script.\n const initScriptResponse = fetchSync(`https://${cdnDomain ?? kDefaultOkendoCdnDomain}/reviews-widget-plus/js/okendo-reviews.js`, {\n cache: CacheMinutes(),\n preload: true\n });\n\n if (!initScriptResponse.response.ok) {\n console.error(okendoError('Failed to retrieve widget initialization script.'));\n setInOkendoRequestContext(request, 'setupFailed', true);\n return null;\n }\n\n const initScriptContents = initScriptResponse.text();\n\n // Set up product URL formatter.\n const productUrlFormatter = typeof productUrlFormatOverride === 'function'\n ? productUrlFormatOverride\n : (product: Pick<ReviewWithProductPublic, 'productHandle' | 'productId' | 'variantId'>) =>\n product?.productHandle\n ? `/products/${product.productHandle}/${product.variantId ? '?variantId=' + product.variantId : ''}`\n : undefined;\n\n // Get pre-rendered style settings.\n const query = gql`\n query metafields {\n shop {\n widgetPreRenderStyleTags: metafield(namespace: \"okendo\", key: \"WidgetPreRenderStyleTags\") {\n value\n }\n }\n }\n `;\n\n const {\n data: { shop: { widgetPreRenderStyleTags } }\n } = useShopQuery<OkendoProviderMetafields>({\n query: query,\n preload: true\n });\n\n const preRenderStyleTags = widgetPreRenderStyleTags?.value ? parse(widgetPreRenderStyleTags.value) : '';\n\n if (!preRenderStyleTags) {\n console.warn(okendoError('Failed to retrieve pre-rendered widget style settings.'));\n }\n\n return (\n <>\n <Head>\n <script id=\"oke-reviews-settings\" type=\"application/json\">{JSON.stringify(reviewsHeaderConfig)}</script>\n <style id=\"oke-css-vars\">{cssVariablesNormalized}</style>\n {customCssNormalized && <style id=\"oke-reviews-custom-css\">{customCssNormalized}</style>}\n <meta name=\"oke:subscriber_id\" content={subscriberId} />\n <script>{initScriptContents}</script>\n {productUrlFormatter && <script type=\"text/javascript\">{`window.okeProductUrlFormatter = ${productUrlFormatter}`}</script>}\n </Head>\n {preRenderStyleTags}\n {parse(starSymbols)}\n </>\n );\n}\n\ninterface OkendoProviderProps {\n apiDomain?: string;\n cdnDomain?: string;\n productUrlFormatOverride?: (product: Pick<ReviewWithProductPublic, 'productHandle' | 'productId' | 'variantId'>) => string;\n request: ServerComponentRequest;\n subscriberId: string;\n}\n\ninterface OkendoProviderMetafields {\n shop: {\n widgetPreRenderStyleTags?: Pick<Metafield, 'value'>\n };\n}\n"]}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import parse from 'html-react-parser';
|
|
3
|
+
import { useShopQuery, gql } from '@shopify/hydrogen';
|
|
3
4
|
import { OkendoWidgetClient } from './OkendoWidget.client';
|
|
4
|
-
import { getOkendoProductId } from '../shared
|
|
5
|
-
import React from 'react';
|
|
5
|
+
import { getOkendoProductId, useOkendoRequestContext, widgetMetafieldError } from '../shared';
|
|
6
6
|
export const OkendoReviewsWidget = (props) => {
|
|
7
|
-
var _a, _b, _c, _d;
|
|
7
|
+
var _a, _b, _c, _d, _e, _f;
|
|
8
|
+
const { setupFailed } = useOkendoRequestContext();
|
|
9
|
+
if (setupFailed) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
8
12
|
const { productId } = props;
|
|
9
13
|
const productQuery = productId
|
|
10
14
|
? `
|
|
@@ -29,16 +33,14 @@ export const OkendoReviewsWidget = (props) => {
|
|
|
29
33
|
query: query,
|
|
30
34
|
preload: true,
|
|
31
35
|
variables: {
|
|
32
|
-
productId
|
|
36
|
+
productId
|
|
33
37
|
}
|
|
34
38
|
});
|
|
35
39
|
if (productId && !((_a = product === null || product === void 0 ? void 0 : product.reviewsWidgetSnippet) === null || _a === void 0 ? void 0 : _a.value)) {
|
|
36
|
-
console.
|
|
37
|
-
return null;
|
|
40
|
+
console.warn(widgetMetafieldError('OkendoReviewsWidget', 'ReviewsWidgetSnippet'));
|
|
38
41
|
}
|
|
39
42
|
if (!((_b = shop === null || shop === void 0 ? void 0 : shop.widgetPreRenderBodyStyleTags) === null || _b === void 0 ? void 0 : _b.value)) {
|
|
40
|
-
console.
|
|
41
|
-
return null;
|
|
43
|
+
console.warn(widgetMetafieldError('OkendoReviewsWidget', 'WidgetPreRenderBodyStyleTags'));
|
|
42
44
|
}
|
|
43
45
|
const dataAttributes = {
|
|
44
46
|
'data-oke-widget': ''
|
|
@@ -50,8 +52,8 @@ export const OkendoReviewsWidget = (props) => {
|
|
|
50
52
|
}
|
|
51
53
|
}
|
|
52
54
|
return (React.createElement(React.Fragment, null,
|
|
53
|
-
parse(shop.widgetPreRenderBodyStyleTags.value),
|
|
54
|
-
React.createElement(OkendoWidgetClient, { dataAttributes: dataAttributes, metafieldContent: (
|
|
55
|
+
parse((_d = (_c = shop === null || shop === void 0 ? void 0 : shop.widgetPreRenderBodyStyleTags) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : ''),
|
|
56
|
+
React.createElement(OkendoWidgetClient, { dataAttributes: dataAttributes, metafieldContent: (_f = (_e = product === null || product === void 0 ? void 0 : product.reviewsWidgetSnippet) === null || _e === void 0 ? void 0 : _e.value) !== null && _f !== void 0 ? _f : '' })));
|
|
55
57
|
};
|
|
56
58
|
export default OkendoReviewsWidget;
|
|
57
59
|
//# sourceMappingURL=OkendoReviewsWidget.server.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OkendoReviewsWidget.server.js","sourceRoot":"","sources":["../../../src/components/OkendoReviewsWidget.server.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"OkendoReviewsWidget.server.js","sourceRoot":"","sources":["../../../src/components/OkendoReviewsWidget.server.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,MAAM,mBAAmB,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAItD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,uBAAuB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AAE;YACjB,cAAc,CAAC,6BAA6B,CAAC,GAAG,eAAe,CAAC;SACnE;KACJ;IAED,OAAO,CACH;QACK,KAAK,CAAC,MAAA,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,4BAA4B,0CAAE,KAAK,mCAAI,EAAE,CAAC;QACvD,oBAAC,kBAAkB,IAAC,cAAc,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAA,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,oBAAoB,0CAAE,KAAK,mCAAI,EAAE,GAAI,CACrH,CACN,CAAC;AACN,CAAC,CAAC;AAeF,eAAe,mBAAmB,CAAC","sourcesContent":["import React from 'react';\nimport parse from 'html-react-parser';\nimport { useShopQuery, gql } from '@shopify/hydrogen';\nimport type { Metafield } from '@shopify/hydrogen/dist/esnext/storefront-api-types';\nimport type { SKO } from '@okendo/reviews-common';\n\nimport { OkendoWidgetClient } from './OkendoWidget.client';\nimport { getOkendoProductId, useOkendoRequestContext, widgetMetafieldError } from '../shared';\n\nexport const OkendoReviewsWidget: React.FunctionComponent<OkendoReviewsWidgetProps> = (props): React.ReactElement | null => {\n const { setupFailed } = useOkendoRequestContext();\n if (setupFailed) {\n return null;\n }\n\n const { productId } = props;\n\n const productQuery = productId\n ? `\n product(id: $productId) {\n reviewsWidgetSnippet: metafield(namespace: \"okendo\", key: \"ReviewsWidgetSnippet\") {\n value\n }\n }\n `\n : '';\n\n const query = gql`\n query metafields${productId ? '($productId: ID!)' : ''} {\n ${productQuery}\n shop {\n widgetPreRenderBodyStyleTags: metafield(namespace: \"okendo\", key: \"WidgetPreRenderBodyStyleTags\") {\n value\n }\n }\n }\n `;\n\n const {\n data: { product, shop }\n } = useShopQuery<OkendoReviewsWidgetMetafields>({\n query: query,\n preload: true,\n variables: {\n productId\n }\n });\n\n if (productId && !product?.reviewsWidgetSnippet?.value) {\n console.warn(widgetMetafieldError('OkendoReviewsWidget', 'ReviewsWidgetSnippet'));\n }\n\n if (!shop?.widgetPreRenderBodyStyleTags?.value) {\n console.warn(widgetMetafieldError('OkendoReviewsWidget', 'WidgetPreRenderBodyStyleTags'));\n }\n\n const dataAttributes: SKO = {\n 'data-oke-widget': ''\n };\n\n if (productId) {\n const okendoProductId = getOkendoProductId(productId);\n if (okendoProductId) {\n dataAttributes['data-oke-reviews-product-id'] = okendoProductId;\n }\n }\n\n return (\n <>\n {parse(shop?.widgetPreRenderBodyStyleTags?.value ?? '')}\n <OkendoWidgetClient dataAttributes={dataAttributes} metafieldContent={product?.reviewsWidgetSnippet?.value ?? ''} />\n </>\n );\n};\n\ninterface OkendoReviewsWidgetProps {\n productId?: string;\n}\n\ninterface OkendoReviewsWidgetMetafields {\n product: {\n reviewsWidgetSnippet?: Pick<Metafield, 'value'>;\n };\n shop: {\n widgetPreRenderBodyStyleTags?: Pick<Metafield, 'value'>;\n };\n}\n\nexport default OkendoReviewsWidget;\n"]}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { useShopQuery, gql } from '@shopify/hydrogen';
|
|
2
3
|
import { OkendoWidgetClient } from './OkendoWidget.client';
|
|
3
|
-
import { getOkendoProductId } from '../shared
|
|
4
|
-
import React from 'react';
|
|
4
|
+
import { getOkendoProductId, useOkendoRequestContext, widgetConfigurationError, widgetMetafieldError } from '../shared';
|
|
5
5
|
export const OkendoStarRating = (props) => {
|
|
6
|
+
const { setupFailed } = useOkendoRequestContext();
|
|
7
|
+
if (setupFailed) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
6
10
|
const { productId } = props;
|
|
7
11
|
const okendoProductId = getOkendoProductId(productId);
|
|
8
12
|
if (!okendoProductId) {
|
|
9
|
-
console.
|
|
13
|
+
console.error(widgetConfigurationError('OkendoStarRating', 'productId was not provided'));
|
|
10
14
|
return null;
|
|
11
15
|
}
|
|
12
16
|
const query = gql `
|
|
@@ -22,19 +26,18 @@ export const OkendoStarRating = (props) => {
|
|
|
22
26
|
query: query,
|
|
23
27
|
preload: true,
|
|
24
28
|
variables: {
|
|
25
|
-
productId
|
|
29
|
+
productId
|
|
26
30
|
}
|
|
27
31
|
});
|
|
28
32
|
if (!(starRatingSnippet === null || starRatingSnippet === void 0 ? void 0 : starRatingSnippet.value)) {
|
|
29
|
-
console.
|
|
30
|
-
return null;
|
|
33
|
+
console.warn(widgetMetafieldError('OkendoStarRating', 'StarRatingSnippet'));
|
|
31
34
|
}
|
|
32
35
|
const dataAttributes = {
|
|
33
36
|
'data-oke-star-rating': '',
|
|
34
37
|
'data-oke-reviews-product-id': okendoProductId,
|
|
35
38
|
'data-oke-scroll-disabled': 'true'
|
|
36
39
|
};
|
|
37
|
-
return (React.createElement(OkendoWidgetClient, { dataAttributes: dataAttributes, metafieldContent: starRatingSnippet.value }));
|
|
40
|
+
return (React.createElement(OkendoWidgetClient, { dataAttributes: dataAttributes, metafieldContent: starRatingSnippet === null || starRatingSnippet === void 0 ? void 0 : starRatingSnippet.value }));
|
|
38
41
|
};
|
|
39
42
|
export default OkendoStarRating;
|
|
40
43
|
//# sourceMappingURL=OkendoStarRating.server.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OkendoStarRating.server.js","sourceRoot":"","sources":["../../../src/components/OkendoStarRating.server.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAGtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,
|
|
1
|
+
{"version":3,"file":"OkendoStarRating.server.js","sourceRoot":"","sources":["../../../src/components/OkendoStarRating.server.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAGtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,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AC","sourcesContent":["import React from 'react';\nimport { useShopQuery, gql } from '@shopify/hydrogen';\nimport type { Metafield } from '@shopify/hydrogen/dist/esnext/storefront-api-types';\n\nimport { OkendoWidgetClient } from './OkendoWidget.client';\nimport { getOkendoProductId, useOkendoRequestContext, widgetConfigurationError, widgetMetafieldError } from '../shared';\n\nexport const OkendoStarRating: React.FunctionComponent<OkendoStarRatingProps> = (props): React.ReactElement | null => {\n const { setupFailed } = useOkendoRequestContext();\n if (setupFailed) {\n return null;\n }\n\n const { productId } = props;\n\n const okendoProductId = getOkendoProductId(productId);\n if (!okendoProductId) {\n console.error(widgetConfigurationError('OkendoStarRating', 'productId was not provided'));\n return null;\n }\n\n const query = gql`\n query metafields($productId: ID!) {\n product(id: $productId) {\n starRatingSnippet: metafield(namespace: \"okendo\", key: \"StarRatingSnippet\") {\n value\n }\n }\n }\n `;\n\n const {\n data: {\n product: { starRatingSnippet }\n }\n } = useShopQuery<OkendoStarRatingMetafields>({\n query: query,\n preload: true,\n variables: {\n productId\n }\n });\n\n if (!starRatingSnippet?.value) {\n console.warn(widgetMetafieldError('OkendoStarRating', 'StarRatingSnippet'));\n }\n\n const dataAttributes = {\n 'data-oke-star-rating': '',\n 'data-oke-reviews-product-id': okendoProductId,\n 'data-oke-scroll-disabled': 'true'\n };\n\n return (\n <OkendoWidgetClient dataAttributes={dataAttributes} metafieldContent={starRatingSnippet?.value} />\n );\n};\n\ninterface OkendoStarRatingProps {\n productId: string;\n}\n\ninterface OkendoStarRatingMetafields {\n product: {\n starRatingSnippet?: Pick<Metafield, 'value'>;\n };\n}\n\nexport default OkendoStarRating;\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { SKO } from '@okendo/reviews-common';
|
|
2
3
|
import type { ReviewsWidgetPlus } from '@okendo/reviews-widget-plus/dist-utils/ReviewsWidgetPlus';
|
|
3
|
-
import React from "react";
|
|
4
4
|
export declare const OkendoWidgetClient: React.FunctionComponent<OkendoWidgetClientProps>;
|
|
5
5
|
export interface OkendoWidgetClientProps {
|
|
6
6
|
dataAttributes: SKO;
|
|
7
|
-
metafieldContent
|
|
7
|
+
metafieldContent?: string;
|
|
8
8
|
}
|
|
9
9
|
declare global {
|
|
10
10
|
interface Window {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { useEffect, useRef } from "react";
|
|
1
|
+
import React, { useEffect, useRef } from 'react';
|
|
3
2
|
export const OkendoWidgetClient = (props) => {
|
|
4
|
-
const { dataAttributes, metafieldContent } = props;
|
|
3
|
+
const { dataAttributes, metafieldContent = '' } = props;
|
|
5
4
|
const widgetContainer = useRef(null);
|
|
6
5
|
const initialiseReviewsWidget = () => {
|
|
7
6
|
if (widgetContainer.current) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OkendoWidget.client.js","sourceRoot":"","sources":["../../../src/components/OkendoWidget.client.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"OkendoWidget.client.js","sourceRoot":"","sources":["../../../src/components/OkendoWidget.client.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAIjD,MAAM,CAAC,MAAM,kBAAkB,GAAqD,CAAC,KAAK,EAAE,EAAE;IAC1F,MAAM,EAAE,cAAc,EAAE,gBAAgB,GAAG,EAAE,EAAE,GAAG,KAAK,CAAC;IACxD,MAAM,eAAe,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAErD,MAAM,uBAAuB,GAAG,GAAG,EAAE;QACjC,IAAI,eAAe,CAAC,OAAO,EAAE;YACzB,MAAM,CAAC,YAAY,CAAC,UAAU,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;SAC3D;IACL,CAAC,CAAC;IAEF,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,MAAM,CAAC,YAAY,EAAE;YACrB,uBAAuB,EAAE,CAAC;SAC7B;aACI;YACD,MAAM,CAAC,gBAAgB,CAAC,mBAAmB,EAAE,uBAAuB,CAAC,CAAC;SACzE;IACL,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CACH,6BAAK,GAAG,EAAE,eAAe,KAAM,cAAc,EAAE,uBAAuB,EAAE,EAAE,MAAM,EAAE,gBAAgB,EAAE,GAAQ,CAC/G,CAAC;AACN,CAAC,CAAA","sourcesContent":["import React, { useEffect, useRef } from 'react';\nimport type { SKO } from '@okendo/reviews-common';\nimport type { ReviewsWidgetPlus } from '@okendo/reviews-widget-plus/dist-utils/ReviewsWidgetPlus';\n\nexport const OkendoWidgetClient: React.FunctionComponent<OkendoWidgetClientProps> = (props) => {\n const { dataAttributes, metafieldContent = '' } = props;\n const widgetContainer = useRef<HTMLDivElement>(null);\n\n const initialiseReviewsWidget = () => {\n if (widgetContainer.current) {\n window.okeWidgetApi.initWidget(widgetContainer.current);\n }\n };\n\n useEffect(() => {\n if (window.okeWidgetApi) {\n initialiseReviewsWidget();\n }\n else {\n window.addEventListener('oke-script-loaded', initialiseReviewsWidget);\n }\n }, []);\n\n return (\n <div ref={widgetContainer} {...dataAttributes} dangerouslySetInnerHTML={{ __html: metafieldContent }}></div>\n );\n}\n\nexport interface OkendoWidgetClientProps {\n dataAttributes: SKO;\n metafieldContent?: string;\n}\n\ndeclare global {\n interface Window {\n okeWidgetApi: ReviewsWidgetPlus.WidgetWindowApi;\n }\n}\n"]}
|
package/dist/esnext/index.d.ts
CHANGED
package/dist/esnext/index.js
CHANGED
package/dist/esnext/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC","sourcesContent":["export * from './components';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC","sourcesContent":["export * from './components';\nexport * from './shared';\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function okendoError(message) {
|
|
2
|
+
return `Okendo: ${message}`;
|
|
3
|
+
}
|
|
4
|
+
export function widgetConfigurationError(widgetName, message) {
|
|
5
|
+
return okendoError(`${widgetName} error: ${message}`);
|
|
6
|
+
}
|
|
7
|
+
export function widgetMetafieldError(widgetName, metafieldName) {
|
|
8
|
+
return okendoError(`${widgetName} error: Failed to retrieve metafield '${metafieldName}'.`);
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=errorUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorUtils.js","sourceRoot":"","sources":["../../../src/shared/errorUtils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,WAAW,CAAC,OAAe;IACvC,OAAO,WAAW,OAAO,EAAE,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,UAAkB,EAAE,OAAe;IACxE,OAAO,WAAW,CAAC,GAAG,UAAU,WAAW,OAAO,EAAE,CAAC,CAAC;AAC1D,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,UAAkB,EAAE,aAAqB;IAC1E,OAAO,WAAW,CAAC,GAAG,UAAU,yCAAyC,aAAa,IAAI,CAAC,CAAC;AAChG,CAAC","sourcesContent":["export function okendoError(message: string): string {\n return `Okendo: ${message}`;\n}\n\nexport function widgetConfigurationError(widgetName: string, message: string): string {\n return okendoError(`${widgetName} error: ${message}`);\n}\n\nexport function widgetMetafieldError(widgetName: string, metafieldName: string): string {\n return okendoError(`${widgetName} error: Failed to retrieve metafield '${metafieldName}'.`);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/shared/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC","sourcesContent":["export * from './errorUtils';\nexport * from './productUtils';\nexport * from './requestUtils';\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SKO } from '@okendo/reviews-common';
|
|
2
|
+
import { ServerComponentRequest } from '@shopify/hydrogen/dist/esnext/framework/Hydration/ServerComponentRequest.server';
|
|
3
|
+
export declare function setInOkendoRequestContext(request: ServerComponentRequest, key: keyof OkendoRequestContextKeys, value: RequestContextSafeType | RequestContextSafeType[]): void;
|
|
4
|
+
export declare function useOkendoRequestContext(): OkendoRequestContext;
|
|
5
|
+
interface OkendoRequestContextKeys {
|
|
6
|
+
setupFailed: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface OkendoRequestContext extends OkendoRequestContextKeysWithSKO {
|
|
9
|
+
}
|
|
10
|
+
declare type OkendoRequestContextKeysWithSKO = OkendoRequestContextKeys & SKO;
|
|
11
|
+
declare type RequestContextSafeType = string | number | boolean;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useServerRequest } from '@shopify/hydrogen/dist/esnext/foundation/ServerRequestProvider';
|
|
2
|
+
export function setInOkendoRequestContext(request, key, value) {
|
|
3
|
+
const okendoRequestContext = request.ctx.okendoRequestContext || {};
|
|
4
|
+
okendoRequestContext[key] = value;
|
|
5
|
+
request.ctx.okendoRequestContext = okendoRequestContext;
|
|
6
|
+
}
|
|
7
|
+
export function useOkendoRequestContext() {
|
|
8
|
+
const { ctx: { okendoRequestContext } } = useServerRequest();
|
|
9
|
+
return okendoRequestContext || {};
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=requestUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requestUtils.js","sourceRoot":"","sources":["../../../src/shared/requestUtils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gEAAgE,CAAC;AAGlG,MAAM,UAAU,yBAAyB,CAAC,OAA+B,EAAE,GAAmC,EAAE,KAAwD;IACpK,MAAM,oBAAoB,GAAyB,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,EAAE,CAAC;IAC1F,oBAAoB,CAAC,GAAG,CAAC,GAAG,KAAY,CAAC;IACzC,OAAO,CAAC,GAAG,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;AAC5D,CAAC;AAED,MAAM,UAAU,uBAAuB;IACnC,MAAM,EAAE,GAAG,EAAE,EAAE,oBAAoB,EAAE,EAAE,GAAG,gBAAgB,EAAE,CAAC;IAC7D,OAAO,oBAAoB,IAAI,EAAE,CAAC;AACtC,CAAC","sourcesContent":["import { SKO } from '@okendo/reviews-common';\nimport { useServerRequest } from '@shopify/hydrogen/dist/esnext/foundation/ServerRequestProvider';\nimport { ServerComponentRequest } from '@shopify/hydrogen/dist/esnext/framework/Hydration/ServerComponentRequest.server';\n\nexport function setInOkendoRequestContext(request: ServerComponentRequest, key: keyof OkendoRequestContextKeys, value: RequestContextSafeType | RequestContextSafeType[]): void {\n const okendoRequestContext: OkendoRequestContext = request.ctx.okendoRequestContext || {};\n okendoRequestContext[key] = value as any;\n request.ctx.okendoRequestContext = okendoRequestContext;\n}\n\nexport function useOkendoRequestContext(): OkendoRequestContext {\n const { ctx: { okendoRequestContext } } = useServerRequest();\n return okendoRequestContext || {};\n}\n\ninterface OkendoRequestContextKeys {\n setupFailed: boolean;\n}\n\nexport interface OkendoRequestContext extends OkendoRequestContextKeysWithSKO { }\n\ntype OkendoRequestContextKeysWithSKO = OkendoRequestContextKeys & SKO;\n\ntype RequestContextSafeType = string | number | boolean;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/index.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/index.ts"],"names":[],"mappings":";;AAEA,qEAAkE;AAElE,kBAAe,GAAG,EAAE;IAChB,OAAO;QACH,IAAA,+CAAsB,GAAE;KACf,CAAC;AAClB,CAAC,CAAC","sourcesContent":["import type { Plugin } from 'vite';\n\nimport { extendViteOptimizeDeps } from './extendViteOptimizeDeps';\n\nexport default () => {\n return [\n extendViteOptimizeDeps()\n ] as Plugin[];\n};\n"]}
|