typesync 0.12.2 → 0.13.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.
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readFileContents = readFileContents;
4
+ const promises_1 = require("node:fs/promises");
5
+ async function readFileContents(filePath) {
6
+ await assertFile(filePath);
7
+ return (0, promises_1.readFile)(filePath, 'utf-8');
8
+ }
9
+ async function assertFile(filePath) {
10
+ if (!(await existsAsync(filePath))) {
11
+ throw new Error(`${filePath} does not exist.`);
12
+ }
13
+ }
14
+ async function existsAsync(filePath) {
15
+ try {
16
+ await (0, promises_1.stat)(filePath);
17
+ return true;
18
+ }
19
+ catch (err) {
20
+ /* istanbul ignore else */
21
+ if (err.code === 'ENOENT') {
22
+ return false;
23
+ }
24
+ /* istanbul ignore next */
25
+ throw err;
26
+ }
27
+ }
28
+ //# sourceMappingURL=fs-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs-utils.js","sourceRoot":"","sources":["../src/fs-utils.ts"],"names":[],"mappings":";;AAEA,4CAGC;AALD,+CAAiD;AAE1C,KAAK,UAAU,gBAAgB,CAAC,QAAgB;IACrD,MAAM,UAAU,CAAC,QAAQ,CAAC,CAAA;IAC1B,OAAO,IAAA,mBAAQ,EAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;AACpC,CAAC;AAED,KAAK,UAAU,UAAU,CAAC,QAAgB;IACxC,IAAI,CAAC,CAAC,MAAM,WAAW,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CAAC,GAAG,QAAQ,kBAAkB,CAAC,CAAA;IAChD,CAAC;AACH,CAAC;AAED,KAAK,UAAU,WAAW,CAAC,QAAgB;IACzC,IAAI,CAAC;QACH,MAAM,IAAA,eAAI,EAAC,QAAQ,CAAC,CAAA;QACpB,OAAO,IAAI,CAAA;IACb,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,0BAA0B;QAC1B,IAAK,GAAwB,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAChD,OAAO,KAAK,CAAA;QACd,CAAC;QACD,0BAA0B;QAC1B,MAAM,GAAG,CAAA;IACX,CAAC;AACH,CAAC"}
package/lib/globber.d.ts CHANGED
@@ -3,15 +3,15 @@
3
3
  */
4
4
  export interface IGlobber {
5
5
  /**
6
- * Globs for package.json files.
6
+ * Globs for `package.json` files.
7
7
  *
8
- * @param pattern
8
+ * @param root
9
9
  */
10
- globPackageFiles(pattern: string): Promise<Array<string>>;
10
+ globPackageFiles(root: string): Promise<Array<string>>;
11
11
  }
12
12
  /**
13
13
  * Creates a globber.
14
14
  */
15
15
  export declare function createGlobber(): {
16
- globPackageFiles(pattern: string): Promise<string[]>;
16
+ globPackageFiles(root: string, file?: string): Promise<Array<string>>;
17
17
  };
package/lib/globber.js CHANGED
@@ -24,18 +24,19 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.createGlobber = createGlobber;
27
- var glob_1 = require("glob");
28
- var path = __importStar(require("path"));
29
- var util_1 = require("./util");
27
+ const path = __importStar(require("node:path"));
28
+ const glob_1 = require("glob");
29
+ const util_1 = require("./util");
30
30
  /**
31
31
  * Creates a globber.
32
32
  */
