@shopify/hydrogen-react 0.0.0-next-de1d160 → 0.0.0-next-72f8a5c

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 (187) hide show
  1. package/dist/dev/CartProvider.cjs +20 -20
  2. package/dist/dev/CartProvider.cjs.map +1 -1
  3. package/dist/dev/Metafield.cjs +2 -2
  4. package/dist/dev/Metafield.cjs.map +1 -1
  5. package/dist/dev/ModelViewer.cjs +4 -4
  6. package/dist/dev/ModelViewer.cjs.map +1 -1
  7. package/dist/dev/ProductProvider.cjs +14 -14
  8. package/dist/dev/ProductProvider.cjs.map +1 -1
  9. package/dist/dev/ShopifyProvider.cjs +4 -4
  10. package/dist/dev/ShopifyProvider.cjs.map +1 -1
  11. package/dist/dev/Video.cjs +2 -2
  12. package/dist/dev/cart-hooks.cjs +4 -4
  13. package/dist/dev/cart-hooks.cjs.map +1 -1
  14. package/dist/dev/cart-hooks.js +3 -3
  15. package/dist/dev/cart-hooks.js.map +1 -1
  16. package/dist/dev/load-script.cjs +3 -3
  17. package/dist/dev/load-script.cjs.map +1 -1
  18. package/dist/dev/useCartAPIStateMachine.cjs +12 -12
  19. package/dist/dev/useCartAPIStateMachine.cjs.map +1 -1
  20. package/dist/dev/useCartAPIStateMachine.js +8 -8
  21. package/dist/dev/useCartAPIStateMachine.js.map +1 -1
  22. package/dist/dev/useCartActions.cjs +11 -11
  23. package/dist/dev/useCartActions.cjs.map +1 -1
  24. package/dist/dev/useMoney.cjs +5 -5
  25. package/dist/dev/useMoney.cjs.map +1 -1
  26. package/dist/prod/CartProvider.cjs +20 -20
  27. package/dist/prod/CartProvider.cjs.map +1 -1
  28. package/dist/prod/Metafield.cjs +2 -2
  29. package/dist/prod/Metafield.cjs.map +1 -1
  30. package/dist/prod/ModelViewer.cjs +4 -4
  31. package/dist/prod/ModelViewer.cjs.map +1 -1
  32. package/dist/prod/ProductProvider.cjs +14 -14
  33. package/dist/prod/ProductProvider.cjs.map +1 -1
  34. package/dist/prod/ShopifyProvider.cjs +4 -4
  35. package/dist/prod/ShopifyProvider.cjs.map +1 -1
  36. package/dist/prod/Video.cjs +2 -2
  37. package/dist/prod/cart-hooks.cjs +4 -4
  38. package/dist/prod/cart-hooks.cjs.map +1 -1
  39. package/dist/prod/cart-hooks.js +3 -3
  40. package/dist/prod/cart-hooks.js.map +1 -1
  41. package/dist/prod/load-script.cjs +3 -3
  42. package/dist/prod/load-script.cjs.map +1 -1
  43. package/dist/prod/useCartAPIStateMachine.cjs +12 -12
  44. package/dist/prod/useCartAPIStateMachine.cjs.map +1 -1
  45. package/dist/prod/useCartAPIStateMachine.js +8 -8
  46. package/dist/prod/useCartAPIStateMachine.js.map +1 -1
  47. package/dist/prod/useCartActions.cjs +11 -11
  48. package/dist/prod/useCartActions.cjs.map +1 -1
  49. package/dist/prod/useMoney.cjs +5 -5
  50. package/dist/prod/useMoney.cjs.map +1 -1
  51. package/package.json +1 -1
  52. package/dist/dev/_virtual/index.cjs +0 -5
  53. package/dist/dev/_virtual/index.cjs.map +0 -1
  54. package/dist/dev/_virtual/index.js +0 -5
  55. package/dist/dev/_virtual/index.js.map +0 -1
  56. package/dist/dev/_virtual/use-sync-external-store-shim.development.cjs +0 -5
  57. package/dist/dev/_virtual/use-sync-external-store-shim.development.cjs.map +0 -1
  58. package/dist/dev/_virtual/use-sync-external-store-shim.development.js +0 -5
  59. package/dist/dev/_virtual/use-sync-external-store-shim.development.js.map +0 -1
  60. package/dist/dev/_virtual/use-sync-external-store-shim.production.min.cjs +0 -5
  61. package/dist/dev/_virtual/use-sync-external-store-shim.production.min.cjs.map +0 -1
  62. package/dist/dev/_virtual/use-sync-external-store-shim.production.min.js +0 -5
  63. package/dist/dev/_virtual/use-sync-external-store-shim.production.min.js.map +0 -1
  64. package/dist/dev/_virtual/with-selector.cjs +0 -5
  65. package/dist/dev/_virtual/with-selector.cjs.map +0 -1
  66. package/dist/dev/_virtual/with-selector.development.cjs +0 -5
  67. package/dist/dev/_virtual/with-selector.development.cjs.map +0 -1
  68. package/dist/dev/_virtual/with-selector.development.js +0 -5
  69. package/dist/dev/_virtual/with-selector.development.js.map +0 -1
  70. package/dist/dev/_virtual/with-selector.js +0 -5
  71. package/dist/dev/_virtual/with-selector.js.map +0 -1
  72. package/dist/dev/_virtual/with-selector.production.min.cjs +0 -5
  73. package/dist/dev/_virtual/with-selector.production.min.cjs.map +0 -1
  74. package/dist/dev/_virtual/with-selector.production.min.js +0 -5
  75. package/dist/dev/_virtual/with-selector.production.min.js.map +0 -1
  76. package/dist/dev/node_modules/@xstate/fsm/es/index.cjs +0 -158
  77. package/dist/dev/node_modules/@xstate/fsm/es/index.cjs.map +0 -1
  78. package/dist/dev/node_modules/@xstate/fsm/es/index.js +0 -159
  79. package/dist/dev/node_modules/@xstate/fsm/es/index.js.map +0 -1
  80. package/dist/dev/node_modules/@xstate/react/es/fsm.cjs +0 -94
  81. package/dist/dev/node_modules/@xstate/react/es/fsm.cjs.map +0 -1
  82. package/dist/dev/node_modules/@xstate/react/es/fsm.js +0 -94
  83. package/dist/dev/node_modules/@xstate/react/es/fsm.js.map +0 -1
  84. package/dist/dev/node_modules/@xstate/react/es/useConstant.cjs +0 -30
  85. package/dist/dev/node_modules/@xstate/react/es/useConstant.cjs.map +0 -1
  86. package/dist/dev/node_modules/@xstate/react/es/useConstant.js +0 -12
  87. package/dist/dev/node_modules/@xstate/react/es/useConstant.js.map +0 -1
  88. package/dist/dev/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.cjs +0 -5
  89. package/dist/dev/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.cjs.map +0 -1
  90. package/dist/dev/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.js +0 -6
  91. package/dist/dev/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.js.map +0 -1
  92. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.cjs +0 -107
  93. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.cjs.map +0 -1
  94. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +0 -105
  95. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js.map +0 -1
  96. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.cjs +0 -74
  97. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.cjs.map +0 -1
  98. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js +0 -72
  99. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js.map +0 -1
  100. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.cjs +0 -138
  101. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.cjs.map +0 -1
  102. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +0 -136
  103. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js.map +0 -1
  104. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.cjs +0 -60
  105. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.cjs.map +0 -1
  106. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js +0 -58
  107. package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js.map +0 -1
  108. package/dist/dev/node_modules/use-sync-external-store/shim/index.cjs +0 -21
  109. package/dist/dev/node_modules/use-sync-external-store/shim/index.cjs.map +0 -1
  110. package/dist/dev/node_modules/use-sync-external-store/shim/index.js +0 -21
  111. package/dist/dev/node_modules/use-sync-external-store/shim/index.js.map +0 -1
  112. package/dist/dev/node_modules/use-sync-external-store/shim/with-selector.cjs +0 -12
  113. package/dist/dev/node_modules/use-sync-external-store/shim/with-selector.cjs.map +0 -1
  114. package/dist/dev/node_modules/use-sync-external-store/shim/with-selector.js +0 -11
  115. package/dist/dev/node_modules/use-sync-external-store/shim/with-selector.js.map +0 -1
  116. package/dist/dev/node_modules/worktop/cookie/index.cjs +0 -27
  117. package/dist/dev/node_modules/worktop/cookie/index.cjs.map +0 -1
  118. package/dist/dev/node_modules/worktop/cookie/index.js +0 -27
  119. package/dist/dev/node_modules/worktop/cookie/index.js.map +0 -1
  120. package/dist/prod/_virtual/index.cjs +0 -5
  121. package/dist/prod/_virtual/index.cjs.map +0 -1
  122. package/dist/prod/_virtual/index.js +0 -5
  123. package/dist/prod/_virtual/index.js.map +0 -1
  124. package/dist/prod/_virtual/use-sync-external-store-shim.development.cjs +0 -5
  125. package/dist/prod/_virtual/use-sync-external-store-shim.development.cjs.map +0 -1
  126. package/dist/prod/_virtual/use-sync-external-store-shim.development.js +0 -5
  127. package/dist/prod/_virtual/use-sync-external-store-shim.development.js.map +0 -1
  128. package/dist/prod/_virtual/use-sync-external-store-shim.production.min.cjs +0 -5
  129. package/dist/prod/_virtual/use-sync-external-store-shim.production.min.cjs.map +0 -1
  130. package/dist/prod/_virtual/use-sync-external-store-shim.production.min.js +0 -5
  131. package/dist/prod/_virtual/use-sync-external-store-shim.production.min.js.map +0 -1
  132. package/dist/prod/_virtual/with-selector.cjs +0 -5
  133. package/dist/prod/_virtual/with-selector.cjs.map +0 -1
  134. package/dist/prod/_virtual/with-selector.development.cjs +0 -5
  135. package/dist/prod/_virtual/with-selector.development.cjs.map +0 -1
  136. package/dist/prod/_virtual/with-selector.development.js +0 -5
  137. package/dist/prod/_virtual/with-selector.development.js.map +0 -1
  138. package/dist/prod/_virtual/with-selector.js +0 -5
  139. package/dist/prod/_virtual/with-selector.js.map +0 -1
  140. package/dist/prod/_virtual/with-selector.production.min.cjs +0 -5
  141. package/dist/prod/_virtual/with-selector.production.min.cjs.map +0 -1
  142. package/dist/prod/_virtual/with-selector.production.min.js +0 -5
  143. package/dist/prod/_virtual/with-selector.production.min.js.map +0 -1
  144. package/dist/prod/node_modules/@xstate/fsm/es/index.cjs +0 -158
  145. package/dist/prod/node_modules/@xstate/fsm/es/index.cjs.map +0 -1
  146. package/dist/prod/node_modules/@xstate/fsm/es/index.js +0 -159
  147. package/dist/prod/node_modules/@xstate/fsm/es/index.js.map +0 -1
  148. package/dist/prod/node_modules/@xstate/react/es/fsm.cjs +0 -94
  149. package/dist/prod/node_modules/@xstate/react/es/fsm.cjs.map +0 -1
  150. package/dist/prod/node_modules/@xstate/react/es/fsm.js +0 -94
  151. package/dist/prod/node_modules/@xstate/react/es/fsm.js.map +0 -1
  152. package/dist/prod/node_modules/@xstate/react/es/useConstant.cjs +0 -30
  153. package/dist/prod/node_modules/@xstate/react/es/useConstant.cjs.map +0 -1
  154. package/dist/prod/node_modules/@xstate/react/es/useConstant.js +0 -12
  155. package/dist/prod/node_modules/@xstate/react/es/useConstant.js.map +0 -1
  156. package/dist/prod/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.cjs +0 -5
  157. package/dist/prod/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.cjs.map +0 -1
  158. package/dist/prod/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.js +0 -6
  159. package/dist/prod/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.js.map +0 -1
  160. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.cjs +0 -107
  161. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.cjs.map +0 -1
  162. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +0 -105
  163. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js.map +0 -1
  164. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.cjs +0 -74
  165. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.cjs.map +0 -1
  166. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js +0 -72
  167. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js.map +0 -1
  168. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.cjs +0 -138
  169. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.cjs.map +0 -1
  170. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +0 -136
  171. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js.map +0 -1
  172. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.cjs +0 -60
  173. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.cjs.map +0 -1
  174. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js +0 -58
  175. package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js.map +0 -1
  176. package/dist/prod/node_modules/use-sync-external-store/shim/index.cjs +0 -21
  177. package/dist/prod/node_modules/use-sync-external-store/shim/index.cjs.map +0 -1
  178. package/dist/prod/node_modules/use-sync-external-store/shim/index.js +0 -21
  179. package/dist/prod/node_modules/use-sync-external-store/shim/index.js.map +0 -1
  180. package/dist/prod/node_modules/use-sync-external-store/shim/with-selector.cjs +0 -12
  181. package/dist/prod/node_modules/use-sync-external-store/shim/with-selector.cjs.map +0 -1
  182. package/dist/prod/node_modules/use-sync-external-store/shim/with-selector.js +0 -11
  183. package/dist/prod/node_modules/use-sync-external-store/shim/with-selector.js.map +0 -1
  184. package/dist/prod/node_modules/worktop/cookie/index.cjs +0 -27
  185. package/dist/prod/node_modules/worktop/cookie/index.cjs.map +0 -1
  186. package/dist/prod/node_modules/worktop/cookie/index.js +0 -27
  187. package/dist/prod/node_modules/worktop/cookie/index.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"useMoney.cjs","sources":["../../src/useMoney.tsx"],"sourcesContent":["import {useMemo} from 'react';\nimport {useShop} from './ShopifyProvider.js';\nimport {CurrencyCode, MoneyV2} from './storefront-api-types.js';\n\nexport type UseMoneyValue = {\n /**\n * The currency code from the `MoneyV2` object.\n */\n currencyCode: CurrencyCode;\n /**\n * The name for the currency code, returned by `Intl.NumberFormat`.\n */\n currencyName?: string;\n /**\n * The currency symbol returned by `Intl.NumberFormat`.\n */\n currencySymbol?: string;\n /**\n * The currency narrow symbol returned by `Intl.NumberFormat`.\n */\n currencyNarrowSymbol?: string;\n /**\n * The localized amount, without any currency symbols or non-number types from the `Intl.NumberFormat.formatToParts` parts.\n */\n amount: string;\n /**\n * All parts returned by `Intl.NumberFormat.formatToParts`.\n */\n parts: Intl.NumberFormatPart[];\n /**\n * A string returned by `new Intl.NumberFormat` for the amount and currency code,\n * using the `locale` value in the [`LocalizationProvider` component](https://shopify.dev/api/hydrogen/components/localization/localizationprovider).\n */\n localizedString: string;\n /**\n * The `MoneyV2` object provided as an argument to the hook.\n */\n original: MoneyV2;\n /**\n * A string with trailing zeros removed from the fractional part, if any exist. If there are no trailing zeros, then the fractional part remains.\n * For example, `$640.00` turns into `$640`.\n * `$640.42` remains `$640.42`.\n */\n withoutTrailingZeros: string;\n /**\n * A string without currency and without trailing zeros removed from the fractional part, if any exist. If there are no trailing zeros, then the fractional part remains.\n * For example, `$640.00` turns into `640`.\n * `$640.42` turns into `640.42`.\n */\n withoutTrailingZerosAndCurrency: string;\n};\n\n/**\n * The `useMoney` hook takes a [MoneyV2 object](https://shopify.dev/api/storefront/reference/common-objects/moneyv2) and returns a\n * default-formatted string of the amount with the correct currency indicator, along with some of the parts provided by\n * [Intl.NumberFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat).\n * Uses `locale` from `ShopifyProvider`\n */\nexport function useMoney(money: MoneyV2): UseMoneyValue {\n const {locale} = useShop();\n\n if (!locale) {\n throw new Error(\n `useMoney(): Unable to get 'locale' from 'useShop()', which means that 'locale' was not passed to '<ShopifyProvider/>'. 'locale' is required for 'useMoney()' to work`\n );\n }\n\n const amount = parseFloat(money.amount);\n\n const options = useMemo(\n () => ({\n style: 'currency',\n currency: money.currencyCode,\n }),\n [money.currencyCode]\n );\n\n const defaultFormatter = useLazyFormatter(locale, options);\n\n const nameFormatter = useLazyFormatter(locale, {\n ...options,\n currencyDisplay: 'name',\n });\n\n const narrowSymbolFormatter = useLazyFormatter(locale, {\n ...options,\n currencyDisplay: 'narrowSymbol',\n });\n\n const withoutTrailingZerosFormatter = useLazyFormatter(locale, {\n ...options,\n minimumFractionDigits: 0,\n maximumFractionDigits: 0,\n });\n\n const withoutCurrencyFormatter = useLazyFormatter(locale);\n\n const withoutTrailingZerosOrCurrencyFormatter = useLazyFormatter(locale, {\n minimumFractionDigits: 0,\n maximumFractionDigits: 0,\n });\n\n const isPartCurrency = (part: Intl.NumberFormatPart) =>\n part.type === 'currency';\n\n // By wrapping these properties in functions, we only\n // create formatters if they are going to be used.\n const lazyFormatters = useMemo(\n () => ({\n original: () => money,\n currencyCode: () => money.currencyCode,\n\n localizedString: () => defaultFormatter().format(amount),\n\n parts: () => defaultFormatter().formatToParts(amount),\n\n withoutTrailingZeros: () =>\n amount % 1 === 0\n ? withoutTrailingZerosFormatter().format(amount)\n : defaultFormatter().format(amount),\n\n withoutTrailingZerosAndCurrency: () =>\n amount % 1 === 0\n ? withoutTrailingZerosOrCurrencyFormatter().format(amount)\n : withoutCurrencyFormatter().format(amount),\n\n currencyName: () =>\n nameFormatter().formatToParts(amount).find(isPartCurrency)?.value ??\n money.currencyCode, // e.g. \"US dollars\"\n\n currencySymbol: () =>\n defaultFormatter().formatToParts(amount).find(isPartCurrency)?.value ??\n money.currencyCode, // e.g. \"USD\"\n\n currencyNarrowSymbol: () =>\n narrowSymbolFormatter().formatToParts(amount).find(isPartCurrency)\n ?.value ?? '', // e.g. \"$\"\n\n amount: () =>\n defaultFormatter()\n .formatToParts(amount)\n .filter((part) =>\n ['decimal', 'fraction', 'group', 'integer', 'literal'].includes(\n part.type\n )\n )\n .map((part) => part.value)\n .join(''),\n }),\n [\n money,\n amount,\n nameFormatter,\n defaultFormatter,\n narrowSymbolFormatter,\n withoutCurrencyFormatter,\n withoutTrailingZerosFormatter,\n withoutTrailingZerosOrCurrencyFormatter,\n ]\n );\n\n // Call functions automatically when the properties are accessed\n // to keep these functions as an implementation detail.\n return useMemo(\n () =>\n new Proxy(lazyFormatters as unknown as UseMoneyValue, {\n get: (target, key) => Reflect.get(target, key)?.call(null),\n }),\n [lazyFormatters]\n );\n}\n\nfunction useLazyFormatter(locale: string, options?: Intl.NumberFormatOptions) {\n return useMemo(() => {\n let memoized: Intl.NumberFormat;\n return () => (memoized ??= new Intl.NumberFormat(locale, options));\n }, [locale, options]);\n}\n"],"names":["useMoney","money","locale","useShop","Error","amount","parseFloat","options","useMemo","style","currency","currencyCode","defaultFormatter","useLazyFormatter","nameFormatter","currencyDisplay","narrowSymbolFormatter","withoutTrailingZerosFormatter","minimumFractionDigits","maximumFractionDigits","withoutCurrencyFormatter","withoutTrailingZerosOrCurrencyFormatter","isPartCurrency","part","type","lazyFormatters","original","localizedString","format","parts","formatToParts","withoutTrailingZeros","withoutTrailingZerosAndCurrency","currencyName","find","value","currencySymbol","currencyNarrowSymbol","filter","includes","map","join","Proxy","get","target","key","Reflect","call","memoized","Intl","NumberFormat"],"mappings":";;;;AA0DO,SAASA,SAASC,OAA+B;AAChD,QAAA;AAAA,IAACC;AAAAA,MAAUC,gBAAjB,QAAA;AAEA,MAAI,CAACD,QAAQ;AACL,UAAA,IAAIE,MACP,sKADG;AAAA,EAGP;AAEKC,QAAAA,SAASC,WAAWL,MAAMI,M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sC6B,KAAKZ,cAA3C,MAAAR,mBAA4DqB,UAA5DrB,YACAb,MAAMU;AAAAA;AAAAA,IAERyB,gBAAgB,MACdxB;;AAAAA,4CAAmBkB,cAAczB,MAAjC,EAAyC6B,KAAKZ,cAA9C,MAAAV,mBAA+DuB,UAA/DvB,YACAX,MAAMU;AAAAA;AAAAA,IAER0B,sBAAsB,MAAA;;AACpBrB,+CAAwBc,EAAAA,cAAczB,MAAtC,EAA8C6B,KAAKZ,cAAnD,MAAAN,mBACImB,UADJnB,YACa;AAAA;AAAA,IAEfX,QAAQ,MACNO,mBACGkB,cAAczB,MADjB,EAEGiC,OAAQf,CAAAA,SACP,CAAC,WAAW,YAAY,SAAS,WAAW,SAA5C,EAAuDgB,SACrDhB,KAAKC,IADP,CAHJ,EAOGgB,IAAKjB,CAAAA,SAASA,KAAKY,KAPtB,EAQGM,KAAK,EARR;AAAA,EA/BG,IAyCP,CACExC,OACAI,QACAS,eACAF,kBACAI,uBACAI,0BACAH,+BACAI,uCARF,CA1C4B;AAwD9B,SAAOb,mBACL,MACE,IAAIkC,MAAMjB,gBAA4C;AAAA,IACpDkB,KAAK,CAACC,QAAQC;;AAAQC,2BAAQH,IAAIC,QAAQC,GAApB,MAAAC,mBAA0BC,KAAK;AAAA;AAAA,EAA/B,CADxB,GAGF,CAACtB,cAAD,CALY;AAOf;AAED,SAASZ,iBAAiBX,QAAgBK,SAAoC;AAC5E,SAAOC,mBAAQ,MAAM;AACfwC,QAAAA;AACJ,WAAO,MAAOA,yCAAa,IAAIC,KAAKC,aAAahD,QAAQK,OAA9B;AAAA,EAAA,GAC1B,CAACL,QAAQK,OAAT,CAHW;AAIf;;"}
