@menapo/vi18n 0.1.1 → 0.1.2

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 (118) hide show
  1. package/dist/{apply-Bre-lY9J.js → apply-FAHl1R6T.js} +69 -89
  2. package/dist/{captured-Bj8bO6vd.js → captured-CTjjDF5o.js} +196 -217
  3. package/dist/{check-BIKEuu6B.js → check-DwFwOB1d.js} +66 -84
  4. package/dist/cli.js +2 -3
  5. package/dist/{collect-Cx4_SKOe.js → collect-CYATDjdo.js} +1 -2
  6. package/dist/collisions-uMTuq36M.js +215 -0
  7. package/dist/compile-CEvH-6sY.js +240 -0
  8. package/dist/{compile-Cc97JaW2.js → compile-DqkofbiO.js} +376 -331
  9. package/dist/concurrency-BCY_4zcr.js +1 -0
  10. package/dist/concurrency-Dy2ny50V.js +107 -0
  11. package/dist/config.d.ts +1 -5
  12. package/dist/config.js +4 -5
  13. package/dist/{types-D3QGM8XO.js → diagnostics-1onDF6Ua.js} +26 -26
  14. package/dist/{dir-zw6bGMKQ.js → dir-TGLYuOZb.js} +34 -37
  15. package/dist/{duplicates-yuRljQ6h.js → duplicates-CsUXRX2J.js} +10 -27
  16. package/dist/engine-Bf7nVigL.js +556 -0
  17. package/dist/engine.d.ts +1 -5
  18. package/dist/engine.js +297 -168
  19. package/dist/exchange-DYG9RZoT.js +41 -0
  20. package/dist/{exclude-Du-Zd_qI.js → exclude-vMnm3lqU.js} +2 -3
  21. package/dist/{export-C9Sy6UWv.js → export-BYq0gfLd.js} +17 -38
  22. package/dist/{extract-C3S8btx0.js → extract-CYtuEo8u.js} +114 -82
  23. package/dist/{formats-9unqj_fZ.js → formats-ChV1LVH_.js} +352 -276
  24. package/dist/fs-ezCMZeDV.js +52 -0
  25. package/dist/i18next-1waHziMy.js +1 -0
  26. package/dist/i18next-D66Icz3L.js +1907 -0
  27. package/dist/{import-nANvQutw.js → import-BApbQlmm.js} +81 -75
  28. package/dist/index.d.ts +1 -13
  29. package/dist/index.js +14 -16
  30. package/dist/{init-C2ScuW6a.js → init-J7AwwA5e.js} +466 -501
  31. package/dist/{library-D5CWvTQs.js → library-BfSOBeBd.js} +975 -451
  32. package/dist/lingui-Ee2farVo.js +902 -0
  33. package/dist/lint.d.ts +0 -4
  34. package/dist/lint.js +68 -81
  35. package/dist/{load-gW-oJt1Q.js → load-BFLLqY8x.js} +272 -147
  36. package/dist/{load-CQRz4PpM.js → load-CMwhukZ4.js} +1211 -1115
  37. package/dist/{locales-DX4MOBFE.js → locales-DxLDrx-h.js} +271 -237
  38. package/dist/{lsp-RMMMc88P.js → lsp-BC7xDGON.js} +4 -5
  39. package/dist/{match-BGr8EXB3.js → match-BLDcj610.js} +11 -4
  40. package/dist/{mcp-CHVwBoRP.js → mcp-Cka8ywDF.js} +4 -5
  41. package/dist/{merge-driver-BTX87aVm.js → merge-driver-B04Apm29.js} +138 -122
  42. package/dist/migrate-D7TNl6SD.js +2169 -0
  43. package/dist/migrate-khCY8TE0.js +1 -0
  44. package/dist/{openai-CTaMDcl-.js → openai-RWw0YlAx.js} +128 -87
  45. package/dist/{output-DWE3SIUA.js → output-CF9uvk_-.js} +15 -9
  46. package/dist/parse.d.ts +1 -3
  47. package/dist/parse.js +7 -8
  48. package/dist/{pipeline-DbX6rlo5.js → pipeline-B30irGMD.js} +1 -1
  49. package/dist/{pipeline-C9Dbotkh.js → pipeline-sgl_q_op.js} +387 -359
  50. package/dist/project-DSzWKU3C.js +544 -0
  51. package/dist/{pseudo-DRv30iN5.js → pseudo-DNbNNVGP.js} +125 -3
  52. package/dist/{raw-C4Y6vyGY.js → raw-YsYZMS9n.js} +52 -29
  53. package/dist/react-intl-tzGIk6G3.js +634 -0
  54. package/dist/restore-BG_zMpSj.js +199 -0
  55. package/dist/rewrite-hAcRJwiZ.js +415 -0
  56. package/dist/{rich-DCUKl5HM.js → rich-ApY1Dm4S.js} +35 -28
  57. package/dist/rolldown-runtime-C1I3wEg2.js +43 -0
  58. package/dist/{rolldown-runtime-D7D4PA-g.js → rolldown-runtime-D8jQpDG7.js} +1 -2
  59. package/dist/run-CFzR3V93.js +647 -0
  60. package/dist/scan-worker.d.ts +2 -4
  61. package/dist/scan-worker.js +1 -1
  62. package/dist/{scoped-BMYpSthj.js → scoped-h3KE8XWW.js} +3 -4
  63. package/dist/{server-deBOq2vq.js → server-WlxZH0oX.js} +275 -330
  64. package/dist/{server-Da1Ot9IN.js → server-ceuzzkal.js} +292 -386
  65. package/dist/server.d.ts +1 -17
  66. package/dist/server.js +415 -381
  67. package/dist/{sitemap-DJXzKoza.js → sitemap-796jJKUT.js} +21 -33
  68. package/dist/{sources-D19czDSA.js → sources-DuOdM02f.js} +712 -373
  69. package/dist/{status-zr4jY59Y.js → status-CTH3qI-0.js} +30 -30
  70. package/dist/{stdio-FPOKQAgu.js → stdio-D9kTzyqB.js} +2 -4
  71. package/dist/{stdio-CVaJfxA7.js → stdio-FWIVU3P4.js} +1 -2
  72. package/dist/sync-CpL0Qsgw.js +1352 -0
  73. package/dist/{t-DC-c9zE5.js → t-gvEXx25s.js} +76 -53
  74. package/dist/test.d.ts +5 -16
  75. package/dist/test.js +77 -48
  76. package/dist/translate-BrfVRkjl.js +336 -0
  77. package/dist/{ts-BaU5yOf0.js → ts-BX6kwig5.js} +25 -14
  78. package/dist/{types-DtvQ7UdD.js → types-3kwyaCAm.js} +1 -2
  79. package/dist/{types-DsdWBG0b.d.ts → types-BaG1LboH.d.ts} +2 -6
  80. package/dist/{types-CgUCkFU1.d.ts → types-Cy2bPdSg.d.ts} +14 -20
  81. package/dist/types-Ds_vebja.js +41 -0
  82. package/dist/{units-CQ5Q99RC.js → units-VVLgQ7x7.js} +7 -16
  83. package/dist/{url-CRfCOhUI.js → url-Bpc6wLea.js} +24 -11
  84. package/dist/{url-CsBkRaJy.js → url-D2_VlEeH.js} +25 -12
  85. package/dist/{validate-D6DJepZv.js → validate-PGgMsasz.js} +3 -5
  86. package/dist/{validate-BxpupdAf.js → validate-zv4-IZyZ.js} +690 -377
  87. package/dist/{version-Byqi2guX.js → version-BFs370Ce.js} +3 -5
  88. package/dist/{vite-scan-CT_vsp4g.js → vite-scan-DFKSGVE9.js} +87 -92
  89. package/dist/vite.d.ts +2 -6
  90. package/dist/vite.js +6482 -6018
  91. package/dist/vue-i18n-CBmZqHbG.js +806 -0
  92. package/dist/{which-BOemZ5Q8.js → which-BpyJyBkX.js} +44 -37
  93. package/dist/{worker-84U6uYB3.js → worker-BjzVqJVO.js} +454 -608
  94. package/package.json +5 -5
  95. package/dist/check-HsmmpJZg.js +0 -1
  96. package/dist/codec-DuvU2VQy.js +0 -207
  97. package/dist/collisions-CfpZU8e4.js +0 -217
  98. package/dist/compile-BaDh0cHG.js +0 -245
  99. package/dist/concurrency-C9UUWuDC.js +0 -96
  100. package/dist/concurrency-DONL7t4V.js +0 -1
  101. package/dist/engine-C2ENBRJe.js +0 -531
  102. package/dist/i18next-9HAoxwUI.js +0 -1
  103. package/dist/i18next-BEJgv_S8.js +0 -1596
  104. package/dist/lingui-zUiCl9Um.js +0 -833
  105. package/dist/messages-BfjIExyB.js +0 -166
  106. package/dist/migrate-IpLDMXmq.js +0 -1484
  107. package/dist/migrate-rCQuOGsf.js +0 -1
  108. package/dist/project-Bw9UPIdx.js +0 -1046
  109. package/dist/project-C4GpaN-n.js +0 -381
  110. package/dist/react-intl-BP0u-D5m.js +0 -519
  111. package/dist/restore-CiYv-jxS.js +0 -175
  112. package/dist/rewrite-EsIw_lsq.js +0 -803
  113. package/dist/run-BEcnBbu-.js +0 -694
  114. package/dist/runtime-DTMmliT1.js +0 -64
  115. package/dist/sync-B9V2KFwb.js +0 -658
  116. package/dist/translate-CQnJfLjO.js +0 -299
  117. package/dist/types-wSh9fCBY.js +0 -11
  118. package/dist/vue-i18n-g0iGy6CZ.js +0 -651
