@intlayer/engine 9.1.3 → 9.3.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 (100) hide show
  1. package/dist/assets/initConfig/templates/cjs.txt +4 -1
  2. package/dist/assets/initConfig/templates/json.txt +4 -1
  3. package/dist/assets/initConfig/templates/mjs.txt +4 -1
  4. package/dist/assets/initConfig/templates/ts.txt +4 -1
  5. package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs +14 -2
  6. package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs.map +1 -1
  7. package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs +24 -4
  8. package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs.map +1 -1
  9. package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs +43 -6
  10. package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs.map +1 -1
  11. package/dist/cjs/buildIntlayerDictionary/writeNestedDictionary.cjs +96 -0
  12. package/dist/cjs/buildIntlayerDictionary/writeNestedDictionary.cjs.map +1 -0
  13. package/dist/cjs/docReview/alignBlocks.cjs +57 -8
  14. package/dist/cjs/docReview/alignBlocks.cjs.map +1 -1
  15. package/dist/cjs/docReview/rebuildDocument.cjs +37 -9
  16. package/dist/cjs/docReview/rebuildDocument.cjs.map +1 -1
  17. package/dist/cjs/docReview/segmentDocument.cjs +19 -2
  18. package/dist/cjs/docReview/segmentDocument.cjs.map +1 -1
  19. package/dist/cjs/fetchDistantDictionaries.cjs +107 -13
  20. package/dist/cjs/fetchDistantDictionaries.cjs.map +1 -1
  21. package/dist/cjs/init/frameworkSetup/tanstackStart/transforms.cjs +1 -1
  22. package/dist/cjs/init/frameworkSetup/tanstackStart/transforms.cjs.map +1 -1
  23. package/dist/cjs/loadDictionaries/loadDictionaries.cjs +4 -2
  24. package/dist/cjs/loadDictionaries/loadDictionaries.cjs.map +1 -1
  25. package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs +3 -2
  26. package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs.map +1 -1
  27. package/dist/cjs/loadDictionaries/log.cjs +28 -5
  28. package/dist/cjs/loadDictionaries/log.cjs.map +1 -1
  29. package/dist/cjs/prepareIntlayer.cjs +7 -3
  30. package/dist/cjs/prepareIntlayer.cjs.map +1 -1
  31. package/dist/cjs/utils/chunkArray.cjs +24 -0
  32. package/dist/cjs/utils/chunkArray.cjs.map +1 -0
  33. package/dist/cjs/utils/index.cjs +2 -0
  34. package/dist/cjs/utils/runOnce.cjs +129 -50
  35. package/dist/cjs/utils/runOnce.cjs.map +1 -1
  36. package/dist/cjs/writeContentDeclaration/transformJSFile.cjs +153 -92
  37. package/dist/cjs/writeContentDeclaration/transformJSFile.cjs.map +1 -1
  38. package/dist/cjs/writeFileIfChanged.cjs +14 -7
  39. package/dist/cjs/writeFileIfChanged.cjs.map +1 -1
  40. package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs +15 -3
  41. package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs.map +1 -1
  42. package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs +24 -4
  43. package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs.map +1 -1
  44. package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs +43 -6
  45. package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs.map +1 -1
  46. package/dist/esm/buildIntlayerDictionary/writeNestedDictionary.mjs +92 -0
  47. package/dist/esm/buildIntlayerDictionary/writeNestedDictionary.mjs.map +1 -0
  48. package/dist/esm/docReview/alignBlocks.mjs +57 -8
  49. package/dist/esm/docReview/alignBlocks.mjs.map +1 -1
  50. package/dist/esm/docReview/rebuildDocument.mjs +37 -9
  51. package/dist/esm/docReview/rebuildDocument.mjs.map +1 -1
  52. package/dist/esm/docReview/segmentDocument.mjs +19 -2
  53. package/dist/esm/docReview/segmentDocument.mjs.map +1 -1
  54. package/dist/esm/fetchDistantDictionaries.mjs +107 -13
  55. package/dist/esm/fetchDistantDictionaries.mjs.map +1 -1
  56. package/dist/esm/init/frameworkSetup/tanstackStart/transforms.mjs +1 -1
  57. package/dist/esm/init/frameworkSetup/tanstackStart/transforms.mjs.map +1 -1
  58. package/dist/esm/loadDictionaries/loadDictionaries.mjs +4 -2
  59. package/dist/esm/loadDictionaries/loadDictionaries.mjs.map +1 -1
  60. package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs +3 -2
  61. package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs.map +1 -1
  62. package/dist/esm/loadDictionaries/log.mjs +28 -5
  63. package/dist/esm/loadDictionaries/log.mjs.map +1 -1
  64. package/dist/esm/prepareIntlayer.mjs +7 -3
  65. package/dist/esm/prepareIntlayer.mjs.map +1 -1
  66. package/dist/esm/utils/chunkArray.mjs +22 -0
  67. package/dist/esm/utils/chunkArray.mjs.map +1 -0
  68. package/dist/esm/utils/index.mjs +2 -1
  69. package/dist/esm/utils/runOnce.mjs +129 -50
  70. package/dist/esm/utils/runOnce.mjs.map +1 -1
  71. package/dist/esm/writeContentDeclaration/transformJSFile.mjs +153 -92
  72. package/dist/esm/writeContentDeclaration/transformJSFile.mjs.map +1 -1
  73. package/dist/esm/writeFileIfChanged.mjs +15 -8
  74. package/dist/esm/writeFileIfChanged.mjs.map +1 -1
  75. package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts.map +1 -1
  76. package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts +14 -2
  77. package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts.map +1 -1
  78. package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts +16 -2
  79. package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts.map +1 -1
  80. package/dist/types/buildIntlayerDictionary/writeNestedDictionary.d.ts +54 -0
  81. package/dist/types/buildIntlayerDictionary/writeNestedDictionary.d.ts.map +1 -0
  82. package/dist/types/docReview/alignBlocks.d.ts +4 -2
  83. package/dist/types/docReview/alignBlocks.d.ts.map +1 -1
  84. package/dist/types/docReview/rebuildDocument.d.ts.map +1 -1
  85. package/dist/types/docReview/segmentDocument.d.ts.map +1 -1
  86. package/dist/types/docReview/types.d.ts +9 -0
  87. package/dist/types/docReview/types.d.ts.map +1 -1
  88. package/dist/types/fetchDistantDictionaries.d.ts +26 -0
  89. package/dist/types/fetchDistantDictionaries.d.ts.map +1 -1
  90. package/dist/types/formatDictionary.d.ts +2 -0
  91. package/dist/types/formatDictionary.d.ts.map +1 -1
  92. package/dist/types/loadDictionaries/log.d.ts +16 -1
  93. package/dist/types/loadDictionaries/log.d.ts.map +1 -1
  94. package/dist/types/utils/chunkArray.d.ts +16 -0
  95. package/dist/types/utils/chunkArray.d.ts.map +1 -0
  96. package/dist/types/utils/index.d.ts +3 -2
  97. package/dist/types/utils/runOnce.d.ts +30 -6
  98. package/dist/types/utils/runOnce.d.ts.map +1 -1
  99. package/dist/types/writeContentDeclaration/transformJSFile.d.ts.map +1 -1
  100. package/package.json +11 -11
