@simplysm/sd-cli 12.15.39 → 12.15.41

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 (58) hide show
  1. package/dist/entry/SdCliCordova.d.ts +33 -1
  2. package/dist/entry/SdCliCordova.js +84 -88
  3. package/dist/entry/SdCliElectron.d.ts +5 -1
  4. package/dist/entry/SdCliElectron.js +21 -21
  5. package/dist/entry/SdCliLocalUpdate.d.ts +1 -1
  6. package/dist/entry/SdCliLocalUpdate.js +3 -3
  7. package/dist/entry/SdCliProject.d.ts +4 -1
  8. package/dist/entry/SdCliProject.js +11 -11
  9. package/dist/pkg-builders/SdProjectBuildRunner.d.ts +6 -1
  10. package/dist/pkg-builders/SdProjectBuildRunner.js +27 -27
  11. package/dist/pkg-builders/client/SdClientBuildRunner.d.ts +2 -1
  12. package/dist/pkg-builders/client/SdClientBuildRunner.js +8 -10
  13. package/dist/pkg-builders/client/SdNgBundler.d.ts +22 -1
  14. package/dist/pkg-builders/client/SdNgBundler.js +70 -80
  15. package/dist/pkg-builders/client/SdNgBundlerContext.d.ts +3 -1
  16. package/dist/pkg-builders/client/SdNgBundlerContext.js +9 -10
  17. package/dist/pkg-builders/lib/SdCliIndexFileGenerator.d.ts +2 -1
  18. package/dist/pkg-builders/lib/SdCliIndexFileGenerator.js +5 -5
  19. package/dist/pkg-builders/lib/SdJsLibBuildRunner.d.ts +1 -1
  20. package/dist/pkg-builders/lib/SdJsLibBuildRunner.js +2 -2
  21. package/dist/pkg-builders/lib/SdTsLibBuildRunner.d.ts +1 -1
  22. package/dist/pkg-builders/lib/SdTsLibBuildRunner.js +2 -3
  23. package/dist/pkg-builders/lib/SdTsLibBuilder.d.ts +2 -1
  24. package/dist/pkg-builders/lib/SdTsLibBuilder.js +7 -8
  25. package/dist/pkg-builders/server/SdServerBuildRunner.d.ts +3 -1
  26. package/dist/pkg-builders/server/SdServerBuildRunner.js +6 -7
  27. package/dist/pkg-builders/server/SdServerBundler.d.ts +6 -1
  28. package/dist/pkg-builders/server/SdServerBundler.js +21 -23
  29. package/dist/ts-compiler/ScopePathSet.d.ts +1 -1
  30. package/dist/ts-compiler/ScopePathSet.js +3 -4
  31. package/dist/ts-compiler/SdDepCache.d.ts +45 -1
  32. package/dist/ts-compiler/SdDepCache.js +71 -69
  33. package/dist/ts-compiler/SdStyleBundler.d.ts +5 -1
  34. package/dist/ts-compiler/SdStyleBundler.js +25 -26
  35. package/dist/ts-compiler/SdTsCompiler.d.ts +20 -1
  36. package/dist/ts-compiler/SdTsCompiler.js +122 -129
  37. package/dist/utils/SdCliPerformanceTimer.d.ts +2 -1
  38. package/dist/utils/SdCliPerformanceTimer.js +9 -9
  39. package/package.json +8 -8
  40. package/src/entry/SdCliCordova.ts +89 -89
  41. package/src/entry/SdCliElectron.ts +21 -21
  42. package/src/entry/SdCliLocalUpdate.ts +3 -3
  43. package/src/entry/SdCliProject.ts +11 -11
  44. package/src/pkg-builders/SdProjectBuildRunner.ts +27 -27
  45. package/src/pkg-builders/client/SdClientBuildRunner.ts +10 -10
  46. package/src/pkg-builders/client/SdNgBundler.ts +78 -78
  47. package/src/pkg-builders/client/SdNgBundlerContext.ts +10 -10
  48. package/src/pkg-builders/lib/SdCliIndexFileGenerator.ts +5 -5
  49. package/src/pkg-builders/lib/SdJsLibBuildRunner.ts +2 -2
  50. package/src/pkg-builders/lib/SdTsLibBuildRunner.ts +3 -3
  51. package/src/pkg-builders/lib/SdTsLibBuilder.ts +8 -8
  52. package/src/pkg-builders/server/SdServerBuildRunner.ts +7 -7
  53. package/src/pkg-builders/server/SdServerBundler.ts +23 -23
  54. package/src/ts-compiler/ScopePathSet.ts +4 -4
  55. package/src/ts-compiler/SdDepCache.ts +47 -47
  56. package/src/ts-compiler/SdStyleBundler.ts +26 -26
  57. package/src/ts-compiler/SdTsCompiler.ts +130 -130
  58. package/src/utils/SdCliPerformanceTimer.ts +9 -9
@@ -15,9 +15,9 @@ interface InitialFileRecord {
15
15
  }
16
16
 
