@inlang/sdk 0.34.6 → 0.34.8

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.
@@ -1 +1 @@
1
- {"version":3,"file":"createMessagesQuery.d.ts","sourceRoot":"","sources":["../src/createMessagesQuery.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAyC,MAAM,UAAU,CAAA;AAEpF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAA;AAEzE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAKnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AA4B/D,KAAK,6BAA6B,GAAG;IACpC,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,iBAAiB,CAAA;IAC5B,QAAQ,EAAE,MAAM,eAAe,GAAG,SAAS,CAAA;IAC3C,eAAe,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,GAAG,SAAS,CAAA;IAC7E,0BAA0B,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,CAAA;IAC/C,mBAAmB,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,CAAA;IACxC,mBAAmB,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,CAAA;CACxC,CAAA;AACD;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,EACnC,WAAW,EACX,SAAS,EACT,QAAQ,EACR,eAAe,EACf,0BAA0B,EAC1B,mBAAmB,EACnB,mBAAmB,GACnB,EAAE,6BAA6B,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC,UAAU,CAAC,CA+MpE"}
1
+ {"version":3,"file":"createMessagesQuery.d.ts","sourceRoot":"","sources":["../src/createMessagesQuery.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAyC,MAAM,UAAU,CAAA;AAEpF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAA;AAEzE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAKnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AA4B/D,KAAK,6BAA6B,GAAG;IACpC,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,iBAAiB,CAAA;IAC5B,QAAQ,EAAE,MAAM,eAAe,GAAG,SAAS,CAAA;IAC3C,eAAe,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,GAAG,SAAS,CAAA;IAC7E,0BAA0B,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,CAAA;IAC/C,mBAAmB,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,CAAA;IACxC,mBAAmB,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,CAAA;CACxC,CAAA;AACD;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,EACnC,WAAW,EACX,SAAS,EACT,QAAQ,EACR,eAAe,EACf,0BAA0B,EAC1B,mBAAmB,EACnB,mBAAmB,GACnB,EAAE,6BAA6B,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC,UAAU,CAAC,CA6MpE"}
@@ -53,13 +53,6 @@ export function createMessagesQuery({ projectPath, nodeishFs, settings, resolved
53
53
  const resolvedPluginApi = resolvedModules()?.resolvedPluginApi;
54
54
  if (!resolvedPluginApi)
55
55
  return;
56
- const abortController = new AbortController();
57
- // called between executions of effects as well as on disposal
58
- onCleanup(() => {
59
- // stop listening on fs events
60
- abortController.abort();
61
- delegate?.onCleanup();
62
- });
63
56
  const fsWithWatcher = createNodeishFsWithWatcher({
64
57
  nodeishFs: nodeishFs,
65
58
  // this message is called whenever a file changes that was read earlier by this filesystem
@@ -75,7 +68,12 @@ export function createMessagesQuery({ projectPath, nodeishFs, settings, resolved
75
68
  onLoadMessageResult();
76
69
  });
77
70
  },
78
- abortController,
71
+ });
72
+ // called between executions of effects as well as on disposal
73
+ onCleanup(() => {
74
+ // stop listening on fs events
75
+ fsWithWatcher.stopWatching();
76
+ delegate?.onCleanup();
79
77
  });
80
78
  if (!resolvedPluginApi.loadMessages) {
81
79
  onInitialMessageLoadResult(new Error("no loadMessages in resolved Modules found"));
@@ -8,6 +8,7 @@ import type { NodeishFilesystem } from "@lix-js/fs";
8
8
  export declare const createNodeishFsWithWatcher: (args: {
9
9
  nodeishFs: NodeishFilesystem;
10
10
  updateMessages: () => void;
11
- abortController: AbortController;
12
- }) => NodeishFilesystem;
11
+ }) => NodeishFilesystem & {
12
+ stopWatching: () => void;
13
+ };
13
14
  //# sourceMappingURL=createNodeishFsWithWatcher.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createNodeishFsWithWatcher.d.ts","sourceRoot":"","sources":["../src/createNodeishFsWithWatcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAEnD;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,SAAU;IAChD,SAAS,EAAE,iBAAiB,CAAA;IAC5B,cAAc,EAAE,MAAM,IAAI,CAAA;IAC1B,eAAe,EAAE,eAAe,CAAA;CAChC,KAAG,iBAgDH,CAAA"}
1
+ {"version":3,"file":"createNodeishFsWithWatcher.d.ts","sourceRoot":"","sources":["../src/createNodeishFsWithWatcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAEnD;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,SAAU;IAChD,SAAS,EAAE,iBAAiB,CAAA;IAC5B,cAAc,EAAE,MAAM,IAAI,CAAA;CAC1B;kBACc,MAAM,IAAI;CA6DxB,CAAA"}
@@ -6,12 +6,22 @@
6
6
  */
7
7
  export const createNodeishFsWithWatcher = (args) => {
8
8
  const pathList = [];
9
+ let abortControllers = [];
10
+ const stopWatching = () => {
11
+ for (const ac of abortControllers) {
12
+ ac.abort();
13
+ }
14
+ // release references
15
+ abortControllers = [];
16
+ };
9
17
  const makeWatcher = (path) => {
10
18
  ;
11
19
  (async () => {
12
20
  try {
21
+ const ac = new AbortController();
22
+ abortControllers.push(ac);
13
23
  const watcher = args.nodeishFs.watch(path, {
14
- signal: args.abortController.signal,
24
+ signal: ac.signal,
15
25
  persistent: false,
16
26
  });
17
27
  if (watcher) {
@@ -51,5 +61,6 @@ export const createNodeishFsWithWatcher = (args) => {
51
61
  writeFile: args.nodeishFs.writeFile,
52
62
  watch: args.nodeishFs.watch,
53
63
  stat: args.nodeishFs.stat,
64
+ stopWatching,
54
65
  };
55
66
  };
@@ -4,13 +4,11 @@ import { createNodeishFsWithWatcher } from "./createNodeishFsWithWatcher.js";
4
4
  describe("watcher", () => {
5
5
  it("should trigger the update function when file changes", async () => {
6
6
  let counter = 0;
7
- const abortController = new AbortController();
8
7
  const fs = createNodeishFsWithWatcher({
9
8
  nodeishFs: createNodeishMemoryFs(),
10
9
  updateMessages: () => {
11
10
  counter++;
12
11
  },
13
- abortController,
14
12
  });
15
13
  // establish watcher
16
14
  await fs.writeFile("file.txt", "a");
@@ -30,7 +28,7 @@ describe("watcher", () => {
30
28
  await new Promise((resolve) => setTimeout(resolve, 0));
31
29
  //check if update function was called
32
30
  expect(counter).toBe(2);
33
- abortController.abort();
31
+ fs.stopWatching();
34
32
  // change file
35
33
  await fs.writeFile("file.txt", "b");
36
34
  await new Promise((resolve) => setTimeout(resolve, 0));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@inlang/sdk",
3
3
  "type": "module",
4
- "version": "0.34.6",
4
+ "version": "0.34.8",
5
5
  "license": "Apache-2.0",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -37,13 +37,13 @@
37
37
  "@inlang/language-tag": "1.5.1",
38
38
  "@inlang/message": "2.1.0",
39
39
  "@inlang/message-lint-rule": "1.4.7",
40
- "@inlang/plugin": "2.4.11",
41
40
  "@inlang/module": "1.2.11",
41
+ "@inlang/plugin": "2.4.11",
42
42
  "@inlang/project-settings": "2.4.2",
43
43
  "@inlang/result": "1.1.0",
44
44
  "@inlang/translatable": "1.3.1",
45
- "@lix-js/client": "1.4.0",
46
- "@lix-js/fs": "1.0.0"
45
+ "@lix-js/fs": "1.0.0",
46
+ "@lix-js/client": "1.4.0"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@types/debug": "^4.1.12",
@@ -103,14 +103,6 @@ export function createMessagesQuery({
103
103
  const resolvedPluginApi = resolvedModules()?.resolvedPluginApi
104
104
  if (!resolvedPluginApi) return
105
105
 
106
- const abortController = new AbortController()
107
- // called between executions of effects as well as on disposal
108
- onCleanup(() => {
109
- // stop listening on fs events
110
- abortController.abort()
111
- delegate?.onCleanup()
112
- })
113
-
114
106
  const fsWithWatcher = createNodeishFsWithWatcher({
115
107
  nodeishFs: nodeishFs,
116
108
  // this message is called whenever a file changes that was read earlier by this filesystem
@@ -133,7 +125,13 @@ export function createMessagesQuery({
133
125
  onLoadMessageResult()
134
126
  })
135
127
  },
136
- abortController,
128
+ })
129
+
130
+ // called between executions of effects as well as on disposal
131
+ onCleanup(() => {
132
+ // stop listening on fs events
133
+ fsWithWatcher.stopWatching()
134
+ delegate?.onCleanup()
137
135
  })
138
136
 
139
137
  if (!resolvedPluginApi.loadMessages) {
@@ -6,14 +6,11 @@ describe("watcher", () => {
6
6
  it("should trigger the update function when file changes", async () => {
7
7
  let counter = 0
8
8
 
9
- const abortController = new AbortController()
10
-
11
9
  const fs = createNodeishFsWithWatcher({
12
10
  nodeishFs: createNodeishMemoryFs(),
13
11
  updateMessages: () => {
14
12
  counter++
15
13
  },
16
- abortController,
17
14
  })
18
15
 
19
16
  // establish watcher
@@ -41,7 +38,7 @@ describe("watcher", () => {
41
38
  //check if update function was called
42
39
  expect(counter).toBe(2)
43
40
 
44
- abortController.abort()
41
+ fs.stopWatching()
45
42
 
46
43
  // change file
47
44
  await fs.writeFile("file.txt", "b")
@@ -9,15 +9,27 @@ import type { NodeishFilesystem } from "@lix-js/fs"
9
9
  export const createNodeishFsWithWatcher = (args: {
10
10
  nodeishFs: NodeishFilesystem
11
11
  updateMessages: () => void
12
- abortController: AbortController
13
- }): NodeishFilesystem => {
12
+ }): NodeishFilesystem & {
13
+ stopWatching: () => void
14
+ } => {
14
15
  const pathList: string[] = []
16
+ let abortControllers: AbortController[] = []
17
+
18
+ const stopWatching = () => {
19
+ for (const ac of abortControllers) {
20
+ ac.abort()
21
+ }
22
+ // release references
23
+ abortControllers = [];
24
+ }
15
25
 
16
26
  const makeWatcher = (path: string) => {
17
27
  ;(async () => {
18
28
  try {
29
+ const ac = new AbortController()
30
+ abortControllers.push(ac)
19
31
  const watcher = args.nodeishFs.watch(path, {
20
- signal: args.abortController.signal,
32
+ signal: ac.signal,
21
33
  persistent: false,
22
34
  })
23
35
  if (watcher) {
@@ -57,5 +69,6 @@ export const createNodeishFsWithWatcher = (args: {
57
69
  writeFile: args.nodeishFs.writeFile,
58
70
  watch: args.nodeishFs.watch,
59
71
  stat: args.nodeishFs.stat,
72
+ stopWatching,
60
73
  }
61
74
  }