@okendo/shopify-hydrogen 0.0.12 → 1.0.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/LICENSE.txt +3 -0
- package/README.md +16 -10
- package/dist/esnext/components/OkendoProvider.server.js +7 -8
- package/dist/esnext/components/OkendoReviewsWidget.server.js +4 -6
- package/dist/esnext/components/OkendoStarRating.server.js +2 -3
- package/dist/esnext/components/OkendoWidget.client.js +0 -1
- package/dist/esnext/components/index.js +0 -1
- package/dist/esnext/framework/index.d.ts +0 -0
- package/dist/esnext/framework/index.js +1 -0
- package/dist/{node/plugin → esnext/framework/plugins}/extendViteOptimizeDeps.d.ts +0 -0
- package/dist/esnext/framework/plugins/extendViteOptimizeDeps.js +10 -0
- package/dist/esnext/framework/plugins/plugin.d.ts +7 -0
- package/dist/esnext/framework/plugins/plugin.js +9 -0
- package/dist/esnext/framework/plugins/suppressModuleWarning.d.ts +3 -0
- package/dist/esnext/framework/plugins/suppressModuleWarning.js +18 -0
- package/dist/esnext/index.js +0 -1
- package/dist/esnext/shared/errorUtils.js +0 -1
- package/dist/esnext/shared/index.js +0 -1
- package/dist/esnext/shared/productUtils.js +0 -1
- package/dist/esnext/shared/requestUtils.js +0 -1
- package/dist/esnext/shared/sharedTypes.js +0 -1
- package/dist/node/framework/index.d.ts +0 -0
- package/dist/node/framework/index.js +1 -0
- package/dist/node/framework/plugins/extendViteOptimizeDeps.d.ts +2 -0
- package/dist/node/{plugin → framework/plugins}/extendViteOptimizeDeps.js +0 -1
- package/dist/node/framework/plugins/plugin.d.ts +4 -0
- package/dist/node/framework/plugins/plugin.js +14 -0
- package/dist/node/framework/plugins/suppressModuleWarning.d.ts +3 -0
- package/dist/node/framework/plugins/suppressModuleWarning.js +20 -0
- package/package.json +21 -7
- package/plugin.cjs +1 -0
- package/dist/esnext/components/OkendoProvider.server.js.map +0 -1
- package/dist/esnext/components/OkendoReviewsWidget.server.js.map +0 -1
- package/dist/esnext/components/OkendoStarRating.server.js.map +0 -1
- package/dist/esnext/components/OkendoWidget.client.js.map +0 -1
- package/dist/esnext/components/index.js.map +0 -1
- package/dist/esnext/index.js.map +0 -1
- package/dist/esnext/shared/errorUtils.js.map +0 -1
- package/dist/esnext/shared/index.js.map +0 -1
- package/dist/esnext/shared/productUtils.js.map +0 -1
- package/dist/esnext/shared/requestUtils.js.map +0 -1
- package/dist/esnext/shared/sharedTypes.js.map +0 -1
- package/dist/node/plugin/extendViteOptimizeDeps.js.map +0 -1
- package/dist/node/plugin/index.d.ts +0 -3
- package/dist/node/plugin/index.js +0 -9
- package/dist/node/plugin/index.js.map +0 -1
- package/plugin.js +0 -1
package/LICENSE.txt
ADDED
package/README.md
CHANGED
|
@@ -49,7 +49,7 @@ The purpose of this documentation is to guide you on the following:
|
|
|
49
49
|
|
|
50
50
|
## Configure Hydrogen app config <a id="configure-hydrogen-app-config" name="configure-hydrogen-app-config"></a>
|
|
51
51
|
|
|
52
|
-
1. Open **hydrogen.config.
|
|
52
|
+
1. Open **hydrogen.config.ts** in your project.
|
|
53
53
|
2. Make the following changes and save the file:
|
|
54
54
|
- Update `storeDomain` to specify your store's domain name.
|
|
55
55
|
- Update `storefrontToken` to specify your Storefront API access token.
|
|
@@ -296,39 +296,45 @@ mutation {
|
|
|
296
296
|
## Installation
|
|
297
297
|
|
|
298
298
|
1. In your Hydrogen app directory, run `npm install @okendo/shopify-hydrogen` inside a terminal or PowerShell window.
|
|
299
|
-
2. **Optional:** Create (or add to) your `.env` file at the top level of your project (next to **hydrogen.config.
|
|
299
|
+
2. **Optional:** Create (or add to) your `.env` file at the top level of your project (next to **hydrogen.config.ts**) the following, where `<your_subscriber_id>` is replaced with your Okendo Subscriber ID:
|
|
300
300
|
|
|
301
301
|
```sh
|
|
302
302
|
# .env
|
|
303
303
|
VITE_OKENDO_SUBSCRIBER_ID=<your_subscriber_id>
|
|
304
304
|
```
|
|
305
305
|
|
|
306
|
-
3. Open **vite.config.
|
|
306
|
+
3. Open **vite.config.ts** and add `import okendo from '@okendo/shopify-hydrogen/plugin';` to the list of imports.
|
|
307
307
|
4. Add `okendo()` to the list of `plugins`.
|
|
308
308
|
|
|
309
309
|
```tsx
|
|
310
|
-
/* vite.config.
|
|
310
|
+
/* vite.config.ts */
|
|
311
|
+
/// <reference types="vitest" />
|
|
311
312
|
import {defineConfig} from 'vite';
|
|
312
313
|
import hydrogen from '@shopify/hydrogen/plugin';
|
|
313
314
|
import okendo from '@okendo/shopify-hydrogen/plugin';
|
|
314
315
|
|
|
315
|
-
// https://vitejs.dev/config/
|
|
316
316
|
export default defineConfig({
|
|
317
317
|
plugins: [hydrogen(), okendo()],
|
|
318
|
-
|
|
318
|
+
resolve: {
|
|
319
|
+
alias: [{find: /^~\/(.*)/, replacement: '/src/$1'}],
|
|
320
|
+
},
|
|
321
|
+
optimizeDeps: {
|
|
322
|
+
include: ['@headlessui/react', 'clsx', 'react-use', 'typographic-base'],
|
|
323
|
+
},
|
|
319
324
|
test: {
|
|
320
325
|
globals: true,
|
|
321
326
|
testTimeout: 10000,
|
|
322
327
|
hookTimeout: 10000,
|
|
323
328
|
},
|
|
324
329
|
});
|
|
330
|
+
|
|
325
331
|
```
|
|
326
332
|
|
|
327
|
-
5. Open **App.server.
|
|
333
|
+
5. Open **App.server.tsx** and import `OkendoProvider`.
|
|
328
334
|
6. Include the `OkendoProvider` as shown below, passing through your `subscriberId` from your Vite environment variables.
|
|
329
335
|
|
|
330
336
|
```tsx
|
|
331
|
-
/* App.server.
|
|
337
|
+
/* App.server.tsx */
|
|
332
338
|
import {OkendoProvider} from '@okendo/shopify-hydrogen';
|
|
333
339
|
|
|
334
340
|
function App() {
|
|
@@ -363,7 +369,7 @@ mutation {
|
|
|
363
369
|
|
|
364
370
|
## Widget Usage
|
|
365
371
|
|
|
366
|
-
Import `OkendoReviewsWidget` and `OkendoStarRating` and use as
|
|
372
|
+
Import `OkendoReviewsWidget` and `OkendoStarRating` and use as TSX components. Pass in the Shopify Product ID as a prop.
|
|
367
373
|
|
|
368
374
|
The `productId` prop is optional for the `OkendoReviewsWidget`. Not providing it will mean that the widget will display reviews for all products, which is ideal for homepages or collection pages.
|
|
369
375
|
|
|
@@ -389,7 +395,7 @@ const okendoStarRating = <OkendoStarRating productId={product.id} />;
|
|
|
389
395
|
|
|
390
396
|
Top level component for enabling Okendo Widgets.
|
|
391
397
|
|
|
392
|
-
We recommend using it directly inside the `<ShopifyProvider>` as its first child in **App.server.
|
|
398
|
+
We recommend using it directly inside the `<ShopifyProvider>` as its first child in **App.server.tsx**.
|
|
393
399
|
|
|
394
400
|
It will provide:
|
|
395
401
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import parse from 'html-react-parser';
|
|
3
|
-
import { fetchSync, useShopQuery, gql,
|
|
4
|
-
import { Head } from '@shopify/hydrogen
|
|
3
|
+
import { fetchSync, useShopQuery, gql, CacheShort } from '@shopify/hydrogen';
|
|
4
|
+
import { Head } from '@shopify/hydrogen';
|
|
5
5
|
import { okendoError, setInOkendoRequestContext } from '../shared';
|
|
6
6
|
const kDefaultOkendoApiDomain = 'api.okendo.io/v1';
|
|
7
7
|
const kDefaultOkendoCdnDomain = 'cdn-static.okendo.io';
|
|
8
8
|
export const OkendoProvider = (props) => {
|
|
9
9
|
const { apiDomain, cdnDomain, children, productUrlFormatOverride, subscriberId } = props;
|
|
10
10
|
// Download subscriber widget plus settings.
|
|
11
|
-
const url = `https://${apiDomain
|
|
11
|
+
const url = `https://${apiDomain ?? kDefaultOkendoApiDomain}/stores/${subscriberId}/widget_plus_settings`;
|
|
12
12
|
const settingsResponse = fetchSync(url, { preload: true });
|
|
13
13
|
if (!settingsResponse.response.ok) {
|
|
14
14
|
console.error(okendoError('Failed to retrieve subscriber settings. Please check your environment variables.'));
|
|
@@ -19,8 +19,8 @@ export const OkendoProvider = (props) => {
|
|
|
19
19
|
const cssVariablesNormalized = cssVariables.replace('<style id="oke-css-vars">', '').replace('</style>', '');
|
|
20
20
|
const customCssNormalized = customCss ? customCss.replace('<style id="oke-reviews-custom-css">', '').replace('</style>', '') : '';
|
|
21
21
|
// Download contents of widget initialisation script.
|
|
22
|
-
const initScriptResponse = fetchSync(`https://${cdnDomain
|
|
23
|
-
cache:
|
|
22
|
+
const initScriptResponse = fetchSync(`https://${cdnDomain ?? kDefaultOkendoCdnDomain}/reviews-widget-plus/js/okendo-reviews.js`, {
|
|
23
|
+
cache: CacheShort(),
|
|
24
24
|
preload: true
|
|
25
25
|
});
|
|
26
26
|
if (!initScriptResponse.response.ok) {
|
|
@@ -32,7 +32,7 @@ export const OkendoProvider = (props) => {
|
|
|
32
32
|
// Set up product URL formatter.
|
|
33
33
|
const productUrlFormatter = typeof productUrlFormatOverride === 'function'
|
|
34
34
|
? productUrlFormatOverride
|
|
35
|
-
: (product) =>
|
|
35
|
+
: (product) => product?.productHandle
|
|
36
36
|
? `/products/${product.productHandle}/${product.variantId ? '?variantId=' + product.variantId : ''}`
|
|
37
37
|
: undefined;
|
|
38
38
|
// Get pre-rendered style settings.
|
|
@@ -49,7 +49,7 @@ export const OkendoProvider = (props) => {
|
|
|
49
49
|
query: query,
|
|
50
50
|
preload: true
|
|
51
51
|
});
|
|
52
|
-
const preRenderStyleTags =
|
|
52
|
+
const preRenderStyleTags = widgetPreRenderStyleTags?.value ? parse(widgetPreRenderStyleTags.value) : '';
|
|
53
53
|
if (!preRenderStyleTags) {
|
|
54
54
|
console.warn(okendoError('Failed to retrieve pre-rendered widget style settings.'));
|
|
55
55
|
}
|
|
@@ -65,4 +65,3 @@ export const OkendoProvider = (props) => {
|
|
|
65
65
|
parse(starSymbols),
|
|
66
66
|
children));
|
|
67
67
|
};
|
|
68
|
-
//# sourceMappingURL=OkendoProvider.server.js.map
|
|
@@ -4,7 +4,6 @@ import { useShopQuery, gql } from '@shopify/hydrogen';
|
|
|
4
4
|
import { OkendoWidgetClient } from './OkendoWidget.client';
|
|
5
5
|
import { getOkendoProductId, useOkendoRequestContext, widgetMetafieldError } from '../shared';
|
|
6
6
|
export const OkendoReviewsWidget = (props) => {
|
|
7
|
-
var _a, _b, _c, _d, _e, _f;
|
|
8
7
|
const { setupFailed } = useOkendoRequestContext();
|
|
9
8
|
if (setupFailed) {
|
|
10
9
|
return null;
|
|
@@ -36,10 +35,10 @@ export const OkendoReviewsWidget = (props) => {
|
|
|
36
35
|
productId
|
|
37
36
|
}
|
|
38
37
|
});
|
|
39
|
-
if (productId && !
|
|
38
|
+
if (productId && !product?.reviewsWidgetSnippet?.value) {
|
|
40
39
|
console.warn(widgetMetafieldError('OkendoReviewsWidget', 'ReviewsWidgetSnippet'));
|
|
41
40
|
}
|
|
42
|
-
if (!
|
|
41
|
+
if (!shop?.widgetPreRenderBodyStyleTags?.value) {
|
|
43
42
|
console.warn(widgetMetafieldError('OkendoReviewsWidget', 'WidgetPreRenderBodyStyleTags'));
|
|
44
43
|
}
|
|
45
44
|
const dataAttributes = {
|
|
@@ -52,8 +51,7 @@ export const OkendoReviewsWidget = (props) => {
|
|
|
52
51
|
}
|
|
53
52
|
}
|
|
54
53
|
return (React.createElement(React.Fragment, null,
|
|
55
|
-
parse(
|
|
56
|
-
React.createElement(OkendoWidgetClient, { dataAttributes: dataAttributes, metafieldContent:
|
|
54
|
+
parse(shop?.widgetPreRenderBodyStyleTags?.value ?? ''),
|
|
55
|
+
React.createElement(OkendoWidgetClient, { dataAttributes: dataAttributes, metafieldContent: product?.reviewsWidgetSnippet?.value ?? '' })));
|
|
57
56
|
};
|
|
58
57
|
export default OkendoReviewsWidget;
|
|
59
|
-
//# sourceMappingURL=OkendoReviewsWidget.server.js.map
|
|
@@ -29,7 +29,7 @@ export const OkendoStarRating = (props) => {
|
|
|
29
29
|
productId
|
|
30
30
|
}
|
|
31
31
|
});
|
|
32
|
-
if (!
|
|
32
|
+
if (!starRatingSnippet?.value) {
|
|
33
33
|
console.warn(widgetMetafieldError('OkendoStarRating', 'StarRatingSnippet'));
|
|
34
34
|
}
|
|
35
35
|
const dataAttributes = {
|
|
@@ -37,7 +37,6 @@ export const OkendoStarRating = (props) => {
|
|
|
37
37
|
'data-oke-reviews-product-id': okendoProductId,
|
|
38
38
|
'data-oke-scroll-disabled': 'true'
|
|
39
39
|
};
|
|
40
|
-
return (React.createElement(OkendoWidgetClient, { dataAttributes: dataAttributes, metafieldContent: starRatingSnippet
|
|
40
|
+
return (React.createElement(OkendoWidgetClient, { dataAttributes: dataAttributes, metafieldContent: starRatingSnippet?.value }));
|
|
41
41
|
};
|
|
42
42
|
export default OkendoStarRating;
|
|
43
|
-
//# sourceMappingURL=OkendoStarRating.server.js.map
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
File without changes
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { extendViteOptimizeDeps } from './extendViteOptimizeDeps';
|
|
2
|
+
import suppressModuleWarning from './suppressModuleWarning';
|
|
3
|
+
const okendoPlugin = () => {
|
|
4
|
+
return [
|
|
5
|
+
extendViteOptimizeDeps(),
|
|
6
|
+
suppressModuleWarning()
|
|
7
|
+
];
|
|
8
|
+
};
|
|
9
|
+
export default okendoPlugin; // For ESM
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/* Inspired by Hydrogen 1.0.0 source hydrogen\packages\hydrogen\src\framework\plugins\vite-plugin-hydrogen-suppress-warnings.ts */
|
|
2
|
+
export default () => {
|
|
3
|
+
return {
|
|
4
|
+
name: 'okendo:suppress-warnings',
|
|
5
|
+
configResolved(config) {
|
|
6
|
+
// TODO: Fix the actual issues that cause these warnings
|
|
7
|
+
const filterOut = (msg) => msg.startsWith("@okendo/shopify-hydrogen doesn't appear to be written in CJS");
|
|
8
|
+
for (const method of ['warn', 'warnOnce']) {
|
|
9
|
+
const original = config.logger[method];
|
|
10
|
+
config.logger[method] = (msg, ...args) => {
|
|
11
|
+
if (filterOut(msg))
|
|
12
|
+
return;
|
|
13
|
+
return original(msg, ...args);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
};
|
package/dist/esnext/index.js
CHANGED
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
const extendViteOptimizeDeps_1 = require("./extendViteOptimizeDeps");
|
|
6
|
+
const suppressModuleWarning_1 = __importDefault(require("./suppressModuleWarning"));
|
|
7
|
+
const okendoPlugin = () => {
|
|
8
|
+
return [
|
|
9
|
+
(0, extendViteOptimizeDeps_1.extendViteOptimizeDeps)(),
|
|
10
|
+
(0, suppressModuleWarning_1.default)()
|
|
11
|
+
];
|
|
12
|
+
};
|
|
13
|
+
exports.default = okendoPlugin; // For ESM
|
|
14
|
+
module.exports = okendoPlugin;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/* Inspired by Hydrogen 1.0.0 source hydrogen\packages\hydrogen\src\framework\plugins\vite-plugin-hydrogen-suppress-warnings.ts */
|
|
4
|
+
exports.default = () => {
|
|
5
|
+
return {
|
|
6
|
+
name: 'okendo:suppress-warnings',
|
|
7
|
+
configResolved(config) {
|
|
8
|
+
// TODO: Fix the actual issues that cause these warnings
|
|
9
|
+
const filterOut = (msg) => msg.startsWith("@okendo/shopify-hydrogen doesn't appear to be written in CJS");
|
|
10
|
+
for (const method of ['warn', 'warnOnce']) {
|
|
11
|
+
const original = config.logger[method];
|
|
12
|
+
config.logger[method] = (msg, ...args) => {
|
|
13
|
+
if (filterOut(msg))
|
|
14
|
+
return;
|
|
15
|
+
return original(msg, ...args);
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
};
|
package/package.json
CHANGED
|
@@ -1,29 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@okendo/shopify-hydrogen",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "A component library containing Okendo Reviews React components.",
|
|
5
5
|
"main": "dist/esnext/index.js",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": ">=14"
|
|
8
|
+
},
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./dist/esnext/index.js",
|
|
11
|
+
"./plugin": {
|
|
12
|
+
"import": "./dist/esnext/framework/plugins/plugin.js",
|
|
13
|
+
"require": "./dist/node/framework/plugins/plugin.js"
|
|
14
|
+
},
|
|
15
|
+
"./plugin.cjs": "./plugin.cjs",
|
|
16
|
+
"./package.json": "./package.json",
|
|
17
|
+
"./*": "./dist/esnext/*.js"
|
|
18
|
+
},
|
|
19
|
+
"types": "dist/esnext/index.d.ts",
|
|
6
20
|
"files": [
|
|
7
21
|
"dist",
|
|
8
|
-
"plugin.
|
|
22
|
+
"plugin.cjs"
|
|
9
23
|
],
|
|
10
24
|
"scripts": {
|
|
11
|
-
"build": "rimraf dist/ && npm run build:
|
|
25
|
+
"build": "rimraf dist/ && npm run build:esm && npm run build:plugin:cjs",
|
|
12
26
|
"build:plugin:cjs": "tsc --p tsconfig.plugin.cjs.json",
|
|
13
27
|
"build:esm": "tsc --p tsconfig.esm.json",
|
|
14
28
|
"prepublishOnly": "npm run build"
|
|
15
29
|
},
|
|
16
30
|
"author": "Okendo",
|
|
17
|
-
"license": "
|
|
31
|
+
"license": "SEE LICENSE IN LICENSE.txt",
|
|
18
32
|
"dependencies": {
|
|
19
33
|
"html-react-parser": "^1.4.13"
|
|
20
34
|
},
|
|
21
35
|
"devDependencies": {
|
|
22
36
|
"@okendo/reviews-widget-plus": "^0.39.0",
|
|
23
37
|
"@okendo/tsconfig": "0.0.2",
|
|
24
|
-
"@shopify/hydrogen": "^0.
|
|
38
|
+
"@shopify/hydrogen": "^1.0.0",
|
|
25
39
|
"@types/node": "^17.0.35",
|
|
26
|
-
"@types/react": "^18.0.
|
|
40
|
+
"@types/react": "^18.0.14",
|
|
27
41
|
"@types/react-dom": "^18.0.5",
|
|
28
42
|
"dotenv": "^16.0.1",
|
|
29
43
|
"rimraf": "^3.0.2",
|
|
@@ -31,6 +45,6 @@
|
|
|
31
45
|
"vite": "^2.9.0"
|
|
32
46
|
},
|
|
33
47
|
"peerDependencies": {
|
|
34
|
-
"@shopify/hydrogen": "0.
|
|
48
|
+
"@shopify/hydrogen": "1.0.x"
|
|
35
49
|
}
|
|
36
50
|
}
|
package/plugin.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist/node/framework/plugin');
|
|
@@ -1 +0,0 @@
|
|
|
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;AAGhD,OAAO,EAAE,WAAW,EAAE,yBAAyB,EAAO,MAAM,WAAW,CAAC;AAExE,MAAM,uBAAuB,GAAG,kBAAkB,CAAC;AACnD,MAAM,uBAAuB,GAAG,sBAAsB,CAAC;AAEvD,MAAM,CAAC,MAAM,cAAc,GAAiD,CAAC,KAAK,EAAsB,EAAE;IACtG,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,wBAAwB,EAAE,YAAY,EAAE,GAAG,KAAK,CAAC;IAEzF,4CAA4C;IAC5C,MAAM,GAAG,GAAG,WAAW,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,uBAAuB,WAAW,YAAY,uBAAuB,CAAC;IAC1G,MAAM,gBAA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,EAAE,CAAU,CACvH;QACN,kBAAkB;QAClB,KAAK,CAAC,WAAW,CAAC;QAClB,QAAQ,CACV,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 type { Metafield } from '@shopify/hydrogen/dist/esnext/storefront-api-types';\n\nimport { okendoError, setInOkendoRequestContext, SKO } from '../shared';\n\nconst kDefaultOkendoApiDomain = 'api.okendo.io/v1';\nconst kDefaultOkendoCdnDomain = 'cdn-static.okendo.io';\n\nexport const OkendoProvider: React.FunctionComponent<OkendoProviderProps> = (props): JSX.Element | null => {\n const { apiDomain, cdnDomain, children, productUrlFormatOverride, 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('setupFailed', true);\n return null;\n }\n\n const { cssVariables, customCss, reviewsHeaderConfig, starSymbols } = settingsResponse.json() as WidgetPlusSettingsResponse;\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('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: ReviewProduct) =>\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 {children}\n </>\n );\n}\n\ninterface OkendoProviderProps {\n apiDomain?: string;\n cdnDomain?: string;\n children?: React.ReactNode;\n productUrlFormatOverride?: (product: ReviewProduct) => string;\n subscriberId: string;\n}\n\ninterface OkendoProviderMetafields {\n shop: {\n widgetPreRenderStyleTags?: Pick<Metafield, 'value'>\n };\n}\n\ninterface ReviewProduct {\n productHandle?: string;\n productId: string;\n variantId?: string;\n}\n\ninterface WidgetPlusSettingsResponse {\n reviewsHeaderConfig: SKO;\n cssVariables: string;\n starSymbols: string;\n customCss?: string;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OkendoReviewsWidget.server.js","sourceRoot":"","sources":["../../../src/components/Okendo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AA,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';\n\nimport { OkendoWidgetClient } from './OkendoWidget.client';\nimport { getOkendoProductId, SKO, 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 +0,0 @@
|
|
|
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"]}
|
|
@@ -1 +0,0 @@
|
|
|
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 { ReviewsWidgetPlus } from '@okendo/reviews-widget-plus/dist-utils/ReviewsWidgetPlus';\nimport type { SKO } from '../shared';\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"]}
|
|
@@ -1 +0,0 @@
|
|
|
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"]}
|
package/dist/esnext/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"]}
|
|
@@ -1 +0,0 @@
|
|
|
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"]}
|
|
@@ -1 +0,0 @@
|
|
|
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;AAC/B,cAAc,eAAe,CAAC","sourcesContent":["export * from './errorUtils';\nexport * from './productUtils';\nexport * from './requestUtils';\nexport * from './sharedTypes';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
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"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"requestUtils.js","sourceRoot":"","sources":["../../../src/shared/requestUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAItD,MAAM,UAAU,yBAAyB,CAAC,GAAmC,EAAE,KAAwD;IACnI,MAAM,oBAAoB,GAAG,uBAAuB,EAAE,CAAC;IACvD,oBAAoB,CAAC,GAAG,CAAC,GAAG,KAAY,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,uBAAuB;IACnC,OAAO,iBAAiB,CAAuB,QAAQ,CAAC,CAAC;AAC7D,CAAC","sourcesContent":["import { useRequestContext } from '@shopify/hydrogen';\n\nimport { SKO } from './sharedTypes';\n\nexport function setInOkendoRequestContext(key: keyof OkendoRequestContextKeys, value: RequestContextSafeType | RequestContextSafeType[]): void {\n const okendoRequestContext = useOkendoRequestContext();\n okendoRequestContext[key] = value as any;\n}\n\nexport function useOkendoRequestContext(): OkendoRequestContext {\n return useRequestContext<OkendoRequestContext>('okendo');\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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sharedTypes.js","sourceRoot":"","sources":["../../../src/shared/sharedTypes.ts"],"names":[],"mappings":"","sourcesContent":["export type SKO = Record<string, unknown>;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
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"]}
|
|
@@ -1,9 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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/plugin.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('./dist/node/plugin');
|