@shopify/ui-extensions-server-kit 5.3.1 → 5.4.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 (244) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +3 -2
  3. package/dist/ExtensionServerClient/ExtensionServerClient.d.ts +3 -5
  4. package/dist/ExtensionServerClient/server-types.d.ts +31 -7
  5. package/dist/_virtual/jsx-runtime.cjs.js +1 -0
  6. package/dist/_virtual/jsx-runtime.cjs2.js +1 -0
  7. package/dist/_virtual/jsx-runtime.es.js +5 -0
  8. package/dist/_virtual/jsx-runtime.es2.js +4 -0
  9. package/dist/_virtual/react-jsx-runtime.development.cjs.js +1 -0
  10. package/dist/_virtual/react-jsx-runtime.development.es.js +4 -0
  11. package/dist/_virtual/react-jsx-runtime.production.min.cjs.js +1 -0
  12. package/dist/_virtual/react-jsx-runtime.production.min.es.js +4 -0
  13. package/dist/context/ExtensionServerProvider.d.ts +2 -1
  14. package/dist/i18n.d.ts +2 -8
  15. package/dist/index.cjs.js +1 -1
  16. package/dist/index.cjs2.js +1 -1
  17. package/dist/index.es.js +18 -18
  18. package/dist/index.es2.js +3 -3
  19. package/dist/node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react-jsx-runtime.development.cjs.js +22 -0
  20. package/dist/node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react-jsx-runtime.development.es.js +604 -0
  21. package/dist/node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react-jsx-runtime.production.min.cjs.js +9 -0
  22. package/dist/node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react-jsx-runtime.production.min.es.js +28 -0
  23. package/dist/node_modules/.pnpm/react@18.3.1/node_modules/react/jsx-runtime.cjs.js +1 -0
  24. package/dist/node_modules/.pnpm/react@18.3.1/node_modules/react/jsx-runtime.es.js +10 -0
  25. package/dist/packages/ui-extensions-server-kit/src/ExtensionServerClient/ExtensionServerClient.cjs.js +1 -0
  26. package/dist/{ExtensionServerClient → packages/ui-extensions-server-kit/src/ExtensionServerClient}/ExtensionServerClient.es.js +21 -18
  27. package/dist/packages/ui-extensions-server-kit/src/context/ExtensionServerProvider.cjs.js +1 -0
  28. package/dist/packages/ui-extensions-server-kit/src/context/ExtensionServerProvider.es.js +30 -0
  29. package/dist/{context → packages/ui-extensions-server-kit/src/context}/constants.cjs.js +1 -1
  30. package/dist/packages/ui-extensions-server-kit/src/hooks/useExtensionServerContext.cjs.js +1 -0
  31. package/dist/{hooks → packages/ui-extensions-server-kit/src/hooks}/useExtensionServerContext.es.js +3 -2
  32. package/dist/packages/ui-extensions-server-kit/src/testing/MockExtensionServerProvider.cjs.js +1 -0
  33. package/dist/packages/ui-extensions-server-kit/src/testing/MockExtensionServerProvider.es.js +25 -0
  34. package/dist/{testing → packages/ui-extensions-server-kit/src/testing}/extensions.cjs.js +1 -1
  35. package/dist/{testing → packages/ui-extensions-server-kit/src/testing}/extensions.es.js +3 -2
  36. package/dist/packages/ui-extensions-server-kit/src/utilities/isUIExtension.cjs.js +1 -0
  37. package/dist/{utilities → packages/ui-extensions-server-kit/src/utilities}/isUIExtension.es.js +3 -2
  38. package/dist/{utilities → packages/ui-extensions-server-kit/src/utilities}/isValidSurface.cjs.js +1 -1
  39. package/dist/packages/ui-extensions-server-kit/src/utilities/isValidSurface.es.js +7 -0
  40. package/dist/testing/MockExtensionServerProvider.d.ts +2 -1
  41. package/dist/types.d.ts +14 -7
  42. package/dist/utilities/isUIExtension.d.ts +1 -1
  43. package/dist/utilities/isValidSurface.d.ts +1 -1
  44. package/dist/utilities/set.d.ts +1 -1
  45. package/node_modules/{@shopify/react-testing/LICENSE.md → @testing-library/react/LICENSE} +2 -3
  46. package/node_modules/@testing-library/react/README.md +692 -0
  47. package/node_modules/@testing-library/react/dist/@testing-library/react.cjs.js +537 -0
  48. package/node_modules/@testing-library/react/dist/@testing-library/react.esm.js +497 -0
  49. package/node_modules/@testing-library/react/dist/@testing-library/react.pure.cjs.js +501 -0
  50. package/node_modules/@testing-library/react/dist/@testing-library/react.pure.esm.js +461 -0
  51. package/node_modules/@testing-library/react/dist/@testing-library/react.pure.umd.js +502 -0
  52. package/node_modules/@testing-library/react/dist/@testing-library/react.pure.umd.js.map +1 -0
  53. package/node_modules/@testing-library/react/dist/@testing-library/react.pure.umd.min.js +2 -0
  54. package/node_modules/@testing-library/react/dist/@testing-library/react.pure.umd.min.js.map +1 -0
  55. package/node_modules/@testing-library/react/dist/@testing-library/react.umd.js +538 -0
  56. package/node_modules/@testing-library/react/dist/@testing-library/react.umd.js.map +1 -0
  57. package/node_modules/@testing-library/react/dist/@testing-library/react.umd.min.js +2 -0
  58. package/node_modules/@testing-library/react/dist/@testing-library/react.umd.min.js.map +1 -0
  59. package/node_modules/@testing-library/react/dist/act-compat.js +80 -0
  60. package/node_modules/@testing-library/react/dist/config.js +33 -0
  61. package/node_modules/@testing-library/react/dist/fire-event.js +70 -0
  62. package/node_modules/@testing-library/react/dist/index.js +52 -0
  63. package/node_modules/@testing-library/react/dist/pure.js +356 -0
  64. package/node_modules/@testing-library/react/dont-cleanup-after-each.js +1 -0
  65. package/node_modules/@testing-library/react/package.json +116 -0
  66. package/node_modules/@testing-library/react/pure.d.ts +1 -0
  67. package/node_modules/@testing-library/react/pure.js +2 -0
  68. package/node_modules/@testing-library/react/types/index.d.ts +287 -0
  69. package/node_modules/@testing-library/react/types/pure.d.ts +1 -0
  70. package/node_modules/@types/react/README.md +4 -5
  71. package/node_modules/@types/react/canary.d.ts +166 -0
  72. package/node_modules/@types/react/experimental.d.ts +21 -86
  73. package/node_modules/@types/react/global.d.ts +146 -137
  74. package/node_modules/@types/react/index.d.ts +2738 -1370
  75. package/node_modules/@types/react/jsx-dev-runtime.d.ts +45 -2
  76. package/node_modules/@types/react/jsx-runtime.d.ts +36 -2
  77. package/node_modules/@types/react/package.json +111 -54
  78. package/node_modules/@types/react/ts5.0/canary.d.ts +166 -0
  79. package/node_modules/@types/react/ts5.0/experimental.d.ts +127 -0
  80. package/node_modules/@types/react/ts5.0/global.d.ts +160 -0
  81. package/node_modules/@types/react/ts5.0/index.d.ts +4530 -0
  82. package/node_modules/@types/react/ts5.0/jsx-dev-runtime.d.ts +44 -0
  83. package/node_modules/@types/react/ts5.0/jsx-runtime.d.ts +35 -0
  84. package/node_modules/@vitejs/plugin-react/README.md +159 -0
  85. package/node_modules/@vitejs/plugin-react/dist/index.d.ts +75 -0
  86. package/node_modules/@vitejs/plugin-react/dist/index.js +401 -0
  87. package/node_modules/@vitejs/plugin-react/dist/refresh-runtime.js +663 -0
  88. package/node_modules/@vitejs/plugin-react/package.json +77 -0
  89. package/node_modules/@vitejs/plugin-react/types/preamble.d.ts +1 -0
  90. package/package.json +9 -10
  91. package/project.json +1 -1
  92. package/src/ExtensionServerClient/ExtensionServerClient.test.ts +6 -5
  93. package/src/ExtensionServerClient/ExtensionServerClient.ts +27 -19
  94. package/src/ExtensionServerClient/server-types.ts +17 -7
  95. package/src/ExtensionServerClient/types.ts +0 -2
  96. package/src/context/ExtensionServerProvider.test.tsx +55 -73
  97. package/src/context/ExtensionServerProvider.tsx +1 -0
  98. package/src/i18n.ts +2 -5
  99. package/src/state/reducers/extensionServerReducer.test.ts +2 -2
  100. package/src/testing/extensions.ts +1 -0
  101. package/src/types.ts +15 -5
  102. package/src/utilities/assetToString.ts +0 -1
  103. package/src/utilities/isUIExtension.ts +5 -4
  104. package/src/utilities/isValidSurface.ts +2 -3
  105. package/src/utilities/replaceUpdated.ts +0 -2
  106. package/src/utilities/set.ts +10 -5
  107. package/tests/setup.ts +1 -4
  108. package/vite.config.mts +57 -0
  109. package/dist/ExtensionServerClient/ExtensionServerClient.cjs.js +0 -1
  110. package/dist/context/ExtensionServerProvider.cjs.js +0 -1
  111. package/dist/context/ExtensionServerProvider.es.js +0 -29
  112. package/dist/hooks/useExtensionServerContext.cjs.js +0 -1
  113. package/dist/testing/MockExtensionServerProvider.cjs.js +0 -1
  114. package/dist/testing/MockExtensionServerProvider.es.js +0 -24
  115. package/dist/utilities/isUIExtension.cjs.js +0 -1
  116. package/dist/utilities/isValidSurface.es.js +0 -7
  117. package/node_modules/@shopify/react-testing/README.md +0 -711
  118. package/node_modules/@shopify/react-testing/build/cjs/TestWrapper.js +0 -52
  119. package/node_modules/@shopify/react-testing/build/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -47
  120. package/node_modules/@shopify/react-testing/build/cjs/compat.js +0 -14
  121. package/node_modules/@shopify/react-testing/build/cjs/destroy.js +0 -13
  122. package/node_modules/@shopify/react-testing/build/cjs/element.js +0 -225
  123. package/node_modules/@shopify/react-testing/build/cjs/index.js +0 -21
  124. package/node_modules/@shopify/react-testing/build/cjs/matchers/components.js +0 -46
  125. package/node_modules/@shopify/react-testing/build/cjs/matchers/context.js +0 -25
  126. package/node_modules/@shopify/react-testing/build/cjs/matchers/index.js +0 -16
  127. package/node_modules/@shopify/react-testing/build/cjs/matchers/props.js +0 -38
  128. package/node_modules/@shopify/react-testing/build/cjs/matchers/strings.js +0 -42
  129. package/node_modules/@shopify/react-testing/build/cjs/matchers/utilities.js +0 -110
  130. package/node_modules/@shopify/react-testing/build/cjs/mount.js +0 -76
  131. package/node_modules/@shopify/react-testing/build/cjs/root.js +0 -284
  132. package/node_modules/@shopify/react-testing/build/cjs/toReactString.js +0 -86
  133. package/node_modules/@shopify/react-testing/build/cjs/types.js +0 -28
  134. package/node_modules/@shopify/react-testing/build/esm/TestWrapper.mjs +0 -44
  135. package/node_modules/@shopify/react-testing/build/esm/_virtual/_rollupPluginBabelHelpers.mjs +0 -42
  136. package/node_modules/@shopify/react-testing/build/esm/compat.mjs +0 -10
  137. package/node_modules/@shopify/react-testing/build/esm/destroy.mjs +0 -9
  138. package/node_modules/@shopify/react-testing/build/esm/element.mjs +0 -221
  139. package/node_modules/@shopify/react-testing/build/esm/index.mjs +0 -5
  140. package/node_modules/@shopify/react-testing/build/esm/matchers/components.mjs +0 -41
  141. package/node_modules/@shopify/react-testing/build/esm/matchers/context.mjs +0 -21
  142. package/node_modules/@shopify/react-testing/build/esm/matchers/index.mjs +0 -14
  143. package/node_modules/@shopify/react-testing/build/esm/matchers/props.mjs +0 -33
  144. package/node_modules/@shopify/react-testing/build/esm/matchers/strings.mjs +0 -37
  145. package/node_modules/@shopify/react-testing/build/esm/matchers/utilities.mjs +0 -101
  146. package/node_modules/@shopify/react-testing/build/esm/mount.mjs +0 -70
  147. package/node_modules/@shopify/react-testing/build/esm/root.mjs +0 -275
  148. package/node_modules/@shopify/react-testing/build/esm/toReactString.mjs +0 -80
  149. package/node_modules/@shopify/react-testing/build/esm/types.mjs +0 -26
  150. package/node_modules/@shopify/react-testing/build/esnext/TestWrapper.esnext +0 -44
  151. package/node_modules/@shopify/react-testing/build/esnext/compat.esnext +0 -10
  152. package/node_modules/@shopify/react-testing/build/esnext/destroy.esnext +0 -9
  153. package/node_modules/@shopify/react-testing/build/esnext/element.esnext +0 -221
  154. package/node_modules/@shopify/react-testing/build/esnext/index.esnext +0 -5
  155. package/node_modules/@shopify/react-testing/build/esnext/matchers/components.esnext +0 -41
  156. package/node_modules/@shopify/react-testing/build/esnext/matchers/context.esnext +0 -21
  157. package/node_modules/@shopify/react-testing/build/esnext/matchers/index.esnext +0 -14
  158. package/node_modules/@shopify/react-testing/build/esnext/matchers/props.esnext +0 -33
  159. package/node_modules/@shopify/react-testing/build/esnext/matchers/strings.esnext +0 -37
  160. package/node_modules/@shopify/react-testing/build/esnext/matchers/utilities.esnext +0 -99
  161. package/node_modules/@shopify/react-testing/build/esnext/mount.esnext +0 -71
  162. package/node_modules/@shopify/react-testing/build/esnext/root.esnext +0 -275
  163. package/node_modules/@shopify/react-testing/build/esnext/toReactString.esnext +0 -80
  164. package/node_modules/@shopify/react-testing/build/esnext/types.esnext +0 -26
  165. package/node_modules/@shopify/react-testing/build/ts/TestWrapper.d.ts +0 -17
  166. package/node_modules/@shopify/react-testing/build/ts/TestWrapper.d.ts.map +0 -1
  167. package/node_modules/@shopify/react-testing/build/ts/compat.d.ts +0 -3
  168. package/node_modules/@shopify/react-testing/build/ts/compat.d.ts.map +0 -1
  169. package/node_modules/@shopify/react-testing/build/ts/destroy.d.ts +0 -2
  170. package/node_modules/@shopify/react-testing/build/ts/destroy.d.ts.map +0 -1
  171. package/node_modules/@shopify/react-testing/build/ts/element.d.ts +0 -42
  172. package/node_modules/@shopify/react-testing/build/ts/element.d.ts.map +0 -1
  173. package/node_modules/@shopify/react-testing/build/ts/index.d.ts +0 -7
  174. package/node_modules/@shopify/react-testing/build/ts/index.d.ts.map +0 -1
  175. package/node_modules/@shopify/react-testing/build/ts/matchers/components.d.ts +0 -12
  176. package/node_modules/@shopify/react-testing/build/ts/matchers/components.d.ts.map +0 -1
  177. package/node_modules/@shopify/react-testing/build/ts/matchers/context.d.ts +0 -8
  178. package/node_modules/@shopify/react-testing/build/ts/matchers/context.d.ts.map +0 -1
  179. package/node_modules/@shopify/react-testing/build/ts/matchers/index.d.ts +0 -20
  180. package/node_modules/@shopify/react-testing/build/ts/matchers/index.d.ts.map +0 -1
  181. package/node_modules/@shopify/react-testing/build/ts/matchers/props.d.ts +0 -10
  182. package/node_modules/@shopify/react-testing/build/ts/matchers/props.d.ts.map +0 -1
  183. package/node_modules/@shopify/react-testing/build/ts/matchers/strings.d.ts +0 -11
  184. package/node_modules/@shopify/react-testing/build/ts/matchers/strings.d.ts.map +0 -1
  185. package/node_modules/@shopify/react-testing/build/ts/matchers/utilities.d.ts +0 -17
  186. package/node_modules/@shopify/react-testing/build/ts/matchers/utilities.d.ts.map +0 -1
  187. package/node_modules/@shopify/react-testing/build/ts/mount.d.ts +0 -39
  188. package/node_modules/@shopify/react-testing/build/ts/mount.d.ts.map +0 -1
  189. package/node_modules/@shopify/react-testing/build/ts/root.d.ts +0 -55
  190. package/node_modules/@shopify/react-testing/build/ts/root.d.ts.map +0 -1
  191. package/node_modules/@shopify/react-testing/build/ts/toReactString.d.ts +0 -5
  192. package/node_modules/@shopify/react-testing/build/ts/toReactString.d.ts.map +0 -1
  193. package/node_modules/@shopify/react-testing/build/ts/types.d.ts +0 -89
  194. package/node_modules/@shopify/react-testing/build/ts/types.d.ts.map +0 -1
  195. package/node_modules/@shopify/react-testing/index.esnext +0 -1
  196. package/node_modules/@shopify/react-testing/index.js +0 -1
  197. package/node_modules/@shopify/react-testing/index.mjs +0 -1
  198. package/node_modules/@shopify/react-testing/matchers.esnext +0 -1
  199. package/node_modules/@shopify/react-testing/matchers.js +0 -1
  200. package/node_modules/@shopify/react-testing/matchers.mjs +0 -1
  201. package/node_modules/@shopify/react-testing/package.json +0 -69
  202. package/node_modules/@shopify/ui-extensions-test-utils/CHANGELOG.md +0 -66
  203. package/node_modules/@shopify/ui-extensions-test-utils/dist/index.d.ts +0 -3
  204. package/node_modules/@shopify/ui-extensions-test-utils/dist/index.js +0 -3
  205. package/node_modules/@shopify/ui-extensions-test-utils/dist/render.d.ts +0 -2
  206. package/node_modules/@shopify/ui-extensions-test-utils/dist/render.js +0 -5
  207. package/node_modules/@shopify/ui-extensions-test-utils/dist/renderHook.d.ts +0 -17
  208. package/node_modules/@shopify/ui-extensions-test-utils/dist/renderHook.js +0 -20
  209. package/node_modules/@shopify/ui-extensions-test-utils/dist/withProviders.d.ts +0 -9
  210. package/node_modules/@shopify/ui-extensions-test-utils/dist/withProviders.js +0 -7
  211. package/node_modules/@shopify/ui-extensions-test-utils/package.json +0 -40
  212. package/node_modules/@shopify/ui-extensions-test-utils/project.json +0 -39
  213. package/node_modules/@vitejs/plugin-react-refresh/README.md +0 -73
  214. package/node_modules/@vitejs/plugin-react-refresh/index.d.ts +0 -14
  215. package/node_modules/@vitejs/plugin-react-refresh/index.js +0 -239
  216. package/node_modules/@vitejs/plugin-react-refresh/package.json +0 -35
  217. /package/dist/{ExtensionServerClient → packages/ui-extensions-server-kit/src/ExtensionServerClient}/types.cjs.js +0 -0
  218. /package/dist/{ExtensionServerClient → packages/ui-extensions-server-kit/src/ExtensionServerClient}/types.es.js +0 -0
  219. /package/dist/{context → packages/ui-extensions-server-kit/src/context}/constants.es.js +0 -0
  220. /package/dist/{hooks → packages/ui-extensions-server-kit/src/hooks}/useExtensionServerState.cjs.js +0 -0
  221. /package/dist/{hooks → packages/ui-extensions-server-kit/src/hooks}/useExtensionServerState.es.js +0 -0
  222. /package/dist/{hooks → packages/ui-extensions-server-kit/src/hooks}/useIsomorphicLayoutEffect.cjs.js +0 -0
  223. /package/dist/{hooks → packages/ui-extensions-server-kit/src/hooks}/useIsomorphicLayoutEffect.es.js +0 -0
  224. /package/dist/{i18n.cjs.js → packages/ui-extensions-server-kit/src/i18n.cjs.js} +0 -0
  225. /package/dist/{i18n.es.js → packages/ui-extensions-server-kit/src/i18n.es.js} +0 -0
  226. /package/dist/{state → packages/ui-extensions-server-kit/src/state}/actions/actions.cjs.js +0 -0
  227. /package/dist/{state → packages/ui-extensions-server-kit/src/state}/actions/actions.es.js +0 -0
  228. /package/dist/{state → packages/ui-extensions-server-kit/src/state}/reducers/constants.cjs.js +0 -0
  229. /package/dist/{state → packages/ui-extensions-server-kit/src/state}/reducers/constants.es.js +0 -0
  230. /package/dist/{state → packages/ui-extensions-server-kit/src/state}/reducers/extensionServerReducer.cjs.js +0 -0
  231. /package/dist/{state → packages/ui-extensions-server-kit/src/state}/reducers/extensionServerReducer.es.js +0 -0
  232. /package/dist/{testing → packages/ui-extensions-server-kit/src/testing}/app.cjs.js +0 -0
  233. /package/dist/{testing → packages/ui-extensions-server-kit/src/testing}/app.es.js +0 -0
  234. /package/dist/{types.cjs.js → packages/ui-extensions-server-kit/src/types.cjs.js} +0 -0
  235. /package/dist/{types.es.js → packages/ui-extensions-server-kit/src/types.es.js} +0 -0
  236. /package/dist/{utilities → packages/ui-extensions-server-kit/src/utilities}/assetToString.cjs.js +0 -0
  237. /package/dist/{utilities → packages/ui-extensions-server-kit/src/utilities}/assetToString.es.js +0 -0
  238. /package/dist/{utilities → packages/ui-extensions-server-kit/src/utilities}/noop.cjs.js +0 -0
  239. /package/dist/{utilities → packages/ui-extensions-server-kit/src/utilities}/noop.es.js +0 -0
  240. /package/dist/{utilities → packages/ui-extensions-server-kit/src/utilities}/replaceUpdated.cjs.js +0 -0
  241. /package/dist/{utilities → packages/ui-extensions-server-kit/src/utilities}/replaceUpdated.es.js +0 -0
  242. /package/dist/{utilities → packages/ui-extensions-server-kit/src/utilities}/set.cjs.js +0 -0
  243. /package/dist/{utilities → packages/ui-extensions-server-kit/src/utilities}/set.es.js +0 -0
  244. /package/node_modules/@vitejs/{plugin-react-refresh → plugin-react}/LICENSE +0 -0
