@weglot/translate-react 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (292) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +6 -0
  3. package/README.md +199 -2
  4. package/build/_virtual/rolldown_runtime.cjs +29 -0
  5. package/build/_virtual/rolldown_runtime.mjs +7 -0
  6. package/build/index.cjs +0 -0
  7. package/build/index.d.cts +2 -0
  8. package/build/index.d.mts +2 -0
  9. package/build/index.mjs +1 -0
  10. package/build/locale.d.cts +6 -0
  11. package/build/locale.d.cts.map +1 -0
  12. package/build/locale.d.mts +6 -0
  13. package/build/locale.d.mts.map +1 -0
  14. package/build/metadata/manager.cjs +119 -0
  15. package/build/metadata/manager.mjs +114 -0
  16. package/build/metadata/manager.mjs.map +1 -0
  17. package/build/plugin/build-translator.cjs +210 -0
  18. package/build/plugin/build-translator.mjs +208 -0
  19. package/build/plugin/build-translator.mjs.map +1 -0
  20. package/build/plugin/cleanup.cjs +20 -0
  21. package/build/plugin/cleanup.mjs +20 -0
  22. package/build/plugin/cleanup.mjs.map +1 -0
  23. package/build/plugin/index.cjs +0 -0
  24. package/build/plugin/index.d.cts +2 -0
  25. package/build/plugin/index.d.mts +2 -0
  26. package/build/plugin/index.mjs +1 -0
  27. package/build/plugin/next-compiler-loader.cjs +40 -0
  28. package/build/plugin/next-compiler-loader.d.cts +12 -0
  29. package/build/plugin/next-compiler-loader.d.cts.map +1 -0
  30. package/build/plugin/next-compiler-loader.d.mts +13 -0
  31. package/build/plugin/next-compiler-loader.d.mts.map +1 -0
  32. package/build/plugin/next-compiler-loader.mjs +41 -0
  33. package/build/plugin/next-compiler-loader.mjs.map +1 -0
  34. package/build/plugin/next-config-loader.cjs +13 -0
  35. package/build/plugin/next-config-loader.d.cts +8 -0
  36. package/build/plugin/next-config-loader.d.cts.map +1 -0
  37. package/build/plugin/next-config-loader.d.mts +9 -0
  38. package/build/plugin/next-config-loader.d.mts.map +1 -0
  39. package/build/plugin/next-config-loader.mjs +14 -0
  40. package/build/plugin/next-config-loader.mjs.map +1 -0
  41. package/build/plugin/next-locale-client-loader.cjs +9 -0
  42. package/build/plugin/next-locale-client-loader.d.cts +8 -0
  43. package/build/plugin/next-locale-client-loader.d.cts.map +1 -0
  44. package/build/plugin/next-locale-client-loader.d.mts +9 -0
  45. package/build/plugin/next-locale-client-loader.d.mts.map +1 -0
  46. package/build/plugin/next-locale-client-loader.mjs +10 -0
  47. package/build/plugin/next-locale-client-loader.mjs.map +1 -0
  48. package/build/plugin/next-locale-server-loader.cjs +9 -0
  49. package/build/plugin/next-locale-server-loader.d.cts +8 -0
  50. package/build/plugin/next-locale-server-loader.d.cts.map +1 -0
  51. package/build/plugin/next-locale-server-loader.d.mts +9 -0
  52. package/build/plugin/next-locale-server-loader.d.mts.map +1 -0
  53. package/build/plugin/next-locale-server-loader.mjs +10 -0
  54. package/build/plugin/next-locale-server-loader.mjs.map +1 -0
  55. package/build/plugin/next.cjs +227 -0
  56. package/build/plugin/next.d.cts +9 -0
  57. package/build/plugin/next.d.cts.map +1 -0
  58. package/build/plugin/next.d.mts +9 -0
  59. package/build/plugin/next.d.mts.map +1 -0
  60. package/build/plugin/next.mjs +229 -0
  61. package/build/plugin/next.mjs.map +1 -0
  62. package/build/plugin/transform/babel-compat.cjs +13 -0
  63. package/build/plugin/transform/babel-compat.mjs +10 -0
  64. package/build/plugin/transform/babel-compat.mjs.map +1 -0
  65. package/build/plugin/transform/expression-strings.cjs +145 -0
  66. package/build/plugin/transform/expression-strings.mjs +140 -0
  67. package/build/plugin/transform/expression-strings.mjs.map +1 -0
  68. package/build/plugin/transform/index.cjs +45 -0
  69. package/build/plugin/transform/index.mjs +43 -0
  70. package/build/plugin/transform/index.mjs.map +1 -0
  71. package/build/plugin/transform/metadata.cjs +142 -0
  72. package/build/plugin/transform/metadata.mjs +141 -0
  73. package/build/plugin/transform/metadata.mjs.map +1 -0
  74. package/build/plugin/transform/process-file.cjs +525 -0
  75. package/build/plugin/transform/process-file.mjs +524 -0
  76. package/build/plugin/transform/process-file.mjs.map +1 -0
  77. package/build/plugin/transform/use-i18n.cjs +8 -0
  78. package/build/plugin/transform/use-i18n.mjs +7 -0
  79. package/build/plugin/transform/use-i18n.mjs.map +1 -0
  80. package/build/plugin/transform/utils.cjs +237 -0
  81. package/build/plugin/transform/utils.mjs +219 -0
  82. package/build/plugin/transform/utils.mjs.map +1 -0
  83. package/build/plugin/unplugin.cjs +188 -0
  84. package/build/plugin/unplugin.d.cts +8 -0
  85. package/build/plugin/unplugin.d.cts.map +1 -0
  86. package/build/plugin/unplugin.d.mts +8 -0
  87. package/build/plugin/unplugin.d.mts.map +1 -0
  88. package/build/plugin/unplugin.mjs +188 -0
  89. package/build/plugin/unplugin.mjs.map +1 -0
  90. package/build/plugin/vite.cjs +27 -0
  91. package/build/plugin/vite.d.cts +9 -0
  92. package/build/plugin/vite.d.cts.map +1 -0
  93. package/build/plugin/vite.d.mts +9 -0
  94. package/build/plugin/vite.d.mts.map +1 -0
  95. package/build/plugin/vite.mjs +28 -0
  96. package/build/plugin/vite.mjs.map +1 -0
  97. package/build/plugin/webpack.cjs +26 -0
  98. package/build/plugin/webpack.d.cts +8 -0
  99. package/build/plugin/webpack.d.cts.map +1 -0
  100. package/build/plugin/webpack.d.mts +8 -0
  101. package/build/plugin/webpack.d.mts.map +1 -0
  102. package/build/plugin/webpack.mjs +27 -0
  103. package/build/plugin/webpack.mjs.map +1 -0
  104. package/build/react/client/index.cjs +9 -0
  105. package/build/react/client/index.d.cts +5 -0
  106. package/build/react/client/index.d.mts +5 -0
  107. package/build/react/client/index.mjs +6 -0
  108. package/build/react/client/useTranslation.cjs +71 -0
  109. package/build/react/client/useTranslation.d.cts +42 -0
  110. package/build/react/client/useTranslation.d.cts.map +1 -0
  111. package/build/react/client/useTranslation.d.mts +42 -0
  112. package/build/react/client/useTranslation.d.mts.map +1 -0
  113. package/build/react/client/useTranslation.mjs +71 -0
  114. package/build/react/client/useTranslation.mjs.map +1 -0
  115. package/build/react/next/client.cjs +25 -0
  116. package/build/react/next/client.d.cts +9 -0
  117. package/build/react/next/client.d.cts.map +1 -0
  118. package/build/react/next/client.d.mts +9 -0
  119. package/build/react/next/client.d.mts.map +1 -0
  120. package/build/react/next/client.mjs +24 -0
  121. package/build/react/next/client.mjs.map +1 -0
  122. package/build/react/next/cookie-locale-resolver.cjs +29 -0
  123. package/build/react/next/cookie-locale-resolver.d.cts +33 -0
  124. package/build/react/next/cookie-locale-resolver.d.cts.map +1 -0
  125. package/build/react/next/cookie-locale-resolver.d.mts +33 -0
  126. package/build/react/next/cookie-locale-resolver.d.mts.map +1 -0
  127. package/build/react/next/cookie-locale-resolver.mjs +29 -0
  128. package/build/react/next/cookie-locale-resolver.mjs.map +1 -0
  129. package/build/react/next/server.cjs +21 -0
  130. package/build/react/next/server.d.cts +13 -0
  131. package/build/react/next/server.d.cts.map +1 -0
  132. package/build/react/next/server.d.mts +14 -0
  133. package/build/react/next/server.d.mts.map +1 -0
  134. package/build/react/next/server.mjs +20 -0
  135. package/build/react/next/server.mjs.map +1 -0
  136. package/build/react/server/ServerWeglotProvider.cjs +19 -0
  137. package/build/react/server/ServerWeglotProvider.d.cts +12 -0
  138. package/build/react/server/ServerWeglotProvider.d.cts.map +1 -0
  139. package/build/react/server/ServerWeglotProvider.d.mts +12 -0
  140. package/build/react/server/ServerWeglotProvider.d.mts.map +1 -0
  141. package/build/react/server/ServerWeglotProvider.mjs +19 -0
  142. package/build/react/server/ServerWeglotProvider.mjs.map +1 -0
  143. package/build/react/server/index.cjs +7 -0
  144. package/build/react/server/index.d.cts +4 -0
  145. package/build/react/server/index.d.mts +4 -0
  146. package/build/react/server/index.mjs +5 -0
  147. package/build/react/server/useTranslation.cjs +60 -0
  148. package/build/react/server/useTranslation.d.cts +36 -0
  149. package/build/react/server/useTranslation.d.cts.map +1 -0
  150. package/build/react/server/useTranslation.d.mts +36 -0
  151. package/build/react/server/useTranslation.d.mts.map +1 -0
  152. package/build/react/server/useTranslation.mjs +60 -0
  153. package/build/react/server/useTranslation.mjs.map +1 -0
  154. package/build/react/server-only/index.cjs +42 -0
  155. package/build/react/server-only/index.d.cts +38 -0
  156. package/build/react/server-only/index.d.cts.map +1 -0
  157. package/build/react/server-only/index.d.mts +38 -0
  158. package/build/react/server-only/index.d.mts.map +1 -0
  159. package/build/react/server-only/index.mjs +42 -0
  160. package/build/react/server-only/index.mjs.map +1 -0
  161. package/build/react/server-only/translations.cjs +86 -0
  162. package/build/react/server-only/translations.mjs +86 -0
  163. package/build/react/server-only/translations.mjs.map +1 -0
  164. package/build/react/shared/LocaleSwitcher.cjs +61 -0
  165. package/build/react/shared/LocaleSwitcher.d.cts +71 -0
  166. package/build/react/shared/LocaleSwitcher.d.cts.map +1 -0
  167. package/build/react/shared/LocaleSwitcher.d.mts +71 -0
  168. package/build/react/shared/LocaleSwitcher.d.mts.map +1 -0
  169. package/build/react/shared/LocaleSwitcher.mjs +61 -0
  170. package/build/react/shared/LocaleSwitcher.mjs.map +1 -0
  171. package/build/react/shared/WeglotContext.cjs +14 -0
  172. package/build/react/shared/WeglotContext.d.cts +34 -0
  173. package/build/react/shared/WeglotContext.d.cts.map +1 -0
  174. package/build/react/shared/WeglotContext.d.mts +34 -0
  175. package/build/react/shared/WeglotContext.d.mts.map +1 -0
  176. package/build/react/shared/WeglotContext.mjs +13 -0
  177. package/build/react/shared/WeglotContext.mjs.map +1 -0
  178. package/build/react/shared/WeglotProvider.cjs +250 -0
  179. package/build/react/shared/WeglotProvider.d.cts +60 -0
  180. package/build/react/shared/WeglotProvider.d.cts.map +1 -0
  181. package/build/react/shared/WeglotProvider.d.mts +60 -0
  182. package/build/react/shared/WeglotProvider.d.mts.map +1 -0
  183. package/build/react/shared/WeglotProvider.mjs +250 -0
  184. package/build/react/shared/WeglotProvider.mjs.map +1 -0
  185. package/build/react/shared/render-rich-text.cjs +56 -0
  186. package/build/react/shared/render-rich-text.d.cts +16 -0
  187. package/build/react/shared/render-rich-text.d.cts.map +1 -0
  188. package/build/react/shared/render-rich-text.d.mts +16 -0
  189. package/build/react/shared/render-rich-text.d.mts.map +1 -0
  190. package/build/react/shared/render-rich-text.mjs +55 -0
  191. package/build/react/shared/render-rich-text.mjs.map +1 -0
  192. package/build/react/shared/utils.cjs +34 -0
  193. package/build/react/shared/utils.mjs +35 -0
  194. package/build/react/shared/utils.mjs.map +1 -0
  195. package/build/react/types.d.cts +16 -0
  196. package/build/react/types.d.cts.map +1 -0
  197. package/build/react/types.d.mts +16 -0
  198. package/build/react/types.d.mts.map +1 -0
  199. package/build/runtime/html/segmenter.cjs +226 -0
  200. package/build/runtime/html/segmenter.mjs +225 -0
  201. package/build/runtime/html/segmenter.mjs.map +1 -0
  202. package/build/runtime/index.cjs +6 -0
  203. package/build/runtime/index.d.cts +2 -0
  204. package/build/runtime/index.d.mts +2 -0
  205. package/build/runtime/index.mjs +3 -0
  206. package/build/runtime/translate-dynamic.cjs +144 -0
  207. package/build/runtime/translate-dynamic.d.cts +29 -0
  208. package/build/runtime/translate-dynamic.d.cts.map +1 -0
  209. package/build/runtime/translate-dynamic.d.mts +29 -0
  210. package/build/runtime/translate-dynamic.d.mts.map +1 -0
  211. package/build/runtime/translate-dynamic.mjs +141 -0
  212. package/build/runtime/translate-dynamic.mjs.map +1 -0
  213. package/build/translation-server/logger.cjs +37 -0
  214. package/build/translation-server/logger.mjs +37 -0
  215. package/build/translation-server/logger.mjs.map +1 -0
  216. package/build/translation-server/translation-server.cjs +451 -0
  217. package/build/translation-server/translation-server.mjs +448 -0
  218. package/build/translation-server/translation-server.mjs.map +1 -0
  219. package/build/translators/api.cjs +12 -0
  220. package/build/translators/api.mjs +12 -0
  221. package/build/translators/api.mjs.map +1 -0
  222. package/build/translators/cache-factory.cjs +26 -0
  223. package/build/translators/cache-factory.mjs +27 -0
  224. package/build/translators/cache-factory.mjs.map +1 -0
  225. package/build/translators/local-cache.cjs +132 -0
  226. package/build/translators/local-cache.mjs +130 -0
  227. package/build/translators/local-cache.mjs.map +1 -0
  228. package/build/translators/translation-service.cjs +139 -0
  229. package/build/translators/translation-service.mjs +140 -0
  230. package/build/translators/translation-service.mjs.map +1 -0
  231. package/build/translators/weglot/api-client.cjs +131 -0
  232. package/build/translators/weglot/api-client.mjs +130 -0
  233. package/build/translators/weglot/api-client.mjs.map +1 -0
  234. package/build/translators/weglot/definitions/definitions.generated.cjs +53 -0
  235. package/build/translators/weglot/definitions/definitions.generated.mjs +52 -0
  236. package/build/translators/weglot/definitions/definitions.generated.mjs.map +1 -0
  237. package/build/translators/weglot/engine.cjs +43 -0
  238. package/build/translators/weglot/engine.mjs +40 -0
  239. package/build/translators/weglot/engine.mjs.map +1 -0
  240. package/build/translators/weglot/translator.cjs +67 -0
  241. package/build/translators/weglot/translator.mjs +68 -0
  242. package/build/translators/weglot/translator.mjs.map +1 -0
  243. package/build/translators/weglot/wire-format.cjs +128 -0
  244. package/build/translators/weglot/wire-format.mjs +129 -0
  245. package/build/translators/weglot/wire-format.mjs.map +1 -0
  246. package/build/types.d.cts +153 -0
  247. package/build/types.d.cts.map +1 -0
  248. package/build/types.d.mts +153 -0
  249. package/build/types.d.mts.map +1 -0
  250. package/build/utils/config-factory.cjs +100 -0
  251. package/build/utils/config-factory.mjs +97 -0
  252. package/build/utils/config-factory.mjs.map +1 -0
  253. package/build/utils/hash.cjs +17 -0
  254. package/build/utils/hash.mjs +16 -0
  255. package/build/utils/hash.mjs.map +1 -0
  256. package/build/utils/is-valid-locale.cjs +13 -0
  257. package/build/utils/is-valid-locale.mjs +13 -0
  258. package/build/utils/is-valid-locale.mjs.map +1 -0
  259. package/build/utils/logger.cjs +51 -0
  260. package/build/utils/logger.mjs +50 -0
  261. package/build/utils/logger.mjs.map +1 -0
  262. package/build/utils/path-helpers.cjs +49 -0
  263. package/build/utils/path-helpers.mjs +47 -0
  264. package/build/utils/path-helpers.mjs.map +1 -0
  265. package/build/utils/timeout.cjs +42 -0
  266. package/build/utils/timeout.mjs +41 -0
  267. package/build/utils/timeout.mjs.map +1 -0
  268. package/build/virtual/code-generator.cjs +58 -0
  269. package/build/virtual/code-generator.mjs +57 -0
  270. package/build/virtual/code-generator.mjs.map +1 -0
  271. package/build/virtual/config.cjs +19 -0
  272. package/build/virtual/config.d.cts +15 -0
  273. package/build/virtual/config.d.cts.map +1 -0
  274. package/build/virtual/config.d.mts +15 -0
  275. package/build/virtual/config.d.mts.map +1 -0
  276. package/build/virtual/config.mjs +14 -0
  277. package/build/virtual/config.mjs.map +1 -0
  278. package/build/virtual/locale/client.cjs +23 -0
  279. package/build/virtual/locale/client.d.cts +19 -0
  280. package/build/virtual/locale/client.d.cts.map +1 -0
  281. package/build/virtual/locale/client.d.mts +19 -0
  282. package/build/virtual/locale/client.d.mts.map +1 -0
  283. package/build/virtual/locale/client.mjs +22 -0
  284. package/build/virtual/locale/client.mjs.map +1 -0
  285. package/build/virtual/locale/server.cjs +13 -0
  286. package/build/virtual/locale/server.d.cts +13 -0
  287. package/build/virtual/locale/server.d.cts.map +1 -0
  288. package/build/virtual/locale/server.d.mts +13 -0
  289. package/build/virtual/locale/server.d.mts.map +1 -0
  290. package/build/virtual/locale/server.mjs +13 -0
  291. package/build/virtual/locale/server.mjs.map +1 -0
  292. package/package.json +260 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.cts","names":[],"sources":["../../src/virtual/config.ts"],"sourcesContent":[],"mappings":";;;cAEa,SAAA;cACA,QAAA;AADA,cAEA,YAFS,EAE6B,UAF7B;AACtB;AACa,cAGA,UAHsC,EAG1B,MAH0B,CAAA,MAAU,EAGrB,UAHqB,CAAA;AAG7D;AAGa,cAAA,iBAA6B,EAAA,MAAA;AAG1C;cAAa"}