@@ -0,0 +1 @@
1
+ export { t as adaptiveConcurrency } from "./concurrency-Dy2ny50V.js";
@@ -0,0 +1,107 @@
1
+ // src/ai/concurrency.ts
2
+ /**
3
+ * Adaptive concurrency (PLAN §5.20, INTERNALS §2.15): requests start at
4
+ * `ai.concurrency` in flight; a rate limit halves that and holds every new
5
+ * request for the delay the server asked (`RetryInfo`, `Retry-After`), and
6
+ * each full window of requests without one gives a slot back (AIMD). The
7
+ * provider retries the limited request itself; this only decides how many
8
+ * others may start. One instance spans a whole `vi18n translate` run, so a
9
+ * quota learnt on one locale is not rediscovered on the next.
10
+ */
11
+ /** Hold after a rate limit whose answer named no delay. */
12
+ const DEFAULT_HOLD_MS = 1e3;
13
+ function adaptiveConcurrency(max, now = Date.now) {
14
+ return new AdaptiveConcurrency(Math.max(1, Math.floor(max)), now);
15
+ }
16
+ var AdaptiveConcurrency = class {
17
+ max;
18
+ limit;
19
+ rateLimits = 0;
20
+ inFlight = 0;
21
+ holdUntil = 0;
22
+ successes = 0;
23
+ epoch = 0;
24
+ waiters = [];
25
+ timer = null;
26
+ now;
27
+ constructor(max, now) {
28
+ this.max = max;
29
+ this.limit = max;
30
+ this.now = now;
31
+ }
32
+ acquire(signal) {
33
+ return new Promise((resolve, reject) => {
34
+ if (signal?.aborted === true) {
35
+ reject(signal.reason);
36
+ return;
37
+ }
38
+ const onAbort = () => {
39
+ const index = this.waiters.indexOf(waiter);
40
+ if (index !== -1) this.waiters.splice(index, 1);
41
+ reject(signal?.reason);
42
+ };
43
+ const waiter = { grant: () => {
44
+ signal?.removeEventListener("abort", onAbort);
45
+ this.inFlight++;
46
+ resolve(new AdaptiveSlot(this, this.epoch));
47
+ } };
48
+ signal?.addEventListener("abort", onAbort, { once: true });
49
+ this.waiters.push(waiter);
50
+ this.pump();
51
+ });
52
+ }
53
+ /** Grants waiting requests while there is room and no hold; a hold re-pumps when it ends. */
54
+ pump() {
55
+ if (this.timer !== null) {
56
+ clearTimeout(this.timer);
57
+ this.timer = null;
58
+ }
59
+ while (this.waiters.length > 0 && this.inFlight < this.limit) {
60
+ const wait = this.holdUntil - this.now();
61
+ if (wait > 0) {
62
+ this.timer = setTimeout(() => this.pump(), wait);
63
+ return;
64
+ }
65
+ this.waiters.shift().grant();
66
+ }
67
+ }
68
+ /** A request sent in `epoch` met a rate limit: the first of its burst halves the limit. */
69
+ rateLimited(epoch, retryAfterMs) {
70
+ this.rateLimits++;
71
+ if (epoch === this.epoch) {
72
+ this.limit = Math.max(1, Math.floor(this.limit / 2));
73
+ this.successes = 0;
74
+ this.epoch++;
75
+ }
76
+ this.holdUntil = Math.max(this.holdUntil, this.now() + (retryAfterMs ?? DEFAULT_HOLD_MS));
77
+ }
78
+ /** A request sent in `epoch` ended; a full window of unlimited ones gives a slot back. */
79
+ released(epoch, limited) {
80
+ this.inFlight--;
81
+ if (!limited && epoch === this.epoch && ++this.successes >= this.limit && this.limit < this.max) {
82
+ this.limit++;
83
+ this.successes = 0;
84
+ }
85
+ this.pump();
86
+ }
87
+ };
88
+ var AdaptiveSlot = class {
89
+ limited = false;
90
+ done = false;
91
+ owner;
92
+ epoch;
93
+ constructor(owner, epoch) {
94
+ this.owner = owner;
95
+ this.epoch = epoch;
96
+ }
97
+ rateLimited(retryAfterMs) {
98
+ this.limited = true;
99
+ this.owner.rateLimited(this.epoch, retryAfterMs);
100
+ }
101
+ release() {
102
+ if (this.done) return;
103
+ this.done = true;
104
+ this.owner.released(this.epoch, this.limited);
105
+ }
106
+ };
107
+ export { adaptiveConcurrency as t };
package/dist/config.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import { a as Vi18nConfig, c as OpenAICompatibleOptions, d as ProviderResponse, f as Tier, l as ProviderOptions, m as TranslationProvider, n as OutputOptions, o as AiItem, p as TranslateOptions, r as PseudoLocale, s as BatchOptions, t as Level, u as ProviderRequest, v as LocaleStrategy, y as UrlStrategy } from "./types-CgUCkFU1.js";
2
- //#region src/config/index.d.ts
1
+ import { a as Vi18nConfig, c as OpenAICompatibleOptions, d as ProviderResponse, f as Tier, l as ProviderOptions, m as TranslationProvider, n as OutputOptions, o as AiItem, p as TranslateOptions, r as PseudoLocale, s as BatchOptions, t as Level, u as ProviderRequest, v as LocaleStrategy, y as UrlStrategy } from "./types-Cy2bPdSg.js";
3
2
  /**
4
3
  * Types a `vi18n.config.ts`. The config is validated when it is loaded
5
4
  * (`vi18n` plugin, CLI), where errors can name the file.
@@ -14,8 +13,5 @@ export declare function defineConfig(config: Vi18nConfig): Vi18nConfig;
14
13
  * Domains play no part: the list is the paths any unlisted host serves.
15
14
  */