@@ -1,7 +1,21 @@
1
1
  import { LocalizedDictionaryOutput } from "./writeDynamicDictionary.js";
2
2
  import { IntlayerConfig } from "@intlayer/types/config";
3
3
  //#region src/buildIntlayerDictionary/writeFetchDictionary.d.ts
4
- declare const generateDictionaryEntryPoint: (key: string, locales: string[], relativePrefix: string, format?: 'cjs' | 'esm') => string;
4
+ /**
5
+ * Generates the live (fetch-mode) entry point of a dictionary.
6
+ *
7
+ * When the dictionary references others through `nest()`, those are fetched
8
+ * live alongside it and attached as `nestedDictionaries`, so a remote edit to a
9
+ * nested dictionary propagates through the reference instead of resolving
10
+ * against the build-time snapshot.
11
+ *
12
+ * @param key - The dictionary key.
13
+ * @param locales - Locales to emit a loader for.
14
+ * @param relativePrefix - Relative path to the dynamic dictionaries directory.
15
+ * @param format - Output module format.
16
+ * @param nestedKeys - Keys referenced through `nest()`, transitively.
17
+ */
18
+ declare const generateDictionaryEntryPoint: (key: string, locales: string[], relativePrefix: string, format?: 'cjs' | 'esm', nestedKeys?: string[]) => string;
5
19
  /**
6
20
  * Write the localized dictionaries to the dictionariesDir
7
21
  * @param mergedDictionaries - The merged dictionaries
@@ -18,7 +32,7 @@ declare const generateDictionaryEntryPoint: (key: string, locales: string[], rel
18
32
  * // .intlayer/fetch_dictionary/home.cjs
19
33
  * ```
20
34
  */
21
- declare const writeFetchDictionary: (dynamicDictionaries: LocalizedDictionaryOutput, configuration: IntlayerConfig, formats?: ('cjs' | 'esm')[]) => Promise<LocalizedDictionaryOutput>;
35
+ declare const writeFetchDictionary: (dynamicDictionaries: LocalizedDictionaryOutput, configuration: IntlayerConfig, formats?: ('cjs' | 'esm')[], nestedDictionaryGraph?: Map<string, Set<string>>) => Promise<LocalizedDictionaryOutput>;
22
36
  //#endregion