@@ -0,0 +1,15 @@
1
+ import { LocaleCode } from "../locale.mjs";
2
+
3
+ //#region src/virtual/config.d.ts
4
+ declare const serverUrl = "__SERVER_URL__";
5
+ declare const cacheDir = "__CACHE_DIR__";
6
+ declare const sourceLocale: LocaleCode;
7
+ /** Public locale to the language code the translate API expects. */
8
+ declare const apiLocales: Record<string, LocaleCode>;
9
+ /** Which inline elements the project's engine permits inside a segment. */
10
+ declare const translationEngine: number;
11
+ /** The project's regional API host. */
12
+ declare const apiBaseUrl: string;
13
+ //#endregion
14
+ export { apiBaseUrl, apiLocales, cacheDir, serverUrl, sourceLocale, translationEngine };
15
+ //# sourceMappingURL=config.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.mts","names":[],"sources":["../../src/virtual/config.ts"],"sourcesContent":[],"mappings":";;;cAEa,SAAA;cACA,QAAA;AADA,cAEA,YAFS,EAE6B,UAF7B;AACtB;AACa,cAGA,UAHsC,EAG1B,MAH0B,CAAA,MAAU,EAGrB,UAHqB,CAAA;AAG7D;AAGa,cAAA,iBAA6B,EAAA,MAAA;AAG1C;cAAa"}
@@ -0,0 +1,14 @@
1
+ //#region src/virtual/config.ts
2
+ const serverUrl = "__SERVER_URL__";
3
+ const cacheDir = "__CACHE_DIR__";
4
+ const sourceLocale = "__SOURCE_LOCALE__";
5
+ /** Public locale to the language code the translate API expects. */
6
+ const apiLocales = {};
7
+ /** Which inline elements the project's engine permits inside a segment. */
8
+ const translationEngine = 3;
9
+ /** The project's regional API host. */
10
+ const apiBaseUrl = "https://api.weglot.com";
11
+
12
+ //#endregion
13
+ export { apiBaseUrl, apiLocales, cacheDir, serverUrl, sourceLocale, translationEngine };
14
+ //# sourceMappingURL=config.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.mjs","names":["apiLocales: Record<string, LocaleCode>","translationEngine: number","apiBaseUrl: string"],"sources":["../../src/virtual/config.ts"],"sourcesContent":["import type { LocaleCode } from \"../locale\";\n\nexport const serverUrl = \"__SERVER_URL__\";\nexport const cacheDir = \"__CACHE_DIR__\";\nexport const sourceLocale = \"__SOURCE_LOCALE__\" as LocaleCode;\n\n/** Public locale to the language code the translate API expects. */\nexport const apiLocales: Record<string, LocaleCode> = {};\n\n/** Which inline elements the project's engine permits inside a segment. */\nexport const translationEngine: number = 3;\n\n/** The project's regional API host. */\nexport const apiBaseUrl: string = \"https://api.weglot.com\";\n"],"mappings":";AAEA,MAAa,YAAY;AACzB,MAAa,WAAW;AACxB,MAAa,eAAe;;AAG5B,MAAaA,aAAyC,EAAE;;AAGxD,MAAaC,oBAA4B;;AAGzC,MAAaC,aAAqB"}
@@ -0,0 +1,23 @@
1
+
2
+ //#region src/virtual/locale/client.ts
3
+ /**
4
+ * Get the current locale on the client
5
+ * Reads from cookie
6
+ * @returns Resolved locale code
7
+ */
8
+ function getClientLocale() {
9
+ return "en";
10
+ }
11
+ const __NOOP_PERSIST_LOCALE__ = () => {};
12
+ /**
13
+ * Persist the locale on the client
14
+ * Writes to cookie
15
+ * @param locale - Locale code to persist
16
+ */
17
+ function persistLocale(locale) {
18
+ return __NOOP_PERSIST_LOCALE__();
19
+ }
20
+
21
+ //#endregion
22
+ exports.getClientLocale = getClientLocale;
23
+ exports.persistLocale = persistLocale;
@@ -0,0 +1,19 @@
1
+ import { LocaleCode } from "../../locale.cjs";
2
+
3
+ //#region src/virtual/locale/client.d.ts
4
+
5
+ /**
6
+ * Get the current locale on the client
7
+ * Reads from cookie
8
+ * @returns Resolved locale code
9
+ */
10
+ declare function getClientLocale(): LocaleCode;
11
+ /**
12
+ * Persist the locale on the client
13
+ * Writes to cookie
14
+ * @param locale - Locale code to persist
15
+ */
16
+ declare function persistLocale(locale: LocaleCode): void;
17
+ //#endregion
18
+ export { getClientLocale, persistLocale };
19
+ //# sourceMappingURL=client.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.cts","names":[],"sources":["../../../src/virtual/locale/client.ts"],"sourcesContent":[],"mappings":";;;;;;AAOA;AAWA;;iBAXgB,eAAA,CAAA,GAAmB;;;;;;iBAWnB,aAAA,SAAsB"}
@@ -0,0 +1,19 @@
1
+ import { LocaleCode } from "../../locale.mjs";
2
+
3
+ //#region src/virtual/locale/client.d.ts
4
+
5
+ /**
6
+ * Get the current locale on the client
7
+ * Reads from cookie
8
+ * @returns Resolved locale code
9
+ */
10
+ declare function getClientLocale(): LocaleCode;
11
+ /**
12
+ * Persist the locale on the client
13
+ * Writes to cookie
14
+ * @param locale - Locale code to persist
15
+ */
16
+ declare function persistLocale(locale: LocaleCode): void;
17
+ //#endregion
18
+ export { getClientLocale, persistLocale };
19
+ //# sourceMappingURL=client.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.mts","names":[],"sources":["../../../src/virtual/locale/client.ts"],"sourcesContent":[],"mappings":";;;;;;AAOA;AAWA;;iBAXgB,eAAA,CAAA,GAAmB;;;;;;iBAWnB,aAAA,SAAsB"}
@@ -0,0 +1,22 @@
1
+ //#region src/virtual/locale/client.ts
2
+ /**
3
+ * Get the current locale on the client
4
+ * Reads from cookie
5
+ * @returns Resolved locale code
6
+ */
7
+ function getClientLocale() {
8
+ return "en";
9
+ }
10
+ const __NOOP_PERSIST_LOCALE__ = () => {};
11
+ /**
12
+ * Persist the locale on the client
13
+ * Writes to cookie
14
+ * @param locale - Locale code to persist
15
+ */
16
+ function persistLocale(locale) {
17
+ return __NOOP_PERSIST_LOCALE__();
18
+ }
19
+
20
+ //#endregion
21
+ export { getClientLocale, persistLocale };
22
+ //# sourceMappingURL=client.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.mjs","names":[],"sources":["../../../src/virtual/locale/client.ts"],"sourcesContent":["import type { LocaleCode } from \"../../locale\";\n\n/**\n * Get the current locale on the client\n * Reads from cookie\n * @returns Resolved locale code\n */\nexport function getClientLocale(): LocaleCode {\n return \"en\";\n}\n\nconst __NOOP_PERSIST_LOCALE__ = () => {};\n\n/**\n * Persist the locale on the client\n * Writes to cookie\n * @param locale - Locale code to persist\n */\nexport function persistLocale(locale: LocaleCode): void {\n return __NOOP_PERSIST_LOCALE__();\n}\n"],"mappings":";;;;;;AAOA,SAAgB,kBAA8B;AAC5C,QAAO;;AAGT,MAAM,gCAAgC;;;;;;AAOtC,SAAgB,cAAc,QAA0B;AACtD,QAAO,yBAAyB"}
@@ -0,0 +1,13 @@
1
+
2
+ //#region src/virtual/locale/server.ts
3
+ /**
4
+ * Get the current locale on the server
5
+ * Uses cookies, headers, or other server-side mechanisms
6
+ * @returns Resolved locale code
7
+ */
8
+ async function getServerLocale() {
9
+ return "en";
10
+ }
11
+
12
+ //#endregion
13
+ exports.getServerLocale = getServerLocale;
@@ -0,0 +1,13 @@
1
+ import { LocaleCode } from "../../locale.cjs";
2
+
3
+ //#region src/virtual/locale/server.d.ts
4
+
5
+ /**
6
+ * Get the current locale on the server
7
+ * Uses cookies, headers, or other server-side mechanisms
8
+ * @returns Resolved locale code
9
+ */
10
+ declare function getServerLocale(): Promise<LocaleCode>;
11
+ //#endregion
12
+ export { getServerLocale };
13
+ //# sourceMappingURL=server.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.cts","names":[],"sources":["../../../src/virtual/locale/server.ts"],"sourcesContent":[],"mappings":";;;;;;AAOA;;;iBAAsB,eAAA,CAAA,GAAmB,QAAQ"}
@@ -0,0 +1,13 @@
1
+ import { LocaleCode } from "../../locale.mjs";
2
+
3
+ //#region src/virtual/locale/server.d.ts
4
+
5
+ /**
6
+ * Get the current locale on the server
7
+ * Uses cookies, headers, or other server-side mechanisms
8
+ * @returns Resolved locale code
9
+ */
10
+ declare function getServerLocale(): Promise<LocaleCode>;
11
+ //#endregion
12
+ export { getServerLocale };
13
+ //# sourceMappingURL=server.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.mts","names":[],"sources":["../../../src/virtual/locale/server.ts"],"sourcesContent":[],"mappings":";;;;;;AAOA;;;iBAAsB,eAAA,CAAA,GAAmB,QAAQ"}
@@ -0,0 +1,13 @@
1
+ //#region src/virtual/locale/server.ts
2
+ /**
3
+ * Get the current locale on the server
4
+ * Uses cookies, headers, or other server-side mechanisms
5
+ * @returns Resolved locale code
6
+ */
7
+ async function getServerLocale() {
8
+ return "en";
9
+ }
10
+
11
+ //#endregion
12
+ export { getServerLocale };
13
+ //# sourceMappingURL=server.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.mjs","names":[],"sources":["../../../src/virtual/locale/server.ts"],"sourcesContent":["import type { LocaleCode } from \"../../locale\";\n\n/**\n * Get the current locale on the server\n * Uses cookies, headers, or other server-side mechanisms\n * @returns Resolved locale code\n */\nexport async function getServerLocale(): Promise<LocaleCode> {\n return \"en\";\n}\n"],"mappings":";;;;;;AAOA,eAAsB,kBAAuC;AAC3D,QAAO"}
package/package.json CHANGED
@@ -1,6 +1,262 @@
1
1
  {
2
2
  "name": "@weglot/translate-react",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "Automatic Weglot translation for React and Next.js apps, detected from your JSX at build time",
5
+ "sideEffects": false,
6
+ "type": "module",
7
+ "main": "build/index.cjs",
8
+ "types": "build/index.d.cts",
9
+ "module": "build/index.mjs",
10
+ "exports": {
11
+ "./dynamic": {
12
+ "import": {
13
+ "types": "./build/runtime/index.d.mts",
14
+ "default": "./build/runtime/index.mjs"
15
+ },
16
+ "require": {
17
+ "types": "./build/runtime/index.d.cts",
18
+ "default": "./build/runtime/index.cjs"
19
+ }
20
+ },
21
+ ".": {
22
+ "import": {
23
+ "types": "./build/plugin/index.d.mts",
24
+ "default": "./build/plugin/index.mjs"
25
+ },
26
+ "require": {
27
+ "types": "./build/plugin/index.d.cts",
28
+ "default": "./build/plugin/index.cjs"
29
+ }
30
+ },
31
+ "./react": {
32
+ "react-server": {
33
+ "import": {
34
+ "types": "./build/react/server/index.d.mts",
35
+ "default": "./build/react/server/index.mjs"
36
+ },
37
+ "default": {
38
+ "types": "./build/react/server/index.d.cts",
39
+ "default": "./build/react/server/index.cjs"
40
+ }
41
+ },
42
+ "default": {
43
+ "import": {
44
+ "types": "./build/react/client/index.d.mts",
45
+ "default": "./build/react/client/index.mjs"
46
+ },
47
+ "default": {
48
+ "types": "./build/react/client/index.d.cts",
49
+ "default": "./build/react/client/index.cjs"
50
+ }
51
+ }
52
+ },
53
+ "./virtual/config": {
54
+ "import": {
55
+ "types": "./build/virtual/config.d.mts",
56
+ "default": "./build/virtual/config.mjs"
57
+ },
58
+ "require": {
59
+ "types": "./build/virtual/config.d.cts",
60
+ "default": "./build/virtual/config.cjs"
61
+ }
62
+ },
63
+ "./virtual/locale/server": {
64
+ "import": {
65
+ "types": "./build/virtual/locale/server.d.mts",
66
+ "default": "./build/virtual/locale/server.mjs"
67
+ },
68
+ "require": {
69
+ "types": "./build/virtual/locale/server.d.cts",
70
+ "default": "./build/virtual/locale/server.cjs"
71
+ }
72
+ },
73
+ "./virtual/locale/client": {
74
+ "import": {
75
+ "types": "./build/virtual/locale/client.d.mts",
76
+ "default": "./build/virtual/locale/client.mjs"
77
+ },
78
+ "require": {
79
+ "types": "./build/virtual/locale/client.d.cts",
80
+ "default": "./build/virtual/locale/client.cjs"
81
+ }
82
+ },
83
+ "./react/next": {
84
+ "react-server": {
85
+ "import": {
86
+ "types": "./build/react/next/server.d.mts",
87
+ "default": "./build/react/next/server.mjs"
88
+ },
89
+ "default": {
90
+ "types": "./build/react/next/server.d.cts",
91
+ "default": "./build/react/next/server.cjs"
92
+ }
93
+ },
94
+ "default": {
95
+ "import": {
96
+ "types": "./build/react/next/client.d.mts",
97
+ "default": "./build/react/next/client.mjs"
98
+ },
99
+ "default": {
100
+ "types": "./build/react/next/client.d.cts",
101
+ "default": "./build/react/next/client.cjs"
102
+ }
103
+ }
104
+ },
105
+ "./react/server": {
106
+ "import": {
107
+ "types": "./build/react/server-only/index.d.mts",
108
+ "default": "./build/react/server-only/index.mjs"
109
+ },
110
+ "require": {
111
+ "types": "./build/react/server-only/index.d.cts",
112
+ "default": "./build/react/server-only/index.cjs"
113
+ }
114
+ },
115
+ "./next": {
116
+ "import": {
117
+ "types": "./build/plugin/next.d.mts",
118
+ "default": "./build/plugin/next.mjs"
119
+ },
120
+ "require": {
121
+ "types": "./build/plugin/next.d.cts",
122
+ "default": "./build/plugin/next.cjs"
123
+ }
124
+ },
125
+ "./vite": {
126
+ "import": {
127
+ "types": "./build/plugin/vite.d.mts",
128
+ "default": "./build/plugin/vite.mjs"
129
+ },
130
+ "require": {
131
+ "types": "./build/plugin/vite.d.cts",
132
+ "default": "./build/plugin/vite.cjs"
133
+ }
134
+ },
135
+ "./webpack": {
136
+ "import": {
137
+ "types": "./build/plugin/webpack.d.mts",
138
+ "default": "./build/plugin/webpack.mjs"
139
+ },
140
+ "require": {
141
+ "types": "./build/plugin/webpack.d.cts",
142
+ "default": "./build/plugin/webpack.cjs"
143
+ }
144
+ },
145
+ "./next-compiler-loader": {
146
+ "import": {
147
+ "types": "./build/plugin/next-compiler-loader.d.mts",
148
+ "default": "./build/plugin/next-compiler-loader.mjs"
149
+ },
150
+ "require": {
151
+ "types": "./build/plugin/next-compiler-loader.d.cts",
152
+ "default": "./build/plugin/next-compiler-loader.cjs"
153
+ }
154
+ },
155
+ "./next-config-loader": {
156
+ "import": {
157
+ "types": "./build/plugin/next-config-loader.d.mts",
158
+ "default": "./build/plugin/next-config-loader.mjs"
159
+ },
160
+ "require": {
161
+ "types": "./build/plugin/next-config-loader.d.cts",
162
+ "default": "./build/plugin/next-config-loader.cjs"
163
+ }
164
+ },
165
+ "./next-locale-server-loader": {
166
+ "import": {
167
+ "types": "./build/plugin/next-locale-server-loader.d.mts",
168
+ "default": "./build/plugin/next-locale-server-loader.mjs"
169
+ },
170
+ "require": {
171
+ "types": "./build/plugin/next-locale-server-loader.d.cts",
172
+ "default": "./build/plugin/next-locale-server-loader.cjs"
173
+ }
174
+ },
175
+ "./next-locale-client-loader": {
176
+ "import": {
177
+ "types": "./build/plugin/next-locale-client-loader.d.mts",
178
+ "default": "./build/plugin/next-locale-client-loader.mjs"
179
+ },
180
+ "require": {
181
+ "types": "./build/plugin/next-locale-client-loader.d.cts",
182
+ "default": "./build/plugin/next-locale-client-loader.cjs"
183
+ }
184
+ }
185
+ },
186
+ "files": [
187
+ "build",
188
+ "NOTICE"
189
+ ],
190
+ "scripts": {
191
+ "dev": "tsdown --watch",
192
+ "build": "pnpm typecheck && tsdown",
193
+ "typecheck": "tsc --noEmit",
194
+ "clean": "rm -rf build",
195
+ "test": "vitest --run",
196
+ "sync-definitions": "node scripts/sync-definitions.ts",
197
+ "check-definitions": "node scripts/sync-definitions.ts --check",
198
+ "test:watch": "vitest -w",
199
+ "prepublishOnly": "pnpm build"
200
+ },
201
+ "keywords": [
202
+ "weglot",
203
+ "i18n",
204
+ "translation",
205
+ "react",
206
+ "nextjs",
207
+ "vite",
208
+ "compiler"
209
+ ],
210
+ "author": "Weglot",
211
+ "license": "Apache-2.0",
212
+ "repository": {
213
+ "type": "git",
214
+ "url": "git+https://github.com/weglot/translate-jsx.git"
215
+ },
216
+ "homepage": "https://github.com/weglot/translate-jsx#readme",
217
+ "bugs": {
218
+ "url": "https://github.com/weglot/translate-jsx/issues"
219
+ },
220
+ "engines": {
221
+ "node": ">=20.9.0"
222
+ },
223
+ "publishConfig": {
224
+ "access": "public"
225
+ },
226
+ "devDependencies": {
227
+ "@types/babel__core": "7.20.5",
228
+ "@types/babel__generator": "7.27.0",
229
+ "@types/babel__traverse": "7.28.0",
230
+ "@types/node": "25.0.3",
231
+ "@types/react": "19.2.7",
232
+ "@types/react-dom": "19.2.3",
233
+ "jsdom": "30.0.1",
234
+ "next": "16.2.9",
235
+ "tsdown": "0.18.2",
236
+ "typescript": "5.9.3",
237
+ "vitest": "4.1.0"
238
+ },
239
+ "dependencies": {
240
+ "@babel/generator": "^7.28.5",
241
+ "@babel/parser": "^7.28.5",
242
+ "@babel/traverse": "^7.28.5",
243
+ "@babel/types": "^7.28.5",
244
+ "dom-serializer": "^2.0.0",
245
+ "domhandler": "^5.0.3",
246
+ "dotenv": "^17.2.3",
247
+ "htmlparser2": "^10.1.0",
248
+ "intl-messageformat": "^11.0.6",
249
+ "lmdb": "^3.2.6",
250
+ "unplugin": "^2.3.11"
251
+ },
252
+ "peerDependencies": {
253
+ "next": "^15.0.0 || ^16.0.4",
254
+ "react": "^19.0.0",
255
+ "react-dom": "^19.0.0"
256
+ },
257
+ "peerDependenciesMeta": {
258
+ "next": {
259
+ "optional": true
260
+ }
261
+ }
262
+ }