16
15
  export declare function localizedPaths(paths: readonly string[], config: Vi18nConfig): string[];
17
- //#endregion
18
- //#region src/ai/openai.d.ts
19
16
  export declare function openaiCompatible(options: OpenAICompatibleOptions): TranslationProvider;
20
- //#endregion
21
17
  export type { AiItem, BatchOptions, Level, LocaleStrategy, OpenAICompatibleOptions, OutputOptions, ProviderOptions, ProviderRequest, ProviderResponse, PseudoLocale, Tier, TranslateOptions, TranslationProvider, UrlStrategy, Vi18nConfig };
package/dist/config.js CHANGED
@@ -1,7 +1,7 @@
1
- import { n as DEFAULT_CONFIG } from "./types-D3QGM8XO.js";
2
- import { i as localizedPathsFor } from "./url-CRfCOhUI.js";
3
- import { n as openaiCompatible } from "./openai-CTaMDcl-.js";
4
- //#region src/config/index.ts
1
+ import { i as localizedPathsFor } from "./url-Bpc6wLea.js";
2
+ import { i as DEFAULT_CONFIG } from "./diagnostics-1onDF6Ua.js";
3
+ import { n as openaiCompatible } from "./openai-RWw0YlAx.js";
4
+ // src/config/index.ts
5
5
  /**
6
6
  * `@menapo/vi18n/config` implementation (docs/INTERNALS.md §3.4). Loaded by
7
7
  * every `vi18n.config.ts` under Node, so it stays a few lines: no zod, no file
@@ -35,5 +35,4 @@ function localizedPaths(paths, config) {
35
35
  }
36
36
  });
37
37
  }
38
- //#endregion
39
38
  export { defineConfig, localizedPaths, openaiCompatible };
@@ -1,27 +1,6 @@
1
- //#region src/core/diagnostics.ts
2
- /**
3
- * The only way core code creates a throwable diagnostic, so every error that
4
- * crosses a module boundary can be reported without knowing who threw it.
5
- */
6
- function diagnosticError(diagnostic) {
7
- const error = new Error(diagnostic.message);
8
- error.name = "DiagnosticError";
9
- error.diagnostic = diagnostic;
10
- return error;
11
- }
12
- /**
13
- * Recognises a {@link DiagnosticError} by shape rather than by class: errors
14
- * thrown in a `vm` context or another bundled copy of vi18n fail `instanceof`,
15
- * while `Object.prototype.toString` sees the internal error slot in any realm.
16
- */
17
- function isDiagnosticError(error) {
18
- if (typeof error !== "object" || error === null) return false;
19
- if (!(error instanceof Error) && Object.prototype.toString.call(error) !== "[object Error]") return false;
20
- const diagnostic = error.diagnostic;
21
- return typeof diagnostic === "object" && diagnostic !== null && typeof diagnostic.code === "string";
22
- }
23
- //#endregion
24
- //#region src/config/types.ts
1
+ // src/config/types.ts
2
+ /** The two generated pseudo-locales (PLAN §4.7, §5.21). */
3
+ const PSEUDO_LOCALES = ["en-XA", "ar-XB"];
25
4
  /** The only config file name (revision 4.2). */
