@occluze/tether 0.6.8 → 0.7.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.
Files changed (259) hide show
  1. package/README.md +11 -11
  2. package/dist/esm/astro.js +2 -2
  3. package/dist/esm/chunks/account-UIPWJQ3Y.js +1 -0
  4. package/dist/esm/chunks/account-pages-6ROA6Y4V.js +1 -0
  5. package/dist/esm/chunks/analytics-2V632IRV.js +1 -0
  6. package/dist/esm/chunks/chunk-4GCXM764.js +1 -0
  7. package/dist/esm/chunks/chunk-56FCLJJD.js +1 -0
  8. package/dist/esm/chunks/chunk-5Z5O3767.js +1 -0
  9. package/dist/esm/chunks/chunk-6OZJCAGZ.js +1 -0
  10. package/dist/esm/chunks/chunk-A5SYCVQM.js +1 -0
  11. package/dist/esm/chunks/chunk-BA4LQJJQ.js +1 -0
  12. package/dist/esm/chunks/chunk-BFTZR4OB.js +4 -0
  13. package/dist/esm/chunks/chunk-C5JYQCWH.js +1 -0
  14. package/dist/esm/chunks/chunk-E5YO6274.js +1 -0
  15. package/dist/esm/chunks/chunk-MPDWM2NN.js +1 -0
  16. package/dist/esm/chunks/chunk-T44MUL4Y.js +1 -0
  17. package/dist/esm/chunks/chunk-YLUULATY.js +1 -0
  18. package/dist/esm/chunks/diagnose-3FEKRIEK.js +14 -0
  19. package/dist/esm/chunks/extras-6POFBNOP.js +1 -0
  20. package/dist/esm/chunks/markets-ui-FD6NI2OG.js +1 -0
  21. package/dist/esm/chunks/search-UJ73YBQ5.js +1 -0
  22. package/dist/esm/index.js +1 -1
  23. package/dist/esm/server.js +2 -2
  24. package/dist/presets/barba.esm.js +19 -23
  25. package/dist/tether.account-pages.js +320 -365
  26. package/dist/tether.account-pages.min.js +1 -1
  27. package/dist/tether.account.js +242 -491
  28. package/dist/tether.account.min.js +1 -1
  29. package/dist/tether.analytics.js +66 -88
  30. package/dist/tether.analytics.min.js +1 -1
  31. package/dist/tether.diagnose.js +36 -33
  32. package/dist/tether.diagnose.min.js +2 -2
  33. package/dist/tether.extras.js +28 -36
  34. package/dist/tether.extras.min.js +1 -1
  35. package/dist/tether.js +1270 -894
  36. package/dist/tether.markets.js +73 -90
  37. package/dist/tether.markets.min.js +1 -1
  38. package/dist/tether.min.js +0 -0
  39. package/dist/tether.min.js.map +4 -4
  40. package/dist/tether.search.js +44 -68
  41. package/dist/tether.search.min.js +1 -1
  42. package/dist/types/server/src/shared/account-orders.d.ts +44 -0
  43. package/dist/types/server/src/shared/account-routes.d.ts +153 -0
  44. package/dist/types/server/src/shared/api-versions.d.ts +13 -0
  45. package/dist/types/server/src/shared/error-message.d.ts +2 -0
  46. package/dist/types/server/src/shared/json.d.ts +25 -0
  47. package/dist/types/server/src/shared/market-codes.d.ts +16 -0
  48. package/dist/types/src/account/addresses-view.d.ts +5 -0
  49. package/dist/types/src/account/answers.d.ts +40 -0
  50. package/dist/types/src/account/markup.d.ts +19 -0
  51. package/dist/types/src/account/operations.d.ts +41 -0
  52. package/dist/types/src/account/order-lines.d.ts +13 -0
  53. package/dist/types/src/account/order-list.d.ts +12 -0
  54. package/dist/types/src/account/order-page.d.ts +6 -0
  55. package/dist/types/src/account/page-answers.d.ts +182 -0
  56. package/dist/types/src/account/page-events.d.ts +2 -0
  57. package/dist/types/src/account/server-client.d.ts +60 -0
  58. package/dist/types/src/account/subscriptions-view.d.ts +2 -0
  59. package/dist/types/src/account-api.d.ts +18 -0
  60. package/dist/types/src/account-marks.d.ts +15 -0
  61. package/dist/types/src/account-pages.d.ts +8 -0
  62. package/dist/types/src/account.d.ts +64 -0
  63. package/dist/types/src/amounts.d.ts +12 -0
  64. package/dist/types/src/analytics-shopify.d.ts +41 -0
  65. package/dist/types/src/analytics.d.ts +2 -0
  66. package/dist/types/src/api-version.d.ts +28 -0
  67. package/dist/types/src/astro.d.ts +42 -0
  68. package/dist/types/src/cart/cart-shape.d.ts +43 -0
  69. package/dist/types/src/cart/checkout.d.ts +16 -0
  70. package/dist/types/src/cart/drawer.d.ts +18 -0
  71. package/dist/types/src/cart/mutations.d.ts +79 -0
  72. package/dist/types/src/cart/render.d.ts +17 -0
  73. package/dist/types/src/cart/store.d.ts +182 -0
  74. package/dist/types/src/cart.d.ts +106 -0
  75. package/dist/types/src/client.d.ts +100 -0
  76. package/dist/types/src/collection.d.ts +25 -0
  77. package/dist/types/src/config-sections.d.ts +40 -0
  78. package/dist/types/src/config.d.ts +185 -0
  79. package/dist/types/src/controls/cart-controls.d.ts +2 -0
  80. package/dist/types/src/controls/discount.d.ts +2 -0
  81. package/dist/types/src/controls/extras.d.ts +5 -0
  82. package/dist/types/src/controls/navigation.d.ts +12 -0
  83. package/dist/types/src/diagnose-markup.d.ts +19 -0
  84. package/dist/types/src/diagnose.d.ts +60 -0
  85. package/dist/types/src/dom.d.ts +75 -0
  86. package/dist/types/src/extras.d.ts +21 -0
  87. package/dist/types/src/fragments.d.ts +158 -0
  88. package/dist/types/src/globals.d.ts +15 -0
  89. package/dist/types/src/images.d.ts +20 -0
  90. package/dist/types/src/index.d.ts +167 -0
  91. package/dist/types/src/initial.d.ts +56 -0
  92. package/dist/types/src/lazy.d.ts +28 -0
  93. package/dist/types/src/loader.d.ts +84 -0
  94. package/dist/types/src/market-codes.d.ts +6 -0
  95. package/dist/types/src/markets-ui.d.ts +32 -0
  96. package/dist/types/src/markets.d.ts +72 -0
  97. package/dist/types/src/markup.d.ts +131 -0
  98. package/dist/types/src/mounting.d.ts +46 -0
  99. package/dist/types/src/page-market.d.ts +27 -0
  100. package/dist/types/src/presets/barba.d.ts +56 -0
  101. package/dist/types/src/product-events.d.ts +2 -0
  102. package/dist/types/src/product-render.d.ts +17 -0
  103. package/dist/types/src/product-shape.d.ts +88 -0
  104. package/dist/types/src/product-state.d.ts +110 -0
  105. package/dist/types/src/product.d.ts +66 -0
  106. package/dist/types/src/repeaters.d.ts +16 -0
  107. package/dist/types/src/search.d.ts +33 -0
  108. package/dist/types/src/selling-plans.d.ts +64 -0
  109. package/dist/types/src/server.d.ts +88 -0
  110. package/dist/types/src/shopify-values.d.ts +46 -0
  111. package/dist/types/src/status.d.ts +33 -0
  112. package/dist/types/src/storage.d.ts +12 -0
  113. package/dist/types/src/store-html.d.ts +39 -0
  114. package/dist/types/src/storefront/catalog.d.ts +38 -0
  115. package/dist/types/src/storefront/json-ld.d.ts +20 -0
  116. package/dist/types/src/variant-render.d.ts +14 -0
  117. package/package.json +24 -23
  118. package/src/account/addresses-view.ts +58 -0
  119. package/src/account/answers.ts +79 -0
  120. package/src/account/markup.ts +36 -0
  121. package/src/account/operations.ts +145 -0
  122. package/src/account/{order-lines.js → order-lines.ts} +20 -41
  123. package/src/account/order-list.ts +107 -0
  124. package/src/account/order-page.ts +137 -0
  125. package/src/account/page-answers.ts +317 -0
  126. package/src/account/{page-events.js → page-events.ts} +55 -90
  127. package/src/account/server-client.ts +183 -0
  128. package/src/account/{subscriptions-view.js → subscriptions-view.ts} +25 -68
  129. package/src/account-api.ts +98 -0
  130. package/src/account-marks.ts +35 -0
  131. package/src/{account-pages.js → account-pages.ts} +29 -37
  132. package/src/account.ts +284 -0
  133. package/src/amounts.ts +64 -0
  134. package/src/{analytics-shopify.js → analytics-shopify.ts} +112 -107
  135. package/src/analytics.ts +315 -0
  136. package/src/{api-version.js → api-version.ts} +25 -31
  137. package/src/{astro.js → astro.ts} +110 -104
  138. package/src/cart/cart-shape.ts +25 -0
  139. package/src/cart/checkout.ts +101 -0
  140. package/src/cart/{drawer.js → drawer.ts} +18 -31
  141. package/src/cart/mutations.ts +237 -0
  142. package/src/cart/{render.js → render.ts} +68 -96
  143. package/src/cart/store.ts +279 -0
  144. package/src/{cart.js → cart.ts} +82 -128
  145. package/src/client.ts +391 -0
  146. package/src/{collection.js → collection.ts} +30 -38
  147. package/src/config-sections.ts +284 -0
  148. package/src/config.ts +480 -0
  149. package/src/controls/{cart-controls.js → cart-controls.ts} +22 -54
  150. package/src/controls/{discount.js → discount.ts} +13 -34
  151. package/src/controls/{extras.js → extras.ts} +15 -24
  152. package/src/controls/{navigation.js → navigation.ts} +24 -30
  153. package/src/{diagnose-markup.js → diagnose-markup.ts} +37 -72
  154. package/src/{diagnose.js → diagnose.ts} +95 -96
  155. package/src/dom.ts +268 -0
  156. package/src/{extras.js → extras.ts} +43 -52
  157. package/src/fragments.ts +261 -0
  158. package/src/globals.d.ts +15 -0
  159. package/src/{images.js → images.ts} +30 -43
  160. package/src/index.ts +415 -0
  161. package/src/initial.ts +101 -0
  162. package/src/lazy-iife.ts +197 -0
  163. package/src/lazy.ts +42 -0
  164. package/src/{loader.js → loader.ts} +149 -123
  165. package/src/market-codes.ts +6 -0
  166. package/src/{markets-ui.js → markets-ui.ts} +91 -68
  167. package/src/markets.ts +246 -0
  168. package/src/markup.ts +127 -0
  169. package/src/{mounting.js → mounting.ts} +88 -101
  170. package/src/{page-market.js → page-market.ts} +32 -38
  171. package/src/part-integrity.ts +7 -0
  172. package/src/parts/account-pages.ts +7 -0
  173. package/src/parts/account.ts +7 -0
  174. package/src/parts/analytics.ts +7 -0
  175. package/src/parts/diagnose.ts +7 -0
  176. package/src/parts/extras.ts +7 -0
  177. package/src/parts/markets.ts +7 -0
  178. package/src/parts/search.ts +7 -0
  179. package/src/presets/barba.ts +194 -0
  180. package/src/{product-events.js → product-events.ts} +33 -48
  181. package/src/{product-render.js → product-render.ts} +38 -77
  182. package/src/product-shape.ts +49 -0
  183. package/src/product-state.ts +318 -0
  184. package/src/{product.js → product.ts} +90 -126
  185. package/src/{repeaters.js → repeaters.ts} +40 -52
  186. package/src/{search.js → search.ts} +85 -103
  187. package/src/selling-plans.ts +145 -0
  188. package/src/server.ts +211 -0
  189. package/src/{shopify-values.js → shopify-values.ts} +24 -22
  190. package/src/{status.js → status.ts} +34 -54
  191. package/src/storage.ts +34 -0
  192. package/src/store-html.ts +359 -0
  193. package/src/storefront/catalog.ts +196 -0
  194. package/src/storefront/{json-ld.js → json-ld.ts} +45 -68
  195. package/src/{variant-render.js → variant-render.ts} +24 -50
  196. package/dist/esm/chunks/account-C3NP6HFB.js +0 -1
  197. package/dist/esm/chunks/account-pages-WLK374FO.js +0 -1
  198. package/dist/esm/chunks/analytics-G3SAWMNL.js +0 -1
  199. package/dist/esm/chunks/chunk-27PJJZGC.js +0 -1
  200. package/dist/esm/chunks/chunk-2FSXS55U.js +0 -1
  201. package/dist/esm/chunks/chunk-FCSWQDVV.js +0 -1
  202. package/dist/esm/chunks/chunk-FOMSMIAM.js +0 -1
  203. package/dist/esm/chunks/chunk-GZJTCLLW.js +0 -1
  204. package/dist/esm/chunks/chunk-HEQILZVR.js +0 -1
  205. package/dist/esm/chunks/chunk-JOOEXYF3.js +0 -4
  206. package/dist/esm/chunks/chunk-MPTQYLSM.js +0 -1
  207. package/dist/esm/chunks/chunk-NEHZ37TU.js +0 -3
  208. package/dist/esm/chunks/chunk-V74KGEJF.js +0 -1
  209. package/dist/esm/chunks/chunk-VT4CDUJJ.js +0 -1
  210. package/dist/esm/chunks/chunk-YJLWX2HK.js +0 -1
  211. package/dist/esm/chunks/diagnose-6VVGZNTY.js +0 -14
  212. package/dist/esm/chunks/extras-GJVRDFM3.js +0 -1
  213. package/dist/esm/chunks/markets-ui-UNB4PTA7.js +0 -1
  214. package/dist/esm/chunks/search-OU75RNQL.js +0 -1
  215. package/src/account/addresses-view.js +0 -92
  216. package/src/account/browser-session.js +0 -359
  217. package/src/account/markup.js +0 -48
  218. package/src/account/operations.js +0 -180
  219. package/src/account/order-list.js +0 -91
  220. package/src/account/order-page.js +0 -192
  221. package/src/account/server-client.js +0 -172
  222. package/src/account/shared.js +0 -111
  223. package/src/account/shopify-auth.js +0 -150
  224. package/src/account-api.js +0 -118
  225. package/src/account-links.js +0 -35
  226. package/src/account.js +0 -342
  227. package/src/amounts.js +0 -36
  228. package/src/analytics.js +0 -352
  229. package/src/cart/checkout.js +0 -97
  230. package/src/cart/mutations.js +0 -234
  231. package/src/cart/store.js +0 -326
  232. package/src/client.js +0 -267
  233. package/src/config.js +0 -349
  234. package/src/dom.js +0 -287
  235. package/src/fragments.js +0 -237
  236. package/src/index.js +0 -353
  237. package/src/initial.js +0 -87
  238. package/src/lazy-iife.js +0 -116
  239. package/src/lazy.js +0 -39
  240. package/src/market-codes.js +0 -35
  241. package/src/markets.js +0 -334
  242. package/src/markup.js +0 -64
  243. package/src/parts/account-pages.js +0 -6
  244. package/src/parts/account.js +0 -6
  245. package/src/parts/analytics.js +0 -6
  246. package/src/parts/diagnose.js +0 -6
  247. package/src/parts/extras.js +0 -6
  248. package/src/parts/markets.js +0 -6
  249. package/src/parts/search.js +0 -6
  250. package/src/presets/barba.js +0 -190
  251. package/src/product-state.js +0 -318
  252. package/src/selling-plans.js +0 -154
  253. package/src/server.js +0 -215
  254. package/src/store-html.js +0 -0
  255. package/src/storefront/catalog.js +0 -199
  256. package/types/astro.d.ts +0 -28
  257. package/types/barba.d.ts +0 -16
  258. package/types/index.d.ts +0 -577
  259. 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 };