33
33
  function createGlobber() {
34
34
  return {
35
- globPackageFiles: function (pattern) {
36
- return (0, glob_1.glob)(path.join(pattern, 'package.json'), {
35
+ async globPackageFiles(root, file = 'package.json') {
36
+ const source = await (0, glob_1.glob)(path.join(root, file), {
37
37
  ignore: '**/node_modules/**',
38
- }).then(util_1.uniq);
38
+ });
39
+ return (0, util_1.uniq)(source);
39
40
  },
40
41
  };
41
42
  }
@@ -1 +1 @@
1
- {"version":3,"file":"globber.js","sourceRoot":"","sources":["../src/globber.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,sCAQC;AA3BD,6BAA2B;AAC3B,yCAA4B;AAC5B,+BAA6B;AAc7B;;GAEG;AACH,SAAgB,aAAa;IAC3B,OAAO;QACL,gBAAgB,YAAC,OAAe;YAC9B,OAAO,IAAA,WAAI,EAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,EAAE;gBAC9C,MAAM,EAAE,oBAAoB;aAC7B,CAAC,CAAC,IAAI,CAAC,WAAI,CAAC,CAAA;QACf,CAAC;KACF,CAAA;AACH,CAAC"}
1
+ {"version":3,"file":"globber.js","sourceRoot":"","sources":["../src/globber.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,sCAaC;AAhCD,gDAAiC;AACjC,+BAA2B;AAC3B,iCAA6B;AAc7B;;GAEG;AACH,SAAgB,aAAa;IAC3B,OAAO;QACL,KAAK,CAAC,gBAAgB,CACpB,IAAY,EACZ,IAAI,GAAG,cAAc;YAErB,MAAM,MAAM,GAAG,MAAM,IAAA,WAAI,EAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE;gBAC/C,MAAM,EAAE,oBAAoB;aAC7B,CAAC,CAAA;YAEF,OAAO,IAAA,WAAI,EAAC,MAAM,CAAC,CAAA;QACrB,CAAC;KACF,CAAA;AACH,CAAC"}
package/lib/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export * from './type-syncer';
2
1
  export * from './config-service';
3
- export * from './types';
4
2
  export * from './package-source';
3
+ export * from './type-syncer';
4
+ export * from './types';
package/lib/index.js CHANGED
@@ -14,8 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./type-syncer"), exports);
18
17
  __exportStar(require("./config-service"), exports);
19
- __exportStar(require("./types"), exports);
20
18
  __exportStar(require("./package-source"), exports);
19
+ __exportStar(require("./type-syncer"), exports);
20
+ __exportStar(require("./types"), exports);
21
21
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA6B;AAC7B,mDAAgC;AAChC,0CAAuB;AACvB,mDAAgC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAgC;AAChC,mDAAgC;AAChC,gDAA6B;AAC7B,0CAAuB"}
@@ -1,2 +1,15 @@
1
- import { IPackageJSONService } from './types';
1
+ import { IPackageFile } from './types';
2
+ /**
3
+ * File service.
4
+ */
5
+ export interface IPackageJSONService {
6
+ /**
7
+ * Reads and parses JSON from the specified file. Path is relative to the current working directory.
8
+ */
9
+ readPackageFile(filePath: string): Promise<IPackageFile>;
10
+ /**
11
+ * Writes the JSON to the specified file.
12
+ */
13
+ writePackageFile(filePath: string, fileContents: IPackageFile): Promise<void>;
14
+ }
2
15
  export declare function createPackageJSONFileService(): IPackageJSONService;
@@ -22,128 +22,27 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
- var __generator = (this && this.__generator) || function (thisArg, body) {
35
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
36
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
37
- function verb(n) { return function (v) { return step([n, v]); }; }
38
- function step(op) {
39
- if (f) throw new TypeError("Generator is already executing.");
40
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
41
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
42
- if (y = 0, t) op = [op[0] & 2, t.value];
43
- switch (op[0]) {
44
- case 0: case 1: t = op; break;
45
- case 4: _.label++; return { value: op[1], done: false };
46
- case 5: _.label++; y = op[1]; op = [0]; continue;
47
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
48
- default:
49
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
50
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
51
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
52
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
53
- if (t[2]) _.ops.pop();
54
- _.trys.pop(); continue;
55
- }
56
- op = body.call(thisArg, _);
57
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
58
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
59
- }
60
- };
61
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
62
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
63
27
  };
64
28
  Object.defineProperty(exports, "__esModule", { value: true });
65
29
  exports.createPackageJSONFileService = createPackageJSONFileService;
66
- var fs = __importStar(require("fs"));
67
- var util_1 = require("./util");
68
- var detect_indent_1 = __importDefault(require("detect-indent"));
69
- var statAsync = (0, util_1.promisify)(fs.stat);
70
- var readFileAsync = (0, util_1.promisify)(fs.readFile);
71
- var writeFileAsync = (0, util_1.promisify)(fs.writeFile);
30
+ const fsp = __importStar(require("node:fs/promises"));
31
+ const detect_indent_1 = __importDefault(require("detect-indent"));
32
+ const fs_utils_1 = require("./fs-utils");
72
33
  function createPackageJSONFileService() {
73
- var _this = this;
74
34
  return {
75
- readPackageFile: function (filePath) { return __awaiter(_this, void 0, void 0, function () {
76
- var contents;
77
- return __generator(this, function (_a) {
78
- switch (_a.label) {
79
- case 0: return [4 /*yield*/, readFileContents(filePath)];
80
- case 1:
81
- contents = _a.sent();
82
- return [2 /*return*/, JSON.parse(contents)];
83
- }
84
- });
85
- }); },
86
- writePackageFile: function (filePath, fileContent) { return __awaiter(_this, void 0, void 0, function () {
87
- var contents, indent, trailingNewline, data;
88
- return __generator(this, function (_a) {
89
- switch (_a.label) {
90
- case 0: return [4 /*yield*/, readFileContents(filePath)];
91
- case 1:
92
- contents = _a.sent();
93
- indent = (0, detect_indent_1.default)(contents).indent;
94
- trailingNewline = contents.length
95
- ? contents[contents.length - 1] === '\n'
96
- : false;
97
- data = JSON.stringify(fileContent, null, indent /* istanbul ignore next */ || ' ');
98
- return [4 /*yield*/, writeFileAsync(filePath, data + (trailingNewline ? '\n' : ''))];
99
- case 2:
100
- _a.sent();
101
- return [2 /*return*/];
102
- }
103
- });
104
- }); },
35
+ readPackageFile: async (filePath) => {
36
+ const contents = await (0, fs_utils_1.readFileContents)(filePath);
37
+ return JSON.parse(contents);
38
+ },
39
+ writePackageFile: async (filePath, fileContent) => {
40
+ const contents = await (0, fs_utils_1.readFileContents)(filePath);
41
+ const { indent } = (0, detect_indent_1.default)(contents);
42
+ const trailingNewline = contents.length ? contents.endsWith('\n') : false;
43
+ const data = JSON.stringify(fileContent, null, indent /* istanbul ignore next */ || ' ');
44
+ await fsp.writeFile(filePath, data + (trailingNewline ? '\n' : ''));
45
+ },
105
46
  };
106
47
  }
107
- function readFileContents(filePath) {
108
- return __awaiter(this, void 0, void 0, function () {
109
- return __generator(this, function (_a) {
110
- switch (_a.label) {
111
- case 0: return [4 /*yield*/, assertFile(filePath)];
112
- case 1:
113
- _a.sent();
114
- return [2 /*return*/, readFileAsync(filePath, 'utf-8').then(function (x) { return x.toString(); })];
115
- }
116
- });
117
- });
118
- }
119
- function assertFile(filePath) {
120
- return __awaiter(this, void 0, void 0, function () {
121
- return __generator(this, function (_a) {
122
- switch (_a.label) {
123
- case 0: return [4 /*yield*/, existsAsync(filePath)];
124
- case 1:
125
- if (!(_a.sent())) {
126
- throw new Error("".concat(filePath, " does not exist."));
127
- }
128
- return [2 /*return*/];
129
- }
130
- });
131
- });
132
- }
133
- function existsAsync(filePath) {
134
- return __awaiter(this, void 0, void 0, function () {
135
- return __generator(this, function (_a) {
136
- return [2 /*return*/, statAsync(filePath)
137
- .then(function () { return true; })
138
- .catch(function (err) {
139
- /* istanbul ignore else */
140
- if (err.code === 'ENOENT') {
141
- return false;
142
- }
143
- /* istanbul ignore next */
144
- throw err;
145
- })];
146
- });
147
- });
148
- }
149
48
  //# sourceMappingURL=package-json-file-service.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"package-json-file-service.js","sourceRoot":"","sources":["../src/package-json-file-service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,oEAoBC;AA5BD,qCAAwB;AACxB,+BAAkC;AAClC,gEAAwC;AAExC,IAAM,SAAS,GAAG,IAAA,gBAAS,EAAC,EAAE,CAAC,IAAI,CAAC,CAAA;AACpC,IAAM,aAAa,GAAG,IAAA,gBAAS,EAAC,EAAE,CAAC,QAAQ,CAAC,CAAA;AAC5C,IAAM,cAAc,GAAG,IAAA,gBAAS,EAAC,EAAE,CAAC,SAAS,CAAC,CAAA;AAE9C,SAAgB,4BAA4B;IAA5C,iBAoBC;IAnBC,OAAO;QACL,eAAe,EAAE,UAAO,QAAQ;;;;4BACb,qBAAM,gBAAgB,CAAC,QAAQ,CAAC,EAAA;;wBAA3C,Q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C,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;QACrE,CAAC;KACF,CAAA;AACH,CAAC"}
@@ -1,4 +1,24 @@
1
- import { IPackageSource } from './types';
1
+ import type { IPackageVersionInfo } from './versioning';
2
+ /**
3
+ * Fetches info about a package.
4
+ */
5
+ export interface IPackageSource {
6
+ /**
7
+ * Fetches package info from an external source.
8
+ *
9
+ * @param packageName
10
+ */
11
+ fetch(this: void, packageName: string): Promise<IPackageInfo | null>;
12
+ }
13
+ /**
14
+ * Interface for the Package Info structure.
15
+ */
16
+ export interface IPackageInfo {
17
+ name: string;
18
+ latestVersion: string;
19
+ deprecated: boolean;
20
+ versions: Array<IPackageVersionInfo>;
21
+ }
2
22
  /**
3
23
  * Creates a package source.
4
24
  */
@@ -1,95 +1,49 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
39
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
40
4
  };
41
5
  Object.defineProperty(exports, "__esModule", { value: true });
42
6
  exports.createPackageSource = createPackageSource;
43
- var npm_registry_fetch_1 = __importDefault(require("npm-registry-fetch"));
44
- var semver_1 = require("semver");
7
+ const npm_registry_fetch_1 = __importDefault(require("npm-registry-fetch"));
8
+ const semver_1 = require("semver");
45
9
  /**
46
10
  * Creates a package source.
47
11
  */
48
12
  function createPackageSource() {
49
- var _this = this;
50
13
  return {
51
14
  /**
52
15
  * Fetches info about a package, or `null` if not found.
53
16
  */
54
- fetch: function (name) { return __awaiter(_this, void 0, void 0, function () {
55
- var response, data, versionIdentifiers, versions;
56
- return __generator(this, function (_a) {
57
- switch (_a.label) {
58
- case 0: return [4 /*yield*/, (0, npm_registry_fetch_1.default)(encodeURIComponent(name)).catch(function (err) {
59
- if (err.statusCode === 404) {
60
- return null;
61
- }
62
- /* istanbul ignore next */
63
- throw err;
64
- })];
65
- case 1:
66
- response = _a.sent();
67
- return [4 /*yield*/, (response === null || response === void 0 ? void 0 : response.json())];
68
- case 2:
69
- data = _a.sent();
70
- if (!data) {
71
- return [2 /*return*/, null];
72
- }
73
- versionIdentifiers = Object.keys(data.versions)
74
- .sort(semver_1.compare)
75
- .reverse();
76
- versions = versionIdentifiers.map(function (v) {
77
- var item = data.versions[v];
78
- return {
79
- version: item.version,
80
- containsInternalTypings: !!item.types || !!item.typings,
81
- };
82
- });
83
- return [2 /*return*/, {
84
- name: data.name,
85
- deprecated: Boolean(data.versions[versionIdentifiers[0]].deprecated),
86
- latestVersion: data['dist-tags'].latest,
87
- // Sort by version, highest version first.
88
- versions: versions,
89
- }];
17
+ fetch: async (name) => {
18
+ const response = await (0, npm_registry_fetch_1.default)(encodeURI(name)).catch((err) => {
19
+ if (err.statusCode === 404) {
20
+ return null;
90
21
  }
22
+ /* istanbul ignore next */
23
+ throw err;
24
+ });
25
+ const data = await response?.json();
26
+ if (!data?.versions) {
27
+ return null;
28
+ }
29
+ const versionIdentifiers = Object.keys(data.versions)
30
+ .sort(semver_1.compare)
31
+ .reverse();
32
+ const versions = versionIdentifiers.map((v) => {
33
+ const item = data.versions[v];
34
+ return {
35
+ version: item.version,
36
+ containsInternalTypings: !!item.types || !!item.typings,
37
+ };
91
38
  });
92
- }); },
39
+ return {
40
+ name: data.name,
41
+ deprecated: Boolean(data.versions[versionIdentifiers[0]].deprecated),
42
+ latestVersion: data['dist-tags'].latest,
43
+ // Sort by version, highest version first.
44
+ versions: versions,
45
+ };
46
+ },
93
47
  };
94
48
  }
95
49
  //# sourceMappingURL=package-source.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"package-source.js","sourceRoot":"","sources":["../src/package-source.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,kDA2CC;AAjDD,0EAAsC;AACt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AC,IAAI;gBACf,UAAU,EAAE,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;gBACpE,aAAa,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM;gBACvC,0CAA0C;gBAC1C,QAAQ,EAAE,QAAQ;aACnB,CAAA;QACH,CAAC;KACF,CAAA;AACH,CAAC"}
@@ -1,9 +1,13 @@
1
- import { ITypeSyncer, IPackageJSONService, IPackageSource, IConfigService } from './types';
2
- import { IGlobber } from './globber';
1
+ import type { IConfigService } from './config-service';
2
+ import type { IGlobber } from './globber';
3
+ import type { IPackageJSONService } from './package-json-file-service';
4
+ import type { IPackageSource } from './package-source';
5
+ import { type ITypeSyncer } from './types';
6
+ import type { IWorkspaceResolverService } from './workspace-resolver';
3
7
  /**
4
8
  * Creates a type syncer.
5
9
  *
6
10
  * @param packageJSONservice
7
11
  * @param typeDefinitionSource
8
12
  */
9
- export declare function createTypeSyncer(packageJSONService: IPackageJSONService, packageSource: IPackageSource, configService: IConfigService, globber: IGlobber): ITypeSyncer;
13
+ export declare function createTypeSyncer(packageJSONService: IPackageJSONService, workspaceResolverService: IWorkspaceResolverService, packageSource: IPackageSource, configService: IConfigService, globber: IGlobber): ITypeSyncer;