@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,44 @@
1
+ import * as React from "./";
2
+ export { Fragment } from "./";
3
+
4
+ export namespace JSX {
5
+ interface Element extends React.JSX.Element {}
6
+ interface ElementClass extends React.JSX.ElementClass {}
7
+ interface ElementAttributesProperty extends React.JSX.ElementAttributesProperty {}
8
+ interface ElementChildrenAttribute extends React.JSX.ElementChildrenAttribute {}
9
+ type LibraryManagedAttributes<C, P> = React.JSX.LibraryManagedAttributes<C, P>;
10
+ interface IntrinsicAttributes extends React.JSX.IntrinsicAttributes {}
11
+ interface IntrinsicClassAttributes<T> extends React.JSX.IntrinsicClassAttributes<T> {}
12
+ interface IntrinsicElements extends React.JSX.IntrinsicElements {}
13
+ }
14
+
15
+ export interface JSXSource {
16
+ /**
17
+ * The source file where the element originates from.
18
+ */
19
+ fileName?: string | undefined;
20
+
21
+ /**
22
+ * The line number where the element was created.
23
+ */
24
+ lineNumber?: number | undefined;
25
+
26
+ /**
27
+ * The column number where the element was created.
28
+ */
29
+ columnNumber?: number | undefined;
30
+ }
31
+
32
+ /**
33
+ * Create a React element.
34
+ *
35
+ * You should not use this function directly. Use JSX and a transpiler instead.
36
+ */
37
+ export function jsxDEV(
38
+ type: React.ElementType,
39
+ props: unknown,
40
+ key: React.Key | undefined,
41
+ isStatic: boolean,
42
+ source?: JSXSource,
43
+ self?: unknown,
44
+ ): React.ReactElement;
@@ -0,0 +1,35 @@
1
+ import * as React from "./";
2
+ export { Fragment } from "./";
3
+
4
+ export namespace JSX {
5
+ interface Element extends React.JSX.Element {}
6
+ interface ElementClass extends React.JSX.ElementClass {}
7
+ interface ElementAttributesProperty extends React.JSX.ElementAttributesProperty {}
8
+ interface ElementChildrenAttribute extends React.JSX.ElementChildrenAttribute {}
9
+ type LibraryManagedAttributes<C, P> = React.JSX.LibraryManagedAttributes<C, P>;
10
+ interface IntrinsicAttributes extends React.JSX.IntrinsicAttributes {}
11
+ interface IntrinsicClassAttributes<T> extends React.JSX.IntrinsicClassAttributes<T> {}
12
+ interface IntrinsicElements extends React.JSX.IntrinsicElements {}
13
+ }
14
+
15
+ /**
16
+ * Create a React element.
17
+ *
18
+ * You should not use this function directly. Use JSX and a transpiler instead.
19
+ */
20
+ export function jsx(
21
+ type: React.ElementType,
22
+ props: unknown,
23
+ key?: React.Key,
24
+ ): React.ReactElement;
25
+
26
+ /**
27
+ * Create a React element.
28
+ *
29
+ * You should not use this function directly. Use JSX and a transpiler instead.
30
+ */
31
+ export function jsxs(
32
+ type: React.ElementType,
33
+ props: unknown,
34
+ key?: React.Key,
35
+ ): React.ReactElement;
@@ -0,0 +1,159 @@
1
+ # @vitejs/plugin-react [![npm](https://img.shields.io/npm/v/@vitejs/plugin-react.svg)](https://npmjs.com/package/@vitejs/plugin-react)
2
+
3
+ The default Vite plugin for React projects.
4
+
5
+ - enable [Fast Refresh](https://www.npmjs.com/package/react-refresh) in development (requires react >= 16.9)
6
+ - use the [automatic JSX runtime](https://legacy.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html)
7
+ - use custom Babel plugins/presets
8
+ - small installation size
9
+
10
+ ```js
11
+ // vite.config.js
12
+ import { defineConfig } from 'vite'
13
+ import react from '@vitejs/plugin-react'
14
+
15
+ export default defineConfig({
16
+ plugins: [react()],
17
+ })
18
+ ```
19
+
20
+ ## Options
21
+
22
+ ### include
23
+
24
+ Includes `.js`, `.jsx`, `.ts` & `.tsx` by default. This option can be used to add fast refresh to `.mdx` files:
25
+
26
+ ```js
27
+ import { defineConfig } from 'vite'
28
+ import react from '@vitejs/plugin-react'
29
+ import mdx from '@mdx-js/rollup'
30
+
31
+ export default defineConfig({
32
+ plugins: [
33
+ { enforce: 'pre', ...mdx() },
34
+ react({ include: /\.(mdx|js|jsx|ts|tsx)$/ }),
35
+ ],
36
+ })
37
+ ```
38
+
39
+ ### exclude
40
+
41
+ The default value is `/node_modules/`. You may use it to exclude JSX/TSX files that runs in a worker or are not React files.
42
+ Except if explicitly desired, you should keep `node_modules` in the exclude list:
43
+
44
+ ```js
45
+ import { defineConfig } from 'vite'
46
+ import react from '@vitejs/plugin-react'
47
+
48
+ export default defineConfig({
49
+ plugins: [
50
+ react({ exclude: [/\/pdf\//, /\.solid\.tsx$/, /\/node_modules\//] }),
51
+ ],
52
+ })
53
+ ```
54
+
55
+ ### jsxImportSource
56
+
57
+ Control where the JSX factory is imported from. By default, this is inferred from `jsxImportSource` from corresponding a tsconfig file for a transformed file.
58
+
59
+ ```js
60
+ react({ jsxImportSource: '@emotion/react' })
61
+ ```
62
+
63
+ ### jsxRuntime
64
+
65
+ By default, the plugin uses the [automatic JSX runtime](https://legacy.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html). However, if you encounter any issues, you may opt out using the `jsxRuntime` option.
66
+
67
+ ```js
68
+ react({ jsxRuntime: 'classic' })
69
+ ```
70
+
71
+ ### babel
72
+
73
+ The `babel` option lets you add plugins, presets, and [other configuration](https://babeljs.io/docs/en/options) to the Babel transformation performed on each included file.
74
+
75
+ ```js
76
+ react({
77
+ babel: {
78
+ presets: [...],
79
+ // Your plugins run before any built-in transform (eg: Fast Refresh)
80
+ plugins: [...],
81
+ // Use .babelrc files
82
+ babelrc: true,
83
+ // Use babel.config.js files
84
+ configFile: true,
85
+ }
86
+ })
87
+ ```
88
+
89
+ Note: When not using plugins, only esbuild is used for production builds, resulting in faster builds.
90
+
91
+ #### Proposed syntax
92
+
93
+ If you are using ES syntax that are still in proposal status (e.g. class properties), you can selectively enable them with the `babel.parserOpts.plugins` option:
94
+
95
+ ```js
96
+ react({
97
+ babel: {
98
+ parserOpts: {
99
+ plugins: ['decorators-legacy'],
100
+ },
101
+ },
102
+ })
103
+ ```
104
+
105
+ This option does not enable _code transformation_. That is handled by esbuild.
106
+
107
+ **Note:** TypeScript syntax is handled automatically.
108
+
109
+ Here's the [complete list of Babel parser plugins](https://babeljs.io/docs/en/babel-parser#ecmascript-proposalshttpsgithubcombabelproposals).
110
+
111
+ ### reactRefreshHost
112
+
113
+ The `reactRefreshHost` option is only necessary in a module federation context. It enables HMR to work between a remote & host application. In your remote Vite config, you would add your host origin:
114
+
115
+ ```js
116
+ react({ reactRefreshHost: 'http://localhost:3000' })
117
+ ```
118
+
119
+ Under the hood, this simply updates the React Fash Refresh runtime URL from `/@react-refresh` to `http://localhost:3000/@react-refresh` to ensure there is only one Refresh runtime across the whole application. Note that if you define `base` option in the host application, you need to include it in the option, like: `http://localhost:3000/{base}`.
120
+
121
+ ## `@vitejs/plugin-react/preamble`
122
+
123
+ The package provides `@vitejs/plugin-react/preamble` to initialize HMR runtime from client entrypoint for SSR applications which don't use [`transformIndexHtml` API](https://vite.dev/guide/api-javascript.html#vitedevserver). For example:
124
+
125
+ ```js
126
+ // [entry.client.js]
127
+ import '@vitejs/plugin-react/preamble'
128
+ ```
129
+
130
+ Alternatively, you can manually call `transformIndexHtml` during SSR, which sets up equivalent initialization code. Here's an example for an Express server:
131
+
132
+ ```js
133
+ app.get('/', async (req, res, next) => {
134
+ try {
135
+ let html = fs.readFileSync(path.resolve(root, 'index.html'), 'utf-8')
136
+
137
+ // Transform HTML using Vite plugins.
138
+ html = await viteServer.transformIndexHtml(req.url, html)
139
+
140
+ res.send(html)
141
+ } catch (e) {
142
+ return next(e)
143
+ }
144
+ })
145
+ ```
146
+
147
+ Otherwise, you'll get the following error:
148
+
149
+ ```
150
+ Uncaught Error: @vitejs/plugin-react can't detect preamble. Something is wrong.
151
+ ```
152
+
153
+ ## Consistent components exports
154
+
155
+ For React refresh to work correctly, your file should only export React components. You can find a good explanation in the [Gatsby docs](https://www.gatsbyjs.com/docs/reference/local-development/fast-refresh/#how-it-works).
156
+
157
+ If an incompatible change in exports is found, the module will be invalidated and HMR will propagate. To make it easier to export simple constants alongside your component, the module is only invalidated when their value changes.
158
+
159
+ You can catch mistakes and get more detailed warning with this [eslint rule](https://github.com/ArnaudBarre/eslint-plugin-react-refresh).
@@ -0,0 +1,75 @@
1
+ import { Plugin, ResolvedConfig } from "vite";
2
+ import { ParserOptions, TransformOptions } from "@babel/core";
3
+
4
+ //#region src/index.d.ts
5
+ interface Options {
6
+ /**
7
+ * Can be used to process extra files like `.mdx`
8
+ * @example include: /\.(mdx|js|jsx|ts|tsx)$/
9
+ * @default /\.[tj]sx?$/
10
+ */
11
+ include?: string | RegExp | Array<string | RegExp>;
12
+ /**
13
+ * Can be used to exclude JSX/TSX files that runs in a worker or are not React files.
14
+ * Except if explicitly desired, you should keep node_modules in the exclude list
15
+ * @example exclude: [/\/pdf\//, /\.solid\.tsx$/, /\/node_modules\//]
16
+ * @default /\/node_modules\//
17
+ */
18
+ exclude?: string | RegExp | Array<string | RegExp>;
19
+ /**
20
+ * Control where the JSX factory is imported from.
21
+ * https://esbuild.github.io/api/#jsx-import-source
22
+ * @default 'react'
23
+ */
24
+ jsxImportSource?: string;
25
+ /**
26
+ * Note: Skipping React import with classic runtime is not supported from v4
27
+ * @default "automatic"
28
+ */
29
+ jsxRuntime?: 'classic' | 'automatic';
30
+ /**
31
+ * Babel configuration applied in both dev and prod.
32
+ */
33
+ babel?: BabelOptions | ((id: string, options: {
34
+ ssr?: boolean;
35
+ }) => BabelOptions);
36
+ /**
37
+ * React Fast Refresh runtime URL prefix.
38
+ * Useful in a module federation context to enable HMR by specifying
39
+ * the host application URL in the Vite config of a remote application.
40
+ * @example
41
+ * reactRefreshHost: 'http://localhost:3000'
42
+ */
43
+ reactRefreshHost?: string;
44
+ }
45
+ type BabelOptions = Omit<TransformOptions, 'ast' | 'filename' | 'root' | 'sourceFileName' | 'sourceMaps' | 'inputSourceMap'>;
46
+ /**
47
+ * The object type used by the `options` passed to plugins with
48
+ * an `api.reactBabel` method.
49
+ */
50
+ interface ReactBabelOptions extends BabelOptions {
51
+ plugins: Extract<BabelOptions['plugins'], any[]>;
52
+ presets: Extract<BabelOptions['presets'], any[]>;
53
+ overrides: Extract<BabelOptions['overrides'], any[]>;
54
+ parserOpts: ParserOptions & {
55
+ plugins: Extract<ParserOptions['plugins'], any[]>;
56
+ };
57
+ }
58
+ type ReactBabelHook = (babelConfig: ReactBabelOptions, context: ReactBabelHookContext, config: ResolvedConfig) => void;
59
+ type ReactBabelHookContext = {
60
+ ssr: boolean;
61
+ id: string;
62
+ };
63
+ type ViteReactPluginApi = {
64
+ /**
65
+ * Manipulate the Babel options of `@vitejs/plugin-react`
66
+ */
67
+ reactBabel?: ReactBabelHook;
68
+ };
69
+ declare function viteReact(opts?: Options): Plugin[];
70
+ declare namespace viteReact {
71
+ var preambleCode: string;
72
+ }
73
+ declare function viteReactForCjs(this: unknown, options: Options): Plugin[];
74
+ //#endregion
75
+ export { BabelOptions, Options, ReactBabelOptions, ViteReactPluginApi, viteReact as default, viteReactForCjs as "module.exports" };