better-translation 0.4.2 → 0.4.3

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.
package/dist/react.d.mts CHANGED
@@ -32,6 +32,10 @@ interface TProps {
32
32
  id?: string;
33
33
  /** Extra disambiguating context for translators and custom grouping. */
34
34
  context?: string;
35
+ /** Source-language message template injected by the Vite plugin for deterministic fallback rendering. */
36
+ message?: string;
37
+ /** Runtime placeholder values injected by the Vite plugin for deterministic interpolation. */
38
+ values?: Record<string, ReactNode>;
35
39
  /** Source-language JSX content to translate. */
36
40
  children?: ReactNode;
37
41
  }
@@ -39,6 +43,8 @@ interface TProps {
39
43
  declare function T({
40
44
  id,
41
45
  context,
46
+ message,
47
+ values,
42
48
  children
43
49
  }: TProps): import("react/jsx-runtime").JSX.Element;
44
50
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"react.d.mts","names":[],"sources":["../src/react.tsx"],"mappings":";;;;;UAciB,sBAAA;EAAA;EAEf,QAAA,EAAU,MAAA;;EAEV,QAAA,EAAU,SAAS;AAAA;;iBAIL,iBAAA;EAAoB,QAAA;EAAU;AAAA,GAAY,sBAAA,+BAAsB,GAAA,CAAA,OAAA;;iBAMhE,WAAA,IAAW,MAAA;AAAA,KAItB,aAAA,GAAgB,MAAM;AAAA,KACtB,WAAA,IAAe,OAAA,UAAiB,eAAA,GAAkB,aAAA,GAAgB,gBAAA,EAAkB,OAAA,GAAU,gBAAA;;iBAGnF,IAAA,IAAQ,WAAW;;KAevB,QAAA;EA7B8C,sFA+BxD,QAAA,GAAW,SAAA;AAAA,IACT,MAAA,SAAe,SAAA;;iBAGH,GAAA,CAAI,KAAA,EAAO,QAAQ,+BAAA,GAAA,CAAA,OAAA;;UAKlB,MAAA;EAxCyC;EA0CxD,EAAA;EA1C8E;EA4C9E,OAAA;EA5C8E;EA8C9E,QAAA,GAAW,SAAS;AAAA;;iBAIN,CAAA;EAAI,EAAA;EAAI,OAAA;EAAS;AAAA,GAAY,MAAA,+BAAM,GAAA,CAAA,OAAA"}
1
+ {"version":3,"file":"react.d.mts","names":[],"sources":["../src/react.tsx"],"mappings":";;;;;UAciB,sBAAA;EAAA;EAEf,QAAA,EAAU,MAAA;;EAEV,QAAA,EAAU,SAAS;AAAA;;iBAIL,iBAAA;EAAoB,QAAA;EAAU;AAAA,GAAY,sBAAA,+BAAsB,GAAA,CAAA,OAAA;;iBAMhE,WAAA,IAAW,MAAA;AAAA,KAItB,aAAA,GAAgB,MAAM;AAAA,KACtB,WAAA,IAAe,OAAA,UAAiB,eAAA,GAAkB,aAAA,GAAgB,gBAAA,EAAkB,OAAA,GAAU,gBAAA;;iBAGnF,IAAA,IAAQ,WAAW;;KAevB,QAAA;EA7B8C,sFA+BxD,QAAA,GAAW,SAAA;AAAA,IACT,MAAA,SAAe,SAAA;;iBAGH,GAAA,CAAI,KAAA,EAAO,QAAQ,+BAAA,GAAA,CAAA,OAAA;;UAKlB,MAAA;EAxCyC;EA0CxD,EAAA;EA1C8E;EA4C9E,OAAA;EA5C8E;EA8C9E,OAAA;EAxCyB;EA0CzB,MAAA,GAAS,MAAA,SAAe,SAAA;EA1CC;EA4CzB,QAAA,GAAW,SAAA;AAAA;;iBAIG,CAAA;EAAI,EAAA;EAAI,OAAA;EAAS,OAAA;EAAS,MAAA;EAAQ;AAAA,GAAY,MAAA,+BAAM,GAAA,CAAA,OAAA"}
package/dist/react.mjs CHANGED
@@ -31,12 +31,13 @@ function Var(props) {
31
31
  return /* @__PURE__ */ jsx(Fragment, { children: getRuntimeVarEntry(props)?.value ?? props.children });
32
32
  }
33
33
  /** Renders translated JSX content and supports placeholders through `<Var>`. */
