@occluze/tether 0.6.8 → 0.7.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.
Files changed (215) hide show
  1. package/README.md +28 -28
  2. package/dist/esm/astro.js +2 -2
  3. package/dist/esm/chunks/account-CXMA5RPZ.js +1 -0
  4. package/dist/esm/chunks/account-pages-IZO7FEOZ.js +1 -0
  5. package/dist/esm/chunks/analytics-PG5FPRDN.js +1 -0
  6. package/dist/esm/chunks/chunk-4HD4J5JC.js +1 -0
  7. package/dist/esm/chunks/chunk-6TFMLT4A.js +4 -0
  8. package/dist/esm/chunks/chunk-BBVUVPMO.js +1 -0
  9. package/dist/esm/chunks/chunk-E5YO6274.js +1 -0
  10. package/dist/esm/chunks/chunk-EW5SYO6L.js +1 -0
  11. package/dist/esm/chunks/chunk-HJY2JSNB.js +1 -0
  12. package/dist/esm/chunks/chunk-MQYB6BH4.js +1 -0
  13. package/dist/esm/chunks/chunk-N3V45JPS.js +1 -0
  14. package/dist/esm/chunks/chunk-RPMBCAGS.js +1 -0
  15. package/dist/esm/chunks/chunk-VFNHIGCS.js +1 -0
  16. package/dist/esm/chunks/chunk-WT7RGGJU.js +1 -0
  17. package/dist/esm/chunks/chunk-YN6LEBEN.js +1 -0
  18. package/dist/esm/chunks/chunk-Z6HS3H7K.js +1 -0
  19. package/dist/esm/chunks/diagnose-XCEBQKBO.js +14 -0
  20. package/dist/esm/chunks/extras-4HU3VSBQ.js +1 -0
  21. package/dist/esm/chunks/markets-ui-M4IQ62CT.js +1 -0
  22. package/dist/esm/chunks/search-A5DS2IOS.js +1 -0
  23. package/dist/esm/index.js +1 -1
  24. package/dist/esm/server.js +2 -2
  25. package/dist/presets/barba.esm.js +19 -23
  26. package/dist/tether.account-pages.js +332 -367
  27. package/dist/tether.account-pages.min.js +1 -1
  28. package/dist/tether.account.js +253 -492
  29. package/dist/tether.account.min.js +1 -1
  30. package/dist/tether.analytics.js +82 -89
  31. package/dist/tether.analytics.min.js +1 -1
  32. package/dist/tether.diagnose.js +52 -34
  33. package/dist/tether.diagnose.min.js +2 -2
  34. package/dist/tether.extras.js +42 -37
  35. package/dist/tether.extras.min.js +1 -1
  36. package/dist/tether.js +1361 -935
  37. package/dist/tether.markets.js +89 -91
  38. package/dist/tether.markets.min.js +1 -1
  39. package/dist/tether.min.js +0 -0
  40. package/dist/tether.min.js.map +4 -4
  41. package/dist/tether.search.js +60 -69
  42. package/dist/tether.search.min.js +1 -1
  43. package/dist/types/server/src/shared/account-orders.d.ts +44 -0
  44. package/dist/types/server/src/shared/account-routes.d.ts +153 -0
  45. package/dist/types/server/src/shared/api-versions.d.ts +13 -0
  46. package/dist/types/server/src/shared/cart-id.d.ts +2 -0
  47. package/dist/types/server/src/shared/error-message.d.ts +2 -0
  48. package/dist/types/server/src/shared/json.d.ts +25 -0
  49. package/dist/types/server/src/shared/market-codes.d.ts +16 -0
  50. package/dist/types/src/account/addresses-view.d.ts +5 -0
  51. package/dist/types/src/account/answers.d.ts +40 -0
  52. package/dist/types/src/account/markup.d.ts +19 -0
  53. package/dist/types/src/account/operations.d.ts +41 -0
  54. package/dist/types/src/account/order-lines.d.ts +13 -0
  55. package/dist/types/src/account/order-list.d.ts +12 -0
  56. package/dist/types/src/account/order-page.d.ts +6 -0
  57. package/dist/types/src/account/page-answers.d.ts +182 -0
  58. package/dist/types/src/account/page-events.d.ts +2 -0
  59. package/dist/types/src/account/server-client.d.ts +60 -0
  60. package/dist/types/src/account/subscriptions-view.d.ts +2 -0
  61. package/dist/types/src/account-api.d.ts +18 -0
  62. package/dist/types/src/account-marks.d.ts +15 -0
  63. package/dist/types/src/account-pages.d.ts +8 -0
  64. package/dist/types/src/account.d.ts +64 -0
  65. package/dist/types/src/amounts.d.ts +12 -0
  66. package/dist/types/src/analytics-shopify.d.ts +41 -0
  67. package/dist/types/src/analytics.d.ts +2 -0
  68. package/dist/types/src/api-version.d.ts +28 -0
  69. package/dist/types/src/astro.d.ts +42 -0
  70. package/dist/types/src/cart/cart-shape.d.ts +43 -0
  71. package/dist/types/src/cart/checkout.d.ts +16 -0
  72. package/dist/types/src/cart/drawer.d.ts +18 -0
  73. package/dist/types/src/cart/mutations.d.ts +85 -0
  74. package/dist/types/src/cart/render.d.ts +17 -0
  75. package/dist/types/src/cart/store.d.ts +185 -0
  76. package/dist/types/src/cart.d.ts +106 -0
  77. package/dist/types/src/client.d.ts +134 -0
  78. package/dist/types/src/collection.d.ts +25 -0
  79. package/dist/types/src/config-sections.d.ts +40 -0
  80. package/dist/types/src/config.d.ts +190 -0
  81. package/dist/types/src/controls/cart-controls.d.ts +2 -0
  82. package/dist/types/src/controls/discount.d.ts +2 -0
  83. package/dist/types/src/controls/extras.d.ts +5 -0
  84. package/dist/types/src/controls/navigation.d.ts +12 -0
  85. package/dist/types/src/diagnose-markup.d.ts +19 -0
  86. package/dist/types/src/diagnose.d.ts +60 -0
  87. package/dist/types/src/dom.d.ts +75 -0
  88. package/dist/types/src/extras.d.ts +21 -0
  89. package/dist/types/src/fragments.d.ts +158 -0
  90. package/dist/types/src/globals.d.ts +15 -0
  91. package/dist/types/src/images.d.ts +20 -0
  92. package/dist/types/src/index.d.ts +167 -0
  93. package/dist/types/src/initial.d.ts +56 -0
  94. package/dist/types/src/lazy.d.ts +28 -0
  95. package/dist/types/src/loader.d.ts +84 -0
  96. package/dist/types/src/market-codes.d.ts +6 -0
  97. package/dist/types/src/markets-ui.d.ts +32 -0
  98. package/dist/types/src/markets.d.ts +72 -0
  99. package/dist/types/src/markup.d.ts +131 -0
  100. package/dist/types/src/mounting.d.ts +46 -0
  101. package/dist/types/src/page-market.d.ts +27 -0
  102. package/dist/types/src/presets/barba.d.ts +56 -0
  103. package/dist/types/src/product-events.d.ts +2 -0
  104. package/dist/types/src/product-render.d.ts +17 -0
  105. package/dist/types/src/product-shape.d.ts +90 -0
  106. package/dist/types/src/product-state.d.ts +110 -0
  107. package/dist/types/src/product.d.ts +66 -0
  108. package/dist/types/src/repeaters.d.ts +16 -0
  109. package/dist/types/src/search.d.ts +33 -0
  110. package/dist/types/src/selling-plans.d.ts +64 -0
  111. package/dist/types/src/server.d.ts +88 -0
  112. package/dist/types/src/shopify-values.d.ts +46 -0
  113. package/dist/types/src/status.d.ts +33 -0
  114. package/dist/types/src/storage.d.ts +12 -0
  115. package/dist/types/src/store-html.d.ts +39 -0
  116. package/dist/types/src/storefront/catalog.d.ts +38 -0
  117. package/dist/types/src/storefront/json-ld.d.ts +20 -0
  118. package/dist/types/src/variant-render.d.ts +14 -0
  119. package/package.json +24 -24
  120. package/dist/esm/chunks/account-C3NP6HFB.js +0 -1
  121. package/dist/esm/chunks/account-pages-WLK374FO.js +0 -1
  122. package/dist/esm/chunks/analytics-G3SAWMNL.js +0 -1
  123. package/dist/esm/chunks/chunk-27PJJZGC.js +0 -1
  124. package/dist/esm/chunks/chunk-2FSXS55U.js +0 -1
  125. package/dist/esm/chunks/chunk-FCSWQDVV.js +0 -1
  126. package/dist/esm/chunks/chunk-FOMSMIAM.js +0 -1
  127. package/dist/esm/chunks/chunk-GZJTCLLW.js +0 -1
  128. package/dist/esm/chunks/chunk-HEQILZVR.js +0 -1
  129. package/dist/esm/chunks/chunk-JOOEXYF3.js +0 -4
  130. package/dist/esm/chunks/chunk-MPTQYLSM.js +0 -1
  131. package/dist/esm/chunks/chunk-NEHZ37TU.js +0 -3
  132. package/dist/esm/chunks/chunk-V74KGEJF.js +0 -1
  133. package/dist/esm/chunks/chunk-VT4CDUJJ.js +0 -1
  134. package/dist/esm/chunks/chunk-YJLWX2HK.js +0 -1
  135. package/dist/esm/chunks/diagnose-6VVGZNTY.js +0 -14
  136. package/dist/esm/chunks/extras-GJVRDFM3.js +0 -1
  137. package/dist/esm/chunks/markets-ui-UNB4PTA7.js +0 -1
  138. package/dist/esm/chunks/search-OU75RNQL.js +0 -1
  139. package/src/account/addresses-view.js +0 -92
  140. package/src/account/browser-session.js +0 -359
  141. package/src/account/markup.js +0 -48
  142. package/src/account/operations.js +0 -180
  143. package/src/account/order-lines.js +0 -96
  144. package/src/account/order-list.js +0 -91
  145. package/src/account/order-page.js +0 -192
  146. package/src/account/page-events.js +0 -288
  147. package/src/account/server-client.js +0 -172
  148. package/src/account/shared.js +0 -111
  149. package/src/account/shopify-auth.js +0 -150
  150. package/src/account/subscriptions-view.js +0 -158
  151. package/src/account-api.js +0 -118
  152. package/src/account-links.js +0 -35
  153. package/src/account-pages.js +0 -89
  154. package/src/account.js +0 -342
  155. package/src/amounts.js +0 -36
  156. package/src/analytics-shopify.js +0 -241
  157. package/src/analytics.js +0 -352
  158. package/src/api-version.js +0 -85
  159. package/src/astro.js +0 -266
  160. package/src/cart/checkout.js +0 -97
  161. package/src/cart/drawer.js +0 -138
  162. package/src/cart/mutations.js +0 -234
  163. package/src/cart/render.js +0 -294
  164. package/src/cart/store.js +0 -326
  165. package/src/cart.js +0 -391
  166. package/src/client.js +0 -267
  167. package/src/collection.js +0 -183
  168. package/src/config.js +0 -349
  169. package/src/controls/cart-controls.js +0 -155
  170. package/src/controls/discount.js +0 -96
  171. package/src/controls/extras.js +0 -63
  172. package/src/controls/navigation.js +0 -83
  173. package/src/diagnose-markup.js +0 -333
  174. package/src/diagnose.js +0 -295
  175. package/src/dom.js +0 -287
  176. package/src/extras.js +0 -145
  177. package/src/fragments.js +0 -237
  178. package/src/images.js +0 -104
  179. package/src/index.js +0 -353
  180. package/src/initial.js +0 -87
  181. package/src/lazy-iife.js +0 -116
  182. package/src/lazy.js +0 -39
  183. package/src/loader.js +0 -337
  184. package/src/market-codes.js +0 -35
  185. package/src/markets-ui.js +0 -204
  186. package/src/markets.js +0 -334
  187. package/src/markup.js +0 -64
  188. package/src/mounting.js +0 -277
  189. package/src/page-market.js +0 -116
  190. package/src/parts/account-pages.js +0 -6
  191. package/src/parts/account.js +0 -6
  192. package/src/parts/analytics.js +0 -6
  193. package/src/parts/diagnose.js +0 -6
  194. package/src/parts/extras.js +0 -6
  195. package/src/parts/markets.js +0 -6
  196. package/src/parts/search.js +0 -6
  197. package/src/presets/barba.js +0 -190
  198. package/src/product-events.js +0 -130
  199. package/src/product-render.js +0 -257
  200. package/src/product-state.js +0 -318
  201. package/src/product.js +0 -344
  202. package/src/repeaters.js +0 -173
  203. package/src/search.js +0 -323
  204. package/src/selling-plans.js +0 -154
  205. package/src/server.js +0 -215
  206. package/src/shopify-values.js +0 -89
  207. package/src/status.js +0 -126
  208. package/src/store-html.js +0 -0
  209. package/src/storefront/catalog.js +0 -199
  210. package/src/storefront/json-ld.js +0 -167
  211. package/src/variant-render.js +0 -165
  212. package/types/astro.d.ts +0 -28
  213. package/types/barba.d.ts +0 -16
  214. package/types/index.d.ts +0 -577
  215. package/types/server.d.ts +0 -182