@@ -0,0 +1,501 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+ var ReactDOM = require('react-dom');
7
+ var ReactDOMClient = require('react-dom/client');
8
+ var dom = require('@testing-library/dom');
9
+ var DeprecatedReactTestUtils = require('react-dom/test-utils');
10
+
11
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
12
+
13
+ function _interopNamespace(e) {
14
+ if (e && e.__esModule) return e;
15
+ var n = Object.create(null);
16
+ if (e) {
17
+ Object.keys(e).forEach(function (k) {
18
+ if (k !== 'default') {
19
+ var d = Object.getOwnPropertyDescriptor(e, k);
20
+ Object.defineProperty(n, k, d.get ? d : {
21
+ enumerable: true,
22
+ get: function () { return e[k]; }
23
+ });
24
+ }
25
+ });
26
+ }
27
+ n["default"] = e;
28
+ return Object.freeze(n);
29
+ }
30
+
31
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
32
+ var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
33
+ var ReactDOMClient__namespace = /*#__PURE__*/_interopNamespace(ReactDOMClient);
34
+ var DeprecatedReactTestUtils__namespace = /*#__PURE__*/_interopNamespace(DeprecatedReactTestUtils);
35
+
36
+ const reactAct = typeof React__namespace.act === 'function' ? React__namespace.act : DeprecatedReactTestUtils__namespace.act;
37
+ function getGlobalThis() {
38
+ /* istanbul ignore else */
39
+ if (typeof globalThis !== 'undefined') {
40
+ return globalThis;
41
+ }
42
+ /* istanbul ignore next */
43
+ if (typeof self !== 'undefined') {
44
+ return self;
45
+ }
46
+ /* istanbul ignore next */
47
+ if (typeof window !== 'undefined') {
48
+ return window;
49
+ }
50
+ /* istanbul ignore next */
51
+ if (typeof global !== 'undefined') {
52
+ return global;
53
+ }
54
+ /* istanbul ignore next */
55
+ throw new Error('unable to locate global object');
56
+ }
57
+ function setIsReactActEnvironment(isReactActEnvironment) {
58
+ getGlobalThis().IS_REACT_ACT_ENVIRONMENT = isReactActEnvironment;
59
+ }
60
+ function getIsReactActEnvironment() {
61
+ return getGlobalThis().IS_REACT_ACT_ENVIRONMENT;
62
+ }
63
+ function withGlobalActEnvironment(actImplementation) {
64
+ return callback => {
65
+ const previousActEnvironment = getIsReactActEnvironment();
66
+ setIsReactActEnvironment(true);
67
+ try {
68
+ // The return value of `act` is always a thenable.
69
+ let callbackNeedsToBeAwaited = false;
70
+ const actResult = actImplementation(() => {
71
+ const result = callback();
72
+ if (result !== null && typeof result === 'object' && typeof result.then === 'function') {
73
+ callbackNeedsToBeAwaited = true;
74
+ }
75
+ return result;
76
+ });
77
+ if (callbackNeedsToBeAwaited) {
78
+ const thenable = actResult;
79
+ return {
80
+ then: (resolve, reject) => {
81
+ thenable.then(returnValue => {
82
+ setIsReactActEnvironment(previousActEnvironment);
83
+ resolve(returnValue);
84
+ }, error => {
85
+ setIsReactActEnvironment(previousActEnvironment);
86
+ reject(error);
87
+ });
88
+ }
89
+ };
90
+ } else {
91
+ setIsReactActEnvironment(previousActEnvironment);
92
+ return actResult;
93
+ }
94
+ } catch (error) {
95
+ // Can't be a `finally {}` block since we don't know if we have to immediately restore IS_REACT_ACT_ENVIRONMENT
96
+ // or if we have to await the callback first.
97
+ setIsReactActEnvironment(previousActEnvironment);
98
+ throw error;
99
+ }
100
+ };
101
+ }
102
+ const act = withGlobalActEnvironment(reactAct);
103
+
104
+ /* eslint no-console:0 */
105
+
106
+ // react-testing-library's version of fireEvent will call
107
+ // dom-testing-library's version of fireEvent. The reason
108
+ // we make this distinction however is because we have
109
+ // a few extra events that work a bit differently
110
+ const fireEvent = (...args) => dom.fireEvent(...args);
111
+ Object.keys(dom.fireEvent).forEach(key => {
112
+ fireEvent[key] = (...args) => dom.fireEvent[key](...args);
113
+ });
114
+
115
+ // React event system tracks native mouseOver/mouseOut events for
116
+ // running onMouseEnter/onMouseLeave handlers
117
+ // @link https://github.com/facebook/react/blob/b87aabdfe1b7461e7331abb3601d9e6bb27544bc/packages/react-dom/src/events/EnterLeaveEventPlugin.js#L24-L31
118
+ const mouseEnter = fireEvent.mouseEnter;
119
+ const mouseLeave = fireEvent.mouseLeave;
120
+ fireEvent.mouseEnter = (...args) => {
121
+ mouseEnter(...args);
122
+ return fireEvent.mouseOver(...args);
123
+ };
124
+ fireEvent.mouseLeave = (...args) => {
125
+ mouseLeave(...args);
126
+ return fireEvent.mouseOut(...args);
127
+ };
128
+ const pointerEnter = fireEvent.pointerEnter;
129
+ const pointerLeave = fireEvent.pointerLeave;
130
+ fireEvent.pointerEnter = (...args) => {
131
+ pointerEnter(...args);
132
+ return fireEvent.pointerOver(...args);
133
+ };
134
+ fireEvent.pointerLeave = (...args) => {
135
+ pointerLeave(...args);
136
+ return fireEvent.pointerOut(...args);
137
+ };
138
+ const select = fireEvent.select;
139
+ fireEvent.select = (node, init) => {
140
+ select(node, init);
141
+ // React tracks this event only on focused inputs
142
+ node.focus();
143
+
144
+ // React creates this event when one of the following native events happens
145
+ // - contextMenu
146
+ // - mouseUp
147
+ // - dragEnd
148
+ // - keyUp
149
+ // - keyDown
150
+ // so we can use any here
151
+ // @link https://github.com/facebook/react/blob/b87aabdfe1b7461e7331abb3601d9e6bb27544bc/packages/react-dom/src/events/SelectEventPlugin.js#L203-L224
152
+ fireEvent.keyUp(node, init);
153
+ };
154
+
155
+ // React event system tracks native focusout/focusin events for
156
+ // running blur/focus handlers
157
+ // @link https://github.com/facebook/react/pull/19186
158
+ const blur = fireEvent.blur;
159
+ const focus = fireEvent.focus;
160
+ fireEvent.blur = (...args) => {
161
+ fireEvent.focusOut(...args);
162
+ return blur(...args);
163
+ };
164
+ fireEvent.focus = (...args) => {
165
+ fireEvent.focusIn(...args);
166
+ return focus(...args);
167
+ };
168
+
169
+ let configForRTL = {
170
+ reactStrictMode: false
171
+ };
172
+ function getConfig() {
173
+ return {
174
+ ...dom.getConfig(),
175
+ ...configForRTL
176
+ };
177
+ }
178
+ function configure(newConfig) {
179
+ if (typeof newConfig === 'function') {
180
+ // Pass the existing config out to the provided function
181
+ // and accept a delta in return
182
+ newConfig = newConfig(getConfig());
183
+ }
184
+ const {
185
+ reactStrictMode,
186
+ ...configForDTL
187
+ } = newConfig;
188
+ dom.configure(configForDTL);
189
+ configForRTL = {
190
+ ...configForRTL,
191
+ reactStrictMode
192
+ };
193
+ }
194
+
195
+ function jestFakeTimersAreEnabled() {
196
+ /* istanbul ignore else */
197
+ if (typeof jest !== 'undefined' && jest !== null) {
198
+ return (
199
+ // legacy timers
200
+ setTimeout._isMockFunction === true ||
201
+ // modern timers
202
+ // eslint-disable-next-line prefer-object-has-own -- No Object.hasOwn in all target environments we support.
203
+ Object.prototype.hasOwnProperty.call(setTimeout, 'clock')
204
+ );
205
+ } // istanbul ignore next
206
+
207
+ return false;
208
+ }
209
+ dom.configure({
210
+ unstable_advanceTimersWrapper: cb => {
211
+ return act(cb);
212
+ },
213
+ // We just want to run `waitFor` without IS_REACT_ACT_ENVIRONMENT
214
+ // But that's not necessarily how `asyncWrapper` is used since it's a public method.
215
+ // Let's just hope nobody else is using it.
216
+ asyncWrapper: async cb => {
217
+ const previousActEnvironment = getIsReactActEnvironment();
218
+ setIsReactActEnvironment(false);
219
+ try {
220
+ const result = await cb();
221
+ // Drain microtask queue.
222
+ // Otherwise we'll restore the previous act() environment, before we resolve the `waitFor` call.
223
+ // The caller would have no chance to wrap the in-flight Promises in `act()`
224
+ await new Promise(resolve => {
225
+ setTimeout(() => {
226
+ resolve();
227
+ }, 0);
228
+ if (jestFakeTimersAreEnabled()) {
229
+ jest.advanceTimersByTime(0);
230
+ }
231
+ });
232
+ return result;
233
+ } finally {
234
+ setIsReactActEnvironment(previousActEnvironment);
235
+ }
236
+ },
237
+ eventWrapper: cb => {
238
+ let result;
239
+ act(() => {
240
+ result = cb();
241
+ });
242
+ return result;
243
+ }
244
+ });
245
+
246
+ // Ideally we'd just use a WeakMap where containers are keys and roots are values.
247
+ // We use two variables so that we can bail out in constant time when we render with a new container (most common use case)
248
+ /**
249
+ * @type {Set<import('react-dom').Container>}
250
+ */
251
+ const mountedContainers = new Set();
252
+ /**
253
+ * @type Array<{container: import('react-dom').Container, root: ReturnType<typeof createConcurrentRoot>}>
254
+ */
255
+ const mountedRootEntries = [];
256
+ function strictModeIfNeeded(innerElement, reactStrictMode) {
257
+ return reactStrictMode ?? getConfig().reactStrictMode ? /*#__PURE__*/React__namespace.createElement(React__namespace.StrictMode, null, innerElement) : innerElement;
258
+ }
259
+ function wrapUiIfNeeded(innerElement, wrapperComponent) {
260
+ return wrapperComponent ? /*#__PURE__*/React__namespace.createElement(wrapperComponent, null, innerElement) : innerElement;
261
+ }
262
+ function createConcurrentRoot(container, {
263
+ hydrate,
264
+ onCaughtError,
265
+ onRecoverableError,
266
+ ui,
267
+ wrapper: WrapperComponent,
268
+ reactStrictMode
269
+ }) {
270
+ let root;
271
+ if (hydrate) {
272
+ act(() => {
273
+ root = ReactDOMClient__namespace.hydrateRoot(container, strictModeIfNeeded(wrapUiIfNeeded(ui, WrapperComponent), reactStrictMode), {
274
+ onCaughtError,
275
+ onRecoverableError
276
+ });
277
+ });
278
+ } else {
279
+ root = ReactDOMClient__namespace.createRoot(container, {
280
+ onCaughtError,
281
+ onRecoverableError
282
+ });
283
+ }
284
+ return {
285
+ hydrate() {
286
+ /* istanbul ignore if */
287
+ if (!hydrate) {
288
+ throw new Error('Attempted to hydrate a non-hydrateable root. This is a bug in `@testing-library/react`.');
289
+ }
290
+ // Nothing to do since hydration happens when creating the root object.
291
+ },
292
+ render(element) {
293
+ root.render(element);
294
+ },
295
+ unmount() {
296
+ root.unmount();
297
+ }
298
+ };
299
+ }
300
+ function createLegacyRoot(container) {
301
+ return {
302
+ hydrate(element) {
303
+ ReactDOM__default["default"].hydrate(element, container);
304
+ },
305
+ render(element) {
306
+ ReactDOM__default["default"].render(element, container);
307
+ },
308
+ unmount() {
309
+ ReactDOM__default["default"].unmountComponentAtNode(container);
310
+ }
311
+ };
312
+ }
313
+ function renderRoot(ui, {
314
+ baseElement,
315
+ container,
316
+ hydrate,
317
+ queries,
318
+ root,
319
+ wrapper: WrapperComponent,
320
+ reactStrictMode
321
+ }) {
322
+ act(() => {
323
+ if (hydrate) {
324
+ root.hydrate(strictModeIfNeeded(wrapUiIfNeeded(ui, WrapperComponent), reactStrictMode), container);
325
+ } else {
326
+ root.render(strictModeIfNeeded(wrapUiIfNeeded(ui, WrapperComponent), reactStrictMode), container);
327
+ }
328
+ });
329
+ return {
330
+ container,
331
+ baseElement,
332
+ debug: (el = baseElement, maxLength, options) => Array.isArray(el) ?
333
+ // eslint-disable-next-line no-console
334
+ el.forEach(e => console.log(dom.prettyDOM(e, maxLength, options))) :
335
+ // eslint-disable-next-line no-console,
336
+ console.log(dom.prettyDOM(el, maxLength, options)),
337
+ unmount: () => {
338
+ act(() => {
339
+ root.unmount();
340
+ });
341
+ },
342
+ rerender: rerenderUi => {
343
+ renderRoot(rerenderUi, {
344
+ container,
345
+ baseElement,
346
+ root,
347
+ wrapper: WrapperComponent,
348
+ reactStrictMode
349
+ });
350
+ // Intentionally do not return anything to avoid unnecessarily complicating the API.
351
+ // folks can use all the same utilities we return in the first place that are bound to the container
352
+ },
353
+ asFragment: () => {
354
+ /* istanbul ignore else (old jsdom limitation) */
355
+ if (typeof document.createRange === 'function') {
356
+ return document.createRange().createContextualFragment(container.innerHTML);
357
+ } else {
358
+ const template = document.createElement('template');
359
+ template.innerHTML = container.innerHTML;
360
+ return template.content;
361
+ }
362
+ },
363
+ ...dom.getQueriesForElement(baseElement, queries)
364
+ };
365
+ }
366
+ function render(ui, {
367
+ container,
368
+ baseElement = container,
369
+ legacyRoot = false,
370
+ onCaughtError,
371
+ onUncaughtError,
372
+ onRecoverableError,
373
+ queries,
374
+ hydrate = false,
375
+ wrapper,
376
+ reactStrictMode
377
+ } = {}) {
378
+ if (onUncaughtError !== undefined) {
379
+ throw new Error('onUncaughtError is not supported. The `render` call will already throw on uncaught errors.');
380
+ }
381
+ if (legacyRoot && typeof ReactDOM__default["default"].render !== 'function') {
382
+ const error = new Error('`legacyRoot: true` is not supported in this version of React. ' + 'If your app runs React 19 or later, you should remove this flag. ' + 'If your app runs React 18 or earlier, visit https://react.dev/blog/2022/03/08/react-18-upgrade-guide for upgrade instructions.');
383
+ Error.captureStackTrace(error, render);
384
+ throw error;
385
+ }
386
+ if (!baseElement) {
387
+ // default to document.body instead of documentElement to avoid output of potentially-large
388
+ // head elements (such as JSS style blocks) in debug output
389
+ baseElement = document.body;
390
+ }
391
+ if (!container) {
392
+ container = baseElement.appendChild(document.createElement('div'));
393
+ }
394
+ let root;
395
+ // eslint-disable-next-line no-negated-condition -- we want to map the evolution of this over time. The root is created first. Only later is it re-used so we don't want to read the case that happens later first.
396
+ if (!mountedContainers.has(container)) {
397
+ const createRootImpl = legacyRoot ? createLegacyRoot : createConcurrentRoot;
398
+ root = createRootImpl(container, {
399
+ hydrate,
400
+ onCaughtError,
401
+ onRecoverableError,
402
+ ui,
403
+ wrapper,
404
+ reactStrictMode
405
+ });
406
+ mountedRootEntries.push({
407
+ container,
408
+ root
409
+ });
410
+ // we'll add it to the mounted containers regardless of whether it's actually
411
+ // added to document.body so the cleanup method works regardless of whether
412
+ // they're passing us a custom container or not.
413
+ mountedContainers.add(container);
414
+ } else {
415
+ mountedRootEntries.forEach(rootEntry => {
416
+ // Else is unreachable since `mountedContainers` has the `container`.
417
+ // Only reachable if one would accidentally add the container to `mountedContainers` but not the root to `mountedRootEntries`
418
+ /* istanbul ignore else */
419
+ if (rootEntry.container === container) {
420
+ root = rootEntry.root;
421
+ }
422
+ });
423
+ }
424
+ return renderRoot(ui, {
425
+ container,
426
+ baseElement,
427
+ queries,
428
+ hydrate,
429
+ wrapper,
430
+ root,
431
+ reactStrictMode
432
+ });
433
+ }
434
+ function cleanup() {
435
+ mountedRootEntries.forEach(({
436
+ root,
437
+ container
438
+ }) => {
439
+ act(() => {
440
+ root.unmount();
441
+ });
442
+ if (container.parentNode === document.body) {
443
+ document.body.removeChild(container);
444
+ }
445
+ });
446
+ mountedRootEntries.length = 0;
447
+ mountedContainers.clear();
448
+ }
449
+ function renderHook(renderCallback, options = {}) {
450
+ const {
451
+ initialProps,
452
+ ...renderOptions
453
+ } = options;
454
+ if (renderOptions.legacyRoot && typeof ReactDOM__default["default"].render !== 'function') {
455
+ const error = new Error('`legacyRoot: true` is not supported in this version of React. ' + 'If your app runs React 19 or later, you should remove this flag. ' + 'If your app runs React 18 or earlier, visit https://react.dev/blog/2022/03/08/react-18-upgrade-guide for upgrade instructions.');
456
+ Error.captureStackTrace(error, renderHook);
457
+ throw error;
458
+ }
459
+ const result = /*#__PURE__*/React__namespace.createRef();
460
+ function TestComponent({
461
+ renderCallbackProps
462
+ }) {
463
+ const pendingResult = renderCallback(renderCallbackProps);
464
+ React__namespace.useEffect(() => {
465
+ result.current = pendingResult;
466
+ });
467
+ return null;
468
+ }
469
+ const {
470
+ rerender: baseRerender,
471
+ unmount
472
+ } = render(/*#__PURE__*/React__namespace.createElement(TestComponent, {
473
+ renderCallbackProps: initialProps
474
+ }), renderOptions);
475
+ function rerender(rerenderCallbackProps) {
476
+ return baseRerender(/*#__PURE__*/React__namespace.createElement(TestComponent, {
477
+ renderCallbackProps: rerenderCallbackProps
478
+ }));
479
+ }
480
+ return {
481
+ result,
482
+ rerender,
483
+ unmount
484
+ };
485
+ }
486
+
487
+ /* eslint func-name-matching:0 */
488
+
489
+ exports.act = act;
490
+ exports.cleanup = cleanup;
491
+ exports.configure = configure;
492
+ exports.fireEvent = fireEvent;
493
+ exports.getConfig = getConfig;
494
+ exports.render = render;
495
+ exports.renderHook = renderHook;
496
+ Object.keys(dom).forEach(function (k) {
497
+ if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
498
+ enumerable: true,
499
+ get: function () { return dom[k]; }
500
+ });
501
+ });