23
37
  export { generateDictionaryEntryPoint, writeFetchDictionary };
24
38
  //# sourceMappingURL=writeFetchDictionary.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"writeFetchDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/writeFetchDictionary.ts"],"mappings":";;;cAUa,+BAA4B,aAC5B,mBACM,wBACK;;;;;;;;;;;;;;;;;cAmDX,uBAAoB,qBACV,2BAAyB,eAC/B,gBAAc,gCAE5B,QAAQ"}
1
+ {"version":3,"file":"writeFetchDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/writeFetchDictionary.ts"],"mappings":";;;;;;;;;;;;;;;;;cAqDa,+BAA4B,aAC5B,mBACM,wBACK,wBACD;;;;;;;;;;;;;;;;;cA2FV,uBAAoB,qBACV,2BAAyB,eAC/B,gBAAc,6BACH,wBACH,YAAY,iBAClC,QAAQ"}
@@ -0,0 +1,54 @@
1
+ import { IntlayerConfig } from "@intlayer/types/config";
2
+ //#region src/buildIntlayerDictionary/writeNestedDictionary.d.ts
3
+ /**
4
+ * Subdirectory of `dictionariesDir` holding the companion modules. Nested under
5
+ * the compiled dictionaries so both stay together and are cleaned as one, and
6
+ * because the `**\/*.json` globs listing compiled dictionaries never match the
7
+ * `.mjs` / `.cjs` files written here.
8
+ */
9
+ declare const NESTED_DICTIONARIES_SUBDIR = "nested";
10
+ /**
11
+ * Path of the companion module carrying the `nest()` targets of a dictionary.
12
+ *
13
+ * Shared with the bundler plugins, which re-point the static import they inject
14
+ * at a `useIntlayer` call site to this module whenever the dictionary has nest
15
+ * targets.
16
+ *
17
+ * @param dictionariesDir - The compiled dictionaries directory.
18
+ * @param key - The dictionary key.
19
+ * @param extension - Module extension, `'mjs'` (default) or `'cjs'`.
20
+ */
21
+ declare const getNestedDictionaryPath: (dictionariesDir: string, key: string, extension?: 'mjs' | 'cjs') => string;
22
+ /**
23
+ * Generates a companion module that re-exports a compiled dictionary with its
24
+ * `nest()` targets attached.
25
+ *
26
+ * The optimizer imports this instead of the raw JSON, so `getNesting` resolves
27
+ * the reference from `nestedDictionaries` rather from the global registry
28
+ * — which lets the registry be stripped, and puts each nest target in the same
29
+ * chunk as the dictionary that references it.
30
+ *
31
+ * @param key - The dictionary key.
32
+ * @param nestedKeys - Keys of the dictionaries it references, transitively.
33
+ * @param format - Output module format.
34
+ *
35
+ * @example
36
+ * ```js
37
+ * import _dictionary from '../dashboard.json' with { type: 'json' };
38
+ * import _1a2b3c from '../common.json' with { type: 'json' };
39
+ *
40
+ * export default { ..._dictionary, nestedDictionaries: { 'common': _1a2b3c } };
41
+ * ```
42
+ */
43
+ declare const generateNestedDictionaryEntryPoint: (key: string, nestedKeys: string[], format?: 'cjs' | 'esm') => string;
44
+ /**
45
+ * Writes one companion module per dictionary holding `nest()` references.
46
+ *
47
+ * @param nestedDictionaryGraph - Dictionary key → keys it nests, transitively.
48
+ * @param configuration - The resolved intlayer configuration.
49
+ * @param formats - Module formats to emit.
50
+ */
51
+ declare const writeNestedDictionaries: (nestedDictionaryGraph: Map<string, Set<string>>, configuration: IntlayerConfig, formats?: ('cjs' | 'esm')[]) => Promise<void>;
52
+ //#endregion
53
+ export { NESTED_DICTIONARIES_SUBDIR, generateNestedDictionaryEntryPoint, getNestedDictionaryPath, writeNestedDictionaries };
54
+ //# sourceMappingURL=writeNestedDictionary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writeNestedDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/writeNestedDictionary.ts"],"mappings":";;;;;;;;cAgBa;;;;;;;;;;;;cAoBA,0BAAuB,yBACX,aACZ;;;;;;;;;;;;;;;;;;;;;;cA0BA,qCAAkC,aAClC,sBACS;;;;;;;;cAkDT,0BAAuB,uBACX,YAAY,cAAY,eAChC,gBAAc,gCAE5B"}
@@ -2,10 +2,12 @@ import { AlignmentPair, FingerprintedBlock } from "./types.js";
2
2
  //#region src/docReview/alignBlocks.d.ts