26
5
  const CONFIG_FILE = "vi18n.config.ts";
27
6
  /** Import sources that always apply; `extraction.importSources` is appended to them. */
@@ -142,5 +121,26 @@ const DEFAULT_CONFIG = {
142
121
  moduleScope: "warn"
143
122
  }
144
123
  };
145
- //#endregion
146
- export { diagnosticError as a, ID_LENGTH as i, DEFAULT_CONFIG as n, isDiagnosticError as o, DEFAULT_IMPORT_SOURCES as r, CONFIG_FILE as t };
124
+ // src/core/diagnostics.ts
125
+ /**
126
+ * The only way core code creates a throwable diagnostic, so every error that
127
+ * crosses a module boundary can be reported without knowing who threw it.
128
+ */
129
+ function diagnosticError(diagnostic) {
130
+ const error = new Error(diagnostic.message);
131
+ error.name = "DiagnosticError";
132
+ error.diagnostic = diagnostic;
133
+ return error;
134
+ }
135
+ /**
136
+ * Recognises a {@link DiagnosticError} by shape rather than by class: errors
137
+ * thrown in a `vm` context or another bundled copy of vi18n fail `instanceof`,
138
+ * while `Object.prototype.toString` sees the internal error slot in any realm.
139
+ */
140
+ function isDiagnosticError(error) {
141
+ if (typeof error !== "object" || error === null) return false;
142
+ if (!(error instanceof Error) && Object.prototype.toString.call(error) !== "[object Error]") return false;
143
+ const diagnostic = error.diagnostic;
144
+ return typeof diagnostic === "object" && diagnostic !== null && typeof diagnostic.code === "string";
145
+ }
146
+ export { DEFAULT_IMPORT_SOURCES as a, DEFAULT_CONFIG as i, isDiagnosticError as n, ID_LENGTH as o, CONFIG_FILE as r, PSEUDO_LOCALES as s, diagnosticError as t };
@@ -1,4 +1,4 @@
1
- //#region src/runtime/ctx.ts
1
+ // src/runtime/ctx.ts
2
2
  /** Dev helpers shared by the runtime modules. */