package/types/server.d.ts DELETED
@@ -1,182 +0,0 @@
1
- import type { ShopifyProduct, ShopifyVariant, Money, TetherError, SellingPlanHelpers, TetherConfig } from './index.js';
2
- export type { ShopifyProduct, ShopifyVariant, ShopifyCart, ShopifyCartLine, Money } from './index.js';
3
-
4
- export interface StorefrontOptions extends Partial<
5
- Pick<
6
- TetherConfig,
7
- | 'apiVersion'
8
- | 'country'
9
- | 'language'
10
- | 'locale'
11
- | 'productPath'
12
- | 'maxAge'
13
- | 'lowStock'
14
- | 'defaultPurchase'
15
- | 'metafields'
16
- | 'imagesFirst'
17
- | 'variantsFirst'
18
- | 'sellingPlanGroupsFirst'
19
- | 'sellingPlansFirst'
20
- | 'retries'
21
- >
22
- > {
23
- /** your-store.myshopify.com (or pass import.meta.env with PUBLIC_SHOPIFY_DOMAIN). */
24
- domain?: string;
25
- /** Public Storefront API token (or PUBLIC_SHOPIFY_STOREFRONT_TOKEN in import.meta.env). */
26
- token?: string;
27
- /** Your site's address, e.g. https://shop.example: product URLs in jsonLd() without passing url. */
28
- siteUrl?: string;
29
- /** Products per request for allProducts() (default 25). */
30
- pageSize?: number;
31
- /** Custom fetch (tests, caching). */
32
- fetch?: typeof fetch;
33
- PUBLIC_SHOPIFY_DOMAIN?: string;
34
- PUBLIC_SHOPIFY_STOREFRONT_TOKEN?: string;
35
- /** Astro's import.meta.env carries these too; ignored. */
36
- MODE?: string;
37
- BASE_URL?: string;
38
- PROD?: boolean;
39
- DEV?: boolean;
40
- SSR?: boolean;
41
- SITE?: string;
42
- ASSETS_PREFIX?: string;
43
- }
44
-
45
- export interface ShopifyCollection {
46
- id: string;
47
- handle: string;
48
- title: string;
49
- description: string;
50
- descriptionHtml: string;
51
- image?: { url: string; altText?: string | null } | null;
52
- seo?: { title?: string | null; description?: string | null };
53
- }
54
-
55
- export interface ProductQuery {
56
- collection?: string;
57
- /** A Shopify search query; null or '' = every product (e.g. searchParams.get('q')). */
58
- query?: string | null;
59
- first?: number;
60
- after?: string | null;
61
- sortKey?: string;
62
- reverse?: boolean;
63
- filters?: unknown[];
64
- }
65
-
66
- export interface Storefront {
67
- readonly config: Required<Pick<StorefrontOptions, 'domain' | 'token'>> & StorefrontOptions;
68
- query<T = any>(query: string, variables?: Record<string, unknown>, opts?: { context?: boolean }): Promise<T>;
69
- /** By handle, numeric id, gid or product URL. null when it doesn't exist. */
70
- getProduct(handleOrId: string | number | null | undefined): Promise<ShopifyProduct | null>;
71
- getProducts(opts?: ProductQuery): Promise<{
72
- collection: ShopifyCollection | null;
73
- products: ShopifyProduct[];
74
- pageInfo: { hasNextPage: boolean; endCursor: string | null };
75
- }>;
76
- /** Every product (of a collection or a search query), page by page. For getStaticPaths(). */
77
- allProducts(opts?: Omit<ProductQuery, 'first' | 'after'>): Promise<ShopifyProduct[]>;
78
- getCollection(
79
- handle: string,
80
- opts?: Omit<ProductQuery, 'collection'>,
81
- ): Promise<
82
- | (ShopifyCollection & { products: ShopifyProduct[]; pageInfo: { hasNextPage: boolean; endCursor: string | null } })
83
- | null
84
- >;
85
- allCollections(): Promise<ShopifyCollection[]>;
86
- /** By handle, id or product (runs in parallel with getProduct when you pass the handle). */
87
- getRecommendations(
88
- product: string | number | Pick<ShopifyProduct, 'id'>,
89
- intent?: 'RELATED' | 'COMPLEMENTARY',
90
- ): Promise<ShopifyProduct[]>;
91
- /**
92
- * A <script type="application/json" data-tether-hydrate> tag: the browser script renders these
93
- * products without its own request, then refreshes prices and stock once in the background.
94
- * Astro: <Fragment set:html={shop.hydrate(product)} />
95
- */
96
- hydrate(
97
- products: ShopifyProduct | ShopifyProduct[],
98
- opts?: {
99
- /** For lists: without descriptions and variant images, about 40% smaller. */
100
- card?: boolean;
101
- /** Images a card keeps (default 2: the main one and a hover image). */
102
- images?: number;
103
- },
104
- ): string;
105
- formatMoney(money: Money | null | undefined, locale?: string): string;
106
- /** 30 -> '30%' (nl, en) / '30 %' (de, fr), the way Tether shows savings. '' for 0. */
107
- formatPercent(n: number, locale?: string): string;
108
- productUrl(handle: string, opts?: { productPath?: string; id?: string }): string;
109
- /** Shopify CDN image at a size. Use the element's max-width value, so the browser keeps the image. */
110
- imageUrl(url: string | null | undefined, size?: ImageSize): string;
111
- /**
112
- * What Tether shows first for this product (variant, price, purchase mode, tether-show conditions),
113
- * so the server renders the same and nothing flashes. Pass Astro.url.searchParams.get('variant') in SSR.
114
- */
115
- initialState(product: ShopifyProduct, opts?: InitialOptions): InitialState;
116
- initialState(product: ShopifyProduct | null | undefined, opts?: InitialOptions): InitialState | null;
117
- /** schema.org Product / ProductGroup data for search engines, as a <script type="application/ld+json"> tag. */
118
- jsonLd(product: ShopifyProduct | null, opts?: { url?: string; brand?: string }): string;
119
- jsonLdData(product: ShopifyProduct | null, opts?: { url?: string; brand?: string }): Record<string, unknown> | null;
120
- plans: SellingPlanHelpers;
121
- }
122
-
123
- export interface InitialState {
124
- variant: ShopifyVariant;
125
- /** option name -> value of that variant: is-selected on those buttons. */
126
- selected: Record<string, string>;
127
- purchase: 'one-time' | 'subscription';
128
- plan: { id: string; name: string } | null;
129
- plans: { id: string; name: string; price: Money; savings: number; selected: boolean; available: boolean }[];
130
- savings: number;
131
- /** The price Tether shows first (the plan price for products that require a subscription). */
132
- price: Money;
133
- /** Set only when on sale. */
134
- compareAtPrice: Money | null;
135
- available: boolean;
136
- /** tether-show conditions: hidden={!state.show['out-of-stock']}. */
137
- show: Record<
138
- | 'in-stock'
139
- | 'out-of-stock'
140
- | 'backorder'
141
- | 'on-sale'
142
- | 'not-on-sale'
143
- | 'has-variants'
144
- | 'single-variant'
145
- | 'low-stock'
146
- | 'subscription-available'
147
- | 'subscription-unavailable'
148
- | 'subscription-only'
149
- | 'one-time-available'
150
- | 'subscription-selected'
151
- | 'one-time-selected'
152
- | 'plenty-in-stock'
153
- | 'has-savings',
154
- boolean
155
- >;
156
- /** true for option values without an available variant: class is-unavailable. */
157
- isUnavailable(optionName: string, value: string): boolean;
158
- }
159
- export interface InitialOptions {
160
- variant?: string | null;
161
- sellingPlan?: string | null;
162
- defaultPurchase?: 'one-time' | 'subscription';
163
- }
164
- export declare function initialState(product: ShopifyProduct, opts?: InitialOptions): InitialState;
165
- export declare function initialState(
166
- product: ShopifyProduct | null | undefined,
167
- opts?: InitialOptions,
168
- ): InitialState | null;
169
-
170
- export interface ImageSize {
171
- width?: number;
172
- height?: number;
173
- crop?: 'center' | 'top' | 'bottom' | 'left' | 'right';
174
- }
175
- export declare function imageUrl(url: string | null | undefined, size?: ImageSize): string;
176
- export declare function createStorefront(options?: StorefrontOptions): Storefront;
177
- export declare function formatMoney(money: Money | null | undefined, locale?: string): string;
178
- export declare function productUrl(handle: string, opts?: { productPath?: string; id?: string }): string;
179
- export declare function productKey(raw: string | number): string | null;
180
- export declare function withContext(query: string, ctx?: { country?: string; language?: string }): string;
181
- export declare const plans: SellingPlanHelpers;
182
- export { TetherError };