@blotoutio/providers-shop-gpt-sdk 0.68.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/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@blotoutio/providers-shop-gpt-sdk",
3
+ "version": "0.68.1",
4
+ "description": "Shop GPT SDK for EdgeTag",
5
+ "author": "Blotout",
6
+ "license": "MIT",
7
+ "homepage": "https://github.com/blotoutio/edgetag-sdk",
8
+ "publishConfig": {
9
+ "access": "public"
10
+ },
11
+ "main": "./index.cjs.js",
12
+ "module": "./index.mjs",
13
+ "exports": {
14
+ ".": {
15
+ "require": "./index.cjs.js",
16
+ "import": "./index.mjs",
17
+ "default": "./index.js"
18
+ },
19
+ "./stores/shopify/index.js": {
20
+ "require": "./stores/shopify/index.cjs.js",
21
+ "import": "./stores/shopify/index.mjs",
22
+ "default": "./stores/shopify/index.js"
23
+ }
24
+ },
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git+https://github.com/blotoutio/edgetag-sdk.git"
28
+ },
29
+ "files": [
30
+ "package.json",
31
+ "README.md",
32
+ "index.js",
33
+ "index.cjs.js",
34
+ "index.mjs",
35
+ "stores/shopify/index.js",
36
+ "stores/shopify/index.cjs.js",
37
+ "stores/shopify/index.mjs"
38
+ ]
39
+ }
@@ -0,0 +1,36 @@
1
+ 'use strict';
2
+
3
+ var _a$1;
4
+ const registryKey = Symbol.for('shop-gpt');
5
+ if (typeof window != 'undefined') {
6
+ (_a$1 = window[registryKey]) !== null && _a$1 !== void 0 ? _a$1 : (window[registryKey] = {});
7
+ }
8
+
9
+ var _a, _b;
10
+ var _c;
11
+ const addItemToCart = (fetchOverride, itemsToAdd) => fetchOverride(`${window.Shopify.routes.root}cart/add.js`, {
12
+ method: 'POST',
13
+ body: JSON.stringify({
14
+ items: itemsToAdd.map((item) => ({
15
+ id: item.variantId || item.productId,
16
+ quantity: item.quantity,
17
+ })),
18
+ }),
19
+ headers: { 'Content-type': 'application/json' },
20
+ });
21
+ const createShopApi = (fetchOverride = window.fetch) => ({
22
+ async addToCart(item) {
23
+ const response = await addItemToCart(fetchOverride, [item]);
24
+ if (!response.ok) {
25
+ throw new Error(`Could not add items`, { cause: await response.text() });
26
+ }
27
+ },
28
+ getCurrentProductHandle() {
29
+ const pathname = window.location.pathname;
30
+ return pathname.split('/').at(-1);
31
+ },
32
+ });
33
+ if (typeof window != 'undefined') {
34
+ (_a = window[registryKey]) !== null && _a !== void 0 ? _a : (window[registryKey] = {});
35
+ (_b = (_c = window[registryKey]).storeAPIFactory) !== null && _b !== void 0 ? _b : (_c.storeAPIFactory = createShopApi);
36
+ }
@@ -0,0 +1,39 @@
1
+ (function () {
2
+ 'use strict';
3
+
4
+ var _a$1;
5
+ const registryKey = Symbol.for('shop-gpt');
6
+ if (typeof window != 'undefined') {
7
+ (_a$1 = window[registryKey]) !== null && _a$1 !== void 0 ? _a$1 : (window[registryKey] = {});
8
+ }
9
+
10
+ var _a, _b;
11
+ var _c;
12
+ const addItemToCart = (fetchOverride, itemsToAdd) => fetchOverride(`${window.Shopify.routes.root}cart/add.js`, {
13
+ method: 'POST',
14
+ body: JSON.stringify({
15
+ items: itemsToAdd.map((item) => ({
16
+ id: item.variantId || item.productId,
17
+ quantity: item.quantity,
18
+ })),
19
+ }),
20
+ headers: { 'Content-type': 'application/json' },
21
+ });
22
+ const createShopApi = (fetchOverride = window.fetch) => ({
23
+ async addToCart(item) {
24
+ const response = await addItemToCart(fetchOverride, [item]);
25
+ if (!response.ok) {
26
+ throw new Error(`Could not add items`, { cause: await response.text() });
27
+ }
28
+ },
29
+ getCurrentProductHandle() {
30
+ const pathname = window.location.pathname;
31
+ return pathname.split('/').at(-1);
32
+ },
33
+ });
34
+ if (typeof window != 'undefined') {
35
+ (_a = window[registryKey]) !== null && _a !== void 0 ? _a : (window[registryKey] = {});
36
+ (_b = (_c = window[registryKey]).storeAPIFactory) !== null && _b !== void 0 ? _b : (_c.storeAPIFactory = createShopApi);
37
+ }
38
+
39
+ })();
@@ -0,0 +1,34 @@
1
+ var _a$1;
2
+ const registryKey = Symbol.for('shop-gpt');
3
+ if (typeof window != 'undefined') {
4
+ (_a$1 = window[registryKey]) !== null && _a$1 !== void 0 ? _a$1 : (window[registryKey] = {});
5
+ }
6
+
7
+ var _a, _b;
8
+ var _c;
9
+ const addItemToCart = (fetchOverride, itemsToAdd) => fetchOverride(`${window.Shopify.routes.root}cart/add.js`, {
10
+ method: 'POST',
11
+ body: JSON.stringify({
12
+ items: itemsToAdd.map((item) => ({
13
+ id: item.variantId || item.productId,
14
+ quantity: item.quantity,
15
+ })),
16
+ }),
17
+ headers: { 'Content-type': 'application/json' },
18
+ });
19
+ const createShopApi = (fetchOverride = window.fetch) => ({
20
+ async addToCart(item) {
21
+ const response = await addItemToCart(fetchOverride, [item]);
22
+ if (!response.ok) {
23
+ throw new Error(`Could not add items`, { cause: await response.text() });
24
+ }
25
+ },
26
+ getCurrentProductHandle() {
27
+ const pathname = window.location.pathname;
28
+ return pathname.split('/').at(-1);
29
+ },
30
+ });
31
+ if (typeof window != 'undefined') {
32
+ (_a = window[registryKey]) !== null && _a !== void 0 ? _a : (window[registryKey] = {});
33
+ (_b = (_c = window[registryKey]).storeAPIFactory) !== null && _b !== void 0 ? _b : (_c.storeAPIFactory = createShopApi);
34
+ }