@lingo.dev/compiler 0.1.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 (300) hide show
  1. package/LICENSE.md +201 -0
  2. package/README.md +192 -0
  3. package/build/_virtual/rolldown_runtime.cjs +29 -0
  4. package/build/_virtual/rolldown_runtime.mjs +7 -0
  5. package/build/index.cjs +0 -0
  6. package/build/index.d.cts +2 -0
  7. package/build/index.d.mts +2 -0
  8. package/build/index.mjs +1 -0
  9. package/build/metadata/manager.cjs +131 -0
  10. package/build/metadata/manager.mjs +123 -0
  11. package/build/metadata/manager.mjs.map +1 -0
  12. package/build/plugin/build-translator.cjs +198 -0
  13. package/build/plugin/build-translator.mjs +196 -0
  14. package/build/plugin/build-translator.mjs.map +1 -0
  15. package/build/plugin/cleanup.cjs +20 -0
  16. package/build/plugin/cleanup.mjs +20 -0
  17. package/build/plugin/cleanup.mjs.map +1 -0
  18. package/build/plugin/next-compiler-loader.cjs +41 -0
  19. package/build/plugin/next-compiler-loader.d.cts +12 -0
  20. package/build/plugin/next-compiler-loader.d.cts.map +1 -0
  21. package/build/plugin/next-compiler-loader.d.mts +13 -0
  22. package/build/plugin/next-compiler-loader.d.mts.map +1 -0
  23. package/build/plugin/next-compiler-loader.mjs +42 -0
  24. package/build/plugin/next-compiler-loader.mjs.map +1 -0
  25. package/build/plugin/next-config-loader.cjs +13 -0
  26. package/build/plugin/next-config-loader.d.cts +8 -0
  27. package/build/plugin/next-config-loader.d.cts.map +1 -0
  28. package/build/plugin/next-config-loader.d.mts +9 -0
  29. package/build/plugin/next-config-loader.d.mts.map +1 -0
  30. package/build/plugin/next-config-loader.mjs +14 -0
  31. package/build/plugin/next-config-loader.mjs.map +1 -0
  32. package/build/plugin/next-locale-client-loader.cjs +9 -0
  33. package/build/plugin/next-locale-client-loader.d.cts +8 -0
  34. package/build/plugin/next-locale-client-loader.d.cts.map +1 -0
  35. package/build/plugin/next-locale-client-loader.d.mts +9 -0
  36. package/build/plugin/next-locale-client-loader.d.mts.map +1 -0
  37. package/build/plugin/next-locale-client-loader.mjs +10 -0
  38. package/build/plugin/next-locale-client-loader.mjs.map +1 -0
  39. package/build/plugin/next-locale-server-loader.cjs +9 -0
  40. package/build/plugin/next-locale-server-loader.d.cts +8 -0
  41. package/build/plugin/next-locale-server-loader.d.cts.map +1 -0
  42. package/build/plugin/next-locale-server-loader.d.mts +9 -0
  43. package/build/plugin/next-locale-server-loader.d.mts.map +1 -0
  44. package/build/plugin/next-locale-server-loader.mjs +10 -0
  45. package/build/plugin/next-locale-server-loader.mjs.map +1 -0
  46. package/build/plugin/next.cjs +220 -0
  47. package/build/plugin/next.d.cts +9 -0
  48. package/build/plugin/next.d.cts.map +1 -0
  49. package/build/plugin/next.d.mts +9 -0
  50. package/build/plugin/next.d.mts.map +1 -0
  51. package/build/plugin/next.mjs +222 -0
  52. package/build/plugin/next.mjs.map +1 -0
  53. package/build/plugin/transform/babel-compat.cjs +13 -0
  54. package/build/plugin/transform/babel-compat.mjs +10 -0
  55. package/build/plugin/transform/babel-compat.mjs.map +1 -0
  56. package/build/plugin/transform/index.cjs +44 -0
  57. package/build/plugin/transform/index.mjs +42 -0
  58. package/build/plugin/transform/index.mjs.map +1 -0
  59. package/build/plugin/transform/metadata.cjs +142 -0
  60. package/build/plugin/transform/metadata.mjs +141 -0
  61. package/build/plugin/transform/metadata.mjs.map +1 -0
  62. package/build/plugin/transform/parse-override.cjs +145 -0
  63. package/build/plugin/transform/parse-override.mjs +144 -0
  64. package/build/plugin/transform/parse-override.mjs.map +1 -0
  65. package/build/plugin/transform/process-file.cjs +391 -0
  66. package/build/plugin/transform/process-file.mjs +390 -0
  67. package/build/plugin/transform/process-file.mjs.map +1 -0
  68. package/build/plugin/transform/use-i18n.cjs +8 -0
  69. package/build/plugin/transform/use-i18n.mjs +7 -0
  70. package/build/plugin/transform/use-i18n.mjs.map +1 -0
  71. package/build/plugin/transform/utils.cjs +205 -0
  72. package/build/plugin/transform/utils.mjs +192 -0
  73. package/build/plugin/transform/utils.mjs.map +1 -0
  74. package/build/plugin/unplugin.cjs +188 -0
  75. package/build/plugin/unplugin.d.cts +8 -0
  76. package/build/plugin/unplugin.d.cts.map +1 -0
  77. package/build/plugin/unplugin.d.mts +8 -0
  78. package/build/plugin/unplugin.d.mts.map +1 -0
  79. package/build/plugin/unplugin.mjs +186 -0
  80. package/build/plugin/unplugin.mjs.map +1 -0
  81. package/build/plugin/vite.cjs +28 -0
  82. package/build/plugin/vite.d.cts +9 -0
  83. package/build/plugin/vite.d.cts.map +1 -0
  84. package/build/plugin/vite.d.mts +9 -0
  85. package/build/plugin/vite.d.mts.map +1 -0
  86. package/build/plugin/vite.mjs +29 -0
  87. package/build/plugin/vite.mjs.map +1 -0
  88. package/build/plugin/webpack.cjs +27 -0
  89. package/build/plugin/webpack.d.cts +8 -0
  90. package/build/plugin/webpack.d.cts.map +1 -0
  91. package/build/plugin/webpack.d.mts +8 -0
  92. package/build/plugin/webpack.d.mts.map +1 -0
  93. package/build/plugin/webpack.mjs +28 -0
  94. package/build/plugin/webpack.mjs.map +1 -0
  95. package/build/react/client/index.cjs +9 -0
  96. package/build/react/client/index.d.cts +5 -0
  97. package/build/react/client/index.d.mts +5 -0
  98. package/build/react/client/index.mjs +6 -0
  99. package/build/react/client/useTranslation.cjs +71 -0
  100. package/build/react/client/useTranslation.d.cts +42 -0
  101. package/build/react/client/useTranslation.d.cts.map +1 -0
  102. package/build/react/client/useTranslation.d.mts +42 -0
  103. package/build/react/client/useTranslation.d.mts.map +1 -0
  104. package/build/react/client/useTranslation.mjs +71 -0
  105. package/build/react/client/useTranslation.mjs.map +1 -0
  106. package/build/react/next/client.cjs +25 -0
  107. package/build/react/next/client.d.cts +9 -0
  108. package/build/react/next/client.d.cts.map +1 -0
  109. package/build/react/next/client.d.mts +9 -0
  110. package/build/react/next/client.d.mts.map +1 -0
  111. package/build/react/next/client.mjs +24 -0
  112. package/build/react/next/client.mjs.map +1 -0
  113. package/build/react/next/cookie-locale-resolver.cjs +29 -0
  114. package/build/react/next/cookie-locale-resolver.d.cts +33 -0
  115. package/build/react/next/cookie-locale-resolver.d.cts.map +1 -0
  116. package/build/react/next/cookie-locale-resolver.d.mts +33 -0
  117. package/build/react/next/cookie-locale-resolver.d.mts.map +1 -0
  118. package/build/react/next/cookie-locale-resolver.mjs +29 -0
  119. package/build/react/next/cookie-locale-resolver.mjs.map +1 -0
  120. package/build/react/next/server.cjs +21 -0
  121. package/build/react/next/server.d.cts +13 -0
  122. package/build/react/next/server.d.cts.map +1 -0
  123. package/build/react/next/server.d.mts +14 -0
  124. package/build/react/next/server.d.mts.map +1 -0
  125. package/build/react/next/server.mjs +20 -0
  126. package/build/react/next/server.mjs.map +1 -0
  127. package/build/react/server/ServerLingoProvider.cjs +19 -0
  128. package/build/react/server/ServerLingoProvider.d.cts +12 -0
  129. package/build/react/server/ServerLingoProvider.d.cts.map +1 -0
  130. package/build/react/server/ServerLingoProvider.d.mts +12 -0
  131. package/build/react/server/ServerLingoProvider.d.mts.map +1 -0
  132. package/build/react/server/ServerLingoProvider.mjs +19 -0
  133. package/build/react/server/ServerLingoProvider.mjs.map +1 -0
  134. package/build/react/server/index.cjs +7 -0
  135. package/build/react/server/index.d.cts +4 -0
  136. package/build/react/server/index.d.mts +4 -0
  137. package/build/react/server/index.mjs +5 -0
  138. package/build/react/server/useTranslation.cjs +60 -0
  139. package/build/react/server/useTranslation.d.cts +36 -0
  140. package/build/react/server/useTranslation.d.cts.map +1 -0
  141. package/build/react/server/useTranslation.d.mts +36 -0
  142. package/build/react/server/useTranslation.d.mts.map +1 -0
  143. package/build/react/server/useTranslation.mjs +60 -0
  144. package/build/react/server/useTranslation.mjs.map +1 -0
  145. package/build/react/server-only/index.cjs +42 -0
  146. package/build/react/server-only/index.d.cts +38 -0
  147. package/build/react/server-only/index.d.cts.map +1 -0
  148. package/build/react/server-only/index.d.mts +38 -0
  149. package/build/react/server-only/index.d.mts.map +1 -0
  150. package/build/react/server-only/index.mjs +42 -0
  151. package/build/react/server-only/index.mjs.map +1 -0
  152. package/build/react/server-only/translations.cjs +85 -0
  153. package/build/react/server-only/translations.mjs +85 -0
  154. package/build/react/server-only/translations.mjs.map +1 -0
  155. package/build/react/shared/LingoContext.cjs +14 -0
  156. package/build/react/shared/LingoContext.d.cts +41 -0
  157. package/build/react/shared/LingoContext.d.cts.map +1 -0
  158. package/build/react/shared/LingoContext.d.mts +41 -0
  159. package/build/react/shared/LingoContext.d.mts.map +1 -0
  160. package/build/react/shared/LingoContext.mjs +13 -0
  161. package/build/react/shared/LingoContext.mjs.map +1 -0
  162. package/build/react/shared/LingoProvider.cjs +274 -0
  163. package/build/react/shared/LingoProvider.d.cts +76 -0
  164. package/build/react/shared/LingoProvider.d.cts.map +1 -0
  165. package/build/react/shared/LingoProvider.d.mts +76 -0
  166. package/build/react/shared/LingoProvider.d.mts.map +1 -0
  167. package/build/react/shared/LingoProvider.mjs +274 -0
  168. package/build/react/shared/LingoProvider.mjs.map +1 -0
  169. package/build/react/shared/LocaleSwitcher.cjs +61 -0
  170. package/build/react/shared/LocaleSwitcher.d.cts +71 -0
  171. package/build/react/shared/LocaleSwitcher.d.cts.map +1 -0
  172. package/build/react/shared/LocaleSwitcher.d.mts +71 -0
  173. package/build/react/shared/LocaleSwitcher.d.mts.map +1 -0
  174. package/build/react/shared/LocaleSwitcher.mjs +61 -0
  175. package/build/react/shared/LocaleSwitcher.mjs.map +1 -0
  176. package/build/react/shared/render-rich-text.cjs +55 -0
  177. package/build/react/shared/render-rich-text.d.cts +17 -0
  178. package/build/react/shared/render-rich-text.d.cts.map +1 -0
  179. package/build/react/shared/render-rich-text.d.mts +17 -0
  180. package/build/react/shared/render-rich-text.d.mts.map +1 -0
  181. package/build/react/shared/render-rich-text.mjs +54 -0
  182. package/build/react/shared/render-rich-text.mjs.map +1 -0
  183. package/build/react/shared/utils.cjs +34 -0
  184. package/build/react/shared/utils.mjs +35 -0
  185. package/build/react/shared/utils.mjs.map +1 -0
  186. package/build/react/types.d.cts +16 -0
  187. package/build/react/types.d.cts.map +1 -0
  188. package/build/react/types.d.mts +16 -0
  189. package/build/react/types.d.mts.map +1 -0
  190. package/build/translation-server/logger.cjs +37 -0
  191. package/build/translation-server/logger.mjs +37 -0
  192. package/build/translation-server/logger.mjs.map +1 -0
  193. package/build/translation-server/translation-server.cjs +547 -0
  194. package/build/translation-server/translation-server.mjs +544 -0
  195. package/build/translation-server/translation-server.mjs.map +1 -0
  196. package/build/translation-server/ws-events.cjs +15 -0
  197. package/build/translation-server/ws-events.mjs +15 -0
  198. package/build/translation-server/ws-events.mjs.map +1 -0
  199. package/build/translators/api.cjs +12 -0
  200. package/build/translators/api.mjs +12 -0
  201. package/build/translators/api.mjs.map +1 -0
  202. package/build/translators/cache-factory.cjs +26 -0
  203. package/build/translators/cache-factory.mjs +27 -0
  204. package/build/translators/cache-factory.mjs.map +1 -0
  205. package/build/translators/lingo/model-factory.cjs +179 -0
  206. package/build/translators/lingo/model-factory.mjs +174 -0
  207. package/build/translators/lingo/model-factory.mjs.map +1 -0
  208. package/build/translators/lingo/prompt.cjs +43 -0
  209. package/build/translators/lingo/prompt.mjs +43 -0
  210. package/build/translators/lingo/prompt.mjs.map +1 -0
  211. package/build/translators/lingo/service.cjs +152 -0
  212. package/build/translators/lingo/service.mjs +152 -0
  213. package/build/translators/lingo/service.mjs.map +1 -0
  214. package/build/translators/lingo/shots.cjs +28 -0
  215. package/build/translators/lingo/shots.mjs +28 -0
  216. package/build/translators/lingo/shots.mjs.map +1 -0
  217. package/build/translators/local-cache.cjs +115 -0
  218. package/build/translators/local-cache.mjs +113 -0
  219. package/build/translators/local-cache.mjs.map +1 -0
  220. package/build/translators/parse-xml.cjs +109 -0
  221. package/build/translators/parse-xml.mjs +108 -0
  222. package/build/translators/parse-xml.mjs.map +1 -0
  223. package/build/translators/pluralization/icu-validator.cjs +36 -0
  224. package/build/translators/pluralization/icu-validator.mjs +36 -0
  225. package/build/translators/pluralization/icu-validator.mjs.map +1 -0
  226. package/build/translators/pluralization/pattern-detector.cjs +25 -0
  227. package/build/translators/pluralization/pattern-detector.mjs +25 -0
  228. package/build/translators/pluralization/pattern-detector.mjs.map +1 -0
  229. package/build/translators/pluralization/prompt.cjs +98 -0
  230. package/build/translators/pluralization/prompt.mjs +98 -0
  231. package/build/translators/pluralization/prompt.mjs.map +1 -0
  232. package/build/translators/pluralization/service.cjs +247 -0
  233. package/build/translators/pluralization/service.mjs +247 -0
  234. package/build/translators/pluralization/service.mjs.map +1 -0
  235. package/build/translators/pluralization/shots.cjs +53 -0
  236. package/build/translators/pluralization/shots.mjs +53 -0
  237. package/build/translators/pluralization/shots.mjs.map +1 -0
  238. package/build/translators/pluralization/types.d.cts +17 -0
  239. package/build/translators/pluralization/types.d.cts.map +1 -0
  240. package/build/translators/pluralization/types.d.mts +17 -0
  241. package/build/translators/pluralization/types.d.mts.map +1 -0
  242. package/build/translators/pseudotranslator/index.cjs +129 -0
  243. package/build/translators/pseudotranslator/index.mjs +129 -0
  244. package/build/translators/pseudotranslator/index.mjs.map +1 -0
  245. package/build/translators/translation-service.cjs +182 -0
  246. package/build/translators/translation-service.mjs +183 -0
  247. package/build/translators/translation-service.mjs.map +1 -0
  248. package/build/translators/translator-factory.cjs +49 -0
  249. package/build/translators/translator-factory.mjs +50 -0
  250. package/build/translators/translator-factory.mjs.map +1 -0
  251. package/build/types.d.cts +161 -0
  252. package/build/types.d.cts.map +1 -0
  253. package/build/types.d.mts +161 -0
  254. package/build/types.d.mts.map +1 -0
  255. package/build/utils/config-factory.cjs +58 -0
  256. package/build/utils/config-factory.mjs +58 -0
  257. package/build/utils/config-factory.mjs.map +1 -0
  258. package/build/utils/hash.cjs +17 -0
  259. package/build/utils/hash.mjs +16 -0
  260. package/build/utils/hash.mjs.map +1 -0
  261. package/build/utils/is-valid-locale.cjs +14 -0
  262. package/build/utils/is-valid-locale.mjs +14 -0
  263. package/build/utils/is-valid-locale.mjs.map +1 -0
  264. package/build/utils/logger.cjs +51 -0
  265. package/build/utils/logger.mjs +50 -0
  266. package/build/utils/logger.mjs.map +1 -0
  267. package/build/utils/path-helpers.cjs +49 -0
  268. package/build/utils/path-helpers.mjs +47 -0
  269. package/build/utils/path-helpers.mjs.map +1 -0
  270. package/build/utils/timeout.cjs +42 -0
  271. package/build/utils/timeout.mjs +41 -0
  272. package/build/utils/timeout.mjs.map +1 -0
  273. package/build/virtual/code-generator.cjs +54 -0
  274. package/build/virtual/code-generator.mjs +53 -0
  275. package/build/virtual/code-generator.mjs.map +1 -0
  276. package/build/virtual/config.cjs +10 -0
  277. package/build/virtual/config.d.cts +9 -0
  278. package/build/virtual/config.d.cts.map +1 -0
  279. package/build/virtual/config.d.mts +9 -0
  280. package/build/virtual/config.d.mts.map +1 -0
  281. package/build/virtual/config.mjs +8 -0
  282. package/build/virtual/config.mjs.map +1 -0
  283. package/build/virtual/locale/client.cjs +23 -0
  284. package/build/virtual/locale/client.d.cts +19 -0
  285. package/build/virtual/locale/client.d.cts.map +1 -0
  286. package/build/virtual/locale/client.d.mts +19 -0
  287. package/build/virtual/locale/client.d.mts.map +1 -0
  288. package/build/virtual/locale/client.mjs +22 -0
  289. package/build/virtual/locale/client.mjs.map +1 -0
  290. package/build/virtual/locale/server.cjs +13 -0
  291. package/build/virtual/locale/server.d.cts +13 -0
  292. package/build/virtual/locale/server.d.cts.map +1 -0
  293. package/build/virtual/locale/server.d.mts +13 -0
  294. package/build/virtual/locale/server.d.mts.map +1 -0
  295. package/build/virtual/locale/server.mjs +13 -0
  296. package/build/virtual/locale/server.mjs.map +1 -0
  297. package/build/widget/lingo-dev-widget.cjs +228 -0
  298. package/build/widget/lingo-dev-widget.mjs +229 -0
  299. package/build/widget/lingo-dev-widget.mjs.map +1 -0
  300. package/package.json +189 -0
