@formatjs/cli 6.16.7 → 6.16.9

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
@@ -12320,18 +12320,34 @@ function getStdinAsString() {
12320
12320
  //#region packages/cli-lib/native.ts
12321
12321
  const require$1 = createRequire$1(import.meta.url);
12322
12322
  const NATIVE_PACKAGES = {
12323
- "darwin-arm64": "@formatjs/cli-native-darwin-arm64",
12324
- "linux-arm64": "@formatjs/cli-native-linux-arm64",
12325
- "linux-x64": "@formatjs/cli-native-linux-x64",
12326
- "win32-x64": "@formatjs/cli-native-win32-x64"
12323
+ "darwin-arm64": ["@formatjs/cli-native-darwin-arm64"],
12324
+ "linux-arm64": ["@formatjs/cli-native-linux-arm64", "@formatjs/cli-native-linux-arm64-musl"],
12325
+ "linux-x64": ["@formatjs/cli-native-linux-x64", "@formatjs/cli-native-linux-x64-musl"],
12326
+ "win32-x64": ["@formatjs/cli-native-win32-x64"]
12327
12327
  };
12328
12328
  let nativeBinding;
12329
+ function getInstalledNativePackageCandidates(candidates, canResolve = (candidate) => {
12330
+ try {
12331
+ require$1.resolve(candidate);
12332
+ return true;
12333
+ } catch {
12334
+ return false;
12335
+ }
12336
+ }) {
12337
+ return candidates.filter(canResolve);
12338
+ }
12339
+ function getNativePackageCandidates(platform = process.platform, arch = process.arch) {
12340
+ return NATIVE_PACKAGES[`${platform}-${arch}`] || [];
12341
+ }
12329
12342
  function loadNative() {
12330
12343
  if (nativeBinding !== void 0) {
12331
12344
  if (nativeBinding) return nativeBinding;
12332
12345
  throw new Error("Native @formatjs/cli-lib binding is unavailable");
12333
12346
  }
12334
- const candidates = [process.env.FORMATJS_CLI_LIB_NATIVE_PATH, NATIVE_PACKAGES[`${process.platform}-${process.arch}`]].filter(Boolean);
12347
+ const overridePath = process.env.FORMATJS_CLI_LIB_NATIVE_PATH;
12348
+ const packageCandidates = getNativePackageCandidates();
12349
+ const installedPackageCandidates = getInstalledNativePackageCandidates(packageCandidates);
12350
+ const candidates = [overridePath, ...installedPackageCandidates.length ? installedPackageCandidates : packageCandidates].filter(Boolean);
12335
12351
  const loadErrors = [];
12336
12352
  for (const candidate of candidates) try {
12337
12353
  nativeBinding = require$1(candidate);
@@ -162922,6 +162938,11 @@ function interpolateName(loaderContext, name, options) {
162922
162938
  if (typeof loaderContext.options === "object" && typeof loaderContext.options.customInterpolateName === "function") url = loaderContext.options.customInterpolateName.call(loaderContext, url, name, options);
162923
162939
  return url;
162924
162940
  }
162941
+ const TRIM_UNICODE_WHITE_SPACE_RE = /^\p{White_Space}+|\p{White_Space}+$/gu;
162942
+ const UNICODE_WHITE_SPACE_RE = /\p{White_Space}+/gu;
162943
+ function normalizeMessageWhitespace(message) {
162944
+ return message.replace(TRIM_UNICODE_WHITE_SPACE_RE, "").replace(UNICODE_WHITE_SPACE_RE, " ");
162945
+ }
162925
162946
  const stringify$1 = import_json_stable_stringify.default || import_json_stable_stringify;
162926
162947
  const MESSAGE_DESC_KEYS = [
162927
162948
  "id",
@@ -163157,7 +163178,7 @@ function extractMessageDescriptor(ts, node, { overrideIdFn, extractSourceLocatio
163157
163178
  });
163158
163179
  if (extractionError) return;
163159
163180
  if (!msg.defaultMessage && !msg.id) return;
163160
- if (msg.defaultMessage && !preserveWhitespace) msg.defaultMessage = msg.defaultMessage.trim().replace(/\s+/gm, " ");
163181
+ if (msg.defaultMessage && !preserveWhitespace) msg.defaultMessage = normalizeMessageWhitespace(msg.defaultMessage);
163161
163182
  if (flatten && msg.defaultMessage) try {
163162
163183
  msg.defaultMessage = printAST(hoistSelectors(parse(msg.defaultMessage)));
163163
163184
  } catch (e) {