@tiledev/sdk-shopify 0.7.0 → 0.8.0
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/README.md +30 -0
- package/dist/alertSettings.d.ts +39 -0
- package/dist/alertSettings.d.ts.map +1 -0
- package/dist/alertSettings.js +76 -0
- package/dist/alertSettings.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -2
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +3 -1
- package/dist/react/index.js.map +1 -1
- package/dist/react/useAlertSettings.d.ts +32 -0
- package/dist/react/useAlertSettings.d.ts.map +1 -0
- package/dist/react/useAlertSettings.js +35 -0
- package/dist/react/useAlertSettings.js.map +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -269,6 +269,36 @@ Resolution order per key: `messages` prop → `config.messages` → `translate(k
|
|
|
269
269
|
rendering blank. `translate` is called with the i18n key where one exists
|
|
270
270
|
(`cart.added` → `toast.added_to_cart`), otherwise the message key itself.
|
|
271
271
|
|
|
272
|
+
### Reading the panel from the Live Layer
|
|
273
|
+
|
|
274
|
+
The editor publishes these fields into the app's Live Layer tree. The SDK owns
|
|
275
|
+
where each one lives, so an app only reads two values and passes its toast:
|
|
276
|
+
|
|
277
|
+
```tsx
|
|
278
|
+
import { ALERT_SETTINGS_PATH, MAX_LINE_ITEMS_SETTING_PATH, useAlertSettings } from '@tiledev/sdk-shopify';
|
|
279
|
+
|
|
280
|
+
const alerts = useLL(ALERT_SETTINGS_PATH); // settings.alerts
|
|
281
|
+
const maxLineItems = useLL(MAX_LINE_ITEMS_SETTING_PATH); // settings.cart.maxLineItems
|
|
282
|
+
const props = useAlertSettings({ alerts, maxLineItems, show: showToast });
|
|
283
|
+
|
|
284
|
+
<ShopifyProvider config={config} {...props}> // messages, cartPolicy, onEvent
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
| Published value | Result |
|
|
288
|
+
| --- | --- |
|
|
289
|
+
| A string | That alert's copy, cut to 200 characters |
|
|
290
|
+
| `''` (the merchant cleared the field) | That alert is **silenced**: `onEvent` shows nothing |
|
|
291
|
+
| Absent, or not a string | The default copy |
|
|
292
|
+
| `maxLineItems` 1–100 (number or numeric string) | The cart limit |
|
|
293
|
+
| `maxLineItems` anything else | No limit |
|
|
294
|
+
|
|
295
|
+
Note the one difference from the `messages` prop: there an empty string falls
|
|
296
|
+
back to the default, here it silences. The panel publishes `''` only when the
|
|
297
|
+
merchant clears a field on purpose. Without React, `readAlertSettings(tree)`
|
|
298
|
+
and `readCartPolicy(value)` return the same values, and
|
|
299
|
+
`ALERT_SETTING_FIELDS` is the path table (`cart.outOfStock` sits in the
|
|
300
|
+
Checkout group, where the panel shows it).
|
|
301
|
+
|
|
272
302
|
### Cart line limit
|
|
273
303
|
|
|
274
304
|
`cartPolicy.maxLineItems` is the panel's "Cart Line Item Maximum Limit". It counts
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { AlertMessageKey, AlertMessages, CartPolicy } from './types';
|
|
2
|
+
/** The Live Layer subtree holding every alert's copy. */
|
|
3
|
+
export declare const ALERT_SETTINGS_PATH: readonly ["settings", "alerts"];
|
|
4
|
+
/** The panel's "Max Different Products in Cart". */
|
|
5
|
+
export declare const MAX_LINE_ITEMS_SETTING_PATH: readonly ["settings", "cart", "maxLineItems"];
|
|
6
|
+
/**
|
|
7
|
+
* Where each alert's copy lives, as `[group, field]` under `ALERT_SETTINGS_PATH`.
|
|
8
|
+
* `cart.outOfStock` sits in the Checkout group: that is where the panel shows it.
|
|
9
|
+
*/
|
|
10
|
+
export declare const ALERT_SETTING_FIELDS: Readonly<Record<AlertMessageKey, readonly [group: string, field: string]>>;
|
|
11
|
+
/** The panel caps every alert at this; a longer published value is cut, not refused. */
|
|
12
|
+
export declare const MAX_ALERT_LENGTH = 200;
|
|
13
|
+
/** The panel's bounds for the line limit. Outside them the value is ignored (no limit). */
|
|
14
|
+
export declare const MAX_LINE_ITEMS_RANGE: {
|
|
15
|
+
readonly min: 1;
|
|
16
|
+
readonly max: 100;
|
|
17
|
+
};
|
|
18
|
+
export interface AlertSettings {
|
|
19
|
+
/** Published copy, ready for `<ShopifyProvider messages>`. */
|
|
20
|
+
messages: AlertMessages;
|
|
21
|
+
/** Alerts the merchant cleared: raise no toast for these. */
|
|
22
|
+
silenced: ReadonlySet<AlertMessageKey>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The alert copy and the silenced set from the `settings.alerts` subtree.
|
|
26
|
+
* Anything that isn't a string (unpublished, a stray number) keeps the default.
|
|
27
|
+
*/
|
|
28
|
+
export declare function readAlertSettings(alerts: unknown): AlertSettings;
|
|
29
|
+
/**
|
|
30
|
+
* The cart policy from `settings.cart.maxLineItems`. The panel's number field may
|
|
31
|
+
* publish a string; a value outside 1–100 would either block every add or mean
|
|
32
|
+
* nothing, so it is ignored.
|
|
33
|
+
*/
|
|
34
|
+
export declare function readCartPolicy(maxLineItems: unknown): CartPolicy;
|
|
35
|
+
/** Whether an event's alert was cleared in the panel. Events with no alert are never silenced. */
|
|
36
|
+
export declare function isAlertSilenced(event: {
|
|
37
|
+
messageKey?: AlertMessageKey;
|
|
38
|
+
}, silenced: ReadonlySet<AlertMessageKey>): boolean;
|
|
39
|
+
//# sourceMappingURL=alertSettings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alertSettings.d.ts","sourceRoot":"","sources":["../src/alertSettings.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1E,yDAAyD;AACzD,eAAO,MAAM,mBAAmB,iCAAkC,CAAC;AAEnE,oDAAoD;AACpD,eAAO,MAAM,2BAA2B,+CAAgD,CAAC;AAEzF;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,MAAM,CAAC,eAAe,EAAE,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAc3G,CAAC;AAEF,wFAAwF;AACxF,eAAO,MAAM,gBAAgB,MAAM,CAAC;AAEpC,2FAA2F;AAC3F,eAAO,MAAM,oBAAoB;;;CAAgC,CAAC;AAElE,MAAM,WAAW,aAAa;IAC5B,8DAA8D;IAC9D,QAAQ,EAAE,aAAa,CAAC;IACxB,6DAA6D;IAC7D,QAAQ,EAAE,WAAW,CAAC,eAAe,CAAC,CAAC;CACxC;AAID;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,GAAG,aAAa,CAahE;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,YAAY,EAAE,OAAO,GAAG,UAAU,CAKhE;AAED,kGAAkG;AAClG,wBAAgB,eAAe,CAC7B,KAAK,EAAE;IAAE,UAAU,CAAC,EAAE,eAAe,CAAA;CAAE,EACvC,QAAQ,EAAE,WAAW,CAAC,eAAe,CAAC,GACrC,OAAO,CAET"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MAX_LINE_ITEMS_RANGE = exports.MAX_ALERT_LENGTH = exports.ALERT_SETTING_FIELDS = exports.MAX_LINE_ITEMS_SETTING_PATH = exports.ALERT_SETTINGS_PATH = void 0;
|
|
4
|
+
exports.readAlertSettings = readAlertSettings;
|
|
5
|
+
exports.readCartPolicy = readCartPolicy;
|
|
6
|
+
exports.isAlertSilenced = isAlertSilenced;
|
|
7
|
+
/** The Live Layer subtree holding every alert's copy. */
|
|
8
|
+
exports.ALERT_SETTINGS_PATH = ['settings', 'alerts'];
|
|
9
|
+
/** The panel's "Max Different Products in Cart". */
|
|
10
|
+
exports.MAX_LINE_ITEMS_SETTING_PATH = ['settings', 'cart', 'maxLineItems'];
|
|
11
|
+
/**
|
|
12
|
+
* Where each alert's copy lives, as `[group, field]` under `ALERT_SETTINGS_PATH`.
|
|
13
|
+
* `cart.outOfStock` sits in the Checkout group: that is where the panel shows it.
|
|
14
|
+
*/
|
|
15
|
+
exports.ALERT_SETTING_FIELDS = {
|
|
16
|
+
'cart.added': ['cart', 'added'],
|
|
17
|
+
'cart.removed': ['cart', 'removed'],
|
|
18
|
+
'cart.limitExceeded': ['cart', 'limitExceeded'],
|
|
19
|
+
'cart.outOfStock': ['checkout', 'outOfStock'],
|
|
20
|
+
'wishlist.added': ['wishlist', 'added'],
|
|
21
|
+
'wishlist.removed': ['wishlist', 'removed'],
|
|
22
|
+
'wishlist.empty': ['wishlist', 'empty'],
|
|
23
|
+
'auth.loginSuccess': ['auth', 'loginSuccess'],
|
|
24
|
+
'auth.loginFailed': ['auth', 'loginFailed'],
|
|
25
|
+
'auth.loggedOut': ['auth', 'loggedOut'],
|
|
26
|
+
'auth.resetLinkSent': ['auth', 'resetLinkSent'],
|
|
27
|
+
'checkout.orderPlaced': ['checkout', 'orderPlaced'],
|
|
28
|
+
'checkout.paymentFailed': ['checkout', 'paymentFailed'],
|
|
29
|
+
};
|
|
30
|
+
/** The panel caps every alert at this; a longer published value is cut, not refused. */
|
|
31
|
+
exports.MAX_ALERT_LENGTH = 200;
|
|
32
|
+
/** The panel's bounds for the line limit. Outside them the value is ignored (no limit). */
|
|
33
|
+
exports.MAX_LINE_ITEMS_RANGE = { min: 1, max: 100 };
|
|
34
|
+
const ALERT_KEYS = Object.keys(exports.ALERT_SETTING_FIELDS);
|
|
35
|
+
/**
|
|
36
|
+
* The alert copy and the silenced set from the `settings.alerts` subtree.
|
|
37
|
+
* Anything that isn't a string (unpublished, a stray number) keeps the default.
|
|
38
|
+
*/
|
|
39
|
+
function readAlertSettings(alerts) {
|
|
40
|
+
const messages = {};
|
|
41
|
+
const silenced = new Set();
|
|
42
|
+
const tree = isRecord(alerts) ? alerts : {};
|
|
43
|
+
for (const key of ALERT_KEYS) {
|
|
44
|
+
const [group, field] = exports.ALERT_SETTING_FIELDS[key];
|
|
45
|
+
const section = tree[group];
|
|
46
|
+
const value = isRecord(section) ? section[field] : undefined;
|
|
47
|
+
if (typeof value !== 'string')
|
|
48
|
+
continue;
|
|
49
|
+
if (value.trim() === '')
|
|
50
|
+
silenced.add(key);
|
|
51
|
+
else
|
|
52
|
+
messages[key] = value.slice(0, exports.MAX_ALERT_LENGTH);
|
|
53
|
+
}
|
|
54
|
+
return { messages, silenced };
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The cart policy from `settings.cart.maxLineItems`. The panel's number field may
|
|
58
|
+
* publish a string; a value outside 1–100 would either block every add or mean
|
|
59
|
+
* nothing, so it is ignored.
|
|
60
|
+
*/
|
|
61
|
+
function readCartPolicy(maxLineItems) {
|
|
62
|
+
const n = typeof maxLineItems === 'string' ? Number.parseInt(maxLineItems, 10) : maxLineItems;
|
|
63
|
+
if (typeof n !== 'number' || !Number.isFinite(n))
|
|
64
|
+
return {};
|
|
65
|
+
if (n < exports.MAX_LINE_ITEMS_RANGE.min || n > exports.MAX_LINE_ITEMS_RANGE.max)
|
|
66
|
+
return {};
|
|
67
|
+
return { maxLineItems: Math.round(n) };
|
|
68
|
+
}
|
|
69
|
+
/** Whether an event's alert was cleared in the panel. Events with no alert are never silenced. */
|
|
70
|
+
function isAlertSilenced(event, silenced) {
|
|
71
|
+
return !!event.messageKey && silenced.has(event.messageKey);
|
|
72
|
+
}
|
|
73
|
+
function isRecord(value) {
|
|
74
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=alertSettings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alertSettings.js","sourceRoot":"","sources":["../src/alertSettings.ts"],"names":[],"mappings":";;;AA4DA,8CAaC;AAOD,wCAKC;AAGD,0CAKC;AA9ED,yDAAyD;AAC5C,QAAA,mBAAmB,GAAG,CAAC,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AAe,CAC7B,KAAuC,EACvC,QAAsC;IAEtC,OAAO,CAAC,CAAC,KAAK,CAAC,UAAU,IAAI,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;AAC9D,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,10 +7,11 @@ export { toLineSnapshot } from './cart';
|
|
|
7
7
|
export { priceRange, priceFilterInput, parsePriceFilterInput, isPriceFilterInput, type PriceRange, } from './filters';
|
|
8
8
|
export { DEFAULT_MESSAGES, message, getMessages, setMessages, patchMessages, setMessageResolver, limitExceededMessage, } from './messages';
|
|
9
9
|
export { setCartPolicy, getCartPolicy, maxLineItems, projectedLineCount, wouldExceedLineLimit, } from './cartPolicy';
|
|
10
|
+
export { ALERT_SETTINGS_PATH, MAX_LINE_ITEMS_SETTING_PATH, ALERT_SETTING_FIELDS, MAX_ALERT_LENGTH, MAX_LINE_ITEMS_RANGE, readAlertSettings, readCartPolicy, isAlertSilenced, type AlertSettings, } from './alertSettings';
|
|
10
11
|
export { classifyAuthFailure, isOutOfStockError, isUserErrorRejection, userErrorsOf, } from './errors';
|
|
11
12
|
export { TileCreditClient, configureTileCredit, getTileCreditClient, redeemAndApplyToCart, centsToMoney, moneyToCents, } from './tileCredit';
|
|
12
13
|
export { setProductMetafields, getProductMetafields, productMetafield, } from './metafields';
|
|
13
14
|
export { TileCreditError } from './types';
|
|
14
15
|
export type * from './types';
|
|
15
|
-
export { ShopifyProvider, useShopify, useCart, useWishlist, useCustomer, useCheckout, useShopifyMessage, useTileCredit, useCollectionProducts, COLLECTION_PAGE_SIZE, useSearch, SEARCH_PAGE_SIZE, SEARCH_DEBOUNCE_MS, useProduct, REVALIDATE_AFTER_MS, type ShopifyProviderProps, type ShopifyEvent, type ShopifyEventType, type CartState, type WishlistState, type CustomerState, type CheckoutState, type UseTileCreditOptions, type UseTileCreditState, type CollectionSort, type UseCollectionProductsOptions, type CollectionProductsState, type UseCollectionProductsResult, type SearchSort, type UseSearchOptions, type UseSearchResult, type SearchState, type UseProductOptions, type UseProductState, type UseProductResult, type ProductFeedState, type ProductFeedResult, } from './react';
|
|
16
|
+
export { ShopifyProvider, useShopify, useCart, useWishlist, useCustomer, useCheckout, useShopifyMessage, useTileCredit, useCollectionProducts, COLLECTION_PAGE_SIZE, useSearch, SEARCH_PAGE_SIZE, SEARCH_DEBOUNCE_MS, useProduct, REVALIDATE_AFTER_MS, useAlertSettings, type ShopifyProviderProps, type ShopifyEvent, type ShopifyEventType, type CartState, type WishlistState, type CustomerState, type CheckoutState, type UseTileCreditOptions, type UseTileCreditState, type CollectionSort, type UseCollectionProductsOptions, type CollectionProductsState, type UseCollectionProductsResult, type SearchSort, type UseSearchOptions, type UseSearchResult, type SearchState, type UseProductOptions, type UseProductState, type UseProductResult, type ProductFeedState, type ProductFeedResult, type UseAlertSettingsOptions, type AlertSettingsProps, } from './react';
|
|
16
17
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,KAAK,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACnG,OAAO,EACL,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,aA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KAAK,2BAA2B,EAChC,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,KAAK,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACnG,OAAO,EACL,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,KAAK,WAAW,EAChB,KAAK,aAAa,GACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,qBAAqB,EACrB,kBAAkB,EAClB,KAAK,UAAU,GAChB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,gBAAgB,EAChB,OAAO,EACP,WAAW,EACX,WAAW,EACX,aAAa,EACb,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,aAAa,EACb,aAAa,EACb,YAAY,EACZ,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,mBAAmB,EACnB,2BAA2B,EAC3B,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,KAAK,aAAa,GACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,YAAY,GACb,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,YAAY,EACZ,YAAY,GACb,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC1C,mBAAmB,SAAS,CAAC;AAO7B,OAAO,EACL,eAAe,EACf,UAAU,EACV,OAAO,EACP,WAAW,EACX,WAAW,EACX,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,qBAAqB,EACrB,oBAAoB,EACpB,SAAS,EACT,gBAAgB,EAChB,kBAAkB,EAClB,UAAU,EACV,mBAAmB,EACnB,gBAAgB,EAChB,KAAK,oBAAoB,EACzB,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,4BAA4B,EACjC,KAAK,uBAAuB,EAC5B,KAAK,2BAA2B,EAChC,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,GACxB,MAAM,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.REVALIDATE_AFTER_MS = exports.useProduct = exports.SEARCH_DEBOUNCE_MS = exports.SEARCH_PAGE_SIZE = exports.useSearch = exports.COLLECTION_PAGE_SIZE = exports.useCollectionProducts = exports.useTileCredit = exports.useShopifyMessage = exports.useCheckout = void 0;
|
|
3
|
+
exports.setProductMetafields = exports.moneyToCents = exports.centsToMoney = exports.redeemAndApplyToCart = exports.getTileCreditClient = exports.configureTileCredit = exports.TileCreditClient = exports.userErrorsOf = exports.isUserErrorRejection = exports.isOutOfStockError = exports.classifyAuthFailure = exports.isAlertSilenced = exports.readCartPolicy = exports.readAlertSettings = exports.MAX_LINE_ITEMS_RANGE = exports.MAX_ALERT_LENGTH = exports.ALERT_SETTING_FIELDS = exports.MAX_LINE_ITEMS_SETTING_PATH = exports.ALERT_SETTINGS_PATH = exports.wouldExceedLineLimit = exports.projectedLineCount = exports.maxLineItems = exports.getCartPolicy = exports.setCartPolicy = exports.limitExceededMessage = exports.setMessageResolver = exports.patchMessages = exports.setMessages = exports.getMessages = exports.message = exports.DEFAULT_MESSAGES = exports.isPriceFilterInput = exports.parsePriceFilterInput = exports.priceFilterInput = exports.priceRange = exports.toLineSnapshot = exports.toProductBase = exports.clearProductStore = exports.forgetProduct = exports.peekProduct = exports.PRODUCT_BASE_KEYS = exports.DEFAULT_CACHE_TTL_MS = exports.clearRequestCache = exports.getCurrencyCode = exports.getMoneyFormat = exports.shop = exports.applyMoneyFormat = exports.formatMoney = exports.default = exports.shopify = void 0;
|
|
4
|
+
exports.useAlertSettings = exports.REVALIDATE_AFTER_MS = exports.useProduct = exports.SEARCH_DEBOUNCE_MS = exports.SEARCH_PAGE_SIZE = exports.useSearch = exports.COLLECTION_PAGE_SIZE = exports.useCollectionProducts = exports.useTileCredit = exports.useShopifyMessage = exports.useCheckout = exports.useCustomer = exports.useWishlist = exports.useCart = exports.useShopify = exports.ShopifyProvider = exports.TileCreditError = exports.productMetafield = exports.getProductMetafields = void 0;
|
|
5
5
|
var shopify_1 = require("./shopify");
|
|
6
6
|
Object.defineProperty(exports, "shopify", { enumerable: true, get: function () { return shopify_1.shopify; } });
|
|
7
7
|
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return shopify_1.shopify; } });
|
|
@@ -42,6 +42,15 @@ Object.defineProperty(exports, "getCartPolicy", { enumerable: true, get: functio
|
|
|
42
42
|
Object.defineProperty(exports, "maxLineItems", { enumerable: true, get: function () { return cartPolicy_1.maxLineItems; } });
|
|
43
43
|
Object.defineProperty(exports, "projectedLineCount", { enumerable: true, get: function () { return cartPolicy_1.projectedLineCount; } });
|
|
44
44
|
Object.defineProperty(exports, "wouldExceedLineLimit", { enumerable: true, get: function () { return cartPolicy_1.wouldExceedLineLimit; } });
|
|
45
|
+
var alertSettings_1 = require("./alertSettings");
|
|
46
|
+
Object.defineProperty(exports, "ALERT_SETTINGS_PATH", { enumerable: true, get: function () { return alertSettings_1.ALERT_SETTINGS_PATH; } });
|
|
47
|
+
Object.defineProperty(exports, "MAX_LINE_ITEMS_SETTING_PATH", { enumerable: true, get: function () { return alertSettings_1.MAX_LINE_ITEMS_SETTING_PATH; } });
|
|
48
|
+
Object.defineProperty(exports, "ALERT_SETTING_FIELDS", { enumerable: true, get: function () { return alertSettings_1.ALERT_SETTING_FIELDS; } });
|
|
49
|
+
Object.defineProperty(exports, "MAX_ALERT_LENGTH", { enumerable: true, get: function () { return alertSettings_1.MAX_ALERT_LENGTH; } });
|
|
50
|
+
Object.defineProperty(exports, "MAX_LINE_ITEMS_RANGE", { enumerable: true, get: function () { return alertSettings_1.MAX_LINE_ITEMS_RANGE; } });
|
|
51
|
+
Object.defineProperty(exports, "readAlertSettings", { enumerable: true, get: function () { return alertSettings_1.readAlertSettings; } });
|
|
52
|
+
Object.defineProperty(exports, "readCartPolicy", { enumerable: true, get: function () { return alertSettings_1.readCartPolicy; } });
|
|
53
|
+
Object.defineProperty(exports, "isAlertSilenced", { enumerable: true, get: function () { return alertSettings_1.isAlertSilenced; } });
|
|
45
54
|
var errors_1 = require("./errors");
|
|
46
55
|
Object.defineProperty(exports, "classifyAuthFailure", { enumerable: true, get: function () { return errors_1.classifyAuthFailure; } });
|
|
47
56
|
Object.defineProperty(exports, "isOutOfStockError", { enumerable: true, get: function () { return errors_1.isOutOfStockError; } });
|
|
@@ -81,4 +90,5 @@ Object.defineProperty(exports, "SEARCH_PAGE_SIZE", { enumerable: true, get: func
|
|
|
81
90
|
Object.defineProperty(exports, "SEARCH_DEBOUNCE_MS", { enumerable: true, get: function () { return react_1.SEARCH_DEBOUNCE_MS; } });
|
|
82
91
|
Object.defineProperty(exports, "useProduct", { enumerable: true, get: function () { return react_1.useProduct; } });
|
|
83
92
|
Object.defineProperty(exports, "REVALIDATE_AFTER_MS", { enumerable: true, get: function () { return react_1.REVALIDATE_AFTER_MS; } });
|
|
93
|
+
Object.defineProperty(exports, "useAlertSettings", { enumerable: true, get: function () { return react_1.useAlertSettings; } });
|
|
84
94
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,qCAAwD;AAA/C,kGAAA,OAAO,OAAA;AAAE,kGAAA,OAAO,OAAW;AACpC,iCAA8D;AAArD,oGAAA,WAAW,OAAA;AAAE,yGAAA,gBAAgB,OAAA;AAAE,6FAAA,IAAI,OAAA;AAC5C,mCAA2D;AAAlD,wGAAA,cAAc,OAAA;AAAE,yGAAA,eAAe,OAAA;AACxC,+CAAmG;AAA1F,iHAAA,iBAAiB,OAAA;AAAE,oHAAA,oBAAoB,OAAA;AAChD,+CAQwB;AAPtB,iHAAA,iBAAiB,OAAA;AACjB,2GAAA,WAAW,OAAA;AACX,6GAAA,aAAa,OAAA;AACb,iHAAA,iBAAiB,OAAA;AACjB,6GAAA,aAAa,OAAA;AAIf,+BAAwC;AAA/B,sGAAA,cAAc,OAAA;AACvB,qCAMmB;AALjB,qGAAA,UAAU,OAAA;AACV,2GAAA,gBAAgB,OAAA;AACh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AEd,2CAIsB;AAHpB,kHAAA,oBAAoB,OAAA;AACpB,kHAAA,oBAAoB,OAAA;AACpB,8GAAA,gBAAgB,OAAA;AAElB,iCAA0C;AAAjC,wGAAA,eAAe,OAAA;AAGxB,uEAAuE;AACvE,qEAAqE;AACrE,yEAAyE;AACzE,kEAAkE;AAClE,gEAAgE;AAChE,iCAyCiB;AAxCf,wGAAA,eAAe,OAAA;AACf,mGAAA,UAAU,OAAA;AACV,gGAAA,OAAO,OAAA;AACP,oGAAA,WAAW,OAAA;AACX,oGAAA,WAAW,OAAA;AACX,oGAAA,WAAW,OAAA;AACX,0GAAA,iBAAiB,OAAA;AACjB,sGAAA,aAAa,OAAA;AACb,8GAAA,qBAAqB,OAAA;AACrB,6GAAA,oBAAoB,OAAA;AACpB,kGAAA,SAAS,OAAA;AACT,yGAAA,gBAAgB,OAAA;AAChB,2GAAA,kBAAkB,OAAA;AAClB,mGAAA,UAAU,OAAA;AACV,4GAAA,mBAAmB,OAAA;AACnB,yGAAA,gBAAgB,OAAA"}
|
package/dist/react/index.d.ts
CHANGED
|
@@ -4,4 +4,5 @@ export { useCollectionProducts, COLLECTION_PAGE_SIZE, type CollectionSort, type
|
|
|
4
4
|
export { useSearch, SEARCH_PAGE_SIZE, SEARCH_DEBOUNCE_MS, type SearchSort, type UseSearchOptions, type UseSearchResult, type SearchState, } from "./useSearch";
|
|
5
5
|
export { useProduct, type UseProductOptions, type UseProductState, type UseProductResult, } from "./useProduct";
|
|
6
6
|
export { REVALIDATE_AFTER_MS, type ProductFeedState, type ProductFeedResult } from "./useProductFeed";
|
|
7
|
+
export { useAlertSettings, type UseAlertSettingsOptions, type AlertSettingsProps, } from "./useAlertSettings";
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,UAAU,EACV,OAAO,EACP,WAAW,EACX,WAAW,EACX,WAAW,EACX,iBAAiB,EACjB,KAAK,oBAAoB,EACzB,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,aAAa,GACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,aAAa,EACb,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,GACxB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,KAAK,cAAc,EACnB,KAAK,4BAA4B,EACjC,KAAK,uBAAuB,EAC5B,KAAK,2BAA2B,GACjC,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,WAAW,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,UAAU,EACV,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,gBAAgB,GACtB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,mBAAmB,EAAE,KAAK,gBAAgB,EAAE,KAAK,iBAAiB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,UAAU,EACV,OAAO,EACP,WAAW,EACX,WAAW,EACX,WAAW,EACX,iBAAiB,EACjB,KAAK,oBAAoB,EACzB,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,aAAa,GACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,aAAa,EACb,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,GACxB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,KAAK,cAAc,EACnB,KAAK,4BAA4B,EACjC,KAAK,uBAAuB,EAC5B,KAAK,2BAA2B,GACjC,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,WAAW,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,UAAU,EACV,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,gBAAgB,GACtB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,mBAAmB,EAAE,KAAK,gBAAgB,EAAE,KAAK,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACtG,OAAO,EACL,gBAAgB,EAChB,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,GACxB,MAAM,oBAAoB,CAAC"}
|
package/dist/react/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.REVALIDATE_AFTER_MS = exports.useProduct = exports.SEARCH_DEBOUNCE_MS = exports.SEARCH_PAGE_SIZE = exports.useSearch = exports.COLLECTION_PAGE_SIZE = exports.useCollectionProducts = exports.useTileCredit = exports.useShopifyMessage = exports.useCheckout = exports.useCustomer = exports.useWishlist = exports.useCart = exports.useShopify = exports.ShopifyProvider = void 0;
|
|
3
|
+
exports.useAlertSettings = exports.REVALIDATE_AFTER_MS = exports.useProduct = exports.SEARCH_DEBOUNCE_MS = exports.SEARCH_PAGE_SIZE = exports.useSearch = exports.COLLECTION_PAGE_SIZE = exports.useCollectionProducts = exports.useTileCredit = exports.useShopifyMessage = exports.useCheckout = exports.useCustomer = exports.useWishlist = exports.useCart = exports.useShopify = exports.ShopifyProvider = void 0;
|
|
4
4
|
var ShopifyProvider_1 = require("./ShopifyProvider");
|
|
5
5
|
Object.defineProperty(exports, "ShopifyProvider", { enumerable: true, get: function () { return ShopifyProvider_1.ShopifyProvider; } });
|
|
6
6
|
Object.defineProperty(exports, "useShopify", { enumerable: true, get: function () { return ShopifyProvider_1.useShopify; } });
|
|
@@ -22,4 +22,6 @@ var useProduct_1 = require("./useProduct");
|
|
|
22
22
|
Object.defineProperty(exports, "useProduct", { enumerable: true, get: function () { return useProduct_1.useProduct; } });
|
|
23
23
|
var useProductFeed_1 = require("./useProductFeed");
|
|
24
24
|
Object.defineProperty(exports, "REVALIDATE_AFTER_MS", { enumerable: true, get: function () { return useProductFeed_1.REVALIDATE_AFTER_MS; } });
|
|
25
|
+
var useAlertSettings_1 = require("./useAlertSettings");
|
|
26
|
+
Object.defineProperty(exports, "useAlertSettings", { enumerable: true, get: function () { return useAlertSettings_1.useAlertSettings; } });
|
|
25
27
|
//# sourceMappingURL=index.js.map
|
package/dist/react/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":";;;AAAA,qDAe2B;AAdzB,kHAAA,eAAe,OAAA;AACf,6GAAA,UAAU,OAAA;AACV,0GAAA,OAAO,OAAA;AACP,8GAAA,WAAW,OAAA;AACX,8GAAA,WAAW,OAAA;AACX,8GAAA,WAAW,OAAA;AACX,oHAAA,iBAAiB,OAAA;AASnB,iDAIyB;AAHvB,8GAAA,aAAa,OAAA;AAIf,iEAOiC;AAN/B,8HAAA,qBAAqB,OAAA;AACrB,6HAAA,oBAAoB,OAAA;AAMtB,yCAQqB;AAPnB,sGAAA,SAAS,OAAA;AACT,6GAAA,gBAAgB,OAAA;AAChB,+GAAA,kBAAkB,OAAA;AAMpB,2CAKsB;AAJpB,wGAAA,UAAU,OAAA;AAKZ,mDAAsG;AAA7F,qHAAA,mBAAmB,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":";;;AAAA,qDAe2B;AAdzB,kHAAA,eAAe,OAAA;AACf,6GAAA,UAAU,OAAA;AACV,0GAAA,OAAO,OAAA;AACP,8GAAA,WAAW,OAAA;AACX,8GAAA,WAAW,OAAA;AACX,8GAAA,WAAW,OAAA;AACX,oHAAA,iBAAiB,OAAA;AASnB,iDAIyB;AAHvB,8GAAA,aAAa,OAAA;AAIf,iEAOiC;AAN/B,8HAAA,qBAAqB,OAAA;AACrB,6HAAA,oBAAoB,OAAA;AAMtB,yCAQqB;AAPnB,sGAAA,SAAS,OAAA;AACT,6GAAA,gBAAgB,OAAA;AAChB,+GAAA,kBAAkB,OAAA;AAMpB,2CAKsB;AAJpB,wGAAA,UAAU,OAAA;AAKZ,mDAAsG;AAA7F,qHAAA,mBAAmB,OAAA;AAC5B,uDAI4B;AAH1B,oHAAA,gBAAgB,OAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { AlertMessages, CartPolicy } from "../types";
|
|
2
|
+
import type { ShopifyEvent } from "./ShopifyProvider";
|
|
3
|
+
export interface UseAlertSettingsOptions {
|
|
4
|
+
/** The Live Layer's `settings.alerts` subtree (`ALERT_SETTINGS_PATH`). */
|
|
5
|
+
alerts: unknown;
|
|
6
|
+
/** The Live Layer's `settings.cart.maxLineItems` (`MAX_LINE_ITEMS_SETTING_PATH`). */
|
|
7
|
+
maxLineItems?: unknown;
|
|
8
|
+
/** Show one alert, e.g. the app's toast. Not called for alerts the merchant cleared. */
|
|
9
|
+
show: (message: string, severity: ShopifyEvent["severity"]) => void;
|
|
10
|
+
}
|
|
11
|
+
export interface AlertSettingsProps {
|
|
12
|
+
messages: AlertMessages;
|
|
13
|
+
cartPolicy: CartPolicy;
|
|
14
|
+
onEvent: (event: ShopifyEvent) => void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The Settings panel's alerts and cart limit, as `ShopifyProvider` props. The app
|
|
18
|
+
* reads the two Live Layer values and passes its toast; the path table, the
|
|
19
|
+
* "cleared means silent" rule and the limit bounds stay here.
|
|
20
|
+
*
|
|
21
|
+
* ```tsx
|
|
22
|
+
* const alerts = useLL(ALERT_SETTINGS_PATH);
|
|
23
|
+
* const maxLineItems = useLL(MAX_LINE_ITEMS_SETTING_PATH);
|
|
24
|
+
* const props = useAlertSettings({ alerts, maxLineItems, show: showToast });
|
|
25
|
+
* <ShopifyProvider config={config} {...props}>
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* `onEvent` keeps one identity for the provider's lifetime, so a new `show`
|
|
29
|
+
* arrow on each render rebuilds nothing.
|
|
30
|
+
*/
|
|
31
|
+
export declare function useAlertSettings({ alerts, maxLineItems, show }: UseAlertSettingsOptions): AlertSettingsProps;
|
|
32
|
+
//# sourceMappingURL=useAlertSettings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAlertSettings.d.ts","sourceRoot":"","sources":["../../src/react/useAlertSettings.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,MAAM,WAAW,uBAAuB;IACtC,0EAA0E;IAC1E,MAAM,EAAE,OAAO,CAAC;IAChB,qFAAqF;IACrF,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,wFAAwF;IACxF,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;CACrE;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,aAAa,CAAC;IACxB,UAAU,EAAE,UAAU,CAAC;IACvB,OAAO,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;CACxC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,uBAAuB,GAAG,kBAAkB,CAc5G"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useAlertSettings = useAlertSettings;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const alertSettings_1 = require("../alertSettings");
|
|
6
|
+
/**
|
|
7
|
+
* The Settings panel's alerts and cart limit, as `ShopifyProvider` props. The app
|
|
8
|
+
* reads the two Live Layer values and passes its toast; the path table, the
|
|
9
|
+
* "cleared means silent" rule and the limit bounds stay here.
|
|
10
|
+
*
|
|
11
|
+
* ```tsx
|
|
12
|
+
* const alerts = useLL(ALERT_SETTINGS_PATH);
|
|
13
|
+
* const maxLineItems = useLL(MAX_LINE_ITEMS_SETTING_PATH);
|
|
14
|
+
* const props = useAlertSettings({ alerts, maxLineItems, show: showToast });
|
|
15
|
+
* <ShopifyProvider config={config} {...props}>
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* `onEvent` keeps one identity for the provider's lifetime, so a new `show`
|
|
19
|
+
* arrow on each render rebuilds nothing.
|
|
20
|
+
*/
|
|
21
|
+
function useAlertSettings({ alerts, maxLineItems, show }) {
|
|
22
|
+
const { messages, silenced } = (0, react_1.useMemo)(() => (0, alertSettings_1.readAlertSettings)(alerts), [alerts]);
|
|
23
|
+
const cartPolicy = (0, react_1.useMemo)(() => (0, alertSettings_1.readCartPolicy)(maxLineItems), [maxLineItems]);
|
|
24
|
+
const latest = (0, react_1.useRef)({ silenced, show });
|
|
25
|
+
latest.current = { silenced, show };
|
|
26
|
+
const onEvent = (0, react_1.useCallback)((event) => {
|
|
27
|
+
const { silenced: quiet, show: display } = latest.current;
|
|
28
|
+
if ((0, alertSettings_1.isAlertSilenced)(event, quiet))
|
|
29
|
+
return;
|
|
30
|
+
if (event.message)
|
|
31
|
+
display(event.message, event.severity);
|
|
32
|
+
}, []);
|
|
33
|
+
return { messages, cartPolicy, onEvent };
|
|
34
|
+
}
|
|
35
|
+
//# sourceMapp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
|
"name": "@tiledev/sdk-shopify",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Type-safe Shopify Storefront API client for React Native (web, iOS, Android). Products, collections, cart, customer session, blogs, a local-storage-backed wishlist, and configurable shopper alerts. Zero deps beyond fetch.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"clean": "rm -rf dist",
|
|
27
27
|
"build": "npm run clean && tsc -p tsconfig.json",
|
|
28
28
|
"lint": "tsc --noEmit",
|
|
29
|
-
"test": "npm run build && node test/alerts.test.mjs && node test/provider.test.mjs && node test/cart-snapshot.test.mjs && node test/collection-filters.test.mjs && node test/request-cache.test.mjs && node test/product-store.test.mjs && node test/image-transform.test.mjs"
|
|
29
|
+
"test": "npm run build && node test/alerts.test.mjs && node test/provider.test.mjs && node test/cart-snapshot.test.mjs && node test/collection-filters.test.mjs && node test/request-cache.test.mjs && node test/product-store.test.mjs && node test/image-transform.test.mjs && node test/alert-settings.test.mjs"
|
|
30
30
|
},
|
|
31
31
|
"keywords": [
|
|
32
32
|
"shopify",
|