1
+ {"version":3,"file":"useMoney.cjs","sources":["../../src/useMoney.tsx"],"sourcesContent":["import {useMemo} from 'react';\nimport {useShop} from './ShopifyProvider.js';\nimport {CurrencyCode, MoneyV2} from './storefront-api-types.js';\n\nexport type UseMoneyValue = {\n /**\n * The currency code from the `MoneyV2` object.\n */\n currencyCode: CurrencyCode;\n /**\n * The name for the currency code, returned by `Intl.NumberFormat`.\n */\n currencyName?: string;\n /**\n * The currency symbol returned by `Intl.NumberFormat`.\n */\n currencySymbol?: string;\n /**\n * The currency narrow symbol returned by `Intl.NumberFormat`.\n */\n currencyNarrowSymbol?: string;\n /**\n * The localized amount, without any currency symbols or non-number types from the `Intl.NumberFormat.formatToParts` parts.\n */\n amount: string;\n /**\n * All parts returned by `Intl.NumberFormat.formatToParts`.\n */\n parts: Intl.NumberFormatPart[];\n /**\n * A string returned by `new Intl.NumberFormat` for the amount and currency code,\n * using the `locale` value in the [`LocalizationProvider` component](https://shopify.dev/api/hydrogen/components/localization/localizationprovider).\n */\n localizedString: string;\n /**\n * The `MoneyV2` object provided as an argument to the hook.\n */\n original: MoneyV2;\n /**\n * A string with trailing zeros removed from the fractional part, if any exist. If there are no trailing zeros, then the fractional part remains.\n * For example, `$640.00` turns into `$640`.\n * `$640.42` remains `$640.42`.\n */\n withoutTrailingZeros: string;\n /**\n * A string without currency and without trailing zeros removed from the fractional part, if any exist. If there are no trailing zeros, then the fractional part remains.\n * For example, `$640.00` turns into `640`.\n * `$640.42` turns into `640.42`.\n */\n withoutTrailingZerosAndCurrency: string;\n};\n\n/**\n * The `useMoney` hook takes a [MoneyV2 object](https://shopify.dev/api/storefront/reference/common-objects/moneyv2) and returns a\n * default-formatted string of the amount with the correct currency indicator, along with some of the parts provided by\n * [Intl.NumberFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat).\n * Uses `locale` from `ShopifyProvider`\n */\nexport function useMoney(money: MoneyV2): UseMoneyValue {\n const {locale} = useShop();\n\n if (!locale) {\n throw new Error(\n `useMoney(): Unable to get 'locale' from 'useShop()', which means that 'locale' was not passed to '<ShopifyProvider/>'. 'locale' is required for 'useMoney()' to work`\n );\n }\n\n const amount = parseFloat(money.amount);\n\n const options = useMemo(\n () => ({\n style: 'currency',\n currency: money.currencyCode,\n }),\n [money.currencyCode]\n );\n\n const defaultFormatter = useLazyFormatter(locale, options);\n\n const nameFormatter = useLazyFormatter(locale, {\n ...options,\n currencyDisplay: 'name',\n });\n\n const narrowSymbolFormatter = useLazyFormatter(locale, {\n ...options,\n currencyDisplay: 'narrowSymbol',\n });\n\n const withoutTrailingZerosFormatter = useLazyFormatter(locale, {\n ...options,\n minimumFractionDigits: 0,\n maximumFractionDigits: 0,\n });\n\n const withoutCurrencyFormatter = useLazyFormatter(locale);\n\n const withoutTrailingZerosOrCurrencyFormatter = useLazyFormatter(locale, {\n minimumFractionDigits: 0,\n maximumFractionDigits: 0,\n });\n\n const isPartCurrency = (part: Intl.NumberFormatPart) =>\n part.type === 'currency';\n\n // By wrapping these properties in functions, we only\n // create formatters if they are going to be used.\n const lazyFormatters = useMemo(\n () => ({\n original: () => money,\n currencyCode: () => money.currencyCode,\n\n localizedString: () => defaultFormatter().format(amount),\n\n parts: () => defaultFormatter().formatToParts(amount),\n\n withoutTrailingZeros: () =>\n amount % 1 === 0\n ? withoutTrailingZerosFormatter().format(amount)\n : defaultFormatter().format(amount),\n\n withoutTrailingZerosAndCurrency: () =>\n amount % 1 === 0\n ? withoutTrailingZerosOrCurrencyFormatter().format(amount)\n : withoutCurrencyFormatter().format(amount),\n\n currencyName: () =>\n nameFormatter().formatToParts(amount).find(isPartCurrency)?.value ??\n money.currencyCode, // e.g. \"US dollars\"\n\n currencySymbol: () =>\n defaultFormatter().formatToParts(amount).find(isPartCurrency)?.value ??\n money.currencyCode, // e.g. \"USD\"\n\n currencyNarrowSymbol: () =>\n narrowSymbolFormatter().formatToParts(amount).find(isPartCurrency)\n ?.value ?? '', // e.g. \"$\"\n\n amount: () =>\n defaultFormatter()\n .formatToParts(amount)\n .filter((part) =>\n ['decimal', 'fraction', 'group', 'integer', 'literal'].includes(\n part.type\n )\n )\n .map((part) => part.value)\n .join(''),\n }),\n [\n money,\n amount,\n nameFormatter,\n defaultFormatter,\n narrowSymbolFormatter,\n withoutCurrencyFormatter,\n withoutTrailingZerosFormatter,\n withoutTrailingZerosOrCurrencyFormatter,\n ]\n );\n\n // Call functions automatically when the properties are accessed\n // to keep these functions as an implementation detail.\n return useMemo(\n () =>\n new Proxy(lazyFormatters as unknown as UseMoneyValue, {\n get: (target, key) => Reflect.get(target, key)?.call(null),\n }),\n [lazyFormatters]\n );\n}\n\nfunction useLazyFormatter(locale: string, options?: Intl.NumberFormatOptions) {\n return useMemo(() => {\n let memoized: Intl.NumberFormat;\n return () => (memoized ??= new Intl.NumberFormat(locale, options));\n }, [locale, options]);\n}\n"],"names":["useMoney","money","locale","useShop","Error","amount","parseFloat","options","useMemo","style","currency","currencyCode","defaultFormatter","useLazyFormatter","nameFormatter","currencyDisplay","narrowSymbolFormatter","withoutTrailingZerosFormatter","minimumFractionDigits","maximumFractionDigits","withoutCurrencyFormatter","withoutTrailingZerosOrCurrencyFormatter","isPartCurrency","part","type","lazyFormatters","original","localizedString","format","parts","formatToParts","withoutTrailingZeros","withoutTrailingZerosAndCurrency","currencyName","find","value","currencySymbol","currencyNarrowSymbol","filter","includes","map","join","Proxy","get","target","key","Reflect","call","memoized","Intl","NumberFormat"],"mappings":";;;;AA0DO,SAASA,SAASC,OAA+B;AAChD,QAAA;AAAA,IAACC;AAAAA,MAAUC,gBAAjB,QAAA;AAEA,MAAI,CAACD,QAAQ;AACL,UAAA,IAAIE,MACP,sKADG;AAAA,EAGP;AAEKC,QAAAA,SAASC,WAAWL,MAAMI,MAAP;AAEnBE,QAAAA,UAAUC,MAAAA,QACd,OAAO;AAAA,IACLC,OAAO;AAAA,IACPC,UAAUT,MAAMU;AAAAA,EAElB,IAAA,CAACV,MAAMU,YAAP,CALqB;AAQjBC,QAAAA,mBAAmBC,iBAAiBX,QAAQK,OAAT;AAEnCO,QAAAA,gBAAgBD,iBAAiBX,QAAQ;AAAA,IAC7C,GAAGK;AAAAA,IACHQ,iBAAiB;AAAA,EAAA,CAFmB;AAKhCC,QAAAA,wBAAwBH,iBAAiBX,QAAQ;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AAA;AAAA,IAEfX,QAAQ,MACNO,mBACGkB,cAAczB,MADjB,EAEGiC,OAAQf,CAAAA,SACP,CAAC,WAAW,YAAY,SAAS,WAAW,SAA5C,EAAuDgB,SACrDhB,KAAKC,IADP,CAHJ,EAOGgB,IAAKjB,CAAAA,SAASA,KAAKY,KAPtB,EAQGM,KAAK,EARR;AAAA,EA/BG,IAyCP,CACExC,OACAI,QACAS,eACAF,kBACAI,uBACAI,0BACAH,+BACAI,uCARF,CA1C4B;AAwD9B,SAAOb,cACL,MACE,IAAIkC,MAAMjB,gBAA4C;AAAA,IACpDkB,KAAK,CAACC,QAAQC;;AAAQC,2BAAQH,IAAIC,QAAQC,GAApB,MAAAC,mBAA0BC,KAAK;AAAA;AAAA,EAA/B,CADxB,GAGF,CAACtB,cAAD,CALY;AAOf;AAED,SAASZ,iBAAiBX,QAAgBK,SAAoC;AAC5E,SAAOC,cAAQ,MAAM;AACfwC,QAAAA;AACJ,WAAO,MAAOA,yCAAa,IAAIC,KAAKC,aAAahD,QAAQK,OAA9B;AAAA,EAAA,GAC1B,CAACL,QAAQK,OAAT,CAHW;AAIf;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopify/hydrogen-react",
3
- "version": "0.0.0-next-de1d160",
3
+ "version": "0.0.0-next-72f8a5c",
4
4
  "description": "React components, hooks, and utilities for creating custom Shopify storefronts",
5
5
  "homepage": "https://github.com/Shopify/hydrogen-ui/tree/main/packages/react",
6
6
  "license": "MIT",
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- var shim = { exports: {} };
4
- exports.shim = shim;
5
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -1,5 +0,0 @@
1
- var shim = { exports: {} };
2
- export {
3
- shim as s
4
- };
5
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- var useSyncExternalStoreShim_development = {};
4
- exports.__exports = useSyncExternalStoreShim_development;
5
- //# sourceMappingURL=use-sync-external-store-shim.development.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-sync-external-store-shim.development.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -1,5 +0,0 @@
1
- var useSyncExternalStoreShim_development = {};
2
- export {
3
- useSyncExternalStoreShim_development as __exports
4
- };
5
- //# sourceMappingURL=use-sync-external-store-shim.development.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-sync-external-store-shim.development.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- var useSyncExternalStoreShim_production_min = {};
4
- exports.__exports = useSyncExternalStoreShim_production_min;
5
- //# sourceMappingURL=use-sync-external-store-shim.production.min.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-sync-external-store-shim.production.min.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -1,5 +0,0 @@
1
- var useSyncExternalStoreShim_production_min = {};
2
- export {
3
- useSyncExternalStoreShim_production_min as __exports
4
- };
5
- //# sourceMappingURL=use-sync-external-store-shim.production.min.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-sync-external-store-shim.production.min.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- var withSelector = { exports: {} };
4
- exports.withSelector = withSelector;
5
- //# sourceMappingURL=with-selector.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"with-selector.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- var withSelector_development = {};
4
- exports.__exports = withSelector_development;
5
- //# sourceMappingURL=with-selector.development.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"with-selector.development.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -1,5 +0,0 @@
1
- var withSelector_development = {};
2
- export {
3
- withSelector_development as __exports
4
- };
5
- //# sourceMappingURL=with-selector.development.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"with-selector.development.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,5 +0,0 @@
1
- var withSelector = { exports: {} };
2
- export {
3
- withSelector as w
4
- };
5
- //# sourceMappingURL=with-selector.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"with-selector.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- var withSelector_production_min = {};
4
- exports.__exports = withSelector_production_min;
5
- //# sourceMappingURL=with-selector.production.min.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"with-selector.production.min.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -1,5 +0,0 @@
1
- var withSelector_production_min = {};
2
- export {
3
- withSelector_production_min as __exports
4
- };
5
- //# sourceMappingURL=with-selector.production.min.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"with-selector.production.min.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,158 +0,0 @@
1
- "use strict";
2
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- /*! *****************************************************************************
4
- Copyright (c) Microsoft Corporation.
5
-
6
- Permission to use, copy, modify, and/or distribute this software for any
7
- purpose with or without fee is hereby granted.
8
-
9
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
- PERFORMANCE OF THIS SOFTWARE.
16
- ***************************************************************************** */
17
- function t(t2, n) {
18
- var e2 = "function" == typeof Symbol && t2[Symbol.iterator];
19
- if (!e2)
20
- return t2;
21
- var r2, i2, o2 = e2.call(t2), a2 = [];
22
- try {
23
- for (; (void 0 === n || n-- > 0) && !(r2 = o2.next()).done; )
24
- a2.push(r2.value);
25
- } catch (t3) {
26
- i2 = { error: t3 };
27
- } finally {
28
- try {
29
- r2 && !r2.done && (e2 = o2.return) && e2.call(o2);
30
- } finally {
31
- if (i2)
32
- throw i2.error;
33
- }
34
- }
35
- return a2;
36
- }
37
- exports.InterpreterStatus = void 0;
38
- !function(t2) {
39
- t2[t2.NotStarted = 0] = "NotStarted", t2[t2.Running = 1] = "Running", t2[t2.Stopped = 2] = "Stopped";
40
- }(exports.InterpreterStatus || (exports.InterpreterStatus = {}));
41
- var e = { type: "xstate.init" };
42
- function r(t2) {
43
- return void 0 === t2 ? [] : [].concat(t2);
44
- }
45
- function i(t2) {
46
- return { type: "xstate.assign", assignment: t2 };
47
- }
48
- function o(t2, n) {
49
- return "string" == typeof (t2 = "string" == typeof t2 && n && n[t2] ? n[t2] : t2) ? { type: t2 } : "function" == typeof t2 ? { type: t2.name, exec: t2 } : t2;
50
- }
51
- function a(t2) {
52
- return function(n) {
53
- return t2 === n;
54
- };
55
- }
56
- function u(t2) {
57
- return "string" == typeof t2 ? { type: t2 } : t2;
58
- }
59
- function c(t2, n) {
60
- return { value: t2, context: n, actions: [], changed: false, matches: a(t2) };
61
- }
62
- function f(t2, n, e2) {
63
- var r2 = n, i2 = false;
64
- return [t2.filter(function(t3) {
65
- if ("xstate.assign" === t3.type) {
66
- i2 = true;
67
- var n2 = Object.assign({}, r2);
68
- return "function" == typeof t3.assignment ? n2 = t3.assignment(r2, e2) : Object.keys(t3.assignment).forEach(function(i3) {
69
- n2[i3] = "function" == typeof t3.assignment[i3] ? t3.assignment[i3](r2, e2) : t3.assignment[i3];
70
- }), r2 = n2, false;
71
- }
72
- return true;
73
- }), r2, i2];
74
- }
75
- function s(n, i2) {
76
- void 0 === i2 && (i2 = {});
77
- var s2 = t(f(r(n.states[n.initial].entry).map(function(t2) {
78
- return o(t2, i2.actions);
79
- }), n.context, e), 2), l2 = s2[0], v2 = s2[1], y = { config: n, _options: i2, initialState: { value: n.initial, actions: l2, context: v2, matches: a(n.initial) }, transition: function(e2, i3) {
80
- var s3, l3, v3 = "string" == typeof e2 ? { value: e2, context: n.context } : e2, p = v3.value, g = v3.context, d = u(i3), x = n.states[p];
81
- if (x.on) {
82
- var m = r(x.on[d.type]);
83
- try {
84
- for (var h = function(t2) {
85
- var n2 = "function" == typeof Symbol && Symbol.iterator, e3 = n2 && t2[n2], r2 = 0;
86
- if (e3)
87
- return e3.call(t2);
88
- if (t2 && "number" == typeof t2.length)
89
- return { next: function() {
90
- return t2 && r2 >= t2.length && (t2 = void 0), { value: t2 && t2[r2++], done: !t2 };
91
- } };
92
- throw new TypeError(n2 ? "Object is not iterable." : "Symbol.iterator is not defined.");
93
- }(m), b = h.next(); !b.done; b = h.next()) {
94
- var S = b.value;
95
- if (void 0 === S)
96
- return c(p, g);
97
- var w = "string" == typeof S ? { target: S } : S, j = w.target, E = w.actions, R = void 0 === E ? [] : E, N = w.cond, O = void 0 === N ? function() {
98
- return true;
99
- } : N, _ = void 0 === j, k = null != j ? j : p, T = n.states[k];
100
- if (O(g, d)) {
101
- var q = t(f((_ ? r(R) : [].concat(x.exit, R, T.entry).filter(function(t2) {
102
- return t2;
103
- })).map(function(t2) {
104
- return o(t2, y._options.actions);
105
- }), g, d), 3), z = q[0], A = q[1], B = q[2], C = null != j ? j : p;
106
- return { value: C, context: A, actions: z, changed: j !== p || z.length > 0 || B, matches: a(C) };
107
- }
108
- }
109
- } catch (t2) {
110
- s3 = { error: t2 };
111
- } finally {
112
- try {
113
- b && !b.done && (l3 = h.return) && l3.call(h);
114
- } finally {
115
- if (s3)
116
- throw s3.error;
117
- }
118
- }
119
- }
120
- return c(p, g);
121
- } };
122
- return y;
123
- }
124
- var l = function(t2, n) {
125
- return t2.actions.forEach(function(e2) {
126
- var r2 = e2.exec;
127
- return r2 && r2(t2.context, n);
128
- });
129
- };
130
- function v(t2) {
131
- var r2 = t2.initialState, i2 = exports.InterpreterStatus.NotStarted, o2 = /* @__PURE__ */ new Set(), c2 = { _machine: t2, send: function(e2) {
132
- i2 === exports.InterpreterStatus.Running && (r2 = t2.transition(r2, e2), l(r2, u(e2)), o2.forEach(function(t3) {
133
- return t3(r2);
134
- }));
135
- }, subscribe: function(t3) {
136
- return o2.add(t3), t3(r2), { unsubscribe: function() {
137
- return o2.delete(t3);
138
- } };
139
- }, start: function(o3) {
140
- if (o3) {
141
- var u2 = "object" == typeof o3 ? o3 : { context: t2.config.context, value: o3 };
142
- r2 = { value: u2.value, actions: [], context: u2.context, matches: a(u2.value) };
143
- } else
144
- r2 = t2.initialState;
145
- return i2 = exports.InterpreterStatus.Running, l(r2, e), c2;
146
- }, stop: function() {
147
- return i2 = exports.InterpreterStatus.Stopped, o2.clear(), c2;
148
- }, get state() {
149
- return r2;
150
- }, get status() {
151
- return i2;
152
- } };
153
- return c2;
154
- }
155
- exports.assign = i;
156
- exports.createMachine = s;
157
- exports.interpret = v;
158
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../../../../../../node_modules/@xstate/fsm/es/index.js"],"sourcesContent":["/*! *****************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\nfunction t(t,n){var e=\"function\"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var r,i,o=e.call(t),a=[];try{for(;(void 0===n||n-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(e=o.return)&&e.call(o)}finally{if(i)throw i.error}}return a}var n;!function(t){t[t.NotStarted=0]=\"NotStarted\",t[t.Running=1]=\"Running\",t[t.Stopped=2]=\"Stopped\"}(n||(n={}));var e={type:\"xstate.init\"};function r(t){return void 0===t?[]:[].concat(t)}function i(t){return{type:\"xstate.assign\",assignment:t}}function o(t,n){return\"string\"==typeof(t=\"string\"==typeof t&&n&&n[t]?n[t]:t)?{type:t}:\"function\"==typeof t?{type:t.name,exec:t}:t}function a(t){return function(n){return t===n}}function u(t){return\"string\"==typeof t?{type:t}:t}function c(t,n){return{value:t,context:n,actions:[],changed:!1,matches:a(t)}}function f(t,n,e){var r=n,i=!1;return[t.filter((function(t){if(\"xstate.assign\"===t.type){i=!0;var n=Object.assign({},r);return\"function\"==typeof t.assignment?n=t.assignment(r,e):Object.keys(t.assignment).forEach((function(i){n[i]=\"function\"==typeof t.assignment[i]?t.assignment[i](r,e):t.assignment[i]})),r=n,!1}return!0})),r,i]}function s(n,i){void 0===i&&(i={});var s=t(f(r(n.states[n.initial].entry).map((function(t){return o(t,i.actions)})),n.context,e),2),l=s[0],v=s[1],y={config:n,_options:i,initialState:{value:n.initial,actions:l,context:v,matches:a(n.initial)},transition:function(e,i){var s,l,v=\"string\"==typeof e?{value:e,context:n.context}:e,p=v.value,g=v.context,d=u(i),x=n.states[p];if(x.on){var m=r(x.on[d.type]);try{for(var h=function(t){var n=\"function\"==typeof Symbol&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&\"number\"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?\"Object is not iterable.\":\"Symbol.iterator is not defined.\")}(m),b=h.next();!b.done;b=h.next()){var S=b.value;if(void 0===S)return c(p,g);var w=\"string\"==typeof S?{target:S}:S,j=w.target,E=w.actions,R=void 0===E?[]:E,N=w.cond,O=void 0===N?function(){return!0}:N,_=void 0===j,k=null!=j?j:p,T=n.states[k];if(O(g,d)){var q=t(f((_?r(R):[].concat(x.exit,R,T.entry).filter((function(t){return t}))).map((function(t){return o(t,y._options.actions)})),g,d),3),z=q[0],A=q[1],B=q[2],C=null!=j?j:p;return{value:C,context:A,actions:z,changed:j!==p||z.length>0||B,matches:a(C)}}}}catch(t){s={error:t}}finally{try{b&&!b.done&&(l=h.return)&&l.call(h)}finally{if(s)throw s.error}}}return c(p,g)}};return y}var l=function(t,n){return t.actions.forEach((function(e){var r=e.exec;return r&&r(t.context,n)}))};function v(t){var r=t.initialState,i=n.NotStarted,o=new Set,c={_machine:t,send:function(e){i===n.Running&&(r=t.transition(r,e),l(r,u(e)),o.forEach((function(t){return t(r)})))},subscribe:function(t){return o.add(t),t(r),{unsubscribe:function(){return o.delete(t)}}},start:function(o){if(o){var u=\"object\"==typeof o?o:{context:t.config.context,value:o};r={value:u.value,actions:[],context:u.context,matches:a(u.value)}}else r=t.initialState;return i=n.Running,l(r,e),c},stop:function(){return i=n.Stopped,o.clear(),c},get state(){return r},get status(){return i}};return c}export{n as InterpreterStatus,i as assign,s as createMachine,v as interpret};\n"],"names":["t","e","r","i","o","a","n","s","l","v","c","u"],"mappings":";;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAcA,SAAS,EAAEA,IAAE,GAAE;AAAC,MAAIC,KAAE,cAAY,OAAO,UAAQD,GAAE,OAAO;AAAU,MAAG,CAACC;AAAE,WAAOD;AAAE,MAAIE,IAAEC,IAAEC,KAAEH,GAAE,KAAKD,EAAC,GAAEK,KAAE,CAAE;AAAC,MAAG;AAAC,YAAM,WAAS,KAAG,MAAK,MAAI,EAAEH,KAAEE,GAAE,KAAI,GAAI;AAAM,MAAAC,GAAE,KAAKH,GAAE,KAAK;AAAA,EAAC,SAAOF,IAAN;AAAS,IAAAG,KAAE,EAAC,OAAMH,GAAC;AAAA,EAAC,UAAC;AAAQ,QAAG;AAAC,MAAAE,MAAG,CAACA,GAAE,SAAOD,KAAEG,GAAE,WAASH,GAAE,KAAKG,EAAC;AAAA,IAAC,UAAC;AAAQ,UAAGD;AAAE,cAAMA,GAAE;AAAA,IAAK;AAAA,EAAC;AAAC,SAAOE;AAAC;AAAKC,QAAE,oBAAA;AAAA,CAAC,SAASN,IAAE;AAAC,EAAAA,GAAEA,GAAE,aAAW,KAAG,cAAaA,GAAEA,GAAE,UAAQ,KAAG,WAAUA,GAAEA,GAAE,UAAQ,KAAG;AAAS,EAAEM,QAAC,sBAAGA,4BAAE,CAAA,EAAG;AAAE,IAAI,IAAE,EAAC,MAAK,cAAa;AAAE,SAAS,EAAEN,IAAE;A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
1
- /*! *****************************************************************************
2
- Copyright (c) Microsoft Corporation.
3
-
4
- Permission to use, copy, modify, and/or distribute this software for any
5
- purpose with or without fee is hereby granted.
6
-
7
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
- PERFORMANCE OF THIS SOFTWARE.
14
- ***************************************************************************** */
15
- function t(t2, n2) {
16
- var e2 = "function" == typeof Symbol && t2[Symbol.iterator];
17
- if (!e2)
18
- return t2;
19
- var r2, i2, o2 = e2.call(t2), a2 = [];
20
- try {
21
- for (; (void 0 === n2 || n2-- > 0) && !(r2 = o2.next()).done; )
22
- a2.push(r2.value);
23
- } catch (t3) {
24
- i2 = { error: t3 };
25
- } finally {
26
- try {
27
- r2 && !r2.done && (e2 = o2.return) && e2.call(o2);
28
- } finally {
29
- if (i2)
30
- throw i2.error;
31
- }
32
- }
33
- return a2;
34
- }
35
- var n;
36
- !function(t2) {
37
- t2[t2.NotStarted = 0] = "NotStarted", t2[t2.Running = 1] = "Running", t2[t2.Stopped = 2] = "Stopped";
38
- }(n || (n = {}));
39
- var e = { type: "xstate.init" };
40
- function r(t2) {
41
- return void 0 === t2 ? [] : [].concat(t2);
42
- }
43
- function i(t2) {
44
- return { type: "xstate.assign", assignment: t2 };
45
- }
46
- function o(t2, n2) {
47
- return "string" == typeof (t2 = "string" == typeof t2 && n2 && n2[t2] ? n2[t2] : t2) ? { type: t2 } : "function" == typeof t2 ? { type: t2.name, exec: t2 } : t2;
48
- }
49
- function a(t2) {
50
- return function(n2) {
51
- return t2 === n2;
52
- };
53
- }
54
- function u(t2) {
55
- return "string" == typeof t2 ? { type: t2 } : t2;
56
- }
57
- function c(t2, n2) {
58
- return { value: t2, context: n2, actions: [], changed: false, matches: a(t2) };
59
- }
60
- function f(t2, n2, e2) {
61
- var r2 = n2, i2 = false;
62
- return [t2.filter(function(t3) {
63
- if ("xstate.assign" === t3.type) {
64
- i2 = true;
65
- var n3 = Object.assign({}, r2);
66
- return "function" == typeof t3.assignment ? n3 = t3.assignment(r2, e2) : Object.keys(t3.assignment).forEach(function(i3) {
67
- n3[i3] = "function" == typeof t3.assignment[i3] ? t3.assignment[i3](r2, e2) : t3.assignment[i3];
68
- }), r2 = n3, false;
69
- }
70
- return true;
71
- }), r2, i2];
72
- }
73
- function s(n2, i2) {
74
- void 0 === i2 && (i2 = {});
75
- var s2 = t(f(r(n2.states[n2.initial].entry).map(function(t2) {
76
- return o(t2, i2.actions);
77
- }), n2.context, e), 2), l2 = s2[0], v2 = s2[1], y = { config: n2, _options: i2, initialState: { value: n2.initial, actions: l2, context: v2, matches: a(n2.initial) }, transition: function(e2, i3) {
78
- var s3, l3, v3 = "string" == typeof e2 ? { value: e2, context: n2.context } : e2, p = v3.value, g = v3.context, d = u(i3), x = n2.states[p];
79
- if (x.on) {
80
- var m = r(x.on[d.type]);
81
- try {
82
- for (var h = function(t2) {
83
- var n3 = "function" == typeof Symbol && Symbol.iterator, e3 = n3 && t2[n3], r2 = 0;
84
- if (e3)
85
- return e3.call(t2);
86
- if (t2 && "number" == typeof t2.length)
87
- return { next: function() {
88
- return t2 && r2 >= t2.length && (t2 = void 0), { value: t2 && t2[r2++], done: !t2 };
89
- } };
90
- throw new TypeError(n3 ? "Object is not iterable." : "Symbol.iterator is not defined.");
91
- }(m), b = h.next(); !b.done; b = h.next()) {
92
- var S = b.value;
93
- if (void 0 === S)
94
- return c(p, g);
95
- var w = "string" == typeof S ? { target: S } : S, j = w.target, E = w.actions, R = void 0 === E ? [] : E, N = w.cond, O = void 0 === N ? function() {
96
- return true;
97
- } : N, _ = void 0 === j, k = null != j ? j : p, T = n2.states[k];
98
- if (O(g, d)) {
99
- var q = t(f((_ ? r(R) : [].concat(x.exit, R, T.entry).filter(function(t2) {
100
- return t2;
101
- })).map(function(t2) {
102
- return o(t2, y._options.actions);
103
- }), g, d), 3), z = q[0], A = q[1], B = q[2], C = null != j ? j : p;
104
- return { value: C, context: A, actions: z, changed: j !== p || z.length > 0 || B, matches: a(C) };
105
- }
106
- }
107
- } catch (t2) {
108
- s3 = { error: t2 };
109
- } finally {
110
- try {
111
- b && !b.done && (l3 = h.return) && l3.call(h);
112
- } finally {
113
- if (s3)
114
- throw s3.error;
115
- }
116
- }
117
- }
118
- return c(p, g);
119
- } };
120
- return y;
121
- }
122
- var l = function(t2, n2) {
123
- return t2.actions.forEach(function(e2) {
124
- var r2 = e2.exec;
125
- return r2 && r2(t2.context, n2);
126
- });
127
- };
128
- function v(t2) {
129
- var r2 = t2.initialState, i2 = n.NotStarted, o2 = /* @__PURE__ */ new Set(), c2 = { _machine: t2, send: function(e2) {
130
- i2 === n.Running && (r2 = t2.transition(r2, e2), l(r2, u(e2)), o2.forEach(function(t3) {
131
- return t3(r2);
132
- }));
133
- }, subscribe: function(t3) {
134
- return o2.add(t3), t3(r2), { unsubscribe: function() {
135
- return o2.delete(t3);
136
- } };
137
- }, start: function(o3) {
138
- if (o3) {
139
- var u2 = "object" == typeof o3 ? o3 : { context: t2.config.context, value: o3 };
140
- r2 = { value: u2.value, actions: [], context: u2.context, matches: a(u2.value) };
141
- } else
142
- r2 = t2.initialState;
143
- return i2 = n.Running, l(r2, e), c2;
144
- }, stop: function() {
145
- return i2 = n.Stopped, o2.clear(), c2;
146
- }, get state() {
147
- return r2;
148
- }, get status() {
149
- return i2;
150
- } };
151
- return c2;
152
- }
153
- export {
154
- n as InterpreterStatus,
155
- i as assign,
156
- s as createMachine,
157
- v as interpret
158
- };
159
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../../../../../../../../node_modules/@xstate/fsm/es/index.js"],"sourcesContent":["/*! *****************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\nfunction t(t,n){var e=\"function\"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var r,i,o=e.call(t),a=[];try{for(;(void 0===n||n-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(e=o.return)&&e.call(o)}finally{if(i)throw i.error}}return a}var n;!function(t){t[t.NotStarted=0]=\"NotStarted\",t[t.Running=1]=\"Running\",t[t.Stopped=2]=\"Stopped\"}(n||(n={}));var e={type:\"xstate.init\"};function r(t){return void 0===t?[]:[].concat(t)}function i(t){return{type:\"xstate.assign\",assignment:t}}function o(t,n){return\"string\"==typeof(t=\"string\"==typeof t&&n&&n[t]?n[t]:t)?{type:t}:\"function\"==typeof t?{type:t.name,exec:t}:t}function a(t){return function(n){return t===n}}function u(t){return\"string\"==typeof t?{type:t}:t}function c(t,n){return{value:t,context:n,actions:[],changed:!1,matches:a(t)}}function f(t,n,e){var r=n,i=!1;return[t.filter((function(t){if(\"xstate.assign\"===t.type){i=!0;var n=Object.assign({},r);return\"function\"==typeof t.assignment?n=t.assignment(r,e):Object.keys(t.assignment).forEach((function(i){n[i]=\"function\"==typeof t.assignment[i]?t.assignment[i](r,e):t.assignment[i]})),r=n,!1}return!0})),r,i]}function s(n,i){void 0===i&&(i={});var s=t(f(r(n.states[n.initial].entry).map((function(t){return o(t,i.actions)})),n.context,e),2),l=s[0],v=s[1],y={config:n,_options:i,initialState:{value:n.initial,actions:l,context:v,matches:a(n.initial)},transition:function(e,i){var s,l,v=\"string\"==typeof e?{value:e,context:n.context}:e,p=v.value,g=v.context,d=u(i),x=n.states[p];if(x.on){var m=r(x.on[d.type]);try{for(var h=function(t){var n=\"function\"==typeof Symbol&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&\"number\"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?\"Object is not iterable.\":\"Symbol.iterator is not defined.\")}(m),b=h.next();!b.done;b=h.next()){var S=b.value;if(void 0===S)return c(p,g);var w=\"string\"==typeof S?{target:S}:S,j=w.target,E=w.actions,R=void 0===E?[]:E,N=w.cond,O=void 0===N?function(){return!0}:N,_=void 0===j,k=null!=j?j:p,T=n.states[k];if(O(g,d)){var q=t(f((_?r(R):[].concat(x.exit,R,T.entry).filter((function(t){return t}))).map((function(t){return o(t,y._options.actions)})),g,d),3),z=q[0],A=q[1],B=q[2],C=null!=j?j:p;return{value:C,context:A,actions:z,changed:j!==p||z.length>0||B,matches:a(C)}}}}catch(t){s={error:t}}finally{try{b&&!b.done&&(l=h.return)&&l.call(h)}finally{if(s)throw s.error}}}return c(p,g)}};return y}var l=function(t,n){return t.actions.forEach((function(e){var r=e.exec;return r&&r(t.context,n)}))};function v(t){var r=t.initialState,i=n.NotStarted,o=new Set,c={_machine:t,send:function(e){i===n.Running&&(r=t.transition(r,e),l(r,u(e)),o.forEach((function(t){return t(r)})))},subscribe:function(t){return o.add(t),t(r),{unsubscribe:function(){return o.delete(t)}}},start:function(o){if(o){var u=\"object\"==typeof o?o:{context:t.config.context,value:o};r={value:u.value,actions:[],context:u.context,matches:a(u.value)}}else r=t.initialState;return i=n.Running,l(r,e),c},stop:function(){return i=n.Stopped,o.clear(),c},get state(){return r},get status(){return i}};return c}export{n as InterpreterStatus,i as assign,s as createMachine,v as interpret};\n"],"names":["t","n","e","r","i","o","a","s","l","v","c","u"],"mappings":"AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAcA,SAAS,EAAEA,IAAEC,IAAE;AAAC,MAAIC,KAAE,cAAY,OAAO,UAAQF,GAAE,OAAO;AAAU,MAAG,CAACE;AAAE,WAAOF;AAAE,MAAIG,IAAEC,IAAEC,KAAEH,GAAE,KAAKF,EAAC,GAAEM,KAAE,CAAE;AAAC,MAAG;AAAC,YAAM,WAASL,MAAGA,OAAK,MAAI,EAAEE,KAAEE,GAAE,KAAI,GAAI;AAAM,MAAAC,GAAE,KAAKH,GAAE,KAAK;AAAA,EAAC,SAAOH,IAAN;AAAS,IAAAI,KAAE,EAAC,OAAMJ,GAAC;AAAA,EAAC,UAAC;AAAQ,QAAG;AAAC,MAAAG,MAAG,CAACA,GAAE,SAAOD,KAAEG,GAAE,WAASH,GAAE,KAAKG,EAAC;AAAA,IAAC,UAAC;AAAQ,UAAGD;AAAE,cAAMA,GAAE;AAAA,IAAK;AAAA,EAAC;AAAC,SAAOE;AAAC;AAAI,IAAC;AAAE,CAAC,SAASN,IAAE;AAAC,EAAAA,GAAEA,GAAE,aAAW,KAAG,cAAaA,GAAEA,GAAE,UAAQ,KAAG,WAAUA,GAAEA,GAAE,UAAQ,KAAG;AAAS,EAAE,MAAI,IAAE,CAAE,EAAC;AAAE,IAAI,IAAE,EAAC,MAAK,cAAa;AAAE,SAAS,EAAEA,IAAE;AAAC,SAAO,WAASA,KAAE,CAAE,IAAC,GAAG,OAA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toStringTag]: { value: "Module" } });
3
- const index = require("../../fsm/es/index.cjs");
4
- const require$$0 = require("react");
5
- const useIsomorphicLayoutEffect_browser_esm = require("../../../use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.cjs");
6
- require("../../../use-sync-external-store/shim/with-selector.cjs");
7
- const useConstant = require("./useConstant.cjs");
8
- const withSelector = require("../../../../_virtual/with-selector.cjs");
9
- var __read = globalThis && globalThis.__read || function(o, n) {
10
- var m = typeof Symbol === "function" && o[Symbol.iterator];
11
- if (!m)
12
- return o;
13
- var i = m.call(o), r, ar = [], e;
14
- try {
15
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
16
- ar.push(r.value);
17
- } catch (error) {
18
- e = { error };
19
- } finally {
20
- try {
21
- if (r && !r.done && (m = i["return"]))
22
- m.call(i);
23
- } finally {
24
- if (e)
25
- throw e.error;
26
- }
27
- }
28
- return ar;
29
- };
30
- function identity(a) {
31
- return a;
32
- }
33
- var getServiceState = function(service) {
34
- var currentValue;
35
- service.subscribe(function(state) {
36
- currentValue = state;
37
- }).unsubscribe();
38
- return currentValue;
39
- };
40
- function useMachine(stateMachine, options) {
41
- var persistedStateRef = require$$0.useRef();
42
- if (process.env.NODE_ENV !== "production") {
43
- var _a = __read(require$$0.useState(stateMachine), 1), initialMachine = _a[0];
44
- if (stateMachine !== initialMachine) {
45
- console.warn("Machine given to `useMachine` has changed between renders. This is not supported and might lead to unexpected results.\nPlease make sure that you pass the same Machine as argument each time.");
46
- }
47
- }
48
- var _b = __read(useConstant(function() {
49
- var queue2 = [];
50
- var service2 = index.interpret(index.createMachine(stateMachine.config, options ? options : stateMachine._options));
51
- var send = service2.send;
52
- service2.send = function(event) {
53
- if (service2.status === index.InterpreterStatus.NotStarted) {
54
- queue2.push(event);
55
- return;
56
- }
57
- send(event);
58
- persistedStateRef.current = service2.state;
59
- };
60
- return [service2, queue2];
61
- }), 2), service = _b[0], queue = _b[1];
62
- useIsomorphicLayoutEffect_browser_esm(function() {
63
- if (options) {
64
- service._machine._options = options;
65
- }
66
- });
67
- var useServiceResult = useService(service);
68
- require$$0.useEffect(function() {
69
- service.start(persistedStateRef.current);
70
- queue.forEach(service.send);
71
- persistedStateRef.current = service.state;
72
- return function() {
73
- service.stop();
74
- };
75
- }, []);
76
- return useServiceResult;
77
- }
78
- var isEqual = function(_prevState, nextState) {
79
- return nextState.changed === false;
80
- };
81
- function useService(service) {
82
- var getSnapshot = require$$0.useCallback(function() {
83
- return getServiceState(service);
84
- }, [service]);
85
- var subscribe = require$$0.useCallback(function(handleStoreChange) {
86
- var unsubscribe = service.subscribe(handleStoreChange).unsubscribe;
87
- return unsubscribe;
88
- }, [service]);
89
- var storeSnapshot = withSelector.withSelector.exports.useSyncExternalStoreWithSelector(subscribe, getSnapshot, getSnapshot, identity, isEqual);
90
- return [storeSnapshot, service.send, service];
91
- }
92
- exports.useMachine = useMachine;
93
- exports.useService = useService;
94
- //# sourceMappingURL=fsm.cjs.map