@parlajs/compiler 0.0.0-stage → 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 (159) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +21 -2
  3. package/build/build.d.ts +18 -0
  4. package/build/build.d.ts.map +1 -0
  5. package/build/build.js +10 -0
  6. package/build/cli.d.ts +3 -0
  7. package/build/cli.d.ts.map +1 -0
  8. package/build/cli.js +8 -0
  9. package/build/command.d.ts +13 -0
  10. package/build/command.d.ts.map +1 -0
  11. package/build/command.js +156 -0
  12. package/build/compile/code.d.ts +13 -0
  13. package/build/compile/code.d.ts.map +1 -0
  14. package/build/compile/code.js +42 -0
  15. package/build/compile/compile.d.ts +11 -0
  16. package/build/compile/compile.d.ts.map +1 -0
  17. package/build/compile/compile.js +244 -0
  18. package/build/compile/error.d.ts +4 -0
  19. package/build/compile/error.d.ts.map +1 -0
  20. package/build/compile/error.js +3 -0
  21. package/build/compile/info.d.ts +49 -0
  22. package/build/compile/info.d.ts.map +1 -0
  23. package/build/compile/info.js +22 -0
  24. package/build/compile/scope.d.ts +7 -0
  25. package/build/compile/scope.d.ts.map +1 -0
  26. package/build/compile/scope.js +14 -0
  27. package/build/compile/single.d.ts +11 -0
  28. package/build/compile/single.d.ts.map +1 -0
  29. package/build/compile/single.js +36 -0
  30. package/build/compile/variants.d.ts +16 -0
  31. package/build/compile/variants.d.ts.map +1 -0
  32. package/build/compile/variants.js +48 -0
  33. package/build/config/checks.d.ts +21 -0
  34. package/build/config/checks.d.ts.map +1 -0
  35. package/build/config/checks.js +97 -0
  36. package/build/config/config.d.ts +71 -0
  37. package/build/config/config.d.ts.map +1 -0
  38. package/build/config/config.js +7 -0
  39. package/build/config/fallbacks.d.ts +6 -0
  40. package/build/config/fallbacks.d.ts.map +1 -0
  41. package/build/config/fallbacks.js +13 -0
  42. package/build/config/import.d.ts +31 -0
  43. package/build/config/import.d.ts.map +1 -0
  44. package/build/config/import.js +115 -0
  45. package/build/config/load.d.ts +13 -0
  46. package/build/config/load.d.ts.map +1 -0
  47. package/build/config/load.js +59 -0
  48. package/build/diagnostics.d.ts +31 -0
  49. package/build/diagnostics.d.ts.map +1 -0
  50. package/build/diagnostics.js +41 -0
  51. package/build/generate/checks.d.ts +9 -0
  52. package/build/generate/checks.d.ts.map +1 -0
  53. package/build/generate/checks.js +93 -0
  54. package/build/generate/chunk.d.ts +11 -0
  55. package/build/generate/chunk.d.ts.map +1 -0
  56. package/build/generate/chunk.js +57 -0
  57. package/build/generate/digits.d.ts +8 -0
  58. package/build/generate/digits.d.ts.map +1 -0
  59. package/build/generate/digits.js +57 -0
  60. package/build/generate/files.d.ts +7 -0
  61. package/build/generate/files.d.ts.map +1 -0
  62. package/build/generate/files.js +59 -0
  63. package/build/generate/locale.d.ts +21 -0
  64. package/build/generate/locale.d.ts.map +1 -0
  65. package/build/generate/locale.js +108 -0
  66. package/build/generate/modules.d.ts +27 -0
  67. package/build/generate/modules.d.ts.map +1 -0
  68. package/build/generate/modules.js +61 -0
  69. package/build/generate/namespace.d.ts +19 -0
  70. package/build/generate/namespace.d.ts.map +1 -0
  71. package/build/generate/namespace.js +65 -0
  72. package/build/generate/namespaces.d.ts +5 -0
  73. package/build/generate/namespaces.d.ts.map +1 -0
  74. package/build/generate/namespaces.js +41 -0
  75. package/build/generate/read.d.ts +21 -0
  76. package/build/generate/read.d.ts.map +1 -0
  77. package/build/generate/read.js +115 -0
  78. package/build/index.d.ts +9 -0
  79. package/build/index.d.ts.map +1 -0
  80. package/build/index.js +7 -0
  81. package/build/init/detect.d.ts +43 -0
  82. package/build/init/detect.d.ts.map +1 -0
  83. package/build/init/detect.js +69 -0
  84. package/build/init/init.d.ts +12 -0
  85. package/build/init/init.d.ts.map +1 -0
  86. package/build/init/init.js +126 -0
  87. package/build/options/date.d.ts +3 -0
  88. package/build/options/date.d.ts.map +1 -0
  89. package/build/options/date.js +77 -0
  90. package/build/options/literal.d.ts +10 -0
  91. package/build/options/literal.d.ts.map +1 -0
  92. package/build/options/literal.js +11 -0
  93. package/build/options/names.d.ts +5 -0
  94. package/build/options/names.d.ts.map +1 -0
  95. package/build/options/names.js +56 -0
  96. package/build/options/number.d.ts +3 -0
  97. package/build/options/number.d.ts.map +1 -0
  98. package/build/options/number.js +17 -0
  99. package/build/options/options.d.ts +7 -0
  100. package/build/options/options.d.ts.map +1 -0
  101. package/build/options/options.js +66 -0
  102. package/build/plurals.d.ts +6 -0
  103. package/build/plurals.d.ts.map +1 -0
  104. package/build/plurals.js +50 -0
  105. package/build/types/names.d.ts +9 -0
  106. package/build/types/names.d.ts.map +1 -0
  107. package/build/types/names.js +109 -0
  108. package/build/types/namespace.d.ts +17 -0
  109. package/build/types/namespace.d.ts.map +1 -0
  110. package/build/types/namespace.js +113 -0
  111. package/build/types/signature.d.ts +8 -0
  112. package/build/types/signature.d.ts.map +1 -0
  113. package/build/types/signature.js +87 -0
  114. package/build/vite.d.ts +9 -0
  115. package/build/vite.d.ts.map +1 -0
  116. package/build/vite.js +125 -0
  117. package/build/watch.d.ts +12 -0
  118. package/build/watch.d.ts.map +1 -0
  119. package/build/watch.js +93 -0
  120. package/package.json +84 -3
  121. package/src/build.ts +31 -0
  122. package/src/cli.ts +9 -0
  123. package/src/command.ts +195 -0
  124. package/src/compile/code.ts +51 -0
  125. package/src/compile/compile.ts +289 -0
  126. package/src/compile/error.ts +3 -0
  127. package/src/compile/info.ts +63 -0
  128. package/src/compile/scope.ts +14 -0
  129. package/src/compile/single.ts +46 -0
  130. package/src/compile/variants.ts +68 -0
  131. package/src/config/checks.ts +140 -0
  132. package/src/config/config.ts +83 -0
  133. package/src/config/fallbacks.ts +18 -0
  134. package/src/config/import.ts +146 -0
  135. package/src/config/load.ts +75 -0
  136. package/src/diagnostics.ts +98 -0
  137. package/src/generate/checks.ts +103 -0
  138. package/src/generate/chunk.ts +73 -0
  139. package/src/generate/digits.ts +74 -0
  140. package/src/generate/files.ts +83 -0
  141. package/src/generate/locale.ts +145 -0
  142. package/src/generate/modules.ts +94 -0
  143. package/src/generate/namespace.ts +119 -0
  144. package/src/generate/namespaces.ts +59 -0
  145. package/src/generate/read.ts +159 -0
  146. package/src/index.ts +27 -0
  147. package/src/init/detect.ts +103 -0
  148. package/src/init/init.ts +158 -0
  149. package/src/options/date.ts +87 -0
  150. package/src/options/literal.ts +21 -0
  151. package/src/options/names.ts +64 -0
  152. package/src/options/number.ts +20 -0
  153. package/src/options/options.ts +75 -0
  154. package/src/plurals.ts +68 -0
  155. package/src/types/names.ts +115 -0
  156. package/src/types/namespace.ts +148 -0
  157. package/src/types/signature.ts +111 -0
  158. package/src/vite.ts +143 -0
  159. package/src/watch.ts +115 -0
