@formatjs/cli 6.16.10 → 6.16.12

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/bin/formatjs CHANGED
@@ -45,7 +45,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
45
45
  value: mod,
46
46
  enumerable: true
47
47
  }) : target, mod));
48
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
48
+ var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
49
49
  //#endregion
50
50
  //#region node_modules/.aspect_rules_js/commander@14.0.3/node_modules/commander/lib/error.js
51
51
  var require_error$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
@@ -3516,7 +3516,7 @@ var require_to_regex_range = /* @__PURE__ */ __commonJSMin(((exports, module) =>
3516
3516
  let nines = 1;
3517
3517
  let zeros = 1;
3518
3518
  let stop = countNines(min, nines);
3519
- let stops = new Set([max]);
3519
+ let stops = /* @__PURE__ */ new Set([max]);
3520
3520
  while (min <= stop && stop <= max) {
3521
3521
  stops.add(stop);
3522
3522
  nines += 1;
@@ -12395,10 +12395,10 @@ function extractWithNative(inputFiles, opts = {}) {
12395
12395
  //#endregion
12396
12396
  //#region packages/cli-lib/compile.ts
12397
12397
  const dynamicImport = new Function("specifier", "return import(specifier)");
12398
- const globSync$1 = import_out.sync;
12398
+ const globSync$1 = import_out.default.sync;
12399
12399
  const stringify$2 = import_json_stable_stringify.default || import_json_stable_stringify;
12400
12400
  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.";
12401
- const BUILTIN_FORMATTERS$1 = new Set([
12401
+ const BUILTIN_FORMATTERS$1 = /* @__PURE__ */ new Set([
12402
12402
  "default",
12403
12403
  "simple",
12404
12404
  "transifex",
@@ -15203,10 +15203,25 @@ function findBraceSyntaxEnd(message, index) {
15203
15203
  function printEscapedMessage(message, isInPlural = false) {
15204
15204
  let result = "";
15205
15205
  let literalStart = 0;
15206
+ let quotedStart = -1;
15207
+ let quotedEnd = -1;
15208
+ function flushQuotedToken() {
15209
+ if (quotedStart === -1) return;
15210
+ const literal = message.slice(literalStart, quotedStart);
15211
+ result += literal;
15212
+ if (literal.endsWith("'")) result += "'";
15213
+ result += quoteSyntaxToken(message.slice(quotedStart, quotedEnd));
15214
+ literalStart = quotedEnd;
15215
+ quotedStart = -1;
15216
+ }
15206
15217
  function quoteToken(start, end) {
15207
- result += message.slice(literalStart, start);
15208
- result += quoteSyntaxToken(message.slice(start, end));
15209
- literalStart = end;
15218
+ if (quotedStart !== -1 && start === quotedEnd) {
15219
+ quotedEnd = end;
15220
+ return;
15221
+ }
15222
+ flushQuotedToken();
15223
+ quotedStart = start;
15224
+ quotedEnd = end;
15210
15225
  }
15211
15226
  for (let i = 0; i < message.length; i++) {
15212
15227
  const ch = message[i];
@@ -15221,6 +15236,7 @@ function printEscapedMessage(message, isInPlural = false) {
15221
15236
  i = end - 1;
15222
15237
  } else if (isInPlural && ch === "#") quoteToken(i, i + 1);
15223
15238
  }
15239
+ flushQuotedToken();
15224
15240
  return result + message.slice(literalStart);
15225
15241
  }
15226
15242
  function printLiteralElement({ value }, isInPlural, isFirstEl, isLastEl) {
@@ -15247,19 +15263,50 @@ function printArgumentStyle(style) {
15247
15263
  function printDateTimeSkeleton(style) {
15248
15264
  return style.pattern;
15249
15265
  }
15266
+ function compareCodePoints(a, b) {
15267
+ const aIter = a[Symbol.iterator]();
15268
+ const bIter = b[Symbol.iterator]();
15269
+ while (true) {
15270
+ const aNext = aIter.next();
15271
+ const bNext = bIter.next();
15272
+ if (aNext.done || bNext.done) return aNext.done === bNext.done ? 0 : aNext.done ? -1 : 1;
15273
+ const diff = aNext.value.codePointAt(0) - bNext.value.codePointAt(0);
15274
+ if (diff !== 0) return diff;
15275
+ }
15276
+ }
15250
15277
  function printSelectElement(el) {
15278
+ const keys = Object.keys(el.options).sort(compareCodePoints);
15251
15279
  return `{${[
15252
15280
  el.value,
15253
15281
  "select",
15254
- Object.keys(el.options).map((id) => `${id}{${doPrintAST(el.options[id].value, false)}}`).join(" ")
15282
+ keys.map((id) => `${id}{${doPrintAST(el.options[id].value, false)}}`).join(" ")
15255
15283
  ].join(",")}}`;
15256
15284
  }
15285
+ const PLURAL_RULE_ORDER = {
15286
+ zero: 0,
15287
+ one: 1,
15288
+ two: 2,
15289
+ few: 3,
15290
+ many: 4,
15291
+ other: 5
15292
+ };
15293
+ function getPluralRuleSortOrder(rule) {
15294
+ const categoryOrder = PLURAL_RULE_ORDER[rule];
15295
+ if (categoryOrder !== void 0) return [categoryOrder, 0];
15296
+ const exactRule = rule.replace(/^=+/, "");
15297
+ return [6, /^[+-]?\d+$/.test(exactRule) ? Number(exactRule) : 0];
15298
+ }
15257
15299
  function printPluralElement(el) {
15258
15300
  const type = el.pluralType === "cardinal" ? "plural" : "selectordinal";
15301
+ const keys = Object.keys(el.options).sort((a, b) => {
15302
+ const [pa, sa] = getPluralRuleSortOrder(a);
15303
+ const [pb, sb] = getPluralRuleSortOrder(b);
15304
+ return pa - pb || sa - sb;
15305
+ });
15259
15306
  return `{${[
15260
15307
  el.value,
15261
15308
  type,
15262
- [el.offset ? `offset:${el.offset}` : "", ...Object.keys(el.options).map((id) => `${id}{${doPrintAST(el.options[id].value, true)}}`)].filter(Boolean).join(" ")
15309
+ [el.offset ? `offset:${el.offset}` : "", ...keys.map((id) => `${id}{${doPrintAST(el.options[id].value, true)}}`)].filter(Boolean).join(" ")
15263
15310
  ].join(",")}}`;
15264
15311
  }
15265
15312
  /*! *****************************************************************************
@@ -162991,7 +163038,7 @@ function isMultipleMessageDecl(ts, node) {
162991
163038
  return ts.isIdentifier(node.expression) && node.expression.text === "defineMessages";
162992
163039
  }
162993
163040
  function isSingularMessageDecl(ts, node, additionalComponentNames) {
162994
- const compNames = new Set([
163041
+ const compNames = /* @__PURE__ */ new Set([
162995
163042
  "FormattedMessage",
162996
163043
  "defineMessage",
162997
163044
  "formatMessage",
@@ -163207,7 +163254,7 @@ function extractMessageDescriptor(ts, node, { overrideIdFn, extractSourceLocatio
163207
163254
  * @param sf
163208
163255
  */
163209
163256
  function isMemberMethodFormatMessageCall(ts, node, additionalFunctionNames) {
163210
- const fnNames = new Set([
163257
+ const fnNames = /* @__PURE__ */ new Set([
163211
163258
  "formatMessage",
163212
163259
  "$formatMessage",
163213
163260
  ...additionalFunctionNames
@@ -163506,7 +163553,7 @@ ${e.message || ""}`;
163506
163553
  //#endregion
163507
163554
  //#region packages/cli-lib/extract.ts
163508
163555
  const stringify = import_json_stable_stringify.default || import_json_stable_stringify;
163509
- const BUILTIN_FORMATTERS = new Set([
163556
+ const BUILTIN_FORMATTERS = /* @__PURE__ */ new Set([
163510
163557
  "default",
163511
163558
  "simple",
163512
163559
  "transifex",
@@ -163514,7 +163561,7 @@ const BUILTIN_FORMATTERS = new Set([
163514
163561
  "lokalise",
163515
163562
  "crowdin"
163516
163563
  ]);
163517
- const NATIVE_SUPPORTED_EXTENSIONS = new Set([
163564
+ const NATIVE_SUPPORTED_EXTENSIONS = /* @__PURE__ */ new Set([
163518
163565
  ".cjs",
163519
163566
  ".js",
163520
163567
  ".jsx",
@@ -163573,7 +163620,7 @@ async function processFile(source, fn, { idInterpolationPattern, ...opts }) {
163573
163620
  parseFile(source, fn, scriptParseFn);
163574
163621
  } else if (fn.endsWith(".svelte")) {
163575
163622
  debug$1("Processing %s using svelte extractor", fn);
163576
- const { parseFile } = await import("./svelte_extractor-BWjG2pEq.js");
163623
+ const { parseFile } = await import("./svelte_extractor-x3_5PFcw.js");
163577
163624
  parseFile(source, fn, scriptParseFn);
163578
163625
  } else if (fn.endsWith(".hbs")) {
163579
163626
  debug$1("Processing %s using hbs extractor", fn);
@@ -163827,7 +163874,7 @@ async function verify(files, { sourceLocale, missingKeys, extraKeys, structuralE
163827
163874
  }
163828
163875
  //#endregion
163829
163876
  //#region packages/cli-lib/cli.ts
163830
- const globSync = import_out.sync;
163877
+ const globSync = import_out.default.sync;
163831
163878
  const KNOWN_COMMANDS = ["extract"];
163832
163879
  async function main(argv) {
163833
163880
  (0, import_loud_rejection.default)();