@formatjs/cli-lib 8.7.13 → 9.0.1

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/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { MessageDescriptor, MessageDescriptor as MessageDescriptor$1, Opts as Opts$1 } from "@formatjs/ts-transformer";
2
2
  import { Comparator, Comparator as Comparator$1 } from "json-stable-stringify";
3
-
4
3
  //#region packages/cli-lib/formatters/default.d.ts
5
4
  type FormatFn<T = Record<string, MessageDescriptor$1>> = (msgs: Record<string, MessageDescriptor$1>) => T;
6
5
  type CompileFn<T = Record<string, MessageDescriptor$1>> = (msgs: T) => Record<string, string>;
@@ -17,125 +16,125 @@ interface Formatter<T> {
17
16
  //#region packages/cli-lib/extract.d.ts
18
17
  type ExtractCLIOptions = Omit<ExtractOpts, "overrideIdFn" | "onMsgExtracted" | "onMetaExtracted"> & {
19
18
  /**
20
- * Output File
21
- */
19
+ * Output File
20
+ */
22
21
  outFile?: string;
23
22
  /**
24
- * Input File
25
- */
23
+ * Input File
24
+ */
26
25
  inFile?: string;
27
26
  /**
28
- * Ignore file glob pattern
29
- */
27
+ * Ignore file glob pattern
28
+ */
30
29
  ignore?: string[];
31
30
  /**
32
- * Whether to follow symbolic links when traversing directories.
33
- * Defaults to true for compatibility with pnpm symlinked node_modules.
34
- */
31
+ * Whether to follow symbolic links when traversing directories.
32
+ * Defaults to true for compatibility with pnpm symlinked node_modules.
33
+ */
35
34
  followLinks?: boolean;
36
35
  };
37
36
  type ExtractOpts = Opts$1 & {
38
37
  /**
39
- * Whether to throw an error if we had any issues with
40
- * 1 of the source files
41
- */
38
+ * Whether to throw an error if we had any issues with
39
+ * 1 of the source files
40
+ */
42
41
  throws?: boolean;
43
42
  /**
44
- * Message ID interpolation pattern
45
- */
43
+ * Message ID interpolation pattern
44
+ */
46
45
  idInterpolationPattern?: string;
47
46
  /**
48
- * Whether we read from stdin instead of a file
49
- */
47
+ * Whether we read from stdin instead of a file
48
+ */
50
49
  readFromStdin?: boolean;
51
50
  /**
52
- * Either path to a formatter file that controls the shape of JSON file from `outFile` or {@link Formatter} object.
53
- */
51
+ * Either path to a formatter file that controls the shape of JSON file from `outFile` or {@link Formatter} object.
52
+ */
54
53
  format?: string | Formatter<any>;
55
54
  /**
56
- * Whether to hoist selectors & flatten sentences
57
- */
55
+ * Whether to hoist selectors & flatten sentences
56
+ */
58
57
  flatten?: boolean;
59
58
  /**
60
- * An AbortSignal to cancel the extraction
61
- */
59
+ * An AbortSignal to cancel the extraction
60
+ */
62
61
  signal?: AbortSignal;
63
62
  } & Pick<Opts$1, "onMsgExtracted" | "onMetaExtracted">;
64
63
  /**
65
- * Extract strings from source files
66
- * @param files list of files
67
- * @param extractOpts extract options
68
- * @returns messages serialized as JSON string since key order
69
- * matters for some `format`
70
- */
64
+ * Extract strings from source files
65
+ * @param files list of files
66
+ * @param extractOpts extract options
67
+ * @returns messages serialized as JSON string since key order
68
+ * matters for some `format`
69
+ */
71
70
  declare function extract(files: readonly string[], extractOpts: ExtractOpts): Promise<string>;
72
71
  /**
73
- * Extract strings from source files, also writes to a file.
74
- * @param files list of files
75
- * @param extractOpts extract options
76
- * @returns A Promise that resolves if output file was written successfully
77
- */
72
+ * Extract strings from source files, also writes to a file.
73
+ * @param files list of files
74
+ * @param extractOpts extract options
75
+ * @returns A Promise that resolves if output file was written successfully
76
+ */
78
77
  declare function extractAndWrite(files: readonly string[], extractOpts: ExtractCLIOptions): Promise<void>;
79
78
  //#endregion
80
79
  //#region packages/cli-lib/compile.d.ts
81
80
  type PseudoLocale = "xx-LS" | "xx-AC" | "xx-HA" | "en-XA" | "en-XB";
82
81
  interface CompileCLIOpts extends Opts {
83
82
  /**
84
- * The target file that contains compiled messages.
85
- */
83
+ * The target file that contains compiled messages.
84
+ */
86
85
  outFile?: string;
87
86
  }
88
87
  interface Opts {
89
88
  /**
90
- * Whether to compile message into AST instead of just string
91
- */
89
+ * Whether to compile message into AST instead of just string
90
+ */
92
91
  ast?: boolean;
93
92
  /**
94
- * Whether to continue compiling messages after encountering an error.
95
- * Any keys with errors will not be included in the output file.
96
- */
93
+ * Whether to continue compiling messages after encountering an error.
94
+ * Any keys with errors will not be included in the output file.
95
+ */
97
96
  skipErrors?: boolean;
98
97
  /**
99
- * Built-in formatter name or path to a formatter file that converts
100
- * <translation_files> to `Record<string, string>` so we can compile.
101
- * Formatter file paths are deprecated for compilation.
102
- */
98
+ * Built-in formatter name or path to a formatter file that converts
99
+ * <translation_files> to `Record<string, string>` so we can compile.
100
+ * Formatter file paths are deprecated for compilation.
101
+ */
103
102
  format?: string | Formatter<unknown>;
104
103
  /**
105
- * Whether to compile to pseudo locale
106
- */
104
+ * Whether to compile to pseudo locale
105
+ */
107
106
  pseudoLocale?: PseudoLocale;
108
107
  /**
109
- * Whether the parser to treat HTML/XML tags as string literal
110
- * instead of parsing them as tag token.
111
- * When this is false we only allow simple tags without
112
- * any attributes
113
- */
108
+ * Whether the parser to treat HTML/XML tags as string literal
109
+ * instead of parsing them as tag token.
110
+ * When this is false we only allow simple tags without
111
+ * any attributes
112
+ */
114
113
  ignoreTag?: boolean;
115
114
  /**
116
- * An AbortSignal to cancel the compilation before invoking native code.
117
- */
115
+ * An AbortSignal to cancel the compilation before invoking native code.
116
+ */
118
117
  signal?: AbortSignal;
119
118
  /**
120
- * Whether to follow symbolic links when traversing directories.
121
- * Defaults to true for compatibility with pnpm symlinked node_modules.
122
- */
119
+ * Whether to follow symbolic links when traversing directories.
120
+ * Defaults to true for compatibility with pnpm symlinked node_modules.
121
+ */
123
122
  followLinks?: boolean;
124
123
  }
125
124
  /**
126
- * Compile extracted translation files with the native formatjs CLI binding.
127
- * @param inputFiles Input files or glob patterns
128
- * @param opts Options
129
- * @returns serialized result in string format
130
- */
125
+ * Compile extracted translation files with the native formatjs CLI binding.
126
+ * @param inputFiles Input files or glob patterns
127
+ * @param opts Options
128
+ * @returns serialized result in string format
129
+ */
131
130
  declare function compile(inputFiles: string[], opts?: Opts): Promise<string>;
132
131
  /**
133
- * Compile extracted translation files with the native formatjs CLI binding and
134
- * write output to `outFile` when provided.
135
- * @param inputFiles Input files or glob patterns
136
- * @param compileOpts options
137
- * @returns A `Promise` that resolves if file was written successfully
138
- */
132
+ * Compile extracted translation files with the native formatjs CLI binding and
133
+ * write output to `outFile` when provided.
134
+ * @param inputFiles Input files or glob patterns
135
+ * @param compileOpts options
136
+ * @returns A `Promise` that resolves if file was written successfully
137
+ */
139
138
  declare function compileAndWrite(inputFiles: string[], compileOpts?: CompileCLIOpts): Promise<void>;
140
139
  //#endregion
141
140
  export { type Comparator, type CompileCLIOpts, type CompileFn, type Opts as CompileOpts, type ExtractCLIOptions, type ExtractOpts, type FormatFn, type MessageDescriptor, compile, compileAndWrite, extract, extractAndWrite };
package/index.js CHANGED
@@ -180,7 +180,8 @@ function getInstalledNativePackageCandidates(candidates, canResolve = (candidate
180
180
  return candidates.filter(canResolve);
181
181
  }
182
182
  function getNativePackageCandidates(platform = process.platform, arch = process.arch) {
183
- return NATIVE_PACKAGES[`${platform}-${arch}`] || [];
183
+ const platformArch = `${platform}-${arch}`;
184
+ return NATIVE_PACKAGES[platformArch] || [];
184
185
  }
185
186
  function loadNative() {
186
187
  if (nativeBinding !== void 0) {
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["format","compile","format","compile","format","compile","format","compile","format","compile","compile","defaultFormatter","transifex","smartling","simple","lokalise","crowdin","require","stringify","BUILTIN_FORMATTERS","isBuiltinFormatter"],"sources":["../formatters/crowdin.ts","../formatters/default.ts","../formatters/lokalise.ts","../formatters/simple.ts","../formatters/smartling.ts","../formatters/transifex.ts","../formatters/index.ts","../native.ts","../extract.ts","../compile.ts"],"sourcesContent":["import {\n type CompileFn,\n type FormatFn,\n} from '#packages/cli-lib/formatters/default.js'\n\nexport type CrowdinJson = Record<\n string,\n {\n message: string\n description?: string\n }\n>\n\nexport const format: FormatFn<CrowdinJson> = msgs => {\n const results: CrowdinJson = {}\n for (const [id, msg] of Object.entries(msgs)) {\n results[id] = {\n message: msg.defaultMessage!,\n description:\n typeof msg.description === 'string'\n ? msg.description\n : JSON.stringify(msg.description),\n }\n }\n return results\n}\n\nexport const compile: CompileFn<CrowdinJson> = msgs => {\n const results: Record<string, string> = {}\n for (const [id, msg] of Object.entries(msgs)) {\n if (id === 'smartling') {\n continue\n }\n results[id] = msg.message\n }\n return results\n}\n","import {type MessageDescriptor} from '@formatjs/ts-transformer'\nexport type FormatFn<T = Record<string, MessageDescriptor>> = (\n msgs: Record<string, MessageDescriptor>\n) => T\n\nexport type CompileFn<T = Record<string, MessageDescriptor>> = (\n msgs: T\n) => Record<string, string>\n\nexport type SerializeFn<T = Record<string, MessageDescriptor>> = (\n msgs: T\n) => string\n\nexport const format: FormatFn = msgs => msgs\n\nexport const compile: CompileFn = msgs => {\n const results: Record<string, string> = {}\n for (const k in msgs) {\n results[k] = msgs[k].defaultMessage!\n }\n return results\n}\n","import {\n type CompileFn,\n type FormatFn,\n} from '#packages/cli-lib/formatters/default.js'\n\nexport type StructuredJson = Record<\n string,\n {\n translation: string\n notes?: string\n context?: string\n limit?: string\n }\n>\n\nexport const format: FormatFn<StructuredJson> = msgs => {\n const results: StructuredJson = {}\n for (const [id, msg] of Object.entries(msgs)) {\n results[id] = {\n translation: msg.defaultMessage!,\n notes:\n typeof msg.description === 'string'\n ? msg.description\n : JSON.stringify(msg.description),\n }\n }\n return results\n}\n\nexport const compile: CompileFn<StructuredJson> = msgs => {\n const results: Record<string, string> = {}\n for (const [id, msg] of Object.entries(msgs)) {\n results[id] = msg.translation\n }\n return results\n}\n","import {\n type CompileFn,\n type FormatFn,\n} from '#packages/cli-lib/formatters/default.js'\n\nexport type PhraseJson = Record<string, string>\n\nexport const format: FormatFn<PhraseJson> = msgs => {\n return Object.keys(msgs).reduce((all: PhraseJson, k) => {\n all[k] = msgs[k].defaultMessage!\n return all\n }, {})\n}\n\nexport const compile: CompileFn<PhraseJson> = msgs => msgs\n","import type {Comparator} from 'json-stable-stringify'\nimport {\n type CompileFn,\n type FormatFn,\n} from '#packages/cli-lib/formatters/default.js'\n\nexport interface SmartlingDirectives {\n translate_paths: [\n {\n path: string\n key: string\n instruction: string\n },\n ]\n variants_enabled: boolean\n string_format: string\n [k: string]: any\n}\n\nexport type SmartlingJson = {\n smartling: SmartlingDirectives\n} & Record<\n string,\n {\n message: string\n description?: string\n }\n>\n\nexport const format: FormatFn<SmartlingJson> = msgs => {\n const results: SmartlingJson = {\n smartling: {\n translate_paths: [\n {\n path: '*/message',\n key: '{*}/message',\n instruction: '*/description',\n },\n ],\n variants_enabled: true,\n string_format: 'icu',\n },\n } as any\n for (const [id, msg] of Object.entries(msgs)) {\n results[id] = {\n message: msg.defaultMessage!,\n description:\n typeof msg.description === 'string'\n ? msg.description\n : JSON.stringify(msg.description),\n }\n }\n return results\n}\n\nexport const compareMessages: Comparator = (el1, el2) => {\n // `smartling` has to be the 1st key\n if (el1.key === 'smartling') {\n return -1\n }\n if (el2.key === 'smartling') {\n return 1\n }\n return el1.key < el2.key ? -1 : el1.key === el2.key ? 0 : 1\n}\n\nexport const compile: CompileFn<SmartlingJson> = msgs => {\n const results: Record<string, string> = {}\n for (const [id, msg] of Object.entries(msgs)) {\n if (id === 'smartling') {\n continue\n }\n results[id] = msg.message\n }\n return results\n}\n","import {\n type CompileFn,\n type FormatFn,\n} from '#packages/cli-lib/formatters/default.js'\n\nexport type StructuredJson = Record<\n string,\n {\n string: string\n developer_comment?: string\n context?: string\n character_limit?: string\n }\n>\n\nexport const format: FormatFn<StructuredJson> = msgs => {\n const results: StructuredJson = {}\n for (const [id, msg] of Object.entries(msgs)) {\n results[id] = {\n string: msg.defaultMessage!,\n developer_comment:\n typeof msg.description === 'string'\n ? msg.description\n : JSON.stringify(msg.description),\n }\n }\n return results\n}\n\nexport const compile: CompileFn<StructuredJson> = msgs => {\n const results: Record<string, string> = {}\n for (const [id, msg] of Object.entries(msgs)) {\n results[id] = msg.string\n }\n return results\n}\n","import type {Comparator} from 'json-stable-stringify'\nimport {resolve} from 'path'\nimport {pathToFileURL} from 'url'\nimport * as crowdin from '#packages/cli-lib/formatters/crowdin.js'\nimport * as defaultFormatter from '#packages/cli-lib/formatters/default.js'\nimport {\n type CompileFn,\n type FormatFn,\n type SerializeFn,\n} from '#packages/cli-lib/formatters/default.js'\nimport * as lokalise from '#packages/cli-lib/formatters/lokalise.js'\nimport * as simple from '#packages/cli-lib/formatters/simple.js'\nimport * as smartling from '#packages/cli-lib/formatters/smartling.js'\nimport * as transifex from '#packages/cli-lib/formatters/transifex.js'\n\nexport interface Formatter<T> {\n serialize?: SerializeFn<T>\n format: FormatFn<T>\n compile: CompileFn<T>\n compareMessages?: Comparator\n}\n\nexport async function resolveBuiltinFormatter(\n format?: string | Formatter<unknown>\n): Promise<any> {\n if (!format) {\n return defaultFormatter\n }\n if (typeof format !== 'string') {\n return format\n }\n switch (format) {\n case 'transifex':\n return transifex\n case 'smartling':\n return smartling\n case 'simple':\n return simple\n case 'lokalise':\n return lokalise\n case 'crowdin':\n return crowdin\n }\n try {\n // eslint-disable-next-line import/dynamic-import-chunkname\n return import(pathToFileURL(resolve(process.cwd(), format)).href)\n } catch (e) {\n console.error(`Cannot resolve formatter ${format}`)\n throw e\n }\n}\n","import {createRequire} from 'module'\n\nconst require = createRequire(import.meta.url)\n\nconst NATIVE_PACKAGES: Record<string, string[]> = {\n 'darwin-arm64': ['@formatjs/cli-native-darwin-arm64'],\n 'linux-arm64': [\n '@formatjs/cli-native-linux-arm64',\n '@formatjs/cli-native-linux-arm64-musl',\n ],\n 'linux-x64': [\n '@formatjs/cli-native-linux-x64',\n '@formatjs/cli-native-linux-x64-musl',\n ],\n 'win32-x64': ['@formatjs/cli-native-win32-x64'],\n}\n\nexport interface NativeCompileOptions {\n ast?: boolean\n format?: string\n ignoreTag?: boolean\n pseudoLocale?: string\n skipErrors?: boolean\n followLinks?: boolean\n}\n\nexport interface NativeCompileMessage {\n id: string\n message: string\n sourceFile: string\n}\n\nexport interface NativeExtractOptions {\n additionalComponentNames?: string[]\n additionalFunctionNames?: string[]\n extractSourceLocation?: boolean\n flatten?: boolean\n followLinks?: boolean\n format?: string\n idInterpolationPattern?: string\n ignore?: string[]\n inFile?: string\n pragma?: string\n preserveWhitespace?: boolean\n throws?: boolean\n}\n\nexport interface NativeBinding {\n compile(inputFiles: string[], opts?: NativeCompileOptions): string\n compileMessages(\n messages: NativeCompileMessage[],\n opts?: NativeCompileOptions\n ): string\n extract(inputFiles: string[], opts?: NativeExtractOptions): string\n supportedBuiltinFormatters(): string[]\n}\n\nlet nativeBinding: NativeBinding | null | undefined\n\nexport function getInstalledNativePackageCandidates(\n candidates: readonly string[],\n canResolve = (candidate: string): boolean => {\n try {\n require.resolve(candidate)\n return true\n } catch {\n return false\n }\n }\n): string[] {\n return candidates.filter(canResolve)\n}\n\nexport function getNativePackageCandidates(\n platform: NodeJS.Platform = process.platform,\n arch: string = process.arch\n): string[] {\n const platformArch = `${platform}-${arch}`\n return NATIVE_PACKAGES[platformArch] || []\n}\n\nexport function loadNative(): NativeBinding {\n if (nativeBinding !== undefined) {\n if (nativeBinding) {\n return nativeBinding\n }\n throw new Error('Native @formatjs/cli-lib binding is unavailable')\n }\n\n const overridePath = process.env.FORMATJS_CLI_LIB_NATIVE_PATH\n const packageCandidates = getNativePackageCandidates()\n const installedPackageCandidates =\n getInstalledNativePackageCandidates(packageCandidates)\n const candidates = [\n overridePath,\n ...(installedPackageCandidates.length\n ? installedPackageCandidates\n : packageCandidates),\n ].filter(Boolean) as string[]\n const loadErrors: string[] = []\n\n for (const candidate of candidates) {\n try {\n nativeBinding = require(candidate) as NativeBinding\n return nativeBinding\n } catch (e) {\n loadErrors.push(`${candidate}: ${(e as Error).message}`)\n }\n }\n\n nativeBinding = null\n throw new Error(\n `Native @formatjs/cli-lib binding is unavailable.\\n${loadErrors.join('\\n')}`\n )\n}\n\nexport function compileWithNative(\n inputFiles: string[],\n opts: NativeCompileOptions = {}\n): string {\n const native = loadNative()\n return native.compile(inputFiles, {\n ast: opts.ast,\n format: opts.format,\n followLinks: opts.followLinks,\n ignoreTag: opts.ignoreTag,\n pseudoLocale: opts.pseudoLocale,\n skipErrors: opts.skipErrors,\n })\n}\n\nexport function compileMessagesWithNative(\n messages: NativeCompileMessage[],\n opts: NativeCompileOptions = {}\n): string {\n const native = loadNative()\n return native.compileMessages(messages, {\n ast: opts.ast,\n ignoreTag: opts.ignoreTag,\n pseudoLocale: opts.pseudoLocale,\n skipErrors: opts.skipErrors,\n })\n}\n\nexport function extractWithNative(\n inputFiles: readonly string[],\n opts: NativeExtractOptions = {}\n): string {\n const native = loadNative()\n return native.extract([...inputFiles], {\n additionalComponentNames: opts.additionalComponentNames,\n additionalFunctionNames: opts.additionalFunctionNames,\n extractSourceLocation: opts.extractSourceLocation,\n flatten: opts.flatten,\n followLinks: opts.followLinks,\n format: opts.format,\n idInterpolationPattern: opts.idInterpolationPattern,\n ignore: opts.ignore,\n inFile: opts.inFile,\n pragma: opts.pragma,\n preserveWhitespace: opts.preserveWhitespace,\n throws: opts.throws,\n })\n}\n","import {\n type MessageDescriptor,\n type Opts,\n interpolateName,\n} from '@formatjs/ts-transformer'\nimport {existsSync} from 'fs'\nimport {outputFile} from 'fs-extra/esm'\nimport {\n debug,\n getStdinAsString,\n warn,\n writeStdout,\n} from '#packages/cli-lib/console_utils.js'\nimport * as stringifyNs from 'json-stable-stringify'\nimport {extname} from 'path'\n\nimport {\n type Formatter,\n resolveBuiltinFormatter,\n} from '#packages/cli-lib/formatters/index.js'\nimport {extractWithNative} from '#packages/cli-lib/native.js'\nimport {parseScript} from '#packages/cli-lib/parse_script.js'\nimport {readFile} from 'fs/promises'\n\nconst stringify = (stringifyNs as any).default || stringifyNs\nconst BUILTIN_FORMATTERS = new Set([\n 'default',\n 'simple',\n 'transifex',\n 'smartling',\n 'lokalise',\n 'crowdin',\n])\nconst NATIVE_SUPPORTED_EXTENSIONS = new Set([\n '.cjs',\n '.js',\n '.jsx',\n '.mjs',\n '.ts',\n '.tsx',\n])\nexport interface ExtractionResult<M = Record<string, string>> {\n /**\n * List of extracted messages\n */\n messages: MessageDescriptor[]\n /**\n * Metadata extracted w/ `pragma`\n */\n meta?: M\n}\n\nexport interface ExtractedMessageDescriptor extends MessageDescriptor {\n /**\n * Line number\n */\n line?: number\n /**\n * Column number\n */\n col?: number\n /**\n * Metadata extracted from pragma\n */\n meta?: Record<string, string>\n}\n\nexport type ExtractCLIOptions = Omit<\n ExtractOpts,\n 'overrideIdFn' | 'onMsgExtracted' | 'onMetaExtracted'\n> & {\n /**\n * Output File\n */\n outFile?: string\n /**\n * Input File\n */\n inFile?: string\n /**\n * Ignore file glob pattern\n */\n ignore?: string[]\n /**\n * Whether to follow symbolic links when traversing directories.\n * Defaults to true for compatibility with pnpm symlinked node_modules.\n */\n followLinks?: boolean\n}\n\nexport type ExtractOpts = Opts & {\n /**\n * Whether to throw an error if we had any issues with\n * 1 of the source files\n */\n throws?: boolean\n /**\n * Message ID interpolation pattern\n */\n idInterpolationPattern?: string\n /**\n * Whether we read from stdin instead of a file\n */\n readFromStdin?: boolean\n /**\n * Either path to a formatter file that controls the shape of JSON file from `outFile` or {@link Formatter} object.\n */\n format?: string | Formatter<any>\n /**\n * Whether to hoist selectors & flatten sentences\n */\n flatten?: boolean\n /**\n * An AbortSignal to cancel the extraction\n */\n signal?: AbortSignal\n} & Pick<Opts, 'onMsgExtracted' | 'onMetaExtracted'>\n\nfunction calculateLineColFromOffset(\n text: string,\n start?: number\n): Pick<ExtractedMessageDescriptor, 'line' | 'col'> {\n if (!start) {\n return {line: 1, col: 1}\n }\n const chunk = text.slice(0, start)\n const lines = chunk.split('\\n')\n const lastLine = lines[lines.length - 1]\n return {line: lines.length, col: lastLine.length}\n}\n\nfunction isBuiltinFormatter(\n format: ExtractOpts['format']\n): format is string | undefined {\n return (\n !format || (typeof format === 'string' && BUILTIN_FORMATTERS.has(format))\n )\n}\n\nfunction canExtractWithNative(\n files: readonly string[],\n opts: Omit<ExtractOpts, 'readFromStdin' | 'signal' | 'throws'>,\n readFromStdin: boolean | undefined\n): boolean {\n return (\n !readFromStdin &&\n typeof opts.idInterpolationPattern === 'string' &&\n !opts.ast &&\n !opts.extractSourceLocation &&\n !opts.onMetaExtracted &&\n !opts.onMsgError &&\n !opts.onMsgExtracted &&\n !opts.overrideIdFn &&\n !opts.pragma &&\n !opts.removeDefaultMessage &&\n isBuiltinFormatter(opts.format) &&\n files.every(\n file =>\n existsSync(file) &&\n NATIVE_SUPPORTED_EXTENSIONS.has(extname(file).toLowerCase())\n )\n )\n}\n\nasync function processFile(\n source: string,\n fn: string,\n {idInterpolationPattern, ...opts}: Opts & {idInterpolationPattern?: string}\n) {\n let messages: ExtractedMessageDescriptor[] = []\n let meta: Record<string, string> | undefined\n\n const onMsgExtracted = opts.onMsgExtracted\n const onMetaExtracted = opts.onMetaExtracted\n\n opts = {\n ...opts,\n additionalComponentNames: [\n '$formatMessage',\n ...(opts.additionalComponentNames || []),\n ],\n onMsgExtracted(filePath, msgs) {\n if (opts.extractSourceLocation) {\n msgs = msgs.map(msg => ({\n ...msg,\n ...calculateLineColFromOffset(source, msg.start),\n }))\n }\n messages = messages.concat(msgs)\n\n if (onMsgExtracted) {\n onMsgExtracted(filePath, msgs)\n }\n },\n onMetaExtracted(filePath, m) {\n meta = m\n\n if (onMetaExtracted) {\n onMetaExtracted(filePath, m)\n }\n },\n }\n\n if (!opts.overrideIdFn && idInterpolationPattern) {\n opts = {\n ...opts,\n overrideIdFn: (id, defaultMessage, description, fileName) =>\n id ||\n interpolateName(\n {\n resourcePath: fileName,\n } as any,\n idInterpolationPattern,\n {\n content: description\n ? `${defaultMessage}#${\n typeof description === 'string'\n ? description\n : stringify(description)\n }`\n : defaultMessage,\n }\n ),\n }\n }\n\n debug('Processing opts for %s: %s', fn, opts)\n\n const scriptParseFn = parseScript(opts, fn)\n if (fn.endsWith('.vue')) {\n debug('Processing %s using vue extractor', fn)\n const {parseFile} = await import('./vue_extractor.js')\n parseFile(source, fn, scriptParseFn)\n } else if (fn.endsWith('.svelte')) {\n debug('Processing %s using svelte extractor', fn)\n const {parseFile} = await import('./svelte_extractor.js')\n parseFile(source, fn, scriptParseFn)\n } else if (fn.endsWith('.hbs')) {\n debug('Processing %s using hbs extractor', fn)\n const {parseFile} = await import('./hbs_extractor.js')\n parseFile(source, fn, opts)\n } else if (fn.endsWith('.gts') || fn.endsWith('.gjs')) {\n debug('Processing %s as gts/gjs file', fn)\n const {parseFile} = await import('./gts_extractor.js')\n parseFile(source, fn, opts)\n } else {\n debug('Processing %s using typescript extractor', fn)\n scriptParseFn(source)\n }\n debug('Done extracting %s messages: %s', fn, messages)\n if (meta) {\n debug('Extracted meta:', meta)\n messages.forEach(m => (m.meta = meta))\n }\n return {messages, meta}\n}\n\n/**\n * Extract strings from source files\n * @param files list of files\n * @param extractOpts extract options\n * @returns messages serialized as JSON string since key order\n * matters for some `format`\n */\nexport async function extract(\n files: readonly string[],\n extractOpts: ExtractOpts\n): Promise<string> {\n const {throws, readFromStdin, signal, ...opts} = extractOpts\n // When throws is not explicitly true, we want to collect partial results\n const shouldThrow = throws === true\n // Pass throws option to transformer for per-message error handling\n const optsWithThrows = {\n ...opts,\n throws: shouldThrow,\n onMsgError: !shouldThrow\n ? (_: string, e: Error) => warn(e.message)\n : undefined,\n }\n\n if (!signal?.aborted && canExtractWithNative(files, opts, readFromStdin)) {\n return extractWithNative(files, {\n additionalComponentNames: [\n '$formatMessage',\n ...(opts.additionalComponentNames || []),\n ],\n additionalFunctionNames: opts.additionalFunctionNames,\n flatten: opts.flatten,\n format: typeof opts.format === 'string' ? opts.format : undefined,\n idInterpolationPattern: opts.idInterpolationPattern,\n preserveWhitespace: opts.preserveWhitespace,\n throws: shouldThrow,\n })\n }\n\n let rawResults: Array<ExtractionResult | undefined> = []\n try {\n if (readFromStdin) {\n debug(`Reading input from stdin`)\n // Read from stdin\n if (process.stdin.isTTY) {\n warn('Reading source file from TTY.')\n }\n const stdinSource = await getStdinAsString()\n rawResults = [await processFile(stdinSource, 'dummy', optsWithThrows)]\n } else {\n // Use Promise.allSettled when throws is not explicitly true to collect partial results\n if (!shouldThrow) {\n const settledResults = await Promise.allSettled(\n files.map(async fn => {\n debug('Extracting file:', fn)\n const source = await readFile(fn, {encoding: 'utf8', signal})\n return processFile(source, fn, optsWithThrows)\n })\n )\n rawResults = settledResults.map(result => {\n if (result.status === 'fulfilled') {\n return result.value\n } else {\n warn(String(result.reason))\n return undefined\n }\n })\n } else {\n rawResults = await Promise.all(\n files.map(async fn => {\n debug('Extracting file:', fn)\n const source = await readFile(fn, {encoding: 'utf8', signal})\n return processFile(source, fn, optsWithThrows)\n })\n )\n }\n }\n } catch (e) {\n if (shouldThrow) {\n throw e\n } else {\n warn(String(e))\n }\n }\n\n const formatter: Formatter<unknown> = await resolveBuiltinFormatter(\n opts.format\n )\n const extractionResults = rawResults.filter((r): r is ExtractionResult => !!r)\n\n const extractedMessages = new Map<string, MessageDescriptor>()\n\n for (const {messages} of extractionResults) {\n for (const message of messages) {\n const {id, description, defaultMessage} = message\n if (!id) {\n const error = new Error(\n `[FormatJS CLI] Missing message id for message:\n${JSON.stringify(message, undefined, 2)}`\n )\n if (throws) {\n throw error\n } else {\n warn(error.message)\n }\n continue\n }\n\n if (extractedMessages.has(id)) {\n const existing = extractedMessages.get(id)!\n if (\n stringify(description) !== stringify(existing.description) ||\n defaultMessage !== existing.defaultMessage\n ) {\n const error = new Error(\n `[FormatJS CLI] Duplicate message id: \"${id}\", ` +\n 'but the `description` and/or `defaultMessage` are different.'\n )\n if (throws) {\n throw error\n } else {\n warn(error.message)\n }\n }\n }\n extractedMessages.set(id, message)\n }\n }\n const results: Record<string, Omit<MessageDescriptor, 'id'>> = {}\n const messages = Array.from(extractedMessages.values())\n for (const {id, ...msg} of messages) {\n // GH #3537: flatten is now applied during extraction in the babel plugin,\n // so we don't need to apply it again here. The messages are already flattened.\n results[id] = msg\n }\n if (typeof formatter.serialize === 'function') {\n return formatter.serialize(formatter.format(results as any))\n }\n return (\n stringify(formatter.format(results as any), {\n space: 2,\n cmp: formatter.compareMessages || undefined,\n }) ?? ''\n )\n}\n\n/**\n * Extract strings from source files, also writes to a file.\n * @param files list of files\n * @param extractOpts extract options\n * @returns A Promise that resolves if output file was written successfully\n */\nexport default async function extractAndWrite(\n files: readonly string[],\n extractOpts: ExtractCLIOptions\n): Promise<void> {\n const {outFile, ...opts} = extractOpts\n const serializedResult = (await extract(files, opts)) + '\\n'\n if (outFile) {\n debug('Writing output file:', outFile)\n return outputFile(outFile, serializedResult)\n }\n await writeStdout(serializedResult)\n}\n","import {outputFile} from 'fs-extra/esm'\nimport {readFile} from 'fs/promises'\nimport glob from 'fast-glob'\nimport * as stringifyNs from 'json-stable-stringify'\nimport {resolve} from 'path'\nimport {pathToFileURL} from 'url'\nimport {debug, warn, writeStdout} from '#packages/cli-lib/console_utils.js'\nimport {type Formatter} from '#packages/cli-lib/formatters/index.js'\nimport {\n type NativeCompileMessage,\n compileMessagesWithNative,\n compileWithNative,\n} from '#packages/cli-lib/native.js'\n\nconst dynamicImport = new Function('specifier', 'return import(specifier)') as (\n specifier: string\n) => Promise<Formatter<unknown>>\nconst globSync = glob.sync\nconst stringify = (stringifyNs as any).default || stringifyNs\nconst CUSTOM_FORMATTER_FILE_DEPRECATION_WARNING =\n 'Passing a custom formatter file to --format during compilation is deprecated and will be removed in a future release. Prefer a built-in formatter name or pre-process translation files before running formatjs compile.'\n\nconst BUILTIN_FORMATTERS = new Set([\n 'default',\n 'simple',\n 'transifex',\n 'smartling',\n 'lokalise',\n 'crowdin',\n])\n\nexport type PseudoLocale = 'xx-LS' | 'xx-AC' | 'xx-HA' | 'en-XA' | 'en-XB'\n\nexport interface CompileCLIOpts extends Opts {\n /**\n * The target file that contains compiled messages.\n */\n outFile?: string\n}\n\nexport interface Opts {\n /**\n * Whether to compile message into AST instead of just string\n */\n ast?: boolean\n /**\n * Whether to continue compiling messages after encountering an error.\n * Any keys with errors will not be included in the output file.\n */\n skipErrors?: boolean\n /**\n * Built-in formatter name or path to a formatter file that converts\n * <translation_files> to `Record<string, string>` so we can compile.\n * Formatter file paths are deprecated for compilation.\n */\n format?: string | Formatter<unknown>\n /**\n * Whether to compile to pseudo locale\n */\n pseudoLocale?: PseudoLocale\n /**\n * Whether the parser to treat HTML/XML tags as string literal\n * instead of parsing them as tag token.\n * When this is false we only allow simple tags without\n * any attributes\n */\n ignoreTag?: boolean\n /**\n * An AbortSignal to cancel the compilation before invoking native code.\n */\n signal?: AbortSignal\n /**\n * Whether to follow symbolic links when traversing directories.\n * Defaults to true for compatibility with pnpm symlinked node_modules.\n */\n followLinks?: boolean\n}\n\n/**\n * Compile extracted translation files with the native formatjs CLI binding.\n * @param inputFiles Input files or glob patterns\n * @param opts Options\n * @returns serialized result in string format\n */\nexport async function compile(\n inputFiles: string[],\n opts: Opts = {}\n): Promise<string> {\n debug('Compiling files:', inputFiles)\n const {\n ast,\n format,\n pseudoLocale,\n skipErrors,\n ignoreTag,\n signal,\n followLinks,\n } = opts\n signal?.throwIfAborted()\n\n if (format && !isBuiltinFormatter(format)) {\n return compileWithCustomFormatter(inputFiles, opts)\n }\n\n return compileWithNative(inputFiles, {\n ast,\n format: typeof format === 'string' ? format : undefined,\n followLinks,\n ignoreTag,\n pseudoLocale,\n skipErrors,\n })\n}\n\nfunction isBuiltinFormatter(\n format: string | Formatter<unknown>\n): format is string {\n return typeof format === 'string' && BUILTIN_FORMATTERS.has(format)\n}\n\nasync function compileWithCustomFormatter(\n inputFiles: string[],\n opts: Opts\n): Promise<string> {\n if (typeof opts.format === 'string') {\n await warn(CUSTOM_FORMATTER_FILE_DEPRECATION_WARNING)\n }\n\n const formatter = await resolveCustomFormatter(opts.format)\n const files = globSync(inputFiles, {\n followSymbolicLinks: opts.followLinks ?? true,\n })\n\n if (!files.length) {\n throw new Error('No translation files found matching the patterns')\n }\n\n const messages: NativeCompileMessage[] = []\n await Promise.all(\n files.map(async file => {\n opts.signal?.throwIfAborted()\n const content = await readFile(file, {\n encoding: 'utf8',\n signal: opts.signal,\n })\n const compiled = formatter.compile(JSON.parse(content))\n for (const id of Object.keys(compiled)) {\n messages.push({\n id,\n message: compiled[id],\n sourceFile: file,\n })\n }\n })\n )\n\n const serialized = compileMessagesWithNative(messages, {\n ast: opts.ast,\n ignoreTag: opts.ignoreTag,\n pseudoLocale: opts.pseudoLocale,\n skipErrors: opts.skipErrors,\n })\n\n if (formatter.compareMessages) {\n return (\n stringify(JSON.parse(serialized), {\n space: 2,\n cmp: formatter.compareMessages,\n }) ?? ''\n )\n }\n\n return serialized\n}\n\nasync function resolveCustomFormatter(\n format: string | Formatter<unknown> | undefined\n): Promise<Formatter<unknown>> {\n if (!format) {\n throw new Error('A custom formatter is required')\n }\n if (typeof format !== 'string') {\n return format\n }\n try {\n return dynamicImport(pathToFileURL(resolve(process.cwd(), format)).href)\n } catch (e) {\n console.error(`Cannot resolve formatter ${format}`)\n throw e\n }\n}\n\n/**\n * Compile extracted translation files with the native formatjs CLI binding and\n * write output to `outFile` when provided.\n * @param inputFiles Input files or glob patterns\n * @param compileOpts options\n * @returns A `Promise` that resolves if file was written successfully\n */\nexport default async function compileAndWrite(\n inputFiles: string[],\n compileOpts: CompileCLIOpts = {}\n): Promise<void> {\n const {outFile, ...opts} = compileOpts\n const serializedResult = (await compile(inputFiles, opts)) + '\\n'\n if (outFile) {\n debug('Writing output file:', outFile)\n return outputFile(outFile, serializedResult)\n }\n await writeStdout(serializedResult)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,MAAaA,YAAgC,SAAQ;CACnD,MAAM,UAAuB,CAAC;CAC9B,KAAK,MAAM,CAAC,IAAI,QAAQ,OAAO,QAAQ,IAAI,GACzC,QAAQ,MAAM;EACZ,SAAS,IAAI;EACb,aACE,OAAO,IAAI,gBAAgB,WACvB,IAAI,cACJ,KAAK,UAAU,IAAI,WAAW;CACtC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;AACF;;;;;;;;AASA,eAA8B,gBAC5B,YACA,cAA8B,CAAC,GAChB;CACf,MAAM,EAAC,SAAS,GAAG,SAAQ;CAC3B,MAAM,mBAAoB,MAAM,QAAQ,YAAY,IAAI,IAAK;CAC7D,IAAI,SAAS;EACX,MAAM,wBAAwB,OAAO;EACrC,OAAO,WAAW,SAAS,gBAAgB;CAC7C;CACA,MAAM,YAAY,gBAAgB;AACpC"}
1
+ {"version":3,"file":"index.js","names":["format","compile","format","compile","format","compile","format","compile","format","compile","compile","defaultFormatter","transifex","smartling","simple","lokalise","crowdin","require","stringify","BUILTIN_FORMATTERS","isBuiltinFormatter"],"sources":["../formatters/crowdin.ts","../formatters/default.ts","../formatters/lokalise.ts","../formatters/simple.ts","../formatters/smartling.ts","../formatters/transifex.ts","../formatters/index.ts","../native.ts","../extract.ts","../compile.ts"],"sourcesContent":["import {\n type CompileFn,\n type FormatFn,\n} from '#packages/cli-lib/formatters/default.js'\n\nexport type CrowdinJson = Record<\n string,\n {\n message: string\n description?: string\n }\n>\n\nexport const format: FormatFn<CrowdinJson> = msgs => {\n const results: CrowdinJson = {}\n for (const [id, msg] of Object.entries(msgs)) {\n results[id] = {\n message: msg.defaultMessage!,\n description:\n typeof msg.description === 'string'\n ? msg.description\n : JSON.stringify(msg.description),\n }\n }\n return results\n}\n\nexport const compile: CompileFn<CrowdinJson> = msgs => {\n const results: Record<string, string> = {}\n for (const [id, msg] of Object.entries(msgs)) {\n if (id === 'smartling') {\n continue\n }\n results[id] = msg.message\n }\n return results\n}\n","import {type MessageDescriptor} from '@formatjs/ts-transformer'\nexport type FormatFn<T = Record<string, MessageDescriptor>> = (\n msgs: Record<string, MessageDescriptor>\n) => T\n\nexport type CompileFn<T = Record<string, MessageDescriptor>> = (\n msgs: T\n) => Record<string, string>\n\nexport type SerializeFn<T = Record<string, MessageDescriptor>> = (\n msgs: T\n) => string\n\nexport const format: FormatFn = msgs => msgs\n\nexport const compile: CompileFn = msgs => {\n const results: Record<string, string> = {}\n for (const k in msgs) {\n results[k] = msgs[k].defaultMessage!\n }\n return results\n}\n","import {\n type CompileFn,\n type FormatFn,\n} from '#packages/cli-lib/formatters/default.js'\n\nexport type StructuredJson = Record<\n string,\n {\n translation: string\n notes?: string\n context?: string\n limit?: string\n }\n>\n\nexport const format: FormatFn<StructuredJson> = msgs => {\n const results: StructuredJson = {}\n for (const [id, msg] of Object.entries(msgs)) {\n results[id] = {\n translation: msg.defaultMessage!,\n notes:\n typeof msg.description === 'string'\n ? msg.description\n : JSON.stringify(msg.description),\n }\n }\n return results\n}\n\nexport const compile: CompileFn<StructuredJson> = msgs => {\n const results: Record<string, string> = {}\n for (const [id, msg] of Object.entries(msgs)) {\n results[id] = msg.translation\n }\n return results\n}\n","import {\n type CompileFn,\n type FormatFn,\n} from '#packages/cli-lib/formatters/default.js'\n\nexport type PhraseJson = Record<string, string>\n\nexport const format: FormatFn<PhraseJson> = msgs => {\n return Object.keys(msgs).reduce((all: PhraseJson, k) => {\n all[k] = msgs[k].defaultMessage!\n return all\n }, {})\n}\n\nexport const compile: CompileFn<PhraseJson> = msgs => msgs\n","import type {Comparator} from 'json-stable-stringify'\nimport {\n type CompileFn,\n type FormatFn,\n} from '#packages/cli-lib/formatters/default.js'\n\nexport interface SmartlingDirectives {\n translate_paths: [\n {\n path: string\n key: string\n instruction: string\n },\n ]\n variants_enabled: boolean\n string_format: string\n [k: string]: any\n}\n\nexport type SmartlingJson = {\n smartling: SmartlingDirectives\n} & Record<\n string,\n {\n message: string\n description?: string\n }\n>\n\nexport const format: FormatFn<SmartlingJson> = msgs => {\n const results: SmartlingJson = {\n smartling: {\n translate_paths: [\n {\n path: '*/message',\n key: '{*}/message',\n instruction: '*/description',\n },\n ],\n variants_enabled: true,\n string_format: 'icu',\n },\n } as any\n for (const [id, msg] of Object.entries(msgs)) {\n results[id] = {\n message: msg.defaultMessage!,\n description:\n typeof msg.description === 'string'\n ? msg.description\n : JSON.stringify(msg.description),\n }\n }\n return results\n}\n\nexport const compareMessages: Comparator = (el1, el2) => {\n // `smartling` has to be the 1st key\n if (el1.key === 'smartling') {\n return -1\n }\n if (el2.key === 'smartling') {\n return 1\n }\n return el1.key < el2.key ? -1 : el1.key === el2.key ? 0 : 1\n}\n\nexport const compile: CompileFn<SmartlingJson> = msgs => {\n const results: Record<string, string> = {}\n for (const [id, msg] of Object.entries(msgs)) {\n if (id === 'smartling') {\n continue\n }\n results[id] = msg.message\n }\n return results\n}\n","import {\n type CompileFn,\n type FormatFn,\n} from '#packages/cli-lib/formatters/default.js'\n\nexport type StructuredJson = Record<\n string,\n {\n string: string\n developer_comment?: string\n context?: string\n character_limit?: string\n }\n>\n\nexport const format: FormatFn<StructuredJson> = msgs => {\n const results: StructuredJson = {}\n for (const [id, msg] of Object.entries(msgs)) {\n results[id] = {\n string: msg.defaultMessage!,\n developer_comment:\n typeof msg.description === 'string'\n ? msg.description\n : JSON.stringify(msg.description),\n }\n }\n return results\n}\n\nexport const compile: CompileFn<StructuredJson> = msgs => {\n const results: Record<string, string> = {}\n for (const [id, msg] of Object.entries(msgs)) {\n results[id] = msg.string\n }\n return results\n}\n","import type {Comparator} from 'json-stable-stringify'\nimport {resolve} from 'path'\nimport {pathToFileURL} from 'url'\nimport * as crowdin from '#packages/cli-lib/formatters/crowdin.js'\nimport * as defaultFormatter from '#packages/cli-lib/formatters/default.js'\nimport {\n type CompileFn,\n type FormatFn,\n type SerializeFn,\n} from '#packages/cli-lib/formatters/default.js'\nimport * as lokalise from '#packages/cli-lib/formatters/lokalise.js'\nimport * as simple from '#packages/cli-lib/formatters/simple.js'\nimport * as smartling from '#packages/cli-lib/formatters/smartling.js'\nimport * as transifex from '#packages/cli-lib/formatters/transifex.js'\n\nexport interface Formatter<T> {\n serialize?: SerializeFn<T>\n format: FormatFn<T>\n compile: CompileFn<T>\n compareMessages?: Comparator\n}\n\nexport async function resolveBuiltinFormatter(\n format?: string | Formatter<unknown>\n): Promise<any> {\n if (!format) {\n return defaultFormatter\n }\n if (typeof format !== 'string') {\n return format\n }\n switch (format) {\n case 'transifex':\n return transifex\n case 'smartling':\n return smartling\n case 'simple':\n return simple\n case 'lokalise':\n return lokalise\n case 'crowdin':\n return crowdin\n }\n try {\n // eslint-disable-next-line import/dynamic-import-chunkname\n return import(pathToFileURL(resolve(process.cwd(), format)).href)\n } catch (e) {\n console.error(`Cannot resolve formatter ${format}`)\n throw e\n }\n}\n","import {createRequire} from 'module'\n\nconst require = createRequire(import.meta.url)\n\nconst NATIVE_PACKAGES: Record<string, string[]> = {\n 'darwin-arm64': ['@formatjs/cli-native-darwin-arm64'],\n 'linux-arm64': [\n '@formatjs/cli-native-linux-arm64',\n '@formatjs/cli-native-linux-arm64-musl',\n ],\n 'linux-x64': [\n '@formatjs/cli-native-linux-x64',\n '@formatjs/cli-native-linux-x64-musl',\n ],\n 'win32-x64': ['@formatjs/cli-native-win32-x64'],\n}\n\nexport interface NativeCompileOptions {\n ast?: boolean\n format?: string\n ignoreTag?: boolean\n pseudoLocale?: string\n skipErrors?: boolean\n followLinks?: boolean\n}\n\nexport interface NativeCompileMessage {\n id: string\n message: string\n sourceFile: string\n}\n\nexport interface NativeExtractOptions {\n additionalComponentNames?: string[]\n additionalFunctionNames?: string[]\n extractSourceLocation?: boolean\n flatten?: boolean\n followLinks?: boolean\n format?: string\n idInterpolationPattern?: string\n ignore?: string[]\n inFile?: string\n pragma?: string\n preserveWhitespace?: boolean\n throws?: boolean\n}\n\nexport interface NativeBinding {\n compile(inputFiles: string[], opts?: NativeCompileOptions): string\n compileMessages(\n messages: NativeCompileMessage[],\n opts?: NativeCompileOptions\n ): string\n extract(inputFiles: string[], opts?: NativeExtractOptions): string\n supportedBuiltinFormatters(): string[]\n}\n\nlet nativeBinding: NativeBinding | null | undefined\n\nexport function getInstalledNativePackageCandidates(\n candidates: readonly string[],\n canResolve = (candidate: string): boolean => {\n try {\n require.resolve(candidate)\n return true\n } catch {\n return false\n }\n }\n): string[] {\n return candidates.filter(canResolve)\n}\n\nexport function getNativePackageCandidates(\n platform: NodeJS.Platform = process.platform,\n arch: string = process.arch\n): string[] {\n const platformArch = `${platform}-${arch}`\n return NATIVE_PACKAGES[platformArch] || []\n}\n\nexport function loadNative(): NativeBinding {\n if (nativeBinding !== undefined) {\n if (nativeBinding) {\n return nativeBinding\n }\n throw new Error('Native @formatjs/cli-lib binding is unavailable')\n }\n\n const overridePath = process.env.FORMATJS_CLI_LIB_NATIVE_PATH\n const packageCandidates = getNativePackageCandidates()\n const installedPackageCandidates =\n getInstalledNativePackageCandidates(packageCandidates)\n const candidates = [\n overridePath,\n ...(installedPackageCandidates.length\n ? installedPackageCandidates\n : packageCandidates),\n ].filter(Boolean) as string[]\n const loadErrors: string[] = []\n\n for (const candidate of candidates) {\n try {\n nativeBinding = require(candidate) as NativeBinding\n return nativeBinding\n } catch (e) {\n loadErrors.push(`${candidate}: ${(e as Error).message}`)\n }\n }\n\n nativeBinding = null\n throw new Error(\n `Native @formatjs/cli-lib binding is unavailable.\\n${loadErrors.join('\\n')}`\n )\n}\n\nexport function compileWithNative(\n inputFiles: string[],\n opts: NativeCompileOptions = {}\n): string {\n const native = loadNative()\n return native.compile(inputFiles, {\n ast: opts.ast,\n format: opts.format,\n followLinks: opts.followLinks,\n ignoreTag: opts.ignoreTag,\n pseudoLocale: opts.pseudoLocale,\n skipErrors: opts.skipErrors,\n })\n}\n\nexport function compileMessagesWithNative(\n messages: NativeCompileMessage[],\n opts: NativeCompileOptions = {}\n): string {\n const native = loadNative()\n return native.compileMessages(messages, {\n ast: opts.ast,\n ignoreTag: opts.ignoreTag,\n pseudoLocale: opts.pseudoLocale,\n skipErrors: opts.skipErrors,\n })\n}\n\nexport function extractWithNative(\n inputFiles: readonly string[],\n opts: NativeExtractOptions = {}\n): string {\n const native = loadNative()\n return native.extract([...inputFiles], {\n additionalComponentNames: opts.additionalComponentNames,\n additionalFunctionNames: opts.additionalFunctionNames,\n extractSourceLocation: opts.extractSourceLocation,\n flatten: opts.flatten,\n followLinks: opts.followLinks,\n format: opts.format,\n idInterpolationPattern: opts.idInterpolationPattern,\n ignore: opts.ignore,\n inFile: opts.inFile,\n pragma: opts.pragma,\n preserveWhitespace: opts.preserveWhitespace,\n throws: opts.throws,\n })\n}\n","import {\n type MessageDescriptor,\n type Opts,\n interpolateName,\n} from '@formatjs/ts-transformer'\nimport {existsSync} from 'fs'\nimport {outputFile} from 'fs-extra/esm'\nimport {\n debug,\n getStdinAsString,\n warn,\n writeStdout,\n} from '#packages/cli-lib/console_utils.js'\nimport * as stringifyNs from 'json-stable-stringify'\nimport {extname} from 'path'\n\nimport {\n type Formatter,\n resolveBuiltinFormatter,\n} from '#packages/cli-lib/formatters/index.js'\nimport {extractWithNative} from '#packages/cli-lib/native.js'\nimport {parseScript} from '#packages/cli-lib/parse_script.js'\nimport {readFile} from 'fs/promises'\n\nconst stringify = (stringifyNs as any).default || stringifyNs\nconst BUILTIN_FORMATTERS = new Set([\n 'default',\n 'simple',\n 'transifex',\n 'smartling',\n 'lokalise',\n 'crowdin',\n])\nconst NATIVE_SUPPORTED_EXTENSIONS = new Set([\n '.cjs',\n '.js',\n '.jsx',\n '.mjs',\n '.ts',\n '.tsx',\n])\nexport interface ExtractionResult<M = Record<string, string>> {\n /**\n * List of extracted messages\n */\n messages: MessageDescriptor[]\n /**\n * Metadata extracted w/ `pragma`\n */\n meta?: M\n}\n\nexport interface ExtractedMessageDescriptor extends MessageDescriptor {\n /**\n * Line number\n */\n line?: number\n /**\n * Column number\n */\n col?: number\n /**\n * Metadata extracted from pragma\n */\n meta?: Record<string, string>\n}\n\nexport type ExtractCLIOptions = Omit<\n ExtractOpts,\n 'overrideIdFn' | 'onMsgExtracted' | 'onMetaExtracted'\n> & {\n /**\n * Output File\n */\n outFile?: string\n /**\n * Input File\n */\n inFile?: string\n /**\n * Ignore file glob pattern\n */\n ignore?: string[]\n /**\n * Whether to follow symbolic links when traversing directories.\n * Defaults to true for compatibility with pnpm symlinked node_modules.\n */\n followLinks?: boolean\n}\n\nexport type ExtractOpts = Opts & {\n /**\n * Whether to throw an error if we had any issues with\n * 1 of the source files\n */\n throws?: boolean\n /**\n * Message ID interpolation pattern\n */\n idInterpolationPattern?: string\n /**\n * Whether we read from stdin instead of a file\n */\n readFromStdin?: boolean\n /**\n * Either path to a formatter file that controls the shape of JSON file from `outFile` or {@link Formatter} object.\n */\n format?: string | Formatter<any>\n /**\n * Whether to hoist selectors & flatten sentences\n */\n flatten?: boolean\n /**\n * An AbortSignal to cancel the extraction\n */\n signal?: AbortSignal\n} & Pick<Opts, 'onMsgExtracted' | 'onMetaExtracted'>\n\nfunction calculateLineColFromOffset(\n text: string,\n start?: number\n): Pick<ExtractedMessageDescriptor, 'line' | 'col'> {\n if (!start) {\n return {line: 1, col: 1}\n }\n const chunk = text.slice(0, start)\n const lines = chunk.split('\\n')\n const lastLine = lines[lines.length - 1]\n return {line: lines.length, col: lastLine.length}\n}\n\nfunction isBuiltinFormatter(\n format: ExtractOpts['format']\n): format is string | undefined {\n return (\n !format || (typeof format === 'string' && BUILTIN_FORMATTERS.has(format))\n )\n}\n\nfunction canExtractWithNative(\n files: readonly string[],\n opts: Omit<ExtractOpts, 'readFromStdin' | 'signal' | 'throws'>,\n readFromStdin: boolean | undefined\n): boolean {\n return (\n !readFromStdin &&\n typeof opts.idInterpolationPattern === 'string' &&\n !opts.ast &&\n !opts.extractSourceLocation &&\n !opts.onMetaExtracted &&\n !opts.onMsgError &&\n !opts.onMsgExtracted &&\n !opts.overrideIdFn &&\n !opts.pragma &&\n !opts.removeDefaultMessage &&\n isBuiltinFormatter(opts.format) &&\n files.every(\n file =>\n existsSync(file) &&\n NATIVE_SUPPORTED_EXTENSIONS.has(extname(file).toLowerCase())\n )\n )\n}\n\nasync function processFile(\n source: string,\n fn: string,\n {idInterpolationPattern, ...opts}: Opts & {idInterpolationPattern?: string}\n) {\n let messages: ExtractedMessageDescriptor[] = []\n let meta: Record<string, string> | undefined\n\n const onMsgExtracted = opts.onMsgExtracted\n const onMetaExtracted = opts.onMetaExtracted\n\n opts = {\n ...opts,\n additionalComponentNames: [\n '$formatMessage',\n ...(opts.additionalComponentNames || []),\n ],\n onMsgExtracted(filePath, msgs) {\n if (opts.extractSourceLocation) {\n msgs = msgs.map(msg => ({\n ...msg,\n ...calculateLineColFromOffset(source, msg.start),\n }))\n }\n messages = messages.concat(msgs)\n\n if (onMsgExtracted) {\n onMsgExtracted(filePath, msgs)\n }\n },\n onMetaExtracted(filePath, m) {\n meta = m\n\n if (onMetaExtracted) {\n onMetaExtracted(filePath, m)\n }\n },\n }\n\n if (!opts.overrideIdFn && idInterpolationPattern) {\n opts = {\n ...opts,\n overrideIdFn: (id, defaultMessage, description, fileName) =>\n id ||\n interpolateName(\n {\n resourcePath: fileName,\n } as any,\n idInterpolationPattern,\n {\n content: description\n ? `${defaultMessage}#${\n typeof description === 'string'\n ? description\n : stringify(description)\n }`\n : defaultMessage,\n }\n ),\n }\n }\n\n debug('Processing opts for %s: %s', fn, opts)\n\n const scriptParseFn = parseScript(opts, fn)\n if (fn.endsWith('.vue')) {\n debug('Processing %s using vue extractor', fn)\n const {parseFile} = await import('./vue_extractor.js')\n parseFile(source, fn, scriptParseFn)\n } else if (fn.endsWith('.svelte')) {\n debug('Processing %s using svelte extractor', fn)\n const {parseFile} = await import('./svelte_extractor.js')\n parseFile(source, fn, scriptParseFn)\n } else if (fn.endsWith('.hbs')) {\n debug('Processing %s using hbs extractor', fn)\n const {parseFile} = await import('./hbs_extractor.js')\n parseFile(source, fn, opts)\n } else if (fn.endsWith('.gts') || fn.endsWith('.gjs')) {\n debug('Processing %s as gts/gjs file', fn)\n const {parseFile} = await import('./gts_extractor.js')\n parseFile(source, fn, opts)\n } else {\n debug('Processing %s using typescript extractor', fn)\n scriptParseFn(source)\n }\n debug('Done extracting %s messages: %s', fn, messages)\n if (meta) {\n debug('Extracted meta:', meta)\n messages.forEach(m => (m.meta = meta))\n }\n return {messages, meta}\n}\n\n/**\n * Extract strings from source files\n * @param files list of files\n * @param extractOpts extract options\n * @returns messages serialized as JSON string since key order\n * matters for some `format`\n */\nexport async function extract(\n files: readonly string[],\n extractOpts: ExtractOpts\n): Promise<string> {\n const {throws, readFromStdin, signal, ...opts} = extractOpts\n // When throws is not explicitly true, we want to collect partial results\n const shouldThrow = throws === true\n // Pass throws option to transformer for per-message error handling\n const optsWithThrows = {\n ...opts,\n throws: shouldThrow,\n onMsgError: !shouldThrow\n ? (_: string, e: Error) => warn(e.message)\n : undefined,\n }\n\n if (!signal?.aborted && canExtractWithNative(files, opts, readFromStdin)) {\n return extractWithNative(files, {\n additionalComponentNames: [\n '$formatMessage',\n ...(opts.additionalComponentNames || []),\n ],\n additionalFunctionNames: opts.additionalFunctionNames,\n flatten: opts.flatten,\n format: typeof opts.format === 'string' ? opts.format : undefined,\n idInterpolationPattern: opts.idInterpolationPattern,\n preserveWhitespace: opts.preserveWhitespace,\n throws: shouldThrow,\n })\n }\n\n let rawResults: Array<ExtractionResult | undefined> = []\n try {\n if (readFromStdin) {\n debug(`Reading input from stdin`)\n // Read from stdin\n if (process.stdin.isTTY) {\n warn('Reading source file from TTY.')\n }\n const stdinSource = await getStdinAsString()\n rawResults = [await processFile(stdinSource, 'dummy', optsWithThrows)]\n } else {\n // Use Promise.allSettled when throws is not explicitly true to collect partial results\n if (!shouldThrow) {\n const settledResults = await Promise.allSettled(\n files.map(async fn => {\n debug('Extracting file:', fn)\n const source = await readFile(fn, {encoding: 'utf8', signal})\n return processFile(source, fn, optsWithThrows)\n })\n )\n rawResults = settledResults.map(result => {\n if (result.status === 'fulfilled') {\n return result.value\n } else {\n warn(String(result.reason))\n return undefined\n }\n })\n } else {\n rawResults = await Promise.all(\n files.map(async fn => {\n debug('Extracting file:', fn)\n const source = await readFile(fn, {encoding: 'utf8', signal})\n return processFile(source, fn, optsWithThrows)\n })\n )\n }\n }\n } catch (e) {\n if (shouldThrow) {\n throw e\n } else {\n warn(String(e))\n }\n }\n\n const formatter: Formatter<unknown> = await resolveBuiltinFormatter(\n opts.format\n )\n const extractionResults = rawResults.filter((r): r is ExtractionResult => !!r)\n\n const extractedMessages = new Map<string, MessageDescriptor>()\n\n for (const {messages} of extractionResults) {\n for (const message of messages) {\n const {id, description, defaultMessage} = message\n if (!id) {\n const error = new Error(\n `[FormatJS CLI] Missing message id for message:\n${JSON.stringify(message, undefined, 2)}`\n )\n if (throws) {\n throw error\n } else {\n warn(error.message)\n }\n continue\n }\n\n if (extractedMessages.has(id)) {\n const existing = extractedMessages.get(id)!\n if (\n stringify(description) !== stringify(existing.description) ||\n defaultMessage !== existing.defaultMessage\n ) {\n const error = new Error(\n `[FormatJS CLI] Duplicate message id: \"${id}\", ` +\n 'but the `description` and/or `defaultMessage` are different.'\n )\n if (throws) {\n throw error\n } else {\n warn(error.message)\n }\n }\n }\n extractedMessages.set(id, message)\n }\n }\n const results: Record<string, Omit<MessageDescriptor, 'id'>> = {}\n const messages = Array.from(extractedMessages.values())\n for (const {id, ...msg} of messages) {\n // GH #3537: flatten is now applied during extraction in the babel plugin,\n // so we don't need to apply it again here. The messages are already flattened.\n results[id] = msg\n }\n if (typeof formatter.serialize === 'function') {\n return formatter.serialize(formatter.format(results as any))\n }\n return (\n stringify(formatter.format(results as any), {\n space: 2,\n cmp: formatter.compareMessages || undefined,\n }) ?? ''\n )\n}\n\n/**\n * Extract strings from source files, also writes to a file.\n * @param files list of files\n * @param extractOpts extract options\n * @returns A Promise that resolves if output file was written successfully\n */\nexport default async function extractAndWrite(\n files: readonly string[],\n extractOpts: ExtractCLIOptions\n): Promise<void> {\n const {outFile, ...opts} = extractOpts\n const serializedResult = (await extract(files, opts)) + '\\n'\n if (outFile) {\n debug('Writing output file:', outFile)\n return outputFile(outFile, serializedResult)\n }\n await writeStdout(serializedResult)\n}\n","import {outputFile} from 'fs-extra/esm'\nimport {readFile} from 'fs/promises'\nimport glob from 'fast-glob'\nimport * as stringifyNs from 'json-stable-stringify'\nimport {resolve} from 'path'\nimport {pathToFileURL} from 'url'\nimport {debug, warn, writeStdout} from '#packages/cli-lib/console_utils.js'\nimport {type Formatter} from '#packages/cli-lib/formatters/index.js'\nimport {\n type NativeCompileMessage,\n compileMessagesWithNative,\n compileWithNative,\n} from '#packages/cli-lib/native.js'\n\nconst dynamicImport = new Function('specifier', 'return import(specifier)') as (\n specifier: string\n) => Promise<Formatter<unknown>>\nconst globSync = glob.sync\nconst stringify = (stringifyNs as any).default || stringifyNs\nconst CUSTOM_FORMATTER_FILE_DEPRECATION_WARNING =\n 'Passing a custom formatter file to --format during compilation is deprecated and will be removed in a future release. Prefer a built-in formatter name or pre-process translation files before running formatjs compile.'\n\nconst BUILTIN_FORMATTERS = new Set([\n 'default',\n 'simple',\n 'transifex',\n 'smartling',\n 'lokalise',\n 'crowdin',\n])\n\nexport type PseudoLocale = 'xx-LS' | 'xx-AC' | 'xx-HA' | 'en-XA' | 'en-XB'\n\nexport interface CompileCLIOpts extends Opts {\n /**\n * The target file that contains compiled messages.\n */\n outFile?: string\n}\n\nexport interface Opts {\n /**\n * Whether to compile message into AST instead of just string\n */\n ast?: boolean\n /**\n * Whether to continue compiling messages after encountering an error.\n * Any keys with errors will not be included in the output file.\n */\n skipErrors?: boolean\n /**\n * Built-in formatter name or path to a formatter file that converts\n * <translation_files> to `Record<string, string>` so we can compile.\n * Formatter file paths are deprecated for compilation.\n */\n format?: string | Formatter<unknown>\n /**\n * Whether to compile to pseudo locale\n */\n pseudoLocale?: PseudoLocale\n /**\n * Whether the parser to treat HTML/XML tags as string literal\n * instead of parsing them as tag token.\n * When this is false we only allow simple tags without\n * any attributes\n */\n ignoreTag?: boolean\n /**\n * An AbortSignal to cancel the compilation before invoking native code.\n */\n signal?: AbortSignal\n /**\n * Whether to follow symbolic links when traversing directories.\n * Defaults to true for compatibility with pnpm symlinked node_modules.\n */\n followLinks?: boolean\n}\n\n/**\n * Compile extracted translation files with the native formatjs CLI binding.\n * @param inputFiles Input files or glob patterns\n * @param opts Options\n * @returns serialized result in string format\n */\nexport async function compile(\n inputFiles: string[],\n opts: Opts = {}\n): Promise<string> {\n debug('Compiling files:', inputFiles)\n const {\n ast,\n format,\n pseudoLocale,\n skipErrors,\n ignoreTag,\n signal,\n followLinks,\n } = opts\n signal?.throwIfAborted()\n\n if (format && !isBuiltinFormatter(format)) {\n return compileWithCustomFormatter(inputFiles, opts)\n }\n\n return compileWithNative(inputFiles, {\n ast,\n format: typeof format === 'string' ? format : undefined,\n followLinks,\n ignoreTag,\n pseudoLocale,\n skipErrors,\n })\n}\n\nfunction isBuiltinFormatter(\n format: string | Formatter<unknown>\n): format is string {\n return typeof format === 'string' && BUILTIN_FORMATTERS.has(format)\n}\n\nasync function compileWithCustomFormatter(\n inputFiles: string[],\n opts: Opts\n): Promise<string> {\n if (typeof opts.format === 'string') {\n await warn(CUSTOM_FORMATTER_FILE_DEPRECATION_WARNING)\n }\n\n const formatter = await resolveCustomFormatter(opts.format)\n const files = globSync(inputFiles, {\n followSymbolicLinks: opts.followLinks ?? true,\n })\n\n if (!files.length) {\n throw new Error('No translation files found matching the patterns')\n }\n\n const messages: NativeCompileMessage[] = []\n await Promise.all(\n files.map(async file => {\n opts.signal?.throwIfAborted()\n const content = await readFile(file, {\n encoding: 'utf8',\n signal: opts.signal,\n })\n const compiled = formatter.compile(JSON.parse(content))\n for (const id of Object.keys(compiled)) {\n messages.push({\n id,\n message: compiled[id],\n sourceFile: file,\n })\n }\n })\n )\n\n const serialized = compileMessagesWithNative(messages, {\n ast: opts.ast,\n ignoreTag: opts.ignoreTag,\n pseudoLocale: opts.pseudoLocale,\n skipErrors: opts.skipErrors,\n })\n\n if (formatter.compareMessages) {\n return (\n stringify(JSON.parse(serialized), {\n space: 2,\n cmp: formatter.compareMessages,\n }) ?? ''\n )\n }\n\n return serialized\n}\n\nasync function resolveCustomFormatter(\n format: string | Formatter<unknown> | undefined\n): Promise<Formatter<unknown>> {\n if (!format) {\n throw new Error('A custom formatter is required')\n }\n if (typeof format !== 'string') {\n return format\n }\n try {\n return dynamicImport(pathToFileURL(resolve(process.cwd(), format)).href)\n } catch (e) {\n console.error(`Cannot resolve formatter ${format}`)\n throw e\n }\n}\n\n/**\n * Compile extracted translation files with the native formatjs CLI binding and\n * write output to `outFile` when provided.\n * @param inputFiles Input files or glob patterns\n * @param compileOpts options\n * @returns A `Promise` that resolves if file was written successfully\n */\nexport default async function compileAndWrite(\n inputFiles: string[],\n compileOpts: CompileCLIOpts = {}\n): Promise<void> {\n const {outFile, ...opts} = compileOpts\n const serializedResult = (await compile(inputFiles, opts)) + '\\n'\n if (outFile) {\n debug('Writing output file:', outFile)\n return outputFile(outFile, serializedResult)\n }\n await writeStdout(serializedResult)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,MAAaA,YAAgC,SAAQ;CACnD,MAAM,UAAuB,CAAC;CAC9B,KAAK,MAAM,CAAC,IAAI,QAAQ,OAAO,QAAQ,IAAI,GACzC,QAAQ,MAAM;EACZ,SAAS,IAAI;EACb,aACE,OAAO,IAAI,gBAAgB,WACvB,IAAI,cACJ,KAAK,UAAU,IAAI,WAAW;CACtC;CAEF,OAAO;AACT;AAEA,MAAaC,aAAkC,SAAQ;CACrD,MAAM,UAAkC,CAAC;CACzC,KAAK,MAAM,CAAC,IAAI,QAAQ,OAAO,QAAQ,IAAI,GAAG;EAC5C,IAAI,OAAO,aACT;EAEF,QAAQ,MAAM,IAAI;CACpB;CACA,OAAO;AACT;;;;;;;ACvBA,MAAaC,YAAmB,SAAQ;AAExC,MAAaC,aAAqB,SAAQ;CACxC,MAAM,UAAkC,CAAC;CACzC,KAAK,MAAM,KAAK,MACd,QAAQ,KAAK,KAAK,EAAE,CAAC;CAEvB,OAAO;AACT;;;;;;;ACNA,MAAaC,YAAmC,SAAQ;CACtD,MAAM,UAA0B,CAAC;CACjC,KAAK,MAAM,CAAC,IAAI,QAAQ,OAAO,QAAQ,IAAI,GACzC,QAAQ,MAAM;EACZ,aAAa,IAAI;EACjB,OACE,OAAO,IAAI,gBAAgB,WAC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f,CAAC;EACD,MAAM,WAAW,UAAU,QAAQ,KAAK,MAAM,OAAO,CAAC;EACtD,KAAK,MAAM,MAAM,OAAO,KAAK,QAAQ,GACnC,SAAS,KAAK;GACZ;GACA,SAAS,SAAS;GAClB,YAAY;EACd,CAAC;CAEL,CAAC,CACH;CAEA,MAAM,aAAa,0BAA0B,UAAU;EACrD,KAAK,KAAK;EACV,WAAW,KAAK;EAChB,cAAc,KAAK;EACnB,YAAY,KAAK;CACnB,CAAC;CAED,IAAI,UAAU,iBACZ,OACE,UAAU,KAAK,MAAM,UAAU,GAAG;EAChC,OAAO;EACP,KAAK,UAAU;CACjB,CAAC,KAAK;CAIV,OAAO;AACT;AAEA,eAAe,uBACb,QAC6B;CAC7B,IAAI,CAAC,QACH,MAAM,IAAI,MAAM,gCAAgC;CAElD,IAAI,OAAO,WAAW,UACpB,OAAO;CAET,IAAI;EACF,OAAO,cAAc,cAAc,QAAQ,QAAQ,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI;CACzE,SAAS,GAAG;EACV,QAAQ,MAAM,4BAA4B,QAAQ;EAClD,MAAM;CACR;AACF;;;;;;;;AASA,eAA8B,gBAC5B,YACA,cAA8B,CAAC,GAChB;CACf,MAAM,EAAC,SAAS,GAAG,SAAQ;CAC3B,MAAM,mBAAoB,MAAM,QAAQ,YAAY,IAAI,IAAK;CAC7D,IAAI,SAAS;EACX,MAAM,wBAAwB,OAAO;EACrC,OAAO,WAAW,SAAS,gBAAgB;CAC7C;CACA,MAAM,YAAY,gBAAgB;AACpC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formatjs/cli-lib",
3
- "version": "8.7.13",
3
+ "version": "9.0.1",
4
4
  "description": "Lib for CLI for formatjs.",
5
5
  "keywords": [
6
6
  "cli",
@@ -34,9 +34,9 @@
34
34
  ".": "./index.js"
35
35
  },
36
36
  "dependencies": {
37
- "@babel/types": "7",
38
- "@formatjs/icu-messageformat-parser": "3.5.14",
39
- "@formatjs/ts-transformer": "4.4.16",
37
+ "@babel/types": "8",
38
+ "@formatjs/icu-messageformat-parser": "3.5.16",
39
+ "@formatjs/ts-transformer": "4.4.18",
40
40
  "@types/fs-extra": "11",
41
41
  "@types/node": "22 || 24",
42
42
  "commander": "14",
@@ -44,7 +44,7 @@
44
44
  "fs-extra": "11",
45
45
  "json-stable-stringify": "1",
46
46
  "loud-rejection": "2",
47
- "typescript": "^5.6 || 6"
47
+ "typescript": "^5.6 || 6 || 7"
48
48
  },
49
49
  "peerDependencies": {
50
50
  "@glimmer/syntax": "^0.84.3 || ^0.95.0",
@@ -80,12 +80,12 @@
80
80
  }
81
81
  },
82
82
  "optionalDependencies": {
83
- "@formatjs/cli-native-darwin-arm64": "1.1.7",
84
- "@formatjs/cli-native-linux-arm64": "1.2.7",
85
- "@formatjs/cli-native-linux-arm64-musl": "1.0.5",
86
- "@formatjs/cli-native-linux-x64": "1.1.7",
87
- "@formatjs/cli-native-linux-x64-musl": "1.0.5",
88
- "@formatjs/cli-native-win32-x64": "1.1.8"
83
+ "@formatjs/cli-native-darwin-arm64": "1.1.9",
84
+ "@formatjs/cli-native-linux-arm64": "1.2.9",
85
+ "@formatjs/cli-native-linux-arm64-musl": "1.0.7",
86
+ "@formatjs/cli-native-linux-x64": "1.1.9",
87
+ "@formatjs/cli-native-linux-x64-musl": "1.0.7",
88
+ "@formatjs/cli-native-win32-x64": "1.1.10"
89
89
  },
90
90
  "engines": {
91
91
  "node": ">= 20.12.0"