@formatjs/cli-lib 8.5.4 → 8.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/index.d.ts +14 -16
  2. package/index.js +104 -274
  3. package/index.js.map +1 -1
  4. package/package.json +8 -4
package/index.d.ts CHANGED
@@ -84,11 +84,6 @@ interface CompileCLIOpts extends Opts {
84
84
  * The target file that contains compiled messages.
85
85
  */
86
86
  outFile?: string;
87
- /**
88
- * Whether to follow symbolic links when traversing directories.
89
- * Defaults to true for compatibility with pnpm symlinked node_modules.
90
- */
91
- followLinks?: boolean;
92
87
  }
93
88
  interface Opts {
94
89
  /**
@@ -101,8 +96,9 @@ interface Opts {
101
96
  */
102
97
  skipErrors?: boolean;
103
98
  /**
104
- * Path to a formatter file that converts <translation_files> to
105
- * `Record<string, string>` so we can compile.
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.
106
102
  */
107
103
  format?: string | Formatter<unknown>;
108
104
  /**
@@ -117,24 +113,26 @@ interface Opts {
117
113
  */
118
114
  ignoreTag?: boolean;
119
115
  /**
120
- * An AbortSignal to cancel the compilation
116
+ * An AbortSignal to cancel the compilation before invoking native code.
121
117
  */
122
118
  signal?: AbortSignal;
119
+ /**
120
+ * Whether to follow symbolic links when traversing directories.
121
+ * Defaults to true for compatibility with pnpm symlinked node_modules.
122
+ */
123
+ followLinks?: boolean;
123
124
  }
124
125
  /**
125
- * Aggregate `inputFiles` into a single JSON blob and compile.
126
- * Also checks for conflicting IDs.
127
- * Then returns the serialized result as a `string` since key order
128
- * makes a difference in some vendor.
129
- * @param inputFiles Input files
126
+ * Compile extracted translation files with the native formatjs CLI binding.
127
+ * @param inputFiles Input files or glob patterns
130
128
  * @param opts Options
131
129
  * @returns serialized result in string format
132
130
  */
133
131
  declare function compile(inputFiles: string[], opts?: Opts): Promise<string>;
134
132
  /**
135
- * Aggregate `inputFiles` into a single JSON blob and compile.
136
- * Also checks for conflicting IDs and write output to `outFile`.
137
- * @param inputFiles Input files
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
138
136
  * @param compileOpts options
139
137
  * @returns A `Promise` that resolves if file was written successfully
140
138
  */
package/index.js CHANGED
@@ -5,7 +5,8 @@ import * as stringifyNs from "json-stable-stringify";
5
5
  import { resolve } from "path";
6
6
  import { pathToFileURL } from "url";
7
7
  import { readFile } from "fs/promises";
8
- import { TYPE, isLiteralElement, isPluralElement, isSelectElement, isTagElement, parse } from "@formatjs/icu-messageformat-parser";
8
+ import * as glob from "fast-glob";
9
+ import { createRequire } from "module";
9
10
  //#region \0rolldown/runtime.js
10
11
  var __defProp = Object.defineProperty;