3
3
  /**
4
4
  * Align the blocks of a base document with the blocks of its translation using a
5
- * Needleman–Wunsch global alignment over anchor similarity and block type.
5
+ * Needleman–Wunsch global alignment over heading depth, anchor similarity and
6
+ * block type.
6
7
  *
7
8
  * Because prose differs across languages, the score is weighted toward the
8
- * structural anchor (digits and symbols) rather than the words themselves.
9
+ * structural signals — heading depth first, then the anchor (digits and symbols)
10
+ * — rather than the words themselves.
9
11
  *
10
12
  * @param baseBlocks - Blocks of the base (source) document.
11
13
  * @param targetBlocks - Blocks of the target (translated) document.
@@ -1 +1 @@
1
- {"version":3,"file":"alignBlocks.d.ts","names":[],"sources":["../../../src/docReview/alignBlocks.ts"],"mappings":";;;;;;;;;;;;;cAca,2BAAwB,YACvB,sBAAoB,cAClB,yBACb"}
1
+ {"version":3,"file":"alignBlocks.d.ts","names":[],"sources":["../../../src/docReview/alignBlocks.ts"],"mappings":";;;;;;;;;;;;;;;cAgEa,2BAAwB,YACvB,sBAAoB,cAClB,yBACb"}
@@ -1 +1 @@
1
- {"version":3,"file":"rebuildDocument.d.ts","names":[],"sources":["../../../src/docReview/rebuildDocument.ts"],"mappings":";;;;;;KAMY;;EAEV,WAAW;;EAEX;;EAEA;;KAGU;EACV,YAAY;EACZ,cAAc;EACd,MAAM;;KAGI;EACV,kBAAkB;;;;;;;;;;cAWP,6BAAwB,YAAA,cAAA,QAIlC,iBAAe;;;;;;;;;;cAmCL,wBAAqB,MAC1B,eAAa,cACL,sBAAoB,kBAChB"}
1
+ {"version":3,"file":"rebuildDocument.d.ts","names":[],"sources":["../../../src/docReview/rebuildDocument.ts"],"mappings":";;;;;;KAMY;;EAEV,WAAW;;EAEX;;EAEA;;KAGU;EACV,YAAY;EACZ,cAAc;EACd,MAAM;;KAGI;EACV,kBAAkB;;;;;;;;;;cAWP,6BAAwB,YAAA,cAAA,QAIlC,iBAAe;;;;;;;;;;cAmDL,wBAAqB,MAC1B,eAAa,cACL,sBAAoB,kBAChB"}
@@ -1 +1 @@
1
- {"version":3,"file":"segmentDocument.d.ts","names":[],"sources":["../../../src/docReview/segmentDocument.ts"],"mappings":";;;;;;;;;;;;;;;;cAmCa,kBAAe,iBAAmB;;;;;;;;;;;;;;;;;;;cAgHlC,kBAAe,iBAAmB"}
1
+ {"version":3,"file":"segmentDocument.d.ts","names":[],"sources":["../../../src/docReview/segmentDocument.ts"],"mappings":";;;;;;;;;;;;;;;;cAoDa,kBAAe,iBAAmB;;;;;;;;;;;;;;;;;;;cAuIlC,kBAAe,iBAAmB"}
@@ -11,6 +11,15 @@ type BlockType = 'heading' | 'paragraph' | 'list_item' | 'code_block' | 'blockqu
11
11
  type Block = {
12
12
  type: BlockType;
13
13
  content: string;
14
+ /**
15
+ * Depth of the ATX heading opening the block (`#` → 1, `######` → 6), or
16
+ * `null` when the block does not start with a heading.
17
+ *
18
+ * Heading depth is the one structural signal that survives translation, so it
19
+ * is used as decisive evidence when aligning a document with its translation:
20
+ * a `##` section is never the counterpart of a `###` section.
21
+ */
22
+ headingDepth: number | null;
14
23
  /** 1-based line number where the block starts (inclusive). */
15
24
  lineStart: number;
16
25
  /** 1-based line number where the block ends (inclusive). */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/docReview/types.ts"],"mappings":";;;;;;KAKY;;;;KAcA;EACV,MAAM;EACN;;EAEA;;EAEA;;;;;KAMU,kBAAkB;;EAE5B;;EAEA;;;;;KAMU,qBAAqB;EAC/B;EACA;EACA;EACA;;;;;;;;KASU;EACV;EACA;EACA;;;;;KAMU;EACN;EAAe;EAAmB;;EAClC;EAAgB;EAAmB;;EACnC;EAAoB;;EACpB;EAAgB;;KAEV;EACV,SAAS;;;KAIC;KAEA;;EAEV;;EAEA"}
