@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
@@ -1,76 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var _rollupPluginBabelHelpers = require('./_virtual/_rollupPluginBabelHelpers.js');
6
- var root = require('./root.js');
7
-
8
- function mount(element) {
9
- return new root.Root(element);
10
- }
11
- class CustomRoot extends root.Root {
12
- constructor(tree, context, options) {
13
- super(tree, options);
14
- this.context = context;
15
- }
16
-
17
- }
18
- function createMount({
19
- render,
20
- context: createContext = defaultContext,
21
- afterMount = defaultAfterMount,
22
- cleanup
23
- }) {
24
- function mount(element, options = {}) {
25
- const context = createContext(options);
26
- const wrapper = new CustomRoot(element, context, {
27
- render: element => render(element, context, options),
28
- resolveRoot: root => root.find(element.type)
29
- });
30
-
31
- if (cleanup) {
32
- const originalDestroy = wrapper.destroy.bind(wrapper);
33
-
34
- wrapper.destroy = () => {
35
- cleanup(wrapper, options);
36
- originalDestroy();
37
- };
38
- }
39
-
40
- const afterMountResult = afterMount(wrapper, options);
41
- return afterMountResult != null && 'then' in afterMountResult ? afterMountResult.then(() => wrapper) : wrapper;
42
- }
43
-
44
- Reflect.defineProperty(mount, 'extend', {
45
- writable: false,
46
- value: ({
47
- context: createAdditionalContext = defaultContext,
48
- render: additionalRender,
49
- afterMount: additionalAfterMount = defaultAfterMount
50
- }) => {
51
- return createMount({
52
- context: options => _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, createContext(options)), createAdditionalContext(options)),
53
- render: (element, context, options) => render(additionalRender(element, context, options), context, options),
54
- afterMount: (wrapper, options) => {
55
- const result = additionalAfterMount(wrapper, options);
56
-
57
- const finalResult = () => afterMount(wrapper, options);
58
-
59
- return result != null && 'then' in result ? result.then(finalResult) : finalResult();
60
- }
61
- });
62
- }
63
- });
64
- return mount;
65
- }
66
-
67
- function defaultContext() {
68
- return {};
69
- }
70
-
71
- function defaultAfterMount() {}
72
-
73
- exports.Root = root.Root;
74
- exports.CustomRoot = CustomRoot;
75
- exports.createMount = createMount;
76
- exports.mount = mount;
@@ -1,284 +0,0 @@
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 testUtils = require('react-dom/test-utils');
8
- var TestWrapper = require('./TestWrapper.js');
9
- var element = require('./element.js');
10
- var compat = require('./compat.js');
11
- var types = require('./types.js');
12
-
13
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
14
-
15
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
16
-
17
- const {
18
- findCurrentFiberUsingSlowPath
19
- } = require('react-reconciler/reflection');
20
-
21
- const connected = new Set();
22
- class Root {
23
- get props() {
24
- return this.withRoot(root => root.props);
25
- }
26
-
27
- get isDOM() {
28
- return this.withRoot(root => root.isDOM);
29
- }
30
-
31
- get type() {
32
- return this.withRoot(root => root.type);
33
- }
34
-
35
- get instance() {
36
- return this.withRoot(root => root.instance);
37
- }
38
-
39
- get children() {
40
- return this.withRoot(root => root.children);
41
- }
42
-
43
- get descendants() {
44
- return this.withRoot(root => root.descendants);
45
- }
46
-
47
- get domNodes() {
48
- return this.withRoot(root => root.domNodes);
49
- }
50
-
51
- get domNode() {
52
- return this.withRoot(root => root.domNode);
53
- }
54
-
55
- get mounted() {
56
- return this.wrapper != null;
57
- }
58
-
59
- constructor(tree, {
60
- render = defaultRender,
61
- resolveRoot = defaultResolveRoot
62
- } = {}) {
63
- this.tree = tree;
64
- this.wrapper = null;
65
- this.element = document.createElement('div');
66
- this.root = null;
67
- this.acting = false;
68
- this.render = void 0;
69
- this.resolveRoot = void 0;
70
- this.render = render;
71
- this.resolveRoot = resolveRoot;
72
- this.mount();
73
- }
74
-
75
- act(action, {
76
- update = true
77
- } = {}) {
78
- const updateWrapper = update ? this.update.bind(this) : noop;
79
- let result;
80
-
81
- if (this.acting) {
82
- return action();
83
- }
84
-
85
- this.acting = true;
86
-
87
- const afterResolve = () => {
88
- updateWrapper();
89
- this.acting = false;
90
- return result;
91
- };
92
-
93
- const promise = testUtils.act(() => {
94
- result = action(); // This condition checks the returned value is an actual Promise and returns it
95
- // to React’s `act()` call, otherwise we just want to return `undefined`
96
-
97
- if (isPromise(result)) {
98
- return result;
99
- }
100
-
101
- return undefined;
102
- });
103
-
104
- if (isPromise(result)) {
105
- updateWrapper();
106
- return Promise.resolve(promise).then(afterResolve);
107
- }
108
-
109
- return afterResolve();
110
- }
111
-
112
- html() {
113
- return this.withRoot(root => root.html());
114
- }
115
-
116
- text() {
117
- return this.withRoot(root => root.text());
118
- }
119
-
120
- is(type) {
121
- return this.withRoot(root => root.is(type));
122
- }
123
-
124
- prop(key) {
125
- return this.withRoot(root => root.prop(key));
126
- }
127
-
128
- data(key) {
129
- return this.withRoot(root => root.data(key));
130
- }
131
-
132
- find(type, props) {
133
- return this.withRoot(root => root.find(type, props));
134
- }
135
-
136
- findAll(type, props) {
137
- return this.withRoot(root => root.findAll(type, props));
138
- }
139
-
140
- findWhere(predicate) {
141
- return this.withRoot(root => root.findWhere(predicate));
142
- }
143
-
144
- findAllWhere(predicate) {
145
- return this.withRoot(root => root.findAllWhere(predicate));
146
- }
147
-
148
- trigger(prop, ...args) {
149
- return this.withRoot(root => root.trigger(prop, ...args));
150
- }
151
-
152
- triggerKeypath(keypath, ...args) {
153
- return this.withRoot(root => root.triggerKeypath(keypath, ...args));
154
- }
155
-
156
- mount() {
157
- if (this.mounted) {
158
- throw new Error('Attempted to mount a node that was already mounted');
159
- }
160
-
161
- if (this.element.parentNode == null) {
162
- document.body.appendChild(this.element);
163
- connected.add(this);
164
- }
165
-
166
- this.act(() => {
167
- reactDom.render( /*#__PURE__*/React__default["default"].createElement(TestWrapper.TestWrapper, {
168
- render: this.render,
169
- ref: wrapper => {
170
- this.wrapper = wrapper;
171
- }
172
- }, this.tree), this.element);
173
- });
174
- }
175
-
176
- unmount() {
177
- if (!this.mounted) {
178
- throw new Error('You attempted to unmount a node that was already unmounted');
179
- }
180
-
181
- this.ensureRoot();
182
- this.act(() => reactDom.unmountComponentAtNode(this.element));
183
- }
184
-
185
- destroy() {
186
- const {
187
- element,
188
- mounted
189
- } = this;
190
-
191
- if (mounted) {
192
- this.unmount();
193
- }
194
-
195
- element.remove();
196
- connected.delete(this);
197
- }
198
-
199
- setProps(props) {
200
- this.ensureRoot();
201
- this.act(() => this.wrapper.setProps(props));
202
- }
203
-
204
- forceUpdate() {
205
- this.ensureRoot();
206
- this.act(() => this.wrapper.forceUpdate());
207
- }
208
-
209
- debug(options) {
210
- this.ensureRoot();
211
- return this.root.debug(options);
212
- }
213
-
214
- toString() {
215
- return this.withRoot(root => root.toString());
216
- }
217
-
218
- update() {
219
- if (this.wrapper == null) {
220
- this.root = null;
221
- } else {
222
- const rootFiber = compat.getInternals(this.wrapper.rootRef);
223
- const topElement = fiberToElement(findCurrentFiberUsingSlowPath(rootFiber), this);
224
- this.root = this.resolveRoot(topElement);
225
- }
226
- }
227
-
228
- ensureRoot() {
229
- if (this.wrapper == null || this.root == null) {
230
- throw new Error('Attempted to operate on a mounted tree, but the component is no longer mounted');
231
- }
232
- }
233
-
234
- withRoot(withRoot) {
235
- this.ensureRoot();
236
- return withRoot(this.root);
237
- }
238
-
239
- }
240
-
241
- function defaultResolveRoot(element) {
242
- return element.children[0];
243
- }
244
-
245
- function defaultRender(element) {
246
- return element;
247
- }
248
-
249
- function fiberToElement(node, root) {
250
- if (node.tag === types.Tag.HostText) {
251
- return node.memoizedProps;
252
- }
253
-
254
- const props = node.memoizedProps;
255
- const children = childrenToTree(node.child, root);
256
- return new element.Element({
257
- tag: node.tag,
258
- type: node.type,
259
- props,
260
- instance: node.stateNode
261
- }, children, root);
262
- }
263
-
264
- function childrenToTree(fiber, root) {
265
- let currentFiber = fiber;
266
- const children = [];
267
-
268
- while (currentFiber != null) {
269
- const result = fiberToElement(currentFiber, root);
270
- children.push(result);
271
- currentFiber = currentFiber.sibling;
272
- }
273
-
274
- return children;
275
- }
276
-
277
- function isPromise(promise) {
278
- return promise != null && typeof promise === 'object' && 'then' in promise;
279
- }
280
-
281
- function noop() {}
282
-
283
- exports.Root = Root;
284
- exports.connected = connected;
@@ -1,86 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var jestMatcherUtils = require('jest-matcher-utils');
6
-
7
- function toReactString(node, options = {}, level = 0) {
8
- // if this is an array node then print all children at the current level
9
- if (!node.type && node.children.length > 0) {
10
- return node.children.map(child => toReactString(child, options, level)).join('\n');
11
- }
12
-
13
- const name = nodeName(node);
14
- const indent = ' '.repeat(level);
15
- const props = Object.keys(node.props) // we always filter out children no matter what, but unless allProps option
16
- // is present we will also filter out insigificant props
17
- .filter(key => options.allProps ? key !== 'children' : !/^(children|className)$|^(aria|data)-/.test(key)).reduce((list, key) => {
18
- if (!key) {
19
- return list;
20
- }
21
-
22
- const value = node.props[key];
23
-
24
- if (value === undefined && !options.allProps) {
25
- return list;
26
- }
27
-
28
- list.push(toPropString(key, value, options.verbosity));
29
- return list;
30
- }, []);
31
- const hasChildren = node.children.length > 0 && !['svg'].includes(name);
32
- const open = `${indent}<${name}${props.length > 0 ? ` ${props.join(' ')}` : ''}${hasChildren ? '>' : ' />'}`;
33
-
34
- if (!hasChildren) {
35
- return open;
36
- }
37
-
38
- const close = `${indent}</${name}>`;
39
-
40
- if (options.depth != null && level >= options.depth) {
41
- return [open, `${indent} {/* <${node.children.length} child${node.children.length === 1 ? '' : 'ren'}... /> */}`, close].join('\n');
42
- }
43
-
44
- return [open, ...node.children.map(child => toReactString(child, options, level + 1)), close].join('\n');
45
- }
46
- function toPropString(key, value, verbosity = 1) {
47
- if (value === undefined) {
48
- return `${key}={undefined}`;
49
- }
50
-
51
- if (value === null) {
52
- return `${key}={null}`;
53
- }
54
-
55
- if (typeof value === 'string') {
56
- return `${key}="${value}"`;
57
- }
58
-
59
- if (typeof value === 'boolean' && value) {
60
- return value ? `${key}` : `${key}={false}`;
61
- }
62
-
63
- if (value instanceof Array) {
64
- return `${key}={${jestMatcherUtils.stringify(value, verbosity + 1)}}`;
65
- }
66
-
67
- return `${key}={${jestMatcherUtils.stringify(value, verbosity)}}`;
68
- }
69
- function nodeName({
70
- type
71
- }) {
72
- if (type && typeof type === 'object' && '_context' in type) {
73
- const context = type._context;
74
- return `${context.displayName || 'Context'}.${type === context.Provider ? 'Provider' : 'Consumer'}`;
75
- }
76
-
77
- if (type == null) {
78
- return 'Node';
79
- }
80
-
81
- return typeof type === 'string' ? type : type.displayName || type.name || 'Component';
82
- }
83
-
84
- exports.nodeName = nodeName;
85
- exports.toPropString = toPropString;
86
- exports.toReactString = toReactString;
@@ -1,28 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- // https://github.com/facebook/react/blob/master/packages/shared/ReactWorkTag.js
6
- exports.Tag = void 0;
7
-
8
- (function (Tag) {
9
- Tag[Tag["FunctionComponent"] = 0] = "FunctionComponent";
10
- Tag[Tag["ClassComponent"] = 1] = "ClassComponent";
11
- Tag[Tag["IndeterminateComponent"] = 2] = "IndeterminateComponent";
12
- Tag[Tag["HostRoot"] = 3] = "HostRoot";
13
- Tag[Tag["HostPortal"] = 4] = "HostPortal";
14
- Tag[Tag["HostComponent"] = 5] = "HostComponent";
15
- Tag[Tag["HostText"] = 6] = "HostText";
16
- Tag[Tag["Fragment"] = 7] = "Fragment";
17
- Tag[Tag["Mode"] = 8] = "Mode";
18
- Tag[Tag["ContextConsumer"] = 9] = "ContextConsumer";
19
- Tag[Tag["ContextProvider"] = 10] = "ContextProvider";
20
- Tag[Tag["ForwardRef"] = 11] = "ForwardRef";
21
- Tag[Tag["Profiler"] = 12] = "Profiler";
22
- Tag[Tag["SuspenseComponent"] = 13] = "SuspenseComponent";
23
- Tag[Tag["MemoComponent"] = 14] = "MemoComponent";
24
- Tag[Tag["SimpleMemoComponent"] = 15] = "SimpleMemoComponent";
25
- Tag[Tag["LazyComponent"] = 16] = "LazyComponent";
26
- Tag[Tag["IncompleteClassComponent"] = 17] = "IncompleteClassComponent";
27
- Tag[Tag["DehydratedSuspenseComponent"] = 18] = "DehydratedSuspenseComponent";
28
- })(exports.Tag || (exports.Tag = {}));
@@ -1,44 +0,0 @@
1
- import React from 'react';
2
-
3
- class TestWrapper extends React.Component {
4
- constructor(...args) {
5
- super(...args);
6
- this.state = {};
7
- this.rootRef = null;
8
-
9
- this.setRef = ref => {
10
- this.rootRef = ref;
11
- };
12
- }
13
-
14
- // eslint-disable-next-line @shopify/react-prefer-private-members
15
- setProps(props) {
16
- this.setState({
17
- props
18
- });
19
- }
20
-
21
- render() {
22
- const {
23
- props
24
- } = this.state;
25
- const {
26
- children,
27
- render
28
- } = this.props;
29
- const rootElement = props ? /*#__PURE__*/React.cloneElement(children, props) : children;
30
- return render( /*#__PURE__*/React.createElement(TestInnerWrapper, {
31
- ref: this.setRef
32
- }, rootElement));
33
- }
34
-
35
- }
36
-
37
- class TestInnerWrapper extends React.Component {
38
- render() {
39
- return this.props.children;
40
- }
41
-
42
- }
43
-
44
- export { TestWrapper };
@@ -1,42 +0,0 @@
1
- function ownKeys(object, enumerableOnly) {
2
- var keys = Object.keys(object);
3
-
4
- if (Object.getOwnPropertySymbols) {
5
- var symbols = Object.getOwnPropertySymbols(object);
6
- enumerableOnly && (symbols = symbols.filter(function (sym) {
7
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
8
- })), keys.push.apply(keys, symbols);
9
- }
10
-
11
- return keys;
12
- }
13
-
14
- function _objectSpread2(target) {
15
- for (var i = 1; i < arguments.length; i++) {
16
- var source = null != arguments[i] ? arguments[i] : {};
17
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
18
- _defineProperty(target, key, source[key]);
19
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
20
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
21
- });
22
- }
23
-
24
- return target;
25
- }
26
-
27
- function _defineProperty(obj, key, value) {
28
- if (key in obj) {
29
- Object.defineProperty(obj, key, {
30
- value: value,
31
- enumerable: true,
32
- configurable: true,
33
- writable: true
34
- });
35
- } else {
36
- obj[key] = value;
37
- }
38
-
39
- return obj;
40
- }
41
-
42
- export { _defineProperty as defineProperty, _objectSpread2 as objectSpread2 };
@@ -1,10 +0,0 @@
1
- function getInternals(instance) {
2
- // In React 17+ _reactInternalFiber was renamed to _reactInternals. As such we need to handle both APIs to maintain support.
3
- if ('_reactInternalFiber' in instance) {
4
- return instance._reactInternalFiber;
5
- }
6
-
7
- return instance._reactInternals;
8
- }
9
-
10
- export { getInternals };
@@ -1,9 +0,0 @@
1
- import { connected } from './root.mjs';
2
-
3
- function destroyAll() {
4
- for (const wrapper of [...connected]) {
5
- wrapper.destroy();
6
- }
7
- }
8
-
9
- export { destroyAll };