@intlayer/engine 9.1.3 → 9.2.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 (38) 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/docReview/alignBlocks.cjs +57 -8
  6. package/dist/cjs/docReview/alignBlocks.cjs.map +1 -1
  7. package/dist/cjs/docReview/rebuildDocument.cjs +37 -9
  8. package/dist/cjs/docReview/rebuildDocument.cjs.map +1 -1
  9. package/dist/cjs/docReview/segmentDocument.cjs +19 -2
  10. package/dist/cjs/docReview/segmentDocument.cjs.map +1 -1
  11. package/dist/cjs/prepareIntlayer.cjs +7 -3
  12. package/dist/cjs/prepareIntlayer.cjs.map +1 -1
  13. package/dist/cjs/utils/runOnce.cjs +129 -50
  14. package/dist/cjs/utils/runOnce.cjs.map +1 -1
  15. package/dist/cjs/writeFileIfChanged.cjs +14 -7
  16. package/dist/cjs/writeFileIfChanged.cjs.map +1 -1
  17. package/dist/esm/docReview/alignBlocks.mjs +57 -8
  18. package/dist/esm/docReview/alignBlocks.mjs.map +1 -1
  19. package/dist/esm/docReview/rebuildDocument.mjs +37 -9
  20. package/dist/esm/docReview/rebuildDocument.mjs.map +1 -1
  21. package/dist/esm/docReview/segmentDocument.mjs +19 -2
  22. package/dist/esm/docReview/segmentDocument.mjs.map +1 -1
  23. package/dist/esm/prepareIntlayer.mjs +7 -3
  24. package/dist/esm/prepareIntlayer.mjs.map +1 -1
  25. package/dist/esm/utils/runOnce.mjs +129 -50
  26. package/dist/esm/utils/runOnce.mjs.map +1 -1
  27. package/dist/esm/writeFileIfChanged.mjs +15 -8
  28. package/dist/esm/writeFileIfChanged.mjs.map +1 -1
  29. package/dist/types/docReview/alignBlocks.d.ts +4 -2
  30. package/dist/types/docReview/alignBlocks.d.ts.map +1 -1
  31. package/dist/types/docReview/rebuildDocument.d.ts.map +1 -1
  32. package/dist/types/docReview/segmentDocument.d.ts.map +1 -1
  33. package/dist/types/docReview/types.d.ts +9 -0
  34. package/dist/types/docReview/types.d.ts.map +1 -1
  35. package/dist/types/utils/index.d.ts +2 -2
  36. package/dist/types/utils/runOnce.d.ts +30 -6
  37. package/dist/types/utils/runOnce.d.ts.map +1 -1
  38. package/package.json +9 -9
@@ -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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/engine",
3
- "version": "9.1.3",
3
+ "version": "9.2.0",
4
4
  "private": false,
5
5
  "description": "Scans and builds Intlayer declaration files into dictionaries based on Intlayer configuration.",
6
6
  "keywords": [
@@ -141,13 +141,13 @@
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.2.0",
145
+ "@intlayer/config": "9.2.0",
146
+ "@intlayer/core": "9.2.0",
147
+ "@intlayer/dictionaries-entry": "9.2.0",
148
+ "@intlayer/remote-dictionaries-entry": "9.2.0",
149
+ "@intlayer/types": "9.2.0",
150
+ "@intlayer/unmerged-dictionaries-entry": "9.2.0",
151
151
  "@parcel/watcher": "2.6.0",
152
152
  "defu": "6.1.7",
153
153
  "fast-glob": "3.3.3",
@@ -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.2.0"
171
171
  },
172
172
  "peerDependenciesMeta": {
173
173
  "@intlayer/babel": {