3
3
  /**
4
4
  * Dev mode, from the plugin's `define` (INTERNALS §6 D44): code bundled
@@ -35,8 +35,7 @@ const warnOnce = (text) => {
35
35
  warned.add(text);
36
36
  if (!seen) console.warn("vi18n: " + text);
37
37
  };
38
- //#endregion
39
- //#region src/runtime/scope.ts
38
+ // src/runtime/scope.ts
40
39
  function createScope(kind, locale, messages, options = {}) {
41
40
  return {
42
41
  kind,
@@ -51,8 +50,7 @@ function createScope(kind, locale, messages, options = {}) {
51
50
  labels: options.labels
52
51
  };
53
52
  }
54
- //#endregion
55
- //#region src/runtime/types.ts
53
+ // src/runtime/types.ts
56
54
  /**
57
55
  * Opcodes of the IR. The runtime may inline the literal numbers to save
58
56
  * bytes; 9 (`list`) and 10 (MF2 `.match`) are reserved and never emitted in 1.0.
@@ -71,8 +69,7 @@ const OP = {
71
69
  };
72
70
  /** The `globalThis[Symbol.for("menapo.vi18n")]` key. */
73
71
  const STATE_KEY = "menapo.vi18n";
74
- //#endregion
75
- //#region src/runtime/state.ts
72
+ // src/runtime/state.ts
76
73
  /**
77
74
  * The page-wide state on `globalThis[Symbol.for("menapo.vi18n")]`
78
75
  * (INTERNALS §2.11.1). The first runtime copy to evaluate creates it, or
@@ -148,28 +145,34 @@ function report(key, locale, reason) {
148
145
  if (DEV) console.error(e);
149
146
  }
150
147
  }
148
+ /**
149
+ * Dev: a client page that should have the engine. Servers run without it by
150
+ * design, and so does everything outside a document. This and the dev
151
+ * helpers below run only once `init()` returned, so `S` is set.
152
+ */
153
+ const clientPage = () => browser() && !S.serverResolver && S.registration?.consumer !== "server";
154
+ /**
155
+ * Dev: says why a client page renders no translations when the engine never
156
+ * evaluated (code the plugin did not process, a suite without the boot
157
+ * module).
158
+ */
159
+ function noEngine() {
160
+ if (clientPage()) warnOnce("the client engine is not loaded, so nothing is fetched or switched and t() renders no translations; the plugin's boot module imports \"@menapo/vi18n/engine\" first. Is this code processed by vi18n()?");
161
+ }
162
+ /** Dev: what to use instead of `setLocale()` where it cannot run. */
163
+ function setLocaleAdvice() {
164
+ if (clientPage()) return " and needs the client engine (\"@menapo/vi18n/engine\", imported by the boot module)";
165
+ return "; use withLocale() or scopeLocale() on the server";
166
+ }
151
167
  function createState(stub) {
152
168
  /** A request-less `t()` on the server (§2.11.1 `resolve`). */
153
169
  const noScope = () => {
154
- const reg = S.registration;
170
+ const reg = state.registration;
155
171
  if (!BUILD && reg?.test) return page;
156
172
  if (DEV) throw new Error("vi18n: t() called outside a request scope");
157
173
  const locale = reg?.config.sourceLocale ?? "und";
158
174
  report("", locale, "no-scope");
159
- return S.serverFallback ?? (fallback ??= createScope("request", locale, /* @__PURE__ */ new Map()));
160
- };
161
- /**
162
- * Dev: a client page that should have the engine. Servers run without it by
163
- * design, and so does everything outside a document.
164
- */
165
- const clientPage = () => browser() && !S.serverResolver && S.registration?.consumer !== "server";
166
- /**
167
- * Dev: says why a client page renders no translations when the engine never
168
- * evaluated (code the plugin did not process, a suite without the boot
169
- * module).
170
- */
171
- const noEngine = () => {
172
- if (clientPage()) warnOnce("the client engine is not loaded, so nothing is fetched or switched and t() renders no translations; the plugin's boot module imports \"@menapo/vi18n/engine\" first. Is this code processed by vi18n()?");
175
+ return state.serverFallback ?? (fallback ??= createScope("request", locale, /* @__PURE__ */ new Map()));
173
176
  };
174
177
  /**
175
178
  * The engine's client methods where it never evaluated: on servers and on
@@ -207,17 +210,17 @@ function createState(stub) {
207
210
  nav = navigate;
208
211
  },
209
212
  register(r) {
210
- S.registration = r;
211
- S.locales.length = 0;
212
- S.locales.push(...r.config.locales);
213
+ state.registration = r;
214
+ state.locales.length = 0;
215
+ state.locales.push(...r.config.locales);
213
216
  page.locale = r.config.sourceLocale;
214
217
  return engine ? engine(r) : resolved;
215
218
  },
216
219
  setLocale() {
217
- throw new Error("vi18n: setLocale() is client-only" + (DEV ? clientPage() ? " and needs the client engine (\"@menapo/vi18n/engine\", imported by the boot module)" : "; use withLocale() or scopeLocale() on the server" : ""));
220
+ throw new Error("vi18n: setLocale() is client-only" + (DEV ? setLocaleAdvice() : ""));
218
221
  },
219
222
  resolve: () => {
220
- const r = S.serverResolver;
223
+ const r = state.serverResolver;
221
224
  return r ? r() ?? noScope() : page;
222
225
  },
223
226
  untracked(fn) {
@@ -245,8 +248,8 @@ function createState(stub) {
245
248
  report(key, scope.locale, reason);
246
249
  }
247
250
  };
248
- const S = stub ? Object.assign(stub, core) : core;
249
- return S;
251
+ const state = stub ? Object.assign(stub, core) : core;
252
+ return state;
250
253
  }
251
254
  /** Creates the global state, or upgrades the boot stub, or joins another copy's state. */
252
255
  function init() {
@@ -263,12 +266,7 @@ function init() {
263
266
  }
264
267
  /** The state, for runtime modules. Evaluating the runtime is what creates (or joins) it. */
265
268
  const S = init();
266
- /** The global state this copy created or joined. Pinned for `/server` and generated glue. */
267
- function getState() {
268
- return S;
269
- }
270
- //#endregion
271
- //#region src/runtime/dir.ts
269
+ // src/runtime/dir.ts
272
270
  /** Text direction of a locale (PLAN §4.16). */
273
271
  const RTL_SCRIPTS = "AdlmArabHebrMandMendNkooRohgSamrSyrcThaaYezi";
274
272
  const cache = /* @__PURE__ */ new Map();
@@ -286,5 +284,4 @@ function textDirection(locale) {
286
284
  }
287
285
  return d;
288
286
  }
289
- //#endregion
290
- export { DEV as _, getState as a, trim as b, page as c, resolved as d, setEngine as f, BUILD as g, createScope as h, created as i, quiet as l, OP as m, S as n, nav as o, subs as p, changed as r, noop as s, textDirection as t, report as u, browser as v, warnOnce as x, own as y };
287
+ export { browser as _, nav as a, warnOnce as b, quiet as c, setEngine as d, subs as f, DEV as g, BUILD as h, created as i, report as l, createScope as m, S as n, noop as o, OP as p, changed as r, page as s, textDirection as t, resolved as u, own as v, trim as y };
@@ -1,10 +1,5 @@
1
- import { S as entryKey } from "./library-D5CWvTQs.js";
2
- //#region src/core/catalog/duplicates.ts
3
- const RANK = {
4
- translated: 2,
5
- ai: 1,
6
- untranslated: 0
7
- };
1
+ import { D as flagKey, E as entryKey, O as stricterLimit, S as defineFields, v as STATE_RANK } from "./library-BfSOBeBd.js";
2
+ // src/core/catalog/duplicates.ts
8
3
  /** Entries grouped by key; only keys seen more than once. Null when there are none. */
9
4
  function duplicateGroups(catalog, codec) {
10
5
  const first = /* @__PURE__ */ new Map();
@@ -28,7 +23,10 @@ function duplicateGroups(catalog, codec) {
28
23
  /** `translated` over `ai` over `untranslated`, then the first in the file. */
29
24
  function winnerOf(entries, indexes) {
30
25
  let best = indexes[0];
31
- for (const index of indexes) if (RANK[entries[index].state] > RANK[entries[best].state]) best = index;
26
+ for (const index of indexes) {
27
+ const state = entries[index].state;
28
+ if (STATE_RANK[state] > STATE_RANK[entries[best].state]) best = index;
29
+ }
32
30
  return best;
33
31
  }
34
32
  /**
@@ -100,20 +98,6 @@ function appendNew(into, seen, from) {
100
98
  }
101
99
  }
102
100
  /**
103
- * Copies `from`'s fields onto `into` in place, not by a spread per copy
104
- * (which would copy everything kept so far each time); defineProperty keeps
105
- * a `__proto__` field data, as the JSON reader does.
106
- */
107
- function defineFields(into, from) {
108
- for (const field of Object.keys(from)) Object.defineProperty(into, field, {
109
- value: from[field],
110
- enumerable: true,
111
- writable: true,
112
- configurable: true
113
- });
114
- return into;
115
- }
116
- /**
117
101
  * The winner with every other copy merged in, in file order: as merging the
118
102
  * copies one by one would, but with one pass over each copy, so the cost
119
103
  * stays linear in the group's size however many copies there are.
@@ -124,7 +108,7 @@ function mergeGroup(winner, others) {
124
108
  const comments = winner.comments.slice();
125
109
  const seenComments = new Set(comments);
126
110
  const flags = winner.flags.slice();
127
- const seenFlags = new Set(flags.map((flag) => flag.line + flag.name));
111
+ const seenFlags = new Set(flags.map(flagKey));
128
112
  const refs = new Set(winner.refs);
129
113
  let maxLength = winner.maxLength;
130
114
  let extra;
@@ -137,20 +121,20 @@ function mergeGroup(winner, others) {
137
121
  appendNew(contexts, seenContexts, other.contexts);
138
122
  appendNew(comments, seenComments, other.comments);
139
123
  for (const flag of other.flags) {
140
- const key = flag.line + flag.name;
124
+ const key = flagKey(flag);
141
125
  if (seenFlags.has(key)) continue;
142
126
  seenFlags.add(key);
143
127
  flags.push(flag);
144
128
  }
145
129
  for (const ref of other.refs) refs.add(ref);
146
- if (other.maxLength !== null) maxLength = maxLength === null ? other.maxLength : Math.min(maxLength, other.maxLength);
130
+ maxLength = stricterLimit(maxLength, other.maxLength);
147
131
  }
148
132
  const merged = {
149
133
  ...winner,
150
134
  contexts,
151
135
  comments,
152
136
  flags,
153
- refs: [...refs].sort((x, y) => x < y ? -1 : x > y ? 1 : 0),
137
+ refs: [...refs].sort(),
154
138
  maxLength
155
139
  };
156
140
  if (extra !== void 0) merged.extra = extra;
@@ -181,5 +165,4 @@ function mergeDuplicates(catalog, codec) {
181
165
  entries: entries.filter((_, index) => !dropped.has(index))
182
166
  };
183
167
  }
184
- //#endregion
185
168
  export { mergeDuplicates as n, resolveDuplicates as r, duplicateDiagnostics as t };