@okendo/shopify-hydrogen 0.0.1 → 0.0.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.
Files changed (38) hide show
  1. package/README.md +420 -21
  2. package/dist/esnext/components/OkendoProvider.server.d.ts +12 -0
  3. package/dist/esnext/components/OkendoProvider.server.js +67 -0
  4. package/dist/esnext/components/OkendoProvider.server.js.map +1 -0
  5. package/dist/esnext/components/OkendoReviewsWidget.server.d.ts +6 -0
  6. package/dist/esnext/components/OkendoReviewsWidget.server.js +59 -0
  7. package/dist/esnext/components/OkendoReviewsWidget.server.js.map +1 -0
  8. package/dist/esnext/components/OkendoStarRating.server.d.ts +6 -0
  9. package/dist/esnext/components/OkendoStarRating.server.js +43 -0
  10. package/dist/esnext/components/OkendoStarRating.server.js.map +1 -0
  11. package/dist/esnext/components/OkendoWidget.client.d.ts +13 -0
  12. package/dist/esnext/components/OkendoWidget.client.js +20 -0
  13. package/dist/esnext/components/OkendoWidget.client.js.map +1 -0
  14. package/dist/esnext/components/index.d.ts +3 -0
  15. package/dist/esnext/components/index.js +4 -0
  16. package/dist/esnext/components/index.js.map +1 -0
  17. package/dist/esnext/index.d.ts +2 -0
  18. package/dist/esnext/index.js +3 -0
  19. package/dist/esnext/index.js.map +1 -0
  20. package/dist/esnext/shared/errorUtils.d.ts +3 -0
  21. package/dist/esnext/shared/errorUtils.js +10 -0
  22. package/dist/esnext/shared/errorUtils.js.map +1 -0
  23. package/dist/esnext/shared/index.d.ts +3 -0
  24. package/dist/esnext/shared/index.js +4 -0
  25. package/dist/esnext/shared/index.js.map +1 -0
  26. package/dist/esnext/shared/productUtils.d.ts +6 -0
  27. package/dist/esnext/shared/productUtils.js +16 -0
  28. package/dist/esnext/shared/productUtils.js.map +1 -0
  29. package/dist/esnext/shared/requestUtils.d.ts +12 -0
  30. package/dist/esnext/shared/requestUtils.js +11 -0
  31. package/dist/esnext/shared/requestUtils.js.map +1 -0
  32. package/dist/node/plugin/extendViteOptimizeDeps.d.ts +2 -0
  33. package/dist/node/plugin/extendViteOptimizeDeps.js +15 -0
  34. package/dist/node/plugin/extendViteOptimizeDeps.js.map +1 -0
  35. package/dist/node/plugin/index.d.ts +3 -0
  36. package/dist/node/plugin/index.js +9 -0
  37. package/dist/node/plugin/index.js.map +1 -0
  38. package/package.json +4 -3
package/README.md CHANGED
@@ -1,13 +1,411 @@
1
- # Okendo Hydrogen React Components #
1
+ # Okendo Hydrogen React Components
2
2
 
3
3
  This is the React component library to support Okendo Widget Plus Widgets in Shopify Hydrogen Projects.
4
4
 
5
5
  Currently we support server side components for 2 widgets:
6
+
6
7
  1. Reviews List
7
8
  2. Star Ratings
8
9
 