17
17
  export class SdNgBundlerContext {
18
- #logger = SdLogger.get(["simplysm", "sd-cli", "SdNgBundlerContext"]);
18
+ private readonly _logger = SdLogger.get(["simplysm", "sd-cli", "SdNgBundlerContext"]);
19
19
 
20
- #context?: esbuild.BuildContext;
20
+ private _context?: esbuild.BuildContext;
21
21
 
22
22
  constructor(
23
23
  private readonly _pkgPath: string,
@@ -28,14 +28,14 @@ export class SdNgBundlerContext {
28
28
  async bundleAsync() {
29
29
  let esbuildResult: esbuild.BuildResult;
30
30
 
31
- this.#debug(`Building...`);
31
+ this._debug(`Building...`);
32
32
  if (this._watch) {
33
- if (this.#context == null) {
34
- this.#context = await esbuild.context(this._esbuildOptions);
33
+ if (this._context == null) {
34
+ this._context = await esbuild.context(this._esbuildOptions);
35
35
  }
36
36
 
37
37
  try {
38
- esbuildResult = await this.#context.rebuild();
38
+ esbuildResult = await this._context.rebuild();
39
39
  } catch (err) {
40
40
  if ("warnings" in err || "errors" in err) {
41
41
  esbuildResult = err;
@@ -54,9 +54,9 @@ export class SdNgBundlerContext {
54
54
  }
55
55
  }
56
56
  }
57
- this.#debug(`Build completed`);
57
+ this._debug(`Build completed`);
58
58
 
59
- this.#debug(`Converting results...`);
59
+ this._debug(`Converting results...`);
60
60
  const results = SdCliConvertMessageUtils.convertToBuildMessagesFromEsbuild(
61
61
  esbuildResult,
62
62
  this._pkgPath,
@@ -127,8 +127,8 @@ export class SdNgBundlerContext {
127
127
  };
128
128
  }
129
129
 
130
- #debug(...msg: any[]): void {
131
- this.#logger.debug(
130
+ private _debug(...msg: any[]): void {
131
+ this._logger.debug(
132
132
  `[${path.basename(this._pkgPath)}] (${Object.keys(
133
133
  this._esbuildOptions.entryPoints as Record<string, any>,
134
134
  ).join(", ")})`,
@@ -11,7 +11,7 @@ export class SdCliIndexFileGenerator {
11
11
  : undefined;
12
12
 
13
13
  const watcher = await SdFsWatcher.watchAsync([path.resolve(pkgPath, "src")], {
14
- ignored: await this.#getExcludesAsync(pkgPath, excludes),
14
+ ignored: await this._getExcludesAsync(pkgPath, excludes),
15
15
  });
16
16
  watcher.onChange({ delay: 50 }, async (changeInfos) => {
17
17
  if (changeInfos.some((item) => ["add", "addDir", "unlink", "unlinkDir"].includes(item.event)))
@@ -34,7 +34,7 @@ export class SdCliIndexFileGenerator {
34
34
  }
35
35
 
36
36
  // 내부 파일들 import
37
- const filePaths = await this.#getFilePathsAsync(pkgPath, excludes);
37
+ const filePaths = await this._getFilePathsAsync(pkgPath, excludes);
38
38
  for (const filePath of filePaths.orderBy()) {
39
39
  const requirePath = PathUtils.posix(path.relative(path.dirname(indexFilePath), filePath))
40
40
  .replace(/\.tsx?$/, "")
@@ -59,7 +59,7 @@ export class SdCliIndexFileGenerator {
59
59
  }
60
60
  }
61
61
 
62
- async #getFilePathsAsync(pkgPath: string, excludes?: string[]) {
62
+ private async _getFilePathsAsync(pkgPath: string, excludes?: string[]) {
63
63
  /*const indexFilePath = path.resolve(pkgPath, "src/index.ts");
64
64
 
65
65
  const tsconfig = await FsUtils.readJsonAsync(path.resolve(pkgPath, "tsconfig.json"));
@@ -68,11 +68,11 @@ export class SdCliIndexFileGenerator {
68
68
 
69
69
  return await FsUtils.globAsync(path.resolve(pkgPath, "src/**/*{.ts,.tsx}"), {
70
70
  nodir: true,
71
- ignore: await this.#getExcludesAsync(pkgPath, excludes),
71
+ ignore: await this._getExcludesAsync(pkgPath, excludes),
72
72
  });
73
73
  }
74
74
 
75
- async #getExcludesAsync(pkgPath: string, excludes?: string[]) {
75
+ private async _getExcludesAsync(pkgPath: string, excludes?: string[]) {
76
76
  const indexFilePath = path.resolve(pkgPath, "src/index.ts");
77
77
 
78
78
  const tsconfig = await FsUtils.readJsonAsync(path.resolve(pkgPath, "tsconfig.json"));
@@ -29,7 +29,7 @@ export class SdJsLibBuildRunner extends SdBuildRunnerBase<"library"> {
29
29
 
30
30
  this._debug("LINT...");
31
31
 
32
- const lintResults = await this.#lintAsync(filePathSet);
32
+ const lintResults = await this._lintAsync(filePathSet);
33
33
  const messages = SdCliConvertMessageUtils.convertToBuildMessagesFromEslint(lintResults);
34
34
 
35
35
  this._debug(`LINT 완료`);
@@ -43,7 +43,7 @@ export class SdJsLibBuildRunner extends SdBuildRunnerBase<"library"> {
43
43
  };
44
44
  }
45
45
 
46
- async #lintAsync(fileSet: Set<string>) {
46
+ private async _lintAsync(fileSet: Set<string>) {
47
47
  const lintFilePaths = Array.from(fileSet)
48
48
  .filter((item) => PathUtils.isChildPath(item, path.resolve(this._opt.pkgPath, "src")))
49
49
  .filter((item) => item.endsWith(".js"))
@@ -8,7 +8,7 @@ import { SdCliDbContextFileGenerator } from "./SdCliDbContextFileGenerator";
8
8
  export class SdTsLibBuildRunner extends SdBuildRunnerBase<"library"> {
9
9
  protected override _logger = SdLogger.get(["simplysm", "sd-cli", "SdTsLibBuildRunner"]);
10
10
 
11
- #builder?: SdTsLibBuilder;
11
+ private _builder?: SdTsLibBuilder;
12
12
 
13
13
  protected override async _runAsync(modifiedFileSet?: Set<TNormPath>): Promise<ISdBuildResult> {
14
14
  // 최초한번
@@ -35,11 +35,11 @@ export class SdTsLibBuildRunner extends SdBuildRunnerBase<"library"> {
35
35
  }
36
36
 
37
37
  this._debug(`BUILD 준비...`);
38
- this.#builder = new SdTsLibBuilder(this._opt);
38
+ this._builder = new SdTsLibBuilder(this._opt);
39
39
  }
40
40
 
41
41
  this._debug(`BUILD...`);
42
- const buildResult = await this.#builder!.buildAsync(modifiedFileSet);
42
+ const buildResult = await this._builder!.buildAsync(modifiedFileSet);
43
43
 
44
44
  this._debug(`빌드 완료`);
45
45
  return buildResult;
@@ -6,15 +6,15 @@ import { ISdBuildResult } from "../../types/build/ISdBuildResult";
6
6
  import { ISdTsCompilerOptions } from "../../types/build/ISdTsCompilerOptions";
7
7
 
8
8
  export class SdTsLibBuilder {
9
- #tsCompiler: SdTsCompiler;
10
- #outputHashCache = new Map<TNormPath, string>();
9
+ private readonly _tsCompiler: SdTsCompiler;
10
+ private readonly _outputHashCache = new Map<TNormPath, string>();
11
11
 
12
12
  constructor(private readonly _opt: ISdTsCompilerOptions) {
13
- this.#tsCompiler = new SdTsCompiler(_opt, false);
13
+ this._tsCompiler = new SdTsCompiler(_opt, false);
14
14
  }
15
15
 
16
16
  async buildAsync(modifiedFileSet?: Set<TNormPath>): Promise<ISdBuildResult> {
17
- const tsCompileResult = await this.#tsCompiler.compileAsync(modifiedFileSet ?? new Set());
17
+ const tsCompileResult = await this._tsCompiler.compileAsync(modifiedFileSet ?? new Set());
18
18
 
19
19
  const emitFileSet = new Set<TNormPath>();
20
20
  for (const emitFile of tsCompileResult.emitFileSet) {
@@ -23,11 +23,11 @@ export class SdTsLibBuilder {
23
23
  for (const emitFileInfo of emitFileInfos) {
24
24
  if (emitFileInfo.outAbsPath != null) {
25
25
  const emitFilePath = PathUtils.norm(emitFileInfo.outAbsPath);
26
- const prevHash = this.#outputHashCache.get(emitFilePath);
26
+ const prevHash = this._outputHashCache.get(emitFilePath);
27
27
  const currHash = HashUtils.get(Buffer.from(emitFileInfo.text));
28
28
  if (prevHash !== currHash) {
29
29
  FsUtils.writeFile(emitFilePath, emitFileInfo.text);
30
- this.#outputHashCache.set(emitFilePath, currHash);
30
+ this._outputHashCache.set(emitFilePath, currHash);
31
31
  emitFileSet.add(emitFilePath);
32
32
  }
33
33
  }
@@ -44,11 +44,11 @@ export class SdTsLibBuilder {
44
44
  path.relative(this._opt.pkgPath, outputFile.path),
45
45
  );
46
46
  if (PathUtils.isChildPath(distPath, path.resolve(this._opt.pkgPath, "dist"))) {
47
- const prevHash = this.#outputHashCache.get(distPath);
47
+ const prevHash = this._outputHashCache.get(distPath);
48
48
  const currHash = HashUtils.get(Buffer.from(outputFile.text));
49
49
  if (prevHash !== currHash) {
50
50
  FsUtils.writeFile(distPath, outputFile.text);
51
- this.#outputHashCache.set(distPath, currHash);
51
+ this._outputHashCache.set(distPath, currHash);
52
52
  emitFileSet.add(distPath);
53
53
  }
54
54
  }
@@ -9,15 +9,15 @@ import { INpmConfig } from "../../types/common-config/INpmConfig";
9
9
  export class SdServerBuildRunner extends SdBuildRunnerBase<"server"> {
10
10
  protected override _logger = SdLogger.get(["simplysm", "sd-cli", "SdServerBuildRunner"]);
11
11
 
12
- #serverBundler?: SdServerBundler;
12
+ private _serverBundler?: SdServerBundler;
13
13
 
14
14
  protected override async _runAsync(modifiedFileSet?: Set<TNormPath>): Promise<ISdBuildResult> {
15
15
  // 최초
16
16
  if (!modifiedFileSet) {
17
- const externalModules = this.#getExternalModules();
17
+ const externalModules = this._getExternalModules();
18
18
 
19
19
  if (!this._opt.watch?.dev) {
20
- this.#generateProductionFiles(
20
+ this._generateProductionFiles(
21
21
  externalModules.filter((item) => item.exists).map((item) => item.name),
22
22
  );
23
23
  }
@@ -29,19 +29,19 @@ export class SdServerBuildRunner extends SdBuildRunnerBase<"server"> {
29
29
  }
30
30
 
31
31
  this._debug(`BUILD 준비...`);
32
- this.#serverBundler = new SdServerBundler(this._opt, {
32
+ this._serverBundler = new SdServerBundler(this._opt, {
33
33
  external: externalModules.map((item) => item.name),
34
34
  });
35
35
  }
36
36
 
37
37
  this._debug(`BUILD...`);
38
- const bundleResult = await this.#serverBundler!.bundleAsync(modifiedFileSet);
38
+ const bundleResult = await this._serverBundler!.bundleAsync(modifiedFileSet);
39
39
 
40
40
  this._debug(`빌드 완료`);
41
41
  return bundleResult;
42
42
  }
43
43
 
44
- #generateProductionFiles(externals: string[]) {
44
+ private _generateProductionFiles(externals: string[]) {
45
45
  const npmConf = FsUtils.readJson(path.resolve(this._opt.pkgPath, "package.json")) as INpmConfig;
46
46
 
47
47
  this._debug("GEN package.json...");
@@ -185,7 +185,7 @@ Options = UnsafeLegacyRenegotiation`.trim(),
185
185
  }
186
186
  }
187
187
 
188
- #getExternalModules(): {
188
+ private _getExternalModules(): {
189
189
  name: string;
190
190
  exists: boolean;
191
191
  }[] {
@@ -15,22 +15,22 @@ import { ISdTsCompilerOptions } from "../../types/build/ISdTsCompilerOptions";
15
15
  import { SdWorkerPathPlugin } from "../commons/SdWorkerPathPlugin";
16
16
 
17
17
  export class SdServerBundler {
18
- #logger = SdLogger.get(["simplysm", "sd-cli", "SdServerBundler"]);
18
+ private readonly _logger = SdLogger.get(["simplysm", "sd-cli", "SdServerBundler"]);
19
19
 
20
- #context?: esbuild.BuildContext;
20
+ private _context?: esbuild.BuildContext;
21
21
 
22
- #modifiedFileSet = new Set<TNormPath>();
23
- #resultCache: ISdCliServerPluginResultCache = {};
22
+ private readonly _modifiedFileSet = new Set<TNormPath>();
23
+ private readonly _resultCache: ISdCliServerPluginResultCache = {};
24
24
 
25
- #outputHashCache = new Map<TNormPath, string>();
25
+ private readonly _outputHashCache = new Map<TNormPath, string>();
26
26
 
27
- #esbuildOptions: esbuild.BuildOptions;
27
+ private readonly _esbuildOptions: esbuild.BuildOptions;
28
28
 
29
29
  constructor(
30
30
  private readonly _opt: ISdTsCompilerOptions,
31
31
  private readonly _conf: { external: string[] },
32
32
  ) {
33
- this.#esbuildOptions = {
33
+ this._esbuildOptions = {
34
34
  entryPoints: [
35
35
  path.resolve(this._opt.pkgPath, "src/main.ts"),
36
36
  // ...FsUtils.glob(path.resolve(this._opt.pkgPath, "src/workers/*.ts")),
@@ -93,26 +93,26 @@ const __filename = __fileURLToPath__(import.meta.url);
93
93
  const __dirname = __path__.dirname(__filename);`.trim(),
94
94
  },
95
95
  plugins: [
96
- createSdServerPlugin(this._opt, this.#modifiedFileSet, this.#resultCache),
96
+ createSdServerPlugin(this._opt, this._modifiedFileSet, this._resultCache),
97
97
  SdWorkerPathPlugin(path.resolve(this._opt.pkgPath, "dist")),
98
98
  ],
99
99
  };
100
100
  }
101
101
 
102
102
  async bundleAsync(modifiedFileSet?: Set<TNormPath>): Promise<ISdBuildResult> {
103
- this.#modifiedFileSet.clear();
103
+ this._modifiedFileSet.clear();
104
104
  if (modifiedFileSet) {
105
- this.#modifiedFileSet.adds(...modifiedFileSet);
105
+ this._modifiedFileSet.adds(...modifiedFileSet);
106
106
  }
107
107
 
108
108
  let esbuildResult: esbuild.BuildResult;
109
109
  if (this._opt.watch) {
110
- if (this.#context == null) {
111
- this.#context = await esbuild.context(this.#esbuildOptions);
110
+ if (this._context == null) {
111
+ this._context = await esbuild.context(this._esbuildOptions);
112
112
  }
113
113
 
114
114
  try {
115
- esbuildResult = await this.#context.rebuild();
115
+ esbuildResult = await this._context.rebuild();
116
116
  } catch (err) {
117
117
  if ("warnings" in err || "errors" in err) {
118
118
  esbuildResult = err;
@@ -122,7 +122,7 @@ const __dirname = __path__.dirname(__filename);`.trim(),
122
122
  }
123
123
  } else {
124
124
  try {
125
- esbuildResult = await esbuild.build(this.#esbuildOptions);
125
+ esbuildResult = await esbuild.build(this._esbuildOptions);
126
126
  } catch (err) {
127
127
  if ("warnings" in err || "errors" in err) {
128
128
  esbuildResult = err;
@@ -139,8 +139,8 @@ const __dirname = __path__.dirname(__filename);`.trim(),
139
139
  this._opt.pkgPath,
140
140
  ),
141
141
 
142
- watchFileSet: this.#resultCache.watchFileSet!,
143
- affectedFileSet: this.#resultCache.affectedFileSet!,
142
+ watchFileSet: this._resultCache.watchFileSet!,
143
+ affectedFileSet: this._resultCache.affectedFileSet!,
144
144
  emitFileSet: new Set<TNormPath>(),
145
145
  };
146
146
  } else {
@@ -154,11 +154,11 @@ const __dirname = __path__.dirname(__filename);`.trim(),
154
154
 
155
155
  for (const outputFile of outputFiles) {
156
156
  const distFilePath = PathUtils.norm(this._opt.pkgPath, outputFile.path);
157
- const prevHash = this.#outputHashCache.get(distFilePath);
157
+ const prevHash = this._outputHashCache.get(distFilePath);
158
158
  const currHash = HashUtils.get(Buffer.from(outputFile.contents));
159
159
  if (prevHash !== currHash) {
160
160
  FsUtils.writeFile(distFilePath, outputFile.contents);
161
- this.#outputHashCache.set(distFilePath, currHash);
161
+ this._outputHashCache.set(distFilePath, currHash);
162
162
  emitFileSet.add(distFilePath);
163
163
  }
164
164
  }
@@ -173,14 +173,14 @@ const __dirname = __path__.dirname(__filename);`.trim(),
173
173
  );
174
174
 
175
175
  for (const assetFile of assetFiles) {
176
- const prevHash = this.#outputHashCache.get(PathUtils.norm(assetFile.source));
176
+ const prevHash = this._outputHashCache.get(PathUtils.norm(assetFile.source));
177
177
  const currHash = HashUtils.get(FsUtils.readFileBuffer(assetFile.source));
178
178
  if (prevHash !== currHash) {
179
179
  FsUtils.copy(
180
180
  assetFile.source,
181
181
  path.resolve(this._opt.pkgPath, "dist", assetFile.destination),
182
182
  );
183
- this.#outputHashCache.set(PathUtils.norm(assetFile.source), currHash);
183
+ this._outputHashCache.set(PathUtils.norm(assetFile.source), currHash);
184
184
  emitFileSet.add(PathUtils.norm(this._opt.pkgPath, "dist", assetFile.destination));
185
185
  }
186
186
  }
@@ -188,7 +188,7 @@ const __dirname = __path__.dirname(__filename);`.trim(),
188
188
  esbuildResult = err;
189
189
  for (const e of err.errors) {
190
190
  if (e.detail != null) {
191
- this.#logger.error(e.detail);
191
+ this._logger.error(e.detail);
192
192
  }
193
193
  }
194
194
  }
@@ -199,8 +199,8 @@ const __dirname = __path__.dirname(__filename);`.trim(),
199
199
  this._opt.pkgPath,
200
200
  ),
201
201
 
202
- watchFileSet: this.#resultCache.watchFileSet!,
203
- affectedFileSet: this.#resultCache.affectedFileSet!,
202
+ watchFileSet: this._resultCache.watchFileSet!,
203
+ affectedFileSet: this._resultCache.affectedFileSet!,
204
204
  emitFileSet: emitFileSet,
205
205
  };
206
206
  }
@@ -1,17 +1,17 @@
1
1
  import { PathUtils, TNormPath } from "@simplysm/sd-core-node";
2
2
 
3
3
  export class ScopePathSet {
4
- #data: Set<TNormPath>;
4
+ private readonly _data: Set<TNormPath>;
5
5
 
6
6
  constructor(arrOrSet?: TNormPath[] | Set<TNormPath>) {
7
- this.#data = arrOrSet instanceof Set ? arrOrSet : new Set(arrOrSet);
7
+ this._data = arrOrSet instanceof Set ? arrOrSet : new Set(arrOrSet);
8
8
  }
9
9
 
10
10
  inScope(filePath: string) {
11
- return Array.from(this.#data).some((scope) => PathUtils.isChildPath(filePath, scope));
11
+ return Array.from(this._data).some((scope) => PathUtils.isChildPath(filePath, scope));
12
12
  }
13
13
 
14
14
  toArray() {
15
- return Array.from(this.#data);
15
+ return Array.from(this._data);
16
16
  }
17
17
  }
@@ -4,14 +4,14 @@ export class SdDepCache {
4
4
  /**
5
5
  * 각 파일이 export한 심볼 집합 (예: export const A → "A")
6
6
  */
7
- #exportCache = new Map<TNormPath, Set<string>>();
7
+ private readonly _exportCache = new Map<TNormPath, Set<string>>();
8
8
 
9
9
  /**
10
10
  * import한 타겟과 그 심볼 정보
11
11
  * - 값이 0이면 전체 import(import * 또는 리소스 import)
12
12
  * - 값이 Set이면 선택적 심볼 import (예: import { A } ...)
13
13
  */
14
- #importCache = new Map<TNormPath, Map<TNormPath, Set<string> | 0>>();
14
+ private readonly _importCache = new Map<TNormPath, Map<TNormPath, Set<string> | 0>>();
15
15
 
16
16
  /**
17
17
  * re-export한 타겟과 그 심볼 정보
@@ -19,7 +19,7 @@ export class SdDepCache {
19
19
  * - export { A as B } from ...
20
20
  * - 값이 0이면 전체 reexport(export * from ...)
21
21
  */
22
- #reexportCache = new Map<
22
+ private readonly _reexportCache = new Map<
23
23
  TNormPath,
24
24
  Map<
25
25
  TNormPath,
@@ -36,20 +36,20 @@ export class SdDepCache {
36
36
  * - 특정 파일이 어떤 파일에게 의존(참조)되는지
37
37
  * - symbol 기반 추적
38
38
  */
39
- #revDepCache = new Map<TNormPath, Map<TNormPath, Set<string> | 0>>();
39
+ private readonly _revDepCache = new Map<TNormPath, Map<TNormPath, Set<string> | 0>>();
40
40
 
41
41
  /**
42
42
  * 분석이 완료된 파일 경로
43
43
  */
44
- #collectedCache = new Set<TNormPath>();
44
+ private readonly _collectedCache = new Set<TNormPath>();
45
45
 
46
- #exportSymbolCache = new Map<TNormPath, Set<string>>();
46
+ private readonly _exportSymbolCache = new Map<TNormPath, Set<string>>();
47
47
 
48
48
  /**
49
49
  * .d.ts 또는 .js가 입력되었을 때 쌍으로 존재하는 파일 경로를 반환
50
50
  * 예: "/a.d.ts" → ["/a.d.ts", "/a.js"]
51
51
  */
52
- #getRelatedNPaths(nPath: TNormPath): TNormPath[] {
52
+ private _getRelatedNPaths(nPath: TNormPath): TNormPath[] {
53
53
  if (nPath.endsWith(".d.ts")) {
54
54
  return [nPath, nPath.replace(/\.d\.ts$/, ".js") as TNormPath];
55
55
  }
@@ -63,13 +63,13 @@ export class SdDepCache {
63
63
  * 분석이 완료된 파일로 표시
64
64
  */
65
65
  addCollected(fileNPath: TNormPath) {
66
- for (const path of this.#getRelatedNPaths(fileNPath)) {
67
- this.#collectedCache.add(path);
66
+ for (const path of this._getRelatedNPaths(fileNPath)) {
67
+ this._collectedCache.add(path);
68
68
  }
69
69
  }
70
70
 
71
71
  hasCollected(fileNPath: TNormPath) {
72
- return this.#collectedCache.has(fileNPath);
72
+ return this._collectedCache.has(fileNPath);
73
73
  }
74
74
 
75
75
  /**
@@ -77,8 +77,8 @@ export class SdDepCache {
77
77
  * 예: export const A → "A"
78
78
  */
79
79
  addExport(fileNPath: TNormPath, exportSymbol: string) {
80
- for (const path of this.#getRelatedNPaths(fileNPath)) {
81
- const exportSymbolSet = this.#exportCache.getOrCreate(path, new Set());
80
+ for (const path of this._getRelatedNPaths(fileNPath)) {
81
+ const exportSymbolSet = this._exportCache.getOrCreate(path, new Set());
82
82
  exportSymbolSet.add(exportSymbol);
83
83
  }
84
84
  }
@@ -89,19 +89,19 @@ export class SdDepCache {
89
89
  * - import { A } from ... → symbol = "A"
90
90
  */
91
91
  addImport(fileNPath: TNormPath, targetNPath: TNormPath, targetSymbol: string | 0) {
92
- for (const filePath of this.#getRelatedNPaths(fileNPath)) {
93
- const importTargetMap = this.#importCache.getOrCreate(filePath, new Map());
92
+ for (const filePath of this._getRelatedNPaths(fileNPath)) {
93
+ const importTargetMap = this._importCache.getOrCreate(filePath, new Map());
94
94
 
95
- for (const targetPath of this.#getRelatedNPaths(targetNPath)) {
95
+ for (const targetPath of this._getRelatedNPaths(targetNPath)) {
96
96
  if (typeof targetSymbol === "string") {
97
97
  const importTargetSymbolSet = importTargetMap.getOrCreate(targetPath, new Set());
98
98
  if (!(importTargetSymbolSet instanceof Set)) continue;
99
99
 
100
100
  importTargetSymbolSet.add(targetSymbol);
101
- this.#addRevDep(targetPath, filePath, targetSymbol);
101
+ this._addRevDep(targetPath, filePath, targetSymbol);
102
102
  } else {
103
103
  importTargetMap.set(targetPath, targetSymbol);
104
- this.#addRevDep(targetPath, filePath, targetSymbol);
104
+ this._addRevDep(targetPath, filePath, targetSymbol);
105
105
  }
106
106
  }
107
107
  }
@@ -121,13 +121,13 @@ export class SdDepCache {
121
121
  }
122
122
  | 0,
123
123
  ) {
124
- for (const filePath of this.#getRelatedNPaths(fileNPath)) {
125
- const reexportTargetMap = this.#reexportCache.getOrCreate(filePath, new Map());
124
+ for (const filePath of this._getRelatedNPaths(fileNPath)) {
125
+ const reexportTargetMap = this._reexportCache.getOrCreate(filePath, new Map());
126
126
 
127
- for (const targetPath of this.#getRelatedNPaths(targetNPath)) {
127
+ for (const targetPath of this._getRelatedNPaths(targetNPath)) {
128
128
  if (targetSymbolInfo === 0) {
129
129
  reexportTargetMap.set(targetPath, 0);
130
- this.#addRevDep(targetPath, filePath, 0);
130
+ this._addRevDep(targetPath, filePath, 0);
131
131
  } else {
132
132
  const reexportTargetSymbolInfos = reexportTargetMap.getOrCreate(targetPath, []);
133
133
  if (reexportTargetSymbolInfos === 0) return;
@@ -140,7 +140,7 @@ export class SdDepCache {
140
140
  )
141
141
  ) {
142
142
  reexportTargetSymbolInfos.push(targetSymbolInfo);
143
- this.#addRevDep(targetPath, filePath, targetSymbolInfo.importSymbol);
143
+ this._addRevDep(targetPath, filePath, targetSymbolInfo.importSymbol);
144
144
  }
145
145
  }
146
146
  }
@@ -150,11 +150,11 @@ export class SdDepCache {
150
150
  /**
151
151
  * 역의존 관계 등록 (revDep)
152
152
  */
153
- #addRevDep(targetNPath: TNormPath, fileNPath: TNormPath, exportSymbol: string | 0) {
154
- for (const targetPath of this.#getRelatedNPaths(targetNPath)) {
155
- const revDepInfoMap = this.#revDepCache.getOrCreate(targetPath, new Map());
153
+ private _addRevDep(targetNPath: TNormPath, fileNPath: TNormPath, exportSymbol: string | 0) {
154
+ for (const targetPath of this._getRelatedNPaths(targetNPath)) {
155
+ const revDepInfoMap = this._revDepCache.getOrCreate(targetPath, new Map());
156
156
 
157
- for (const filePath of this.#getRelatedNPaths(fileNPath)) {
157
+ for (const filePath of this._getRelatedNPaths(fileNPath)) {
158
158
  if (typeof exportSymbol === "string") {
159
159
  const exportSymbolSet = revDepInfoMap.getOrCreate(filePath, new Set());
160
160
  if (!(exportSymbolSet instanceof Set)) continue;
@@ -183,9 +183,9 @@ export class SdDepCache {
183
183
  }
184
184
  };
185
185
 
186
- for (const relatedNPath of this.#getRelatedNPaths(modifiedNPath)) {
186
+ for (const relatedNPath of this._getRelatedNPaths(modifiedNPath)) {
187
187
  result.add(relatedNPath);
188
- const exportSymbols = this.#getExportSymbols(relatedNPath);
188
+ const exportSymbols = this._getExportSymbols(relatedNPath);
189
189
  if (exportSymbols.size === 0) {
190
190
  enqueue(relatedNPath, undefined);
191
191
  } else {
@@ -197,7 +197,7 @@ export class SdDepCache {
197
197
 
198
198
  while (queue.length > 0) {
199
199
  const curr = queue.shift()!;
200
- const revDepInfoMap = this.#revDepCache.get(curr.fileNPath);
200
+ const revDepInfoMap = this._revDepCache.get(curr.fileNPath);
201
201
  if (!revDepInfoMap) continue;
202
202
 
203
203
  for (const [revDepFileNPath, revDepInfo] of revDepInfoMap) {
@@ -205,7 +205,7 @@ export class SdDepCache {
205
205
  const hasImportSymbol = revDepInfo === 0 || revDepInfo.has(curr.exportSymbol);
206
206
  if (hasImportSymbol) {
207
207
  result.add(revDepFileNPath);
208
- const exportSymbol = this.#convertImportSymbolToExportSymbol(
208
+ const exportSymbol = this._convertImportSymbolToExportSymbol(
209
209
  revDepFileNPath,
210
210
  curr.fileNPath,
211
211
  curr.exportSymbol,
@@ -231,11 +231,11 @@ export class SdDepCache {
231
231
  // const revDepCacheChanged = new Set<TNormPath>();
232
232
 
233
233
  for (const fileNPath of fileNPathSet) {
234
- this.#exportCache.delete(fileNPath);
235
- this.#importCache.delete(fileNPath);
236
- this.#reexportCache.delete(fileNPath);
237
- this.#exportSymbolCache.delete(fileNPath);
238
- this.#collectedCache.delete(fileNPath);
234
+ this._exportCache.delete(fileNPath);
235
+ this._importCache.delete(fileNPath);
236
+ this._reexportCache.delete(fileNPath);
237
+ this._exportSymbolCache.delete(fileNPath);
238
+ this._collectedCache.delete(fileNPath);
239
239
 
240
240
  // if (this.#revDepCache.has(fileNPath)) {
241
241
  // this.#revDepCache.delete(fileNPath); // 자신이 key인 경우
@@ -243,7 +243,7 @@ export class SdDepCache {
243
243
  // }
244
244
  }
245
245
 
246
- for (const [targetNPath, infoMap] of this.#revDepCache) {
246
+ for (const [targetNPath, infoMap] of this._revDepCache) {
247
247
  for (const fileNPath of fileNPathSet) {
248
248
  if (infoMap.has(fileNPath)) {
249
249
  infoMap.delete(fileNPath);
@@ -251,7 +251,7 @@ export class SdDepCache {
251
251
  }
252
252
  }
253
253
  if (infoMap.size === 0) {
254
- this.#revDepCache.delete(targetNPath);
254
+ this._revDepCache.delete(targetNPath);
255
255
  }
256
256
  }
257
257
  }
@@ -259,12 +259,12 @@ export class SdDepCache {
259
259
  /**
260
260
  * reexport된 경우 importSymbol → exportSymbol로 변환
261
261
  */
262
- #convertImportSymbolToExportSymbol(
262
+ private _convertImportSymbolToExportSymbol(
263
263
  fileNPath: TNormPath,
264
264
  targetNPath: TNormPath,
265
265
  importSymbol: string,
266
266
  ) {
267
- const symbolInfos = this.#reexportCache.get(fileNPath)?.get(targetNPath);
267
+ const symbolInfos = this._reexportCache.get(fileNPath)?.get(targetNPath);
268
268
  if (symbolInfos != null && symbolInfos !== 0 && symbolInfos.length > 0) {
269
269
  const symbolInfo = symbolInfos.single((item) => item.importSymbol === importSymbol);
270
270
  if (symbolInfo) return symbolInfo.exportSymbol;
@@ -275,22 +275,22 @@ export class SdDepCache {
275
275
  /**
276
276
  * 해당 파일에서 export된 모든 심볼 (직접 + 재export 포함)
277
277
  */
278
- #getExportSymbols(fileNPath: TNormPath): Set<string> {
279
- if (this.#exportSymbolCache.has(fileNPath)) {
280
- return this.#exportSymbolCache.get(fileNPath)!;
278
+ private _getExportSymbols(fileNPath: TNormPath): Set<string> {
279
+ if (this._exportSymbolCache.has(fileNPath)) {
280
+ return this._exportSymbolCache.get(fileNPath)!;
281
281
  }
282
282
 
283
283
  const result = new Set<string>();
284
284
 
285
- for (const path of this.#getRelatedNPaths(fileNPath)) {
286
- const set = this.#exportCache.get(path);
285
+ for (const path of this._getRelatedNPaths(fileNPath)) {
286
+ const set = this._exportCache.get(path);
287
287
  if (set) result.adds(...set);
288
288
 
289
- const map = this.#reexportCache.get(path);
289
+ const map = this._reexportCache.get(path);
290
290
  if (map) {
291
291
  for (const [key, val] of map) {
292
292
  if (val === 0) {
293
- result.adds(...this.#getExportSymbols(key));
293
+ result.adds(...this._getExportSymbols(key));
294
294
  } else {
295
295
  result.adds(...val.map((item) => item.exportSymbol));
296
296
  }
@@ -298,7 +298,7 @@ export class SdDepCache {
298
298
  }
299
299
  }
300
300
 
301
- this.#exportSymbolCache.set(fileNPath, result);
301
+ this._exportSymbolCache.set(fileNPath, result);
302
302
  return result;
303
303
  }
304
304
  }