@gtkx/cli 1.4.0 → 1.5.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 (143) hide show
  1. package/README.md +1 -1
  2. package/dist/builder.d.ts +1 -0
  3. package/dist/builder.d.ts.map +1 -1
  4. package/dist/builder.js +2 -2
  5. package/dist/builder.js.map +1 -1
  6. package/dist/codegen/run-codegen.d.ts +2 -0
  7. package/dist/codegen/run-codegen.d.ts.map +1 -1
  8. package/dist/codegen/run-codegen.js +30 -6
  9. package/dist/codegen/run-codegen.js.map +1 -1
  10. package/dist/commands/codegen.js +1 -1
  11. package/dist/commands/codegen.js.map +1 -1
  12. package/dist/deploy/freedesktop/localize.d.ts +6 -0
  13. package/dist/deploy/freedesktop/localize.d.ts.map +1 -0
  14. package/dist/deploy/freedesktop/localize.js +107 -0
  15. package/dist/deploy/freedesktop/localize.js.map +1 -0
  16. package/dist/deploy/install-hints.d.ts.map +1 -1
  17. package/dist/deploy/install-hints.js +5 -0
  18. package/dist/deploy/install-hints.js.map +1 -1
  19. package/dist/deploy/payload/launcher.d.ts.map +1 -1
  20. package/dist/deploy/payload/launcher.js +2 -0
  21. package/dist/deploy/payload/launcher.js.map +1 -1
  22. package/dist/deploy/payload/stage.d.ts +1 -1
  23. package/dist/deploy/payload/stage.d.ts.map +1 -1
  24. package/dist/deploy/payload/stage.js +20 -11
  25. package/dist/deploy/payload/stage.js.map +1 -1
  26. package/dist/deploy/run-deploy.d.ts.map +1 -1
  27. package/dist/deploy/run-deploy.js +87 -15
  28. package/dist/deploy/run-deploy.js.map +1 -1
  29. package/dist/deploy/targets/flatpak-source.d.ts.map +1 -1
  30. package/dist/deploy/targets/flatpak-source.js +21 -10
  31. package/dist/deploy/targets/flatpak-source.js.map +1 -1
  32. package/dist/deploy/tools.d.ts +6 -1
  33. package/dist/deploy/tools.d.ts.map +1 -1
  34. package/dist/deploy/tools.js +26 -1
  35. package/dist/deploy/tools.js.map +1 -1
  36. package/dist/dev/locale-dir.d.ts +3 -0
  37. package/dist/dev/locale-dir.d.ts.map +1 -0
  38. package/dist/dev/locale-dir.js +17 -0
  39. package/dist/dev/locale-dir.js.map +1 -0
  40. package/dist/dev/runner-main.d.ts.map +1 -1
  41. package/dist/dev/runner-main.js +2 -0
  42. package/dist/dev/runner-main.js.map +1 -1
  43. package/dist/dev/runner.d.ts.map +1 -1
  44. package/dist/dev/runner.js +6 -0
  45. package/dist/dev/runner.js.map +1 -1
  46. package/dist/dev/vite-dev-server.d.ts +1 -0
  47. package/dist/dev/vite-dev-server.d.ts.map +1 -1
  48. package/dist/dev/vite-dev-server.js.map +1 -1
  49. package/dist/i18n/binding-extractor.d.ts +30 -0
  50. package/dist/i18n/binding-extractor.d.ts.map +1 -0
  51. package/dist/i18n/binding-extractor.js +1324 -0
  52. package/dist/i18n/binding-extractor.js.map +1 -0
  53. package/dist/i18n/catalog-template.d.ts +3 -0
  54. package/dist/i18n/catalog-template.d.ts.map +1 -0
  55. package/dist/i18n/catalog-template.js +18 -0
  56. package/dist/i18n/catalog-template.js.map +1 -0
  57. package/dist/i18n/catalogs.d.ts +21 -0
  58. package/dist/i18n/catalogs.d.ts.map +1 -0
  59. package/dist/i18n/catalogs.js +139 -0
  60. package/dist/i18n/catalogs.js.map +1 -0
  61. package/dist/i18n/extractor-plugin.d.ts +8 -0
  62. package/dist/i18n/extractor-plugin.d.ts.map +1 -0
  63. package/dist/i18n/extractor-plugin.js +247 -0
  64. package/dist/i18n/extractor-plugin.js.map +1 -0
  65. package/dist/i18n/metadata-templates.d.ts +11 -0
  66. package/dist/i18n/metadata-templates.d.ts.map +1 -0
  67. package/dist/i18n/metadata-templates.js +11 -0
  68. package/dist/i18n/metadata-templates.js.map +1 -0
  69. package/dist/i18n/source-messages.d.ts +23 -0
  70. package/dist/i18n/source-messages.d.ts.map +1 -0
  71. package/dist/i18n/source-messages.js +403 -0
  72. package/dist/i18n/source-messages.js.map +1 -0
  73. package/dist/i18n/types.d.ts +10 -0
  74. package/dist/i18n/types.d.ts.map +1 -0
  75. package/dist/i18n/types.js +108 -0
  76. package/dist/i18n/types.js.map +1 -0
  77. package/dist/internal/source-imports.d.ts +5 -1
  78. package/dist/internal/source-imports.d.ts.map +1 -1
  79. package/dist/internal/source-imports.js +23 -44
  80. package/dist/internal/source-imports.js.map +1 -1
  81. package/dist/mcp/client.d.ts +0 -1
  82. package/dist/mcp/client.d.ts.map +1 -1
  83. package/dist/mcp/client.js +11 -39
  84. package/dist/mcp/client.js.map +1 -1
  85. package/dist/mcp/handlers.d.ts +2 -1
  86. package/dist/mcp/handlers.d.ts.map +1 -1
  87. package/dist/mcp/handlers.js.map +1 -1
  88. package/dist/settings/render.d.ts +4 -1
  89. package/dist/settings/render.d.ts.map +1 -1
  90. package/dist/settings/render.js +11 -2
  91. package/dist/settings/render.js.map +1 -1
  92. package/dist/settings/schema.d.ts.map +1 -1
  93. package/dist/settings/schema.js +3 -1
  94. package/dist/settings/schema.js.map +1 -1
  95. package/dist/vite-plugins/asset-imports.d.ts.map +1 -1
  96. package/dist/vite-plugins/asset-imports.js +2 -12
  97. package/dist/vite-plugins/asset-imports.js.map +1 -1
  98. package/dist/vite-plugins/i18n.d.ts +5 -0
  99. package/dist/vite-plugins/i18n.d.ts.map +1 -0
  100. package/dist/vite-plugins/i18n.js +88 -0
  101. package/dist/vite-plugins/i18n.js.map +1 -0
  102. package/dist/vite-plugins/index.d.ts +1 -1
  103. package/dist/vite-plugins/index.d.ts.map +1 -1
  104. package/dist/vite-plugins/index.js +3 -1
  105. package/dist/vite-plugins/index.js.map +1 -1
  106. package/dist/vite-plugins/resources.d.ts.map +1 -1
  107. package/dist/vite-plugins/resources.js +10 -55
  108. package/dist/vite-plugins/resources.js.map +1 -1
  109. package/dist/vite-plugins/self-contained.d.ts.map +1 -1
  110. package/dist/vite-plugins/self-contained.js +128 -135
  111. package/dist/vite-plugins/self-contained.js.map +1 -1
  112. package/package.json +10 -9
  113. package/src/builder.ts +3 -2
  114. package/src/codegen/run-codegen.ts +53 -7
  115. package/src/commands/codegen.ts +1 -1
  116. package/src/deploy/freedesktop/localize.ts +144 -0
  117. package/src/deploy/install-hints.ts +5 -0
  118. package/src/deploy/payload/launcher.ts +2 -0
  119. package/src/deploy/payload/stage.ts +35 -10
  120. package/src/deploy/run-deploy.ts +128 -13
  121. package/src/deploy/targets/flatpak-source.ts +33 -10
  122. package/src/deploy/tools.ts +35 -0
  123. package/src/dev/locale-dir.ts +22 -0
  124. package/src/dev/runner-main.ts +2 -0
  125. package/src/dev/runner.ts +8 -0
  126. package/src/dev/vite-dev-server.ts +1 -0
  127. package/src/i18n/binding-extractor.ts +1969 -0
  128. package/src/i18n/catalog-template.ts +24 -0
  129. package/src/i18n/catalogs.ts +216 -0
  130. package/src/i18n/extractor-plugin.ts +413 -0
  131. package/src/i18n/metadata-templates.ts +29 -0
  132. package/src/i18n/source-messages.ts +608 -0
  133. package/src/i18n/types.ts +154 -0
  134. package/src/internal/source-imports.ts +28 -57
  135. package/src/mcp/client.ts +17 -44
  136. package/src/mcp/handlers.ts +7 -6
  137. package/src/settings/render.ts +16 -2
  138. package/src/settings/schema.ts +3 -1
  139. package/src/vite-plugins/asset-imports.ts +3 -15
  140. package/src/vite-plugins/i18n.ts +146 -0
  141. package/src/vite-plugins/index.ts +3 -0
  142. package/src/vite-plugins/resources.ts +10 -72
  143. package/src/vite-plugins/self-contained.ts +150 -169
