@akanjs/devkit 1.0.7-canary.2 → 1.0.7-canary.4

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.
@@ -341,7 +341,7 @@ class Executor {
341
341
  }, dict = {}, options = {}) {
342
342
  if (targetPath.endsWith(".js") || targetPath.endsWith(".jsx")) {
343
343
  const getContent = await import(templatePath);
344
- const result = getContent.default(scanInfo ?? null, dict, options);
344
+ const result = await getContent.default(scanInfo ?? null, dict, options);
345
345
  if (result === null)
346
346
  return null;
347
347
  const filename = typeof result === "object" ? result.filename : import_path.default.basename(targetPath).replace(".js", ".ts");
@@ -790,8 +790,9 @@ class SysExecutor extends Executor {
790
790
  const scanInfo = this.type === "app" ? await import_scanInfo.AppInfo.fromExecutor(this) : await import_scanInfo.LibInfo.fromExecutor(this);
791
791
  const sysContantFiles = await this.getConstantFiles();
792
792
  const sysScalarConstantFiles = await this.getScalarConstantFiles();
793
+ const libDeps = scanInfo.getLibs();
793
794
  const libConstantFiles = await Promise.all(
794
- scanInfo.getLibs().map(async (lib) => [
795
+ libDeps.map(async (lib) => [
795
796
  ...await LibExecutor.from(this, lib).getConstantFiles(),
796
797
  ...await LibExecutor.from(this, lib).getScalarConstantFiles()
797
798
  ])
@@ -246,6 +246,7 @@ class AppInfo extends ScanInfo {
246
246
  type = "app";
247
247
  exec;
248
248
  akanConfig;
249
+ libDeps;
249
250
  static appInfos = /* @__PURE__ */ new Map();
250
251
  static async fromExecutor(exec, options = {}) {
251
252
  const existingAppInfo = this.appInfos.get(exec.name);
@@ -259,24 +260,41 @@ class AppInfo extends ScanInfo {
259
260
  LibInfo.libInfos.set(libName, await LibInfo.fromExecutor(libExecutor));
260
261
  })
261
262
  );
262
- const appInfo = new AppInfo(exec, scanResult);
263
+ const libDeps = await this.#getAllLibDeps(exec, scanResult.libDeps);
264
+ const appInfo = new AppInfo(exec, scanResult, libDeps);
263
265
  this.appInfos.set(exec.name, appInfo);
264
266
  return appInfo;
265
267
  }
266
- constructor(exec, scanResult) {
268
+ constructor(exec, scanResult, libDeps) {
267
269
  super(scanResult);
268
270
  this.exec = exec;
269
271
  this.akanConfig = scanResult.akanConfig;
272
+ this.libDeps = libDeps;
270
273
  }
271
274
  getScanResult() {
272
275
  return this.scanResult;
273
276
  }
277
+ static async #getAllLibDeps(exec, libDeps, libSet = /* @__PURE__ */ new Set()) {
278
+ await Promise.all(
279
+ libDeps.map(async (libName) => {
280
+ if (libSet.has(libName))
281
+ return;
282
+ libSet.add(libName);
283
+ const libExecutor = import_executors.LibExecutor.from(exec, libName);
284
+ const libInfo = await LibInfo.fromExecutor(libExecutor);
285
+ const libScanResult = libInfo.getScanResult();
286
+ if (libScanResult.libDeps.length > 0)
287
+ await this.#getAllLibDeps(exec, libScanResult.libDeps, libSet);
288
+ })
289
+ );
290
+ return [...libSet];
291
+ }
274
292
  #sortedLibs = null;
275
293
  #getSortedLibs() {
276
294
  if (this.#sortedLibs)
277
295
  return this.#sortedLibs;
278
296
  const libIndices = LibInfo.getSortedLibIndices();
279
- this.#sortedLibs = this.getScanResult().libDeps.sort((libNameA, libNameB) => {
297
+ this.#sortedLibs = this.libDeps.sort((libNameA, libNameB) => {
280
298
  const indexA = libIndices.get(libNameA);
281
299
  const indexB = libIndices.get(libNameB);
282
300
  if (indexA === void 0 || indexB === void 0)
@@ -288,12 +306,6 @@ class AppInfo extends ScanInfo {
288
306
  getLibs() {
289
307
  return this.#getSortedLibs();
290
308
  }
291
- getLibInfo(libName) {
292
- const libSet = new Set(this.#getSortedLibs());
293
- if (!libSet.has(libName))
294
- throw new Error(`LibInfo is invalid: ${libName}`);
295
- return LibInfo.libInfos.get(libName);
296
- }
297
309
  getLibInfos() {
298
310
  return new Map(
299
311
  this.#getSortedLibs().map((libName) => {
@@ -306,7 +306,7 @@ class Executor {
306
306
  }, dict = {}, options = {}) {
307
307
  if (targetPath.endsWith(".js") || targetPath.endsWith(".jsx")) {
308
308
  const getContent = await import(templatePath);
309
- const result = getContent.default(scanInfo ?? null, dict, options);
309
+ const result = await getContent.default(scanInfo ?? null, dict, options);
310
310
  if (result === null)
311
311
  return null;
312
312
  const filename = typeof result === "object" ? result.filename : path.basename(targetPath).replace(".js", ".ts");
@@ -755,8 +755,9 @@ class SysExecutor extends Executor {
755
755
  const scanInfo = this.type === "app" ? await AppInfo.fromExecutor(this) : await LibInfo.fromExecutor(this);
756
756
  const sysContantFiles = await this.getConstantFiles();
757
757
  const sysScalarConstantFiles = await this.getScalarConstantFiles();
758
+ const libDeps = scanInfo.getLibs();
758
759
  const libConstantFiles = await Promise.all(
759
- scanInfo.getLibs().map(async (lib) => [
760
+ libDeps.map(async (lib) => [
760
761
  ...await LibExecutor.from(this, lib).getConstantFiles(),
761
762
  ...await LibExecutor.from(this, lib).getScalarConstantFiles()
762
763
  ])
@@ -211,6 +211,7 @@ class AppInfo extends ScanInfo {
211
211
  type = "app";
212
212
  exec;
213
213
  akanConfig;
214
+ libDeps;
214
215
  static appInfos = /* @__PURE__ */ new Map();
215
216
  static async fromExecutor(exec, options = {}) {
216
217
  const existingAppInfo = this.appInfos.get(exec.name);
@@ -224,24 +225,41 @@ class AppInfo extends ScanInfo {
224
225
  LibInfo.libInfos.set(libName, await LibInfo.fromExecutor(libExecutor));
225
226
  })
226
227
  );
227
- const appInfo = new AppInfo(exec, scanResult);
228
+ const libDeps = await this.#getAllLibDeps(exec, scanResult.libDeps);
229
+ const appInfo = new AppInfo(exec, scanResult, libDeps);
228
230
  this.appInfos.set(exec.name, appInfo);
229
231
  return appInfo;
230
232
  }
231
- constructor(exec, scanResult) {
233
+ constructor(exec, scanResult, libDeps) {
232
234
  super(scanResult);
233
235
  this.exec = exec;
234
236
  this.akanConfig = scanResult.akanConfig;
237
+ this.libDeps = libDeps;
235
238
  }
236
239
  getScanResult() {
237
240
  return this.scanResult;
238
241
  }
242
+ static async #getAllLibDeps(exec, libDeps, libSet = /* @__PURE__ */ new Set()) {
243
+ await Promise.all(
244
+ libDeps.map(async (libName) => {
245
+ if (libSet.has(libName))
246
+ return;
247
+ libSet.add(libName);
248
+ const libExecutor = LibExecutor.from(exec, libName);
249
+ const libInfo = await LibInfo.fromExecutor(libExecutor);
250
+ const libScanResult = libInfo.getScanResult();
251
+ if (libScanResult.libDeps.length > 0)
252
+ await this.#getAllLibDeps(exec, libScanResult.libDeps, libSet);
253
+ })
254
+ );
255
+ return [...libSet];
256
+ }
239
257
  #sortedLibs = null;
240
258
  #getSortedLibs() {
241
259
  if (this.#sortedLibs)
242
260
  return this.#sortedLibs;
243
261
  const libIndices = LibInfo.getSortedLibIndices();
244
- this.#sortedLibs = this.getScanResult().libDeps.sort((libNameA, libNameB) => {
262
+ this.#sortedLibs = this.libDeps.sort((libNameA, libNameB) => {
245
263
  const indexA = libIndices.get(libNameA);
246
264
  const indexB = libIndices.get(libNameB);
247
265
  if (indexA === void 0 || indexB === void 0)
@@ -253,12 +271,6 @@ class AppInfo extends ScanInfo {
253
271
  getLibs() {
254
272
  return this.#getSortedLibs();
255
273
  }
256
- getLibInfo(libName) {
257
- const libSet = new Set(this.#getSortedLibs());
258
- if (!libSet.has(libName))
259
- throw new Error(`LibInfo is invalid: ${libName}`);
260
- return LibInfo.libInfos.get(libName);
261
- }
262
274
  getLibInfos() {
263
275
  return new Map(
264
276
  this.#getSortedLibs().map((libName) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/devkit",
3
- "version": "1.0.7-canary.2",
3
+ "version": "1.0.7-canary.4",
4
4
  "sourceType": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
package/src/scanInfo.d.ts CHANGED
@@ -26,14 +26,14 @@ export declare class AppInfo extends ScanInfo {
26
26
  readonly type = "app";
27
27
  readonly exec: AppExecutor;
28
28
  readonly akanConfig: AppConfigResult;
29
+ readonly libDeps: string[];
29
30
  static appInfos: Map<string, AppInfo>;
30
31
  static fromExecutor(exec: AppExecutor, options?: {
31
32
  refresh?: boolean;
32
33
  }): Promise<AppInfo>;
33
- constructor(exec: AppExecutor, scanResult: AppScanResult);
34
+ constructor(exec: AppExecutor, scanResult: AppScanResult, libDeps: string[]);
34
35
  getScanResult(): AppScanResult;
35
36
  getLibs(): string[];
36
- getLibInfo(libName: string): LibInfo | undefined;
37
37
  getLibInfos(): Map<string, LibInfo>;
38
38
  }
39
39
  export declare class LibInfo extends ScanInfo {