34
- function T({ id, context, children }) {
34
+ function T({ id, context, message, values, children }) {
35
35
  const { messages } = use(TranslateContext);
36
36
  const resolvedMeta = context ? { context } : void 0;
37
37
  const runtimeContent = useMemo(() => extractRuntimeContent(children), [children]);
38
- const template = messages[id ?? (runtimeContent.message ? getMessageId(runtimeContent.message, resolvedMeta) : "")];
39
- const vars = template?.includes("{") ? runtimeContent.vars : void 0;
38
+ const sourceMessage = message ?? runtimeContent.message;
39
+ const template = messages[id ?? (sourceMessage ? getMessageId(sourceMessage, resolvedMeta) : "")] ?? message;
40
+ const vars = template?.includes("{") ? values ?? runtimeContent.vars : void 0;
40
41
  const interpolated = useMemo(() => interpolate(template, vars), [template, vars]);
41
42
  if (!template) return /* @__PURE__ */ jsx(Fragment, { children });
42
43
  if (!vars) return /* @__PURE__ */ jsx(Fragment, { children: template });
@@ -1 +1 @@
1
- {"version":3,"file":"react.mjs","names":[],"sources":["../src/react.tsx"],"sourcesContent":["import { Children, createContext, isValidElement, use, useMemo, type ReactNode } from \"react\"\n\nimport type { TranslateOptions } from \"./types.js\"\n\nimport { getCallMessageId, getMessageId } from \"./message-id.js\"\nimport { isTranslateOptions, normalizeValues } from \"./runtime.js\"\n\ninterface TranslateContextValue {\n messages: Record<string, string>\n}\n\nconst TranslateContext = createContext<TranslateContextValue>({ messages: {} })\n\n/** Props for `TranslateProvider`. */\nexport interface TranslateProviderProps {\n /** Flattened locale message map keyed by stable lookup id. */\n messages: Record<string, string>\n /** React subtree that should have access to translations. */\n children: ReactNode\n}\n\n/** Provides translated messages to React components below it. */\nexport function TranslateProvider({ messages, children }: TranslateProviderProps) {\n const value = useMemo(() => ({ messages }), [messages])\n return <TranslateContext.Provider value={value}>{children}</TranslateContext.Provider>\n}\n\n/** Returns the raw locale message map from the current provider. */\nexport function useMessages() {\n return use(TranslateContext).messages\n}\n\ntype MessageValues = Record<string, unknown>\ntype TranslateFn = (message: string, valuesOrOptions?: MessageValues | TranslateOptions, options?: TranslateOptions) => string\n\n/** Returns a translator function for text used in props, labels, and other non-JSX positions. */\nexport function useT(): TranslateFn {\n const { messages } = use(TranslateContext)\n return useMemo<TranslateFn>(\n () => (message, valuesOrOptions, options) => {\n const values = isTranslateOptions(valuesOrOptions) ? undefined : normalizeValues(valuesOrOptions)\n const resolvedOptions = isTranslateOptions(valuesOrOptions) ? valuesOrOptions : options\n const template = messages[getCallMessageId(message, resolvedOptions)] ?? message\n if (!values) return template\n return template.replace(/\\{(\\w+)\\}/g, (_, name: string) => values[name] ?? `{${name}}`)\n },\n [messages],\n )\n}\n\n/** Props for `Var`. */\nexport type VarProps = {\n /** Optional shorthand child form, normalized at build time for simple identifiers. */\n children?: ReactNode\n} & Record<string, ReactNode | undefined>\n\n/** Marks a runtime value for placeholder interpolation inside `<T>` content. */\nexport function Var(props: VarProps) {\n return <>{getRuntimeVarEntry(props)?.value ?? props.children}</>\n}\n\n/** Props for `T`. */\nexport interface TProps {\n /** Explicit stable lookup id to use instead of hashing the rendered source text, whether provided manually or by a transform. */\n id?: string\n /** Extra disambiguating context for translators and custom grouping. */\n context?: string\n /** Source-language JSX content to translate. */\n children?: ReactNode\n}\n\n/** Renders translated JSX content and supports placeholders through `<Var>`. */\nexport function T({ id, context, children }: TProps) {\n const { messages } = use(TranslateContext)\n const resolvedMeta = context ? { context } : undefined\n const runtimeContent = useMemo(() => extractRuntimeContent(children), [children])\n const template = messages[id ?? (runtimeContent.message ? getMessageId(runtimeContent.message, resolvedMeta) : \"\")]\n const vars = template?.includes(\"{\") ? runtimeContent.vars : undefined\n const interpolated = useMemo(() => interpolate(template, vars), [template, vars])\n\n if (!template) return <>{children}</>\n if (!vars) return <>{template}</>\n if (!interpolated.length) return <>{children}</>\n return <>{interpolated}</>\n}\n\nfunction interpolate(template?: string, vars?: Record<string, ReactNode>): ReactNode[] {\n if (!template || !vars) return []\n const result: ReactNode[] = []\n const re = /\\{(\\w+)\\}/g\n let lastIndex = 0\n let match: RegExpExecArray | null\n\n while ((match = re.exec(template)) !== null) {\n if (match.index > lastIndex) result.push(template.slice(lastIndex, match.index))\n result.push(vars[match[1]!] ?? `{${match[1]}}`)\n lastIndex = re.lastIndex\n }\n\n if (lastIndex < template.length) result.push(template.slice(lastIndex))\n return result\n}\n\nfunction extractRuntimeContent(children: ReactNode) {\n const parts: string[] = []\n const vars: Record<string, ReactNode> = {}\n\n Children.forEach(children, (child) => {\n if (typeof child === \"string\" || typeof child === \"number\") {\n parts.push(String(child))\n return\n }\n\n if (isValidElement<VarProps>(child) && child.type === Var) {\n const entry = getRuntimeVarEntry(child.props)\n if (entry) {\n parts.push(`{${entry.name}}`)\n vars[entry.name] = entry.value\n }\n }\n })\n\n return {\n message: parts.join(\"\").replace(/\\s+/g, \" \").trim(),\n vars: Object.keys(vars).length > 0 ? vars : undefined,\n }\n}\n\nfunction getRuntimeVarEntry(props: VarProps) {\n if (typeof props.name === \"string\" && props.children !== undefined) {\n return { name: props.name, value: props.children }\n }\n\n const entries = Object.entries(props).filter(([key]) => key !== \"children\")\n if (entries.length !== 1) return undefined\n\n const [name, value] = entries[0]!\n return { name, value }\n}\n"],"mappings":";;;;;AAWA,MAAM,mBAAmB,cAAqC,EAAE,UAAU,CAAC,EAAE,CAAC;;AAW9E,SAAgB,kBAAkB,EAAE,UAAU,YAAoC;CAChF,MAAM,QAAQ,eAAe,EAAE,SAAS,IAAI,CAAC,QAAQ,CAAC;CACtD,OAAO,oBAAC,iBAAiB,UAAlB;EAAkC;EAAQ;CAAoC,CAAA;AACvF;;AAGA,SAAgB,cAAc;CAC5B,OAAO,IAAI,gBAAgB,EAAE;AAC/B;;AAMA,SAAgB,OAAoB;CAClC,MAAM,EAAE,aAAa,IAAI,gBAAgB;CACzC,OAAO,eACE,SAAS,iBAAiB,YAAY;EAC3C,MAAM,SAAS,mBAAmB,eAAe,IAAI,KAAA,IAAY,gBAAgB,eAAe;EAEhG,MAAM,WAAW,SAAS,iBAAiB,SADnB,mBAAmB,eAAe,IAAI,kBAAkB,OACb,MAAM;EACzE,IAAI,CAAC,QAAQ,OAAO;EACpB,OAAO,SAAS,QAAQ,eAAe,GAAG,SAAiB,OAAO,SAAS,IAAI,KAAK,EAAE;CACxF,GACA,CAAC,QAAQ,CACX;AACF;;AASA,SAAgB,IAAI,OAAiB;CACnC,OAAO,oBAAA,UAAA,EAAA,UAAG,mBA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AAM,OAAkC,CAAC;CAEzC,SAAS,QAAQ,WAAW,UAAU;EACpC,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,UAAU;GAC1D,MAAM,KAAK,OAAO,KAAK,CAAC;GACxB;EACF;EAEA,IAAI,eAAyB,KAAK,KAAK,MAAM,SAAS,KAAK;GACzD,MAAM,QAAQ,mBAAmB,MAAM,KAAK;GAC5C,IAAI,OAAO;IACT,MAAM,KAAK,IAAI,MAAM,KAAK,EAAE;IAC5B,KAAK,MAAM,QAAQ,MAAM;GAC3B;EACF;CACF,CAAC;CAED,OAAO;EACL,SAAS,MAAM,KAAK,EAAE,EAAE,QAAQ,QAAQ,GAAG,EAAE,KAAK;EAClD,MAAM,OAAO,KAAK,IAAI,EAAE,SAAS,IAAI,OAAO,KAAA;CAC9C;AACF;AAEA,SAAS,mBAAmB,OAAiB;CAC3C,IAAI,OAAO,MAAM,SAAS,YAAY,MAAM,aAAa,KAAA,GACvD,OAAO;EAAE,MAAM,MAAM;EAAM,OAAO,MAAM;CAAS;CAGnD,MAAM,UAAU,OAAO,QAAQ,KAAK,EAAE,QAAQ,CAAC,SAAS,QAAQ,UAAU;CAC1E,IAAI,QAAQ,WAAW,GAAG,OAAO,KAAA;CAEjC,MAAM,CAAC,MAAM,SAAS,QAAQ;CAC9B,OAAO;EAAE;EAAM;CAAM;AACvB"}
1
+ {"version":3,"file":"react.mjs","names":[],"sources":["../src/react.tsx"],"sourcesContent":["import { Children, createContext, isValidElement, use, useMemo, type ReactNode } from \"react\"\n\nimport type { TranslateOptions } from \"./types.js\"\n\nimport { getCallMessageId, getMessageId } from \"./message-id.js\"\nimport { isTranslateOptions, normalizeValues } from \"./runtime.js\"\n\ninterface TranslateContextValue {\n messages: Record<string, string>\n}\n\nconst TranslateContext = createContext<TranslateContextValue>({ messages: {} })\n\n/** Props for `TranslateProvider`. */\nexport interface TranslateProviderProps {\n /** Flattened locale message map keyed by stable lookup id. */\n messages: Record<string, string>\n /** React subtree that should have access to translations. */\n children: ReactNode\n}\n\n/** Provides translated messages to React components below it. */\nexport function TranslateProvider({ messages, children }: TranslateProviderProps) {\n const value = useMemo(() => ({ messages }), [messages])\n return <TranslateContext.Provider value={value}>{children}</TranslateContext.Provider>\n}\n\n/** Returns the raw locale message map from the current provider. */\nexport function useMessages() {\n return use(TranslateContext).messages\n}\n\ntype MessageValues = Record<string, unknown>\ntype TranslateFn = (message: string, valuesOrOptions?: MessageValues | TranslateOptions, options?: TranslateOptions) => string\n\n/** Returns a translator function for text used in props, labels, and other non-JSX positions. */\nexport function useT(): TranslateFn {\n const { messages } = use(TranslateContext)\n return useMemo<TranslateFn>(\n () => (message, valuesOrOptions, options) => {\n const values = isTranslateOptions(valuesOrOptions) ? undefined : normalizeValues(valuesOrOptions)\n const resolvedOptions = isTranslateOptions(valuesOrOptions) ? valuesOrOptions : options\n const template = messages[getCallMessageId(message, resolvedOptions)] ?? message\n if (!values) return template\n return template.replace(/\\{(\\w+)\\}/g, (_, name: string) => values[name] ?? `{${name}}`)\n },\n [messages],\n )\n}\n\n/** Props for `Var`. */\nexport type VarProps = {\n /** Optional shorthand child form, normalized at build time for simple identifiers. */\n children?: ReactNode\n} & Record<string, ReactNode | undefined>\n\n/** Marks a runtime value for placeholder interpolation inside `<T>` content. */\nexport function Var(props: VarProps) {\n return <>{getRuntimeVarEntry(props)?.value ?? props.children}</>\n}\n\n/** Props for `T`. */\nexport interface TProps {\n /** Explicit stable lookup id to use instead of hashing the rendered source text, whether provided manually or by a transform. */\n id?: string\n /** Extra disambiguating context for translators and custom grouping. */\n context?: string\n /** Source-language message template injected by the Vite plugin for deterministic fallback rendering. */\n message?: string\n /** Runtime placeholder values injected by the Vite plugin for deterministic interpolation. */\n values?: Record<string, ReactNode>\n /** Source-language JSX content to translate. */\n children?: ReactNode\n}\n\n/** Renders translated JSX content and supports placeholders through `<Var>`. */\nexport function T({ id, context, message, values, children }: TProps) {\n const { messages } = use(TranslateContext)\n const resolvedMeta = context ? { context } : undefined\n const runtimeContent = useMemo(() => extractRuntimeContent(children), [children])\n const sourceMessage = message ?? runtimeContent.message\n const template = messages[id ?? (sourceMessage ? getMessageId(sourceMessage, resolvedMeta) : \"\")] ?? message\n const vars = template?.includes(\"{\") ? (values ?? runtimeContent.vars) : undefined\n const interpolated = useMemo(() => interpolate(template, vars), [template, vars])\n\n if (!template) return <>{children}</>\n if (!vars) return <>{template}</>\n if (!interpolated.length) return <>{children}</>\n return <>{interpolated}</>\n}\n\nfunction interpolate(template?: string, vars?: Record<string, ReactNode>): ReactNode[] {\n if (!template || !vars) return []\n const result: ReactNode[] = []\n const re = /\\{(\\w+)\\}/g\n let lastIndex = 0\n let match: RegExpExecArray | null\n\n while ((match = re.exec(template)) !== null) {\n if (match.index > lastIndex) result.push(template.slice(lastIndex, match.index))\n result.push(vars[match[1]!] ?? `{${match[1]}}`)\n lastIndex = re.lastIndex\n }\n\n if (lastIndex < template.length) result.push(template.slice(lastIndex))\n return result\n}\n\nfunction extractRuntimeContent(children: ReactNode) {\n const parts: string[] = []\n const vars: Record<string, ReactNode> = {}\n\n Children.forEach(children, (child) => {\n if (typeof child === \"string\" || typeof child === \"number\") {\n parts.push(String(child))\n return\n }\n\n if (isValidElement<VarProps>(child) && child.type === Var) {\n const entry = getRuntimeVarEntry(child.props)\n if (entry) {\n parts.push(`{${entry.name}}`)\n vars[entry.name] = entry.value\n }\n }\n })\n\n return {\n message: parts.join(\"\").replace(/\\s+/g, \" \").trim(),\n vars: Object.keys(vars).length > 0 ? vars : undefined,\n }\n}\n\nfunction getRuntimeVarEntry(props: VarProps) {\n if (typeof props.name === \"string\" && props.children !== undefined) {\n return { name: props.name, value: props.children }\n }\n\n const entries = Object.entries(props).filter(([key]) => key !== \"children\")\n if (entries.length !== 1) return undefined\n\n const [name, value] = entries[0]!\n return { name, value }\n}\n"],"mappings":";;;;;AAWA,MAAM,mBAAmB,cAAqC,EAAE,UAAU,CAAC,EAAE,CAAC;;AAW9E,SAAgB,kBAAkB,EAAE,UAA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AC3C,IAAI,OAAO,MAAM,SAAS,YAAY,MAAM,aAAa,KAAA,GACvD,OAAO;EAAE,MAAM,MAAM;EAAM,OAAO,MAAM;CAAS;CAGnD,MAAM,UAAU,OAAO,QAAQ,KAAK,EAAE,QAAQ,CAAC,SAAS,QAAQ,UAAU;CAC1E,IAAI,QAAQ,WAAW,GAAG,OAAO,KAAA;CAEjC,MAAM,CAAC,MAAM,SAAS,QAAQ;CAC9B,OAAO;EAAE;EAAM;CAAM;AACvB"}
package/dist/vite.mjs CHANGED
@@ -152,7 +152,7 @@ function extractSvelteChildren(code, children) {
152
152
  continue;
153
153
  }
154
154
  if (child.type === "Component" && child.name === "Var") {
155
- const entry = getVarEntry(code, child);
155
+ const entry = getVarEntry$1(code, child);
156
156
  if (!entry) return {
157
157
  message: "",
158
158
  placeholders: [],
@@ -180,7 +180,7 @@ function extractSvelteChildren(code, children) {
180
180
  valid: message.length > 0
181
181
  };
182
182
  }
183
- function getVarEntry(code, node) {
183
+ function getVarEntry$1(code, node) {
184
184
  const explicitName = getStringAttribute(node.attributes, "name");
185
185
  const explicitValue = getExpressionAttributeSource(code, node.attributes, "value");
186
186
  if (explicitName && explicitValue) return {
@@ -355,7 +355,7 @@ function analyzeTypeScriptSourceFile(code, filename, markers) {
355
355
  }
356
356
  if (opening.name.type !== "JSXIdentifier") return;
357
357
  if (!markers.component.includes(opening.name.name)) return;
358
- const extraction = extractJSXChildren(node.children);
358
+ const extraction = extractJSXChildren(code, node.children);
359
359
  if (!extraction.valid) {
360
360
  if (markers.logging) console.warn(`[better-translation] Non-static <${opening.name.name}> in ${filename}, skipping`);
361
361
  return;
@@ -379,6 +379,16 @@ function analyzeTypeScriptSourceFile(code, filename, markers) {
379
379
  end: opening.name.end,
380
380
  replacement: ` id="${id}"`
381
381
  });
382
+ if (!hasJSXAttribute(opening.attributes, "message")) edits.push({
383
+ start: opening.name.end,
384
+ end: opening.name.end,
385
+ replacement: ` message={${JSON.stringify(extraction.message)}}`
386
+ });
387
+ if (!hasJSXAttribute(opening.attributes, "values") && extraction.values.length > 0) edits.push({
388
+ start: opening.name.end,
389
+ end: opening.name.end,
390
+ replacement: ` values={{ ${extraction.values.map((entry) => `${entry.name}: ${entry.value}`).join(", ")} }}`
391
+ });
382
392
  }
383
393
  }).visit(result.program);
384
394
  return {
@@ -456,9 +466,10 @@ function hasObjectProperty(node, name) {
456
466
  return property.key?.type === "Identifier" && property.key.name === name || property.key?.type === "Literal" && property.key.value === name;
457
467
  });
458
468
  }
459
- function extractJSXChildren(children) {
469
+ function extractJSXChildren(code, children) {
460
470
  const parts = [];
461
471
  const placeholders = [];
472
+ const values = [];
462
473
  for (const child of children) switch (child.type) {
463
474
  case "JSXText":
464
475
  parts.push(child.value);
@@ -468,22 +479,26 @@ function extractJSXChildren(children) {
468
479
  if (name.type !== "JSXIdentifier" || name.name !== "Var") return {
469
480
  message: "",
470
481
  placeholders: [],
482
+ values: [],
471
483
  valid: false
472
484
  };
473
- const varName = getVarPlaceholderName(child);
474
- if (!varName) return {
485
+ const entry = getVarEntry(code, child);
486
+ if (!entry) return {
475
487
  message: "",
476
488
  placeholders: [],
489
+ values: [],
477
490
  valid: false
478
491
  };
479
- placeholders.push(varName);
480
- parts.push(`{${varName}}`);
492
+ placeholders.push(entry.name);
493
+ values.push(entry);
494
+ parts.push(`{${entry.name}}`);
481
495
  break;
482
496
  }
483
497
  case "JSXExpressionContainer":
484
498
  if (child.expression.type !== "JSXEmptyExpression") return {
485
499
  message: "",
486
500
  placeholders: [],
501
+ values: [],
487
502
  valid: false
488
503
  };
489
504
  break;
@@ -493,24 +508,58 @@ function extractJSXChildren(children) {
493
508
  return {
494
509
  message,
495
510
  placeholders,
511
+ values,
496
512
  valid: message.length > 0
497
513
  };
498
514
  }
499
- function getVarPlaceholderName(node) {
515
+ function getVarEntry(code, node) {
500
516
  const explicitName = getJSXStringAttribute(node.openingElement.attributes, "name");
501
- if (explicitName) return explicitName;
502
- const customPropName = getSingleJSXAttributeName(node.openingElement.attributes);
503
- if (customPropName) return customPropName;
504
- return getVarChildIdentifier(node.children);
505
- }
506
- function getSingleJSXAttributeName(attributes) {
517
+ const explicitValue = getJSXExpressionAttributeSource(code, node.openingElement.attributes, "value");
518
+ const childValue = getVarChildrenSource(code, node.children);
519
+ if (explicitName && explicitValue) return {
520
+ name: explicitName,
521
+ value: explicitValue
522
+ };
523
+ if (explicitName && childValue) return {
524
+ name: explicitName,
525
+ value: childValue
526
+ };
527
+ if (explicitName) return {
528
+ name: explicitName,
529
+ value: JSON.stringify(explicitName)
530
+ };
531
+ const customProp = getSingleJSXAttributeEntry(code, node.openingElement.attributes);
532
+ if (customProp) return customProp;
533
+ const childIdentifier = getVarChildIdentifier(node.children);
534
+ return childIdentifier ? {
535
+ name: childIdentifier,
536
+ value: childIdentifier
537
+ } : void 0;
538
+ }
539
+ function getSingleJSXAttributeEntry(code, attributes) {
507
540
  const keys = attributes.flatMap((attr) => {
508
541
  const attribute = attr;
509
- if (attribute?.type !== "JSXAttribute" || attribute.name?.type !== "JSXIdentifier") return [];
510
- return [attribute.name.name];
542
+ if (attribute?.type !== "JSXAttribute" || attribute.name?.type !== "JSXIdentifier" || !attribute.name.name) return [];
543
+ const value = getJSXAttributeValueSource(code, attribute.value);
544
+ return value ? [{
545
+ name: attribute.name.name,
546
+ value
547
+ }] : [];
511
548
  });
512
549
  return keys.length === 1 ? keys[0] : void 0;
513
550
  }
551
+ function getJSXExpressionAttributeSource(code, attributes, name) {
552
+ for (const attr of attributes) {
553
+ if (attr.type !== "JSXAttribute" || attr.name?.type !== "JSXIdentifier" || attr.name.name !== name) continue;
554
+ if (attr.value?.type !== "JSXExpressionContainer" || !attr.value.expression) return void 0;
555
+ return code.slice(attr.value.expression.start, attr.value.expression.end);
556
+ }
557
+ }
558
+ function getJSXAttributeValueSource(code, value) {
559
+ if (!value) return void 0;
560
+ if (value.type === "JSXExpressionContainer" && value.expression) return code.slice(value.expression.start, value.expression.end);
561
+ if (value.type === "Literal" && typeof value.value === "string") return JSON.stringify(value.value);
562
+ }
514
563
  function getVarChildIdentifier(children) {
515
564
  const meaningfulChildren = children.filter((child) => !(child.type === "JSXText" && child.value.trim().length === 0));
516
565
  if (meaningfulChildren.length !== 1) return void 0;
@@ -518,6 +567,19 @@ function getVarChildIdentifier(children) {
518
567
  if (!child || child.type !== "JSXExpressionContainer" || child.expression.type !== "Identifier") return void 0;
519
568
  return child.expression.name;
520
569
  }
570
+ function getVarChildrenSource(code, children) {
571
+ const meaningfulChildren = children.filter((child) => !(child.type === "JSXText" && child.value.trim().length === 0));
572
+ if (meaningfulChildren.length === 0) return void 0;
573
+ if (meaningfulChildren.length === 1) {
574
+ const [child] = meaningfulChildren;
575
+ if (!child) return void 0;
576
+ if (child.type === "JSXExpressionContainer" && child.expression.type !== "JSXEmptyExpression") return code.slice(child.expression.start, child.expression.end);
577
+ }
578
+ const [first] = meaningfulChildren;
579
+ const last = meaningfulChildren.at(-1);
580
+ if (!first || !last) return void 0;
581
+ return `<>${code.slice(first.start, last.end)}</>`;
582
+ }
521
583
  //#endregion
522
584
  //#region src/extractor.ts
523
585
  /** Extracts messages and source edits from a framework source file. */
package/dist/vite.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"vite.mjs","names":["isStringLiteral","getCallMetaArgument","createCallOptionsEdit","getMetaArgument","isTranslateOptionsArgument","hasObjectProperty","CYAN","PREFIX","RESET","compareManifestEntryIds"],"sources":["../src/cache.ts","../src/extractors/types.ts","../src/extractors/svelte.ts","../src/extractors/typescript.ts","../src/extractor.ts","../src/local-editor/server.ts","../src/plugin.ts"],"sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\"\nimport { dirname } from \"node:path\"\n\nimport type { TranslationCache } from \"./types.js\"\n\nconst CURRENT_VERSION = 1\n\nexport function createEmptyCache(): TranslationCache {\n return { version: CURRENT_VERSION, entries: {} }\n}\n\n/** Loads the translation cache from disk, resetting it when the schema version changes. */\nexport function loadCache(path: string): TranslationCache {\n if (!existsSync(path)) return createEmptyCache()\n try {\n const data = JSON.parse(readFileSync(path, \"utf-8\")) as TranslationCache\n if (data.version !== CURRENT_VERSION) return createEmptyCache()\n return data\n } catch {\n return createEmptyCache()\n }\n}\n\n/** Persists the translation cache so future runs can reuse existing translations. */\nexport function saveCache(path: string, cache: TranslationCache) {\n const dir = dirname(path)\n if (!existsSync(dir)) mkdirSync(dir, { recursive: true })\n const next = JSON.stringify(cache, null, 2)\n if (existsSync(path) && readFileSync(path, \"utf-8\") === next) return\n writeFileSync(path, next)\n}\n\n/** Builds the cache key used to distinguish translations by stable lookup id and locale. */\nexport function getCacheKey(lookupId: string, locale: string) {\n return `${lookupId}\\0${locale}`\n}\n","import type { ExtractedMessage, MessageSource } from \"../types.js\"\n\nexport interface SourceMarkers {\n call: string[]\n component: string[]\n logging: boolean\n}\n\nexport interface SourceEdit {\n start: number\n end: number\n replacement: string\n}\n\nexport interface SourceAnalysis {\n parsed: boolean\n messages: ExtractedMessage[]\n edits: SourceEdit[]\n}\n\nexport function extractPlaceholdersFromMessage(message: string) {\n const names = new Set<string>()\n for (const match of message.matchAll(/\\{(\\w+)\\}/g)) {\n if (match[1]) names.add(match[1])\n }\n return [...names]\n}\n\nexport function createSource({\n filename,\n marker,\n kind,\n}: {\n filename: string\n marker: string\n kind: MessageSource[\"kind\"]\n}): MessageSource {\n return {\n file: filename,\n kind,\n marker,\n }\n}\n","import { createRequire } from \"node:module\"\n\nimport type { ExtractedMessage, TranslateOptions } from \"../types.js\"\n\nimport { getCallMessageId, getMessageId } from \"../message-id.js\"\nimport {\n createSource,\n extractPlaceholdersFromMessage,\n type SourceAnalysis,\n type SourceEdit,\n type SourceMarkers,\n} from \"./types.js\"\n\ntype SvelteNode = {\n type?: string\n start?: number\n end?: number\n name?: string\n attributes?: SvelteNode[]\n fragment?: {\n nodes?: SvelteNode[]\n }\n value?: unknown\n raw?: string\n data?: string\n expression?: SvelteNode\n [key: string]: unknown\n}\n\ntype SvelteAttribute = SvelteNode & {\n name?: string\n value?: SvelteNode | SvelteNode[] | true\n}\n\ntype SvelteCallExpression = SvelteNode & {\n callee?: SvelteNode\n arguments?: SvelteNode[]\n}\n\nconst require = createRequire(import.meta.url)\n\n/** Extracts messages from Svelte component markup and embedded expressions. */\nexport function analyzeSvelteSourceFile(code: string, filename: string, markers: SourceMarkers): SourceAnalysis {\n const messages: ExtractedMessage[] = []\n const edits: SourceEdit[] = []\n let ast: SvelteNode\n\n try {\n ast = loadSvelteCompiler().parse(code, { modern: true }) as unknown as SvelteNode\n } catch {\n return { parsed: false, messages, edits }\n }\n\n walkSvelte(ast, (node) => {\n if (node.type === \"Component\" && typeof node.name === \"string\" && markers.component.includes(node.name)) {\n analyzeTComponent(code, filename, markers, node, messages, edits)\n return\n }\n\n if (node.type === \"CallExpression\") {\n analyzeCallExpression(code, filename, markers, node as SvelteCallExpression, messages, edits)\n }\n })\n\n return { parsed: true, messages, edits }\n}\n\nfunction loadSvelteCompiler(): { parse: (code: string, options: { modern: true }) => unknown } {\n return require(\"svelte/compiler\") as { parse: (code: string, options: { modern: true }) => unknown }\n}\n\nfunction analyzeCallExpression(\n code: string,\n filename: string,\n markers: SourceMarkers,\n node: SvelteCallExpression,\n messages: ExtractedMessage[],\n edits: SourceEdit[],\n) {\n if (node.callee?.type !== \"Identifier\") return\n if (typeof node.callee.name !== \"string\" || !markers.call.includes(node.callee.name)) return\n const [messageArg] = node.arguments ?? []\n if (!isStringLiteral(messageArg)) return\n\n const value = String(messageArg.value)\n const meta = getCallMetaArgument(node.arguments ?? [])\n const id = getCallMessageId(value, meta)\n messages.push({\n id,\n defaultMessage: value,\n meta: meta ?? {},\n placeholders: extractPlaceholdersFromMessage(value),\n source: createSource({\n filename,\n marker: node.callee.name,\n kind: \"call\",\n }),\n })\n\n const edit = createCallOptionsEdit(code, node.arguments ?? [], id)\n if (edit) edits.push(edit)\n}\n\nfunction analyzeTComponent(\n code: string,\n filename: string,\n markers: SourceMarkers,\n node: SvelteNode,\n messages: ExtractedMessage[],\n edits: SourceEdit[],\n) {\n const extraction = extractSvelteChildren(code, node.fragment?.nodes ?? [])\n if (!extraction.valid) {\n if (markers.logging) console.warn(`[better-translation] Non-static <${node.name}> in ${filename}, skipping`)\n return\n }\n\n const context = getStringAttribute(node.attributes, \"context\")\n const meta = context ? { context } : undefined\n const id = getStringAttribute(node.attributes, \"id\") ?? getMessageId(extraction.message, meta)\n messages.push({\n id,\n defaultMessage: extraction.message,\n meta: meta ?? {},\n placeholders: extraction.placeholders,\n source: createSource({\n filename,\n marker: String(node.name),\n kind: \"component\",\n }),\n })\n\n const insertAt = getSvelteOpeningTagNameEnd(code, node)\n if (!hasAttribute(node.attributes, \"id\") && insertAt !== undefined) {\n edits.push({\n start: insertAt,\n end: insertAt,\n replacement: ` id=${JSON.stringify(id)}`,\n })\n }\n\n if (!hasAttribute(node.attributes, \"message\") && insertAt !== undefined) {\n edits.push({\n start: insertAt,\n end: insertAt,\n replacement: ` message=${JSON.stringify(extraction.message)}`,\n })\n }\n\n if (!hasAttribute(node.attributes, \"values\") && extraction.values.length > 0 && insertAt !== undefined) {\n edits.push({\n start: insertAt,\n end: insertAt,\n replacement: ` values={{ ${extraction.values.map((entry) => `${entry.name}: ${entry.value}`).join(\", \")} }}`,\n })\n }\n}\n\nfunction extractSvelteChildren(code: string, children: SvelteNode[]) {\n const parts: string[] = []\n const placeholders: string[] = []\n const values: Array<{ name: string; value: string }> = []\n\n for (const child of children) {\n if (child.type === \"Text\") {\n parts.push(String(child.data ?? child.raw ?? \"\"))\n continue\n }\n\n if (child.type === \"Component\" && child.name === \"Var\") {\n const entry = getVarEntry(code, child)\n if (!entry) return { message: \"\", placeholders: [], values: [], valid: false }\n placeholders.push(entry.name)\n values.push(entry)\n parts.push(`{${entry.name}}`)\n continue\n }\n\n if (child.type === \"Comment\") continue\n return { message: \"\", placeholders: [], values: [], valid: false }\n }\n\n const message = parts.join(\"\").replace(/\\s+/g, \" \").trim()\n return { message, placeholders, values, valid: message.length > 0 }\n}\n\nfunction getVarEntry(code: string, node: SvelteNode) {\n const explicitName = getStringAttribute(node.attributes, \"name\")\n const explicitValue = getExpressionAttributeSource(code, node.attributes, \"value\")\n if (explicitName && explicitValue) return { name: explicitName, value: explicitValue }\n if (explicitName) return { name: explicitName, value: JSON.stringify(explicitName) }\n\n const shorthandAttribute = getSingleExpressionAttribute(node.attributes)\n if (!shorthandAttribute) return undefined\n return {\n name: shorthandAttribute.name,\n value: code.slice(shorthandAttribute.expression.start!, shorthandAttribute.expression.end!),\n }\n}\n\nfunction getSingleExpressionAttribute(attributes?: SvelteNode[]) {\n const expressionAttributes = (attributes ?? []).flatMap((attribute) => {\n if (attribute.type !== \"Attribute\" || typeof attribute.name !== \"string\") return []\n const value = (attribute as SvelteAttribute).value\n return isExpressionAttributeValue(value) ? [{ name: attribute.name, expression: value.expression }] : []\n })\n\n return expressionAttributes.length === 1 ? expressionAttributes[0] : undefined\n}\n\nfunction getStringAttribute(attributes: SvelteNode[] | undefined, name: string) {\n const attribute = attributes?.find((entry) => entry.type === \"Attribute\" && entry.name === name) as SvelteAttribute | undefined\n if (!attribute) return undefined\n if (typeof attribute.value === \"string\") return attribute.value\n\n const value = Array.isArray(attribute.value) ? attribute.value[0] : attribute.value\n if (!value || value === true) return undefined\n if (value?.type === \"Text\") return String(value.data ?? value.raw ?? \"\")\n}\n\nfunction getExpressionAttributeSource(code: string, attributes: SvelteNode[] | undefined, name: string) {\n const attribute = attributes?.find((entry) => entry.type === \"Attribute\" && entry.name === name) as SvelteAttribute | undefined\n const value = attribute?.value\n if (!isExpressionAttributeValue(value)) return undefined\n return code.slice(value.expression.start!, value.expression.end!)\n}\n\nfunction hasAttribute(attributes: SvelteNode[] | undefined, name: string) {\n return attributes?.some((entry) => entry.type === \"Attribute\" && entry.name === name) ?? false\n}\n\nfunction getSvelteOpeningTagNameEnd(code: string, node: SvelteNode) {\n if (node.start === undefined || typeof node.name !== \"string\") return undefined\n const tagStart = code.indexOf(`<${node.name}`, node.start)\n if (tagStart < 0) return undefined\n return tagStart + node.name.length + 1\n}\n\nfunction isExpressionAttributeValue(value: SvelteAttribute[\"value\"]): value is SvelteNode & { expression: SvelteNode } {\n if (Array.isArray(value) || value === true || !value) return false\n return value.type === \"ExpressionTag\" && value.expression !== undefined\n}\n\nfunction isStringLiteral(node?: SvelteNode): node is SvelteNode & { value: string } {\n return node?.type === \"Literal\" && typeof node.value === \"string\"\n}\n\nfunction getCallMetaArgument(args: SvelteNode[]) {\n return getMetaArgument(isTranslateOptionsArgument(args[1]) ? args[1] : args[2])\n}\n\nfunction getMetaArgument(node?: SvelteNode) {\n if (!node) return undefined\n if (isStringLiteral(node)) return { context: node.value }\n if (node.type !== \"ObjectExpression\") return undefined\n\n const meta: TranslateOptions = {}\n for (const property of (node.properties as SvelteNode[] | undefined) ?? []) {\n const key = getPropertyKey(property)\n const value = property.value as SvelteNode | undefined\n if ((key === \"context\" || key === \"id\") && isStringLiteral(value)) meta[key] = value.value\n }\n\n return Object.keys(meta).length > 0 ? meta : undefined\n}\n\nfunction createCallOptionsEdit(code: string, args: SvelteNode[], id: string): SourceEdit | undefined {\n const valuesArg = args[1]\n const optionsArg = isTranslateOptionsArgument(valuesArg) ? valuesArg : args[2]\n\n if (!optionsArg) {\n return {\n start: (valuesArg ?? args[0])!.end!,\n end: (valuesArg ?? args[0])!.end!,\n replacement: `, { id: ${JSON.stringify(id)} }`,\n }\n }\n\n if (isStringLiteral(optionsArg)) {\n const contextValue = code.slice(optionsArg.start, optionsArg.end)\n return {\n start: optionsArg.start!,\n end: optionsArg.end!,\n replacement: `{ id: ${JSON.stringify(id)}, context: ${contextValue} }`,\n }\n }\n\n if (optionsArg.type !== \"ObjectExpression\") return undefined\n if (hasObjectProperty(optionsArg, \"id\")) return undefined\n\n const objectSource = code.slice(optionsArg.start, optionsArg.end)\n const innerSource = objectSource.slice(1, -1)\n const replacement =\n innerSource.trim().length > 0 ? `{ id: ${JSON.stringify(id)},${innerSource} }` : `{ id: ${JSON.stringify(id)} }`\n\n return {\n start: optionsArg.start!,\n end: optionsArg.end!,\n replacement,\n }\n}\n\nfunction isTranslateOptionsArgument(node?: SvelteNode) {\n if (!node) return false\n if (isStringLiteral(node)) return true\n if (node.type !== \"ObjectExpression\") return false\n\n return ((node.properties as SvelteNode[] | undefined) ?? []).every((property) => {\n const key = getPropertyKey(property)\n return key === \"context\" || key === \"id\"\n })\n}\n\nfunction getPropertyKey(property: SvelteNode) {\n const key = property.key as SvelteNode | undefined\n if (key?.type === \"Identifier\" && typeof key.name === \"string\") return key.name\n if (key?.type === \"Literal\" && typeof key.value === \"string\") return key.value\n}\n\nfunction hasObjectProperty(node: SvelteNode, name: string) {\n return ((node.properties as SvelteNode[] | undefined) ?? []).some((property) => getPropertyKey(property) === name)\n}\n\nfunction walkSvelte(node: unknown, visit: (node: SvelteNode) => void, seen = new Set<unknown>()) {\n if (!node || typeof node !== \"object\" || seen.has(node)) return\n seen.add(node)\n\n const current = node as SvelteNode\n visit(current)\n\n for (const value of Object.values(current)) {\n if (!value || typeof value !== \"object\") continue\n if (Array.isArray(value)) {\n for (const item of value) walkSvelte(item, visit, seen)\n continue\n }\n walkSvelte(value, visit, seen)\n }\n}\n","import type { Argument, JSXChild, StringLiteral } from \"oxc-parser\"\nimport { parseSync, Visitor } from \"oxc-parser\"\n\nimport type { ExtractedMessage, TranslateOptions } from \"../types.js\"\n\nimport { getCallMessageId, getMessageId } from \"../message-id.js\"\nimport {\n createSource,\n extractPlaceholdersFromMessage,\n type SourceAnalysis,\n type SourceEdit,\n type SourceMarkers,\n} from \"./types.js\"\n\n/** Extracts messages and source edits from a TypeScript, JavaScript, or JSX file in one coordinated parse pass. */\nexport function analyzeTypeScriptSourceFile(code: string, filename: string, markers: SourceMarkers): SourceAnalysis {\n const messages: ExtractedMessage[] = []\n const edits: SourceEdit[] = []\n const result = parseSync(filename, code)\n if (result.errors.length > 0) return { parsed: false, messages, edits }\n\n const visitor = new Visitor({\n CallExpression(node) {\n if (\n node.callee.type === \"Identifier\" &&\n markers.call.includes(node.callee.name) &&\n node.arguments.length >= 1 &&\n isStringLiteral(node.arguments[0]!)\n ) {\n const value = (node.arguments[0] as StringLiteral).value\n const meta = getCallMetaArgument(node.arguments)\n const id = getCallMessageId(value, meta)\n messages.push({\n id,\n defaultMessage: value,\n meta: meta ?? {},\n placeholders: extractPlaceholdersFromMessage(value),\n source: createSource({\n filename,\n marker: node.callee.name,\n kind: \"call\",\n }),\n })\n\n const callOptionsEdit = createCallOptionsEdit(code, node.arguments, id)\n if (callOptionsEdit) edits.push(callOptionsEdit)\n }\n },\n\n JSXElement(node) {\n const opening = node.openingElement\n if (\n opening.name.type === \"JSXIdentifier\" &&\n opening.name.name === \"Var\" &&\n (opening.attributes as Array<unknown>).length === 0\n ) {\n const identifier = getVarChildIdentifier(node.children)\n if (identifier) {\n edits.push({\n start: node.start,\n end: node.end,\n replacement: `<Var ${identifier}={${identifier}} />`,\n })\n }\n }\n\n if (opening.name.type !== \"JSXIdentifier\") return\n if (!markers.component.includes(opening.name.name)) return\n\n const extraction = extractJSXChildren(node.children)\n if (!extraction.valid) {\n if (markers.logging) {\n console.warn(`[better-translation] Non-static <${opening.name.name}> in ${filename}, skipping`)\n }\n return\n }\n\n const context = getJSXStringAttribute(opening.attributes, \"context\")\n const meta = context ? { context } : undefined\n const id = getJSXStringAttribute(opening.attributes, \"id\") ?? getMessageId(extraction.message, meta)\n messages.push({\n id,\n defaultMessage: extraction.message,\n meta: meta ?? {},\n placeholders: extraction.placeholders,\n source: createSource({\n filename,\n marker: opening.name.name,\n kind: \"component\",\n }),\n })\n\n if (!hasJSXAttribute(opening.attributes as Array<unknown>, \"id\")) {\n edits.push({\n start: opening.name.end,\n end: opening.name.end,\n replacement: ` id=\"${id}\"`,\n })\n }\n },\n })\n\n visitor.visit(result.program)\n return { parsed: true, messages, edits }\n}\n\nfunction isStringLiteral(node: Argument): node is StringLiteral {\n return node.type === \"Literal\" && typeof (node as StringLiteral).value === \"string\"\n}\n\nfunction getMetaArgument(node?: Argument) {\n if (!node) return undefined\n if (isStringLiteral(node)) return { context: node.value }\n\n if (node.type !== \"ObjectExpression\") return undefined\n\n const meta: TranslateOptions = {}\n\n for (const property of node.properties as Array<{\n type: string\n key?: { type: string; name?: string; value?: unknown }\n value?: Argument\n }>) {\n if (\n (property.type === \"ObjectProperty\" || property.type === \"Property\") &&\n ((property.key?.type === \"Identifier\" && (property.key.name === \"context\" || property.key.name === \"id\")) ||\n (property.key?.type === \"Literal\" && (property.key.value === \"context\" || property.key.value === \"id\"))) &&\n property.value &&\n isStringLiteral(property.value)\n ) {\n const key = property.key?.type === \"Identifier\" ? property.key.name : property.key?.value\n if (key === \"context\" || key === \"id\") meta[key] = property.value.value\n }\n }\n\n return Object.keys(meta).length > 0 ? meta : undefined\n}\n\nfunction getCallMetaArgument(args: Argument[]) {\n return getMetaArgument(isTranslateOptionsArgument(args[1]) ? args[1] : args[2])\n}\n\nfunction createCallOptionsEdit(code: string, args: Argument[], id: string) {\n const valuesArg = args[1]\n const optionsArg = isTranslateOptionsArgument(valuesArg) ? valuesArg : args[2]\n\n if (!optionsArg) {\n return {\n start: (valuesArg ?? args[0]!).end,\n end: (valuesArg ?? args[0]!).end,\n replacement: `, { id: ${JSON.stringify(id)} }`,\n }\n }\n\n if (isStringLiteral(optionsArg)) {\n const contextValue = code.slice(optionsArg.start, optionsArg.end)\n return {\n start: optionsArg.start,\n end: optionsArg.end,\n replacement: `{ id: ${JSON.stringify(id)}, context: ${contextValue} }`,\n }\n }\n\n if (optionsArg.type !== \"ObjectExpression\") return undefined\n if (hasObjectProperty(optionsArg, \"id\")) return undefined\n\n const objectSource = code.slice(optionsArg.start, optionsArg.end)\n const innerSource = objectSource.slice(1, -1)\n const replacement =\n innerSource.trim().length > 0 ? `{ id: ${JSON.stringify(id)},${innerSource} }` : `{ id: ${JSON.stringify(id)} }`\n\n return {\n start: optionsArg.start,\n end: optionsArg.end,\n replacement,\n }\n}\n\nfunction isTranslateOptionsArgument(node?: Argument) {\n if (!node) return false\n if (isStringLiteral(node)) return true\n if (node.type !== \"ObjectExpression\") return false\n\n return (node.properties as Array<unknown>).every((entry) => {\n const property = entry as\n | {\n type?: string\n key?: { type?: string; name?: string; value?: unknown }\n }\n | undefined\n\n if (property?.type !== \"ObjectProperty\" && property?.type !== \"Property\") return false\n\n return (\n (property.key?.type === \"Identifier\" && (property.key.name === \"context\" || property.key.name === \"id\")) ||\n (property.key?.type === \"Literal\" && (property.key.value === \"context\" || property.key.value === \"id\"))\n )\n })\n}\n\nfunction getJSXStringAttribute(attributes: Array<unknown>, name: string) {\n for (const attr of attributes as Array<{\n type: string\n name?: { type: string; name?: string }\n value?: { type: string; value?: unknown } | null\n }>) {\n if (\n attr.type === \"JSXAttribute\" &&\n attr.name?.type === \"JSXIdentifier\" &&\n attr.name.name === name &&\n attr.value?.type === \"Literal\" &&\n typeof attr.value.value === \"string\"\n ) {\n return attr.value.value as string\n }\n }\n}\n\nfunction hasJSXAttribute(attributes: Array<unknown>, name: string) {\n return attributes.some((attr) => {\n const attribute = attr as\n | {\n type?: string\n name?: { type?: string; name?: string }\n }\n | undefined\n\n return attribute?.type === \"JSXAttribute\" && attribute.name?.type === \"JSXIdentifier\" && attribute.name.name === name\n })\n}\n\nfunction hasObjectProperty(node: { properties: Array<unknown> }, name: string) {\n return node.properties.some((entry) => {\n const property = entry as\n | {\n type?: string\n key?: { type?: string; name?: string; value?: unknown }\n }\n | undefined\n\n if (property?.type !== \"ObjectProperty\" && property?.type !== \"Property\") return false\n return (\n (property.key?.type === \"Identifier\" && property.key.name === name) ||\n (property.key?.type === \"Literal\" && property.key.value === name)\n )\n })\n}\n\ninterface ExtractionResult {\n message: string\n placeholders: string[]\n valid: boolean\n}\n\nfunction extractJSXChildren(children: Array<JSXChild>): ExtractionResult {\n const parts: string[] = []\n const placeholders: string[] = []\n\n for (const child of children) {\n switch (child.type) {\n case \"JSXText\":\n parts.push(child.value)\n break\n\n case \"JSXElement\": {\n const name = child.openingElement.name\n if (name.type !== \"JSXIdentifier\" || name.name !== \"Var\") {\n return { message: \"\", placeholders: [], valid: false }\n }\n\n const varName = getVarPlaceholderName(child)\n if (!varName) return { message: \"\", placeholders: [], valid: false }\n\n placeholders.push(varName)\n parts.push(`{${varName}}`)\n break\n }\n\n case \"JSXExpressionContainer\":\n if (child.expression.type !== \"JSXEmptyExpression\") {\n return { message: \"\", placeholders: [], valid: false }\n }\n break\n\n default:\n break\n }\n }\n\n const message = parts.join(\"\").replace(/\\s+/g, \" \").trim()\n return { message, placeholders, valid: message.length > 0 }\n}\n\nfunction getVarPlaceholderName(node: { openingElement: { attributes: Array<unknown> }; children: Array<JSXChild> }) {\n const explicitName = getJSXStringAttribute(node.openingElement.attributes as Array<unknown>, \"name\")\n if (explicitName) return explicitName\n\n const customPropName = getSingleJSXAttributeName(node.openingElement.attributes as Array<unknown>)\n if (customPropName) return customPropName\n\n return getVarChildIdentifier(node.children)\n}\n\nfunction getSingleJSXAttributeName(attributes: Array<unknown>) {\n const keys = attributes.flatMap((attr) => {\n const attribute = attr as\n | {\n type?: string\n name?: { type?: string; name?: string }\n }\n | undefined\n\n if (attribute?.type !== \"JSXAttribute\" || attribute.name?.type !== \"JSXIdentifier\") return []\n return [attribute.name.name]\n })\n\n return keys.length === 1 ? keys[0] : undefined\n}\n\nfunction getVarChildIdentifier(children: Array<JSXChild>) {\n const meaningfulChildren = children.filter((child) => !(child.type === \"JSXText\" && child.value.trim().length === 0))\n if (meaningfulChildren.length !== 1) return undefined\n\n const [child] = meaningfulChildren\n if (!child || child.type !== \"JSXExpressionContainer\" || child.expression.type !== \"Identifier\") return undefined\n return child.expression.name\n}\n","import { extname } from \"node:path\"\n\nimport type { SourceAnalysis, SourceMarkers } from \"./extractors/types.js\"\n\nimport { analyzeSvelteSourceFile } from \"./extractors/svelte.js\"\nimport { analyzeTypeScriptSourceFile } from \"./extractors/typescript.js\"\n\nexport type { SourceAnalysis, SourceEdit } from \"./extractors/types.js\"\n\n/** Extracts messages and source edits from a framework source file. */\nexport function analyzeSourceFile(code: string, filename: string, markers: SourceMarkers): SourceAnalysis {\n if (extname(filename) === \".svelte\") return analyzeSvelteSourceFile(code, filename, markers)\n return analyzeTypeScriptSourceFile(code, filename, markers)\n}\n","import { execFileSync } from \"node:child_process\"\nimport { readFileSync } from \"node:fs\"\nimport type { IncomingMessage, ServerResponse } from \"node:http\"\nimport type { ViteDevServer } from \"vite\"\n\nimport type { BetterTranslateRuntimeOptions, ManifestEntry, MessageManifest, RuntimeMessages } from \"../types.js\"\n\nexport const DEFAULT_LOCAL_EDITOR_PATH = \"/__better-translation\"\n\nconst CYAN = \"\\x1b[36m\"\nconst PREFIX = \"\\x1b[36m[better-translation]\\x1b[0m\"\nconst RESET = \"\\x1b[0m\"\n\ntype LocalEditorOptions = {\n open: boolean\n path: string\n}\n\nexport type LocalEditorRuntimeContext = {\n defaultLocale: string\n isUntranslatedLocaleValue: (value: string, entry: Pick<ManifestEntry, \"defaultMessage\">) => boolean\n locales: string[]\n log: (message: string) => void\n manifest: MessageManifest\n readLocaleMessages: (locale: string) => RuntimeMessages\n writeLocaleMessages: (locale: string, localeMessages: RuntimeMessages) => void\n}\n\nexport function getLocalEditorOptions({\n isDev,\n runtime,\n}: {\n isDev: boolean\n runtime: BetterTranslateRuntimeOptions\n}): LocalEditorOptions | null {\n if (!isDev || runtime.type !== \"local\") return null\n const editor = runtime.editor\n if (!editor) return null\n if (editor === true) return { path: DEFAULT_LOCAL_EDITOR_PATH, open: false }\n if (editor.enabled === false) return null\n return {\n path: normalizeLocalEditorPath(editor.path ?? DEFAULT_LOCAL_EDITOR_PATH),\n open: editor.open ?? false,\n }\n}\n\nexport function configureLocalEditor(server: ViteDevServer, context: LocalEditorRuntimeContext, options: LocalEditorOptions) {\n const editorPath = options.path\n server.middlewares.use(async (request, response, next) => {\n const requestUrl = new URL(request.url ?? \"/\", \"http://better-translation.local\")\n const pathname = stripTrailingSlash(requestUrl.pathname)\n if (pathname !== editorPath && !pathname.startsWith(`${editorPath}/`)) {\n next()\n return\n }\n\n try {\n if (pathname === editorPath || pathname === `${editorPath}/index.html`) {\n sendHtml(response, createLocalEditorHtml(editorPath))\n return\n }\n\n if (pathname === `${editorPath}/client.js`) {\n sendJavaScript(response, readLocalEditorAsset(\"local-editor.js\"))\n return\n }\n\n if (pathname === `${editorPath}/style.css`) {\n sendCss(response, readLocalEditorAsset(\"style.css\"))\n return\n }\n\n if (pathname.startsWith(`${editorPath}/local-editor-assets/`)) {\n const assetName = pathname.slice(`${editorPath}/local-editor-assets/`.length)\n sendAsset(response, assetName)\n return\n }\n\n if (pathname === `${editorPath}/api/messages` && request.method === \"GET\") {\n sendJson(\n response,\n getLocalEditorMessages(context, {\n q: requestUrl.searchParams.get(\"q\") ?? undefined,\n view: parseLocalEditorView(requestUrl.searchParams.get(\"view\")),\n }),\n )\n return\n }\n\n const detailMatch = pathname.match(new RegExp(`^${escapeRegExp(editorPath)}/api/messages/([^/]+)$`))\n if (detailMatch?.[1] && request.method === \"GET\") {\n sendJson(response, getLocalEditorMessageDetail(context, decodeURIComponent(detailMatch[1])))\n return\n }\n\n const updateMatch = pathname.match(new RegExp(`^${escapeRegExp(editorPath)}/api/messages/([^/]+)/locales/([^/]+)$`))\n if (updateMatch?.[1] && updateMatch[2] && request.method === \"PATCH\") {\n const body = await readJsonRequest(request)\n const value =\n typeof body === \"object\" && body !== null && \"value\" in body && typeof body.value === \"string\" ? body.value.trim() : \"\"\n if (!value) {\n sendJson(response, { error: \"Locale value is required.\" }, 400)\n return\n }\n updateLocalEditorLocaleValue(context, {\n locale: decodeURIComponent(updateMatch[2]),\n lookupId: decodeURIComponent(updateMatch[1]),\n value,\n })\n sendJson(response, getLocalEditorMessageDetail(context, decodeURIComponent(updateMatch[1])))\n return\n }\n\n sendJson(response, { error: \"Not found.\" }, 404)\n } catch (error) {\n sendJson(response, { error: error instanceof Error ? error.message : \"Local editor request failed.\" }, 500)\n }\n })\n\n server.httpServer?.once(\"listening\", () => {\n const localUrl = server.resolvedUrls?.local[0]\n const editorUrl = localUrl ? new URL(editorPath, localUrl).toString() : editorPath\n context.log(`${PREFIX} Local editor: ${CYAN}${editorUrl}${RESET}`)\n if (options.open) openLocalEditor(editorUrl)\n })\n}\n\nfunction getLocalEditorMessages(\n context: LocalEditorRuntimeContext,\n { q, view }: { q?: string; view: \"all\" | \"needs-value\" | \"manual\" | \"ai\" },\n) {\n const query = q?.trim().toLowerCase()\n const localeMessagesByLocale = readEditableLocaleMessages(context)\n const summaries = Object.entries(context.manifest)\n .sort(compareManifestEntryIds)\n .map(([id, entry]) => getLocalEditorMessageSummary(context, localeMessagesByLocale, id, entry))\n const filteredMessages = summaries.filter((message) => {\n if (query) {\n const searchableValues = [\n message.defaultMessage,\n ...Object.values(localeMessagesByLocale).map((localeMessages) => localeMessages[message.id] ?? \"\"),\n ]\n if (!searchableValues.some((value) => value.toLowerCase().includes(query))) return false\n }\n if (view === \"all\") return true\n if (view === \"needs-value\") return message.done < message.total\n if (view === \"ai\") return false\n return Object.values(localeMessagesByLocale).some((localeMessages) => localeMessages[message.id] !== undefined)\n })\n\n return {\n config: {\n appLocale: context.defaultLocale,\n defaultLocale: context.defaultLocale,\n locales: context.locales,\n },\n incompleteCount: summaries.filter((message) => message.done < message.total).length,\n messages: filteredMessages.map(({ defaultMessage, done, id, lookupId, placeholders, total }) => ({\n defaultMessage,\n done,\n id,\n lookupId,\n placeholders,\n total,\n })),\n }\n}\n\nfunction readEditableLocaleMessages(context: LocalEditorRuntimeContext) {\n return Object.fromEntries(\n context.locales\n .filter((locale) => locale !== context.defaultLocale)\n .map((locale) => [locale, context.readLocaleMessages(locale)]),\n )\n}\n\nfunction getLocalEditorMessageSummary(\n context: LocalEditorRuntimeContext,\n localeMessagesByLocale: Record<string, RuntimeMessages>,\n id: string,\n entry: ManifestEntry,\n) {\n const editableLocales = context.locales.filter((locale) => locale !== context.defaultLocale)\n\n return {\n defaultMessage: entry.defaultMessage,\n done: editableLocales.filter((locale) => localeMessagesByLocale[locale]?.[id] !== undefined).length,\n id,\n lookupId: id,\n placeholders: entry.placeholders,\n total: editableLocales.length,\n }\n}\n\nfunction getLocalEditorMessageDetail(context: LocalEditorRuntimeContext, id: string) {\n const entry = context.manifest[id]\n if (!entry) throw new Error(\"Unknown Message.\")\n const localeValues = Object.fromEntries(\n context.locales.map((locale) => {\n if (locale === context.defaultLocale) {\n return [locale, { value: entry.defaultMessage, source: \"default\", hasValue: true }]\n }\n\n const localeMessages = context.readLocaleMessages(locale)\n const value = localeMessages[id]\n const hasValue = value !== undefined\n return [locale, { value: value ?? entry.defaultMessage, source: hasValue ? \"manual\" : \"default\", hasValue }]\n }),\n )\n const editableValues = Object.entries(localeValues).filter(([locale]) => locale !== context.defaultLocale)\n\n return {\n context: typeof entry.meta.context === \"string\" ? entry.meta.context : null,\n defaultMessage: entry.defaultMessage,\n done: editableValues.filter(([, value]) => value.hasValue).length,\n id,\n localeValues,\n lookupId: id,\n placeholders: entry.placeholders,\n sources: entry.sources,\n total: editableValues.length,\n }\n}\n\nfunction updateLocalEditorLocaleValue(\n context: LocalEditorRuntimeContext,\n { locale, lookupId, value }: { locale: string; lookupId: string; value: string },\n) {\n if (locale === context.defaultLocale) throw new Error(\"Default locale Messages come from source code.\")\n if (!context.locales.includes(locale)) throw new Error(\"Unknown Locale.\")\n if (!context.manifest[lookupId]) throw new Error(\"Unknown Message.\")\n\n const localeMessages = context.readLocaleMessages(locale)\n localeMessages[lookupId] = value\n context.writeLocaleMessages(locale, localeMessages)\n}\n\nfunction createLocalEditorHtml(editorPath: string) {\n return [\n \"<!doctype html>\",\n '<html lang=\"en\">',\n \"<head>\",\n '<meta charset=\"utf-8\" />',\n '<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />',\n \"<title>Better Translation Local Editor</title>\",\n \"</head>\",\n \"<body>\",\n '<div id=\"root\"></div>',\n `<link rel=\"stylesheet\" href=\"${editorPath}/style.css\" />`,\n `<script defer src=\"${editorPath}/client.js\"></script>`,\n \"</body>\",\n \"</html>\",\n ].join(\"\\n\")\n}\n\nfunction sendHtml(response: ServerResponse, html: string) {\n response.statusCode = 200\n response.setHeader(\"content-type\", \"text/html; charset=utf-8\")\n response.end(html)\n}\n\nfunction sendJavaScript(response: ServerResponse, code: string) {\n response.statusCode = 200\n response.setHeader(\"content-type\", \"application/javascript; charset=utf-8\")\n response.end(code)\n}\n\nfunction sendCss(response: ServerResponse, css: string) {\n response.statusCode = 200\n response.setHeader(\"content-type\", \"text/css; charset=utf-8\")\n response.end(css)\n}\n\nfunction sendAsset(response: ServerResponse, assetName: string) {\n if (!/^[\\w.-]+$/.test(assetName)) {\n sendJson(response, { error: \"Not found.\" }, 404)\n return\n }\n\n response.statusCode = 200\n response.setHeader(\"content-type\", getAssetContentType(assetName))\n response.end(readFileSync(new URL(`./local-editor-assets/${assetName}`, import.meta.url)))\n}\n\nfunction sendJson(response: ServerResponse, payload: unknown, statusCode = 200) {\n response.statusCode = statusCode\n response.setHeader(\"content-type\", \"application/json; charset=utf-8\")\n response.end(JSON.stringify(payload))\n}\n\nasync function readJsonRequest(request: IncomingMessage) {\n const chunks: Buffer[] = []\n for await (const chunk of request) {\n chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk))\n }\n if (chunks.length === 0) return null\n return JSON.parse(Buffer.concat(chunks).toString(\"utf-8\")) as unknown\n}\n\nfunction parseLocalEditorView(value: string | null): \"all\" | \"needs-value\" | \"manual\" | \"ai\" {\n if (value === \"needs-value\" || value === \"manual\" || value === \"ai\") return value\n return \"all\"\n}\n\nfunction normalizeLocalEditorPath(path: string) {\n const withLeadingSlash = path.startsWith(\"/\") ? path : `/${path}`\n return stripTrailingSlash(withLeadingSlash)\n}\n\nfunction stripTrailingSlash(path: string) {\n return path.length > 1 ? path.replace(/\\/+$/, \"\") : path\n}\n\nfunction escapeRegExp(value: string) {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\")\n}\n\nfunction openLocalEditor(url: string) {\n try {\n if (process.platform === \"darwin\") execFileSync(\"open\", [url], { stdio: \"ignore\" })\n else if (process.platform === \"win32\") execFileSync(\"cmd\", [\"/c\", \"start\", \"\", url], { stdio: \"ignore\" })\n else execFileSync(\"xdg-open\", [url], { stdio: \"ignore\" })\n } catch {\n // Opening the browser is a convenience only.\n }\n}\n\nfunction readLocalEditorAsset(fileName: \"local-editor.js\" | \"style.css\") {\n return readFileSync(new URL(`./${fileName}`, import.meta.url), \"utf-8\")\n}\n\nfunction getAssetContentType(assetName: string) {\n if (assetName.endsWith(\".woff2\")) return \"font/woff2\"\n if (assetName.endsWith(\".woff\")) return \"font/woff\"\n if (assetName.endsWith(\".css\")) return \"text/css; charset=utf-8\"\n if (assetName.endsWith(\".js\")) return \"application/javascript; charset=utf-8\"\n if (assetName.endsWith(\".svg\")) return \"image/svg+xml\"\n return \"application/octet-stream\"\n}\n\nfunction compareManifestEntryIds([left]: [string, ManifestEntry], [right]: [string, ManifestEntry]) {\n return left.localeCompare(right)\n}\n","import { execFileSync } from \"node:child_process\"\nimport { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from \"node:fs\"\nimport { dirname, relative, resolve } from \"node:path\"\nimport { normalizePath, type Plugin, type ResolvedConfig } from \"vite\"\n\nimport type {\n BetterTranslatePluginOptions,\n BetterTranslateRuntimeOptions,\n ExtractedMessage,\n ManifestEntry,\n MessageManifest,\n MessageManifestFile,\n MessageSource,\n RuntimeMessages,\n TranslateFn,\n TranslateMessage,\n TranslationCache,\n} from \"./types.js\"\n\nimport { createEmptyCache, getCacheKey, loadCache, saveCache } from \"./cache.js\"\nimport { analyzeSourceFile } from \"./extractor.js\"\nimport { configureLocalEditor, getLocalEditorOptions } from \"./local-editor/server.js\"\nimport { serializeMeta } from \"./message-id.js\"\n\nconst PREFIX = \"\\x1b[36m[better-translation]\\x1b[0m\"\nconst DIM = \"\\x1b[2m\"\nconst RESET = \"\\x1b[0m\"\nconst BOLD = \"\\x1b[1m\"\nconst CYAN = \"\\x1b[36m\"\nconst REMOTE_API_BASE_URL = \"https://better-translation.vercel.app\"\nconst DEFAULT_REMOTE_API_KEY_ENV = \"BETTER_TRANSLATION_API_KEY\"\nconst DEFAULT_REMOTE_BRANCH = \"main\"\nconst DEFAULT_CACHE_DIR = \".cache/better-translation\"\nconst DEFAULT_TRANSLATION_CACHE_FILE = `${DEFAULT_CACHE_DIR}/cache.json`\nconst DEFAULT_PRIVATE_MANIFEST_FILE = `${DEFAULT_CACHE_DIR}/manifest.json`\nconst DEFAULT_REMOTE_OFFLINE_OUTPUT_DIR = `${DEFAULT_CACHE_DIR}/runtime`\nconst DEFAULT_LOCAL_OUTPUT_DIR = \"src/lib/bt\"\nconst DEFAULT_PUBLIC_OUTPUT_SUBDIR = \"bt\"\nconst DEFAULT_PUBLIC_BASE_PATH = \"/bt\"\nconst DEFAULT_ROOT_DIR = \"src\"\nconst DEFAULT_SCAN_EXTENSIONS = [\".ts\", \".tsx\", \".js\", \".jsx\", \".svelte\"]\nconst VIRTUAL_MESSAGES_MODULE_ID = \"better-translation/messages\"\nconst RESOLVED_VIRTUAL_MESSAGES_MODULE_ID = `\\0${VIRTUAL_MESSAGES_MODULE_ID}`\nconst CALL_MARKERS = [\"t\", \"useT\"]\nconst COMPONENT_MARKERS = [\"T\"]\nconst LOCALES_SUBDIR = \"locales\"\n\ninterface SyncResult {\n manifestChanged: boolean\n localeMessagesChanged: boolean\n}\n\nfunction formatLocale(locale: string) {\n return locale.toUpperCase()\n}\n\nfunction formatLocales(locales: string[]) {\n return locales.map(formatLocale).join(\", \")\n}\n\n/** Scans source files for translatable messages and keeps locale JSON files in sync. */\nexport function betterTranslation(options: BetterTranslatePluginOptions): Plugin {\n const {\n locales,\n defaultLocale = locales[0] ?? \"en\",\n rootDir = DEFAULT_ROOT_DIR,\n cacheFile = DEFAULT_TRANSLATION_CACHE_FILE,\n logging = true,\n runtime,\n } = options\n const configuredRuntime = normalizeRuntimeOptions(runtime)\n const manifest: MessageManifest = {}\n const fileMessages = new Map<string, ExtractedMessage[]>()\n let cache: TranslationCache = createEmptyCache()\n let resolvedRuntime = configuredRuntime\n let usesLocalStorage = shouldUseLocalStorage(configuredRuntime, false)\n let resolvedTranslate: TranslateFn | undefined = configuredRuntime.type === \"local\" ? configuredRuntime.translate : undefined\n let localesDir =\n configuredRuntime.type === \"local\" ? (configuredRuntime.output ?? DEFAULT_LOCAL_OUTPUT_DIR) : DEFAULT_LOCAL_OUTPUT_DIR\n let publicBasePath =\n configuredRuntime.type === \"local\" && configuredRuntime.target === \"public\"\n ? (configuredRuntime.basePath ?? DEFAULT_PUBLIC_BASE_PATH)\n : DEFAULT_PUBLIC_BASE_PATH\n let remoteUrl = configuredRuntime.type === \"remote\" ? (configuredRuntime.endpoint ?? REMOTE_API_BASE_URL) : REMOTE_API_BASE_URL\n let root = \"\"\n let isDev = false\n let translateTimer: ReturnType<typeof setTimeout> | null = null\n let remoteSyncTimer: ReturnType<typeof setTimeout> | null = null\n let lastSyncedRemoteManifestSignature: string | null = null\n let sourceRoots: string[] = []\n\n function log(message: string) {\n if (logging) console.log(message)\n }\n\n async function syncRemote() {\n if (resolvedRuntime.type !== \"remote\") return\n\n const payload = {\n defaultLocale,\n locales,\n messages: buildMessageManifest(),\n }\n const signature = JSON.stringify(payload)\n if (lastSyncedRemoteManifestSignature === signature) return\n\n const apiKey = resolveRemoteSyncApiKey()\n const target = formatRemoteManifestTarget(resolvedRuntime, remoteUrl)\n if (!apiKey) {\n throw new Error(\n [\n `${PREFIX} remote Manifest sync requires a Project API key`,\n `set ${DEFAULT_REMOTE_API_KEY_ENV} or pass runtime.apiKey in the Vite plugin config`,\n `target: ${target}`,\n ].join(\"\\n\"),\n )\n }\n\n let response: Response\n try {\n response = await fetch(target, {\n method: \"POST\",\n headers: {\n authorization: `Bearer ${apiKey}`,\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify(payload),\n })\n } catch (error) {\n throw new Error(formatRemoteSyncNetworkError(target, error))\n }\n\n const body = await response.text()\n\n if (!response.ok) {\n throw new Error(formatRemoteSyncError(response, target, body))\n }\n\n const result = parseRemoteSyncResult(body)\n if (result?.changed) log(`${PREFIX} ${BOLD}Synced${RESET} Messages -> ${CYAN}${formatRuntime(resolvedRuntime)}${RESET}`)\n lastSyncedRemoteManifestSignature = signature\n }\n\n function resolveRemoteSyncApiKey() {\n const explicitApiKey = resolvedRuntime.type === \"remote\" ? resolvedRuntime.apiKey?.trim() : null\n if (explicitApiKey) return explicitApiKey\n\n const envApiKey = process.env[DEFAULT_REMOTE_API_KEY_ENV]?.trim()\n return envApiKey || null\n }\n\n function buildMessageManifest(): MessageManifestFile {\n return Object.fromEntries(\n Object.entries(manifest)\n .sort(compareManifestEntryIds)\n .map(([id, entry]) => [\n id,\n {\n defaultMessage: entry.defaultMessage,\n meta: entry.meta,\n placeholders: entry.placeholders,\n sources: entry.sources.length > 1 ? [...entry.sources].sort(compareMessageSources) : entry.sources,\n },\n ]),\n )\n }\n\n function shouldScanFile(id: string) {\n const cleanId = id.split(\"?\", 1)[0] ?? id\n if (cleanId.includes(\"node_modules\")) return false\n const extension = DEFAULT_SCAN_EXTENSIONS.find((ext) => cleanId.endsWith(ext))\n if (!extension) return false\n return sourceRoots.some(\n (sourceRoot) => cleanId === sourceRoot || cleanId.startsWith(`${sourceRoot}/`) || cleanId.startsWith(`${sourceRoot}\\\\`),\n )\n }\n\n function getPrivateManifestPath() {\n return resolve(root, DEFAULT_PRIVATE_MANIFEST_FILE)\n }\n\n function getLocalesDirPath() {\n return resolve(root, localesDir, LOCALES_SUBDIR)\n }\n\n function getLocalePath(locale: string) {\n return resolve(getLocalesDirPath(), `${locale}.json`)\n }\n\n function readLocaleMessages(locale: string): RuntimeMessages {\n const path = getLocalePath(locale)\n if (!existsSync(path)) return {}\n\n try {\n const input = JSON.parse(readFileSync(path, \"utf-8\")) as unknown\n return normalizeLocaleMessages(input)\n } catch {\n return {}\n }\n }\n\n function writePrivateManifest() {\n if (!usesLocalStorage) return\n const path = getPrivateManifestPath()\n const dir = dirname(path)\n if (!existsSync(dir)) mkdirSync(dir, { recursive: true })\n writeFileIfChanged(path, JSON.stringify(buildMessageManifest(), null, 2) + \"\\n\")\n }\n\n function buildLocalLocaleMessages(locale: string, manifestEntries: Array<[string, ManifestEntry]>): RuntimeMessages {\n const existingMessages = readLocaleMessages(locale)\n const messages: RuntimeMessages = {}\n\n if (locale === defaultLocale) {\n for (const [id, entry] of manifestEntries) {\n messages[id] = entry.defaultMessage\n }\n return messages\n }\n\n for (const [id, entry] of manifestEntries) {\n if (Object.hasOwn(messages, id)) continue\n const existingMessage = existingMessages[id]\n const cachedMessage = getFreshCachedMessage(id, locale)\n\n if (existingMessage !== undefined && !isUntranslatedLocaleValue(existingMessage, entry)) {\n messages[id] = existingMessage\n continue\n }\n\n if (cachedMessage !== undefined) messages[id] = cachedMessage\n else if (shouldWriteDefaultLocaleFallback()) messages[id] = entry.defaultMessage\n }\n return messages\n }\n\n function writeLocaleFilesToDisk() {\n if (!usesLocalStorage) return\n const dir = getLocalesDirPath()\n if (!existsSync(dir)) mkdirSync(dir, { recursive: true })\n const manifestEntries = Object.entries(manifest).sort(compareManifestEntryIds)\n for (const locale of locales) {\n writeFileIfChanged(\n resolve(dir, `${locale}.json`),\n JSON.stringify(buildLocalLocaleMessages(locale, manifestEntries), null, 2) + \"\\n\",\n )\n }\n }\n\n function getMissingMessagesByLocale() {\n const missingByLocale = new Map<string, TranslateMessage[]>()\n const manifestEntries = Object.entries(manifest).sort(compareManifestEntryIds)\n\n for (const locale of locales) {\n if (locale === defaultLocale) continue\n const existingMessages = readLocaleMessages(locale)\n for (const [id, entry] of manifestEntries) {\n const existingMessage = existingMessages[id]\n const hasExistingMessage = existingMessage !== undefined && !isUntranslatedLocaleValue(existingMessage, entry)\n if (!hasExistingMessage && getFreshCachedMessage(id, locale) === undefined) {\n const misses = missingByLocale.get(locale) ?? []\n misses.push({\n id,\n text: entry.defaultMessage,\n meta: entry.meta,\n placeholders: entry.placeholders,\n sources: entry.sources,\n })\n missingByLocale.set(locale, misses)\n }\n }\n }\n\n return missingByLocale\n }\n\n function assertLocalBuildTranslationsComplete() {\n const expectedIds = new Set(Object.keys(manifest))\n const issues: string[] = []\n\n for (const locale of locales) {\n const localePath = getLocalePath(locale)\n if (!existsSync(localePath)) {\n issues.push(`- ${locale}: missing file at ${relative(root, localePath)}`)\n continue\n }\n\n const localeMessages = readLocaleMessages(locale)\n const missingIds = [...expectedIds].filter((id) => !Object.hasOwn(localeMessages, id))\n const orphanIds = Object.keys(localeMessages).filter((id) => !expectedIds.has(id))\n\n if (locale === defaultLocale) {\n const staleIds = [...expectedIds].filter((id) => localeMessages[id] !== manifest[id]!.defaultMessage)\n if (missingIds.length > 0) issues.push(formatLocaleIssue(locale, \"missing\", missingIds))\n if (orphanIds.length > 0) issues.push(formatLocaleIssue(locale, \"orphaned\", orphanIds))\n if (staleIds.length > 0) issues.push(formatLocaleIssue(locale, \"outdated default messages\", staleIds))\n continue\n }\n\n if (missingIds.length > 0) issues.push(formatLocaleIssue(locale, \"missing\", missingIds))\n if (orphanIds.length > 0) issues.push(formatLocaleIssue(locale, \"orphaned\", orphanIds))\n }\n\n if (issues.length === 0) return\n\n throw new Error(\n [\n `${PREFIX} committed locale artifacts are out of sync for local production build`,\n `local production builds are check-only and never regenerate locale files`,\n `run the dev workflow to regenerate locale artifacts and commit the result`,\n ...issues,\n ].join(\"\\n\"),\n )\n }\n\n async function translateMissingMessages() {\n if (!resolvedTranslate) return false\n const missingByLocale = getMissingMessagesByLocale()\n\n const totalMisses = [...missingByLocale.values()].reduce((count, misses) => count + misses.length, 0)\n if (totalMisses === 0) return false\n\n const missLocales = [...missingByLocale.keys()]\n log(\n `${PREFIX} ${BOLD}Translating${RESET} ${CYAN}${totalMisses}${RESET} ${totalMisses === 1 ? \"Message\" : \"Messages\"} -> ${CYAN}${formatLocales(missLocales)}${RESET}`,\n )\n\n let translatedCount = 0\n for (const [locale, misses] of missingByLocale) {\n const result = await resolvedTranslate(misses, locale)\n\n for (const miss of misses) {\n const translated = result[miss.id]?.trim()\n if (!translated) continue\n cache.entries[getCacheKey(miss.id, locale)] = {\n sourceText: miss.text,\n meta: miss.meta,\n locale,\n translation: translated,\n timestamp: Date.now(),\n }\n translatedCount += 1\n }\n }\n\n log(\n `${PREFIX} ${BOLD}Translated${RESET} ${CYAN}${translatedCount}${RESET}/${CYAN}${totalMisses}${RESET} ${totalMisses === 1 ? \"Message\" : \"Messages\"} -> ${CYAN}${formatLocales(missLocales)}${RESET}`,\n )\n\n return true\n }\n\n function getFreshCachedMessage(id: string, locale: string) {\n const entry = manifest[id]\n const cachedMessage = cache.entries[getCacheKey(id, locale)]\n if (!entry || !cachedMessage) return undefined\n if (cachedMessage.sourceText !== entry.defaultMessage) return undefined\n if (serializeMeta(cachedMessage.meta) !== serializeMeta(entry.meta)) return undefined\n return cachedMessage.translation\n }\n\n function isUntranslatedLocaleValue(value: string, entry: Pick<ManifestEntry, \"defaultMessage\">) {\n return resolvedTranslate !== undefined && value.trim() === entry.defaultMessage.trim()\n }\n\n function shouldWriteDefaultLocaleFallback() {\n return resolvedTranslate !== undefined || isRemoteOfflineDev(resolvedRuntime, isDev)\n }\n\n function scheduleDevTranslation() {\n if (!resolvedTranslate) return\n if (!isDev) return\n if (translateTimer) clearTimeout(translateTimer)\n translateTimer = setTimeout(async () => {\n const translated = await translateMissingMessages()\n if (translated) saveCache(resolve(root, cacheFile), cache)\n writeLocaleFilesToDisk()\n writePrivateManifest()\n }, 1000)\n }\n\n function scheduleDevRemoteSync() {\n if (usesLocalStorage || !isDev) return\n if (remoteSyncTimer) clearTimeout(remoteSyncTimer)\n remoteSyncTimer = setTimeout(() => {\n void syncRemote().catch((error) => console.error(error instanceof Error ? error.message : error))\n }, 1000)\n }\n\n function writeLocaleMessages(locale: string, localeMessages: RuntimeMessages) {\n const dir = getLocalesDirPath()\n if (!existsSync(dir)) mkdirSync(dir, { recursive: true })\n\n const messages: RuntimeMessages = {}\n for (const [id, entry] of Object.entries(manifest).sort(compareManifestEntryIds)) {\n if (locale === defaultLocale) {\n messages[id] = entry.defaultMessage\n continue\n }\n\n const existingMessage = localeMessages[id]\n const cachedMessage = getFreshCachedMessage(id, locale)\n if (existingMessage !== undefined) messages[id] = existingMessage\n else if (cachedMessage !== undefined) messages[id] = cachedMessage\n else if (shouldWriteDefaultLocaleFallback()) messages[id] = entry.defaultMessage\n }\n\n writeFileIfChanged(getLocalePath(locale), JSON.stringify(messages, null, 2) + \"\\n\")\n }\n\n function removeFileMessages(file: string) {\n const previous = fileMessages.get(file)\n if (!previous) return false\n\n for (const message of previous) {\n const entry = manifest[message.id]\n if (!entry) continue\n entry.sources = entry.sources.filter((source) => !isSameSource(source, message.source))\n if (entry.sources.length === 0) delete manifest[message.id]\n }\n\n fileMessages.delete(file)\n return true\n }\n\n function syncFileMessages(file: string, messages: ExtractedMessage[]): SyncResult {\n const previousMessages = fileMessages.get(file) ?? []\n const nextEntries = groupMessagesById(messages)\n for (const [id, entry] of Object.entries(nextEntries)) {\n const existing = manifest[id]\n if (existing && !hasSameMessageShape(existing, entry)) {\n throw new Error(formatCollisionError(id, existing, entry))\n }\n }\n\n removeFileMessages(file)\n for (const [id, entry] of Object.entries(nextEntries)) {\n if (!manifest[id]) {\n manifest[id] = entry\n continue\n }\n for (const source of entry.sources) {\n if (!manifest[id]!.sources.some((existingSource) => isSameSource(existingSource, source))) {\n manifest[id]!.sources.push(source)\n }\n }\n }\n\n if (messages.length > 0) fileMessages.set(file, messages)\n return {\n manifestChanged:\n previousMessages.length !== messages.length ||\n previousMessages.some((message, index) => !isSameExtractedMessage(message, messages[index])),\n localeMessagesChanged:\n previousMessages.length !== messages.length ||\n previousMessages.some((message, index) => !hasSameMessageShape(message, messages[index]!)),\n }\n }\n\n function syncSourceCode(file: string, code: string) {\n const analysis = analyzeSourceFile(code, file, {\n call: CALL_MARKERS,\n component: COMPONENT_MARKERS,\n logging,\n })\n if (!analysis.parsed) return null\n return syncFileMessages(\n file,\n analysis.messages.map((message) => ({\n ...message,\n source: {\n ...message.source,\n file: toRootRelativePath(message.source.file),\n },\n })),\n )\n }\n\n function removeTrackedFile(file: string): SyncResult {\n const hadPreviousMessages = removeFileMessages(file)\n return {\n manifestChanged: hadPreviousMessages,\n localeMessagesChanged: hadPreviousMessages,\n }\n }\n\n function applySyncResult(syncResult: SyncResult | null, options: { scheduleTranslation: boolean }) {\n if (!syncResult) return\n if (syncResult.localeMessagesChanged) {\n writeLocaleFilesToDisk()\n writePrivateManifest()\n if (options.scheduleTranslation) scheduleDevTranslation()\n return\n }\n if (syncResult.manifestChanged) writePrivateManifest()\n }\n\n function scanAllSourceFiles() {\n for (const id of Object.keys(manifest)) delete manifest[id]\n fileMessages.clear()\n\n for (const sourceRoot of sourceRoots) {\n if (!existsSync(sourceRoot)) continue\n for (const file of collectScanFiles(sourceRoot).sort()) {\n const code = readFileSync(file, \"utf-8\")\n syncSourceCode(file, code)\n }\n }\n }\n\n function toRootRelativePath(file: string) {\n return relative(root, file).replaceAll(\"\\\\\", \"/\")\n }\n\n function createVirtualMessagesModule() {\n if (isRemoteOfflineDev(resolvedRuntime, isDev)) {\n return createModuleMessagesModule(locales, (locale) => `/${normalizePath(toRootRelativePath(getLocalePath(locale)))}`)\n }\n if (resolvedRuntime.type === \"remote\") return createRemoteMessagesModule(resolvedRuntime, locales, remoteUrl)\n if (resolvedRuntime.target === \"public\") return createPublicMessagesModule(locales, publicBasePath)\n return createModuleMessagesModule(locales, (locale) => `/${normalizePath(toRootRelativePath(getLocalePath(locale)))}`)\n }\n\n return {\n name: \"better-translation-extract\",\n enforce: \"pre\",\n\n config() {\n return {\n ssr: {\n noExternal: [\"better-translation\"],\n },\n }\n },\n\n configResolved(config) {\n root = config.root\n isDev = config.command === \"serve\"\n resolvedRuntime = resolveRuntimeOptions(configuredRuntime, config)\n usesLocalStorage = shouldUseLocalStorage(resolvedRuntime, isDev)\n resolvedTranslate = resolvedRuntime.type === \"local\" ? resolvedRuntime.translate : undefined\n localesDir = getRuntimeOutputDir(resolvedRuntime, isDev)\n publicBasePath =\n resolvedRuntime.type === \"local\" && resolvedRuntime.target === \"public\"\n ? (resolvedRuntime.basePath ?? DEFAULT_PUBLIC_BASE_PATH)\n : DEFAULT_PUBLIC_BASE_PATH\n remoteUrl = resolvedRuntime.type === \"remote\" ? (resolvedRuntime.endpoint ?? REMOTE_API_BASE_URL) : REMOTE_API_BASE_URL\n sourceRoots = (Array.isArray(rootDir) ? rootDir : [rootDir]).map((dir) => resolve(root, dir))\n log(\n `${PREFIX} Locales: ${CYAN}${formatLocales(locales)}${RESET} | Default: ${CYAN}${formatLocale(defaultLocale)}${RESET} | Runtime: ${CYAN}${formatRuntime(resolvedRuntime)}${RESET} | Out Dir: ${DIM}${usesLocalStorage ? localesDir : \"n/a\"}${RESET} | Roots: ${DIM}${(Array.isArray(rootDir) ? rootDir : [rootDir]).join(\", \")}${RESET}`,\n )\n },\n\n resolveId(id) {\n if (id === VIRTUAL_MESSAGES_MODULE_ID) return RESOLVED_VIRTUAL_MESSAGES_MODULE_ID\n },\n\n load(id) {\n if (id === RESOLVED_VIRTUAL_MESSAGES_MODULE_ID) return createVirtualMessagesModule()\n },\n\n async buildStart() {\n cache = loadCache(resolve(root, cacheFile))\n scanAllSourceFiles()\n if (usesLocalStorage && !isDev) {\n assertLocalBuildTranslationsComplete()\n return\n }\n writeLocaleFilesToDisk()\n writePrivateManifest()\n\n if (isDev) scheduleDevTranslation()\n },\n\n configureServer(server) {\n const localEditorOptions = getLocalEditorOptions({ isDev, runtime: resolvedRuntime })\n if (localEditorOptions) {\n configureLocalEditor(\n server,\n { defaultLocale, isUntranslatedLocaleValue, locales, log, manifest, readLocaleMessages, writeLocaleMessages },\n localEditorOptions,\n )\n }\n server.watcher.add(sourceRoots)\n server.httpServer?.once(\"listening\", () => scheduleDevRemoteSync())\n\n const syncFileFromDisk = (file: string) => {\n if (!shouldScanFile(file) || !existsSync(file)) return\n applySyncResult(syncSourceCode(file, readFileSync(file, \"utf-8\")), { scheduleTranslation: true })\n scheduleDevRemoteSync()\n }\n\n const removeFileFromManifest = (file: string) => {\n if (!shouldScanFile(file)) return\n applySyncResult(removeTrackedFile(file), { scheduleTranslation: true })\n scheduleDevRemoteSync()\n }\n\n server.watcher.on(\"add\", syncFileFromDisk)\n server.watcher.on(\"change\", syncFileFromDisk)\n server.watcher.on(\"unlink\", removeFileFromManifest)\n },\n\n transform(code, id) {\n const cleanId = id.split(\"?\", 1)[0] ?? id\n if (!shouldScanFile(cleanId)) return\n\n const analysis = analyzeSourceFile(code, cleanId, {\n call: CALL_MARKERS,\n component: COMPONENT_MARKERS,\n logging,\n })\n\n if (analysis.edits.length === 0) return\n return {\n code: applyEdits(code, analysis.edits),\n map: null,\n }\n },\n\n async generateBundle() {\n if (usesLocalStorage) {\n assertLocalBuildTranslationsComplete()\n } else if (isDev) {\n await translateMissingMessages()\n }\n\n if (!usesLocalStorage) {\n await syncRemote()\n }\n },\n\n closeBundle() {\n if (usesLocalStorage && !isDev) return\n saveCache(resolve(root, cacheFile), cache)\n },\n }\n}\n\nfunction formatLocaleIssue(locale: string, label: string, ids: string[]) {\n const preview = ids\n .slice(0, 5)\n .map((id) => JSON.stringify(id))\n .join(\", \")\n const suffix = ids.length > 5 ? `, ... ${ids.length - 5} more` : \"\"\n return `- ${locale}: ${label} (${preview}${suffix})`\n}\n\nfunction shouldUseLocalStorage(runtime: BetterTranslateRuntimeOptions, isDev: boolean) {\n return runtime.type === \"local\" || isRemoteOfflineDev(runtime, isDev)\n}\n\nfunction isRemoteOfflineDev(runtime: BetterTranslateRuntimeOptions, isDev: boolean) {\n return runtime.type === \"remote\" && isDev && runtime.dev?.offline === true\n}\n\nfunction getRuntimeOutputDir(runtime: BetterTranslateRuntimeOptions, isDev: boolean) {\n if (runtime.type === \"local\") return runtime.output!\n if (isRemoteOfflineDev(runtime, isDev)) return DEFAULT_REMOTE_OFFLINE_OUTPUT_DIR\n return DEFAULT_LOCAL_OUTPUT_DIR\n}\n\nfunction normalizeRuntimeOptions(runtime: BetterTranslateRuntimeOptions | undefined): BetterTranslateRuntimeOptions {\n if (runtime) return runtime.type === \"local\" ? { ...runtime, target: runtime.target ?? \"module\" } : runtime\n return { type: \"local\", target: \"module\" }\n}\n\nfunction resolveRuntimeOptions(runtime: BetterTranslateRuntimeOptions, config: ResolvedConfig): BetterTranslateRuntimeOptions {\n if (runtime.type === \"remote\") {\n const projectId = typeof runtime.projectId === \"string\" ? runtime.projectId.trim() : \"\"\n if (!projectId) {\n throw new Error(`${PREFIX} remote runtime requires a projectId`)\n }\n return {\n ...runtime,\n projectId,\n endpoint: runtime.endpoint ?? REMOTE_API_BASE_URL,\n branch: resolveBranch(runtime, config.root),\n dev: {\n offline: runtime.dev?.offline ?? false,\n },\n }\n }\n\n const target = runtime.target ?? \"module\"\n if (target === \"module\") {\n return {\n ...runtime,\n target,\n output: runtime.output ?? DEFAULT_LOCAL_OUTPUT_DIR,\n }\n }\n\n if (!config.publicDir) {\n throw new Error(`${PREFIX} runtime target \"public\" requires Vite publicDir to be enabled`)\n }\n\n const output = runtime.output ?? normalizePath(relative(config.root, resolve(config.publicDir, DEFAULT_PUBLIC_OUTPUT_SUBDIR)))\n const outputPath = resolve(config.root, output)\n const publicBasePath = runtime.basePath ?? inferPublicBasePath(outputPath, config.publicDir)\n\n return {\n ...runtime,\n target,\n output,\n basePath: publicBasePath,\n }\n}\n\nfunction inferPublicBasePath(outputPath: string, publicDir: string) {\n const relativeToPublic = normalizePath(relative(publicDir, outputPath))\n if (relativeToPublic.startsWith(\"..\")) {\n throw new Error(`${PREFIX} runtime target \"public\" output must be inside Vite publicDir unless basePath is provided`)\n }\n return `/${relativeToPublic}`.replace(/\\/$/, \"\")\n}\n\nfunction formatRuntime(runtime: BetterTranslateRuntimeOptions) {\n return runtime.type === \"local\" ? `Local/${runtime.target ?? \"module\"}` : `Remote/${runtime.branch ?? \"auto\"}`\n}\n\nfunction resolveBranch(runtime: Pick<Extract<BetterTranslateRuntimeOptions, { type: \"remote\" }>, \"branch\">, root: string) {\n if (runtime.branch && runtime.branch !== \"auto\") return runtime.branch\n\n const envBranch = process.env.BETTER_TRANSLATION_BRANCH?.trim()\n if (envBranch) return envBranch\n\n const providerBranch = process.env.VERCEL_GIT_COMMIT_REF?.trim()\n if (providerBranch) return providerBranch\n\n const gitBranch = readCurrentGitBranch(root)\n return gitBranch ?? DEFAULT_REMOTE_BRANCH\n}\n\nfunction readCurrentGitBranch(root: string) {\n try {\n const branch = execFileSync(\"git\", [\"branch\", \"--show-current\"], {\n cwd: root,\n encoding: \"utf-8\",\n stdio: [\"ignore\", \"pipe\", \"ignore\"],\n }).trim()\n return branch || null\n } catch {\n return null\n }\n}\n\nfunction formatRemoteManifestTarget(runtime: Extract<BetterTranslateRuntimeOptions, { type: \"remote\" }>, endpoint: string) {\n return `${endpoint.replace(/\\/$/, \"\")}/api/projects/${encodeURIComponent(runtime.projectId)}/branches/${encodeURIComponent(runtime.branch ?? DEFAULT_REMOTE_BRANCH)}/manifest`\n}\n\nfunction parseRemoteSyncResult(body: string) {\n try {\n const parsed = JSON.parse(body) as unknown\n if (typeof parsed !== \"object\" || parsed === null) return null\n return {\n changed: \"changed\" in parsed && parsed.changed === true,\n }\n } catch {\n return null\n }\n}\n\nfunction formatRemoteSyncError(response: Response, target: string, body: string) {\n const details = formatRemoteSyncResponseDetails(body)\n return [\n `${PREFIX} remote Manifest sync failed with ${response.status} ${response.statusText || \"HTTP error\"}`,\n `target: ${target}`,\n details ? `response: ${details}` : null,\n ]\n .filter((line) => line !== null)\n .join(\"\\n\")\n}\n\nfunction formatRemoteSyncNetworkError(target: string, error: unknown) {\n const message = error instanceof Error ? error.message : String(error)\n return [`${PREFIX} remote Manifest sync could not reach the hosted service`, `target: ${target}`, `error: ${message}`].join(\n \"\\n\",\n )\n}\n\nfunction formatRemoteSyncResponseDetails(body: string) {\n const details = body.trim().replace(/\\s+/g, \" \")\n if (!details) return \"\"\n return details.length > 500 ? `${details.slice(0, 500)}...` : details\n}\n\nfunction createModuleMessagesModule(locales: string[], getImportPath: (locale: string) => string) {\n const cases = locales\n .map(\n (locale) => ` case ${JSON.stringify(locale)}:\n return (await import(${JSON.stringify(getImportPath(locale))})).default`,\n )\n .join(\"\\n\")\n\n return [\n `export const locales = ${JSON.stringify(locales)}`,\n \"\",\n \"export async function loadMessages(locale) {\",\n \" switch (locale) {\",\n cases,\n \" default:\",\n \" throw new Error(`Unknown locale: ${locale}`)\",\n \" }\",\n \"}\",\n \"\",\n ].join(\"\\n\")\n}\n\nfunction createPublicMessagesModule(locales: string[], basePath: string) {\n const normalizedBasePath = basePath.replace(/\\/$/, \"\")\n return [\n `export const locales = ${JSON.stringify(locales)}`,\n \"\",\n \"export async function loadMessages(locale) {\",\n \" assertKnownLocale(locale)\",\n ` const response = await fetch(\\`${normalizedBasePath}/locales/\\${encodeURIComponent(locale)}.json\\`)`,\n \" if (!response.ok) throw new Error(`Failed to load locale: ${locale}`)\",\n \" return response.json()\",\n \"}\",\n \"\",\n createKnownLocaleAssertion(locales),\n ].join(\"\\n\")\n}\n\nfunction createRemoteMessagesModule(\n runtime: Extract<BetterTranslateRuntimeOptions, { type: \"remote\" }>,\n locales: string[],\n endpoint: string,\n) {\n const normalizedEndpoint = endpoint.replace(/\\/$/, \"\")\n const projectPath = `/projects/${encodeURIComponent(runtime.projectId)}`\n const branchPath = `/branches/${encodeURIComponent(runtime.branch ?? DEFAULT_REMOTE_BRANCH)}`\n return [\n `export const locales = ${JSON.stringify(locales)}`,\n \"\",\n \"export async function loadMessages(locale) {\",\n \" assertKnownLocale(locale)\",\n ` const response = await fetch(\\`${normalizedEndpoint}${projectPath}${branchPath}/locales/\\${encodeURIComponent(locale)}.json\\`)`,\n \" if (!response.ok) throw new Error(`Failed to load locale: ${locale}`)\",\n \" return response.json()\",\n \"}\",\n \"\",\n createKnownLocaleAssertion(locales),\n ].join(\"\\n\")\n}\n\nfunction createKnownLocaleAssertion(locales: string[]) {\n return [\n `const knownLocales = new Set(${JSON.stringify(locales)})`,\n \"\",\n \"function assertKnownLocale(locale) {\",\n \" if (!knownLocales.has(locale)) throw new Error(`Unknown locale: ${locale}`)\",\n \"}\",\n \"\",\n ].join(\"\\n\")\n}\n\nfunction normalizeLocaleMessages(input: unknown): RuntimeMessages {\n if (isRuntimeMessages(input)) return input\n if (\n typeof input === \"object\" &&\n input !== null &&\n \"messages\" in input &&\n typeof input.messages === \"object\" &&\n input.messages !== null\n ) {\n return Object.fromEntries(\n Object.entries(input.messages).flatMap(([id, entry]) =>\n typeof entry === \"object\" && entry !== null && \"translation\" in entry && typeof entry.translation === \"string\"\n ? [[id, entry.translation]]\n : [],\n ),\n ) as RuntimeMessages\n }\n return {}\n}\n\nfunction writeFileIfChanged(path: string, contents: string) {\n if (existsSync(path) && readFileSync(path, \"utf-8\") === contents) return false\n writeFileSync(path, contents)\n return true\n}\n\nfunction collectScanFiles(root: string) {\n const files: string[] = []\n for (const entry of readdirSync(root, { withFileTypes: true })) {\n const path = resolve(root, entry.name)\n if (entry.isDirectory()) {\n if (entry.name === \"node_modules\") continue\n files.push(...collectScanFiles(path))\n continue\n }\n files.push(path)\n }\n return files\n}\n\nfunction isRuntimeMessages(input: unknown): input is RuntimeMessages {\n return typeof input === \"object\" && input !== null && Object.values(input).every((value) => typeof value === \"string\")\n}\n\nfunction applyEdits(code: string, edits: Array<{ start: number; end: number; replacement: string }>) {\n let transformed = code\n for (const edit of [...edits].sort((a, b) => b.start - a.start)) {\n transformed = `${transformed.slice(0, edit.start)}${edit.replacement}${transformed.slice(edit.end)}`\n }\n return transformed\n}\n\nfunction groupMessagesById(messages: ExtractedMessage[]): MessageManifest {\n const grouped: MessageManifest = {}\n\n for (const message of messages) {\n const existing = grouped[message.id]\n if (existing && !hasSameMessageShape(existing, message)) {\n throw new Error(formatCollisionError(message.id, existing, message))\n }\n if (!existing) {\n grouped[message.id] = {\n defaultMessage: message.defaultMessage,\n meta: message.meta,\n placeholders: message.placeholders,\n sources: [message.source],\n }\n continue\n }\n if (!existing.sources.some((source) => isSameSource(source, message.source))) {\n existing.sources.push(message.source)\n }\n }\n\n return grouped\n}\n\nfunction hasSameMessageShape(\n existing: Pick<ManifestEntry, \"defaultMessage\" | \"meta\" | \"placeholders\">,\n incoming: Pick<ManifestEntry, \"defaultMessage\" | \"meta\" | \"placeholders\"> | ExtractedMessage,\n) {\n return (\n existing.defaultMessage === incoming.defaultMessage &&\n serializeMeta(existing.meta) === serializeMeta(incoming.meta) &&\n JSON.stringify(existing.placeholders) === JSON.stringify(incoming.placeholders)\n )\n}\n\nfunction isSameSource(left: MessageSource, right: MessageSource) {\n return left.file === right.file && left.kind === right.kind && left.marker === right.marker\n}\n\nfunction compareManifestEntryIds([left]: [string, ManifestEntry], [right]: [string, ManifestEntry]) {\n return left.localeCompare(right)\n}\n\nfunction compareMessageSources(left: MessageSource, right: MessageSource) {\n return left.file.localeCompare(right.file) || left.kind.localeCompare(right.kind) || left.marker.localeCompare(right.marker)\n}\n\nfunction isSameExtractedMessage(left: ExtractedMessage, right?: ExtractedMessage) {\n if (!right) return false\n return hasSameMessageShape(left, right) && isSameSource(left.source, right.source)\n}\n\nfunction formatCollisionError(\n id: string,\n existing: Pick<ManifestEntry, \"defaultMessage\" | \"meta\" | \"placeholders\" | \"sources\">,\n incoming: Pick<ManifestEntry, \"defaultMessage\" | \"meta\" | \"placeholders\" | \"sources\"> | ExtractedMessage,\n) {\n const existingSources = formatSources(existing.sources)\n const incomingSources = formatSources(\"source\" in incoming ? [incoming.source] : incoming.sources)\n return [\n `${PREFIX} conflicting message definition for ${BOLD}\"${id}\"${RESET}`,\n `existing: ${JSON.stringify({ defaultMessage: existing.defaultMessage, meta: existing.meta, placeholders: existing.placeholders })}`,\n `existing sources: ${existingSources}`,\n `incoming: ${JSON.stringify({ defaultMessage: incoming.defaultMessage, meta: incoming.meta, placeholders: incoming.placeholders })}`,\n `incoming sources: ${incomingSources}`,\n ].join(\"\\n\")\n}\n\nfunction formatSources(sources: MessageSource[]) {\n return sources.map((source) => `${source.file} (${source.kind}:${source.marker})`).join(\", \")\n}\n"],"mappings":";;;;;;;;AAKA,MAAM,kBAAkB;AAExB,SAAgB,mBAAqC;CACnD,OAAO;EAAE,SAAS;EAAiB,SAAS,CAAC;CAAE;AACjD;;AAGA,SAAgB,UAAU,MAAgC;CACxD,IAAI,CAAC,WAAW,IAAI,GAAG,OAAO,iBAAiB;CAC/C,IAAI;EACF,MAAM,OAAO,KAAK,MAAM,aAAa,MAAM,OAAO,CAAC;EACnD,IAAI,KAAK,YAAY,iBAAiB,OAAO,iBAAiB;EAC9D,OAAO;CACT,QAAQ;EACN,OAAO,iBAAiB;CAC1B;AACF;;AAGA,SAAgB,UAAU,MAAc,OAAyB;CAC/D,MAAM,MAAM,QAAQ,IAAI;CACxB,IAAI,CAAC,WAAW,GAAG,GAAG,UAAU,KAAK,EAAE,WAAW,KAAK,CAAC;CACxD,MAAM,OAAO,KAAK,UAAU,OAAO,MAAM,CAAC;CAC1C,IAAI,WAAW,IAAI,KAAK,aAAa,MAAM,OAAO,MAAM,MAAM;CAC9D,cAAc,MAAM,IAAI;AAC1B;;AAGA,SAAgB,YAAY,UAAkB,QAAgB;CAC5D,OAAO,GAAG,SAAS,IAAI;AACzB;;;ACfA,SAAgB,+BAA+B,SAAiB;CAC9D,MAAM,wBAAQ,IAAI,IAAY;CAC9B,KAAK,MAAM,SAAS,QAAQ,SAAS,YAAY,GAC/C,IAAI,MAAM,IAAI,MAAM,IAAI,MAAM,EAAE;CAElC,OAAO,CAAC,GAAG,KAAK;AAClB;AAEA,SAAgB,aAAa,EAC3B,UACA,QACA,QAKgB;CAChB,OAAO;EACL,MAAM;EACN;EACA;CACF;AACF;;;ACHA,MAAM,UAAU,cAAc,OAAO,KAAK,GAAG;;AAG7C,SAAgB,wBAAwB,MAAc,UAAkB,SAAwC;CAC9G,MAAM,WAA+B,CAAC;CACtC,MAAM,QAAsB,CAAC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M,IAAI,KAAK,KAAK,KAAK,cAAc,MAAM,IAAI,KAAK,KAAK,OAAO,cAAc,MAAM,MAAM;AAC7H;AAEA,SAAS,uBAAuB,MAAwB,OAA0B;CAChF,IAAI,CAAC,OAAO,OAAO;CACnB,OAAO,oBAAoB,MAAM,KAAK,KAAK,aAAa,KAAK,QAAQ,MAAM,MAAM;AACnF;AAEA,SAAS,qBACP,IACA,UACA,UACA;CACA,MAAM,kBAAkB,cAAc,SAAS,OAAO;CACtD,MAAM,kBAAkB,cAAc,YAAY,WAAW,CAAC,SAAS,MAAM,IAAI,SAAS,OAAO;CACjG,OAAO;EACL,GAAG,OAAO,sCAAsC,KAAK,GAAG,GAAG,GAAG;EAC9D,aAAa,KAAK,UAAU;GAAE,gBAAgB,SAAS;GAAgB,MAAM,SAAS;GAAM,cAAc,SAAS;EAAa,CAAC;EACjI,qBAAqB;EACrB,aAAa,KAAK,UAAU;GAAE,gBAAgB,SAAS;GAAgB,MAAM,SAAS;GAAM,cAAc,SAAS;EAAa,CAAC;EACjI,qBAAqB;CACvB,EAAE,KAAK,IAAI;AACb;AAEA,SAAS,cAAc,SAA0B;CAC/C,OAAO,QAAQ,KAAK,WAAW,GAAG,OAAO,KAAK,IAAI,OAAO,KAAK,GAAG,OAAO,OAAO,EAAE,EAAE,KAAK,IAAI;AAC9F"}
1
+ {"version":3,"file":"vite.mjs","names":["isStringLiteral","getCallMetaArgument","createCallOptionsEdit","getVarEntry","getMetaArgument","isTranslateOptionsArgument","hasObjectProperty","CYAN","PREFIX","RESET","compareManifestEntryIds"],"sources":["../src/cache.ts","../src/extractors/types.ts","../src/extractors/svelte.ts","../src/extractors/typescript.ts","../src/extractor.ts","../src/local-editor/server.ts","../src/plugin.ts"],"sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\"\nimport { dirname } from \"node:path\"\n\nimport type { TranslationCache } from \"./types.js\"\n\nconst CURRENT_VERSION = 1\n\nexport function createEmptyCache(): TranslationCache {\n return { version: CURRENT_VERSION, entries: {} }\n}\n\n/** Loads the translation cache from disk, resetting it when the schema version changes. */\nexport function loadCache(path: string): TranslationCache {\n if (!existsSync(path)) return createEmptyCache()\n try {\n const data = JSON.parse(readFileSync(path, \"utf-8\")) as TranslationCache\n if (data.version !== CURRENT_VERSION) return createEmptyCache()\n return data\n } catch {\n return createEmptyCache()\n }\n}\n\n/** Persists the translation cache so future runs can reuse existing translations. */\nexport function saveCache(path: string, cache: TranslationCache) {\n const dir = dirname(path)\n if (!existsSync(dir)) mkdirSync(dir, { recursive: true })\n const next = JSON.stringify(cache, null, 2)\n if (existsSync(path) && readFileSync(path, \"utf-8\") === next) return\n writeFileSync(path, next)\n}\n\n/** Builds the cache key used to distinguish translations by stable lookup id and locale. */\nexport function getCacheKey(lookupId: string, locale: string) {\n return `${lookupId}\\0${locale}`\n}\n","import type { ExtractedMessage, MessageSource } from \"../types.js\"\n\nexport interface SourceMarkers {\n call: string[]\n component: string[]\n logging: boolean\n}\n\nexport interface SourceEdit {\n start: number\n end: number\n replacement: string\n}\n\nexport interface SourceAnalysis {\n parsed: boolean\n messages: ExtractedMessage[]\n edits: SourceEdit[]\n}\n\nexport function extractPlaceholdersFromMessage(message: string) {\n const names = new Set<string>()\n for (const match of message.matchAll(/\\{(\\w+)\\}/g)) {\n if (match[1]) names.add(match[1])\n }\n return [...names]\n}\n\nexport function createSource({\n filename,\n marker,\n kind,\n}: {\n filename: string\n marker: string\n kind: MessageSource[\"kind\"]\n}): MessageSource {\n return {\n file: filename,\n kind,\n marker,\n }\n}\n","import { createRequire } from \"node:module\"\n\nimport type { ExtractedMessage, TranslateOptions } from \"../types.js\"\n\nimport { getCallMessageId, getMessageId } from \"../message-id.js\"\nimport {\n createSource,\n extractPlaceholdersFromMessage,\n type SourceAnalysis,\n type SourceEdit,\n type SourceMarkers,\n} from \"./types.js\"\n\ntype SvelteNode = {\n type?: string\n start?: number\n end?: number\n name?: string\n attributes?: SvelteNode[]\n fragment?: {\n nodes?: SvelteNode[]\n }\n value?: unknown\n raw?: string\n data?: string\n expression?: SvelteNode\n [key: string]: unknown\n}\n\ntype SvelteAttribute = SvelteNode & {\n name?: string\n value?: SvelteNode | SvelteNode[] | true\n}\n\ntype SvelteCallExpression = SvelteNode & {\n callee?: SvelteNode\n arguments?: SvelteNode[]\n}\n\nconst require = createRequire(import.meta.url)\n\n/** Extracts messages from Svelte component markup and embedded expressions. */\nexport function analyzeSvelteSourceFile(code: string, filename: string, markers: SourceMarkers): SourceAnalysis {\n const messages: ExtractedMessage[] = []\n const edits: SourceEdit[] = []\n let ast: SvelteNode\n\n try {\n ast = loadSvelteCompiler().parse(code, { modern: true }) as unknown as SvelteNode\n } catch {\n return { parsed: false, messages, edits }\n }\n\n walkSvelte(ast, (node) => {\n if (node.type === \"Component\" && typeof node.name === \"string\" && markers.component.includes(node.name)) {\n analyzeTComponent(code, filename, markers, node, messages, edits)\n return\n }\n\n if (node.type === \"CallExpression\") {\n analyzeCallExpression(code, filename, markers, node as SvelteCallExpression, messages, edits)\n }\n })\n\n return { parsed: true, messages, edits }\n}\n\nfunction loadSvelteCompiler(): { parse: (code: string, options: { modern: true }) => unknown } {\n return require(\"svelte/compiler\") as { parse: (code: string, options: { modern: true }) => unknown }\n}\n\nfunction analyzeCallExpression(\n code: string,\n filename: string,\n markers: SourceMarkers,\n node: SvelteCallExpression,\n messages: ExtractedMessage[],\n edits: SourceEdit[],\n) {\n if (node.callee?.type !== \"Identifier\") return\n if (typeof node.callee.name !== \"string\" || !markers.call.includes(node.callee.name)) return\n const [messageArg] = node.arguments ?? []\n if (!isStringLiteral(messageArg)) return\n\n const value = String(messageArg.value)\n const meta = getCallMetaArgument(node.arguments ?? [])\n const id = getCallMessageId(value, meta)\n messages.push({\n id,\n defaultMessage: value,\n meta: meta ?? {},\n placeholders: extractPlaceholdersFromMessage(value),\n source: createSource({\n filename,\n marker: node.callee.name,\n kind: \"call\",\n }),\n })\n\n const edit = createCallOptionsEdit(code, node.arguments ?? [], id)\n if (edit) edits.push(edit)\n}\n\nfunction analyzeTComponent(\n code: string,\n filename: string,\n markers: SourceMarkers,\n node: SvelteNode,\n messages: ExtractedMessage[],\n edits: SourceEdit[],\n) {\n const extraction = extractSvelteChildren(code, node.fragment?.nodes ?? [])\n if (!extraction.valid) {\n if (markers.logging) console.warn(`[better-translation] Non-static <${node.name}> in ${filename}, skipping`)\n return\n }\n\n const context = getStringAttribute(node.attributes, \"context\")\n const meta = context ? { context } : undefined\n const id = getStringAttribute(node.attributes, \"id\") ?? getMessageId(extraction.message, meta)\n messages.push({\n id,\n defaultMessage: extraction.message,\n meta: meta ?? {},\n placeholders: extraction.placeholders,\n source: createSource({\n filename,\n marker: String(node.name),\n kind: \"component\",\n }),\n })\n\n const insertAt = getSvelteOpeningTagNameEnd(code, node)\n if (!hasAttribute(node.attributes, \"id\") && insertAt !== undefined) {\n edits.push({\n start: insertAt,\n end: insertAt,\n replacement: ` id=${JSON.stringify(id)}`,\n })\n }\n\n if (!hasAttribute(node.attributes, \"message\") && insertAt !== undefined) {\n edits.push({\n start: insertAt,\n end: insertAt,\n replacement: ` message=${JSON.stringify(extraction.message)}`,\n })\n }\n\n if (!hasAttribute(node.attributes, \"values\") && extraction.values.length > 0 && insertAt !== undefined) {\n edits.push({\n start: insertAt,\n end: insertAt,\n replacement: ` values={{ ${extraction.values.map((entry) => `${entry.name}: ${entry.value}`).join(\", \")} }}`,\n })\n }\n}\n\nfunction extractSvelteChildren(code: string, children: SvelteNode[]) {\n const parts: string[] = []\n const placeholders: string[] = []\n const values: Array<{ name: string; value: string }> = []\n\n for (const child of children) {\n if (child.type === \"Text\") {\n parts.push(String(child.data ?? child.raw ?? \"\"))\n continue\n }\n\n if (child.type === \"Component\" && child.name === \"Var\") {\n const entry = getVarEntry(code, child)\n if (!entry) return { message: \"\", placeholders: [], values: [], valid: false }\n placeholders.push(entry.name)\n values.push(entry)\n parts.push(`{${entry.name}}`)\n continue\n }\n\n if (child.type === \"Comment\") continue\n return { message: \"\", placeholders: [], values: [], valid: false }\n }\n\n const message = parts.join(\"\").replace(/\\s+/g, \" \").trim()\n return { message, placeholders, values, valid: message.length > 0 }\n}\n\nfunction getVarEntry(code: string, node: SvelteNode) {\n const explicitName = getStringAttribute(node.attributes, \"name\")\n const explicitValue = getExpressionAttributeSource(code, node.attributes, \"value\")\n if (explicitName && explicitValue) return { name: explicitName, value: explicitValue }\n if (explicitName) return { name: explicitName, value: JSON.stringify(explicitName) }\n\n const shorthandAttribute = getSingleExpressionAttribute(node.attributes)\n if (!shorthandAttribute) return undefined\n return {\n name: shorthandAttribute.name,\n value: code.slice(shorthandAttribute.expression.start!, shorthandAttribute.expression.end!),\n }\n}\n\nfunction getSingleExpressionAttribute(attributes?: SvelteNode[]) {\n const expressionAttributes = (attributes ?? []).flatMap((attribute) => {\n if (attribute.type !== \"Attribute\" || typeof attribute.name !== \"string\") return []\n const value = (attribute as SvelteAttribute).value\n return isExpressionAttributeValue(value) ? [{ name: attribute.name, expression: value.expression }] : []\n })\n\n return expressionAttributes.length === 1 ? expressionAttributes[0] : undefined\n}\n\nfunction getStringAttribute(attributes: SvelteNode[] | undefined, name: string) {\n const attribute = attributes?.find((entry) => entry.type === \"Attribute\" && entry.name === name) as SvelteAttribute | undefined\n if (!attribute) return undefined\n if (typeof attribute.value === \"string\") return attribute.value\n\n const value = Array.isArray(attribute.value) ? attribute.value[0] : attribute.value\n if (!value || value === true) return undefined\n if (value?.type === \"Text\") return String(value.data ?? value.raw ?? \"\")\n}\n\nfunction getExpressionAttributeSource(code: string, attributes: SvelteNode[] | undefined, name: string) {\n const attribute = attributes?.find((entry) => entry.type === \"Attribute\" && entry.name === name) as SvelteAttribute | undefined\n const value = attribute?.value\n if (!isExpressionAttributeValue(value)) return undefined\n return code.slice(value.expression.start!, value.expression.end!)\n}\n\nfunction hasAttribute(attributes: SvelteNode[] | undefined, name: string) {\n return attributes?.some((entry) => entry.type === \"Attribute\" && entry.name === name) ?? false\n}\n\nfunction getSvelteOpeningTagNameEnd(code: string, node: SvelteNode) {\n if (node.start === undefined || typeof node.name !== \"string\") return undefined\n const tagStart = code.indexOf(`<${node.name}`, node.start)\n if (tagStart < 0) return undefined\n return tagStart + node.name.length + 1\n}\n\nfunction isExpressionAttributeValue(value: SvelteAttribute[\"value\"]): value is SvelteNode & { expression: SvelteNode } {\n if (Array.isArray(value) || value === true || !value) return false\n return value.type === \"ExpressionTag\" && value.expression !== undefined\n}\n\nfunction isStringLiteral(node?: SvelteNode): node is SvelteNode & { value: string } {\n return node?.type === \"Literal\" && typeof node.value === \"string\"\n}\n\nfunction getCallMetaArgument(args: SvelteNode[]) {\n return getMetaArgument(isTranslateOptionsArgument(args[1]) ? args[1] : args[2])\n}\n\nfunction getMetaArgument(node?: SvelteNode) {\n if (!node) return undefined\n if (isStringLiteral(node)) return { context: node.value }\n if (node.type !== \"ObjectExpression\") return undefined\n\n const meta: TranslateOptions = {}\n for (const property of (node.properties as SvelteNode[] | undefined) ?? []) {\n const key = getPropertyKey(property)\n const value = property.value as SvelteNode | undefined\n if ((key === \"context\" || key === \"id\") && isStringLiteral(value)) meta[key] = value.value\n }\n\n return Object.keys(meta).length > 0 ? meta : undefined\n}\n\nfunction createCallOptionsEdit(code: string, args: SvelteNode[], id: string): SourceEdit | undefined {\n const valuesArg = args[1]\n const optionsArg = isTranslateOptionsArgument(valuesArg) ? valuesArg : args[2]\n\n if (!optionsArg) {\n return {\n start: (valuesArg ?? args[0])!.end!,\n end: (valuesArg ?? args[0])!.end!,\n replacement: `, { id: ${JSON.stringify(id)} }`,\n }\n }\n\n if (isStringLiteral(optionsArg)) {\n const contextValue = code.slice(optionsArg.start, optionsArg.end)\n return {\n start: optionsArg.start!,\n end: optionsArg.end!,\n replacement: `{ id: ${JSON.stringify(id)}, context: ${contextValue} }`,\n }\n }\n\n if (optionsArg.type !== \"ObjectExpression\") return undefined\n if (hasObjectProperty(optionsArg, \"id\")) return undefined\n\n const objectSource = code.slice(optionsArg.start, optionsArg.end)\n const innerSource = objectSource.slice(1, -1)\n const replacement =\n innerSource.trim().length > 0 ? `{ id: ${JSON.stringify(id)},${innerSource} }` : `{ id: ${JSON.stringify(id)} }`\n\n return {\n start: optionsArg.start!,\n end: optionsArg.end!,\n replacement,\n }\n}\n\nfunction isTranslateOptionsArgument(node?: SvelteNode) {\n if (!node) return false\n if (isStringLiteral(node)) return true\n if (node.type !== \"ObjectExpression\") return false\n\n return ((node.properties as SvelteNode[] | undefined) ?? []).every((property) => {\n const key = getPropertyKey(property)\n return key === \"context\" || key === \"id\"\n })\n}\n\nfunction getPropertyKey(property: SvelteNode) {\n const key = property.key as SvelteNode | undefined\n if (key?.type === \"Identifier\" && typeof key.name === \"string\") return key.name\n if (key?.type === \"Literal\" && typeof key.value === \"string\") return key.value\n}\n\nfunction hasObjectProperty(node: SvelteNode, name: string) {\n return ((node.properties as SvelteNode[] | undefined) ?? []).some((property) => getPropertyKey(property) === name)\n}\n\nfunction walkSvelte(node: unknown, visit: (node: SvelteNode) => void, seen = new Set<unknown>()) {\n if (!node || typeof node !== \"object\" || seen.has(node)) return\n seen.add(node)\n\n const current = node as SvelteNode\n visit(current)\n\n for (const value of Object.values(current)) {\n if (!value || typeof value !== \"object\") continue\n if (Array.isArray(value)) {\n for (const item of value) walkSvelte(item, visit, seen)\n continue\n }\n walkSvelte(value, visit, seen)\n }\n}\n","import type { Argument, JSXChild, StringLiteral } from \"oxc-parser\"\nimport { parseSync, Visitor } from \"oxc-parser\"\n\nimport type { ExtractedMessage, TranslateOptions } from \"../types.js\"\n\nimport { getCallMessageId, getMessageId } from \"../message-id.js\"\nimport {\n createSource,\n extractPlaceholdersFromMessage,\n type SourceAnalysis,\n type SourceEdit,\n type SourceMarkers,\n} from \"./types.js\"\n\n/** Extracts messages and source edits from a TypeScript, JavaScript, or JSX file in one coordinated parse pass. */\nexport function analyzeTypeScriptSourceFile(code: string, filename: string, markers: SourceMarkers): SourceAnalysis {\n const messages: ExtractedMessage[] = []\n const edits: SourceEdit[] = []\n const result = parseSync(filename, code)\n if (result.errors.length > 0) return { parsed: false, messages, edits }\n\n const visitor = new Visitor({\n CallExpression(node) {\n if (\n node.callee.type === \"Identifier\" &&\n markers.call.includes(node.callee.name) &&\n node.arguments.length >= 1 &&\n isStringLiteral(node.arguments[0]!)\n ) {\n const value = (node.arguments[0] as StringLiteral).value\n const meta = getCallMetaArgument(node.arguments)\n const id = getCallMessageId(value, meta)\n messages.push({\n id,\n defaultMessage: value,\n meta: meta ?? {},\n placeholders: extractPlaceholdersFromMessage(value),\n source: createSource({\n filename,\n marker: node.callee.name,\n kind: \"call\",\n }),\n })\n\n const callOptionsEdit = createCallOptionsEdit(code, node.arguments, id)\n if (callOptionsEdit) edits.push(callOptionsEdit)\n }\n },\n\n JSXElement(node) {\n const opening = node.openingElement\n if (\n opening.name.type === \"JSXIdentifier\" &&\n opening.name.name === \"Var\" &&\n (opening.attributes as Array<unknown>).length === 0\n ) {\n const identifier = getVarChildIdentifier(node.children)\n if (identifier) {\n edits.push({\n start: node.start,\n end: node.end,\n replacement: `<Var ${identifier}={${identifier}} />`,\n })\n }\n }\n\n if (opening.name.type !== \"JSXIdentifier\") return\n if (!markers.component.includes(opening.name.name)) return\n\n const extraction = extractJSXChildren(code, node.children)\n if (!extraction.valid) {\n if (markers.logging) {\n console.warn(`[better-translation] Non-static <${opening.name.name}> in ${filename}, skipping`)\n }\n return\n }\n\n const context = getJSXStringAttribute(opening.attributes, \"context\")\n const meta = context ? { context } : undefined\n const id = getJSXStringAttribute(opening.attributes, \"id\") ?? getMessageId(extraction.message, meta)\n messages.push({\n id,\n defaultMessage: extraction.message,\n meta: meta ?? {},\n placeholders: extraction.placeholders,\n source: createSource({\n filename,\n marker: opening.name.name,\n kind: \"component\",\n }),\n })\n\n if (!hasJSXAttribute(opening.attributes as Array<unknown>, \"id\")) {\n edits.push({\n start: opening.name.end,\n end: opening.name.end,\n replacement: ` id=\"${id}\"`,\n })\n }\n\n if (!hasJSXAttribute(opening.attributes as Array<unknown>, \"message\")) {\n edits.push({\n start: opening.name.end,\n end: opening.name.end,\n replacement: ` message={${JSON.stringify(extraction.message)}}`,\n })\n }\n\n if (!hasJSXAttribute(opening.attributes as Array<unknown>, \"values\") && extraction.values.length > 0) {\n edits.push({\n start: opening.name.end,\n end: opening.name.end,\n replacement: ` values={{ ${extraction.values.map((entry) => `${entry.name}: ${entry.value}`).join(\", \")} }}`,\n })\n }\n },\n })\n\n visitor.visit(result.program)\n return { parsed: true, messages, edits }\n}\n\nfunction isStringLiteral(node: Argument): node is StringLiteral {\n return node.type === \"Literal\" && typeof (node as StringLiteral).value === \"string\"\n}\n\nfunction getMetaArgument(node?: Argument) {\n if (!node) return undefined\n if (isStringLiteral(node)) return { context: node.value }\n\n if (node.type !== \"ObjectExpression\") return undefined\n\n const meta: TranslateOptions = {}\n\n for (const property of node.properties as Array<{\n type: string\n key?: { type: string; name?: string; value?: unknown }\n value?: Argument\n }>) {\n if (\n (property.type === \"ObjectProperty\" || property.type === \"Property\") &&\n ((property.key?.type === \"Identifier\" && (property.key.name === \"context\" || property.key.name === \"id\")) ||\n (property.key?.type === \"Literal\" && (property.key.value === \"context\" || property.key.value === \"id\"))) &&\n property.value &&\n isStringLiteral(property.value)\n ) {\n const key = property.key?.type === \"Identifier\" ? property.key.name : property.key?.value\n if (key === \"context\" || key === \"id\") meta[key] = property.value.value\n }\n }\n\n return Object.keys(meta).length > 0 ? meta : undefined\n}\n\nfunction getCallMetaArgument(args: Argument[]) {\n return getMetaArgument(isTranslateOptionsArgument(args[1]) ? args[1] : args[2])\n}\n\nfunction createCallOptionsEdit(code: string, args: Argument[], id: string) {\n const valuesArg = args[1]\n const optionsArg = isTranslateOptionsArgument(valuesArg) ? valuesArg : args[2]\n\n if (!optionsArg) {\n return {\n start: (valuesArg ?? args[0]!).end,\n end: (valuesArg ?? args[0]!).end,\n replacement: `, { id: ${JSON.stringify(id)} }`,\n }\n }\n\n if (isStringLiteral(optionsArg)) {\n const contextValue = code.slice(optionsArg.start, optionsArg.end)\n return {\n start: optionsArg.start,\n end: optionsArg.end,\n replacement: `{ id: ${JSON.stringify(id)}, context: ${contextValue} }`,\n }\n }\n\n if (optionsArg.type !== \"ObjectExpression\") return undefined\n if (hasObjectProperty(optionsArg, \"id\")) return undefined\n\n const objectSource = code.slice(optionsArg.start, optionsArg.end)\n const innerSource = objectSource.slice(1, -1)\n const replacement =\n innerSource.trim().length > 0 ? `{ id: ${JSON.stringify(id)},${innerSource} }` : `{ id: ${JSON.stringify(id)} }`\n\n return {\n start: optionsArg.start,\n end: optionsArg.end,\n replacement,\n }\n}\n\nfunction isTranslateOptionsArgument(node?: Argument) {\n if (!node) return false\n if (isStringLiteral(node)) return true\n if (node.type !== \"ObjectExpression\") return false\n\n return (node.properties as Array<unknown>).every((entry) => {\n const property = entry as\n | {\n type?: string\n key?: { type?: string; name?: string; value?: unknown }\n }\n | undefined\n\n if (property?.type !== \"ObjectProperty\" && property?.type !== \"Property\") return false\n\n return (\n (property.key?.type === \"Identifier\" && (property.key.name === \"context\" || property.key.name === \"id\")) ||\n (property.key?.type === \"Literal\" && (property.key.value === \"context\" || property.key.value === \"id\"))\n )\n })\n}\n\nfunction getJSXStringAttribute(attributes: Array<unknown>, name: string) {\n for (const attr of attributes as Array<{\n type: string\n name?: { type: string; name?: string }\n value?: { type: string; value?: unknown } | null\n }>) {\n if (\n attr.type === \"JSXAttribute\" &&\n attr.name?.type === \"JSXIdentifier\" &&\n attr.name.name === name &&\n attr.value?.type === \"Literal\" &&\n typeof attr.value.value === \"string\"\n ) {\n return attr.value.value as string\n }\n }\n}\n\nfunction hasJSXAttribute(attributes: Array<unknown>, name: string) {\n return attributes.some((attr) => {\n const attribute = attr as\n | {\n type?: string\n name?: { type?: string; name?: string }\n }\n | undefined\n\n return attribute?.type === \"JSXAttribute\" && attribute.name?.type === \"JSXIdentifier\" && attribute.name.name === name\n })\n}\n\nfunction hasObjectProperty(node: { properties: Array<unknown> }, name: string) {\n return node.properties.some((entry) => {\n const property = entry as\n | {\n type?: string\n key?: { type?: string; name?: string; value?: unknown }\n }\n | undefined\n\n if (property?.type !== \"ObjectProperty\" && property?.type !== \"Property\") return false\n return (\n (property.key?.type === \"Identifier\" && property.key.name === name) ||\n (property.key?.type === \"Literal\" && property.key.value === name)\n )\n })\n}\n\ninterface ExtractionResult {\n message: string\n placeholders: string[]\n values: Array<{ name: string; value: string }>\n valid: boolean\n}\n\nfunction extractJSXChildren(code: string, children: Array<JSXChild>): ExtractionResult {\n const parts: string[] = []\n const placeholders: string[] = []\n const values: Array<{ name: string; value: string }> = []\n\n for (const child of children) {\n switch (child.type) {\n case \"JSXText\":\n parts.push(child.value)\n break\n\n case \"JSXElement\": {\n const name = child.openingElement.name\n if (name.type !== \"JSXIdentifier\" || name.name !== \"Var\") {\n return { message: \"\", placeholders: [], values: [], valid: false }\n }\n\n const entry = getVarEntry(code, child)\n if (!entry) return { message: \"\", placeholders: [], values: [], valid: false }\n\n placeholders.push(entry.name)\n values.push(entry)\n parts.push(`{${entry.name}}`)\n break\n }\n\n case \"JSXExpressionContainer\":\n if (child.expression.type !== \"JSXEmptyExpression\") {\n return { message: \"\", placeholders: [], values: [], valid: false }\n }\n break\n\n default:\n break\n }\n }\n\n const message = parts.join(\"\").replace(/\\s+/g, \" \").trim()\n return { message, placeholders, values, valid: message.length > 0 }\n}\n\nfunction getVarEntry(\n code: string,\n node: { openingElement: { attributes: Array<unknown> }; children: Array<JSXChild> },\n): { name: string; value: string } | undefined {\n const explicitName = getJSXStringAttribute(node.openingElement.attributes as Array<unknown>, \"name\")\n const explicitValue = getJSXExpressionAttributeSource(code, node.openingElement.attributes as Array<unknown>, \"value\")\n const childValue = getVarChildrenSource(code, node.children)\n if (explicitName && explicitValue) return { name: explicitName, value: explicitValue }\n if (explicitName && childValue) return { name: explicitName, value: childValue }\n if (explicitName) return { name: explicitName, value: JSON.stringify(explicitName) }\n\n const customProp = getSingleJSXAttributeEntry(code, node.openingElement.attributes as Array<unknown>)\n if (customProp) return customProp\n\n const childIdentifier = getVarChildIdentifier(node.children)\n return childIdentifier ? { name: childIdentifier, value: childIdentifier } : undefined\n}\n\nfunction getSingleJSXAttributeEntry(code: string, attributes: Array<unknown>): { name: string; value: string } | undefined {\n const keys = attributes.flatMap((attr) => {\n const attribute = attr as\n | {\n type?: string\n name?: { type?: string; name?: string }\n value?: { type?: string; value?: unknown; expression?: { start: number; end: number } } | null\n }\n | undefined\n\n if (attribute?.type !== \"JSXAttribute\" || attribute.name?.type !== \"JSXIdentifier\" || !attribute.name.name) return []\n const value = getJSXAttributeValueSource(code, attribute.value)\n return value ? [{ name: attribute.name.name, value }] : []\n })\n\n return keys.length === 1 ? keys[0] : undefined\n}\n\nfunction getJSXExpressionAttributeSource(code: string, attributes: Array<unknown>, name: string) {\n for (const attr of attributes as Array<{\n type: string\n name?: { type: string; name?: string }\n value?: { type?: string; expression?: { start: number; end: number } } | null\n }>) {\n if (attr.type !== \"JSXAttribute\" || attr.name?.type !== \"JSXIdentifier\" || attr.name.name !== name) continue\n if (attr.value?.type !== \"JSXExpressionContainer\" || !attr.value.expression) return undefined\n return code.slice(attr.value.expression.start, attr.value.expression.end)\n }\n}\n\nfunction getJSXAttributeValueSource(\n code: string,\n value?: { type?: string; value?: unknown; expression?: { start: number; end: number } } | null,\n) {\n if (!value) return undefined\n if (value.type === \"JSXExpressionContainer\" && value.expression) {\n return code.slice(value.expression.start, value.expression.end)\n }\n if (value.type === \"Literal\" && typeof value.value === \"string\") {\n return JSON.stringify(value.value)\n }\n}\n\nfunction getVarChildIdentifier(children: Array<JSXChild>) {\n const meaningfulChildren = children.filter((child) => !(child.type === \"JSXText\" && child.value.trim().length === 0))\n if (meaningfulChildren.length !== 1) return undefined\n\n const [child] = meaningfulChildren\n if (!child || child.type !== \"JSXExpressionContainer\" || child.expression.type !== \"Identifier\") return undefined\n return child.expression.name\n}\n\nfunction getVarChildrenSource(code: string, children: Array<JSXChild>) {\n const meaningfulChildren = children.filter((child) => !(child.type === \"JSXText\" && child.value.trim().length === 0))\n if (meaningfulChildren.length === 0) return undefined\n\n if (meaningfulChildren.length === 1) {\n const [child] = meaningfulChildren\n if (!child) return undefined\n if (child.type === \"JSXExpressionContainer\" && child.expression.type !== \"JSXEmptyExpression\") {\n return code.slice(child.expression.start, child.expression.end)\n }\n }\n\n const [first] = meaningfulChildren\n const last = meaningfulChildren.at(-1)\n if (!first || !last) return undefined\n return `<>${code.slice(first.start, last.end)}</>`\n}\n","import { extname } from \"node:path\"\n\nimport type { SourceAnalysis, SourceMarkers } from \"./extractors/types.js\"\n\nimport { analyzeSvelteSourceFile } from \"./extractors/svelte.js\"\nimport { analyzeTypeScriptSourceFile } from \"./extractors/typescript.js\"\n\nexport type { SourceAnalysis, SourceEdit } from \"./extractors/types.js\"\n\n/** Extracts messages and source edits from a framework source file. */\nexport function analyzeSourceFile(code: string, filename: string, markers: SourceMarkers): SourceAnalysis {\n if (extname(filename) === \".svelte\") return analyzeSvelteSourceFile(code, filename, markers)\n return analyzeTypeScriptSourceFile(code, filename, markers)\n}\n","import { execFileSync } from \"node:child_process\"\nimport { readFileSync } from \"node:fs\"\nimport type { IncomingMessage, ServerResponse } from \"node:http\"\nimport type { ViteDevServer } from \"vite\"\n\nimport type { BetterTranslateRuntimeOptions, ManifestEntry, MessageManifest, RuntimeMessages } from \"../types.js\"\n\nexport const DEFAULT_LOCAL_EDITOR_PATH = \"/__better-translation\"\n\nconst CYAN = \"\\x1b[36m\"\nconst PREFIX = \"\\x1b[36m[better-translation]\\x1b[0m\"\nconst RESET = \"\\x1b[0m\"\n\ntype LocalEditorOptions = {\n open: boolean\n path: string\n}\n\nexport type LocalEditorRuntimeContext = {\n defaultLocale: string\n isUntranslatedLocaleValue: (value: string, entry: Pick<ManifestEntry, \"defaultMessage\">) => boolean\n locales: string[]\n log: (message: string) => void\n manifest: MessageManifest\n readLocaleMessages: (locale: string) => RuntimeMessages\n writeLocaleMessages: (locale: string, localeMessages: RuntimeMessages) => void\n}\n\nexport function getLocalEditorOptions({\n isDev,\n runtime,\n}: {\n isDev: boolean\n runtime: BetterTranslateRuntimeOptions\n}): LocalEditorOptions | null {\n if (!isDev || runtime.type !== \"local\") return null\n const editor = runtime.editor\n if (!editor) return null\n if (editor === true) return { path: DEFAULT_LOCAL_EDITOR_PATH, open: false }\n if (editor.enabled === false) return null\n return {\n path: normalizeLocalEditorPath(editor.path ?? DEFAULT_LOCAL_EDITOR_PATH),\n open: editor.open ?? false,\n }\n}\n\nexport function configureLocalEditor(server: ViteDevServer, context: LocalEditorRuntimeContext, options: LocalEditorOptions) {\n const editorPath = options.path\n server.middlewares.use(async (request, response, next) => {\n const requestUrl = new URL(request.url ?? \"/\", \"http://better-translation.local\")\n const pathname = stripTrailingSlash(requestUrl.pathname)\n if (pathname !== editorPath && !pathname.startsWith(`${editorPath}/`)) {\n next()\n return\n }\n\n try {\n if (pathname === editorPath || pathname === `${editorPath}/index.html`) {\n sendHtml(response, createLocalEditorHtml(editorPath))\n return\n }\n\n if (pathname === `${editorPath}/client.js`) {\n sendJavaScript(response, readLocalEditorAsset(\"local-editor.js\"))\n return\n }\n\n if (pathname === `${editorPath}/style.css`) {\n sendCss(response, readLocalEditorAsset(\"style.css\"))\n return\n }\n\n if (pathname.startsWith(`${editorPath}/local-editor-assets/`)) {\n const assetName = pathname.slice(`${editorPath}/local-editor-assets/`.length)\n sendAsset(response, assetName)\n return\n }\n\n if (pathname === `${editorPath}/api/messages` && request.method === \"GET\") {\n sendJson(\n response,\n getLocalEditorMessages(context, {\n q: requestUrl.searchParams.get(\"q\") ?? undefined,\n view: parseLocalEditorView(requestUrl.searchParams.get(\"view\")),\n }),\n )\n return\n }\n\n const detailMatch = pathname.match(new RegExp(`^${escapeRegExp(editorPath)}/api/messages/([^/]+)$`))\n if (detailMatch?.[1] && request.method === \"GET\") {\n sendJson(response, getLocalEditorMessageDetail(context, decodeURIComponent(detailMatch[1])))\n return\n }\n\n const updateMatch = pathname.match(new RegExp(`^${escapeRegExp(editorPath)}/api/messages/([^/]+)/locales/([^/]+)$`))\n if (updateMatch?.[1] && updateMatch[2] && request.method === \"PATCH\") {\n const body = await readJsonRequest(request)\n const value =\n typeof body === \"object\" && body !== null && \"value\" in body && typeof body.value === \"string\" ? body.value.trim() : \"\"\n if (!value) {\n sendJson(response, { error: \"Locale value is required.\" }, 400)\n return\n }\n updateLocalEditorLocaleValue(context, {\n locale: decodeURIComponent(updateMatch[2]),\n lookupId: decodeURIComponent(updateMatch[1]),\n value,\n })\n sendJson(response, getLocalEditorMessageDetail(context, decodeURIComponent(updateMatch[1])))\n return\n }\n\n sendJson(response, { error: \"Not found.\" }, 404)\n } catch (error) {\n sendJson(response, { error: error instanceof Error ? error.message : \"Local editor request failed.\" }, 500)\n }\n })\n\n server.httpServer?.once(\"listening\", () => {\n const localUrl = server.resolvedUrls?.local[0]\n const editorUrl = localUrl ? new URL(editorPath, localUrl).toString() : editorPath\n context.log(`${PREFIX} Local editor: ${CYAN}${editorUrl}${RESET}`)\n if (options.open) openLocalEditor(editorUrl)\n })\n}\n\nfunction getLocalEditorMessages(\n context: LocalEditorRuntimeContext,\n { q, view }: { q?: string; view: \"all\" | \"needs-value\" | \"manual\" | \"ai\" },\n) {\n const query = q?.trim().toLowerCase()\n const localeMessagesByLocale = readEditableLocaleMessages(context)\n const summaries = Object.entries(context.manifest)\n .sort(compareManifestEntryIds)\n .map(([id, entry]) => getLocalEditorMessageSummary(context, localeMessagesByLocale, id, entry))\n const filteredMessages = summaries.filter((message) => {\n if (query) {\n const searchableValues = [\n message.defaultMessage,\n ...Object.values(localeMessagesByLocale).map((localeMessages) => localeMessages[message.id] ?? \"\"),\n ]\n if (!searchableValues.some((value) => value.toLowerCase().includes(query))) return false\n }\n if (view === \"all\") return true\n if (view === \"needs-value\") return message.done < message.total\n if (view === \"ai\") return false\n return Object.values(localeMessagesByLocale).some((localeMessages) => localeMessages[message.id] !== undefined)\n })\n\n return {\n config: {\n appLocale: context.defaultLocale,\n defaultLocale: context.defaultLocale,\n locales: context.locales,\n },\n incompleteCount: summaries.filter((message) => message.done < message.total).length,\n messages: filteredMessages.map(({ defaultMessage, done, id, lookupId, placeholders, total }) => ({\n defaultMessage,\n done,\n id,\n lookupId,\n placeholders,\n total,\n })),\n }\n}\n\nfunction readEditableLocaleMessages(context: LocalEditorRuntimeContext) {\n return Object.fromEntries(\n context.locales\n .filter((locale) => locale !== context.defaultLocale)\n .map((locale) => [locale, context.readLocaleMessages(locale)]),\n )\n}\n\nfunction getLocalEditorMessageSummary(\n context: LocalEditorRuntimeContext,\n localeMessagesByLocale: Record<string, RuntimeMessages>,\n id: string,\n entry: ManifestEntry,\n) {\n const editableLocales = context.locales.filter((locale) => locale !== context.defaultLocale)\n\n return {\n defaultMessage: entry.defaultMessage,\n done: editableLocales.filter((locale) => localeMessagesByLocale[locale]?.[id] !== undefined).length,\n id,\n lookupId: id,\n placeholders: entry.placeholders,\n total: editableLocales.length,\n }\n}\n\nfunction getLocalEditorMessageDetail(context: LocalEditorRuntimeContext, id: string) {\n const entry = context.manifest[id]\n if (!entry) throw new Error(\"Unknown Message.\")\n const localeValues = Object.fromEntries(\n context.locales.map((locale) => {\n if (locale === context.defaultLocale) {\n return [locale, { value: entry.defaultMessage, source: \"default\", hasValue: true }]\n }\n\n const localeMessages = context.readLocaleMessages(locale)\n const value = localeMessages[id]\n const hasValue = value !== undefined\n return [locale, { value: value ?? entry.defaultMessage, source: hasValue ? \"manual\" : \"default\", hasValue }]\n }),\n )\n const editableValues = Object.entries(localeValues).filter(([locale]) => locale !== context.defaultLocale)\n\n return {\n context: typeof entry.meta.context === \"string\" ? entry.meta.context : null,\n defaultMessage: entry.defaultMessage,\n done: editableValues.filter(([, value]) => value.hasValue).length,\n id,\n localeValues,\n lookupId: id,\n placeholders: entry.placeholders,\n sources: entry.sources,\n total: editableValues.length,\n }\n}\n\nfunction updateLocalEditorLocaleValue(\n context: LocalEditorRuntimeContext,\n { locale, lookupId, value }: { locale: string; lookupId: string; value: string },\n) {\n if (locale === context.defaultLocale) throw new Error(\"Default locale Messages come from source code.\")\n if (!context.locales.includes(locale)) throw new Error(\"Unknown Locale.\")\n if (!context.manifest[lookupId]) throw new Error(\"Unknown Message.\")\n\n const localeMessages = context.readLocaleMessages(locale)\n localeMessages[lookupId] = value\n context.writeLocaleMessages(locale, localeMessages)\n}\n\nfunction createLocalEditorHtml(editorPath: string) {\n return [\n \"<!doctype html>\",\n '<html lang=\"en\">',\n \"<head>\",\n '<meta charset=\"utf-8\" />',\n '<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />',\n \"<title>Better Translation Local Editor</title>\",\n \"</head>\",\n \"<body>\",\n '<div id=\"root\"></div>',\n `<link rel=\"stylesheet\" href=\"${editorPath}/style.css\" />`,\n `<script defer src=\"${editorPath}/client.js\"></script>`,\n \"</body>\",\n \"</html>\",\n ].join(\"\\n\")\n}\n\nfunction sendHtml(response: ServerResponse, html: string) {\n response.statusCode = 200\n response.setHeader(\"content-type\", \"text/html; charset=utf-8\")\n response.end(html)\n}\n\nfunction sendJavaScript(response: ServerResponse, code: string) {\n response.statusCode = 200\n response.setHeader(\"content-type\", \"application/javascript; charset=utf-8\")\n response.end(code)\n}\n\nfunction sendCss(response: ServerResponse, css: string) {\n response.statusCode = 200\n response.setHeader(\"content-type\", \"text/css; charset=utf-8\")\n response.end(css)\n}\n\nfunction sendAsset(response: ServerResponse, assetName: string) {\n if (!/^[\\w.-]+$/.test(assetName)) {\n sendJson(response, { error: \"Not found.\" }, 404)\n return\n }\n\n response.statusCode = 200\n response.setHeader(\"content-type\", getAssetContentType(assetName))\n response.end(readFileSync(new URL(`./local-editor-assets/${assetName}`, import.meta.url)))\n}\n\nfunction sendJson(response: ServerResponse, payload: unknown, statusCode = 200) {\n response.statusCode = statusCode\n response.setHeader(\"content-type\", \"application/json; charset=utf-8\")\n response.end(JSON.stringify(payload))\n}\n\nasync function readJsonRequest(request: IncomingMessage) {\n const chunks: Buffer[] = []\n for await (const chunk of request) {\n chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk))\n }\n if (chunks.length === 0) return null\n return JSON.parse(Buffer.concat(chunks).toString(\"utf-8\")) as unknown\n}\n\nfunction parseLocalEditorView(value: string | null): \"all\" | \"needs-value\" | \"manual\" | \"ai\" {\n if (value === \"needs-value\" || value === \"manual\" || value === \"ai\") return value\n return \"all\"\n}\n\nfunction normalizeLocalEditorPath(path: string) {\n const withLeadingSlash = path.startsWith(\"/\") ? path : `/${path}`\n return stripTrailingSlash(withLeadingSlash)\n}\n\nfunction stripTrailingSlash(path: string) {\n return path.length > 1 ? path.replace(/\\/+$/, \"\") : path\n}\n\nfunction escapeRegExp(value: string) {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\")\n}\n\nfunction openLocalEditor(url: string) {\n try {\n if (process.platform === \"darwin\") execFileSync(\"open\", [url], { stdio: \"ignore\" })\n else if (process.platform === \"win32\") execFileSync(\"cmd\", [\"/c\", \"start\", \"\", url], { stdio: \"ignore\" })\n else execFileSync(\"xdg-open\", [url], { stdio: \"ignore\" })\n } catch {\n // Opening the browser is a convenience only.\n }\n}\n\nfunction readLocalEditorAsset(fileName: \"local-editor.js\" | \"style.css\") {\n return readFileSync(new URL(`./${fileName}`, import.meta.url), \"utf-8\")\n}\n\nfunction getAssetContentType(assetName: string) {\n if (assetName.endsWith(\".woff2\")) return \"font/woff2\"\n if (assetName.endsWith(\".woff\")) return \"font/woff\"\n if (assetName.endsWith(\".css\")) return \"text/css; charset=utf-8\"\n if (assetName.endsWith(\".js\")) return \"application/javascript; charset=utf-8\"\n if (assetName.endsWith(\".svg\")) return \"image/svg+xml\"\n return \"application/octet-stream\"\n}\n\nfunction compareManifestEntryIds([left]: [string, ManifestEntry], [right]: [string, ManifestEntry]) {\n return left.localeCompare(right)\n}\n","import { execFileSync } from \"node:child_process\"\nimport { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from \"node:fs\"\nimport { dirname, relative, resolve } from \"node:path\"\nimport { normalizePath, type Plugin, type ResolvedConfig } from \"vite\"\n\nimport type {\n BetterTranslatePluginOptions,\n BetterTranslateRuntimeOptions,\n ExtractedMessage,\n ManifestEntry,\n MessageManifest,\n MessageManifestFile,\n MessageSource,\n RuntimeMessages,\n TranslateFn,\n TranslateMessage,\n TranslationCache,\n} from \"./types.js\"\n\nimport { createEmptyCache, getCacheKey, loadCache, saveCache } from \"./cache.js\"\nimport { analyzeSourceFile } from \"./extractor.js\"\nimport { configureLocalEditor, getLocalEditorOptions } from \"./local-editor/server.js\"\nimport { serializeMeta } from \"./message-id.js\"\n\nconst PREFIX = \"\\x1b[36m[better-translation]\\x1b[0m\"\nconst DIM = \"\\x1b[2m\"\nconst RESET = \"\\x1b[0m\"\nconst BOLD = \"\\x1b[1m\"\nconst CYAN = \"\\x1b[36m\"\nconst REMOTE_API_BASE_URL = \"https://better-translation.vercel.app\"\nconst DEFAULT_REMOTE_API_KEY_ENV = \"BETTER_TRANSLATION_API_KEY\"\nconst DEFAULT_REMOTE_BRANCH = \"main\"\nconst DEFAULT_CACHE_DIR = \".cache/better-translation\"\nconst DEFAULT_TRANSLATION_CACHE_FILE = `${DEFAULT_CACHE_DIR}/cache.json`\nconst DEFAULT_PRIVATE_MANIFEST_FILE = `${DEFAULT_CACHE_DIR}/manifest.json`\nconst DEFAULT_REMOTE_OFFLINE_OUTPUT_DIR = `${DEFAULT_CACHE_DIR}/runtime`\nconst DEFAULT_LOCAL_OUTPUT_DIR = \"src/lib/bt\"\nconst DEFAULT_PUBLIC_OUTPUT_SUBDIR = \"bt\"\nconst DEFAULT_PUBLIC_BASE_PATH = \"/bt\"\nconst DEFAULT_ROOT_DIR = \"src\"\nconst DEFAULT_SCAN_EXTENSIONS = [\".ts\", \".tsx\", \".js\", \".jsx\", \".svelte\"]\nconst VIRTUAL_MESSAGES_MODULE_ID = \"better-translation/messages\"\nconst RESOLVED_VIRTUAL_MESSAGES_MODULE_ID = `\\0${VIRTUAL_MESSAGES_MODULE_ID}`\nconst CALL_MARKERS = [\"t\", \"useT\"]\nconst COMPONENT_MARKERS = [\"T\"]\nconst LOCALES_SUBDIR = \"locales\"\n\ninterface SyncResult {\n manifestChanged: boolean\n localeMessagesChanged: boolean\n}\n\nfunction formatLocale(locale: string) {\n return locale.toUpperCase()\n}\n\nfunction formatLocales(locales: string[]) {\n return locales.map(formatLocale).join(\", \")\n}\n\n/** Scans source files for translatable messages and keeps locale JSON files in sync. */\nexport function betterTranslation(options: BetterTranslatePluginOptions): Plugin {\n const {\n locales,\n defaultLocale = locales[0] ?? \"en\",\n rootDir = DEFAULT_ROOT_DIR,\n cacheFile = DEFAULT_TRANSLATION_CACHE_FILE,\n logging = true,\n runtime,\n } = options\n const configuredRuntime = normalizeRuntimeOptions(runtime)\n const manifest: MessageManifest = {}\n const fileMessages = new Map<string, ExtractedMessage[]>()\n let cache: TranslationCache = createEmptyCache()\n let resolvedRuntime = configuredRuntime\n let usesLocalStorage = shouldUseLocalStorage(configuredRuntime, false)\n let resolvedTranslate: TranslateFn | undefined = configuredRuntime.type === \"local\" ? configuredRuntime.translate : undefined\n let localesDir =\n configuredRuntime.type === \"local\" ? (configuredRuntime.output ?? DEFAULT_LOCAL_OUTPUT_DIR) : DEFAULT_LOCAL_OUTPUT_DIR\n let publicBasePath =\n configuredRuntime.type === \"local\" && configuredRuntime.target === \"public\"\n ? (configuredRuntime.basePath ?? DEFAULT_PUBLIC_BASE_PATH)\n : DEFAULT_PUBLIC_BASE_PATH\n let remoteUrl = configuredRuntime.type === \"remote\" ? (configuredRuntime.endpoint ?? REMOTE_API_BASE_URL) : REMOTE_API_BASE_URL\n let root = \"\"\n let isDev = false\n let translateTimer: ReturnType<typeof setTimeout> | null = null\n let remoteSyncTimer: ReturnType<typeof setTimeout> | null = null\n let lastSyncedRemoteManifestSignature: string | null = null\n let sourceRoots: string[] = []\n\n function log(message: string) {\n if (logging) console.log(message)\n }\n\n async function syncRemote() {\n if (resolvedRuntime.type !== \"remote\") return\n\n const payload = {\n defaultLocale,\n locales,\n messages: buildMessageManifest(),\n }\n const signature = JSON.stringify(payload)\n if (lastSyncedRemoteManifestSignature === signature) return\n\n const apiKey = resolveRemoteSyncApiKey()\n const target = formatRemoteManifestTarget(resolvedRuntime, remoteUrl)\n if (!apiKey) {\n throw new Error(\n [\n `${PREFIX} remote Manifest sync requires a Project API key`,\n `set ${DEFAULT_REMOTE_API_KEY_ENV} or pass runtime.apiKey in the Vite plugin config`,\n `target: ${target}`,\n ].join(\"\\n\"),\n )\n }\n\n let response: Response\n try {\n response = await fetch(target, {\n method: \"POST\",\n headers: {\n authorization: `Bearer ${apiKey}`,\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify(payload),\n })\n } catch (error) {\n throw new Error(formatRemoteSyncNetworkError(target, error))\n }\n\n const body = await response.text()\n\n if (!response.ok) {\n throw new Error(formatRemoteSyncError(response, target, body))\n }\n\n const result = parseRemoteSyncResult(body)\n if (result?.changed) log(`${PREFIX} ${BOLD}Synced${RESET} Messages -> ${CYAN}${formatRuntime(resolvedRuntime)}${RESET}`)\n lastSyncedRemoteManifestSignature = signature\n }\n\n function resolveRemoteSyncApiKey() {\n const explicitApiKey = resolvedRuntime.type === \"remote\" ? resolvedRuntime.apiKey?.trim() : null\n if (explicitApiKey) return explicitApiKey\n\n const envApiKey = process.env[DEFAULT_REMOTE_API_KEY_ENV]?.trim()\n return envApiKey || null\n }\n\n function buildMessageManifest(): MessageManifestFile {\n return Object.fromEntries(\n Object.entries(manifest)\n .sort(compareManifestEntryIds)\n .map(([id, entry]) => [\n id,\n {\n defaultMessage: entry.defaultMessage,\n meta: entry.meta,\n placeholders: entry.placeholders,\n sources: entry.sources.length > 1 ? [...entry.sources].sort(compareMessageSources) : entry.sources,\n },\n ]),\n )\n }\n\n function shouldScanFile(id: string) {\n const cleanId = id.split(\"?\", 1)[0] ?? id\n if (cleanId.includes(\"node_modules\")) return false\n const extension = DEFAULT_SCAN_EXTENSIONS.find((ext) => cleanId.endsWith(ext))\n if (!extension) return false\n return sourceRoots.some(\n (sourceRoot) => cleanId === sourceRoot || cleanId.startsWith(`${sourceRoot}/`) || cleanId.startsWith(`${sourceRoot}\\\\`),\n )\n }\n\n function getPrivateManifestPath() {\n return resolve(root, DEFAULT_PRIVATE_MANIFEST_FILE)\n }\n\n function getLocalesDirPath() {\n return resolve(root, localesDir, LOCALES_SUBDIR)\n }\n\n function getLocalePath(locale: string) {\n return resolve(getLocalesDirPath(), `${locale}.json`)\n }\n\n function readLocaleMessages(locale: string): RuntimeMessages {\n const path = getLocalePath(locale)\n if (!existsSync(path)) return {}\n\n try {\n const input = JSON.parse(readFileSync(path, \"utf-8\")) as unknown\n return normalizeLocaleMessages(input)\n } catch {\n return {}\n }\n }\n\n function writePrivateManifest() {\n if (!usesLocalStorage) return\n const path = getPrivateManifestPath()\n const dir = dirname(path)\n if (!existsSync(dir)) mkdirSync(dir, { recursive: true })\n writeFileIfChanged(path, JSON.stringify(buildMessageManifest(), null, 2) + \"\\n\")\n }\n\n function buildLocalLocaleMessages(locale: string, manifestEntries: Array<[string, ManifestEntry]>): RuntimeMessages {\n const existingMessages = readLocaleMessages(locale)\n const messages: RuntimeMessages = {}\n\n if (locale === defaultLocale) {\n for (const [id, entry] of manifestEntries) {\n messages[id] = entry.defaultMessage\n }\n return messages\n }\n\n for (const [id, entry] of manifestEntries) {\n if (Object.hasOwn(messages, id)) continue\n const existingMessage = existingMessages[id]\n const cachedMessage = getFreshCachedMessage(id, locale)\n\n if (existingMessage !== undefined && !isUntranslatedLocaleValue(existingMessage, entry)) {\n messages[id] = existingMessage\n continue\n }\n\n if (cachedMessage !== undefined) messages[id] = cachedMessage\n else if (shouldWriteDefaultLocaleFallback()) messages[id] = entry.defaultMessage\n }\n return messages\n }\n\n function writeLocaleFilesToDisk() {\n if (!usesLocalStorage) return\n const dir = getLocalesDirPath()\n if (!existsSync(dir)) mkdirSync(dir, { recursive: true })\n const manifestEntries = Object.entries(manifest).sort(compareManifestEntryIds)\n for (const locale of locales) {\n writeFileIfChanged(\n resolve(dir, `${locale}.json`),\n JSON.stringify(buildLocalLocaleMessages(locale, manifestEntries), null, 2) + \"\\n\",\n )\n }\n }\n\n function getMissingMessagesByLocale() {\n const missingByLocale = new Map<string, TranslateMessage[]>()\n const manifestEntries = Object.entries(manifest).sort(compareManifestEntryIds)\n\n for (const locale of locales) {\n if (locale === defaultLocale) continue\n const existingMessages = readLocaleMessages(locale)\n for (const [id, entry] of manifestEntries) {\n const existingMessage = existingMessages[id]\n const hasExistingMessage = existingMessage !== undefined && !isUntranslatedLocaleValue(existingMessage, entry)\n if (!hasExistingMessage && getFreshCachedMessage(id, locale) === undefined) {\n const misses = missingByLocale.get(locale) ?? []\n misses.push({\n id,\n text: entry.defaultMessage,\n meta: entry.meta,\n placeholders: entry.placeholders,\n sources: entry.sources,\n })\n missingByLocale.set(locale, misses)\n }\n }\n }\n\n return missingByLocale\n }\n\n function assertLocalBuildTranslationsComplete() {\n const expectedIds = new Set(Object.keys(manifest))\n const issues: string[] = []\n\n for (const locale of locales) {\n const localePath = getLocalePath(locale)\n if (!existsSync(localePath)) {\n issues.push(`- ${locale}: missing file at ${relative(root, localePath)}`)\n continue\n }\n\n const localeMessages = readLocaleMessages(locale)\n const missingIds = [...expectedIds].filter((id) => !Object.hasOwn(localeMessages, id))\n const orphanIds = Object.keys(localeMessages).filter((id) => !expectedIds.has(id))\n\n if (locale === defaultLocale) {\n const staleIds = [...expectedIds].filter((id) => localeMessages[id] !== manifest[id]!.defaultMessage)\n if (missingIds.length > 0) issues.push(formatLocaleIssue(locale, \"missing\", missingIds))\n if (orphanIds.length > 0) issues.push(formatLocaleIssue(locale, \"orphaned\", orphanIds))\n if (staleIds.length > 0) issues.push(formatLocaleIssue(locale, \"outdated default messages\", staleIds))\n continue\n }\n\n if (missingIds.length > 0) issues.push(formatLocaleIssue(locale, \"missing\", missingIds))\n if (orphanIds.length > 0) issues.push(formatLocaleIssue(locale, \"orphaned\", orphanIds))\n }\n\n if (issues.length === 0) return\n\n throw new Error(\n [\n `${PREFIX} committed locale artifacts are out of sync for local production build`,\n `local production builds are check-only and never regenerate locale files`,\n `run the dev workflow to regenerate locale artifacts and commit the result`,\n ...issues,\n ].join(\"\\n\"),\n )\n }\n\n async function translateMissingMessages() {\n if (!resolvedTranslate) return false\n const missingByLocale = getMissingMessagesByLocale()\n\n const totalMisses = [...missingByLocale.values()].reduce((count, misses) => count + misses.length, 0)\n if (totalMisses === 0) return false\n\n const missLocales = [...missingByLocale.keys()]\n log(\n `${PREFIX} ${BOLD}Translating${RESET} ${CYAN}${totalMisses}${RESET} ${totalMisses === 1 ? \"Message\" : \"Messages\"} -> ${CYAN}${formatLocales(missLocales)}${RESET}`,\n )\n\n let translatedCount = 0\n for (const [locale, misses] of missingByLocale) {\n const result = await resolvedTranslate(misses, locale)\n\n for (const miss of misses) {\n const translated = result[miss.id]?.trim()\n if (!translated) continue\n cache.entries[getCacheKey(miss.id, locale)] = {\n sourceText: miss.text,\n meta: miss.meta,\n locale,\n translation: translated,\n timestamp: Date.now(),\n }\n translatedCount += 1\n }\n }\n\n log(\n `${PREFIX} ${BOLD}Translated${RESET} ${CYAN}${translatedCount}${RESET}/${CYAN}${totalMisses}${RESET} ${totalMisses === 1 ? \"Message\" : \"Messages\"} -> ${CYAN}${formatLocales(missLocales)}${RESET}`,\n )\n\n return true\n }\n\n function getFreshCachedMessage(id: string, locale: string) {\n const entry = manifest[id]\n const cachedMessage = cache.entries[getCacheKey(id, locale)]\n if (!entry || !cachedMessage) return undefined\n if (cachedMessage.sourceText !== entry.defaultMessage) return undefined\n if (serializeMeta(cachedMessage.meta) !== serializeMeta(entry.meta)) return undefined\n return cachedMessage.translation\n }\n\n function isUntranslatedLocaleValue(value: string, entry: Pick<ManifestEntry, \"defaultMessage\">) {\n return resolvedTranslate !== undefined && value.trim() === entry.defaultMessage.trim()\n }\n\n function shouldWriteDefaultLocaleFallback() {\n return resolvedTranslate !== undefined || isRemoteOfflineDev(resolvedRuntime, isDev)\n }\n\n function scheduleDevTranslation() {\n if (!resolvedTranslate) return\n if (!isDev) return\n if (translateTimer) clearTimeout(translateTimer)\n translateTimer = setTimeout(async () => {\n const translated = await translateMissingMessages()\n if (translated) saveCache(resolve(root, cacheFile), cache)\n writeLocaleFilesToDisk()\n writePrivateManifest()\n }, 1000)\n }\n\n function scheduleDevRemoteSync() {\n if (usesLocalStorage || !isDev) return\n if (remoteSyncTimer) clearTimeout(remoteSyncTimer)\n remoteSyncTimer = setTimeout(() => {\n void syncRemote().catch((error) => console.error(error instanceof Error ? error.message : error))\n }, 1000)\n }\n\n function writeLocaleMessages(locale: string, localeMessages: RuntimeMessages) {\n const dir = getLocalesDirPath()\n if (!existsSync(dir)) mkdirSync(dir, { recursive: true })\n\n const messages: RuntimeMessages = {}\n for (const [id, entry] of Object.entries(manifest).sort(compareManifestEntryIds)) {\n if (locale === defaultLocale) {\n messages[id] = entry.defaultMessage\n continue\n }\n\n const existingMessage = localeMessages[id]\n const cachedMessage = getFreshCachedMessage(id, locale)\n if (existingMessage !== undefined) messages[id] = existingMessage\n else if (cachedMessage !== undefined) messages[id] = cachedMessage\n else if (shouldWriteDefaultLocaleFallback()) messages[id] = entry.defaultMessage\n }\n\n writeFileIfChanged(getLocalePath(locale), JSON.stringify(messages, null, 2) + \"\\n\")\n }\n\n function removeFileMessages(file: string) {\n const previous = fileMessages.get(file)\n if (!previous) return false\n\n for (const message of previous) {\n const entry = manifest[message.id]\n if (!entry) continue\n entry.sources = entry.sources.filter((source) => !isSameSource(source, message.source))\n if (entry.sources.length === 0) delete manifest[message.id]\n }\n\n fileMessages.delete(file)\n return true\n }\n\n function syncFileMessages(file: string, messages: ExtractedMessage[]): SyncResult {\n const previousMessages = fileMessages.get(file) ?? []\n const nextEntries = groupMessagesById(messages)\n for (const [id, entry] of Object.entries(nextEntries)) {\n const existing = manifest[id]\n if (existing && !hasSameMessageShape(existing, entry)) {\n throw new Error(formatCollisionError(id, existing, entry))\n }\n }\n\n removeFileMessages(file)\n for (const [id, entry] of Object.entries(nextEntries)) {\n if (!manifest[id]) {\n manifest[id] = entry\n continue\n }\n for (const source of entry.sources) {\n if (!manifest[id]!.sources.some((existingSource) => isSameSource(existingSource, source))) {\n manifest[id]!.sources.push(source)\n }\n }\n }\n\n if (messages.length > 0) fileMessages.set(file, messages)\n return {\n manifestChanged:\n previousMessages.length !== messages.length ||\n previousMessages.some((message, index) => !isSameExtractedMessage(message, messages[index])),\n localeMessagesChanged:\n previousMessages.length !== messages.length ||\n previousMessages.some((message, index) => !hasSameMessageShape(message, messages[index]!)),\n }\n }\n\n function syncSourceCode(file: string, code: string) {\n const analysis = analyzeSourceFile(code, file, {\n call: CALL_MARKERS,\n component: COMPONENT_MARKERS,\n logging,\n })\n if (!analysis.parsed) return null\n return syncFileMessages(\n file,\n analysis.messages.map((message) => ({\n ...message,\n source: {\n ...message.source,\n file: toRootRelativePath(message.source.file),\n },\n })),\n )\n }\n\n function removeTrackedFile(file: string): SyncResult {\n const hadPreviousMessages = removeFileMessages(file)\n return {\n manifestChanged: hadPreviousMessages,\n localeMessagesChanged: hadPreviousMessages,\n }\n }\n\n function applySyncResult(syncResult: SyncResult | null, options: { scheduleTranslation: boolean }) {\n if (!syncResult) return\n if (syncResult.localeMessagesChanged) {\n writeLocaleFilesToDisk()\n writePrivateManifest()\n if (options.scheduleTranslation) scheduleDevTranslation()\n return\n }\n if (syncResult.manifestChanged) writePrivateManifest()\n }\n\n function scanAllSourceFiles() {\n for (const id of Object.keys(manifest)) delete manifest[id]\n fileMessages.clear()\n\n for (const sourceRoot of sourceRoots) {\n if (!existsSync(sourceRoot)) continue\n for (const file of collectScanFiles(sourceRoot).sort()) {\n const code = readFileSync(file, \"utf-8\")\n syncSourceCode(file, code)\n }\n }\n }\n\n function toRootRelativePath(file: string) {\n return relative(root, file).replaceAll(\"\\\\\", \"/\")\n }\n\n function createVirtualMessagesModule() {\n if (isRemoteOfflineDev(resolvedRuntime, isDev)) {\n return createModuleMessagesModule(locales, (locale) => `/${normalizePath(toRootRelativePath(getLocalePath(locale)))}`)\n }\n if (resolvedRuntime.type === \"remote\") return createRemoteMessagesModule(resolvedRuntime, locales, remoteUrl)\n if (resolvedRuntime.target === \"public\") return createPublicMessagesModule(locales, publicBasePath)\n return createModuleMessagesModule(locales, (locale) => `/${normalizePath(toRootRelativePath(getLocalePath(locale)))}`)\n }\n\n return {\n name: \"better-translation-extract\",\n enforce: \"pre\",\n\n config() {\n return {\n ssr: {\n noExternal: [\"better-translation\"],\n },\n }\n },\n\n configResolved(config) {\n root = config.root\n isDev = config.command === \"serve\"\n resolvedRuntime = resolveRuntimeOptions(configuredRuntime, config)\n usesLocalStorage = shouldUseLocalStorage(resolvedRuntime, isDev)\n resolvedTranslate = resolvedRuntime.type === \"local\" ? resolvedRuntime.translate : undefined\n localesDir = getRuntimeOutputDir(resolvedRuntime, isDev)\n publicBasePath =\n resolvedRuntime.type === \"local\" && resolvedRuntime.target === \"public\"\n ? (resolvedRuntime.basePath ?? DEFAULT_PUBLIC_BASE_PATH)\n : DEFAULT_PUBLIC_BASE_PATH\n remoteUrl = resolvedRuntime.type === \"remote\" ? (resolvedRuntime.endpoint ?? REMOTE_API_BASE_URL) : REMOTE_API_BASE_URL\n sourceRoots = (Array.isArray(rootDir) ? rootDir : [rootDir]).map((dir) => resolve(root, dir))\n log(\n `${PREFIX} Locales: ${CYAN}${formatLocales(locales)}${RESET} | Default: ${CYAN}${formatLocale(defaultLocale)}${RESET} | Runtime: ${CYAN}${formatRuntime(resolvedRuntime)}${RESET} | Out Dir: ${DIM}${usesLocalStorage ? localesDir : \"n/a\"}${RESET} | Roots: ${DIM}${(Array.isArray(rootDir) ? rootDir : [rootDir]).join(\", \")}${RESET}`,\n )\n },\n\n resolveId(id) {\n if (id === VIRTUAL_MESSAGES_MODULE_ID) return RESOLVED_VIRTUAL_MESSAGES_MODULE_ID\n },\n\n load(id) {\n if (id === RESOLVED_VIRTUAL_MESSAGES_MODULE_ID) return createVirtualMessagesModule()\n },\n\n async buildStart() {\n cache = loadCache(resolve(root, cacheFile))\n scanAllSourceFiles()\n if (usesLocalStorage && !isDev) {\n assertLocalBuildTranslationsComplete()\n return\n }\n writeLocaleFilesToDisk()\n writePrivateManifest()\n\n if (isDev) scheduleDevTranslation()\n },\n\n configureServer(server) {\n const localEditorOptions = getLocalEditorOptions({ isDev, runtime: resolvedRuntime })\n if (localEditorOptions) {\n configureLocalEditor(\n server,\n { defaultLocale, isUntranslatedLocaleValue, locales, log, manifest, readLocaleMessages, writeLocaleMessages },\n localEditorOptions,\n )\n }\n server.watcher.add(sourceRoots)\n server.httpServer?.once(\"listening\", () => scheduleDevRemoteSync())\n\n const syncFileFromDisk = (file: string) => {\n if (!shouldScanFile(file) || !existsSync(file)) return\n applySyncResult(syncSourceCode(file, readFileSync(file, \"utf-8\")), { scheduleTranslation: true })\n scheduleDevRemoteSync()\n }\n\n const removeFileFromManifest = (file: string) => {\n if (!shouldScanFile(file)) return\n applySyncResult(removeTrackedFile(file), { scheduleTranslation: true })\n scheduleDevRemoteSync()\n }\n\n server.watcher.on(\"add\", syncFileFromDisk)\n server.watcher.on(\"change\", syncFileFromDisk)\n server.watcher.on(\"unlink\", removeFileFromManifest)\n },\n\n transform(code, id) {\n const cleanId = id.split(\"?\", 1)[0] ?? id\n if (!shouldScanFile(cleanId)) return\n\n const analysis = analyzeSourceFile(code, cleanId, {\n call: CALL_MARKERS,\n component: COMPONENT_MARKERS,\n logging,\n })\n\n if (analysis.edits.length === 0) return\n return {\n code: applyEdits(code, analysis.edits),\n map: null,\n }\n },\n\n async generateBundle() {\n if (usesLocalStorage) {\n assertLocalBuildTranslationsComplete()\n } else if (isDev) {\n await translateMissingMessages()\n }\n\n if (!usesLocalStorage) {\n await syncRemote()\n }\n },\n\n closeBundle() {\n if (usesLocalStorage && !isDev) return\n saveCache(resolve(root, cacheFile), cache)\n },\n }\n}\n\nfunction formatLocaleIssue(locale: string, label: string, ids: string[]) {\n const preview = ids\n .slice(0, 5)\n .map((id) => JSON.stringify(id))\n .join(\", \")\n const suffix = ids.length > 5 ? `, ... ${ids.length - 5} more` : \"\"\n return `- ${locale}: ${label} (${preview}${suffix})`\n}\n\nfunction shouldUseLocalStorage(runtime: BetterTranslateRuntimeOptions, isDev: boolean) {\n return runtime.type === \"local\" || isRemoteOfflineDev(runtime, isDev)\n}\n\nfunction isRemoteOfflineDev(runtime: BetterTranslateRuntimeOptions, isDev: boolean) {\n return runtime.type === \"remote\" && isDev && runtime.dev?.offline === true\n}\n\nfunction getRuntimeOutputDir(runtime: BetterTranslateRuntimeOptions, isDev: boolean) {\n if (runtime.type === \"local\") return runtime.output!\n if (isRemoteOfflineDev(runtime, isDev)) return DEFAULT_REMOTE_OFFLINE_OUTPUT_DIR\n return DEFAULT_LOCAL_OUTPUT_DIR\n}\n\nfunction normalizeRuntimeOptions(runtime: BetterTranslateRuntimeOptions | undefined): BetterTranslateRuntimeOptions {\n if (runtime) return runtime.type === \"local\" ? { ...runtime, target: runtime.target ?? \"module\" } : runtime\n return { type: \"local\", target: \"module\" }\n}\n\nfunction resolveRuntimeOptions(runtime: BetterTranslateRuntimeOptions, config: ResolvedConfig): BetterTranslateRuntimeOptions {\n if (runtime.type === \"remote\") {\n const projectId = typeof runtime.projectId === \"string\" ? runtime.projectId.trim() : \"\"\n if (!projectId) {\n throw new Error(`${PREFIX} remote runtime requires a projectId`)\n }\n return {\n ...runtime,\n projectId,\n endpoint: runtime.endpoint ?? REMOTE_API_BASE_URL,\n branch: resolveBranch(runtime, config.root),\n dev: {\n offline: runtime.dev?.offline ?? false,\n },\n }\n }\n\n const target = runtime.target ?? \"module\"\n if (target === \"module\") {\n return {\n ...runtime,\n target,\n output: runtime.output ?? DEFAULT_LOCAL_OUTPUT_DIR,\n }\n }\n\n if (!config.publicDir) {\n throw new Error(`${PREFIX} runtime target \"public\" requires Vite publicDir to be enabled`)\n }\n\n const output = runtime.output ?? normalizePath(relative(config.root, resolve(config.publicDir, DEFAULT_PUBLIC_OUTPUT_SUBDIR)))\n const outputPath = resolve(config.root, output)\n const publicBasePath = runtime.basePath ?? inferPublicBasePath(outputPath, config.publicDir)\n\n return {\n ...runtime,\n target,\n output,\n basePath: publicBasePath,\n }\n}\n\nfunction inferPublicBasePath(outputPath: string, publicDir: string) {\n const relativeToPublic = normalizePath(relative(publicDir, outputPath))\n if (relativeToPublic.startsWith(\"..\")) {\n throw new Error(`${PREFIX} runtime target \"public\" output must be inside Vite publicDir unless basePath is provided`)\n }\n return `/${relativeToPublic}`.replace(/\\/$/, \"\")\n}\n\nfunction formatRuntime(runtime: BetterTranslateRuntimeOptions) {\n return runtime.type === \"local\" ? `Local/${runtime.target ?? \"module\"}` : `Remote/${runtime.branch ?? \"auto\"}`\n}\n\nfunction resolveBranch(runtime: Pick<Extract<BetterTranslateRuntimeOptions, { type: \"remote\" }>, \"branch\">, root: string) {\n if (runtime.branch && runtime.branch !== \"auto\") return runtime.branch\n\n const envBranch = process.env.BETTER_TRANSLATION_BRANCH?.trim()\n if (envBranch) return envBranch\n\n const providerBranch = process.env.VERCEL_GIT_COMMIT_REF?.trim()\n if (providerBranch) return providerBranch\n\n const gitBranch = readCurrentGitBranch(root)\n return gitBranch ?? DEFAULT_REMOTE_BRANCH\n}\n\nfunction readCurrentGitBranch(root: string) {\n try {\n const branch = execFileSync(\"git\", [\"branch\", \"--show-current\"], {\n cwd: root,\n encoding: \"utf-8\",\n stdio: [\"ignore\", \"pipe\", \"ignore\"],\n }).trim()\n return branch || null\n } catch {\n return null\n }\n}\n\nfunction formatRemoteManifestTarget(runtime: Extract<BetterTranslateRuntimeOptions, { type: \"remote\" }>, endpoint: string) {\n return `${endpoint.replace(/\\/$/, \"\")}/api/projects/${encodeURIComponent(runtime.projectId)}/branches/${encodeURIComponent(runtime.branch ?? DEFAULT_REMOTE_BRANCH)}/manifest`\n}\n\nfunction parseRemoteSyncResult(body: string) {\n try {\n const parsed = JSON.parse(body) as unknown\n if (typeof parsed !== \"object\" || parsed === null) return null\n return {\n changed: \"changed\" in parsed && parsed.changed === true,\n }\n } catch {\n return null\n }\n}\n\nfunction formatRemoteSyncError(response: Response, target: string, body: string) {\n const details = formatRemoteSyncResponseDetails(body)\n return [\n `${PREFIX} remote Manifest sync failed with ${response.status} ${response.statusText || \"HTTP error\"}`,\n `target: ${target}`,\n details ? `response: ${details}` : null,\n ]\n .filter((line) => line !== null)\n .join(\"\\n\")\n}\n\nfunction formatRemoteSyncNetworkError(target: string, error: unknown) {\n const message = error instanceof Error ? error.message : String(error)\n return [`${PREFIX} remote Manifest sync could not reach the hosted service`, `target: ${target}`, `error: ${message}`].join(\n \"\\n\",\n )\n}\n\nfunction formatRemoteSyncResponseDetails(body: string) {\n const details = body.trim().replace(/\\s+/g, \" \")\n if (!details) return \"\"\n return details.length > 500 ? `${details.slice(0, 500)}...` : details\n}\n\nfunction createModuleMessagesModule(locales: string[], getImportPath: (locale: string) => string) {\n const cases = locales\n .map(\n (locale) => ` case ${JSON.stringify(locale)}:\n return (await import(${JSON.stringify(getImportPath(locale))})).default`,\n )\n .join(\"\\n\")\n\n return [\n `export const locales = ${JSON.stringify(locales)}`,\n \"\",\n \"export async function loadMessages(locale) {\",\n \" switch (locale) {\",\n cases,\n \" default:\",\n \" throw new Error(`Unknown locale: ${locale}`)\",\n \" }\",\n \"}\",\n \"\",\n ].join(\"\\n\")\n}\n\nfunction createPublicMessagesModule(locales: string[], basePath: string) {\n const normalizedBasePath = basePath.replace(/\\/$/, \"\")\n return [\n `export const locales = ${JSON.stringify(locales)}`,\n \"\",\n \"export async function loadMessages(locale) {\",\n \" assertKnownLocale(locale)\",\n ` const response = await fetch(\\`${normalizedBasePath}/locales/\\${encodeURIComponent(locale)}.json\\`)`,\n \" if (!response.ok) throw new Error(`Failed to load locale: ${locale}`)\",\n \" return response.json()\",\n \"}\",\n \"\",\n createKnownLocaleAssertion(locales),\n ].join(\"\\n\")\n}\n\nfunction createRemoteMessagesModule(\n runtime: Extract<BetterTranslateRuntimeOptions, { type: \"remote\" }>,\n locales: string[],\n endpoint: string,\n) {\n const normalizedEndpoint = endpoint.replace(/\\/$/, \"\")\n const projectPath = `/projects/${encodeURIComponent(runtime.projectId)}`\n const branchPath = `/branches/${encodeURIComponent(runtime.branch ?? DEFAULT_REMOTE_BRANCH)}`\n return [\n `export const locales = ${JSON.stringify(locales)}`,\n \"\",\n \"export async function loadMessages(locale) {\",\n \" assertKnownLocale(locale)\",\n ` const response = await fetch(\\`${normalizedEndpoint}${projectPath}${branchPath}/locales/\\${encodeURIComponent(locale)}.json\\`)`,\n \" if (!response.ok) throw new Error(`Failed to load locale: ${locale}`)\",\n \" return response.json()\",\n \"}\",\n \"\",\n createKnownLocaleAssertion(locales),\n ].join(\"\\n\")\n}\n\nfunction createKnownLocaleAssertion(locales: string[]) {\n return [\n `const knownLocales = new Set(${JSON.stringify(locales)})`,\n \"\",\n \"function assertKnownLocale(locale) {\",\n \" if (!knownLocales.has(locale)) throw new Error(`Unknown locale: ${locale}`)\",\n \"}\",\n \"\",\n ].join(\"\\n\")\n}\n\nfunction normalizeLocaleMessages(input: unknown): RuntimeMessages {\n if (isRuntimeMessages(input)) return input\n if (\n typeof input === \"object\" &&\n input !== null &&\n \"messages\" in input &&\n typeof input.messages === \"object\" &&\n input.messages !== null\n ) {\n return Object.fromEntries(\n Object.entries(input.messages).flatMap(([id, entry]) =>\n typeof entry === \"object\" && entry !== null && \"translation\" in entry && typeof entry.translation === \"string\"\n ? [[id, entry.translation]]\n : [],\n ),\n ) as RuntimeMessages\n }\n return {}\n}\n\nfunction writeFileIfChanged(path: string, contents: string) {\n if (existsSync(path) && readFileSync(path, \"utf-8\") === contents) return false\n writeFileSync(path, contents)\n return true\n}\n\nfunction collectScanFiles(root: string) {\n const files: string[] = []\n for (const entry of readdirSync(root, { withFileTypes: true })) {\n const path = resolve(root, entry.name)\n if (entry.isDirectory()) {\n if (entry.name === \"node_modules\") continue\n files.push(...collectScanFiles(path))\n continue\n }\n files.push(path)\n }\n return files\n}\n\nfunction isRuntimeMessages(input: unknown): input is RuntimeMessages {\n return typeof input === \"object\" && input !== null && Object.values(input).every((value) => typeof value === \"string\")\n}\n\nfunction applyEdits(code: string, edits: Array<{ start: number; end: number; replacement: string }>) {\n let transformed = code\n for (const edit of [...edits].sort((a, b) => b.start - a.start)) {\n transformed = `${transformed.slice(0, edit.start)}${edit.replacement}${transformed.slice(edit.end)}`\n }\n return transformed\n}\n\nfunction groupMessagesById(messages: ExtractedMessage[]): MessageManifest {\n const grouped: MessageManifest = {}\n\n for (const message of messages) {\n const existing = grouped[message.id]\n if (existing && !hasSameMessageShape(existing, message)) {\n throw new Error(formatCollisionError(message.id, existing, message))\n }\n if (!existing) {\n grouped[message.id] = {\n defaultMessage: message.defaultMessage,\n meta: message.meta,\n placeholders: message.placeholders,\n sources: [message.source],\n }\n continue\n }\n if (!existing.sources.some((source) => isSameSource(source, message.source))) {\n existing.sources.push(message.source)\n }\n }\n\n return grouped\n}\n\nfunction hasSameMessageShape(\n existing: Pick<ManifestEntry, \"defaultMessage\" | \"meta\" | \"placeholders\">,\n incoming: Pick<ManifestEntry, \"defaultMessage\" | \"meta\" | \"placeholders\"> | ExtractedMessage,\n) {\n return (\n existing.defaultMessage === incoming.defaultMessage &&\n serializeMeta(existing.meta) === serializeMeta(incoming.meta) &&\n JSON.stringify(existing.placeholders) === JSON.stringify(incoming.placeholders)\n )\n}\n\nfunction isSameSource(left: MessageSource, right: MessageSource) {\n return left.file === right.file && left.kind === right.kind && left.marker === right.marker\n}\n\nfunction compareManifestEntryIds([left]: [string, ManifestEntry], [right]: [string, ManifestEntry]) {\n return left.localeCompare(right)\n}\n\nfunction compareMessageSources(left: MessageSource, right: MessageSource) {\n return left.file.localeCompare(right.file) || left.kind.localeCompare(right.kind) || left.marker.localeCompare(right.marker)\n}\n\nfunction isSameExtractedMessage(left: ExtractedMessage, right?: ExtractedMessage) {\n if (!right) return false\n return hasSameMessageShape(left, right) && isSameSource(left.source, right.source)\n}\n\nfunction formatCollisionError(\n id: string,\n existing: Pick<ManifestEntry, \"defaultMessage\" | \"meta\" | \"placeholders\" | \"sources\">,\n incoming: Pick<ManifestEntry, \"defaultMessage\" | \"meta\" | \"placeholders\" | \"sources\"> | ExtractedMessage,\n) {\n const existingSources = formatSources(existing.sources)\n const incomingSources = formatSources(\"source\" in incoming ? [incoming.source] : incoming.sources)\n return [\n `${PREFIX} conflicting message definition for ${BOLD}\"${id}\"${RESET}`,\n `existing: ${JSON.stringify({ defaultMessage: existing.defaultMessage, meta: existing.meta, placeholders: existing.placeholders })}`,\n `existing sources: ${existingSources}`,\n `incoming: ${JSON.stringify({ defaultMessage: incoming.defaultMessage, meta: incoming.meta, placeholders: incoming.placeholders })}`,\n `incoming sources: ${incomingSources}`,\n ].join(\"\\n\")\n}\n\nfunction formatSources(sources: MessageSource[]) {\n return sources.map((source) => `${source.file} (${source.kind}:${source.marker})`).join(\", \")\n}\n"],"mappings":";;;;;;;;AAKA,MAAM,kBAAkB;AAExB,SAAgB,mBAAqC;CACnD,OAAO;EAAE,SAAS;EAAiB,SAAS,CAAC;CAAE;AACjD;;AAGA,SAAgB,UAAU,MAAgC;CACxD,IAAI,CAAC,WAAW,IAAI,GAAG,OAAO,iBAAiB;CAC/C,IAAI;EACF,MAAM,OAAO,KAAK,MAAM,aAAa,MAAM,OAAO,CAAC;EACnD,IAAI,KAAK,YAAY,iBAAiB,OAAO,iBAAiB;EAC9D,OAAO;CACT,QAAQ;EACN,OAAO,iBAAiB;CAC1B;AACF;;AAGA,SAAgB,UAAU,MAAc,OAAyB;CAC/D,MAAM,MAAM,QAAQ,IAAI;CACxB,IAAI,CAAC,WAAW,GAAG,GAAG,UAAU,KAAK,EAAE,WAAW,KAAK,CAAC;CACxD,MAAM,OAAO,KAAK,UAAU,OAAO,MAAM,CAAC;CAC1C,IAAI,WAAW,IAAI,KAAK,aAAa,MAAM,OAAO,MAAM,MAAM;CAC9D,cAAc,MAAM,IAAI;AAC1B;;AAGA,SAAg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,SAAS,MAAM,QAAQ,KAAK,WAAW,MAAM;AACvF;AAEA,SAAS,wBAAwB,CAAC,OAAgC,CAAC,QAAiC;CAClG,OAAO,KAAK,cAAc,KAAK;AACjC;AAEA,SAAS,sBAAsB,MAAqB,OAAsB;CACxE,OAAO,KAAK,KAAK,cAAc,MAAM,IAAI,KAAK,KAAK,KAAK,cAAc,MAAM,IAAI,KAAK,KAAK,OAAO,cAAc,MAAM,MAAM;AAC7H;AAEA,SAAS,uBAAuB,MAAwB,OAA0B;CAChF,IAAI,CAAC,OAAO,OAAO;CACnB,OAAO,oBAAoB,MAAM,KAAK,KAAK,aAAa,KAAK,QAAQ,MAAM,MAAM;AACnF;AAEA,SAAS,qBACP,IACA,UACA,UACA;CACA,MAAM,kBAAkB,cAAc,SAAS,OAAO;CACtD,MAAM,kBAAkB,cAAc,YAAY,WAAW,CAAC,SAAS,MAAM,IAAI,SAAS,OAAO;CACjG,OAAO;EACL,GAAG,OAAO,sCAAsC,KAAK,GAAG,GAAG,GAAG;EAC9D,aAAa,KAAK,UAAU;GAAE,gBAAgB,SAAS;GAAgB,MAAM,SAAS;GAAM,cAAc,SAAS;EAAa,CAAC;EACjI,qBAAqB;EACrB,aAAa,KAAK,UAAU;GAAE,gBAAgB,SAAS;GAAgB,MAAM,SAAS;GAAM,cAAc,SAAS;EAAa,CAAC;EACjI,qBAAqB;CACvB,EAAE,KAAK,IAAI;AACb;AAEA,SAAS,cAAc,SAA0B;CAC/C,OAAO,QAAQ,KAAK,WAAW,GAAG,OAAO,KAAK,IAAI,OAAO,KAAK,GAAG,OAAO,OAAO,EAAE,EAAE,KAAK,IAAI;AAC9F"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "better-translation",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "Vite plugin and runtime helpers for Better Translation.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -47,7 +47,7 @@
47
47
  "prepack": "bun run build"
48
48
  },
49
49
  "dependencies": {
50
- "ai": "7.0.0-beta.116",
50
+ "ai": "7.0.0-canary.172",
51
51
  "oxc-parser": "0.135.0"
52
52
  },
53
53
  "devDependencies": {