lingo.dev 0.87.12 → 0.87.14

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/build/cli.mjs CHANGED
@@ -1190,7 +1190,7 @@ function denormalizeObjectKeys(obj) {
1190
1190
  obj,
1191
1191
  (result, value, key) => {
1192
1192
  const newKey = !isNaN(Number(key)) ? `${OBJECT_NUMERIC_KEY_PREFIX}${key}` : key;
1193
- result[newKey] = _6.isObject(value) ? denormalizeObjectKeys(value) : value;
1193
+ result[newKey] = _6.isObject(value) && !_6.isDate(value) ? denormalizeObjectKeys(value) : value;
1194
1194
  },
1195
1195
  {}
1196
1196
  );
@@ -1204,7 +1204,7 @@ function normalizeObjectKeys(obj) {
1204
1204
  obj,
1205
1205
  (result, value, key) => {
1206
1206
  const newKey = `${key}`.replace(OBJECT_NUMERIC_KEY_PREFIX, "");
1207
- result[newKey] = _6.isObject(value) ? normalizeObjectKeys(value) : value;
1207
+ result[newKey] = _6.isObject(value) && !_6.isDate(value) ? normalizeObjectKeys(value) : value;
1208
1208
  },
1209
1209
  {}
1210
1210
  );
@@ -3091,11 +3091,13 @@ function createLockedKeysLoader(lockedKeys, isCacheRestore = false) {
3091
3091
 
3092
3092
  // src/cli/loaders/mdx2/frontmatter-split.ts
3093
3093
  import matter2 from "gray-matter";
3094
+ import YAML3 from "yaml";
3094
3095
  function createMdxFrontmatterSplitLoader() {
3096
+ const fmEngine = createFmEngine();
3095
3097
  return createLoader({
3096
3098
  async pull(locale, input2) {
3097
3099
  const source = input2 || "";
3098
- const { data: frontmatter, content } = matter2(source);
3100
+ const { data: frontmatter, content } = fmEngine.parse(source);
3099
3101
  return {
3100
3102
  frontmatter,
3101
3103
  content
@@ -3103,11 +3105,29 @@ function createMdxFrontmatterSplitLoader() {
3103
3105
  },
3104
3106
  async push(locale, data) {
3105
3107
  const { frontmatter = {}, content = "" } = data || {};
3106
- const result = matter2.stringify(content, frontmatter).trim();
3108
+ const result = fmEngine.stringify(content, frontmatter).trim();
3107
3109
  return result;
3108
3110
  }
3109
3111
  });
3110
3112
  }
3113
+ function createFmEngine() {
3114
+ const yamlEngine2 = {
3115
+ parse: (str) => YAML3.parse(str),
3116
+ stringify: (obj) => YAML3.stringify(obj, { defaultStringType: "PLAIN" })
3117
+ };
3118
+ return {
3119
+ parse: (input2) => matter2(input2, {
3120
+ engines: {
3121
+ yaml: yamlEngine2
3122
+ }
3123
+ }),
3124
+ stringify: (content, frontmatter) => matter2.stringify(content, frontmatter, {
3125
+ engines: {
3126
+ yaml: yamlEngine2
3127
+ }
3128
+ })
3129
+ };
3130
+ }
3111
3131
 
3112
3132
  // src/cli/utils/md5.ts
3113
3133
  import { MD5 } from "object-hash";
@@ -3119,6 +3139,29 @@ function md5(input2) {
3119
3139
  import _20 from "lodash";
3120
3140
  var fenceRegex = /([ \t]*)(^>\s*)?```([\s\S]*?)```/gm;
3121
3141
  var inlineCodeRegex = /(?<!`)`([^`\r\n]+?)`(?!`)/g;
3142
+ var imageRegex = /([ \t]*)(^>\s*)?!\[[^\]]*?\]\([^\n\r]*?\)/gm;
3143
+ function ensureSurroundingImageNewlines(_content) {
3144
+ let found = false;
3145
+ let content = _content;
3146
+ let workingContent = content;
3147
+ do {
3148
+ found = false;
3149
+ const matches = workingContent.match(imageRegex);
3150
+ if (matches) {
3151
+ const match = matches[0];
3152
+ const replacement = match.trim().startsWith(">") ? match : `
3153
+
3154
+ ${match}
3155
+
3156
+ `;
3157
+ content = content.replaceAll(match, replacement);
3158
+ workingContent = workingContent.replaceAll(match, "");
3159
+ found = true;
3160
+ }
3161
+ } while (found);
3162
+ content = _20.chain(content).split("\n\n").map((section) => _20.trim(section, "\n")).filter(Boolean).join("\n\n").value();
3163
+ return content;
3164
+ }
3122
3165
  function ensureTrailingFenceNewline(_content) {
3123
3166
  let found = false;
3124
3167
  let content = _content;
@@ -3144,6 +3187,7 @@ ${match}
3144
3187
  function extractCodePlaceholders(content) {
3145
3188
  let finalContent = content;
3146
3189
  finalContent = ensureTrailingFenceNewline(finalContent);
3190
+ finalContent = ensureSurroundingImageNewlines(finalContent);
3147
3191
  const codePlaceholders = {};
3148
3192
  const codeBlockMatches = finalContent.matchAll(fenceRegex);
3149
3193
  for (const match of codeBlockMatches) {
@@ -3309,6 +3353,7 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys)
3309
3353
  createMdxSectionsSplit2Loader(),
3310
3354
  createLocalizableMdxDocumentLoader(),
3311
3355
  createFlatLoader(),
3356
+ createLockedKeysLoader(lockedKeys || [], options.isCacheRestore),
3312
3357
  createSyncLoader(),
3313
3358
  createUnlocalizableLoader(
3314
3359
  options.isCacheRestore,
@@ -3686,7 +3731,7 @@ function checkIfFileExists(filePath) {
3686
3731
 
3687
3732
  // src/cli/utils/delta.ts
3688
3733
  import * as path13 from "path";
3689
- import YAML3 from "yaml";
3734
+ import YAML4 from "yaml";
3690
3735
  var LockSchema = z.object({
3691
3736
  version: z.literal(1).default(1),
3692
3737
  checksums: z.record(
@@ -3736,7 +3781,7 @@ function createDeltaProcessor(fileKey) {
3736
3781
  },
3737
3782
  async loadLock() {
3738
3783
  const lockfileContent = tryReadFile(lockfilePath, null);
3739
- const lockfileYaml = lockfileContent ? YAML3.parse(lockfileContent) : null;
3784
+ const lockfileYaml = lockfileContent ? YAML4.parse(lockfileContent) : null;
3740
3785
  const lockfileData = lockfileYaml ? LockSchema.parse(lockfileYaml) : {
3741
3786
  version: 1,
3742
3787
  checksums: {}
@@ -3744,7 +3789,7 @@ function createDeltaProcessor(fileKey) {
3744
3789
  return lockfileData;
3745
3790
  },
3746
3791
  async saveLock(lockData) {
3747
- const lockfileYaml = YAML3.stringify(lockData);
3792
+ const lockfileYaml = YAML4.stringify(lockData);
3748
3793
  writeFile(lockfilePath, lockfileYaml);
3749
3794
  },
3750
3795
  async loadChecksums() {
@@ -4400,7 +4445,7 @@ import Ora6 from "ora";
4400
4445
  import fs11 from "fs";
4401
4446
  import path15 from "path";
4402
4447
  import Z4 from "zod";
4403
- import YAML4 from "yaml";
4448
+ import YAML5 from "yaml";
4404
4449
  import { MD5 as MD52 } from "object-hash";
4405
4450
  import _24 from "lodash";
4406
4451
  function createLockfileHelper() {
@@ -4438,12 +4483,12 @@ function createLockfileHelper() {
4438
4483
  return LockfileSchema.parse({});
4439
4484
  }
4440
4485
  const content = fs11.readFileSync(lockfilePath, "utf-8");
4441
- const result = LockfileSchema.parse(YAML4.parse(content));
4486
+ const result = LockfileSchema.parse(YAML5.parse(content));
4442
4487
  return result;
4443
4488
  }
4444
4489
  function _saveLockfile(lockfile) {
4445
4490
  const lockfilePath = _getLockfilePath();
4446
- const content = YAML4.stringify(lockfile);
4491
+ const content = YAML5.stringify(lockfile);
4447
4492
  fs11.writeFileSync(lockfilePath, content);
4448
4493
  }
4449
4494
  function _getLockfilePath() {
@@ -5679,7 +5724,7 @@ function validateParams2(i18nConfig, flags) {
5679
5724
  // package.json
5680
5725
  var package_default = {
5681
5726
  name: "lingo.dev",
5682
- version: "0.87.12",
5727
+ version: "0.87.14",
5683
5728
  description: "Lingo.dev CLI",
5684
5729
  private: false,
5685
5730
  publishConfig: {