@@ -0,0 +1,14 @@
1
+ import { isValidLocale } from "lingo.dev/locale-codes";
2
+
3
+ //#region src/utils/is-valid-locale.ts
4
+ function isValidLocale$1(locale) {
5
+ return isValidLocale(locale);
6
+ }
7
+ function parseLocaleOrThrow(locale) {
8
+ if (locale && isValidLocale$1(locale)) return locale;
9
+ else throw new Error(`Invalid locale: ${locale}`);
10
+ }
11
+
12
+ //#endregion
13
+ export { parseLocaleOrThrow };
14
+ //# sourceMappingURL=is-valid-locale.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-valid-locale.mjs","names":["isValidLocale","_isValidLocale"],"sources":["../../src/utils/is-valid-locale.ts"],"sourcesContent":["import { isValidLocale as _isValidLocale } from \"lingo.dev/locale-codes\";\nimport type { LocaleCode } from \"lingo.dev/spec\";\n\nexport function isValidLocale(locale: string): locale is LocaleCode {\n return _isValidLocale(locale);\n}\n\nexport function parseLocale(\n locale: string | undefined,\n): LocaleCode | undefined {\n return locale && isValidLocale(locale) ? locale : undefined;\n}\n\nexport function parseLocaleOrThrow(locale: string | undefined): LocaleCode {\n if (locale && isValidLocale(locale)) {\n return locale;\n } else {\n throw new Error(`Invalid locale: ${locale}`);\n }\n}\n"],"mappings":";;;AAGA,SAAgBA,gBAAc,QAAsC;AAClE,QAAOC,cAAe,OAAO;;AAS/B,SAAgB,mBAAmB,QAAwC;AACzE,KAAI,UAAUD,gBAAc,OAAO,CACjC,QAAO;KAEP,OAAM,IAAI,MAAM,mBAAmB,SAAS"}
@@ -0,0 +1,51 @@
1
+
2
+ //#region src/utils/logger.ts
3
+ var Logger = class {
4
+ config;
5
+ prefix = "\x1B[42m\x1B[30m[Lingo.dev]\x1B[0m";
6
+ constructor(config = {}) {
7
+ this.config = {
8
+ enableDebug: config.enableDebug ?? (typeof process !== "undefined" && process.env?.LINGO_DEBUG === "true"),
9
+ enableConsole: config.enableConsole ?? true,
10
+ writeToFile: config.writeToFile
11
+ };
12
+ }
13
+ setDebug(enabled) {
14
+ this.config.enableDebug = enabled;
15
+ }
16
+ setConsoleEnabled(enabled) {
17
+ this.config.enableConsole = enabled;
18
+ }
19
+ /**
20
+ * Set a custom file writer function
21
+ * This allows server-side code to inject file writing without importing fs
22
+ */
23
+ setFileWriter(writer) {
24
+ this.config.writeToFile = writer;
25
+ }
26
+ formatMessage(...args) {
27
+ return args.map((arg) => typeof arg === "object" ? JSON.stringify(arg, null, 2) : String(arg)).join(" ");
28
+ }
29
+ log(level, ...args) {
30
+ const message = this.formatMessage(...args);
31
+ if (this.config.enableConsole) (level === "debug" || level === "info" ? console.log : console[level])(this.prefix, message);
32
+ if (this.config.writeToFile) this.config.writeToFile(level, message);
33
+ }
34
+ debug(...args) {
35
+ if (this.config.enableDebug) this.log("debug", ...args);
36
+ }
37
+ info(...args) {
38
+ this.log("info", ...args);
39
+ }
40
+ warn(...args) {
41
+ this.log("warn", ...args);
42
+ }
43
+ error(...args) {
44
+ this.log("error", ...args);
45
+ }
46
+ };
47
+ const logger = new Logger({ enableConsole: true });
48
+
49
+ //#endregion
50
+ exports.Logger = Logger;
51
+ exports.logger = logger;
@@ -0,0 +1,50 @@
1
+ //#region src/utils/logger.ts
2
+ var Logger = class {
3
+ config;
4
+ prefix = "\x1B[42m\x1B[30m[Lingo.dev]\x1B[0m";
5
+ constructor(config = {}) {
6
+ this.config = {
7
+ enableDebug: config.enableDebug ?? (typeof process !== "undefined" && process.env?.LINGO_DEBUG === "true"),
8
+ enableConsole: config.enableConsole ?? true,
9
+ writeToFile: config.writeToFile
10
+ };
11
+ }
12
+ setDebug(enabled) {
13
+ this.config.enableDebug = enabled;
14
+ }
15
+ setConsoleEnabled(enabled) {
16
+ this.config.enableConsole = enabled;
17
+ }
18
+ /**
19
+ * Set a custom file writer function
20
+ * This allows server-side code to inject file writing without importing fs
21
+ */
22
+ setFileWriter(writer) {
23
+ this.config.writeToFile = writer;
24
+ }
25
+ formatMessage(...args) {
26
+ return args.map((arg) => typeof arg === "object" ? JSON.stringify(arg, null, 2) : String(arg)).join(" ");
27
+ }
28
+ log(level, ...args) {
29
+ const message = this.formatMessage(...args);
30
+ if (this.config.enableConsole) (level === "debug" || level === "info" ? console.log : console[level])(this.prefix, message);
31
+ if (this.config.writeToFile) this.config.writeToFile(level, message);
32
+ }
33
+ debug(...args) {
34
+ if (this.config.enableDebug) this.log("debug", ...args);
35
+ }
36
+ info(...args) {
37
+ this.log("info", ...args);
38
+ }
39
+ warn(...args) {
40
+ this.log("warn", ...args);
41
+ }
42
+ error(...args) {
43
+ this.log("error", ...args);
44
+ }
45
+ };
46
+ const logger = new Logger({ enableConsole: true });
47
+
48
+ //#endregion
49
+ export { Logger, logger };
50
+ //# sourceMappingURL=logger.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.mjs","names":[],"sources":["../../src/utils/logger.ts"],"sourcesContent":["export type LogLevel = \"debug\" | \"info\" | \"warn\" | \"error\";\n\ninterface LoggerConfig {\n enableDebug: boolean;\n enableConsole?: boolean;\n writeToFile?: (level: LogLevel, message: string) => void;\n}\n\nexport class Logger {\n private config: LoggerConfig;\n private readonly prefix = \"\\x1b[42m\\x1b[30m[Lingo.dev]\\x1b[0m\";\n\n constructor(config: Partial<LoggerConfig> = {}) {\n this.config = {\n enableDebug:\n config.enableDebug ??\n (typeof process !== \"undefined\" && process.env?.LINGO_DEBUG === \"true\"),\n enableConsole: config.enableConsole ?? true,\n writeToFile: config.writeToFile,\n };\n }\n\n setDebug(enabled: boolean) {\n this.config.enableDebug = enabled;\n }\n\n setConsoleEnabled(enabled: boolean) {\n this.config.enableConsole = enabled;\n }\n\n /**\n * Set a custom file writer function\n * This allows server-side code to inject file writing without importing fs\n */\n setFileWriter(writer: (level: LogLevel, message: string) => void) {\n this.config.writeToFile = writer;\n }\n\n private formatMessage(...args: any[]): string {\n return args\n .map((arg) =>\n typeof arg === \"object\" ? JSON.stringify(arg, null, 2) : String(arg),\n )\n .join(\" \");\n }\n\n private log(level: LogLevel, ...args: any[]) {\n const message = this.formatMessage(...args);\n\n // Console output\n if (this.config.enableConsole) {\n const consoleMethod =\n level === \"debug\" || level === \"info\" ? console.log : console[level];\n consoleMethod(this.prefix, message);\n }\n\n // File output (if configured)\n if (this.config.writeToFile) {\n this.config.writeToFile(level, message);\n }\n }\n\n debug(...args: any[]) {\n if (this.config.enableDebug) {\n this.log(\"debug\", ...args);\n }\n }\n\n info(...args: any[]) {\n this.log(\"info\", ...args);\n }\n\n warn(...args: any[]) {\n this.log(\"warn\", ...args);\n }\n\n error(...args: any[]) {\n this.log(\"error\", ...args);\n }\n}\n\nexport const logger = new Logger({\n enableConsole: true,\n});\n"],"mappings":";AAQA,IAAa,SAAb,MAAoB;CAClB,AAAQ;CACR,AAAiB,SAAS;CAE1B,YAAY,SAAgC,EAAE,EAAE;AAC9C,OAAK,SAAS;GACZ,aACE,OAAO,gBACN,OAAO,YAAY,eAAe,QAAQ,KAAK,gBAAgB;GAClE,eAAe,OAAO,iBAAiB;GACvC,aAAa,OAAO;GACrB;;CAGH,SAAS,SAAkB;AACzB,OAAK,OAAO,cAAc;;CAG5B,kBAAkB,SAAkB;AAClC,OAAK,OAAO,gBAAgB;;;;;;CAO9B,cAAc,QAAoD;AAChE,OAAK,OAAO,cAAc;;CAG5B,AAAQ,cAAc,GAAG,MAAqB;AAC5C,SAAO,KACJ,KAAK,QACJ,OAAO,QAAQ,WAAW,KAAK,UAAU,KAAK,MAAM,EAAE,GAAG,OAAO,IAAI,CACrE,CACA,KAAK,IAAI;;CAGd,AAAQ,IAAI,OAAiB,GAAG,MAAa;EAC3C,MAAM,UAAU,KAAK,cAAc,GAAG,KAAK;AAG3C,MAAI,KAAK,OAAO,cAGd,EADE,UAAU,WAAW,UAAU,SAAS,QAAQ,MAAM,QAAQ,QAClD,KAAK,QAAQ,QAAQ;AAIrC,MAAI,KAAK,OAAO,YACd,MAAK,OAAO,YAAY,OAAO,QAAQ;;CAI3C,MAAM,GAAG,MAAa;AACpB,MAAI,KAAK,OAAO,YACd,MAAK,IAAI,SAAS,GAAG,KAAK;;CAI9B,KAAK,GAAG,MAAa;AACnB,OAAK,IAAI,QAAQ,GAAG,KAAK;;CAG3B,KAAK,GAAG,MAAa;AACnB,OAAK,IAAI,QAAQ,GAAG,KAAK;;CAG3B,MAAM,GAAG,MAAa;AACpB,OAAK,IAAI,SAAS,GAAG,KAAK;;;AAI9B,MAAa,SAAS,IAAI,OAAO,EAC/B,eAAe,MAChB,CAAC"}
@@ -0,0 +1,49 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ let path = require("path");
3
+ path = require_rolldown_runtime.__toESM(path);
4
+
5
+ //#region src/utils/path-helpers.ts
6
+ /**
7
+ * Path resolution utilities
8
+ * Centralize path construction logic to eliminate duplication
9
+ */
10
+ /**
11
+ * Resolve a path to absolute, using cwd as base if relative
12
+ *
13
+ * @param configPath - Path from config (may be relative or absolute)
14
+ * @param basePath - Base path to resolve against (defaults to cwd)
15
+ * @returns Absolute path
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * resolveAbsolutePath("src") // -> "/full/path/to/cwd/src"
20
+ * resolveAbsolutePath("/abs/path") // -> "/abs/path"
21
+ * ```
22
+ */
23
+ function resolveAbsolutePath(configPath, basePath = process.cwd()) {
24
+ return path.default.isAbsolute(configPath) ? configPath : path.default.join(basePath, configPath);
25
+ }
26
+ /**
27
+ * Get the absolute path to the lingo directory
28
+ *
29
+ * @param config - Config with sourceRoot and lingoDir
30
+ * @returns Absolute path to .lingo directory
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * getLingoDir({ sourceRoot: "src", lingoDir: ".lingo" })
35
+ * // -> "/full/path/to/src/.lingo"
36
+ * ```
37
+ */
38
+ function getLingoDir(config) {
39
+ const rootPath = resolveAbsolutePath(config.sourceRoot);
40
+ return path.default.join(rootPath, config.lingoDir);
41
+ }
42
+ function getCacheDir(config) {
43
+ const lingoDir = getLingoDir(config);
44
+ return path.default.join(lingoDir, "cache");
45
+ }
46
+
47
+ //#endregion
48
+ exports.getCacheDir = getCacheDir;
49
+ exports.getLingoDir = getLingoDir;
@@ -0,0 +1,47 @@
1
+ import path from "path";
2
+
3
+ //#region src/utils/path-helpers.ts
4
+ /**
5
+ * Path resolution utilities
6
+ * Centralize path construction logic to eliminate duplication
7
+ */
8
+ /**
9
+ * Resolve a path to absolute, using cwd as base if relative
10
+ *
11
+ * @param configPath - Path from config (may be relative or absolute)
12
+ * @param basePath - Base path to resolve against (defaults to cwd)
13
+ * @returns Absolute path
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * resolveAbsolutePath("src") // -> "/full/path/to/cwd/src"
18
+ * resolveAbsolutePath("/abs/path") // -> "/abs/path"
19
+ * ```
20
+ */
21
+ function resolveAbsolutePath(configPath, basePath = process.cwd()) {
22
+ return path.isAbsolute(configPath) ? configPath : path.join(basePath, configPath);
23
+ }
24
+ /**
25
+ * Get the absolute path to the lingo directory
26
+ *
27
+ * @param config - Config with sourceRoot and lingoDir
28
+ * @returns Absolute path to .lingo directory
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * getLingoDir({ sourceRoot: "src", lingoDir: ".lingo" })
33
+ * // -> "/full/path/to/src/.lingo"
34
+ * ```
35
+ */
36
+ function getLingoDir(config) {
37
+ const rootPath = resolveAbsolutePath(config.sourceRoot);
38
+ return path.join(rootPath, config.lingoDir);
39
+ }
40
+ function getCacheDir(config) {
41
+ const lingoDir = getLingoDir(config);
42
+ return path.join(lingoDir, "cache");
43
+ }
44
+
45
+ //#endregion
46
+ export { getCacheDir, getLingoDir };
47
+ //# sourceMappingURL=path-helpers.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path-helpers.mjs","names":[],"sources":["../../src/utils/path-helpers.ts"],"sourcesContent":["/**\n * Path resolution utilities\n * Centralize path construction logic to eliminate duplication\n */\n\nimport path from \"path\";\nimport type { PathConfig } from \"../types\";\n\n/**\n * Resolve a path to absolute, using cwd as base if relative\n *\n * @param configPath - Path from config (may be relative or absolute)\n * @param basePath - Base path to resolve against (defaults to cwd)\n * @returns Absolute path\n *\n * @example\n * ```typescript\n * resolveAbsolutePath(\"src\") // -> \"/full/path/to/cwd/src\"\n * resolveAbsolutePath(\"/abs/path\") // -> \"/abs/path\"\n * ```\n */\nexport function resolveAbsolutePath(\n configPath: string,\n basePath: string = process.cwd(),\n): string {\n return path.isAbsolute(configPath)\n ? configPath\n : path.join(basePath, configPath);\n}\n\n/**\n * Get the absolute path to the lingo directory\n *\n * @param config - Config with sourceRoot and lingoDir\n * @returns Absolute path to .lingo directory\n *\n * @example\n * ```typescript\n * getLingoDir({ sourceRoot: \"src\", lingoDir: \".lingo\" })\n * // -> \"/full/path/to/src/.lingo\"\n * ```\n */\nexport function getLingoDir(config: PathConfig): string {\n const rootPath = resolveAbsolutePath(config.sourceRoot);\n return path.join(rootPath, config.lingoDir);\n}\n\nexport function getCacheDir(config: PathConfig): string {\n const lingoDir = getLingoDir(config);\n return path.join(lingoDir, \"cache\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,oBACd,YACA,WAAmB,QAAQ,KAAK,EACxB;AACR,QAAO,KAAK,WAAW,WAAW,GAC9B,aACA,KAAK,KAAK,UAAU,WAAW;;;;;;;;;;;;;;AAerC,SAAgB,YAAY,QAA4B;CACtD,MAAM,WAAW,oBAAoB,OAAO,WAAW;AACvD,QAAO,KAAK,KAAK,UAAU,OAAO,SAAS;;AAG7C,SAAgB,YAAY,QAA4B;CACtD,MAAM,WAAW,YAAY,OAAO;AACpC,QAAO,KAAK,KAAK,UAAU,QAAQ"}
@@ -0,0 +1,42 @@
1
+
2
+ //#region src/utils/timeout.ts
3
+ /**
4
+ * Timeout utilities for preventing operations from hanging indefinitely
5
+ */
6
+ /**
7
+ * Wrap a promise with a timeout
8
+ * If the promise doesn't resolve/reject within the timeout, it will reject with a TimeoutError
9
+ *
10
+ * @param promise - The promise to wrap
11
+ * @param timeoutMs - Timeout in milliseconds
12
+ * @param operationName - Name of the operation for error messages
13
+ * @returns Promise that resolves/rejects with timeout protection
14
+ */
15
+ function withTimeout(promise, timeoutMs, operationName = "Operation") {
16
+ return Promise.race([promise, new Promise((_, reject) => setTimeout(() => reject(new TimeoutError(`${operationName} timed out after ${timeoutMs}ms`, timeoutMs)), timeoutMs))]);
17
+ }
18
+ /**
19
+ * Custom error for timeout operations
20
+ */
21
+ var TimeoutError = class extends Error {
22
+ constructor(message, timeoutMs) {
23
+ super(message);
24
+ this.timeoutMs = timeoutMs;
25
+ this.name = "TimeoutError";
26
+ }
27
+ };
28
+ /**
29
+ * Default timeout values (in milliseconds)
30
+ */
31
+ const DEFAULT_TIMEOUTS = {
32
+ FILE_IO: 1e4,
33
+ METADATA: 15e3,
34
+ AI_API: 6e4,
35
+ HTTP_REQUEST: 3e4,
36
+ SERVER_START: 3e4,
37
+ TRANSLATION: 12e4
38
+ };
39
+
40
+ //#endregion
41
+ exports.DEFAULT_TIMEOUTS = DEFAULT_TIMEOUTS;
42
+ exports.withTimeout = withTimeout;
@@ -0,0 +1,41 @@
1
+ //#region src/utils/timeout.ts
2
+ /**
3
+ * Timeout utilities for preventing operations from hanging indefinitely
4
+ */
5
+ /**
6
+ * Wrap a promise with a timeout
7
+ * If the promise doesn't resolve/reject within the timeout, it will reject with a TimeoutError
8
+ *
9
+ * @param promise - The promise to wrap
10
+ * @param timeoutMs - Timeout in milliseconds
11
+ * @param operationName - Name of the operation for error messages
12
+ * @returns Promise that resolves/rejects with timeout protection
13
+ */
14
+ function withTimeout(promise, timeoutMs, operationName = "Operation") {
15
+ return Promise.race([promise, new Promise((_, reject) => setTimeout(() => reject(new TimeoutError(`${operationName} timed out after ${timeoutMs}ms`, timeoutMs)), timeoutMs))]);
16
+ }
17
+ /**
18
+ * Custom error for timeout operations
19
+ */
20
+ var TimeoutError = class extends Error {
21
+ constructor(message, timeoutMs) {
22
+ super(message);
23
+ this.timeoutMs = timeoutMs;
24
+ this.name = "TimeoutError";
25
+ }
26
+ };
27
+ /**
28
+ * Default timeout values (in milliseconds)
29
+ */
30
+ const DEFAULT_TIMEOUTS = {
31
+ FILE_IO: 1e4,
32
+ METADATA: 15e3,
33
+ AI_API: 6e4,
34
+ HTTP_REQUEST: 3e4,
35
+ SERVER_START: 3e4,
36
+ TRANSLATION: 12e4
37
+ };
38
+
39
+ //#endregion
40
+ export { DEFAULT_TIMEOUTS, withTimeout };
41
+ //# sourceMappingURL=timeout.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timeout.mjs","names":["timeoutMs: number"],"sources":["../../src/utils/timeout.ts"],"sourcesContent":["/**\n * Timeout utilities for preventing operations from hanging indefinitely\n */\n\n/**\n * Wrap a promise with a timeout\n * If the promise doesn't resolve/reject within the timeout, it will reject with a TimeoutError\n *\n * @param promise - The promise to wrap\n * @param timeoutMs - Timeout in milliseconds\n * @param operationName - Name of the operation for error messages\n * @returns Promise that resolves/rejects with timeout protection\n */\nexport function withTimeout<T>(\n promise: Promise<T>,\n timeoutMs: number,\n operationName: string = \"Operation\",\n): Promise<T> {\n return Promise.race([\n promise,\n new Promise<T>((_, reject) =>\n setTimeout(\n () =>\n reject(\n new TimeoutError(\n `${operationName} timed out after ${timeoutMs}ms`,\n timeoutMs,\n ),\n ),\n timeoutMs,\n ),\n ),\n ]);\n}\n\n/**\n * Custom error for timeout operations\n */\nexport class TimeoutError extends Error {\n constructor(\n message: string,\n public readonly timeoutMs: number,\n ) {\n super(message);\n this.name = \"TimeoutError\";\n }\n}\n\n/**\n * Default timeout values (in milliseconds)\n */\nexport const DEFAULT_TIMEOUTS = {\n /** File I/O operations (read/write) */\n FILE_IO: 10_000, // 10 seconds\n\n /** Metadata operations (loading/saving) */\n METADATA: 15_000, // 15 seconds\n\n /** AI API calls for translation */\n AI_API: 60_000, // 60 seconds\n\n /** HTTP requests to translation server */\n HTTP_REQUEST: 30_000, // 30 seconds\n\n /** Server initialization */\n SERVER_START: 30_000, // 30 seconds\n\n /** Translation service full operation */\n TRANSLATION: 120_000, // 2 minutes\n} as const;\n"],"mappings":";;;;;;;;;;;;;AAaA,SAAgB,YACd,SACA,WACA,gBAAwB,aACZ;AACZ,QAAO,QAAQ,KAAK,CAClB,SACA,IAAI,SAAY,GAAG,WACjB,iBAEI,OACE,IAAI,aACF,GAAG,cAAc,mBAAmB,UAAU,KAC9C,UACD,CACF,EACH,UACD,CACF,CACF,CAAC;;;;;AAMJ,IAAa,eAAb,cAAkC,MAAM;CACtC,YACE,SACA,AAAgBA,WAChB;AACA,QAAM,QAAQ;EAFE;AAGhB,OAAK,OAAO;;;;;;AAOhB,MAAa,mBAAmB;CAE9B,SAAS;CAGT,UAAU;CAGV,QAAQ;CAGR,cAAc;CAGd,cAAc;CAGd,aAAa;CACd"}
@@ -0,0 +1,54 @@
1
+ const require_path_helpers = require('../utils/path-helpers.cjs');
2
+
3
+ //#region src/virtual/code-generator.ts
4
+ /**
5
+ * Generate complete config module
6
+ * Exports serverUrl and cacheDir constants
7
+ */
8
+ function generateConfigModule(config) {
9
+ const serverUrl = config.dev.translationServerUrl;
10
+ const cacheDir = require_path_helpers.getCacheDir(config);
11
+ return `export const serverUrl = ${JSON.stringify(serverUrl)};
12
+ export const cacheDir = ${JSON.stringify(cacheDir)};
13
+ export const sourceLocale = ${JSON.stringify(config.sourceLocale)};
14
+ `;
15
+ }
16
+ /**
17
+ * Generate complete locale/server module
18
+ * Exports async getServerLocale() function
19
+ */
20
+ function generateServerLocaleModule(config) {
21
+ return `
22
+ import { createNextCookieLocaleResolver } from '@lingo.dev/compiler/react/next';
23
+ export const getServerLocale = createNextCookieLocaleResolver({ cookieConfig: ${JSON.stringify(config.localePersistence.config)}, defaultLocale: ${JSON.stringify(config.sourceLocale)} });
24
+ `;
25
+ }
26
+ /**
27
+ * Generate complete locale/client module
28
+ * Exports getClientLocale() and persistLocale() functions
29
+ */
30
+ function generateClientLocaleModule(config) {
31
+ const cookieName = config.localePersistence.config.name;
32
+ const maxAge = config.localePersistence.config.maxAge;
33
+ return `
34
+ export function getClientLocale() {
35
+ if (typeof document !== 'undefined') {
36
+ const match = document.cookie.match(/${cookieName}=([^;]+)/);
37
+ if (match) return match[1];
38
+ }
39
+ // Fallback to source locale
40
+ return ${JSON.stringify(config.sourceLocale)};
41
+ }
42
+
43
+ export function persistLocale(locale) {
44
+ if (typeof document !== 'undefined') {
45
+ document.cookie = \`${cookieName}=\${locale}; path=/; max-age=${maxAge}\`;
46
+ }
47
+ }
48
+ `;
49
+ }
50
+
51
+ //#endregion
52
+ exports.generateClientLocaleModule = generateClientLocaleModule;
53
+ exports.generateConfigModule = generateConfigModule;
54
+ exports.generateServerLocaleModule = generateServerLocaleModule;
@@ -0,0 +1,53 @@
1
+ import { getCacheDir } from "../utils/path-helpers.mjs";
2
+
3
+ //#region src/virtual/code-generator.ts
4
+ /**
5
+ * Generate complete config module
6
+ * Exports serverUrl and cacheDir constants
7
+ */
8
+ function generateConfigModule(config) {
9
+ const serverUrl = config.dev.translationServerUrl;
10
+ const cacheDir = getCacheDir(config);
11
+ return `export const serverUrl = ${JSON.stringify(serverUrl)};
12
+ export const cacheDir = ${JSON.stringify(cacheDir)};
13
+ export const sourceLocale = ${JSON.stringify(config.sourceLocale)};
14
+ `;
15
+ }
16
+ /**
17
+ * Generate complete locale/server module
18
+ * Exports async getServerLocale() function
19
+ */
20
+ function generateServerLocaleModule(config) {
21
+ return `
22
+ import { createNextCookieLocaleResolver } from '@lingo.dev/compiler/react/next';
23
+ export const getServerLocale = createNextCookieLocaleResolver({ cookieConfig: ${JSON.stringify(config.localePersistence.config)}, defaultLocale: ${JSON.stringify(config.sourceLocale)} });
24
+ `;
25
+ }
26
+ /**
27
+ * Generate complete locale/client module
28
+ * Exports getClientLocale() and persistLocale() functions
29
+ */
30
+ function generateClientLocaleModule(config) {
31
+ const cookieName = config.localePersistence.config.name;
32
+ const maxAge = config.localePersistence.config.maxAge;
33
+ return `
34
+ export function getClientLocale() {
35
+ if (typeof document !== 'undefined') {
36
+ const match = document.cookie.match(/${cookieName}=([^;]+)/);
37
+ if (match) return match[1];
38
+ }
39
+ // Fallback to source locale
40
+ return ${JSON.stringify(config.sourceLocale)};
41
+ }
42
+
43
+ export function persistLocale(locale) {
44
+ if (typeof document !== 'undefined') {
45
+ document.cookie = \`${cookieName}=\${locale}; path=/; max-age=${maxAge}\`;
46
+ }
47
+ }
48
+ `;
49
+ }
50
+
51
+ //#endregion
52
+ export { generateClientLocaleModule, generateConfigModule, generateServerLocaleModule };
53
+ //# sourceMappingURL=code-generator.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-generator.mjs","names":[],"sources":["../../src/virtual/code-generator.ts"],"sourcesContent":["/**\n * Shared code generation for virtual modules\n * Used by both unplugin (virtual modules) and Turbopack loaders\n *\n * This module provides FULL module generators, not just function bodies.\n * Both loaders and unplugin use these to generate complete modules.\n */\n\nimport type { LingoConfig } from \"../types\";\nimport { getCacheDir } from \"../utils/path-helpers\";\n\n/**\n * Generate complete config module\n * Exports serverUrl and cacheDir constants\n */\nexport function generateConfigModule(config: LingoConfig): string {\n const serverUrl = config.dev.translationServerUrl;\n const cacheDir = getCacheDir(config);\n\n return `export const serverUrl = ${JSON.stringify(serverUrl)};\nexport const cacheDir = ${JSON.stringify(cacheDir)};\nexport const sourceLocale = ${JSON.stringify(config.sourceLocale)};\n`;\n}\n\n/**\n * Generate complete locale/server module\n * Exports async getServerLocale() function\n */\nexport function generateServerLocaleModule(config: LingoConfig): string {\n return `\nimport { createNextCookieLocaleResolver } from '@lingo.dev/compiler/react/next';\nexport const getServerLocale = createNextCookieLocaleResolver({ cookieConfig: ${JSON.stringify(config.localePersistence.config)}, defaultLocale: ${JSON.stringify(config.sourceLocale)} });\n`;\n}\n\n/**\n * Generate complete locale/client module\n * Exports getClientLocale() and persistLocale() functions\n */\nexport function generateClientLocaleModule(config: LingoConfig): string {\n const cookieName = config.localePersistence.config.name;\n const maxAge = config.localePersistence.config.maxAge;\n\n return `\nexport function getClientLocale() {\n if (typeof document !== 'undefined') {\n const match = document.cookie.match(/${cookieName}=([^;]+)/);\n if (match) return match[1];\n }\n // Fallback to source locale\n return ${JSON.stringify(config.sourceLocale)};\n}\n\nexport function persistLocale(locale) {\n if (typeof document !== 'undefined') {\n document.cookie = \\`${cookieName}=\\${locale}; path=/; max-age=${maxAge}\\`;\n }\n}\n`;\n}\n"],"mappings":";;;;;;;AAeA,SAAgB,qBAAqB,QAA6B;CAChE,MAAM,YAAY,OAAO,IAAI;CAC7B,MAAM,WAAW,YAAY,OAAO;AAEpC,QAAO,4BAA4B,KAAK,UAAU,UAAU,CAAC;0BACrC,KAAK,UAAU,SAAS,CAAC;8BACrB,KAAK,UAAU,OAAO,aAAa,CAAC;;;;;;;AAQlE,SAAgB,2BAA2B,QAA6B;AACtE,QAAO;;gFAEuE,KAAK,UAAU,OAAO,kBAAkB,OAAO,CAAC,mBAAmB,KAAK,UAAU,OAAO,aAAa,CAAC;;;;;;;AAQvL,SAAgB,2BAA2B,QAA6B;CACtE,MAAM,aAAa,OAAO,kBAAkB,OAAO;CACnD,MAAM,SAAS,OAAO,kBAAkB,OAAO;AAE/C,QAAO;;;2CAGkC,WAAW;;;;WAI3C,KAAK,UAAU,OAAO,aAAa,CAAC;;;;;0BAKrB,WAAW,+BAA+B,OAAO"}
@@ -0,0 +1,10 @@
1
+
2
+ //#region src/virtual/config.ts
3
+ const serverUrl = "__SERVER_URL__";
4
+ const cacheDir = "__CACHE_DIR__";
5
+ const sourceLocale = "__SOURCE_LOCALE__";
6
+
7
+ //#endregion
8
+ exports.cacheDir = cacheDir;
9
+ exports.serverUrl = serverUrl;
10
+ exports.sourceLocale = sourceLocale;
@@ -0,0 +1,9 @@
1
+ import { LocaleCode } from "lingo.dev/spec";
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
+ //#endregion
8
+ export { cacheDir, serverUrl, sourceLocale };
9
+ //# sourceMappingURL=config.d.cts.map
@@ -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"}
@@ -0,0 +1,9 @@
1
+ import { LocaleCode } from "lingo.dev/spec";
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
+ //#endregion
8
+ export { cacheDir, serverUrl, sourceLocale };
9
+ //# 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"}
@@ -0,0 +1,8 @@
1
+ //#region src/virtual/config.ts
2
+ const serverUrl = "__SERVER_URL__";
3
+ const cacheDir = "__CACHE_DIR__";
4
+ const sourceLocale = "__SOURCE_LOCALE__";
5
+
6
+ //#endregion
7
+ export { cacheDir, serverUrl, sourceLocale };
8
+ //# sourceMappingURL=config.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.mjs","names":[],"sources":["../../src/virtual/config.ts"],"sourcesContent":["import type { LocaleCode } from \"lingo.dev/spec\";\n\nexport const serverUrl = \"__SERVER_URL__\";\nexport const cacheDir = \"__CACHE_DIR__\";\nexport const sourceLocale = \"__SOURCE_LOCALE__\" as LocaleCode;\n"],"mappings":";AAEA,MAAa,YAAY;AACzB,MAAa,WAAW;AACxB,MAAa,eAAe"}
@@ -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 "lingo.dev/spec";
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 "lingo.dev/spec";
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 \"lingo.dev/spec\";\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 "lingo.dev/spec";
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 "lingo.dev/spec";
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"}