9
- This includes:
10
- ## OkendoProvider.server ##
10
+ <br/>
11
+
12
+ # Table of contents
13
+
14
+ 1. [What is Okendo Shopify Hydrogen](#introduction)
15
+ 2. [Guided Installation](#installation)
16
+ 1. [Configure Hydrogen App](#configurehydrogenapp)
17
+ 2. [Expose Shopify Metafields](#exposemetafields)
18
+ 3. [How to Use Okendo Hydrogen Components In Your Hydrogen Apps](#okendohydrogencomponentsusage)
19
+ 4. [Component Props](#componentprops)
20
+ 5. [NPM Component Terminology/Defintions](#npmdefinitions)
21
+ 6. [View Our Okendo Sample Hydrogen App](#learnmore)
22
+
23
+ <br/><br/>
24
+
25
+ # What is Okendo Shopify Hydrogen?<a name="introduction"></a>
26
+
27
+ Okendo Shopify Hydrogen is a React component library to be used in Shopify Hydrogen apps. This utilises [Shopify’s Hydrogen framework](https://shopify.dev/custom-storefronts/hydrogen/framework) which is used to create custom storefronts using both server-side rendered and client-side rendered React components.
28
+
29
+ The purpose of this library is for a Hydrogen-based React Shopify storefront to import this library so that the Okendo Reviews List and Okendo Star Ratings components can be rendered within their React application, providing [Okendo’s reviews display functionality](https://www.okendo.io/blog/widget-plus/).
30
+
31
+ <br/>
32
+
33
+ # Guided Installation <a name="installation"></a>
34
+
35
+ The purpose of this documentation is to guide you on the following:
36
+
37
+ - How to configure your Shopify store ready for Okendo Shopify Hydrogen.
38
+ - How to install and configure Okendo Shopify Hydrogen components in your Shopify Hydrogen app.
39
+
40
+ <br/>
41
+
42
+ ## Requirements
43
+
44
+ - You have an existing Shopify store.
45
+ - You have an existing Hydrogen app. ([Learn how to create a Hydrogen app](https://shopify.dev/custom-storefronts/hydrogen/getting-started/create))
46
+ - You have a current Okendo Reviews subscription and have the **Okendo: Product Reviews & UCG** app installed and configured.
47
+ - You have an existing Shopify custom app with Storefront access token. ([Learn how to configure Shopify Storefront](https://www.notion.so/Configure-Shopify-Storefront-9e78e31bb4d94546aa1d037367c6a0b8))
48
+
49
+ <br/>
50
+
51
+ ## 1. Configure Hydrogen app config <a name="configurehydrogenapp"></a>
52
+
53
+ 1. Open **hydrogen.config.js** in your project.
54
+ 2. Make the following changes and save the file:
55
+ - Update `storeDomain` to specify your store's domain name.
56
+ - Update `storefrontToken` to specify your Storefront API access token.
57
+
58
+ <br/>
59
+
60
+ ## 2. Expose Shopify Metafields <a name="exposemetafields"></a>
61
+
62
+ Okendo Reviews utilise Product and Shop specific [metafields](https://shopify.dev/api/examples/metafields) in order to function and provide a seamless user experience. You will need to expose these metafields so that they can be retrieved by your Hydrogen app.
63
+
64
+ At this point in time, unfortunately Shopify does not have a way of exposing Shop Metafields through their admin UI.
65
+
66
+ The preferred method to expose Metafields is to [contact Okendo Support](mailto:support@okendo.io).
67
+
68
+ <br/>
69
+
70
+ ### For Technical/Advanced Users
71
+
72
+ <details>
73
+ <summary>Learn How to Expose Metafields Via The Storefront API</summary>
74
+
75
+ # Exposing Metafields via GraphQL
76
+
77
+ ## Using Curl
78
+
79
+ You can also expose the required Okendo Shopify Metafields by using GraphQL with curl.
80
+
81
+ 1. Open a new terminal or PowerShell window.
82
+ 2. Run the following command to expose the `WidgetPreRenderStyleTag` Shop Metafield.
83
+
84
+ ```bash
85
+ curl -X POST \
86
+ https://{shop}.myshopify.com/admin/api/2022-04/graphql.json \
87
+ -H 'Content-Type: application/graphql' \
88
+ -H 'X-Shopify-Access-Token: {access_token}' \
89
+ -d '
90
+ mutation {
91
+ metafieldStorefrontVisibilityCreate(
92
+ input: {
93
+ namespace: "okendo"
94
+ key: "WidgetPreRenderStyleTags"
95
+ ownerType: SHOP
96
+ }
97
+ ) {
98
+ metafieldStorefrontVisibility {
99
+ id
100
+ }
101
+ userErrors {
102
+ field
103
+ message
104
+ }
105
+ }
106
+ }
107
+ '
108
+ ```
109
+
110
+ 3. Run the following command to expose the `WidgetPreRenderBodyStyleTags` Shop Metafield.
111
+
112
+ ```bash
113
+ curl -X POST \
114
+ https://{shop}.myshopify.com/admin/api/2022-04/graphql.json \
115
+ -H 'Content-Type: application/graphql' \
116
+ -H 'X-Shopify-Access-Token: {access_token}' \
117
+ -d '
118
+ mutation {
119
+ metafieldStorefrontVisibilityCreate(
120
+ input: {
121
+ namespace: "okendo"
122
+ key: "WidgetPreRenderBodyStyleTags"
123
+ ownerType: SHOP
124
+ }
125
+ ) {
126
+ metafieldStorefrontVisibility {
127
+ id
128
+ }
129
+ userErrors {
130
+ field
131
+ message
132
+ }
133
+ }
134
+ }
135
+ '
136
+ ```
137
+
138
+ 4. Run the following command to expose the `ReviewsWidgetSnippet` Product Metafield.
139
+
140
+ ```bash
141
+ curl -X POST \
142
+ https://{shop}.myshopify.com/admin/api/2022-04/graphql.json \
143
+ -H 'Content-Type: application/graphql' \
144
+ -H 'X-Shopify-Access-Token: {access_token}' \
145
+ -d '
146
+ mutation {
147
+ metafieldStorefrontVisibilityCreate(
148
+ input: {
149
+ namespace: "okendo"
150
+ key: "ReviewsWidgetSnippet"
151
+ ownerType: PRODUCT
152
+ }
153
+ ) {
154
+ metafieldStorefrontVisibility {
155
+ id
156
+ }
157
+ userErrors {
158
+ field
159
+ message
160
+ }
161
+ }
162
+ }
163
+ '
164
+ ```
165
+
166
+ 5. Run the following command to expose the `StarRatingSnippet` the Product Metafield.
167
+
168
+ ```bash
169
+ curl -X POST \
170
+ https://{shop}.myshopify.com/admin/api/2022-04/graphql.json \
171
+ -H 'Content-Type: application/graphql' \
172
+ -H 'X-Shopify-Access-Token: {access_token}' \
173
+ -d '
174
+ mutation {
175
+ metafieldStorefrontVisibilityCreate(
176
+ input: {
177
+ namespace: "okendo"
178
+ key: "StarRatingSnippet"
179
+ ownerType: PRODUCT
180
+ }
181
+ ) {
182
+ metafieldStorefrontVisibility {
183
+ id
184
+ }
185
+ userErrors {
186
+ field
187
+ message
188
+ }
189
+ }
190
+ }
191
+ '
192
+ ```
193
+
194
+ ## Using GraphQL IDE
195
+
196
+ 1. Open your GraphQL IDE (such as Postman) and make a `POST` request with the following details:
197
+
198
+ - **URL:** https://{shop}.myshopify.com/admin/api/2022-04/graphql.json
199
+ - **Headers:** - X-Shopify-Access-Token: {access_token} - Content-Type: application/json 2. Execute the following request to expose the `WidgetPreRenderStyleTag` Shop Metafield.
200
+
201
+ ```graphql
202
+ mutation {
203
+ metafieldStorefrontVisibilityCreate(
204
+ input: {
205
+ namespace: "okendo"
206
+ key: "WidgetPreRenderStyleTags"
207
+ ownerType: SHOP
208
+ }
209
+ ) {
210
+ metafieldStorefrontVisibility {
211
+ id
212
+ }
213
+ userErrors {
214
+ field
215
+ message
216
+ }
217
+ }
218
+ }
219
+ ```
220
+
221
+ 3. Execute the following request to expose the `WidgetPreRenderBodyStyleTags` Shop Metafield.
222
+
223
+ ```graphql
224
+ mutation {
225
+ metafieldStorefrontVisibilityCreate(
226
+ input: {
227
+ namespace: "okendo"
228
+ key: "WidgetPreRenderBodyStyleTags"
229
+ ownerType: SHOP
230
+ }
231
+ ) {
232
+ metafieldStorefrontVisibility {
233
+ id
234
+ }
235
+ userErrors {
236
+ field
237
+ message
238
+ }
239
+ }
240
+ }
241
+ ```
242
+
243
+ 4. Execute the following request to expose the `ReviewsWidgetSnippet` Product Metafield.
244
+
245
+ ```graphql
246
+ mutation {
247
+ metafieldStorefrontVisibilityCreate(
248
+ input: {
249
+ namespace: "okendo"
250
+ key: "ReviewsWidgetSnippet"
251
+ ownerType: PRODUCT
252
+ }
253
+ ) {
254
+ metafieldStorefrontVisibility {
255
+ id
256
+ }
257
+ userErrors {
258
+ field
259
+ message
260
+ }
261
+ }
262
+ }
263
+ ```
264
+
265
+ 5. Execute the following request to expose the `StarRatingSnippet` the Product Metafield.
266
+
267
+ ```graphql
268
+ mutation {
269
+ metafieldStorefrontVisibilityCreate(
270
+ input: {
271
+ namespace: "okendo"
272
+ key: "StarRatingSnippet"
273
+ ownerType: PRODUCT
274
+ }
275
+ ) {
276
+ metafieldStorefrontVisibility {
277
+ id
278
+ }
279
+ userErrors {
280
+ field
281
+ message
282
+ }
283
+ }
284
+ }
285
+ ```
286
+
287
+ **References**
288
+
289
+ [https://shopify.dev/api/examples/metafields#step-1-expose-metafields](https://shopify.dev/api/examples/metafields#step-1-expose-metafields)
290
+ [https://shopify.dev/api/admin-graphql/2022-04/mutations/metafieldstorefrontvisibilitycreate](https://shopify.dev/api/admin-graphql/2022-04/mutations/metafieldstorefrontvisibilitycreate)
291
+ </details>
292
+ <br/>
293
+ <br/>
294
+
295
+ ## 3. How to Use Okendo Hydrogen Components In Your Hydrogen App <a name="okendohydrogencomponentsusage"></a>
296
+
297
+ ### Installation
298
+
299
+ 1. In your Hydrogen app directory, run `npm install @okendo/shopify-hydrogen` inside a terminal or PowerShell window.
300
+ 2. Open **vite.config.js** and add `import okendo from '@okendo/shopify-hydrogen/plugin` to the list of imports.
301
+ 3. Add `okendo()` to the list of `plugins`.
302
+
303
+ ```tsx
304
+ /* **vite.config.js */**
305
+ import {defineConfig} from 'vite';
306
+ import hydrogen from '@shopify/hydrogen/plugin';
307
+ import okendo from '@okendo/shopify-hydrogen/plugin';
308
+
309
+ // https://vitejs.dev/config/
310
+ export default defineConfig({
311
+ plugins: [hydrogen(), okendo()],
312
+ optimizeDeps: {include: ['@headlessui/react']},
313
+ test: {
314
+ globals: true,
315
+ testTimeout: 10000,
316
+ hookTimeout: 10000,
317
+ },
318
+ });
319
+ ```
320
+
321
+ 4. Open **App.server.jsx** and import `OkendoProvider`.
322
+ 5. Include the `OkendoProvider` as shown below.
323
+
324
+ ```tsx
325
+ /* **App.server.jsx */**
326
+ import { OkendoProvider } from '@okendo/shopify-hydrogen';
327
+
328
+ function App() {
329
+ return (
330
+ <Suspense fallback={<LoadingFallback />}>
331
+ <ShopifyProvider>
332
+ <!-- *** Include OkendoProvider HERE *** -->
333
+ <OkendoProvider subscriberId={okendo_subscriber_id} />
334
+ <ServerCartProvider>
335
+ <DefaultSeo />
336
+ <Router>
337
+ <FileRoutes />
338
+ <Route path="*" page={<NotFound />} />
339
+ </Router>
340
+ </ServerCartProvider>
341
+ <PerformanceMetrics />
342
+ {import.meta.env.DEV && <PerformanceMetricsDebug />}
343
+ </ShopifyProvider>
344
+ </Suspense>
345
+ );
346
+
347
+ ```
348
+
349
+ ### **Widget Usage**
350
+
351
+ - Import `OkendoReviewsWidget` and `OkendoStarRating` and use as JSX components. Pass in the Shopify product ID as a prop.
352
+ - The `productId` prop is optional for the `OkendoReviewsWidget`. Not providing will mean that the widget will display reviews for all products, which is ideal for homepages or collection pages.
353
+
354
+ ```tsx
355
+ import {
356
+ OkendoReviewsWidget,
357
+ OkendoStarRating,
358
+ } from "@okendo/shopify-hydrogen";
359
+
360
+ const okendoReviewsWidget = <OkendoReviewsWidget productId={product.id} />;
361
+ const okendoStarRating = <OkendoStarRating productId={product.id} />;
362
+ ```
363
+
364
+ > ℹ️ If you are wanting to use Okendo server components within React client components, you must pass the component in as a prop to the client component passed down from another server component. Otherwise, you can use the component directly in a server component. [Learn more here](https://shopify.dev/api/hydrogen/components#customizing-hydrogen-components).
365
+
366
+ <br/>
367
+
368
+ ---
369
+
370
+ ## Component Props <a name="componentprops"></a>
371
+
372
+ <br/>
373
+
374
+ ### OkendoProviderProps
375
+
376
+ | Name | Type | Description | Optional |
377
+ | ------------------------ | -------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
378
+ | subscriberId | string | The Okendo subscriber ID. | no |
379
+ | apiDomain | string | To override the default Okendo API Domain. (Default: api.okendo.io/v1) | yes |
380
+ | cdnDomain | string | To override the default Okendo CDN domain. (Default: d3hw6dc1ow8pp2.cloudfront.net) | yes |
381
+ | productUrlFormatOverride | (product: Pick<ReviewWithProductPublic, 'productHandle' \| 'productId' \| 'variantId'>) => string; | By default, we use Hydrogen’s default product routing. **Advanced Usage Only:** Function hook which allows the custom configuration of the Shopify product URLs from the Okendo Reviews Widget. | yes |
382
+
383
+ <br/><br/>
384
+
385
+ ### OkendoReviewsWidgetProps
386
+
387
+ | Name | Type | Description | Optional |
388
+ | --------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
389
+ | productId | string | The Shopify Product ID. If provided, the Reviews Widget will be configured to display reviews specific to that product. Otherwise, the Reviews Widget will display reviews for all products. | yes |
390
+
391
+ <br/>
392
+
393
+ ### OkendoStarRatingProps
394
+
395
+ | Name | Type | Description | Optional |
396
+ | --------- | ------ | ----------------------- | -------- |
397
+ | productId | string | The Shopify Product ID. | no |
398
+
399
+ <br/>
400
+
401
+ ---
402
+
403
+ <br/>
404
+
405
+ ## NPM Component Definitions <a name="npmdefinitions"></a>
406
+
407
+ ### OkendoProvider.server
408
+
11
409
  This retrieves the Widget Plus configuration from our public API.
12
410
 
13
411
  This should wrap as high up in the React component tree as possible.
@@ -15,30 +413,31 @@ This should wrap as high up in the React component tree as possible.
15
413
  In the sample Shopify Hydrogen project in `App.server.jsx` we include it as the first child of `<ShopifyProvider>`.
16
414
 
17
415
  The final server side render/output includes:
18
- * Okendo Subscriber Settings JSON
19
- * Widget Pre-Render Style Tags Metafield - This is the "Above the fold" CSS essential for rendering SSR'd Okendo Reviews Widget (first page) and Star Ratings - This ensures styled widgets before client-side hydration occurs.
20
- * Base CSS Vars
21
- * Any custom CSS specified in the Okendo Admin.
22
416
 
23
- ## OkendoStarRating.server ##
417
+ - Okendo Subscriber Settings JSON
418
+ - Widget Pre-Render Style Tags Metafield: This is the "Above the fold" CSS essential for rendering server-side rendered (SSR) Okendo Reviews Widget (first page) and Star Ratings. This ensures styled widgets before client-side hydration occurs.
419
+ - Base CSS Vars
420
+ - Okendo Initialisation Script: This is used to render the widgets on the page.
421
+ - Any custom CSS specified in the Okendo Admin.
422
+
423
+ <br/>
424
+
425
+ ### OkendoStarRating.server
426
+
24
427
  This is the server-side rendered Star Rating widget - It then invokes the client side `OkendoWidget.client.tsx` component to perform client side hydration.
25
428
 
26
- ## OkendoReviewsWidget.server ##
27
- This is the server-side rendered Reviews List widget - It then invokes the client side `OkendoWidget.client.tsx` component to perform client side hydration.
429
+ <br/>
28
430
 
431
+ ### OkendoReviewsWidget.server
432
+
433
+ This is the server-side rendered Reviews List widget - It then invokes the client side `OkendoWidget.client.tsx` component to perform client side hydration.
29
434
 
30
- ### How do I use this in my Shopify Hydrogen project? ###
31
- * Your Shopify Hydrogen app will require the following variables added to your `.env` file:
32
- ** `VITE_STORE_DOMAIN`: Your myshopify.com URL
33
- ** `VITE_SHOPIFY_STOREFRONT_TOKEN`: Your Shopify App Storefront Token - See: https://shopify.dev/api/examples/storefront-api
34
- ** `VITE_OKENDO_SUBSCRIBER_ID`: Your Okendo Subscriber ID - Issued by Okendo
35
- ** `VITE_OKENDO_API_DOMAIN`: The Okendo api domain this will override the default production domain if supplied: api.okendo.io
36
- ** `VITE_OKENDO_CDN`: The Okendo CDN domain - This will override the default production domain if supplied: cdn.okendo.io
435
+ ---
37
436
 
38
- * TODO - Ideally we point to a sample hydrogen project using our widgets.
437
+ <br/>
39
438
 
439
+ ## View Our Okendo Sample Hydrogen App <a name="learnmore"></a>
40
440
 
41
- ### Who do I talk to? ###
441
+ We have created a Shopify Hydrogen sample application with our widgets pre-installed.
42
442
 
43
- * Tom Fulcher - tom.fulcher@okendo.io, Susanne Peng - susanne.peng@okendo.io, Rowan Puckeridge - rowan.puckeridge@okendo.io
44
- * Okendo Widget Pod
443
+ - [View our Sample Okendo Shopify Hydrogen Demo Repository](https://github.com/okendo/okendo-shopify-hydrogen-demo)
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { ServerComponentRequest } from '@shopify/hydrogen/dist/esnext/framework/Hydration/ServerComponentRequest.server';
3
+ import type { ReviewWithProductPublic } from '@okendo/reviews-common';
4
+ export declare const OkendoProvider: React.FunctionComponent<OkendoProviderProps>;
5
+ interface OkendoProviderProps {
6
+ apiDomain?: string;
7
+ cdnDomain?: string;
8
+ productUrlFormatOverride?: (product: Pick<ReviewWithProductPublic, 'productHandle' | 'productId' | 'variantId'>) => string;
9
+ request: ServerComponentRequest;
10
+ subscriberId: string;
11
+ }
12
+ export {};
@@ -0,0 +1,67 @@
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
+ const kDefaultOkendoApiDomain = 'api.okendo.io/v1';
7
+ const kDefaultOkendoCdnDomain = 'd3hw6dc1ow8pp2.cloudfront.net';
8
+ export const OkendoProvider = (props) => {
9
+ const { apiDomain, cdnDomain, productUrlFormatOverride, request, subscriberId } = props;
10
+ // Download subscriber widget plus settings.
11
+ const url = `https://${apiDomain !== null && apiDomain !== void 0 ? apiDomain : kDefaultOkendoApiDomain}/stores/${subscriberId}/widget_plus_settings`;
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();
19
+ const cssVariablesNormalized = cssVariables.replace('<style id="oke-css-vars">', '').replace('</style>', '');
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.
33
+ const productUrlFormatter = typeof productUrlFormatOverride === 'function'
34
+ ? productUrlFormatOverride
35
+ : (product) => (product === null || product === void 0 ? void 0 : product.productHandle)
36
+ ? `/products/${product.productHandle}/${product.variantId ? '?variantId=' + product.variantId : ''}`
37
+ : undefined;
38
+ // Get pre-rendered style settings.
39
+ const query = gql `
40
+ query metafields {
41
+ shop {
42
+ widgetPreRenderStyleTags: metafield(namespace: "okendo", key: "WidgetPreRenderStyleTags") {
43
+ value
44
+ }
45
+ }
46
+ }
47
+ `;
48
+ const { data: { shop: { widgetPreRenderStyleTags } } } = useShopQuery({
49
+ query: query,
50
+ preload: true
51
+ });
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
+ }
56
+ return (React.createElement(React.Fragment, null,
57
+ React.createElement(Head, null,
58
+ React.createElement("script", { id: "oke-reviews-settings", type: "application/json" }, JSON.stringify(reviewsHeaderConfig)),
59
+ React.createElement("style", { id: "oke-css-vars" }, cssVariablesNormalized),
60
+ customCssNormalized && React.createElement("style", { id: "oke-reviews-custom-css" }, customCssNormalized),
61
+ React.createElement("meta", { name: "oke:subscriber_id", content: subscriberId }),
62
+ React.createElement("script", null, initScriptContents),
63
+ productUrlFormatter && React.createElement("script", { type: "text/javascript" }, `window.okeProductUrlFormatter = ${productUrlFormatter}`)),
64
+ preRenderStyleTags,
65
+ parse(starSymbols)));
66
+ };
67
+ //# sourceMappingURL=OkendoProvider.server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OkendoProvider.server.js","sourceRoot":"","sources":["../../../src/components/OkendoProvider.server.tsx"],"names":[],"mappings":"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","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"]}
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ export declare const OkendoReviewsWidget: React.FunctionComponent<OkendoReviewsWidgetProps>;
3
+ interface OkendoReviewsWidgetProps {
4
+ productId?: string;
5
+ }
6
+ export default OkendoReviewsWidget;
@@ -0,0 +1,59 @@
1
+ import React from 'react';
2
+ import parse from 'html-react-parser';
3
+ import { useShopQuery, gql } from '@shopify/hydrogen';
4
+ import { OkendoWidgetClient } from './OkendoWidget.client';
5
+ import { getOkendoProductId, useOkendoRequestContext, widgetMetafieldError } from '../shared';
6
+ export const OkendoReviewsWidget = (props) => {
7
+ var _a, _b, _c, _d, _e, _f;
8
+ const { setupFailed } = useOkendoRequestContext();
9
+ if (setupFailed) {
10
+ return null;
11
+ }
12
+ const { productId } = props;
13
+ const productQuery = productId
14
+ ? `
15
+ product(id: $productId) {
16
+ reviewsWidgetSnippet: metafield(namespace: "okendo", key: "ReviewsWidgetSnippet") {
17
+ value
18
+ }
19
+ }
20
+ `
21
+ : '';
22
+ const query = gql `
23
+ query metafields${productId ? '($productId: ID!)' : ''} {
24
+ ${productQuery}
25
+ shop {
26
+ widgetPreRenderBodyStyleTags: metafield(namespace: "okendo", key: "WidgetPreRenderBodyStyleTags") {
27
+ value
28
+ }
29
+ }
30
+ }
31
+ `;
32
+ const { data: { product, shop } } = useShopQuery({
33
+ query: query,
34
+ preload: true,
35
+ variables: {
36
+ productId
37
+ }
38
+ });
39
+ if (productId && !((_a = product === null || product === void 0 ? void 0 : product.reviewsWidgetSnippet) === null || _a === void 0 ? void 0 : _a.value)) {
40
+ console.warn(widgetMetafieldError('OkendoReviewsWidget', 'ReviewsWidgetSnippet'));
41
+ }
42
+ if (!((_b = shop === null || shop === void 0 ? void 0 : shop.widgetPreRenderBodyStyleTags) === null || _b === void 0 ? void 0 : _b.value)) {
43
+ console.warn(widgetMetafieldError('OkendoReviewsWidget', 'WidgetPreRenderBodyStyleTags'));
44
+ }
45
+ const dataAttributes = {
46
+ 'data-oke-widget': ''
47
+ };
48
+ if (productId) {
49
+ const okendoProductId = getOkendoProductId(productId);
50
+ if (okendoProductId) {
51
+ dataAttributes['data-oke-reviews-product-id'] = okendoProductId;
52
+ }
53
+ }
54
+ return (React.createElement(React.Fragment, null,
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 : '' })));
57
+ };
58
+ export default OkendoReviewsWidget;
59
+ //# sourceMappingURL=OkendoReviewsWidget.server.js.map
@@ -0,0 +1 @@
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,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAE9F,MAAM,CAAC,MAAM,mBAAmB,GAAsD,CAAC,KAAK,EAA6B,EAAE;;IACvH,MAAM,EAAE,WAAW,EAAE,GAAG,uBAAuB,EAAE,CAAC;IAClD,IAAI,WAAW,EAAE;QACb,OAAO,IAAI,CAAC;KACf;IAED,MAAM,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC;IAE5B,MAAM,YAAY,GAAG,SAAS;QAC1B,CAAC,CAAC;;;;;;SAMD;QACD,CAAC,CAAC,EAAE,CAAC;IAET,MAAM,KAAK,GAAG,GAAG,CAAA;0BACK,SAAS,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAAE;cAChD,YAAY;;;;;;;KAOrB,CAAC;IAEF,MAAM,EACF,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAC1B,GAAG,YAAY,CAAgC;QAC5C,KAAK,EAAE,KAAK;QACZ,OAAO,EAAE,IAAI;QACb,SAAS,EAAE;YACP,SAAS;SACZ;KACJ,CAAC,CAAC;IAEH,IAAI,SAAS,IAAI,CAAC,CAAA,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,oBAAoB,0CAAE,KAAK,CAAA,EAAE;QACpD,OAAO,CAAC,IAAI,CAAC,oBAAoB,CAAC,qBAAqB,EAAE,sBAAsB,CAAC,CAAC,CAAC;KACrF;IAED,IAAI,CAAC,CAAA,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,4BAA4B,0CAAE,KAAK,CAAA,EAAE;QAC5C,OAAO,CAAC,IAAI,CAAC,oBAAoB,CAAC,qBAAqB,EAAE,8BAA8B,CAAC,CAAC,CAAC;KAC7F;IAED,MAAM,cAAc,GAAQ;QACxB,iBAAiB,EAAE,EAAE;KACxB,CAAC;IAEF,IAAI,SAAS,EAAE;QACX,MAAM,eAAe,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;QACtD,IAAI,eAAe,EAAE;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"]}
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ export declare const OkendoStarRating: React.FunctionComponent<OkendoStarRatingProps>;
3
+ interface OkendoStarRatingProps {
4
+ productId: string;
5
+ }
6
+ export default OkendoStarRating;
@@ -0,0 +1,43 @@
1
+ import React from 'react';
2
+ import { useShopQuery, gql } from '@shopify/hydrogen';
3
+ import { OkendoWidgetClient } from './OkendoWidget.client';
4
+ import { getOkendoProductId, useOkendoRequestContext, widgetConfigurationError, widgetMetafieldError } from '../shared';
5
+ export const OkendoStarRating = (props) => {
6
+ const { setupFailed } = useOkendoRequestContext();
7
+ if (setupFailed) {
8
+ return null;
9
+ }
10
+ const { productId } = props;
11
+ const okendoProductId = getOkendoProductId(productId);
12
+ if (!okendoProductId) {
13
+ console.error(widgetConfigurationError('OkendoStarRating', 'productId was not provided'));
14
+ return null;
15
+ }
16
+ const query = gql `
17
+ query metafields($productId: ID!) {
18
+ product(id: $productId) {
19
+ starRatingSnippet: metafield(namespace: "okendo", key: "StarRatingSnippet") {
20
+ value
21
+ }
22
+ }
23
+ }
24
+ `;
25
+ const { data: { product: { starRatingSnippet } } } = useShopQuery({
26
+ query: query,
27
+ preload: true,
28
+ variables: {
29
+ productId
30
+ }
31
+ });
32
+ if (!(starRatingSnippet === null || starRatingSnippet === void 0 ? void 0 : starRatingSnippet.value)) {
33
+ console.warn(widgetMetafieldError('OkendoStarRating', 'StarRatingSnippet'));
34
+ }
35
+ const dataAttributes = {
36
+ 'data-oke-star-rating': '',
37
+ 'data-oke-reviews-product-id': okendoProductId,
38
+ 'data-oke-scroll-disabled': 'true'
39
+ };
40
+ return (React.createElement(OkendoWidgetClient, { dataAttributes: dataAttributes, metafieldContent: starRatingSnippet === null || starRatingSnippet === void 0 ? void 0 : starRatingSnippet.value }));
41
+ };
42
+ export default OkendoStarRating;
43
+ //# sourceMappingURL=OkendoStarRating.server.js.map
@@ -0,0 +1 @@
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,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAExH,MAAM,CAAC,MAAM,gBAAgB,GAAmD,CAAC,KAAK,EAA6B,EAAE;IACjH,MAAM,EAAE,WAAW,EAAE,GAAG,uBAAuB,EAAE,CAAC;IAClD,IAAI,WAAW,EAAE;QACb,OAAO,IAAI,CAAC;KACf;IAED,MAAM,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC;IAE5B,MAAM,eAAe,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;IACtD,IAAI,CAAC,eAAe,EAAE;QAClB,OAAO,CAAC,KAAK,CAAC,wBAAwB,CAAC,kBAAkB,EAAE,4BAA4B,CAAC,CAAC,CAAC;QAC1F,OAAO,IAAI,CAAC;KACf;IAED,MAAM,KAAK,GAAG,GAAG,CAAA;;;;;;;;KAQhB,CAAC;IAEF,MAAM,EACF,IAAI,EAAE,EACF,OAAO,EAAE,EAAE,iBAAiB,EAAE,EACjC,EACJ,GAAG,YAAY,CAA6B;QACzC,KAAK,EAAE,KAAK;QACZ,OAAO,EAAE,IAAI;QACb,SAAS,EAAE;YACP,SAAS;SACZ;KACJ,CAAC,CAAC;IAEH,IAAI,CAAC,CAAA,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAE,KAAK,CAAA,EAAE;QAC3B,OAAO,CAAC,IAAI,CAAC,oBAAoB,CAAC,kBAAkB,EAAE,mBAAmB,CAAC,CAAC,CAAC;KAC/E;IAED,MAAM,cAAc,GAAG;QACnB,sBAAsB,EAAE,EAAE;QAC1B,6BAA6B,EAAE,eAAe;QAC9C,0BAA0B,EAAE,MAAM;KACrC,CAAC;IAEF,OAAO,CACH,oBAAC,kBAAkB,IAAC,cAAc,EAAE,cAAc,EAAE,gBAAgB,EAAE,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAE,KAAK,GAAI,CACrG,CAAC;AACN,CAAC,CAAC;AAYF,eAAe,gBAAgB,CAAC","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"]}
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import type { SKO } from '@okendo/reviews-common';
3
+ import type { ReviewsWidgetPlus } from '@okendo/reviews-widget-plus/dist-utils/ReviewsWidgetPlus';
4
+ export declare const OkendoWidgetClient: React.FunctionComponent<OkendoWidgetClientProps>;
5
+ export interface OkendoWidgetClientProps {
6
+ dataAttributes: SKO;
7
+ metafieldContent?: string;
8
+ }
9
+ declare global {
10
+ interface Window {
11
+ okeWidgetApi: ReviewsWidgetPlus.WidgetWindowApi;
12
+ }
13
+ }
@@ -0,0 +1,20 @@
1
+ import React, { useEffect, useRef } from 'react';
2
+ export const OkendoWidgetClient = (props) => {
3
+ const { dataAttributes, metafieldContent = '' } = props;
4
+ const widgetContainer = useRef(null);
5
+ const initialiseReviewsWidget = () => {
6
+ if (widgetContainer.current) {
7
+ window.okeWidgetApi.initWidget(widgetContainer.current);
8
+ }
9
+ };
10
+ useEffect(() => {
11
+ if (window.okeWidgetApi) {
12
+ initialiseReviewsWidget();
13
+ }
14
+ else {
15
+ window.addEventListener('oke-script-loaded', initialiseReviewsWidget);
16
+ }
17
+ }, []);
18
+ return (React.createElement("div", { ref: widgetContainer, ...dataAttributes, dangerouslySetInnerHTML: { __html: metafieldContent } }));
19
+ };
20
+ //# sourceMappingURL=OkendoWidget.client.js.map
@@ -0,0 +1 @@
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"]}
@@ -0,0 +1,3 @@
1
+ export * from './OkendoReviewsWidget.server';
2
+ export * from './OkendoStarRating.server';
3
+ export * from './OkendoProvider.server';
@@ -0,0 +1,4 @@
1
+ export * from './OkendoReviewsWidget.server';
2
+ export * from './OkendoStarRating.server';
3
+ export * from './OkendoProvider.server';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC","sourcesContent":["export * from './OkendoReviewsWidget.server';\nexport * from './OkendoStarRating.server';\nexport * from './OkendoProvider.server';\n"]}
@@ -0,0 +1,2 @@
1
+ export * from './components';
2
+ export * from './shared';
@@ -0,0 +1,3 @@
1
+ export * from './components';
2
+ export * from './shared';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
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,3 @@
1
+ export declare function okendoError(message: string): string;
2
+ export declare function widgetConfigurationError(widgetName: string, message: string): string;
3
+ export declare function widgetMetafieldError(widgetName: string, metafieldName: string): string;
@@ -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,3 @@
1
+ export * from './errorUtils';
2
+ export * from './productUtils';
3
+ export * from './requestUtils';
@@ -0,0 +1,4 @@
1
+ export * from './errorUtils';
2
+ export * from './productUtils';
3
+ export * from './requestUtils';
4
+ //# sourceMappingURL=index.js.map
@@ -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,6 @@
1
+ /**
2
+ * Gets the product ID with Okendo formatting.
3
+ * @param productId The Shopify Product ID e.g. gid://shopify/Product/10079785100.
4
+ * @returns The product ID in Okendo formatting.
5
+ */
6
+ export declare function getOkendoProductId(productId: string): string | undefined;
@@ -0,0 +1,16 @@
1
+ const kProductIdRegex = /^[0-9]*$/;
2
+ /**
3
+ * Gets the product ID with Okendo formatting.
4
+ * @param productId The Shopify Product ID e.g. gid://shopify/Product/10079785100.
5
+ * @returns The product ID in Okendo formatting.
6
+ */
7
+ export function getOkendoProductId(productId) {
8
+ if (!productId) {
9
+ return;
10
+ }
11
+ // Supports Shopify's GraphQL Id syntax e.g. gid://shopify/Product/10079785100
12
+ return `shopify-${kProductIdRegex.test(productId)
13
+ ? productId
14
+ : productId.split('/').slice(-1)[0]}`;
15
+ }
16
+ //# sourceMappingURL=productUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"productUtils.js","sourceRoot":"","sources":["../../../src/shared/productUtils.ts"],"names":[],"mappings":"AAAA,MAAM,eAAe,GAAG,UAAU,CAAC;AAEnC;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,SAAiB;IAChD,IAAI,CAAC,SAAS,EAAE;QACZ,OAAO;KACV;IAED,8EAA8E;IAC9E,OAAO,WAAW,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC;QAC7C,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAClC,EAAE,CAAC;AACX,CAAC","sourcesContent":["const kProductIdRegex = /^[0-9]*$/;\n\n/**\n * Gets the product ID with Okendo formatting.\n * @param productId The Shopify Product ID e.g. gid://shopify/Product/10079785100.\n * @returns The product ID in Okendo formatting.\n */\nexport function getOkendoProductId(productId: string): string | undefined {\n if (!productId) {\n return;\n }\n\n // Supports Shopify's GraphQL Id syntax e.g. gid://shopify/Product/10079785100\n return `shopify-${kProductIdRegex.test(productId)\n ? productId\n : productId.split('/').slice(-1)[0]\n }`;\n}\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"]}
@@ -0,0 +1,2 @@
1
+ import type { Plugin } from 'vite';
2
+ export declare const extendViteOptimizeDeps: () => Plugin;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extendViteOptimizeDeps = void 0;
4
+ const extendViteOptimizeDeps = () => ({
5
+ name: 'vite-plugin-okendo-extend-optimize-deps',
6
+ config: () => ({
7
+ optimizeDeps: {
8
+ include: [
9
+ '@okendo/shopify-hydrogen > html-react-parser'
10
+ ]
11
+ }
12
+ })
13
+ });
14
+ exports.extendViteOptimizeDeps = extendViteOptimizeDeps;
15
+ //# sourceMappingURL=extendViteOptimizeDeps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extendViteOptimizeDeps.js","sourceRoot":"","sources":["../../../src/plugins/extendViteOptimizeDeps.ts"],"names":[],"mappings":";;;AAEO,MAAM,sBAAsB,GAAG,GAAW,EAAE,CAAC,CAAC;IACjD,IAAI,EAAE,yCAAyC;IAC/C,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;QACX,YAAY,EAAE;YACV,OAAO,EAAE;gBACL,8CAA8C;aACjD;SACJ;KACJ,CAAC;CACL,CAAC,CAAC;AATU,QAAA,sBAAsB,0BAShC","sourcesContent":["import type { Plugin } from 'vite';\n\nexport const extendViteOptimizeDeps = (): Plugin => ({\n name: 'vite-plugin-okendo-extend-optimize-deps',\n config: () => ({\n optimizeDeps: {\n include: [\n '@okendo/shopify-hydrogen > html-react-parser'\n ]\n }\n })\n});\n"]}
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from 'vite';
2
+ declare const _default: () => Plugin[];
3
+ export default _default;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const extendViteOptimizeDeps_1 = require("./extendViteOptimizeDeps");
4
+ exports.default = () => {
5
+ return [
6
+ (0, extendViteOptimizeDeps_1.extendViteOptimizeDeps)()
7
+ ];
8
+ };
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
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"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@okendo/shopify-hydrogen",
3
- "version": "0.0.1",
4
- "description": "A component library containing Okendo Reviews Widget componenets.",
3
+ "version": "0.0.4",
4
+ "description": "A component library containing Okendo Reviews React components.",
5
5
  "main": "dist/esnext/index.js",
6
6
  "files": [
7
7
  "dist",
@@ -10,7 +10,8 @@
10
10
  "scripts": {
11
11
  "build": "rimraf dist/ && npm run build:plugin:cjs && npm run build:esm",
12
12
  "build:plugin:cjs": "tsc --p tsconfig.plugin.cjs.json",
13
- "build:esm": "tsc --p tsconfig.esm.json"
13
+ "build:esm": "tsc --p tsconfig.esm.json",
14
+ "prepublishOnly": "npm run build"
14
15
  },
15
16
  "author": "Okendo",
16
17
  "license": "ISC",