@@ -0,0 +1,247 @@
1
+ import { extractBindings, } from "./binding-extractor.js";
2
+ const emptyExtraction = () => ({
3
+ blockedGetFixedT: new Set(),
4
+ calls: new Map(),
5
+ errors: [],
6
+ messages: [],
7
+ trans: new Map(),
8
+ });
9
+ const isRecord = (value) => typeof value === "object" && value !== null;
10
+ const nodeSpanKey = (node) => {
11
+ if (!isRecord(node.span)) {
12
+ return;
13
+ }
14
+ return typeof node.span.start === "number" && typeof node.span.end === "number"
15
+ ? `${String(node.span.start)}:${String(node.span.end)}`
16
+ : undefined;
17
+ };
18
+ const identifier = (value, source) => {
19
+ const span = isRecord(source) && isRecord(source.span) ? source.span : { end: 0, start: 0 };
20
+ return {
21
+ ctxt: 0,
22
+ optional: false,
23
+ span,
24
+ type: "Identifier",
25
+ value,
26
+ };
27
+ };
28
+ const sentinelFor = (code) => {
29
+ let sentinel = "__gtkxI18nSentinel";
30
+ while (new RegExp(String.raw `\b${sentinel}\b`, "u").test(code)) {
31
+ sentinel += "_";
32
+ }
33
+ return sentinel;
34
+ };
35
+ const canonicalSource = (code) => {
36
+ const hasBom = code.startsWith("\u{FEFF}");
37
+ let hashbangIndex = -1;
38
+ if (code.startsWith("#!")) {
39
+ hashbangIndex = 0;
40
+ }
41
+ else if (hasBom && code.startsWith("#!", 1)) {
42
+ hashbangIndex = 1;
43
+ }
44
+ let canonical = hasBom ? ` ${code.slice(1)}` : code;
45
+ if (hashbangIndex !== -1) {
46
+ canonical = `${canonical.slice(0, hashbangIndex)}//${canonical.slice(hashbangIndex + 2)}`;
47
+ }
48
+ return `;${canonical}`;
49
+ };
50
+ const replaceCallCallee = (node, sentinel) => {
51
+ node.callee = identifier(sentinel, node.callee);
52
+ };
53
+ const replaceJsxName = (element, sentinel) => {
54
+ if (!isRecord(element)) {
55
+ return;
56
+ }
57
+ if (isRecord(element.opening)) {
58
+ element.opening.name = identifier(sentinel, element.opening.name);
59
+ }
60
+ if (isRecord(element.closing)) {
61
+ element.closing.name = identifier(sentinel, element.closing.name);
62
+ }
63
+ };
64
+ const isJsxAttribute = (value) => isRecord(value) && value.type === "JSXAttribute";
65
+ const isTAttributeName = (value) => isRecord(value) && value.value === "t";
66
+ const isExpressionContainer = (value) => isRecord(value) && value.type === "JSXExpressionContainer";
67
+ const transTExpression = (attribute) => {
68
+ if (!isJsxAttribute(attribute)) {
69
+ return;
70
+ }
71
+ if (!isTAttributeName(attribute.name)) {
72
+ return;
73
+ }
74
+ if (!isExpressionContainer(attribute.value)) {
75
+ return;
76
+ }
77
+ return attribute.value;
78
+ };
79
+ const replaceTransTProp = (element, sentinel, info, context) => {
80
+ if (info === null || !isRecord(element.opening) || !Array.isArray(element.opening.attributes)) {
81
+ return;
82
+ }
83
+ for (const attribute of element.opening.attributes) {
84
+ const expression = transTExpression(attribute);
85
+ if (expression === undefined) {
86
+ continue;
87
+ }
88
+ context.setVarInScope(sentinel, info);
89
+ expression.expression = identifier(sentinel, expression.expression);
90
+ return;
91
+ }
92
+ };
93
+ const reconcileBlockedNode = (value, key, extraction, reconciled) => {
94
+ if (value.type !== "VariableDeclarator") {
95
+ return;
96
+ }
97
+ if (!extraction.blockedGetFixedT.has(key)) {
98
+ return;
99
+ }
100
+ blockUnrelatedGetFixedT(value);
101
+ reconciled.blocked.add(key);
102
+ };
103
+ const reconcileCallNode = (value, key, extraction, reconciled) => {
104
+ if (value.type === "CallExpression" && extraction.calls.has(key)) {
105
+ reconciled.calls.add(key);
106
+ }
107
+ };
108
+ const reconcileTransNode = (value, key, extraction, reconciled) => {
109
+ if (value.type === "JSXElement" && extraction.trans.has(key)) {
110
+ reconciled.trans.add(key);
111
+ }
112
+ };
113
+ const reconcileNode = (value, extraction, reconciled) => {
114
+ const key = nodeSpanKey(value);
115
+ if (key === undefined) {
116
+ return;
117
+ }
118
+ reconcileBlockedNode(value, key, extraction, reconciled);
119
+ reconcileCallNode(value, key, extraction, reconciled);
120
+ reconcileTransNode(value, key, extraction, reconciled);
121
+ };
122
+ const visitModuleChild = (child, extraction, reconciled) => {
123
+ if (Array.isArray(child)) {
124
+ for (const item of child) {
125
+ visitModuleNode(item, extraction, reconciled);
126
+ }
127
+ return;
128
+ }
129
+ visitModuleNode(child, extraction, reconciled);
130
+ };
131
+ const visitModuleNode = (value, extraction, reconciled) => {
132
+ if (!isRecord(value)) {
133
+ return;
134
+ }
135
+ reconcileNode(value, extraction, reconciled);
136
+ for (const [name, child] of Object.entries(value)) {
137
+ if (name !== "span") {
138
+ visitModuleChild(child, extraction, reconciled);
139
+ }
140
+ }
141
+ };
142
+ const wasExtractionReconciled = (extraction, reconciled) => reconciled.blocked.size === extraction.blockedGetFixedT.size &&
143
+ reconciled.calls.size === extraction.calls.size &&
144
+ reconciled.trans.size === extraction.trans.size;
145
+ const blockUnrelatedGetFixedT = (declarator) => {
146
+ if (!isRecord(declarator.init) || !isRecord(declarator.init.callee)) {
147
+ return;
148
+ }
149
+ const callee = declarator.init.callee;
150
+ if (callee.type === "MemberExpression" &&
151
+ isRecord(callee.property) &&
152
+ callee.property.value === "getFixedT") {
153
+ callee.property.value = "__gtkxIgnoredGetFixedT";
154
+ }
155
+ };
156
+ const prepareModule = (module, extraction, context) => {
157
+ const reconciled = {
158
+ blocked: new Set(),
159
+ calls: new Set(),
160
+ trans: new Set(),
161
+ };
162
+ visitModuleNode(module, extraction, reconciled);
163
+ if (!wasExtractionReconciled(extraction, reconciled)) {
164
+ context.logger.warn("GTKX could not reconcile the binding-aware and i18next syntax trees");
165
+ }
166
+ };
167
+ const submitMessages = (extraction, context) => {
168
+ for (const error of extraction.errors) {
169
+ context.logger.warn(error);
170
+ }
171
+ for (const message of extraction.messages) {
172
+ context.addKey({
173
+ key: message.key,
174
+ defaultValue: message.defaultValue,
175
+ explicitDefault: message.explicitDefault,
176
+ locations: [message.location],
177
+ ...(message.ns !== undefined && { ns: message.ns }),
178
+ });
179
+ }
180
+ };
181
+ const loadSource = async (state, transComponents, code, path) => {
182
+ const canonical = canonicalSource(code);
183
+ state.extraction = await extractBindings(canonical, path);
184
+ state.sentinel = sentinelFor(canonical);
185
+ transComponents.splice(0, transComponents.length, state.sentinel);
186
+ return canonical;
187
+ };
188
+ const visitCall = (state, node, key, context) => {
189
+ const call = state.extraction.calls.get(key);
190
+ if (call !== undefined) {
191
+ context.setVarInScope(state.sentinel, call.info);
192
+ replaceCallCallee(node, state.sentinel);
193
+ }
194
+ };
195
+ const visitTrans = (state, node, key, context) => {
196
+ const transInfo = state.extraction.trans.get(key);
197
+ if (transInfo !== undefined) {
198
+ const tSentinel = `${state.sentinel}T`;
199
+ replaceJsxName(node, state.sentinel);
200
+ replaceTransTProp(node, tSentinel, transInfo, context);
201
+ }
202
+ };
203
+ const visitMatchedNode = (state, node, key, context) => {
204
+ if (node.type === "VariableDeclarator" && state.extraction.blockedGetFixedT.has(key)) {
205
+ blockUnrelatedGetFixedT(node);
206
+ return;
207
+ }
208
+ if (node.type === "CallExpression") {
209
+ visitCall(state, node, key, context);
210
+ return;
211
+ }
212
+ if (node.type === "JSXElement") {
213
+ visitTrans(state, node, key, context);
214
+ }
215
+ };
216
+ const visitNode = (state, node, context) => {
217
+ if (!isRecord(node)) {
218
+ return;
219
+ }
220
+ if (node.type === "Module") {
221
+ prepareModule(node, state.extraction, context);
222
+ submitMessages(state.extraction, context);
223
+ return;
224
+ }
225
+ const key = nodeSpanKey(node);
226
+ if (key !== undefined) {
227
+ visitMatchedNode(state, node, key, context);
228
+ }
229
+ };
230
+ const gtkxExtractorPlugin = () => {
231
+ const state = {
232
+ extraction: emptyExtraction(),
233
+ sentinel: "__gtkxI18nSentinel",
234
+ };
235
+ const transComponents = [];
236
+ const plugin = {
237
+ name: "gtkx-react-i18next",
238
+ onLoad: loadSource.bind(undefined, state, transComponents),
239
+ onVisitNode: visitNode.bind(undefined, state),
240
+ };
241
+ return {
242
+ plugin,
243
+ transComponents,
244
+ };
245
+ };
246
+ export { gtkxExtractorPlugin };
247
+ //# sourceMappingURL=extractor-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extractor-plugin.js","sourceRoot":"","sources":["../../src/i18n/extractor-plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAEH,eAAe,GAElB,MAAM,wBAAwB,CAAC;AAkBhC,MAAM,eAAe,GAAG,GAAsB,EAAE,CAAC,CAAC;IAC9C,gBAAgB,EAAE,IAAI,GAAG,EAAE;IAC3B,KAAK,EAAE,IAAI,GAAG,EAAE;IAChB,MAAM,EAAE,EAAE;IACV,QAAQ,EAAE,EAAE;IACZ,KAAK,EAAE,IAAI,GAAG,EAAE;CACnB,CAAC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CAAC","sourcesContent":["import type { Plugin, PluginContext } from \"i18next-cli\";\nimport {\n type BindingExtraction,\n extractBindings,\n type ScopeInfo,\n} from \"./binding-extractor.js\";\n\ntype GtkxExtractorPlugin = {\n plugin: Plugin;\n transComponents: string[];\n};\n\ntype ExtractorState = {\n extraction: BindingExtraction;\n sentinel: string;\n};\n\ntype ReconciledNodes = {\n blocked: Set<string>;\n calls: Set<string>;\n trans: Set<string>;\n};\n\nconst emptyExtraction = (): BindingExtraction => ({\n blockedGetFixedT: new Set(),\n calls: new Map(),\n errors: [],\n messages: [],\n trans: new Map(),\n});\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null;\n\nconst nodeSpanKey = (node: Record<string, unknown>): string | undefined => {\n if (!isRecord(node.span)) {\n return;\n }\n\n return typeof node.span.start === \"number\" && typeof node.span.end === \"number\"\n ? `${String(node.span.start)}:${String(node.span.end)}`\n : undefined;\n};\n\nconst identifier = (value: string, source: unknown): Record<string, unknown> => {\n const span = isRecord(source) && isRecord(source.span) ? source.span : { end: 0, start: 0 };\n\n return {\n ctxt: 0,\n optional: false,\n span,\n type: \"Identifier\",\n value,\n };\n};\n\nconst sentinelFor = (code: string): string => {\n let sentinel = \"__gtkxI18nSentinel\";\n\n while (new RegExp(String.raw`\\b${sentinel}\\b`, \"u\").test(code)) {\n sentinel += \"_\";\n }\n\n return sentinel;\n};\n\nconst canonicalSource = (code: string): string => {\n const hasBom = code.startsWith(\"\\u{FEFF}\");\n let hashbangIndex = -1;\n\n if (code.startsWith(\"#!\")) {\n hashbangIndex = 0;\n } else if (hasBom && code.startsWith(\"#!\", 1)) {\n hashbangIndex = 1;\n }\n\n let canonical = hasBom ? ` ${code.slice(1)}` : code;\n\n if (hashbangIndex !== -1) {\n canonical = `${canonical.slice(0, hashbangIndex)}//${canonical.slice(hashbangIndex + 2)}`;\n }\n\n return `;${canonical}`;\n};\n\nconst replaceCallCallee = (node: Record<string, unknown>, sentinel: string): void => {\n node.callee = identifier(sentinel, node.callee);\n};\n\nconst replaceJsxName = (element: unknown, sentinel: string): void => {\n if (!isRecord(element)) {\n return;\n }\n\n if (isRecord(element.opening)) {\n element.opening.name = identifier(sentinel, element.opening.name);\n }\n\n if (isRecord(element.closing)) {\n element.closing.name = identifier(sentinel, element.closing.name);\n }\n};\n\nconst isJsxAttribute = (value: unknown): value is Record<string, unknown> =>\n isRecord(value) && value.type === \"JSXAttribute\";\n\nconst isTAttributeName = (value: unknown): boolean =>\n isRecord(value) && value.value === \"t\";\n\nconst isExpressionContainer = (value: unknown): value is Record<string, unknown> =>\n isRecord(value) && value.type === \"JSXExpressionContainer\";\n\nconst transTExpression = (attribute: unknown): Record<string, unknown> | undefined => {\n if (!isJsxAttribute(attribute)) {\n return;\n }\n\n if (!isTAttributeName(attribute.name)) {\n return;\n }\n\n if (!isExpressionContainer(attribute.value)) {\n return;\n }\n\n return attribute.value;\n};\n\nconst replaceTransTProp = (\n element: Record<string, unknown>,\n sentinel: string,\n info: ScopeInfo | null,\n context: PluginContext,\n): void => {\n if (info === null || !isRecord(element.opening) || !Array.isArray(element.opening.attributes)) {\n return;\n }\n\n for (const attribute of element.opening.attributes) {\n const expression = transTExpression(attribute);\n\n if (expression === undefined) {\n continue;\n }\n\n context.setVarInScope(sentinel, info);\n expression.expression = identifier(sentinel, expression.expression);\n\n return;\n }\n};\n\nconst reconcileBlockedNode = (\n value: Record<string, unknown>,\n key: string,\n extraction: BindingExtraction,\n reconciled: ReconciledNodes,\n): void => {\n if (value.type !== \"VariableDeclarator\") {\n return;\n }\n\n if (!extraction.blockedGetFixedT.has(key)) {\n return;\n }\n\n blockUnrelatedGetFixedT(value);\n reconciled.blocked.add(key);\n};\n\nconst reconcileCallNode = (\n value: Record<string, unknown>,\n key: string,\n extraction: BindingExtraction,\n reconciled: ReconciledNodes,\n): void => {\n if (value.type === \"CallExpression\" && extraction.calls.has(key)) {\n reconciled.calls.add(key);\n }\n};\n\nconst reconcileTransNode = (\n value: Record<string, unknown>,\n key: string,\n extraction: BindingExtraction,\n reconciled: ReconciledNodes,\n): void => {\n if (value.type === \"JSXElement\" && extraction.trans.has(key)) {\n reconciled.trans.add(key);\n }\n};\n\nconst reconcileNode = (\n value: Record<string, unknown>,\n extraction: BindingExtraction,\n reconciled: ReconciledNodes,\n): void => {\n const key = nodeSpanKey(value);\n\n if (key === undefined) {\n return;\n }\n\n reconcileBlockedNode(value, key, extraction, reconciled);\n reconcileCallNode(value, key, extraction, reconciled);\n reconcileTransNode(value, key, extraction, reconciled);\n};\n\nconst visitModuleChild = (\n child: unknown,\n extraction: BindingExtraction,\n reconciled: ReconciledNodes,\n): void => {\n if (Array.isArray(child)) {\n for (const item of child) {\n visitModuleNode(item, extraction, reconciled);\n }\n\n return;\n }\n\n visitModuleNode(child, extraction, reconciled);\n};\n\nconst visitModuleNode = (\n value: unknown,\n extraction: BindingExtraction,\n reconciled: ReconciledNodes,\n): void => {\n if (!isRecord(value)) {\n return;\n }\n\n reconcileNode(value, extraction, reconciled);\n\n for (const [name, child] of Object.entries(value)) {\n if (name !== \"span\") {\n visitModuleChild(child, extraction, reconciled);\n }\n }\n};\n\nconst wasExtractionReconciled = (\n extraction: BindingExtraction,\n reconciled: ReconciledNodes,\n): boolean =>\n reconciled.blocked.size === extraction.blockedGetFixedT.size &&\n reconciled.calls.size === extraction.calls.size &&\n reconciled.trans.size === extraction.trans.size;\n\nconst blockUnrelatedGetFixedT = (declarator: Record<string, unknown>): void => {\n if (!isRecord(declarator.init) || !isRecord(declarator.init.callee)) {\n return;\n }\n\n const callee = declarator.init.callee;\n\n if (\n callee.type === \"MemberExpression\" &&\n isRecord(callee.property) &&\n callee.property.value === \"getFixedT\"\n ) {\n callee.property.value = \"__gtkxIgnoredGetFixedT\";\n }\n};\n\nconst prepareModule = (\n module: Record<string, unknown>,\n extraction: BindingExtraction,\n context: PluginContext,\n): void => {\n const reconciled: ReconciledNodes = {\n blocked: new Set(),\n calls: new Set(),\n trans: new Set(),\n };\n\n visitModuleNode(module, extraction, reconciled);\n\n if (!wasExtractionReconciled(extraction, reconciled)) {\n context.logger.warn(\"GTKX could not reconcile the binding-aware and i18next syntax trees\");\n }\n};\n\nconst submitMessages = (\n extraction: BindingExtraction,\n context: PluginContext,\n): void => {\n for (const error of extraction.errors) {\n context.logger.warn(error);\n }\n\n for (const message of extraction.messages) {\n context.addKey({\n key: message.key,\n defaultValue: message.defaultValue,\n explicitDefault: message.explicitDefault,\n locations: [message.location],\n ...(message.ns !== undefined && { ns: message.ns }),\n });\n }\n};\n\nconst loadSource = async (\n state: ExtractorState,\n transComponents: string[],\n code: string,\n path: string,\n): Promise<string> => {\n const canonical = canonicalSource(code);\n state.extraction = await extractBindings(canonical, path);\n state.sentinel = sentinelFor(canonical);\n transComponents.splice(0, transComponents.length, state.sentinel);\n\n return canonical;\n};\n\nconst visitCall = (\n state: ExtractorState,\n node: Record<string, unknown>,\n key: string,\n context: PluginContext,\n): void => {\n const call = state.extraction.calls.get(key);\n\n if (call !== undefined) {\n context.setVarInScope(state.sentinel, call.info);\n replaceCallCallee(node, state.sentinel);\n }\n};\n\nconst visitTrans = (\n state: ExtractorState,\n node: Record<string, unknown>,\n key: string,\n context: PluginContext,\n): void => {\n const transInfo = state.extraction.trans.get(key);\n\n if (transInfo !== undefined) {\n const tSentinel = `${state.sentinel}T`;\n replaceJsxName(node, state.sentinel);\n replaceTransTProp(node, tSentinel, transInfo, context);\n }\n};\n\nconst visitMatchedNode = (\n state: ExtractorState,\n node: Record<string, unknown>,\n key: string,\n context: PluginContext,\n): void => {\n if (node.type === \"VariableDeclarator\" && state.extraction.blockedGetFixedT.has(key)) {\n blockUnrelatedGetFixedT(node);\n\n return;\n }\n\n if (node.type === \"CallExpression\") {\n visitCall(state, node, key, context);\n\n return;\n }\n\n if (node.type === \"JSXElement\") {\n visitTrans(state, node, key, context);\n }\n};\n\nconst visitNode = (\n state: ExtractorState,\n node: unknown,\n context: PluginContext,\n): void => {\n if (!isRecord(node)) {\n return;\n }\n\n if (node.type === \"Module\") {\n prepareModule(node, state.extraction, context);\n submitMessages(state.extraction, context);\n\n return;\n }\n\n const key = nodeSpanKey(node);\n\n if (key !== undefined) {\n visitMatchedNode(state, node, key, context);\n }\n};\n\nconst gtkxExtractorPlugin = (): GtkxExtractorPlugin => {\n const state: ExtractorState = {\n extraction: emptyExtraction(),\n sentinel: \"__gtkxI18nSentinel\",\n };\n\n const transComponents: string[] = [];\n\n const plugin: Plugin = {\n name: \"gtkx-react-i18next\",\n onLoad: loadSource.bind(undefined, state, transComponents),\n onVisitNode: visitNode.bind(undefined, state),\n };\n\n return {\n plugin,\n transComponents,\n };\n};\n\nexport { gtkxExtractorPlugin };\n"]}
@@ -0,0 +1,11 @@
1
+ import type { CatalogProject } from "./catalogs.js";
2
+ type MetadataTemplateKind = "desktop" | "metainfo.xml" | "mime.xml";
3
+ type MetadataTemplateFile = {
4
+ kind: MetadataTemplateKind;
5
+ path: string;
6
+ relativePath: string;
7
+ };
8
+ declare const metadataTemplateFile: (project: CatalogProject, kind: MetadataTemplateKind) => MetadataTemplateFile;
9
+ declare const metadataTemplateFiles: (project: CatalogProject) => MetadataTemplateFile[];
10
+ export { type MetadataTemplateKind, metadataTemplateFile, metadataTemplateFiles, };
11
+ //# sourceMappingURL=metadata-templates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metadata-templates.d.ts","sourceRoot":"","sources":["../../src/i18n/metadata-templates.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,KAAK,oBAAoB,GAAG,SAAS,GAAG,cAAc,GAAG,UAAU,CAAC;AAEpE,KAAK,oBAAoB,GAAG;IACxB,IAAI,EAAE,oBAAoB,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;CACxB,CAAC;AAKF,QAAA,MAAM,oBAAoB,GAAI,SAAS,cAAc,EAAE,MAAM,oBAAoB,KAAG,oBAKnF,CAAC;AAEF,QAAA,MAAM,qBAAqB,GAAI,SAAS,cAAc,KAAG,oBAAoB,EACC,CAAC;AAE/E,OAAO,EACH,KAAK,oBAAoB,EACzB,oBAAoB,EACpB,qBAAqB,GACxB,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { join, relative } from "node:path";
2
+ const METADATA_TEMPLATE_KINDS = ["desktop", "metainfo.xml", "mime.xml"];
3
+ const METADATA_TEMPLATE_DIRNAME = ".gtkx-metadata";
4
+ const metadataTemplateFile = (project, kind) => {
5
+ const path = join(project.poDir, METADATA_TEMPLATE_DIRNAME, `${project.domain}.template.${kind}`);
6
+ const relativePath = relative(project.root, path).replaceAll("\\", "/");
7
+ return { kind, path, relativePath };
8
+ };
9
+ const metadataTemplateFiles = (project) => METADATA_TEMPLATE_KINDS.map((kind) => metadataTemplateFile(project, kind));
10
+ export { metadataTemplateFile, metadataTemplateFiles, };
11
+ //# sourceMappingURL=metadata-templates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metadata-templates.js","sourceRoot":"","sources":["../../src/i18n/metadata-templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAW3C,MAAM,uBAAuB,GAA2B,CAAC,SAAS,EAAE,cAAc,EAAE,UAAU,CAAC,CAAC;AAChG,MAAM,yBAAyB,GAAG,gBAAgB,CAAC;AAEnD,MAAM,oBAAoB,GAAG,CAAC,OAAuB,EAAE,IAA0B,EAAwB,EAAE;IACvG,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,yBAAyB,EAAE,GAAG,OAAO,CAAC,MAAM,aAAa,IAAI,EAAE,CAAC,CAAC;IAClG,MAAM,YAAY,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAExE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;AACxC,CAAC,CAAC;AAEF,MAAM,qBAAqB,GAAG,CAAC,OAAuB,EAA0B,EAAE,CAC9E,uBAAuB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,oBAAoB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;AAE/E,OAAO,EAEH,oBAAoB,EACpB,qBAAqB,GACxB,CAAC","sourcesContent":["import { join, relative } from \"node:path\";\nimport type { CatalogProject } from \"./catalogs.js\";\n\ntype MetadataTemplateKind = \"desktop\" | \"metainfo.xml\" | \"mime.xml\";\n\ntype MetadataTemplateFile = {\n kind: MetadataTemplateKind;\n path: string;\n relativePath: string;\n};\n\nconst METADATA_TEMPLATE_KINDS: MetadataTemplateKind[] = [\"desktop\", \"metainfo.xml\", \"mime.xml\"];\nconst METADATA_TEMPLATE_DIRNAME = \".gtkx-metadata\";\n\nconst metadataTemplateFile = (project: CatalogProject, kind: MetadataTemplateKind): MetadataTemplateFile => {\n const path = join(project.poDir, METADATA_TEMPLATE_DIRNAME, `${project.domain}.template.${kind}`);\n const relativePath = relative(project.root, path).replaceAll(\"\\\\\", \"/\");\n\n return { kind, path, relativePath };\n};\n\nconst metadataTemplateFiles = (project: CatalogProject): MetadataTemplateFile[] =>\n METADATA_TEMPLATE_KINDS.map((kind) => metadataTemplateFile(project, kind));\n\nexport {\n type MetadataTemplateKind,\n metadataTemplateFile,\n metadataTemplateFiles,\n};\n"]}
@@ -0,0 +1,23 @@
1
+ import type { CatalogProject } from "./catalogs.js";
2
+ type SourceLocation = {
3
+ file: string;
4
+ line?: number | undefined;
5
+ column?: number | undefined;
6
+ };
7
+ type SourceMessage = {
8
+ context: string | null;
9
+ kind: "default" | "plural" | "pluralDefaults" | "point";
10
+ locations: SourceLocation[];
11
+ msgid: string;
12
+ namespace: string;
13
+ plural: string | null;
14
+ singular: string;
15
+ };
16
+ type SourceCatalog = {
17
+ messages: SourceMessage[];
18
+ sourceFiles: string[];
19
+ };
20
+ declare const extractSourceCatalogTo: (project: CatalogProject, paths: string[], output: string) => Promise<SourceCatalog>;
21
+ declare const extractSourceCatalog: (project: CatalogProject, paths: string[], shouldPreserveMetadataMessages?: boolean) => Promise<SourceCatalog>;
22
+ export { type SourceMessage, extractSourceCatalog, extractSourceCatalogTo };
23
+ //# sourceMappingURL=source-messages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-messages.d.ts","sourceRoot":"","sources":["../../src/i18n/source-messages.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAMpD,KAAK,cAAc,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B,CAAC;AAEF,KAAK,aAAa,GAAG;IACjB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,IAAI,EAAE,SAAS,GAAG,QAAQ,GAAG,gBAAgB,GAAG,OAAO,CAAC;IACxD,SAAS,EAAE,cAAc,EAAE,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,KAAK,aAAa,GAAG;IACjB,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,WAAW,EAAE,MAAM,EAAE,CAAC;CACzB,CAAC;AAiiBF,QAAA,MAAM,sBAAsB,GACxB,SAAS,cAAc,EACvB,OAAO,MAAM,EAAE,EACf,QAAQ,MAAM,KACf,OAAO,CAAC,aAAa,CAOvB,CAAC;AAEF,QAAA,MAAM,oBAAoB,GACtB,SAAS,cAAc,EACvB,OAAO,MAAM,EAAE,EACf,wCAAqC,KACtC,OAAO,CAAC,aAAa,CAOvB,CAAC;AAEF,OAAO,EAAE,KAAK,aAAa,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,CAAC"}