1
+ {"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/docReview/types.ts"],"mappings":";;;;;;KAKY;;;;KAcA;EACV,MAAM;EACN;;;;;;;;;EASA;;EAEA;;EAEA;;;;;KAMU,kBAAkB;;EAE5B;;EAEA;;;;;KAMU,qBAAqB;EAC/B;EACA;EACA;EACA;;;;;;;;KASU;EACV;EACA;EACA;;;;;KAMU;EACN;EAAe;EAAmB;;EAClC;EAAgB;EAAmB;;EACnC;EAAoB;;EACpB;EAAgB;;KAEV;EACV,SAAS;;;KAIC;KAEA;;EAEV;;EAEA"}
@@ -6,9 +6,35 @@ type FetchDistantDictionariesOptions = {
6
6
  dictionaryKeys: string[];
7
7
  newDictionariesPath?: string;
8
8
  logPrefix?: string;
9
+ /**
10
+ * Number of dictionaries fetched by a single request.
11
+ * @default 3
12
+ */
13
+ dictionariesPerRequest?: number;
14
+ /**
15
+ * Number of requests kept in flight at the same time.
16
+ * @default 5
17
+ */
18
+ parallelRequests?: number;
19
+ /**
20
+ * Number of retries performed when a batch request fails.
21
+ * @default 2
22
+ */
23
+ maxRetry?: number;
24
+ /**
25
+ * Delay between two attempts of a failing batch request, in milliseconds.
26
+ * @default 250
27
+ */
28
+ retryDelay?: number;
9
29
  };
10
30
  /**
11
31
  * Fetch distant dictionaries and update the logger with their statuses.
32
+ *
33
+ * Keys are grouped into batches fetched by a single request each, and those
34
+ * requests are kept in flight together — by default 5 concurrent requests of 3
35
+ * dictionaries, so 15 dictionaries travel at any given time. A slot is refilled
36
+ * as soon as its request settles, so no batch waits for the whole wave.
37
+ * Failing requests are retried before their keys are reported as errors.
12
38
  */
13
39
  declare const fetchDistantDictionaries: (options: FetchDistantDictionariesOptions, onStatusUpdate?: (status: DictionariesStatus[]) => void) => Promise<DictionaryAPI[]>;