11
12
  var __exportAll = (all, no_symbols) => {
@@ -321,300 +322,129 @@ async function extractAndWrite(files, extractOpts) {
321
322
  await writeStdout(serializedResult);
322
323
  }
323
324
  //#endregion
324
- //#region packages/cli-lib/pseudo_locale.ts
325
- function forEachLiteralElement(ast, fn) {
326
- ast.forEach((el) => {
327
- if (isLiteralElement(el)) fn(el);
328
- else if (isPluralElement(el) || isSelectElement(el)) for (const opt of Object.values(el.options)) forEachLiteralElement(opt.value, fn);
329
- else if (isTagElement(el)) forEachLiteralElement(el.children, fn);
330
- });
331
- }
332
- function generateXXLS(msg) {
333
- const ast = typeof msg === "string" ? parse(msg) : msg;
334
- const lastChunk = ast[ast.length - 1];
335
- if (lastChunk && isLiteralElement(lastChunk)) {
336
- lastChunk.value += "SSSSSSSSSSSSSSSSSSSSSSSSS";
337
- return ast;
325
+ //#region packages/cli-lib/native.ts
326
+ const require$1 = createRequire(import.meta.url);
327
+ const NATIVE_PACKAGES = {
328
+ "darwin-arm64": "@formatjs/cli-native-darwin-arm64",
329
+ "linux-x64": "@formatjs/cli-native-linux-x64"
330
+ };
331
+ let nativeBinding;
332
+ function loadNative() {
333
+ if (nativeBinding !== void 0) {
334
+ if (nativeBinding) return nativeBinding;
335
+ throw new Error("Native @formatjs/cli-lib binding is unavailable");
338
336
  }
339
- return [...ast, {
340
- type: TYPE.literal,
341
- value: "SSSSSSSSSSSSSSSSSSSSSSSSS"
342
- }];
343
- }
344
- function generateXXAC(msg) {
345
- const ast = typeof msg === "string" ? parse(msg) : msg;
346
- forEachLiteralElement(ast, (el) => {
347
- el.value = el.value.toUpperCase();
348
- });
349
- return ast;
350
- }
351
- function generateXXHA(msg) {
352
- const ast = typeof msg === "string" ? parse(msg) : msg;
353
- const [firstChunk, ...rest] = ast;
354
- if (firstChunk && isLiteralElement(firstChunk)) {
355
- firstChunk.value = "[javascript]" + firstChunk.value;
356
- return [firstChunk, ...rest];
337
+ const candidates = [process.env.FORMATJS_CLI_LIB_NATIVE_PATH, NATIVE_PACKAGES[`${process.platform}-${process.arch}`]].filter(Boolean);
338
+ const loadErrors = [];
339
+ for (const candidate of candidates) try {
340
+ nativeBinding = require$1(candidate);
341
+ return nativeBinding;
342
+ } catch (e) {
343
+ loadErrors.push(`${candidate}: ${e.message}`);
357
344
  }
358
- return [{
359
- type: TYPE.literal,
360
- value: "[javascript]"
361
- }, ...ast];
345
+ nativeBinding = null;
346
+ throw new Error(`Native @formatjs/cli-lib binding is unavailable.\n${loadErrors.join("\n")}`);
362
347
  }
363
- const ACCENTED_MAP = {
364
- "caps": [
365
- 550,
366
- 385,
367
- 391,
368
- 7698,
369
- 7702,
370
- 401,
371
- 403,
372
- 294,
373
- 298,
374
- 308,
375
- 310,
376
- 319,
377
- 7742,
378
- 544,
379
- 510,
380
- 420,
381
- 586,
382
- 344,
383
- 350,
384
- 358,
385
- 364,
386
- 7804,
387
- 7814,
388
- 7818,
389
- 7822,
390
- 7824
391
- ],
392
- "small": [
393
- 551,
394
- 384,
395
- 392,
396
- 7699,
397
- 7703,
398
- 402,
399
- 608,
400
- 295,
401
- 299,
402
- 309,
403
- 311,
404
- 320,
405
- 7743,
406
- 414,
407
- 511,
408
- 421,
409
- 587,
410
- 345,
411
- 351,
412
- 359,
413
- 365,
414
- 7805,
415
- 7815,
416
- 7819,
417
- 7823,
418
- 7825
419
- ]
420
- };
421
- const FLIPPED_MAP = {
422
- "caps": [
423
- 8704,
424
- 1296,
425
- 8579,
426
- 5601,
427
- 398,
428
- 8498,
429
- 8513,
430
- 72,
431
- 73,
432
- 383,
433
- 1276,
434
- 8514,
435
- 87,
436
- 78,
437
- 79,
438
- 1280,
439
- 210,
440
- 7450,
441
- 83,
442
- 8869,
443
- 8745,
444
- 581,
445
- 77,
446
- 88,
447
- 8516,
448
- 90
449
- ],
450
- "small": [
451
- 592,
452
- 113,
453
- 596,
454
- 112,
455
- 477,
456
- 607,
457
- 387,
458
- 613,
459
- 305,
460
- 638,
461
- 670,
462
- 645,
463
- 623,
464
- 117,
465
- 111,
466
- 100,
467
- 98,
468
- 633,
469
- 115,
470
- 647,
471
- 110,
472
- 652,
473
- 653,
474
- 120,
475
- 654,
476
- 122
477
- ]
478
- };
479
- /**
480
- * Based on: https://hg.mozilla.org/mozilla-central/file/a1f74e8c8fb72390d22054d6b00c28b1a32f6c43/intl/l10n/L10nRegistry.jsm#l425
481
- */
482
- function transformString(map, elongate = false, msg) {
483
- return msg.replace(/[a-z]/gi, (ch) => {
484
- const cc = ch.charCodeAt(0);
485
- if (cc >= 97 && cc <= 122) {
486
- const newChar = String.fromCodePoint(map.small[cc - 97]);
487
- if (elongate && (cc === 97 || cc === 101 || cc === 111 || cc === 117)) return newChar + newChar;
488
- return newChar;
489
- }
490
- if (cc >= 65 && cc <= 90) return String.fromCodePoint(map.caps[cc - 65]);
491
- return ch;
348
+ function compileWithNative(inputFiles, opts = {}) {
349
+ return loadNative().compile(inputFiles, {
350
+ ast: opts.ast,
351
+ format: opts.format,
352
+ followLinks: opts.followLinks,
353
+ ignoreTag: opts.ignoreTag,
354
+ pseudoLocale: opts.pseudoLocale,
355
+ skipErrors: opts.skipErrors
492
356
  });
493
357
  }
494
- /**
495
- * accented - Ȧȧƈƈḗḗƞŧḗḗḓ Ḗḗƞɠŀīīşħ
496
- * --------------------------------
497
- *
498
- * This locale replaces all Latin characters with their accented equivalents, and duplicates some
499
- * vowels to create roughly 30% longer strings. Strings are wrapped in markers (square brackets),
500
- * which help with detecting truncation.
501
- */
502
- function generateENXA(msg) {
503
- const ast = typeof msg === "string" ? parse(msg) : msg;
504
- forEachLiteralElement(ast, (el) => {
505
- el.value = transformString(ACCENTED_MAP, true, el.value);
358
+ function compileMessagesWithNative(messages, opts = {}) {
359
+ return loadNative().compileMessages(messages, {
360
+ ast: opts.ast,
361
+ ignoreTag: opts.ignoreTag,
362
+ pseudoLocale: opts.pseudoLocale,
363
+ skipErrors: opts.skipErrors
506
364
  });
507
- return [
508
- {
509
- type: TYPE.literal,
510
- value: "["
511
- },
512
- ...ast,
513
- {
514
- type: TYPE.literal,
515
- value: "]"
516
- }
517
- ];
518
- }
519
- /**
520
- * bidi - ɥsıʅƃuƎ ıpıԐ
521
- * -------------------
522
- *
523
- * This strategy replaces all Latin characters with their 180 degree rotated versions and enforces
524
- * right to left text flow using Unicode UAX#9 Explicit Directional Embeddings. In this mode, the UI
525
- * directionality will also be set to right-to-left.
526
- */
527
- function generateENXB(msg) {
528
- const ast = typeof msg === "string" ? parse(msg) : msg;
529
- forEachLiteralElement(ast, (el) => {
530
- el.value = transformString(FLIPPED_MAP, false, el.value);
531
- });
532
- return [
533
- {
534
- type: TYPE.literal,
535
- value: "‮"
536
- },
537
- ...ast,
538
- {
539
- type: TYPE.literal,
540
- value: "‬"
541
- }
542
- ];
543
365
  }
544
366
  //#endregion
545
367
  //#region packages/cli-lib/compile.ts
368
+ const dynamicImport = new Function("specifier", "return import(specifier)");
369
+ const globSync = glob.sync;
546
370
  const stringify = stringifyNs.default || stringifyNs;
371
+ const CUSTOM_FORMATTER_FILE_DEPRECATION_WARNING = "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.";
372
+ const BUILTIN_FORMATTERS = new Set([
373
+ "default",
374
+ "simple",
375
+ "transifex",
376
+ "smartling",
377
+ "lokalise",
378
+ "crowdin"
379
+ ]);
547
380
  /**
548
- * Aggregate `inputFiles` into a single JSON blob and compile.
549
- * Also checks for conflicting IDs.
550
- * Then returns the serialized result as a `string` since key order
551
- * makes a difference in some vendor.
552
- * @param inputFiles Input files
381
+ * Compile extracted translation files with the native formatjs CLI binding.
382
+ * @param inputFiles Input files or glob patterns
553
383
  * @param opts Options
554
384
  * @returns serialized result in string format
555
385
  */
556
386
  async function compile(inputFiles, opts = {}) {
557
387
  debug("Compiling files:", inputFiles);
558
- const { ast, format, pseudoLocale, skipErrors, ignoreTag, signal } = opts;
388
+ const { ast, format, pseudoLocale, skipErrors, ignoreTag, signal, followLinks } = opts;
559
389
  signal?.throwIfAborted();
560
- const formatter = await resolveBuiltinFormatter(format);
561
- const messages = {};
562
- const messageAsts = {};
563
- const idsWithFileName = {};
564
- const compiledFiles = await Promise.all(inputFiles.map((f) => readFile(f, {
565
- encoding: "utf8",
566
- signal
567
- }).then((content) => JSON.parse(content)).then(formatter.compile)));
568
- debug("Compiled files:", compiledFiles);
569
- for (let i = 0; i < inputFiles.length; i++) {
570
- const inputFile = inputFiles[i];
571
- debug("Processing file:", inputFile);
572
- const compiled = compiledFiles[i];
573
- for (const id in compiled) {
574
- if (messages[id] && messages[id] !== compiled[id]) throw new Error(`Conflicting ID "${id}" with different translation found in these 2 files:
575
- ID: ${id}
576
- Message from ${idsWithFileName[id]}: ${messages[id]}
577
- Message from ${inputFile}: ${compiled[id]}
578
- `);
579
- try {
580
- const msgAst = parse(compiled[id], { ignoreTag });
581
- messages[id] = compiled[id];
582
- switch (pseudoLocale) {
583
- case "xx-LS":
584
- messageAsts[id] = generateXXLS(msgAst);
585
- break;
586
- case "xx-AC":
587
- messageAsts[id] = generateXXAC(msgAst);
588
- break;
589
- case "xx-HA":
590
- messageAsts[id] = generateXXHA(msgAst);
591
- break;
592
- case "en-XA":
593
- messageAsts[id] = generateENXA(msgAst);
594
- break;
595
- case "en-XB":
596
- messageAsts[id] = generateENXB(msgAst);
597
- break;
598
- default:
599
- messageAsts[id] = msgAst;
600
- break;
601
- }
602
- idsWithFileName[id] = inputFile;
603
- } catch (e) {
604
- warn("Error validating message \"%s\" with ID \"%s\" in file \"%s\"", compiled[id], id, inputFile);
605
- if (!skipErrors) throw e;
606
- }
607
- }
608
- }
609
- return stringify(ast ? messageAsts : messages, {
390
+ if (format && !isBuiltinFormatter(format)) return compileWithCustomFormatter(inputFiles, opts);
391
+ return compileWithNative(inputFiles, {
392
+ ast,
393
+ format: typeof format === "string" ? format : void 0,
394
+ followLinks,
395
+ ignoreTag,
396
+ pseudoLocale,
397
+ skipErrors
398
+ });
399
+ }
400
+ function isBuiltinFormatter(format) {
401
+ return typeof format === "string" && BUILTIN_FORMATTERS.has(format);
402
+ }
403
+ async function compileWithCustomFormatter(inputFiles, opts) {
404
+ if (typeof opts.format === "string") await warn(CUSTOM_FORMATTER_FILE_DEPRECATION_WARNING);
405
+ const formatter = await resolveCustomFormatter(opts.format);
406
+ const files = globSync(inputFiles, { followSymbolicLinks: opts.followLinks ?? true });
407
+ if (!files.length) throw new Error("No translation files found matching the patterns");
408
+ const messages = [];
409
+ await Promise.all(files.map(async (file) => {
410
+ opts.signal?.throwIfAborted();
411
+ const content = await readFile(file, {
412
+ encoding: "utf8",
413
+ signal: opts.signal
414
+ });
415
+ const compiled = formatter.compile(JSON.parse(content));
416
+ for (const id of Object.keys(compiled)) messages.push({
417
+ id,
418
+ message: compiled[id],
419
+ sourceFile: file
420
+ });
421
+ }));
422
+ const serialized = compileMessagesWithNative(messages, {
423
+ ast: opts.ast,
424
+ ignoreTag: opts.ignoreTag,
425
+ pseudoLocale: opts.pseudoLocale,
426
+ skipErrors: opts.skipErrors
427
+ });
428
+ if (formatter.compareMessages) return stringify(JSON.parse(serialized), {
610
429
  space: 2,
611
- cmp: formatter.compareMessages || void 0
430
+ cmp: formatter.compareMessages
612
431
  }) ?? "";
432
+ return serialized;
433
+ }
434
+ async function resolveCustomFormatter(format) {
435
+ if (!format) throw new Error("A custom formatter is required");
436
+ if (typeof format !== "string") return format;
437
+ try {
438
+ return dynamicImport(pathToFileURL(resolve(process.cwd(), format)).href);
439
+ } catch (e) {
440
+ console.error(`Cannot resolve formatter ${format}`);
441
+ throw e;
442
+ }
613
443
  }
614
444
  /**
615
- * Aggregate `inputFiles` into a single JSON blob and compile.
616
- * Also checks for conflicting IDs and write output to `outFile`.
617
- * @param inputFiles Input files
445
+ * Compile extracted translation files with the native formatjs CLI binding and
446
+ * write output to `outFile` when provided.
447
+ * @param inputFiles Input files or glob patterns
618
448
  * @param compileOpts options
619
449
  * @returns A `Promise` that resolves if file was written successfully
620
450
  */
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","stringify"],"sources":["../formatters/crowdin.ts","../formatters/default.ts","../formatters/lokalise.ts","../formatters/simple.ts","../formatters/smartling.ts","../formatters/transifex.ts","../formatters/index.ts","../extract.ts","../pseudo_locale.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 {\n type MessageDescriptor,\n type Opts,\n interpolateName,\n} from '@formatjs/ts-transformer'\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'\n\nimport {\n type Formatter,\n resolveBuiltinFormatter,\n} from '#packages/cli-lib/formatters/index.js'\nimport {parseScript} from '#packages/cli-lib/parse_script.js'\nimport {readFile} from 'fs/promises'\n\nconst stringify = (stringifyNs as any).default || stringifyNs\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\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 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 {\n parse,\n type MessageFormatElement,\n TYPE,\n isLiteralElement,\n isPluralElement,\n isSelectElement,\n isTagElement,\n type LiteralElement,\n} from '@formatjs/icu-messageformat-parser'\n\nfunction forEachLiteralElement(\n ast: MessageFormatElement[],\n fn: (el: LiteralElement) => void\n): void {\n ast.forEach(el => {\n if (isLiteralElement(el)) {\n fn(el)\n } else if (isPluralElement(el) || isSelectElement(el)) {\n for (const opt of Object.values(el.options)) {\n forEachLiteralElement(opt.value, fn)\n }\n } else if (isTagElement(el)) {\n forEachLiteralElement(el.children, fn)\n }\n })\n}\n\nexport function generateXXLS(\n msg: string | MessageFormatElement[]\n): MessageFormatElement[] {\n const ast = typeof msg === 'string' ? parse(msg) : msg\n const lastChunk = ast[ast.length - 1]\n if (lastChunk && isLiteralElement(lastChunk)) {\n lastChunk.value += 'SSSSSSSSSSSSSSSSSSSSSSSSS'\n return ast\n }\n return [...ast, {type: TYPE.literal, value: 'SSSSSSSSSSSSSSSSSSSSSSSSS'}]\n}\n\nexport function generateXXAC(\n msg: string | MessageFormatElement[]\n): MessageFormatElement[] {\n const ast = typeof msg === 'string' ? parse(msg) : msg\n forEachLiteralElement(ast, el => {\n el.value = el.value.toUpperCase()\n })\n return ast\n}\n\nexport function generateXXHA(\n msg: string | MessageFormatElement[]\n): MessageFormatElement[] {\n const ast = typeof msg === 'string' ? parse(msg) : msg\n const [firstChunk, ...rest] = ast\n if (firstChunk && isLiteralElement(firstChunk)) {\n firstChunk.value = '[javascript]' + firstChunk.value\n return [firstChunk, ...rest]\n }\n return [{type: TYPE.literal, value: '[javascript]'}, ...ast]\n}\n\ntype _TupleOf<T, N extends number, R extends unknown[]> = R['length'] extends N\n ? R\n : _TupleOf<T, N, [T, ...R]>\n\ntype Tuple<T, N extends number> = N extends N\n ? number extends N\n ? T[]\n : _TupleOf<T, N, []>\n : never\n\ntype PseudoLocaleTransformMap = {\n caps: Tuple<number, 26>\n small: Tuple<number, 26>\n}\n\nconst ACCENTED_MAP: PseudoLocaleTransformMap = {\n // ȦƁƇḒḖƑƓĦĪĴĶĿḾȠǾƤɊŘŞŦŬṼẆẊẎẐ\n // prettier-ignore\n \"caps\": [550, 385, 391, 7698, 7702, 401, 403, 294, 298, 308, 310, 319, 7742, 544, 510, 420, 586, 344, 350, 358, 364, 7804, 7814, 7818, 7822, 7824],\n // ȧƀƈḓḗƒɠħīĵķŀḿƞǿƥɋřşŧŭṽẇẋẏẑ\n // prettier-ignore\n \"small\": [551, 384, 392, 7699, 7703, 402, 608, 295, 299, 309, 311, 320, 7743, 414, 511, 421, 587, 345, 351, 359, 365, 7805, 7815, 7819, 7823, 7825],\n}\n\nconst FLIPPED_MAP: PseudoLocaleTransformMap = {\n // ∀ԐↃᗡƎℲ⅁HIſӼ⅂WNOԀÒᴚS⊥∩ɅMX⅄Z\n // prettier-ignore\n \"caps\": [8704, 1296, 8579, 5601, 398, 8498, 8513, 72, 73, 383, 1276, 8514, 87, 78, 79, 1280, 210, 7450, 83, 8869, 8745, 581, 77, 88, 8516, 90],\n // ɐqɔpǝɟƃɥıɾʞʅɯuodbɹsʇnʌʍxʎz\n // prettier-ignore\n \"small\": [592, 113, 596, 112, 477, 607, 387, 613, 305, 638, 670, 645, 623, 117, 111, 100, 98, 633, 115, 647, 110, 652, 653, 120, 654, 122],\n}\n\n/**\n * Based on: https://hg.mozilla.org/mozilla-central/file/a1f74e8c8fb72390d22054d6b00c28b1a32f6c43/intl/l10n/L10nRegistry.jsm#l425\n */\nfunction transformString(\n map: PseudoLocaleTransformMap,\n elongate = false,\n msg: string\n) {\n return msg.replace(/[a-z]/gi, ch => {\n const cc = ch.charCodeAt(0)\n if (cc >= 97 && cc <= 122) {\n const newChar = String.fromCodePoint(map.small[cc - 97])\n // duplicate \"a\", \"e\", \"o\" and \"u\" to emulate ~30% longer text\n if (elongate && (cc === 97 || cc === 101 || cc === 111 || cc === 117)) {\n return newChar + newChar\n }\n return newChar\n }\n if (cc >= 65 && cc <= 90) {\n return String.fromCodePoint(map.caps[cc - 65])\n }\n return ch\n })\n}\n\n/**\n * accented - Ȧȧƈƈḗḗƞŧḗḗḓ Ḗḗƞɠŀīīşħ\n * --------------------------------\n *\n * This locale replaces all Latin characters with their accented equivalents, and duplicates some\n * vowels to create roughly 30% longer strings. Strings are wrapped in markers (square brackets),\n * which help with detecting truncation.\n */\nexport function generateENXA(\n msg: string | MessageFormatElement[]\n): MessageFormatElement[] {\n const ast = typeof msg === 'string' ? parse(msg) : msg\n forEachLiteralElement(ast, el => {\n el.value = transformString(ACCENTED_MAP, true, el.value)\n })\n return [\n {type: TYPE.literal, value: '['},\n ...ast,\n {type: TYPE.literal, value: ']'},\n ]\n}\n\n/**\n * bidi - ɥsıʅƃuƎ ıpıԐ\n * -------------------\n *\n * This strategy replaces all Latin characters with their 180 degree rotated versions and enforces\n * right to left text flow using Unicode UAX#9 Explicit Directional Embeddings. In this mode, the UI\n * directionality will also be set to right-to-left.\n */\nexport function generateENXB(\n msg: string | MessageFormatElement[]\n): MessageFormatElement[] {\n const ast = typeof msg === 'string' ? parse(msg) : msg\n forEachLiteralElement(ast, el => {\n el.value = transformString(FLIPPED_MAP, false, el.value)\n })\n return [\n {type: TYPE.literal, value: '\\u202e'},\n ...ast,\n {type: TYPE.literal, value: '\\u202c'},\n ]\n}\n","import {\n type MessageFormatElement,\n parse,\n} from '@formatjs/icu-messageformat-parser'\nimport {outputFile} from 'fs-extra/esm'\nimport {readFile} from 'fs/promises'\nimport * as stringifyNs from 'json-stable-stringify'\nimport {debug, warn, writeStdout} from '#packages/cli-lib/console_utils.js'\nimport {\n type Formatter,\n resolveBuiltinFormatter,\n} from '#packages/cli-lib/formatters/index.js'\nimport {\n generateENXA,\n generateENXB,\n generateXXAC,\n generateXXHA,\n generateXXLS,\n} from '#packages/cli-lib/pseudo_locale.js'\n\nconst stringify = (stringifyNs as any).default || stringifyNs\n\nexport type CompileFn = (msgs: any) => Record<string, string>\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 * Whether to follow symbolic links when traversing directories.\n * Defaults to true for compatibility with pnpm symlinked node_modules.\n */\n followLinks?: boolean\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 * Path to a formatter file that converts <translation_files> to\n * `Record<string, string>` so we can compile.\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\n */\n signal?: AbortSignal\n}\n\n/**\n * Aggregate `inputFiles` into a single JSON blob and compile.\n * Also checks for conflicting IDs.\n * Then returns the serialized result as a `string` since key order\n * makes a difference in some vendor.\n * @param inputFiles Input files\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 {ast, format, pseudoLocale, skipErrors, ignoreTag, signal} = opts\n signal?.throwIfAborted()\n const formatter = await resolveBuiltinFormatter(format)\n\n const messages: Record<string, string> = {}\n const messageAsts: Record<string, MessageFormatElement[]> = {}\n const idsWithFileName: Record<string, string> = {}\n const compiledFiles = await Promise.all(\n inputFiles.map(f =>\n readFile(f, {encoding: 'utf8', signal})\n .then(content => JSON.parse(content))\n .then(formatter.compile)\n )\n )\n debug('Compiled files:', compiledFiles)\n for (let i = 0; i < inputFiles.length; i++) {\n const inputFile = inputFiles[i]\n debug('Processing file:', inputFile)\n const compiled = compiledFiles[i]\n for (const id in compiled) {\n if (messages[id] && messages[id] !== compiled[id]) {\n throw new Error(`Conflicting ID \"${id}\" with different translation found in these 2 files:\nID: ${id}\nMessage from ${idsWithFileName[id]}: ${messages[id]}\nMessage from ${inputFile}: ${compiled[id]}\n`)\n }\n try {\n const msgAst = parse(compiled[id], {ignoreTag})\n messages[id] = compiled[id]\n switch (pseudoLocale) {\n case 'xx-LS':\n messageAsts[id] = generateXXLS(msgAst)\n break\n case 'xx-AC':\n messageAsts[id] = generateXXAC(msgAst)\n break\n case 'xx-HA':\n messageAsts[id] = generateXXHA(msgAst)\n break\n case 'en-XA':\n messageAsts[id] = generateENXA(msgAst)\n break\n case 'en-XB':\n messageAsts[id] = generateENXB(msgAst)\n break\n default:\n messageAsts[id] = msgAst\n break\n }\n idsWithFileName[id] = inputFile\n } catch (e) {\n warn(\n 'Error validating message \"%s\" with ID \"%s\" in file \"%s\"',\n compiled[id],\n id,\n inputFile\n )\n if (!skipErrors) {\n throw e\n }\n }\n }\n }\n\n return (\n stringify(ast ? messageAsts : messages, {\n space: 2,\n cmp: formatter.compareMessages || undefined,\n }) ?? ''\n )\n}\n\n/**\n * Aggregate `inputFiles` into a single JSON blob and compile.\n * Also checks for conflicting IDs and write output to `outFile`.\n * @param inputFiles Input files\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,EAAE;AAC/B,MAAK,MAAM,CAAC,IAAI,QAAQ,OAAO,QAAQ,KAAK,CAC1C,SAAQ,MAAM;EACZ,SAAS,IAAI;EACb,aACE,OAAO,IAAI,gBAAgB,WACvB,IAAI,cACJ,KAAK,UAAU,IAAI,YAAY;EACtC;AAEH,QAAO;;AAGT,MAAaC,aAAkC,SAAQ;CACrD,MAAM,UAAkC,EAAE;AAC1C,MAAK,MAAM,CAAC,IAAI,QAAQ,OAAO,QAAQ,KAAK,EAAE;AAC5C,MAAI,OAAO,YACT;AAEF,UAAQ,MAAM,IAAI;;AAEpB,QAAO;;;;;;;;ACtBT,MAAaC,YAAmB,SAAQ;AAExC,MAAaC,aAAqB,SAAQ;CACxC,MAAM,UAAkC,EAAE;AAC1C,MAAK,MAAM,KAAK,KACd,SAAQ,KAAK,KAAK,GAAG;AAEvB,QAAO;;;;;;;;ACLT,MAAaC,YAAmC,SAAQ;CACtD,MAAM,UAA0B,EAAE;AAClC,MAAK,MAAM,CAAC,IAAI,QAAQ,OAAO,QAAQ,KAAK,CAC1C,SAAQ,MAAM;EACZ,aAAa,IAAI;EACjB,OACE,OAAO,IAAI,gBAAgB,WACvB,IAAI,cACJ,KAAK,UAAU,IAAI,YAAY;EACtC;AAEH,QAAO;;AAGT,MAAaC,aAAqC,SAAQ;CACxD,MAAM,UAAkC,EAAE;AAC1C,MAAK,MAAM,CAAC,IAAI,QAAQ,OAAO,QAAQ,KAAK,CAC1C,SAAQ,MAAM,IAAI;AAEpB,QAAO;;;;;;;;AC3BT,MAAaC,YAA+B,SAAQ;AAClD,QAAO,OAAO,KAAK,KAAK,CAAC,QAAQ,K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A8B,EAAE,EACjB;CACf,MAAM,EAAC,SAAS,GAAG,SAAQ;CAC3B,MAAM,mBAAoB,MAAM,QAAQ,YAAY,KAAK,GAAI;AAC7D,KAAI,SAAS;AACX,QAAM,wBAAwB,QAAQ;AACtC,SAAO,WAAW,SAAS,iBAAiB;;AAE9C,OAAM,YAAY,iBAAiB"}
1
+ {"version":3,"file":"index.js","names":["format","compile","format","compile","format","compile","format","compile","format","compile","compile","defaultFormatter","transifex","smartling","simple","lokalise","crowdin","stringify","require"],"sources":["../formatters/crowdin.ts","../formatters/default.ts","../formatters/lokalise.ts","../formatters/simple.ts","../formatters/smartling.ts","../formatters/transifex.ts","../formatters/index.ts","../extract.ts","../native.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 {\n type MessageDescriptor,\n type Opts,\n interpolateName,\n} from '@formatjs/ts-transformer'\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'\n\nimport {\n type Formatter,\n resolveBuiltinFormatter,\n} from '#packages/cli-lib/formatters/index.js'\nimport {parseScript} from '#packages/cli-lib/parse_script.js'\nimport {readFile} from 'fs/promises'\n\nconst stringify = (stringifyNs as any).default || stringifyNs\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\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 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 {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-x64': '@formatjs/cli-native-linux-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 NativeBinding {\n compile(inputFiles: string[], opts?: NativeCompileOptions): string\n compileMessages(\n messages: NativeCompileMessage[],\n opts?: NativeCompileOptions\n ): string\n supportedBuiltinFormatters(): string[]\n}\n\nlet nativeBinding: NativeBinding | null | undefined\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 platformPackage = NATIVE_PACKAGES[`${process.platform}-${process.arch}`]\n const candidates = [overridePath, platformPackage].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","import {outputFile} from 'fs-extra/esm'\nimport {readFile} from 'fs/promises'\nimport * as 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 CompileFn = (msgs: any) => Record<string, string>\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,EAAE;AAC/B,MAAK,MAAM,CAAC,IAAI,QAAQ,OAAO,QAAQ,KAAK,CAC1C,SAAQ,MAAM;EACZ,SAAS,IAAI;EACb,aACE,OAAO,IAAI,gBAAgB,WACvB,IAAI,cACJ,KAAK,UAAU,IAAI,YAAY;EACtC;AAEH,QAAO;;AAGT,MAAaC,aAAkC,SAAQ;CACrD,MAAM,UAAkC,EAAE;AAC1C,MAAK,MAAM,CAAC,IAAI,QAAQ,OAAO,QAAQ,KAAK,EAAE;AAC5C,MAAI,OAAO,YACT;AAEF,UAAQ,MAAM,IAAI;;AAEpB,QAAO;;;;;;;;ACtBT,MAAaC,YAAmB,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UAAU;EAChB,CAAC,IAAI;AAIV,QAAO;;AAGT,eAAe,uBACb,QAC6B;AAC7B,KAAI,CAAC,OACH,OAAM,IAAI,MAAM,iCAAiC;AAEnD,KAAI,OAAO,WAAW,SACpB,QAAO;AAET,KAAI;AACF,SAAO,cAAc,cAAc,QAAQ,QAAQ,KAAK,EAAE,OAAO,CAAC,CAAC,KAAK;UACjE,GAAG;AACV,UAAQ,MAAM,4BAA4B,SAAS;AACnD,QAAM;;;;;;;;;;AAWV,eAA8B,gBAC5B,YACA,cAA8B,EAAE,EACjB;CACf,MAAM,EAAC,SAAS,GAAG,SAAQ;CAC3B,MAAM,mBAAoB,MAAM,QAAQ,YAAY,KAAK,GAAI;AAC7D,KAAI,SAAS;AACX,QAAM,wBAAwB,QAAQ;AACtC,SAAO,WAAW,SAAS,iBAAiB;;AAE9C,OAAM,YAAY,iBAAiB"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@formatjs/cli-lib",
3
3
  "description": "Lib for CLI for formatjs.",
4
- "version": "8.5.4",
4
+ "version": "8.6.0",
5
5
  "license": "MIT",
6
6
  "author": "Linjie Ding <linjie@airtable.com>",
7
7
  "type": "module",
@@ -22,9 +22,9 @@
22
22
  "json-stable-stringify": "^1.3.0",
23
23
  "loud-rejection": "^2",
24
24
  "typescript": "^5.6 || 6",
25
- "@formatjs/icu-messageformat-parser": "3.5.6",
26
- "@formatjs/ts-transformer": "4.4.6",
27
- "@formatjs/icu-skeleton-parser": "2.1.6"
25
+ "@formatjs/icu-messageformat-parser": "3.5.8",
26
+ "@formatjs/icu-skeleton-parser": "2.1.8",
27
+ "@formatjs/ts-transformer": "4.4.8"
28
28
  },
29
29
  "peerDependencies": {
30
30
  "@glimmer/syntax": "^0.84.3 || ^0.95.0",
@@ -53,6 +53,10 @@
53
53
  "translation"
54
54
  ],
55
55
  "main": "index.js",
56
+ "optionalDependencies": {
57
+ "@formatjs/cli-native-darwin-arm64": "1.1.0",
58
+ "@formatjs/cli-native-linux-x64": "1.1.0"
59
+ },
56
60
  "peerDependenciesMeta": {
57
61
  "vue": {
58
62
  "optional": true