@@ -0,0 +1,31 @@
1
+ interface Located {
2
+ message: string;
3
+ namespace?: string;
4
+ locale?: string;
5
+ key?: string;
6
+ file?: string;
7
+ }
8
+ /** Fails the build. A missing file is one only in the source locale. */
9
+ export interface ErrorDiagnostic extends Located {
10
+ level: 'error';
11
+ code: 'invalid-config' | 'invalid-syntax' | 'invalid-resource' | 'missing-file' | 'param-mismatch' | 'key-conflict' | 'unknown-format';
12
+ }
13
+ /** Fails only `--strict`. */
14
+ export interface WarningDiagnostic extends Located {
15
+ level: 'warning';
16
+ code: 'missing-file' | 'missing-translation' | 'missing-param' | 'missing-plural' | 'unknown-key' | 'namespace-name';
17
+ }
18
+ export type Diagnostic = ErrorDiagnostic | WarningDiagnostic;
19
+ /** A diagnostic before its namespace and locale are known. */
20
+ export type Unplaced = Omit<ErrorDiagnostic, 'namespace' | 'locale'> | Omit<WarningDiagnostic, 'namespace' | 'locale'>;
21
+ export declare function formatDiagnostic(d: Diagnostic, root?: string): string;
22
+ export interface Report {
23
+ level: Diagnostic['level'];
24
+ line: string;
25
+ }
26
+ /** One line per problem: diagnostics that differ only in their key share it. */
27
+ export declare function formatDiagnostics(diagnostics: ReadonlyArray<Diagnostic>, root?: string): Array<Report>;
28
+ /** Filters out what the previous call returned, so a rebuild repeats no warning. */
29
+ export declare function unreported(): (diagnostics: ReadonlyArray<Diagnostic>) => Array<Diagnostic>;
30
+ export {};
31
+ //# sourceMappingURL=diagnostics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../src/diagnostics.ts"],"names":[],"mappings":"AAEA,UAAU,OAAO;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,wEAAwE;AACxE,MAAM,WAAW,eAAgB,SAAQ,OAAO;IAC9C,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EACA,gBAAgB,GAChB,gBAAgB,GAChB,kBAAkB,GAClB,cAAc,GACd,gBAAgB,GAChB,cAAc,GACd,gBAAgB,CAAC;CACtB;AAED,6BAA6B;AAC7B,MAAM,WAAW,iBAAkB,SAAQ,OAAO;IAChD,KAAK,EAAE,SAAS,CAAC;IACjB,IAAI,EACA,cAAc,GACd,qBAAqB,GACrB,eAAe,GACf,gBAAgB,GAChB,aAAa,GACb,gBAAgB,CAAC;CACtB;AAED,MAAM,MAAM,UAAU,GAAG,eAAe,GAAG,iBAAiB,CAAC;AAE7D,8DAA8D;AAC9D,MAAM,MAAM,QAAQ,GAChB,IAAI,CAAC,eAAe,EAAE,WAAW,GAAG,QAAQ,CAAC,GAC7C,IAAI,CAAC,iBAAiB,EAAE,WAAW,GAAG,QAAQ,CAAC,CAAC;AASpD,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAOrE;AAED,MAAM,WAAW,MAAM;IACrB,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;CACd;AAID,gFAAgF;AAChF,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,aAAa,CAAC,UAAU,CAAC,EACtC,IAAI,CAAC,EAAE,MAAM,GACZ,KAAK,CAAC,MAAM,CAAC,CAiBf;AAED,oFAAoF;AACpF,wBAAgB,UAAU,IAAI,CAAC,WAAW,EAAE,aAAa,CAAC,UAAU,CAAC,KAAK,KAAK,CAAC,UAAU,CAAC,CAQ1F"}
@@ -0,0 +1,41 @@
1
+ import path from 'node:path';
2
+ /** Catalogs are others' text: no new lines, which a CI may read as commands, nor terminal codes. */
3
+ const printable = (text) => text.replaceAll(/\p{Cc}/gu, (char) => {
4
+ const code = char.codePointAt(0) ?? 0;
5
+ return `\\u${code.toString(16).padStart(4, '0')}`;
6
+ });
7
+ export function formatDiagnostic(d, root) {
8
+ const where = [d.namespace, d.locale, d.key].filter(Boolean).join(' › ');
9
+ // `/` on Windows too, where its terminals open both.
10
+ const file = d.file && root ? ` (${path.relative(root, d.file).replaceAll(path.sep, '/')})` : '';
11
+ return printable(`${d.level === 'error' ? 'error ' : 'warning'} [${d.code}] ${where}: ${d.message}${file}`);
12
+ }
13
+ const SHOWN_KEYS = 5;
14
+ /** One line per problem: diagnostics that differ only in their key share it. */
15
+ export function formatDiagnostics(diagnostics, root) {
16
+ const groups = new Map();
17
+ for (const d of diagnostics) {
18
+ const id = JSON.stringify([d.level, d.code, d.namespace, d.locale, d.file, d.message]);
19
+ const group = groups.get(id) ?? { d, keys: [] };
20
+ groups.set(id, group);
21
+ if (d.key) {
22
+ group.keys.push(d.key);
23
+ }
24
+ }
25
+ return [...groups.values()].map(({ d, keys }) => {
26
+ const more = keys.length - SHOWN_KEYS;
27
+ // "and 1 more" is no shorter than the key itself
28
+ const key = more > 1 ? `${keys.slice(0, SHOWN_KEYS).join(', ')} and ${more} more` : keys.join(', ');
29
+ return { level: d.level, line: formatDiagnostic({ ...d, key }, root) };
30
+ });
31
+ }
32
+ /** Filters out what the previous call returned, so a rebuild repeats no warning. */
33
+ export function unreported() {
34
+ let last = new Set();
35
+ return (diagnostics) => {
36
+ const ids = diagnostics.map((d) => JSON.stringify(d));
37
+ const fresh = diagnostics.filter((_, i) => !last.has(ids[i] ?? ''));
38
+ last = new Set(ids);
39
+ return fresh;
40
+ };
41
+ }
@@ -0,0 +1,9 @@
1
+ import type { MessageInfo } from '../compile/info.ts';
2
+ import type { ResolvedConfig } from '../config/config.ts';
3
+ /** A locale with a parent (a fallback or its base) leaves gaps by design; the parent reports its own. */
4
+ export declare function inherits(config: ResolvedConfig, locale: string): boolean;
5
+ /** What the source message has and a translation leaves out. */
6
+ export declare function omissions(own: MessageInfo, source: MessageInfo): Array<string>;
7
+ /** A translation's params and markup against the source message's. */
8
+ export declare function mismatches(own: MessageInfo, source: MessageInfo): Array<string>;
9
+ //# sourceMappingURL=checks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checks.d.ts","sourceRoot":"","sources":["../../src/generate/checks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAa,MAAM,oBAAoB,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAI1D,yGAAyG;AACzG,wBAAgB,QAAQ,CAAC,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAExE;AAsCD,gEAAgE;AAChE,wBAAgB,SAAS,CAAC,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,CAe9E;AAED,sEAAsE;AACtE,wBAAgB,UAAU,CAAC,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,CAqC/E"}
@@ -0,0 +1,93 @@
1
+ import { parents } from '../config/fallbacks.js';
2
+ import { paramType } from '../types/signature.js';
3
+ /** A locale with a parent (a fallback or its base) leaves gaps by design; the parent reports its own. */
4
+ export function inherits(config, locale) {
5
+ return parents(config, locale).some((l) => l !== locale && config.locales.includes(l));
6
+ }
7
+ const selectKeys = (kinds) => kinds.flatMap((k) => (k.kind === 'select' ? k.keys : []));
8
+ /** Whether a param typed by the source's kinds suits the translation's. */
9
+ function accepts(own, source) {
10
+ const [ownType, sourceType] = [paramType(own), paramType(source)];
11
+ if (ownType === sourceType || ownType === 'string | number') {
12
+ return true;
13
+ }
14
+ const isText = [...own, ...source].every((k) => k.kind === 'select' || k.kind === 'string');
15
+ // A language may need fewer branches, down to none.
16
+ return (isText &&
17
+ source.some((k) => k.kind === 'select') &&
18
+ selectKeys(own).every((key) => selectKeys(source).includes(key)));
19
+ }
20
+ /** `$p when $k is "a"`, per param the source needs in a branch and the translation leaves out. */
21
+ function branchOmissions(own, source) {
22
+ const { branches } = source;
23
+ const out = new Map();
24
+ if (branches && own.branches?.param === branches.param) {
25
+ for (const [key, needs] of branches.needs) {
26
+ const ownNeeds = own.branches.needs.get(key) ?? own.branches.needs.get(null);
27
+ for (const name of needs) {
28
+ if (own.params.has(name) && ownNeeds?.has(name) === false && !out.has(name)) {
29
+ const when = key === null ? 'another value' : JSON.stringify(key);
30
+ out.set(name, `$${name} when $${branches.param} is ${when}`);
31
+ }
32
+ }
33
+ }
34
+ }
35
+ return [...out.values()];
36
+ }
37
+ /** What the source message has and a translation leaves out. */
38
+ export function omissions(own, source) {
39
+ const left = [];
40
+ for (const [name, kinds] of source.params) {
41
+ // A language may not need a select, as of gender.
42
+ if (!own.params.has(name) && !kinds.some((k) => k.kind === 'select')) {
43
+ left.push(`$${name}`);
44
+ }
45
+ }
46
+ left.push(...branchOmissions(own, source));
47
+ for (const tag of source.markup) {
48
+ if (!own.markup.has(tag)) {
49
+ left.push(`markup "${tag}"`);
50
+ }
51
+ }
52
+ return left.map((what) => `leaves out ${what}, which the source message has`);
53
+ }
54
+ /** A translation's params and markup against the source message's. */
55
+ export function mismatches(own, source) {
56
+ const out = [];
57
+ for (const [param, kinds] of own.params) {
58
+ const expected = source.params.get(param);
59
+ if (!expected) {
60
+ out.push(`uses $${param}, which the source message does not have`);
61
+ }
62
+ else if (!accepts(kinds, expected)) {
63
+ out.push(`$${param} is ${paramType(kinds)} here but ${paramType(expected)} in the source`);
64
+ }
65
+ }
66
+ for (const tag of own.markup) {
67
+ if (!source.markup.has(tag)) {
68
+ out.push(`uses markup "${tag}", which the source message does not have`);
69
+ }
70
+ }
71
+ const { branches } = source;
72
+ if (branches) {
73
+ // The source's type lets a call leave out what its value's branch does not read.
74
+ const ownBranches = own.branches?.param === branches.param ? own.branches : undefined;
75
+ const needs = (info, key) => {
76
+ const map = info === source ? branches : ownBranches;
77
+ return map?.needs.get(key) ?? map?.needs.get(null) ?? new Set(info.params.keys());
78
+ };
79
+ const keys = new Set([...branches.needs.keys(), ...(ownBranches?.needs.keys() ?? [])]);
80
+ const reported = new Set();
81
+ for (const key of keys) {
82
+ const allowed = needs(source, key);
83
+ for (const param of needs(own, key)) {
84
+ if (source.params.has(param) && !allowed.has(param) && !reported.has(param)) {
85
+ reported.add(param);
86
+ const when = key === null ? 'another value' : JSON.stringify(key);
87
+ out.push(`needs $${param} when $${branches.param} is ${when}, but the source does not`);
88
+ }
89
+ }
90
+ }
91
+ }
92
+ return out;
93
+ }
@@ -0,0 +1,11 @@
1
+ interface ChunkTree extends Map<string, ChunkTree | string> {
2
+ }
3
+ /** Dotted keys as nested groups; `key-conflict` already rules out a key that is also a group. */
4
+ export declare function treeOf(messages: ReadonlyArray<[key: string, fn: string]>): ChunkTree;
5
+ /**
6
+ * A chunk's factory. In parentheses, so V8 compiles it at once instead of parsing it twice; bigger
7
+ * groups are built in its own body, as V8 runs a function nested there ~5× slower.
8
+ */
9
+ export declare function emitFactory(tree: ChunkTree): string;
10
+ export {};
11
+ //# sourceMappingURL=chunk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk.d.ts","sourceRoot":"","sources":["../../src/generate/chunk.ts"],"names":[],"mappings":"AACA,UAAU,SAAU,SAAQ,GAAG,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAAC;CAAG;AAE9D,iGAAiG;AACjG,wBAAgB,MAAM,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC,GAAG,SAAS,CAiBpF;AAyCD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CAMnD"}
@@ -0,0 +1,57 @@
1
+ /** Dotted keys as nested groups; `key-conflict` already rules out a key that is also a group. */
2
+ export function treeOf(messages) {
3
+ const root = new Map();
4
+ for (const [key, fn] of messages) {
5
+ const path = key.split('.');
6
+ const leaf = path.pop() ?? key;
7
+ let node = root;
8
+ for (const segment of path) {
9
+ let child = node.get(segment);
10
+ if (typeof child !== 'object') {
11
+ child = new Map();
12
+ node.set(segment, child);
13
+ }
14
+ node = child;
15
+ }
16
+ node.set(leaf, fn);
17
+ }
18
+ return root;
19
+ }
20
+ // A literal `"__proto__": …` would set the prototype; a computed key defines a property.
21
+ const literalKey = (key) => key === '__proto__' ? '["__proto__"]' : JSON.stringify(key);
22
+ // V8 builds a literal of up to 127 properties from a template; at 128 it takes a path ~100× slower.
23
+ const MAX_LITERAL = 127;
24
+ /** A group as an expression: a literal or, when larger, a const that `statements` builds. */
25
+ function emitGroup(node, { indent, statements }) {
26
+ const inner = `${indent} `;
27
+ const value = (v) => typeof v === 'string' ? v : emitGroup(v, { indent: inner, statements });
28
+ // `__proto__` must stay in the literal: an assignment would set the prototype.
29
+ const entries = [...node].toSorted(([a], [b]) => Number(b === '__proto__') - Number(a === '__proto__'));
30
+ const literal = entries
31
+ .slice(0, MAX_LITERAL)
32
+ .map(([key, v]) => `${inner}${literalKey(key)}: ${value(v)},`)
33
+ .join('\n');
34
+ if (entries.length <= MAX_LITERAL) {
35
+ return `{\n${literal}\n${indent}}`;
36
+ }
37
+ const rest = entries
38
+ .slice(MAX_LITERAL)
39
+ .map(([key, v]) => [JSON.stringify(key), value(v)]);
40
+ const name = `g${statements.length}`;
41
+ statements.push([
42
+ `const ${name} = {\n${literal}\n};`,
43
+ ...rest.map(([key, v]) => `${name}[${key}] = ${v};`),
44
+ ].join('\n'));
45
+ return name;
46
+ }
47
+ /**
48
+ * A chunk's factory. In parentheses, so V8 compiles it at once instead of parsing it twice; bigger
49
+ * groups are built in its own body, as V8 runs a function nested there ~5× slower.
50
+ */
51
+ export function emitFactory(tree) {
52
+ const statements = [];
53
+ const root = emitGroup(tree, { indent: '', statements });
54
+ return statements.length === 0
55
+ ? `(($) => (${root}))`
56
+ : `(($) => {\n${statements.join('\n')}\nreturn ${root};\n})`;
57
+ }
@@ -0,0 +1,8 @@
1
+ /** Whether `Intl` writes 0 to 999 as JavaScript does: asking it in a browser costs what this saves. */
2
+ export declare function hasPlainDigits(locale: string): boolean;
3
+ /**
4
+ * What every engine puts between the groups of three of `locale`'s integers, or nothing where they
5
+ * may differ: its parents, and for a language some engines lack its `fallbacks` too, must agree.
6
+ */
7
+ export declare function groupSeparator(locale: string, fallbacks: ReadonlyArray<string>): string | undefined;
8
+ //# sourceMappingURL=digits.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"digits.d.ts","sourceRoot":"","sources":["../../src/generate/digits.ts"],"names":[],"mappings":"AAcA,uGAAuG;AACvG,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAOtD;AAsCD;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,GAC/B,MAAM,GAAG,SAAS,CAMpB"}
@@ -0,0 +1,57 @@
1
+ // A locale of another script, such as `ar`, has latin digits in some engines and its own in others.
2
+ const DIGITLESS_SCRIPTS = new Set([
3
+ 'Armn',
4
+ 'Cyrl',
5
+ 'Geor',
6
+ 'Grek',
7
+ 'Hans',
8
+ 'Hant',
9
+ 'Hebr',
10
+ 'Jpan',
11
+ 'Kore',
12
+ 'Latn',
13
+ ]);
14
+ /** Whether `Intl` writes 0 to 999 as JavaScript does: asking it in a browser costs what this saves. */
15
+ export function hasPlainDigits(locale) {
16
+ const { script = '' } = new Intl.Locale(locale).maximize();
17
+ const numbers = new Intl.NumberFormat(locale);
18
+ return (DIGITLESS_SCRIPTS.has(script) &&
19
+ Array.from({ length: 1000 }, (_, n) => n).every((n) => numbers.format(n) === String(n)));
20
+ }
21
+ // Languages every engine has data for: another may be written as one of its fallbacks.
22
+ const COMMON_LANGUAGES = new Set('af am ar bg bn ca cs da de el en es et fa fi fil fr gu he hi hr hu id it ja kn ko lt lv ml mr ms nb nl pl pt ro ru sk sl sr sv sw ta te th tr uk ur vi zh'.split(' '));
23
+ /** The integers checked against `Intl`: at each power of ten up to the runtime's limit, and between. */
24
+ const PROBES = Array.from({ length: 13 }, (_, i) => 10 ** (i + 3)).flatMap((power) => [
25
+ power,
26
+ power + 1,
27
+ power + Math.floor(power / 7),
28
+ power * 9 - 1,
29
+ ]);
30
+ /** What `Intl` puts between the groups of three of every integer from 1000 up, if that is all it does. */
31
+ function separatorOf(locale) {
32
+ if (Intl.NumberFormat.supportedLocalesOf(locale).length === 0) {
33
+ // It would answer for the machine's own locale.
34
+ return undefined;
35
+ }
36
+ const numbers = new Intl.NumberFormat(locale);
37
+ // Not from 10 000, as Italian does since 2022: engines differ on which locales do.
38
+ const [separator] = /\D+/.exec(numbers.format(1000)) ?? [];
39
+ return separator !== undefined &&
40
+ PROBES.every((n) => numbers.format(n) === String(n).replaceAll(/\B(?=(?:\d{3})+$)/g, separator))
41
+ ? separator
42
+ : undefined;
43
+ }
44
+ /** The locale, then what an engine without its region or script reads instead. */
45
+ function lineage(locale) {
46
+ const subtags = new Intl.Locale(locale).baseName.split('-');
47
+ return [locale, ...subtags.slice(1).map((_, i) => subtags.slice(0, -1 - i).join('-'))];
48
+ }
49
+ /**
50
+ * What every engine puts between the groups of three of `locale`'s integers, or nothing where they
51
+ * may differ: its parents, and for a language some engines lack its `fallbacks` too, must agree.
52
+ */
53
+ export function groupSeparator(locale, fallbacks) {
54
+ const common = COMMON_LANGUAGES.has(new Intl.Locale(locale).language);
55
+ const [own, ...rest] = [...lineage(locale), ...(common ? [] : fallbacks)].map((tag) => separatorOf(tag));
56
+ return rest.every((other) => other === own) ? own : undefined;
57
+ }
@@ -0,0 +1,7 @@
1
+ import type { ResolvedConfig } from '../config/config.ts';
2
+ /** Writes what changed of `files` and the catalog, then removes what an earlier build left. */
3
+ export declare function writeOutput(config: ResolvedConfig, files: ReadonlyMap<string, string>): {
4
+ written: Array<string>;
5
+ removed: Array<string>;
6
+ };
7
+ //# sourceMappingURL=files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../src/generate/files.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAoD1D,+FAA+F;AAC/F,wBAAgB,WAAW,CACzB,MAAM,EAAE,cAAc,EACtB,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GACjC;IAAE,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAAC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;CAAE,CAcpD"}
@@ -0,0 +1,59 @@
1
+ import { existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, writeFileSync, } from 'node:fs';
2
+ import path from 'node:path';
3
+ import { catalogDeclaration, catalogModule, MARK } from './modules.js';
4
+ /**
5
+ * Writes through a dotted temp file and a rename: builds run at once (one per app of a monorepo, the
6
+ * dev server beside `tsc --watch`) must never read a half-written chunk.
7
+ */
8
+ function writeIfChanged(file, content) {
9
+ if (existsSync(file) && readFileSync(file, 'utf8') === content) {
10
+ return false;
11
+ }
12
+ mkdirSync(path.dirname(file), { recursive: true });
13
+ const tmp = path.join(path.dirname(file), `.${path.basename(file)}.${process.pid}.tmp`);
14
+ writeFileSync(tmp, content);
15
+ renameSync(tmp, file);
16
+ return true;
17
+ }
18
+ /** Not a symlink: it leads out of `outDir`. */
19
+ const isFolder = (dir) => lstatSync(dir, { throwIfNoEntry: false })?.isDirectory() ?? false;
20
+ function isGenerated(file) {
21
+ try {
22
+ return readFileSync(file, 'utf8').startsWith(MARK);
23
+ }
24
+ catch {
25
+ // a parallel build removed it first
26
+ return false;
27
+ }
28
+ }
29
+ /** Removes the files in `out/rel` that an earlier build generated and this one did not. */
30
+ function removeStale(out, { rel, kept }) {
31
+ const removed = [];
32
+ const dir = path.join(out, rel);
33
+ for (const entry of isFolder(dir) ? readdirSync(dir, { withFileTypes: true }) : []) {
34
+ const file = path.join(dir, entry.name);
35
+ // a dotted file is another build's write in progress
36
+ const isStale = entry.isFile() && !entry.name.startsWith('.') && !kept.has(path.join(rel, entry.name));
37
+ if (isStale && isGenerated(file)) {
38
+ rmSync(file, { force: true });
39
+ removed.push(file);
40
+ }
41
+ }
42
+ return removed;
43
+ }
44
+ /** Writes what changed of `files` and the catalog, then removes what an earlier build left. */
45
+ export function writeOutput(config, files) {
46
+ const out = config.outDir;
47
+ const all = new Map([
48
+ ...files,
49
+ ['catalog.js', catalogModule(config)],
50
+ ['catalog.d.ts', catalogDeclaration(config)],
51
+ ]);
52
+ const written = [...all].filter(([rel, code]) => writeIfChanged(path.join(out, rel), code));
53
+ const removed = removeStale(out, { rel: 'namespaces', kept: all });
54
+ const messagesDir = path.join(out, 'messages');
55
+ for (const locale of isFolder(messagesDir) ? readdirSync(messagesDir) : []) {
56
+ removed.push(...removeStale(out, { rel: path.join('messages', locale), kept: all }));
57
+ }
58
+ return { written: written.map(([rel]) => path.join(out, rel)), removed };
59
+ }
@@ -0,0 +1,21 @@
1
+ import type { MessageInfo } from '../compile/info.ts';
2
+ import type { ResolvedConfig, ResolvedNamespace } from '../config/config.ts';
3
+ import type { Diagnostic } from '../diagnostics.ts';
4
+ import type { Entry } from './read.ts';
5
+ type Messages = Map<string, {
6
+ info: MessageInfo;
7
+ source: string;
8
+ }>;
9
+ export interface LocaleInput {
10
+ readonly config: ResolvedConfig;
11
+ readonly ns: ResolvedNamespace;
12
+ readonly catalogs: ReadonlyMap<string, ReadonlyMap<string, Entry>>;
13
+ readonly reported: ReadonlySet<string>;
14
+ /** The source locale's messages, filled by its own call, which comes first. */
15
+ readonly sourceInfo: Messages;
16
+ readonly diagnostics: Array<Diagnostic>;
17
+ }
18
+ /** One locale's chunk of a namespace: every source key, translated or borrowed. */
19
+ export declare function compileLocale(locale: string, input: LocaleInput): string;
20
+ export {};
21
+ //# sourceMappingURL=locale.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locale.d.ts","sourceRoot":"","sources":["../../src/generate/locale.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAmB,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEvE,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE7E,OAAO,KAAK,EAAE,UAAU,EAAY,MAAM,mBAAmB,CAAC;AAM9D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAEvC,KAAK,QAAQ,GAAG,GAAG,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAEnE,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,EAAE,EAAE,iBAAiB,CAAC;IAC/B,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;IACnE,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACvC,+EAA+E;IAC/E,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC;IAC9B,QAAQ,CAAC,WAAW,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;CACzC;AAwDD,mFAAmF;AACnF,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,MAAM,CA+DxE"}
@@ -0,0 +1,108 @@
1
+ import { compileMessage } from '../compile/compile.js';
2
+ import { CompileError } from '../compile/error.js';
3
+ import { ModuleScope } from '../compile/scope.js';
4
+ import { fallbackChain } from '../config/fallbacks.js';
5
+ import { missingPlurals, samePlurals } from '../plurals.js';
6
+ import { inherits, mismatches, omissions } from './checks.js';
7
+ import { emitFactory, treeOf } from './chunk.js';
8
+ import { HEADER } from './modules.js';
9
+ /** The entry a locale compiles for `key`: its own, else the first of its chain that has it. */
10
+ function entryFor(key, { config, locale, own, catalogs, chain, gapsAllowed, reported, at }) {
11
+ const entry = own.get(key);
12
+ if (entry) {
13
+ return { entry, from: locale };
14
+ }
15
+ // the chain ends at the source locale, which has every key
16
+ const from = chain.find((l) => catalogs.get(l)?.has(key)) ?? config.sourceLocale;
17
+ if (!gapsAllowed && !reported.has(locale) && !reported.has(`${locale}\0${key}`)) {
18
+ at({
19
+ level: 'warning',
20
+ code: 'missing-translation',
21
+ key,
22
+ message: `untranslated, using "${from}"`,
23
+ });
24
+ }
25
+ return { entry: catalogs.get(from)?.get(key), from };
26
+ }
27
+ /** A translation's params, markup and plurals against the source message's. */
28
+ function compare(key, { compiled, ctx }) {
29
+ const { config, locale, own, sourceInfo, at } = ctx;
30
+ // A source message that fails to compile is reported for the source locale.
31
+ const ref = sourceInfo.get(key)?.info;
32
+ if (locale !== config.sourceLocale && own.has(key) && ref) {
33
+ for (const message of mismatches(compiled.info, ref)) {
34
+ at({ level: 'error', code: 'param-mismatch', key, message });
35
+ }
36
+ for (const message of omissions(compiled.info, ref)) {
37
+ at({ level: 'warning', code: 'missing-param', key, message });
38
+ }
39
+ }
40
+ const missing = own.has(key) ? missingPlurals(locale, compiled.info) : [];
41
+ if (missing.length > 0) {
42
+ const message = `has no plural form for ${missing.join(', ')}, which "${locale}" uses`;
43
+ at({ level: 'warning', code: 'missing-plural', key, message });
44
+ }
45
+ }
46
+ /** One locale's chunk of a namespace: every source key, translated or borrowed. */
47
+ export function compileLocale(locale, input) {
48
+ const { config, ns, catalogs, reported, sourceInfo, diagnostics } = input;
49
+ const source = catalogs.get(config.sourceLocale) ?? new Map();
50
+ const own = catalogs.get(locale) ?? new Map();
51
+ const at = (d) => {
52
+ diagnostics.push({ ...d, namespace: ns.name, locale, file: ns.file(locale) });
53
+ };
54
+ const ctx = {
55
+ ...input,
56
+ locale,
57
+ own,
58
+ chain: fallbackChain(config, locale),
59
+ gapsAllowed: inherits(config, locale),
60
+ at,
61
+ };
62
+ // A source that failed to parse may have the key.
63
+ if (!reported.has(config.sourceLocale)) {
64
+ for (const key of own.keys()) {
65
+ if (source.has(key) || reported.has(`${config.sourceLocale}\0${key}`)) {
66
+ continue;
67
+ }
68
+ at({
69
+ level: 'warning',
70
+ code: 'unknown-key',
71
+ key,
72
+ message: `not in "${config.sourceLocale}", so dropped: add it there or remove it`,
73
+ });
74
+ }
75
+ }
76
+ const scope = new ModuleScope();
77
+ const messages = [];
78
+ for (const [key, srcEntry] of source) {
79
+ const { entry = srcEntry, from } = entryFor(key, ctx);
80
+ let compiled;
81
+ try {
82
+ compiled = compileMessage(entry.model, {
83
+ scope,
84
+ custom: config.functions,
85
+ pluralsOf: from === locale || samePlurals(from, locale) ? undefined : from,
86
+ });
87
+ }
88
+ catch (error) {
89
+ if (!(error instanceof CompileError)) {
90
+ throw error;
91
+ }
92
+ // borrowed text is reported for the locale that wrote it
93
+ if (from === locale) {
94
+ at({ level: 'error', code: 'invalid-syntax', key, message: error.message });
95
+ }
96
+ continue;
97
+ }
98
+ if (locale === config.sourceLocale) {
99
+ sourceInfo.set(key, { info: compiled.info, source: srcEntry.source });
100
+ }
101
+ compare(key, { compiled, ctx });
102
+ // A message that never reads `p` takes no default, so a call without params allocates nothing.
103
+ const param = /\bp\b/.test(compiled.body) ? 'p = {}' : 'p';
104
+ messages.push([key, `(${param}) => ${compiled.body}`]);
105
+ }
106
+ const consts = scope.consts.length > 0 ? `${scope.consts.join('\n')}\n` : '';
107
+ return `${HEADER}${consts}export default ${emitFactory(treeOf(messages))};\n`;
108
+ }
@@ -0,0 +1,27 @@
1
+ import type { MessageInfo } from '../compile/info.ts';
2
+ import type { ResolvedConfig } from '../config/config.ts';
3
+ export declare const MARK = "// Generated by parla. Do not edit.\n";
4
+ export declare const HEADER = "// Generated by parla. Do not edit.\n/* eslint-disable */\n/* oxlint-disable */\n";
5
+ /**
6
+ * The namespace object's type: its messages, a kind that hands them the instance's node type when
7
+ * they have markup, and the locales it was built for.
8
+ */
9
+ export declare function namespaceDeclaration(config: ResolvedConfig, { namespace, iface, exported, messages, }: {
10
+ namespace: string;
11
+ iface: string;
12
+ exported: string;
13
+ messages: Map<string, {
14
+ info: MessageInfo;
15
+ source: string;
16
+ }>;
17
+ }): string;
18
+ /** What an app imports to load a namespace: its name and one chunk loader per locale. */
19
+ export declare function namespaceModule(namespace: string, { exported, locales }: {
20
+ exported: string;
21
+ locales: ReadonlyArray<string>;
22
+ }): string;
23
+ /** `catalog.js`, which an app passes to `createParla`. */
24
+ export declare function catalogModule(config: ResolvedConfig): string;
25
+ /** `catalog.d.ts`: the locales, and the registries it adds to the runtime. */
26
+ export declare function catalogDeclaration(config: ResolvedConfig): string;
27
+ //# sourceMappingURL=modules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modules.d.ts","sourceRoot":"","sources":["../../src/generate/modules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAM1D,eAAO,MAAM,IAAI,0CAA0C,CAAC;AAG5D,eAAO,MAAM,MAAM,sFAAwD,CAAC;AAW5E;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,cAAc,EACtB,EACE,SAAS,EACT,KAAK,EACL,QAAQ,EACR,QAAQ,GACT,EAAE;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,WAAW,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC9D,GACA,MAAM,CAcR;AAED,yFAAyF;AACzF,wBAAgB,eAAe,CAC7B,SAAS,EAAE,MAAM,EACjB,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;CAAE,GAC1E,MAAM,CAQR;AAED,0DAA0D;AAC1D,wBAAgB,aAAa,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAc5D;AAED,8EAA8E;AAC9E,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAOjE"}
@@ -0,0 +1,61 @@
1
+ import { fallbackChain } from '../config/fallbacks.js';
2
+ import { namespaceTypes } from '../types/namespace.js';
3
+ import { groupSeparator, hasPlainDigits } from './digits.js';
4
+ export const MARK = '// Generated by parla. Do not edit.\n';
5
+ // Not all linters skip what `.gitignore` lists, and oxlint may be set to ignore ESLint's directives.
6
+ export const HEADER = `${MARK}/* eslint-disable */\n/* oxlint-disable */\n`;
7
+ /** One registry augmentation, or nothing when it has no member. */
8
+ function registry(name, keys) {
9
+ const members = keys.map((k) => ` ${JSON.stringify(k)}: true;\n`).join('');
10
+ return members ? ` interface ${name} {\n${members} }\n` : '';
11
+ }
12
+ const localeType = (config) => config.locales.map((l) => JSON.stringify(l)).join(' | ');
13
+ /**
14
+ * The namespace object's type: its messages, a kind that hands them the instance's node type when
15
+ * they have markup, and the locales it was built for.
16
+ */
17
+ export function namespaceDeclaration(config, { namespace, iface, exported, messages, }) {
18
+ const types = namespaceTypes(messages, { name: iface, defaults: new Set(config.markup) });
19
+ const kind = iface.replace(/Messages$/, 'Kind');
20
+ const imported = ['Namespace', 'NamespaceKind', ...(types.usesText ? ['Text'] : [])];
21
+ return `${HEADER}import type { ${imported.join(', ')} } from '${config.runtime}';
22
+
23
+ ${types.code}
24
+
25
+ export interface ${kind} extends NamespaceKind {
26
+ readonly messages: ${iface}${types.generic ? "<this['node']>" : ''};
27
+ }
28
+
29
+ export declare const ${exported}: Namespace<${JSON.stringify(namespace)}, ${kind}, ${localeType(config)}>;
30
+ `;
31
+ }
32
+ /** What an app imports to load a namespace: its name and one chunk loader per locale. */
33
+ export function namespaceModule(namespace, { exported, locales }) {
34
+ const loaders = locales
35
+ .map((l) => ` ${JSON.stringify(l)}: () => import(${JSON.stringify(`../messages/${l}/${namespace}.js`)}),`)
36
+ .join('\n');
37
+ return `${HEADER}export const ${exported} = {\n name: ${JSON.stringify(namespace)},\n load: {\n${loaders}\n },\n};\n`;
38
+ }
39
+ /** `catalog.js`, which an app passes to `createParla`. */
40
+ export function catalogModule(config) {
41
+ const fallbacks = Object.fromEntries(config.locales.map((l) => [l, fallbackChain(config, l)]));
42
+ const plainDigits = Object.fromEntries(config.locales
43
+ .filter((l) => [l, ...(fallbacks[l] ?? [])].every((tag) => hasPlainDigits(tag)))
44
+ .map((l) => [l, groupSeparator(l, fallbacks[l] ?? []) ?? true]));
45
+ const members = Object.entries({
46
+ locales: config.locales,
47
+ sourceLocale: config.sourceLocale,
48
+ fallbacks,
49
+ plainDigits,
50
+ }).map(([key, value]) => ` ${key}: ${JSON.stringify(value)},\n`);
51
+ return `${HEADER}export const catalog = {\n${members.join('')}};\n`;
52
+ }
53
+ /** `catalog.d.ts`: the locales, and the registries it adds to the runtime. */
54
+ export function catalogDeclaration(config) {
55
+ const registries = [
56
+ registry('LocaleRegistry', config.locales),
57
+ registry('FunctionRegistry', Object.keys(config.functions)),
58
+ registry('MarkupRegistry', config.markup),
59
+ ].join('');
60
+ return `${HEADER}import type { Catalog } from '${config.runtime}';\n\nexport type Locale = ${localeType(config)};\n\nexport declare const catalog: Catalog & { readonly locales: readonly Locale[]; readonly sourceLocale: ${JSON.stringify(config.sourceLocale)} };\n\ndeclare module '${config.runtime}' {\n${registries}}\n`;
61
+ }