14
40
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"fetchDistantDictionaries.d.ts","names":[],"sources":["../../src/fetchDistantDictionaries.ts"],"mappings":";;;;KASK;EACH;EACA;EACA;;;;;cAMW,2BAAwB,SAC1B,iCAA+B,kBACtB,QAAQ,kCACzB,QAAQ"}
1
+ {"version":3,"file":"fetchDistantDictionaries.d.ts","names":[],"sources":["../../src/fetchDistantDictionaries.ts"],"mappings":";;;;KAqDK;EACH;EACA;EACA;;;;;EAKA;;;;;EAKA;;;;;EAKA;;;;;EAKA;;;;;;;;;;;cAYW,2BAAwB,SAC1B,iCAA+B,kBACtB,QAAQ,kCACzB,QAAQ"}
@@ -8,6 +8,7 @@ declare const formatDictionaryOutput: (dictionary: Dictionary, format: Dictionar
8
8
  projectIds?: string[];
9
9
  localId?: import("@intlayer/types").LocalDictionaryId;
10
10
  localIds?: import("@intlayer/types").LocalDictionaryId[];
11
+ nestedDictionaries?: Record<import("@intlayer/types").DictionaryKey, unknown>;
11
12
  key: import("@intlayer/types").DictionaryKey;
12
13
  title?: string;
13
14
  description?: string;
@@ -34,6 +35,7 @@ declare const formatDictionariesOutput: (dictionaries: Dictionary[], format: Dic
34
35
  projectIds?: string[];
35
36
  localId?: import("@intlayer/types").LocalDictionaryId;
36
37
  localIds?: import("@intlayer/types").LocalDictionaryId[];
38
+ nestedDictionaries?: Record<import("@intlayer/types").DictionaryKey, unknown>;
37
39
  key: import("@intlayer/types").DictionaryKey;
38
40
  title?: string;
39
41
  description?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"formatDictionary.d.ts","names":[],"sources":["../../src/formatDictionary.ts"],"mappings":";;cAYa,mBAAgB,YAAgB,eAAa;cAoC7C,qBAAkB,cACf,iBACb,QAAQ;cAEE,yBAAsB,YACrB,YAAU,QACd;;;;;;;;;;;;;;;;;;;;;;;;;IAmCT;cAEY,2BAAwB,cACrB,cAAY,QAClB;;;;;;;;;;;;;;;;;;;;;;;;;IAEoE"}
1
+ {"version":3,"file":"formatDictionary.d.ts","names":[],"sources":["../../src/formatDictionary.ts"],"mappings":";;cAYa,mBAAgB,YAAgB,eAAa;cAoC7C,qBAAkB,cACf,iBACb,QAAQ;cAEE,yBAAsB,YACrB,YAAU,QACd;;;;;;;;;;;;;;;;;;;;;;;;;;IAmCT;cAEY,2BAAwB,cACrB,cAAY,QAClB;;;;;;;;;;;;;;;;;;;;;;;;;;IAEoE"}
@@ -14,6 +14,7 @@ declare class DictionariesLogger {
14
14
  private remoteError;
15
15
  private pluginTotal;
16
16
  private pluginDone;
17
+ private pluginNames;
17
18
  private pluginError;
18
19
  constructor();
19
20
  setExpectRemote(expect: boolean): void;
@@ -24,9 +25,23 @@ declare class DictionariesLogger {
24
25
  private startSpinner;
25
26
  private stopSpinner;
26
27
  setRemoteError: (error?: Error) => void;
28
+ /**
29
+ * Register the names of the plugins providing dictionaries.
30
+ * They are displayed next to the plugin progress counters, e.g.
31
+ * `Plugin content: 6/6 (sync-json, load-po)`.
32
+ *
33
+ * @param names - Names of the plugins exposing a `loadDictionaries` hook
34
+ */
35
+ setPluginNames(names: string[]): void;
27
36
  setPluginTotal(total: number): void;
28
37
  setPluginDone(done: number): void;
29
- setPluginError(error?: Error): void;
38
+ /**
39
+ * Flag the plugin line as errored.
40
+ *
41
+ * @param error - Error thrown while loading the plugin dictionaries
42
+ * @param pluginName - Name of the plugin that threw, prefixed to the message
43
+ */
44
+ setPluginError(error?: Error, pluginName?: string): void;
30
45
  private render;
31
46
  private computeProgress;
32
47
  }
@@ -1 +1 @@
1
- {"version":3,"file":"log.d.ts","names":[],"sources":["../../../src/loadDictionaries/log.ts"],"mappings":";;cAYa;UACH;UACA;UACA;UACA;mBACS;UACT;mBACS;UACT;UACA;UACA;UACA;UACA;UACA;UACA;EAER;EAIA,gBAAgB;EAIhB;EAOA;EAIA,OAAO,aAAa;EAyBpB;UAOQ;UAQA;EAMD,iBAAc,QAAY;EAQjC,eAAe;EASf,cAAc;EAMd,eAAe,QAAQ;UAMf;UAqGA"}
1
+ {"version":3,"file":"log.d.ts","names":[],"sources":["../../../src/loadDictionaries/log.ts"],"mappings":";;cAYa;UACH;UACA;UACA;UACA;mBACS;UACT;mBACS;UACT;UACA;UACA;UACA;UACA;UACA;UACA;UACA;EAER;EAIA,gBAAgB;EAIhB;EAOA;EAIA,OAAO,aAAa;EAyBpB;UAOQ;UAQA;EAMD,iBAAc,QAAY;;;;;;;;EAejC,eAAe;EAOf,eAAe;EASf,cAAc;;;;;;;EAYd,eAAe,QAAQ,OAAO;UAStB;UA0GA"}
@@ -0,0 +1,16 @@
1
+ //#region src/utils/chunkArray.d.ts
2
+ /**
3
+ * Splits an array into consecutive chunks of at most `chunkSize` items.
4
+ *
5
+ * The last chunk holds the remainder and may be smaller. An empty input, or a
6
+ * `chunkSize` lower than 1, returns an empty list of chunks.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * chunkArray(['a', 'b', 'c', 'd', 'e'], 2); // [['a', 'b'], ['c', 'd'], ['e']]
11
+ * ```
12
+ */
13
+ declare const chunkArray: <T>(items: T[], chunkSize: number) => T[][];
14
+ //#endregion
15
+ export { chunkArray };
16
+ //# sourceMappingURL=chunkArray.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunkArray.d.ts","names":[],"sources":["../../../src/utils/chunkArray.ts"],"mappings":";;;;;;;;;;;;cAWa,aAAc,GAAC,OAAS,KAAG,sBAAsB"}
@@ -1,6 +1,7 @@
1
1
  import { Extension, Format, getExtensionFromFormat, getFormatFromExtension } from "./getFormatFromExtension.js";
2
2
  import { autoDecorateContent } from "./autoDecorateContent.js";
3
3
  import { buildComponentFilesList } from "./buildComponentFilesList.js";
4
+ import { chunkArray } from "./chunkArray.js";
4
5
  import { JSONObject, JsonChunk, assembleJSON, chunkJSON, reconstructFromSingleChunk } from "./chunkJSON.js";
5
6
  import { formatLocale, formatPath } from "./formatter.js";
6
7
  import { getChunk } from "./getChunk.js";
@@ -13,9 +14,9 @@ import { getGlobalLimiter, getTaskLimiter, parallelizeGlobal } from "./paralleli
13
14
  import { Primitive, Recursive, excludeObjectFormat, reduceObjectFormat } from "./reduceObjectFormat.js";
14
15
  import { resolveObjectPromises } from "./resolveObjectPromises.js";
15
16
  import { resolveRelativePath } from "./resolveRelativePath.js";
16
- import { runOnce } from "./runOnce.js";
17
+ import { RunOnceContext, runOnce } from "./runOnce.js";
17
18
  import { ParallelHandle, runParallel } from "./runParallel/index.js";
18
19
  import { sortAlphabetically } from "./sortAlphabetically.js";
19
20
  import { splitTextByLines } from "./splitTextByLine.js";
20
21
  import { verifyIdenticObjectFormat } from "./verifyIdenticObjectFormat.js";
21
- export { Extension, Format, JSONObject, JsonChunk, ParallelHandle, Primitive, Queue, Recursive, assembleJSON, autoDecorateContent, buildComponentFilesList, chunkJSON, excludeObjectFormat, formatLocale, formatPath, getChunk, getContentExtension, getExtensionFromFormat, getFormatFromExtension, getGlobalLimiter, getPathHash, getTaskLimiter, mergeChunks, pLimit, parallelize, parallelizeGlobal, reconstructFromSingleChunk, reduceObjectFormat, resolveObjectPromises, resolveRelativePath, runOnce, runParallel, sortAlphabetically, splitTextByLines, verifyIdenticObjectFormat };
22
+ export { Extension, Format, JSONObject, JsonChunk, ParallelHandle, Primitive, Queue, Recursive, RunOnceContext, assembleJSON, autoDecorateContent, buildComponentFilesList, chunkArray, chunkJSON, excludeObjectFormat, formatLocale, formatPath, getChunk, getContentExtension, getExtensionFromFormat, getFormatFromExtension, getGlobalLimiter, getPathHash, getTaskLimiter, mergeChunks, pLimit, parallelize, parallelizeGlobal, reconstructFromSingleChunk, reduceObjectFormat, resolveObjectPromises, resolveRelativePath, runOnce, runParallel, sortAlphabetically, splitTextByLines, verifyIdenticObjectFormat };
@@ -1,4 +1,16 @@
1
1
  //#region src/utils/runOnce.d.ts
2
+ /**
3
+ * Context handed to the callback so it can interact with the lock it runs under.
4
+ */
5
+ type RunOnceContext = {
6
+ /**
7
+ * Re-create the sentinel file after an operation that may have deleted it —
8
+ * typically cleaning the output directory, which wipes the cache directory the
9
+ * sentinel lives in. Without this, concurrent processes would see no lock and
10
+ * start a competing run while this one is still writing.
11
+ */
12
+ renewLock: () => Promise<void>;
13
+ };
2
14
  type RunOnceOptions = {
3
15
  /**
4
16
  * The function to execute when the sentinel is not found or is older than the cache timeout.
@@ -16,30 +28,42 @@ type RunOnceOptions = {
16
28
  * @default false
17
29
  */
18
30
  forceRun?: boolean;
31
+ /**
32
+ * How long to wait for another process to release the sentinel before
33
+ * considering its run abandoned and taking the lock over.
34
+ *
35
+ * @default 300000 = 5 minutes
36
+ */
37
+ lockWaitTimeoutMs?: number;
19
38
  };
20
39
  /**
21
40
  * Ensures a callback function runs only once within a specified time window across multiple processes.
22
41
  * Uses a sentinel file to coordinate execution and prevent duplicate work.
23
42
  *
43
+ * Processes that lose the race for the sentinel wait for the owner to finish
44
+ * rather than running a competing copy of the callback — concurrent runs would
45
+ * otherwise write to (and clean) the same output directory at the same time.
46
+ *
24
47
  * @param sentinelFilePath - Path to the sentinel file used for coordination
25
48
  * @param callback - The function to execute (should be async)
26
49
  * @param options - The options for the runOnce function
27
50
  *
28
51
  * @example
29
52
  * ```typescript
30
- * await runPrepareIntlayerOnce(
53
+ * await runOnce(
31
54
  * '/tmp/intlayer-sentinel',
32
- * async () => {
33
- * // Your initialization logic here
55
+ * async ({ renewLock }) => {
56
+ * await cleanOutputDir(configuration); // may delete the sentinel
57
+ * await renewLock();
34
58
  * await prepareIntlayer();
35
59
  * },
36
- * 30 * 1000 // 30 seconds cache
60
+ * { cacheTimeoutMs: 30 * 1000 } // 30 seconds cache
37
61
  * );
38
62
  * ```
39
63
  *
40
64
  * @throws {Error} When there are unexpected filesystem errors
41
65
  */
42
- declare const runOnce: (sentinelFilePath: string, callback: () => void | Promise<void>, options?: RunOnceOptions) => Promise<void>;
66
+ declare const runOnce: (sentinelFilePath: string, callback: (context: RunOnceContext) => void | Promise<void>, options?: RunOnceOptions) => Promise<void>;
43
67
  //#endregion
44
- export { runOnce };
68
+ export { RunOnceContext, runOnce };
45
69
  //# sourceMappingURL=runOnce.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runOnce.d.ts","names":[],"sources":["../../../src/utils/runOnce.ts"],"mappings":";KAIK;;;;EAIH,0BAA0B;;;;;;EAM1B;;;;;;EAMA;;;;;;;;;;;;;;;;;;;;;;;;cAoEW,UAAO,0BACM,uBACD,eAAa,UAC1B,mBAAc"}
1
+ {"version":3,"file":"runOnce.d.ts","names":[],"sources":["../../../src/utils/runOnce.ts"],"mappings":";;;;KA4BY;;;;;;;EAOV,iBAAiB;;KAGd;;;;EAIH,0BAA0B;;;;;;EAM1B;;;;;;EAMA;;;;;;;EAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAwKW,UAAO,0BACM,WACb,SAAS,0BAA0B,eAAa,UACjD,mBAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"transformJSFile.d.ts","names":[],"sources":["../../../src/writeContentDeclaration/transformJSFile.ts"],"mappings":";;;;;;cAwmBa,kBAAe,qBACP,YACP,YAAU,iBACL,QAAM,yBAEtB"}
1
+ {"version":3,"file":"transformJSFile.d.ts","names":[],"sources":["../../../src/writeContentDeclaration/transformJSFile.ts"],"mappings":";;;;;;cAixBa,kBAAe,qBACP,YACP,YAAU,iBACL,QAAM,yBAEtB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/engine",
3
- "version": "9.1.3",
3
+ "version": "9.3.0",
4
4
  "private": false,
5
5
  "description": "Scans and builds Intlayer declaration files into dictionaries based on Intlayer configuration.",
6
6
  "keywords": [
@@ -141,22 +141,22 @@
141
141
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
142
142
  },
143
143
  "dependencies": {
144
- "@intlayer/api": "9.1.3",
145
- "@intlayer/config": "9.1.3",
146
- "@intlayer/core": "9.1.3",
147
- "@intlayer/dictionaries-entry": "9.1.3",
148
- "@intlayer/remote-dictionaries-entry": "9.1.3",
149
- "@intlayer/types": "9.1.3",
150
- "@intlayer/unmerged-dictionaries-entry": "9.1.3",
144
+ "@intlayer/api": "9.3.0",
145
+ "@intlayer/config": "9.3.0",
146
+ "@intlayer/core": "9.3.0",
147
+ "@intlayer/dictionaries-entry": "9.3.0",
148
+ "@intlayer/remote-dictionaries-entry": "9.3.0",
149
+ "@intlayer/types": "9.3.0",
150
+ "@intlayer/unmerged-dictionaries-entry": "9.3.0",
151
151
  "@parcel/watcher": "2.6.0",
152
152
  "defu": "6.1.7",
153
153
  "fast-glob": "3.3.3",
154
- "recast": "0.23.14",
154
+ "recast": "0.23.19",
155
155
  "simple-git": "3.36.0",
156
156
  "zod-to-ts": "2.1.0"
157
157
  },
158
158
  "devDependencies": {
159
- "@types/node": "26.1.2",
159
+ "@types/node": "26.2.0",
160
160
  "@utils/ts-config": "1.0.4",
161
161
  "@utils/ts-config-types": "1.0.4",
162
162
  "@utils/tsdown-config": "1.0.4",
@@ -167,7 +167,7 @@
167
167
  "zod": "4.4.3"
168
168
  },
169
169
  "peerDependencies": {
170
- "@intlayer/babel": "9.1.3"
170
+ "@intlayer/babel": "9.3.0"
171
171
  },
172
172
  "peerDependenciesMeta": {
173
173
  "@intlayer/babel": {