@intelligentgraphics/ig.gfx.packager 3.0.28 → 3.1.0-alpha.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 (34) hide show
  1. package/build/bin.mjs +1 -1
  2. package/build/{cli-RWjcRDQ7.mjs → cli-CuiqZ39_.mjs} +16 -22
  3. package/build/{cli-RWjcRDQ7.mjs.map → cli-CuiqZ39_.mjs.map} +1 -1
  4. package/build/{dependencies-_6rsdwHk.mjs → dependencies-BiYItaVS.mjs} +2 -2
  5. package/build/{dependencies-_6rsdwHk.mjs.map → dependencies-BiYItaVS.mjs.map} +1 -1
  6. package/build/{generateIndex-Dy12utjI.mjs → generateIndex-hg6jRXQv.mjs} +96 -83
  7. package/build/generateIndex-hg6jRXQv.mjs.map +1 -0
  8. package/build/{generateParameterType-DKwRLh1m.mjs → generateParameterType-CDjqLM4J.mjs} +2 -3
  9. package/build/{generateParameterType-DKwRLh1m.mjs.map → generateParameterType-CDjqLM4J.mjs.map} +1 -1
  10. package/build/{index-B9e-vtmM.mjs → index-B2kXo6K7.mjs} +298 -84
  11. package/build/index-B2kXo6K7.mjs.map +1 -0
  12. package/build/{index-CLoWLYI6.mjs → index-BoGrZubW.mjs} +14 -14
  13. package/build/index-BoGrZubW.mjs.map +1 -0
  14. package/build/{postinstall-DlYP6BrQ.mjs → postinstall-CbMUz2zy.mjs} +3 -4
  15. package/build/{postinstall-DlYP6BrQ.mjs.map → postinstall-CbMUz2zy.mjs.map} +1 -1
  16. package/build/{publishNpm-CEhZI6-O.mjs → publishNpm-CrnuTwss.mjs} +11 -10
  17. package/build/publishNpm-CrnuTwss.mjs.map +1 -0
  18. package/build/rollup-UR3DADp8.mjs +198 -0
  19. package/build/rollup-UR3DADp8.mjs.map +1 -0
  20. package/build/scripts-Bfojy_uD.mjs +48 -0
  21. package/build/scripts-Bfojy_uD.mjs.map +1 -0
  22. package/build/versionFile-DSqOw-XB.mjs +208 -0
  23. package/build/versionFile-DSqOw-XB.mjs.map +1 -0
  24. package/lib/lib.mjs +421 -331
  25. package/package.json +13 -8
  26. package/readme.md +87 -10
  27. package/build/generateIndex-Dy12utjI.mjs.map +0 -1
  28. package/build/index-B9e-vtmM.mjs.map +0 -1
  29. package/build/index-CLoWLYI6.mjs.map +0 -1
  30. package/build/publishNpm-CEhZI6-O.mjs.map +0 -1
  31. package/build/scripts-EvIjiH6G.mjs +0 -10
  32. package/build/scripts-EvIjiH6G.mjs.map +0 -1
  33. package/build/versionFile-C7xf8PjZ.mjs +0 -380
  34. package/build/versionFile-C7xf8PjZ.mjs.map +0 -1
package/lib/lib.mjs CHANGED
@@ -1,6 +1,8 @@
1
1
  import * as path from 'path';
2
2
  import * as fs$1 from 'fs/promises';
3
3
  import * as terser from 'terser';
4
+ import { EOL } from 'os';
5
+ import ts from 'typescript';
4
6
  import * as fs from 'fs';
5
7
  import { createWriteStream, createReadStream } from 'fs';
6
8
  import resolve from 'resolve';
@@ -8,18 +10,17 @@ import 'write-pkg';
8
10
  import glob from 'glob';
9
11
  import 'write-json-file';
10
12
  import axios, { AxiosError } from 'axios';
11
- import ts from 'typescript';
12
13
  import typedoc from 'typedoc';
13
14
  import EventEmitter from 'events';
14
15
  import { SourceMapGenerator, SourceMapConsumer } from 'source-map-js';
15
16
  import Ajv from 'ajv';
16
- import { EOL } from 'os';
17
17
  import { pipeline } from 'stream/promises';
18
18
  import { exec } from 'child_process';
19
19
  import { promisify } from 'util';
20
20
  import simpleGit from 'simple-git';
21
21
  import JSZip from 'jszip';
22
22
  import { buffer } from 'node:stream/consumers';
23
+ import { resolveNamespaces, resolveNamespaceFullName } from '@intelligentgraphics/declarationbundler';
23
24
 
24
25
  const stripUtf8Bom = (text)=>{
25
26
  // Catches EFBBBF (UTF-8 BOM) because the buffer-to-string
@@ -401,6 +402,35 @@ const getExistingPackages = async (session)=>{
401
402
  return data;
402
403
  };
403
404
 
405
+ function resolveScriptPackageEntryModule(location, manifest) {
406
+ let candidates = [
407
+ "index.ts"
408
+ ];
409
+ if (manifest.Type === "Context") {
410
+ candidates.push("Context.ts");
411
+ }
412
+ for (const candidate of candidates){
413
+ const candidatePath = path.join(location.scriptsDir, candidate);
414
+ if (fs.existsSync(candidatePath)) {
415
+ return candidatePath;
416
+ }
417
+ }
418
+ }
419
+ function readScriptPackageTSConfig(location) {
420
+ const { config } = ts.readConfigFile(path.join(location.scriptsDir, "tsconfig.json"), (path)=>{
421
+ try {
422
+ return fs.readFileSync(path, "utf8");
423
+ } catch {
424
+ return undefined;
425
+ }
426
+ });
427
+ const parsedTsConfig = ts.parseJsonConfigFileContent(config, ts.sys, location.scriptsDir);
428
+ return parsedTsConfig;
429
+ }
430
+ function isScriptPackageModules(options) {
431
+ return options.module === ts.ModuleKind.ES2015;
432
+ }
433
+
404
434
  const tryReadTsConfig = (location)=>{
405
435
  const { config } = ts.readConfigFile(path.join(location.scriptsDir, "tsconfig.json"), (path)=>{
406
436
  try {
@@ -413,19 +443,6 @@ const tryReadTsConfig = (location)=>{
413
443
  };
414
444
  const createTSCBuildParticipant = (location, outputDir)=>(env)=>{
415
445
  const files = getPackageTypescriptFiles(location);
416
- if (files.length === 0) {
417
- env.onBuildStart();
418
- env.onBuildEnd({
419
- type: "success",
420
- artefacts: {
421
- js: "",
422
- definitions: ""
423
- }
424
- });
425
- return {
426
- destroy: ()=>{}
427
- };
428
- }
429
446
  try {
430
447
  env.onBuildStart();
431
448
  env.log("Compiling typescript files");
@@ -463,7 +480,7 @@ const createTSCBuildParticipant = (location, outputDir)=>(env)=>{
463
480
  type: "success",
464
481
  artefacts: {
465
482
  js: js.replace(`//# sourceMappingURL=out.js.map`, ""),
466
- definitions,
483
+ declarations: definitions,
467
484
  sourceMap
468
485
  }
469
486
  });
@@ -556,7 +573,7 @@ const createTSCWatchBuildParticipant = (location, outputDir)=>{
556
573
  type: "success",
557
574
  artefacts: {
558
575
  js: emitState.js.replace(`//# sourceMappingURL=out.js.map`, ""),
559
- definitions: emitState.definitions,
576
+ declarations: emitState.definitions,
560
577
  sourceMap: emitState.sourceMap
561
578
  }
562
579
  });
@@ -570,17 +587,6 @@ const createTSCWatchBuildParticipant = (location, outputDir)=>{
570
587
  getNewLine: ()=>ts.sys.newLine
571
588
  };
572
589
  const watchProgram = ts.createWatchProgram(host);
573
- const files = getPackageTypescriptFiles(location);
574
- if (files.length === 0) {
575
- onBuildStart();
576
- onBuildEnd({
577
- type: "success",
578
- artefacts: {
579
- js: "",
580
- definitions: ""
581
- }
582
- });
583
- }
584
590
  return {
585
591
  destroy: ()=>{
586
592
  watchProgram.close();
@@ -666,12 +672,7 @@ const toposort = (packages)=>{
666
672
 
667
673
  class BuildManager extends EventEmitter {
668
674
  constructor(manifest, writer, reporter){
669
- super();
670
- this.manifest = manifest;
671
- this.writer = writer;
672
- this.reporter = reporter;
673
- this.participants = new Map();
674
- this.states = new Map();
675
+ super(), this.manifest = manifest, this.writer = writer, this.reporter = reporter, this.participants = new Map(), this.states = new Map();
675
676
  }
676
677
  addParticipant(name, participant) {
677
678
  this.participants.set(name, participant);
@@ -744,14 +745,16 @@ class BuildManager extends EventEmitter {
744
745
  line: lines + mapping.generatedLine,
745
746
  column: mapping.generatedColumn
746
747
  },
747
- original: {
748
+ original: mapping.originalLine !== null && mapping.originalColumn !== null ? {
748
749
  line: mapping.originalLine,
749
750
  column: mapping.originalColumn
750
- },
751
+ } : undefined,
751
752
  source: mapping.source,
752
753
  name: mapping.name
753
754
  });
754
- sources.add(mapping.source);
755
+ if (mapping.source !== null) {
756
+ sources.add(mapping.source);
757
+ }
755
758
  });
756
759
  for (const source of sources){
757
760
  const content = sourceMap.sourceContentFor(source);
@@ -762,13 +765,13 @@ class BuildManager extends EventEmitter {
762
765
  }
763
766
  completeResult.js += result.artefacts.js;
764
767
  }
765
- if (result.artefacts.definitions) {
766
- if (completeResult.definitions) {
767
- completeResult.definitions += "\n";
768
+ if (result.artefacts.declarations) {
769
+ if (completeResult.declarations) {
770
+ completeResult.declarations += "\n";
768
771
  } else {
769
- completeResult.definitions = "";
772
+ completeResult.declarations = "";
770
773
  }
771
- completeResult.definitions += result.artefacts.definitions;
774
+ completeResult.declarations += result.artefacts.declarations;
772
775
  }
773
776
  }
774
777
  completeResult.sourceMap = sourceMapGenerator.toString();
@@ -1228,7 +1231,183 @@ const getAnimationJsonValidation = async ()=>{
1228
1231
  return validateAnimationJson;
1229
1232
  };
1230
1233
 
1231
- const buildFolders = async (options)=>{
1234
+ // Stolen from ig.tools.core
1235
+ class PackageVersion {
1236
+ static #_ = // https://regex101.com/r/90PEY9/1
1237
+ this.fullTextMatcher = /(\d+)(\.(\d+)(\.(\d+)(\.(\d+))?(-([^\.]+)\.(\d+))?)?)?/;
1238
+ static #_2 = this.lineMatcher = /^(\d+)(\.(\d+)(\.(\d+)(\.(\d+))?(-([^\.]+)\.(\d+))?)?)?$/;
1239
+ static extractFromText(input, description) {
1240
+ if (input === undefined) {
1241
+ throw new Error(`Can not parse version from undefined`);
1242
+ }
1243
+ const match = input.match(PackageVersion.fullTextMatcher);
1244
+ if (!match) {
1245
+ throw new Error(`Could not extract a version from input: ${input}`);
1246
+ }
1247
+ return PackageVersion.fromMatch(match, description);
1248
+ }
1249
+ static extractFromLine(input, description) {
1250
+ if (input === undefined) {
1251
+ throw new Error(`Can not parse version from undefined`);
1252
+ }
1253
+ const match = input.match(PackageVersion.lineMatcher);
1254
+ if (!match) {
1255
+ throw new Error(`Could not parse version from input: ${input}`);
1256
+ }
1257
+ return PackageVersion.fromMatch(match, description);
1258
+ }
1259
+ static equals(a, b, checkPrerelease = false) {
1260
+ if (a.major !== b.major || a.minor !== b.minor || a.patch !== b.patch) {
1261
+ return false;
1262
+ }
1263
+ if (checkPrerelease === false) {
1264
+ return true;
1265
+ }
1266
+ if (a.preRelease === b.preRelease) {
1267
+ return true;
1268
+ }
1269
+ if (a.preRelease === undefined || b.preRelease === undefined) {
1270
+ return false;
1271
+ }
1272
+ return a.preRelease.type === b.preRelease.type && a.preRelease.version === b.preRelease.version;
1273
+ }
1274
+ static fromMatch([, major, , minor = "0", , patch = "0", , build, , preReleaseType, preReleaseNumber], description) {
1275
+ let preRelease = undefined;
1276
+ let buildNumber = 100;
1277
+ if (preReleaseType && preReleaseNumber) {
1278
+ preRelease = {
1279
+ type: preReleaseType,
1280
+ version: parseInt(preReleaseNumber)
1281
+ };
1282
+ }
1283
+ if (build) {
1284
+ buildNumber = Number(build);
1285
+ } else if (description) {
1286
+ const descriptionMatch = description.match(/(\d+)\)$/);
1287
+ if (descriptionMatch) {
1288
+ buildNumber = parseInt(descriptionMatch[1]);
1289
+ }
1290
+ }
1291
+ return new PackageVersion(parseInt(major), parseInt(minor), parseInt(patch), preRelease, buildNumber);
1292
+ }
1293
+ static sort(a, b, ascending = true) {
1294
+ const createSortResult = (a, b)=>ascending ? a - b : b - a;
1295
+ if (a.major !== b.major) {
1296
+ return createSortResult(a.major, b.major);
1297
+ }
1298
+ if (a.minor !== b.minor) {
1299
+ return createSortResult(a.minor, b.minor);
1300
+ }
1301
+ if (a.patch !== b.patch) {
1302
+ return createSortResult(a.patch, b.patch);
1303
+ }
1304
+ return createSortResult(a.preRelease ? a.preRelease.version : 0, b.preRelease ? b.preRelease.version : 0);
1305
+ }
1306
+ static toNumber(version) {
1307
+ return ((version.major * 1000 + version.minor) * 1000 + version.patch) * 1000 + version.buildNumber;
1308
+ }
1309
+ constructor(major, minor, patch, preRelease, buildNumber){
1310
+ this.major = major;
1311
+ this.minor = minor;
1312
+ this.patch = patch;
1313
+ this.preRelease = preRelease;
1314
+ this.buildNumber = buildNumber;
1315
+ }
1316
+ isPreRelease() {
1317
+ return this.preRelease !== undefined;
1318
+ }
1319
+ clone() {
1320
+ return new PackageVersion(this.major, this.minor, this.patch, this.preRelease ? {
1321
+ ...this.preRelease
1322
+ } : undefined, this.buildNumber);
1323
+ }
1324
+ incrementMajor() {
1325
+ this.preRelease = undefined;
1326
+ this.patch = 0;
1327
+ this.minor = 0;
1328
+ this.major++;
1329
+ }
1330
+ incrementMinor() {
1331
+ this.preRelease = undefined;
1332
+ this.patch = 0;
1333
+ this.minor++;
1334
+ }
1335
+ incrementPatch() {
1336
+ this.preRelease = undefined;
1337
+ this.patch++;
1338
+ }
1339
+ createPreRelease(type) {
1340
+ if (!this.preRelease) {
1341
+ this.buildNumber = 1;
1342
+ } else {
1343
+ this.buildNumber++;
1344
+ }
1345
+ if (this.preRelease && type === this.preRelease.type) {
1346
+ this.preRelease.version++;
1347
+ return;
1348
+ }
1349
+ this.preRelease = {
1350
+ version: 0,
1351
+ type
1352
+ };
1353
+ }
1354
+ createRelease() {
1355
+ this.preRelease = undefined;
1356
+ this.buildNumber = 100;
1357
+ }
1358
+ toVersionString({ buildNumber } = {}) {
1359
+ let version = [
1360
+ this.major,
1361
+ this.minor,
1362
+ this.patch
1363
+ ].join(".");
1364
+ if (buildNumber) {
1365
+ version += "." + this.buildNumber;
1366
+ }
1367
+ if (this.preRelease) {
1368
+ version += `-${this.preRelease.type}.${this.preRelease.version}`;
1369
+ }
1370
+ return version;
1371
+ }
1372
+ toDescriptionString(packageName) {
1373
+ const base = [
1374
+ this.major,
1375
+ this.minor,
1376
+ this.patch
1377
+ ].join(".");
1378
+ const parts = [
1379
+ packageName,
1380
+ base
1381
+ ];
1382
+ if (this.preRelease) {
1383
+ parts.push(upperCaseFirst(this.preRelease.type));
1384
+ parts.push(this.preRelease.version);
1385
+ }
1386
+ parts.push(`(${base}.${this.buildNumber})`);
1387
+ return parts.join(" ");
1388
+ }
1389
+ /**
1390
+ * Determines wether the version is lesser than the input version
1391
+ *
1392
+ * @param {PackageVersion} version
1393
+ * @returns
1394
+ */ isLesserThan(version) {
1395
+ return PackageVersion.toNumber(this) < PackageVersion.toNumber(version);
1396
+ }
1397
+ /**
1398
+ * Determines wether the version is greater than the input version
1399
+ *
1400
+ * @param {PackageVersion} version
1401
+ * @returns
1402
+ */ isGreaterThan(version) {
1403
+ return PackageVersion.toNumber(this) > PackageVersion.toNumber(version);
1404
+ }
1405
+ }
1406
+ const upperCaseFirst = (input)=>{
1407
+ return input.slice(0, 1).toUpperCase() + input.slice(1);
1408
+ };
1409
+
1410
+ async function buildFolders(options) {
1232
1411
  if (options.outDir !== undefined && options.clean) {
1233
1412
  await fs$1.rm(options.outDir, {
1234
1413
  recursive: true
@@ -1245,7 +1424,7 @@ const buildFolders = async (options)=>{
1245
1424
  ]));
1246
1425
  const maxNameLength = Array.from(manifests.values(), (manifest)=>manifest.Package.length).reduce((acc, length)=>Math.max(acc, length), 0);
1247
1426
  for (const location of sortedPackages){
1248
- await ensureTsConfig(location);
1427
+ const tsConfig = await ensureTsConfig(location);
1249
1428
  const data = manifests.get(location);
1250
1429
  const reporter = options.preparedReporter ?? createPackageScopedReporter(baseReporter, data.Package, index, folders.length, maxNameLength);
1251
1430
  const outputDirectory = options.outDir || location.scriptsDir;
@@ -1256,7 +1435,18 @@ const buildFolders = async (options)=>{
1256
1435
  if (options.banner) {
1257
1436
  manager.addParticipant("banner", createBannerCommentBuildParticipant(options.banner));
1258
1437
  }
1259
- manager.addParticipant("tsc", createTSCBuildParticipant(location, outputDirectory));
1438
+ const typescriptFiles = getPackageTypescriptFiles(location);
1439
+ if (!typescriptFiles.some((file)=>path.basename(file).toLowerCase() === "version.ts")) {
1440
+ manager.addParticipant("version", createVersionLogBuildParticipant(data));
1441
+ }
1442
+ if (typescriptFiles.length > 0) {
1443
+ if (isScriptPackageModules(tsConfig.options)) {
1444
+ const { createRollupBuildParticipant } = await import('./rollup-BITLKeAN.mjs');
1445
+ manager.addParticipant("rollup", createRollupBuildParticipant(location, data, outputDirectory));
1446
+ } else {
1447
+ manager.addParticipant("tsc", createTSCBuildParticipant(location, outputDirectory));
1448
+ }
1449
+ }
1260
1450
  manager.addParticipant("animation", createAnimationBuildParticipant(location, data));
1261
1451
  await new Promise((resolve, reject)=>{
1262
1452
  manager.addListener("start", ()=>{
@@ -1277,8 +1467,8 @@ const buildFolders = async (options)=>{
1277
1467
  }
1278
1468
  index++;
1279
1469
  }
1280
- };
1281
- const buildFoldersWatch = async (options)=>{
1470
+ }
1471
+ async function buildFoldersWatch(options) {
1282
1472
  if (options.outDir !== undefined && options.clean) {
1283
1473
  await fs$1.rm(options.outDir, {
1284
1474
  recursive: true
@@ -1294,7 +1484,7 @@ const buildFoldersWatch = async (options)=>{
1294
1484
  ]));
1295
1485
  const maxNameLength = Array.from(manifests.values(), (manifest)=>manifest.Package.length).reduce((acc, length)=>Math.max(acc, length), 0);
1296
1486
  for (const location of sortedPackages){
1297
- await ensureTsConfig(location);
1487
+ const tsConfig = await ensureTsConfig(location);
1298
1488
  const baseReporter = options.reporter ?? consoleReporter;
1299
1489
  const data = manifests.get(location);
1300
1490
  const reporter = createPackageScopedReporter(baseReporter, data.Package, index, folders.length, maxNameLength);
@@ -1306,7 +1496,18 @@ const buildFoldersWatch = async (options)=>{
1306
1496
  if (options.banner) {
1307
1497
  manager.addParticipant("banner", createBannerCommentBuildParticipant(options.banner));
1308
1498
  }
1309
- manager.addParticipant("tsc", createTSCWatchBuildParticipant(location, outputDirectory));
1499
+ const typescriptFiles = getPackageTypescriptFiles(location);
1500
+ if (!typescriptFiles.some((file)=>path.basename(file).toLowerCase() === "version.ts")) {
1501
+ manager.addParticipant("version", createVersionLogBuildParticipant(data));
1502
+ }
1503
+ if (typescriptFiles.length > 0) {
1504
+ if (isScriptPackageModules(tsConfig.options)) {
1505
+ const { createRollupWatchBuildParticipant } = await import('./rollup-BITLKeAN.mjs');
1506
+ manager.addParticipant("rollup", createRollupWatchBuildParticipant(location, data, outputDirectory));
1507
+ } else {
1508
+ manager.addParticipant("tsc", createTSCWatchBuildParticipant(location, outputDirectory));
1509
+ }
1510
+ }
1310
1511
  manager.addParticipant("animation", createAnimationWatchBuildParticipant(location, data));
1311
1512
  await new Promise((resolve, reject)=>{
1312
1513
  manager.addListener("start", ()=>{
@@ -1325,8 +1526,8 @@ const buildFoldersWatch = async (options)=>{
1325
1526
  index++;
1326
1527
  }
1327
1528
  await new Promise(()=>{});
1328
- };
1329
- const writeBuildResult = async (buildResult, manifest, location, workspace, outputDirectory, minimize, reporter)=>{
1529
+ }
1530
+ async function writeBuildResult(buildResult, manifest, location, workspace, outputDirectory, minimize, reporter) {
1330
1531
  let js = buildResult.js;
1331
1532
  if (buildResult.sourceMap) {
1332
1533
  js += `\n//# sourceMappingURL=${manifest.Package}.js.map`;
@@ -1334,8 +1535,8 @@ const writeBuildResult = async (buildResult, manifest, location, workspace, outp
1334
1535
  await fs$1.writeFile(path.join(outputDirectory, `${manifest.Package}.js`), js, {
1335
1536
  encoding: "utf8"
1336
1537
  });
1337
- if (buildResult.definitions !== undefined) {
1338
- await fs$1.writeFile(path.join(outputDirectory, `${manifest.Package}.d.ts`), buildResult.definitions, {
1538
+ if (buildResult.declarations !== undefined) {
1539
+ await fs$1.writeFile(path.join(outputDirectory, `${manifest.Package}.d.ts`), buildResult.declarations, {
1339
1540
  encoding: "utf8"
1340
1541
  });
1341
1542
  }
@@ -1363,54 +1564,95 @@ const writeBuildResult = async (buildResult, manifest, location, workspace, outp
1363
1564
  });
1364
1565
  }
1365
1566
  }
1366
- if (location.path.includes("Basics") && buildResult.definitions !== undefined) {
1567
+ if (location.path.includes("Basics") && buildResult.declarations !== undefined) {
1367
1568
  await fs$1.mkdir(path.join(workspace.path, "lib"), {
1368
1569
  recursive: true
1369
1570
  });
1370
1571
  reporter.log("Copying basics definition file to the lib folder");
1371
- await fs$1.writeFile(path.join(workspace.path, "lib", `${manifest.Package}.d.ts`), buildResult.definitions, {
1572
+ await fs$1.writeFile(path.join(workspace.path, "lib", `${manifest.Package}.d.ts`), buildResult.declarations, {
1372
1573
  encoding: "utf8"
1373
1574
  });
1374
1575
  }
1375
- };
1376
- const createBannerCommentBuildParticipant = (options)=>(env)=>{
1576
+ }
1577
+ function createVersionLogBuildParticipant(manifest) {
1578
+ return (env)=>{
1579
+ env.onBuildStart();
1580
+ const parsedVersion = manifest.Version !== undefined ? PackageVersion.extractFromLine(manifest.Version) : undefined;
1581
+ let logText;
1582
+ if (parsedVersion !== undefined) {
1583
+ logText = parsedVersion.toDescriptionString(manifest.Package);
1584
+ } else {
1585
+ logText = manifest.Package;
1586
+ }
1587
+ logText += ".";
1588
+ if (manifest.Copyright !== undefined) {
1589
+ logText += " " + manifest.Copyright;
1590
+ }
1591
+ env.onBuildEnd({
1592
+ type: "success",
1593
+ artefacts: {
1594
+ js: `console.log(${JSON.stringify(logText)})`
1595
+ }
1596
+ });
1597
+ return {
1598
+ destroy: ()=>{}
1599
+ };
1600
+ };
1601
+ }
1602
+ function createBannerCommentBuildParticipant(options) {
1603
+ return (env)=>{
1377
1604
  env.onBuildStart();
1378
1605
  const banner = createBannerComment(options);
1379
1606
  env.onBuildEnd({
1380
1607
  type: "success",
1381
1608
  artefacts: {
1382
1609
  js: banner ?? "",
1383
- definitions: banner ?? ""
1610
+ declarations: banner ?? ""
1384
1611
  }
1385
1612
  });
1386
1613
  return {
1387
1614
  destroy: ()=>{}
1388
1615
  };
1389
1616
  };
1390
- const ensureTsConfig = async (location)=>{
1617
+ }
1618
+ async function ensureTsConfig(location) {
1391
1619
  const tsconfigPath = path.join(location.scriptsDir, "tsconfig.json");
1392
1620
  try {
1393
1621
  const content = JSON.parse(await fs$1.readFile(tsconfigPath, "utf8"));
1394
- applyTsConfigOption(content);
1622
+ applyTsConfigOptions(content);
1395
1623
  await fs$1.writeFile(tsconfigPath, JSON.stringify(content, undefined, "\t"), "utf8");
1624
+ return ts.parseJsonConfigFileContent(content, ts.sys, location.scriptsDir);
1396
1625
  } catch (err) {
1397
1626
  if (!isErrorENOENT(err)) {
1398
1627
  throw err;
1399
1628
  }
1400
1629
  const content = {};
1401
- applyTsConfigOption(content);
1630
+ applyTsConfigOptions(content);
1402
1631
  await fs$1.writeFile(tsconfigPath, JSON.stringify(content, undefined, "\t"), "utf8");
1632
+ return ts.parseJsonConfigFileContent(content, ts.sys, location.scriptsDir);
1403
1633
  }
1404
- };
1405
- const applyTsConfigOption = (data)=>{
1406
- data.compilerOptions = data.compilerOptions ?? {};
1407
- data.compilerOptions.target = "es5";
1408
- data.compilerOptions.lib = [
1409
- "es5",
1410
- "dom"
1411
- ];
1412
- };
1413
- const sortPackagesByBuildOrder = (folders)=>{
1634
+ }
1635
+ function applyTsConfigOptions(data) {
1636
+ var _data_compilerOptions_module, _data_compilerOptions;
1637
+ if ((_data_compilerOptions = data.compilerOptions) == null ? void 0 : (_data_compilerOptions_module = _data_compilerOptions.module) == null ? void 0 : _data_compilerOptions_module.toLowerCase().startsWith("es")) {
1638
+ data.compilerOptions = data.compilerOptions ?? {};
1639
+ data.compilerOptions.target = "esnext";
1640
+ data.compilerOptions.lib = [
1641
+ "esnext",
1642
+ "dom"
1643
+ ];
1644
+ data.compilerOptions.module = "es2015";
1645
+ data.compilerOptions.moduleResolution = "node";
1646
+ } else {
1647
+ data.compilerOptions = data.compilerOptions ?? {};
1648
+ data.compilerOptions.target = "es5";
1649
+ data.compilerOptions.lib = [
1650
+ "es5",
1651
+ "dom"
1652
+ ];
1653
+ }
1654
+ }
1655
+ function sortPackagesByBuildOrder(folders) {
1414
1656
  const packages = Array.from(folders).reduce((acc, location)=>{
1415
1657
  const data = readPackageNpmManifest(location);
1416
1658
  if (data !== undefined) {
@@ -1450,8 +1692,8 @@ const sortPackagesByBuildOrder = (folders)=>{
1450
1692
  }
1451
1693
  }
1452
1694
  return result;
1453
- };
1454
- const createBannerComment = (banner)=>{
1695
+ }
1696
+ function createBannerComment(banner) {
1455
1697
  const bannerParts = [];
1456
1698
  if (banner.text) {
1457
1699
  bannerParts.push(" * " + banner.text);
@@ -1485,7 +1727,7 @@ ${bannerText}
1485
1727
  */`;
1486
1728
  }
1487
1729
  return undefined;
1488
- };
1730
+ }
1489
1731
 
1490
1732
  const getVersionInformationFromGit = async (workspaceLocation, packageLocation)=>{
1491
1733
  try {
@@ -1536,182 +1778,6 @@ const getWorkspaceBannerText = (manifest)=>{
1536
1778
  return bannerText;
1537
1779
  };
1538
1780
 
1539
- // Stolen from ig.tools.core
1540
- class PackageVersion {
1541
- static #_ = // https://regex101.com/r/90PEY9/1
1542
- this.fullTextMatcher = /(\d+)(\.(\d+)(\.(\d+)(\.(\d+))?(-([^\.]+)\.(\d+))?)?)?/;
1543
- static #_2 = this.lineMatcher = /^(\d+)(\.(\d+)(\.(\d+)(\.(\d+))?(-([^\.]+)\.(\d+))?)?)?$/;
1544
- static extractFromText(input, description) {
1545
- if (input === undefined) {
1546
- throw new Error(`Can not parse version from undefined`);
1547
- }
1548
- const match = input.match(PackageVersion.fullTextMatcher);
1549
- if (!match) {
1550
- throw new Error(`Could not extract a version from input: ${input}`);
1551
- }
1552
- return PackageVersion.fromMatch(match, description);
1553
- }
1554
- static extractFromLine(input, description) {
1555
- if (input === undefined) {
1556
- throw new Error(`Can not parse version from undefined`);
1557
- }
1558
- const match = input.match(PackageVersion.lineMatcher);
1559
- if (!match) {
1560
- throw new Error(`Could not parse version from input: ${input}`);
1561
- }
1562
- return PackageVersion.fromMatch(match, description);
1563
- }
1564
- static equals(a, b, checkPrerelease = false) {
1565
- if (a.major !== b.major || a.minor !== b.minor || a.patch !== b.patch) {
1566
- return false;
1567
- }
1568
- if (checkPrerelease === false) {
1569
- return true;
1570
- }
1571
- if (a.preRelease === b.preRelease) {
1572
- return true;
1573
- }
1574
- if (a.preRelease === undefined || b.preRelease === undefined) {
1575
- return false;
1576
- }
1577
- return a.preRelease.type === b.preRelease.type && a.preRelease.version === b.preRelease.version;
1578
- }
1579
- static fromMatch([, major, , minor = "0", , patch = "0", , build, , preReleaseType, preReleaseNumber], description) {
1580
- let preRelease = undefined;
1581
- let buildNumber = 100;
1582
- if (preReleaseType && preReleaseNumber) {
1583
- preRelease = {
1584
- type: preReleaseType,
1585
- version: parseInt(preReleaseNumber)
1586
- };
1587
- }
1588
- if (build) {
1589
- buildNumber = Number(build);
1590
- } else if (description) {
1591
- const descriptionMatch = description.match(/(\d+)\)$/);
1592
- if (descriptionMatch) {
1593
- buildNumber = parseInt(descriptionMatch[1]);
1594
- }
1595
- }
1596
- return new PackageVersion(parseInt(major), parseInt(minor), parseInt(patch), preRelease, buildNumber);
1597
- }
1598
- static sort(a, b, ascending = true) {
1599
- const createSortResult = (a, b)=>ascending ? a - b : b - a;
1600
- if (a.major !== b.major) {
1601
- return createSortResult(a.major, b.major);
1602
- }
1603
- if (a.minor !== b.minor) {
1604
- return createSortResult(a.minor, b.minor);
1605
- }
1606
- if (a.patch !== b.patch) {
1607
- return createSortResult(a.patch, b.patch);
1608
- }
1609
- return createSortResult(a.preRelease ? a.preRelease.version : 0, b.preRelease ? b.preRelease.version : 0);
1610
- }
1611
- static toNumber(version) {
1612
- return ((version.major * 1000 + version.minor) * 1000 + version.patch) * 1000 + version.buildNumber;
1613
- }
1614
- constructor(major, minor, patch, preRelease, buildNumber){
1615
- this.major = major;
1616
- this.minor = minor;
1617
- this.patch = patch;
1618
- this.preRelease = preRelease;
1619
- this.buildNumber = buildNumber;
1620
- }
1621
- isPreRelease() {
1622
- return this.preRelease !== undefined;
1623
- }
1624
- clone() {
1625
- return new PackageVersion(this.major, this.minor, this.patch, this.preRelease ? {
1626
- ...this.preRelease
1627
- } : undefined, this.buildNumber);
1628
- }
1629
- incrementMajor() {
1630
- this.preRelease = undefined;
1631
- this.patch = 0;
1632
- this.minor = 0;
1633
- this.major++;
1634
- }
1635
- incrementMinor() {
1636
- this.preRelease = undefined;
1637
- this.patch = 0;
1638
- this.minor++;
1639
- }
1640
- incrementPatch() {
1641
- this.preRelease = undefined;
1642
- this.patch++;
1643
- }
1644
- createPreRelease(type) {
1645
- if (!this.preRelease) {
1646
- this.buildNumber = 1;
1647
- } else {
1648
- this.buildNumber++;
1649
- }
1650
- if (this.preRelease && type === this.preRelease.type) {
1651
- this.preRelease.version++;
1652
- return;
1653
- }
1654
- this.preRelease = {
1655
- version: 0,
1656
- type
1657
- };
1658
- }
1659
- createRelease() {
1660
- this.preRelease = undefined;
1661
- this.buildNumber = 100;
1662
- }
1663
- toVersionString({ buildNumber } = {}) {
1664
- let version = [
1665
- this.major,
1666
- this.minor,
1667
- this.patch
1668
- ].join(".");
1669
- if (buildNumber) {
1670
- version += "." + this.buildNumber;
1671
- }
1672
- if (this.preRelease) {
1673
- version += `-${this.preRelease.type}.${this.preRelease.version}`;
1674
- }
1675
- return version;
1676
- }
1677
- toDescriptionString(packageName) {
1678
- const base = [
1679
- this.major,
1680
- this.minor,
1681
- this.patch
1682
- ].join(".");
1683
- const parts = [
1684
- packageName,
1685
- base
1686
- ];
1687
- if (this.preRelease) {
1688
- parts.push(upperCaseFirst(this.preRelease.type));
1689
- parts.push(this.preRelease.version);
1690
- }
1691
- parts.push(`(${base}.${this.buildNumber})`);
1692
- return parts.join(" ");
1693
- }
1694
- /**
1695
- * Determines wether the version is lesser than the input version
1696
- *
1697
- * @param {PackageVersion} version
1698
- * @returns
1699
- */ isLesserThan(version) {
1700
- return PackageVersion.toNumber(this) < PackageVersion.toNumber(version);
1701
- }
1702
- /**
1703
- * Determines wether the version is greater than the input version
1704
- *
1705
- * @param {PackageVersion} version
1706
- * @returns
1707
- */ isGreaterThan(version) {
1708
- return PackageVersion.toNumber(this) > PackageVersion.toNumber(version);
1709
- }
1710
- }
1711
- const upperCaseFirst = (input)=>{
1712
- return input.slice(0, 1).toUpperCase() + input.slice(1);
1713
- };
1714
-
1715
1781
  const parseVersionFromString = (input)=>{
1716
1782
  if (input === undefined) {
1717
1783
  throw new Error(`Can not parse version from undefined`);
@@ -1763,10 +1829,11 @@ const parseVersionFromNumericVersion = (version)=>{
1763
1829
  // https://regex101.com/r/LtGAu5/1
1764
1830
  const logRegex = /console\.log\(\s*"([\w\s\.\(\)]+)\ *Copyright[\w\s\(\)\.]+(\d{4}|\d{4} - \d{4})([\w\s\(\)\.]+)?",?\s*\)/i;
1765
1831
  const currentYear = new Date(Date.now()).getFullYear();
1766
- const getVersionFileHandler = (location)=>{
1832
+ function getVersionFileHandler(location) {
1767
1833
  const filePath = path.join(location.scriptsDir, "Version.ts");
1768
- const invalidVersionFile = (versionFile)=>({
1769
- version: undefined,
1834
+ function invalidVersionFile(versionFile, exists) {
1835
+ return {
1836
+ exists,
1770
1837
  write: (name, newVersion)=>{
1771
1838
  const scriptsContent = fs.readdirSync(location.scriptsDir);
1772
1839
  const tsFiles = scriptsContent.filter((file)=>file.endsWith(".ts"));
@@ -1791,10 +1858,12 @@ const getVersionFileHandler = (location)=>{
1791
1858
  }
1792
1859
  }
1793
1860
  }
1794
- });
1795
- const createVersionFileWriter = (copyright = [
1861
+ };
1862
+ }
1863
+ function createVersionFileWriter(copyright = [
1796
1864
  currentYear
1797
- ], copyrightStuff = "")=>(name, newVersion)=>{
1865
+ ], copyrightStuff = "") {
1866
+ return (name, newVersion)=>{
1798
1867
  const descriptionText = newVersion.toDescriptionString(name);
1799
1868
  const copyrightText = createYearString(copyright);
1800
1869
  const result = `console.log("${descriptionText}. Copyright (C) ${copyrightText}${copyrightStuff}");`;
@@ -1802,14 +1871,15 @@ const getVersionFileHandler = (location)=>{
1802
1871
  encoding: "utf-8"
1803
1872
  });
1804
1873
  };
1874
+ }
1805
1875
  let rawVersionFile = readStringFromFileOrUndefined(filePath);
1806
1876
  if (rawVersionFile === undefined) {
1807
- return invalidVersionFile(rawVersionFile);
1877
+ return invalidVersionFile(rawVersionFile, false);
1808
1878
  }
1809
1879
  const versionFile = rawVersionFile.replace(/\n/g, "");
1810
1880
  const match = versionFile.match(logRegex);
1811
1881
  if (!match) {
1812
- return invalidVersionFile(versionFile);
1882
+ return invalidVersionFile(versionFile, true);
1813
1883
  }
1814
1884
  const [_full, _description, copyright, copyrightStuff] = match;
1815
1885
  const copyrightYears = copyright.match(/^(\d+)( ?- ?(\d+))?$/);
@@ -1825,6 +1895,7 @@ const getVersionFileHandler = (location)=>{
1825
1895
  ];
1826
1896
  }
1827
1897
  return {
1898
+ exists: true,
1828
1899
  write: createVersionFileWriter(years, copyrightStuff),
1829
1900
  reset: ()=>{
1830
1901
  fs.writeFileSync(filePath, versionFile, {
@@ -1832,7 +1903,7 @@ const getVersionFileHandler = (location)=>{
1832
1903
  });
1833
1904
  }
1834
1905
  };
1835
- };
1906
+ }
1836
1907
  const createYearString = (years)=>{
1837
1908
  if (years[1] === undefined || years[0] === years[1]) {
1838
1909
  return years[0].toString();
@@ -2110,7 +2181,7 @@ const execAsync = promisify(exec);
2110
2181
  const releaseFolder = async (options)=>{
2111
2182
  const workspace = options.workspace;
2112
2183
  const location = options.directory;
2113
- const { write: writeVersionFile, reset: resetVersionFile } = getVersionFileHandler(location);
2184
+ const versionFile = getVersionFileHandler(location);
2114
2185
  const packageDescription = readPackageCreatorManifest(location);
2115
2186
  const fullPackageName = packageDescription.Package;
2116
2187
  const reporter = options.reporter ?? createPackageScopedReporter(consoleReporter, packageDescription.Package);
@@ -2183,7 +2254,9 @@ const releaseFolder = async (options)=>{
2183
2254
  }
2184
2255
  } else {
2185
2256
  const gitVersionInformation = await getVersionInformationFromGit(workspace, location);
2186
- writeVersionFile(fullPackageName, newVersion);
2257
+ if (versionFile.exists) {
2258
+ versionFile.write(fullPackageName, newVersion);
2259
+ }
2187
2260
  const bannerText = sharedPackageJson !== undefined ? getWorkspaceBannerText(sharedPackageJson) : undefined;
2188
2261
  await buildFolders({
2189
2262
  ...options,
@@ -2270,7 +2343,7 @@ const releaseFolder = async (options)=>{
2270
2343
  }
2271
2344
  }
2272
2345
  } catch (err) {
2273
- resetVersionFile();
2346
+ versionFile.reset();
2274
2347
  throw err;
2275
2348
  }
2276
2349
  if (newVersion.buildNumber >= 100 && !options.pushOnly) {
@@ -2289,63 +2362,90 @@ const releaseFolder = async (options)=>{
2289
2362
  *
2290
2363
  * @param folderPath path to a src folder
2291
2364
  */ function generateIndex({ location, ignore = [], strictOptional = false }) {
2292
- const files = getPackageTypescriptFiles(location);
2293
- const filtered = files.filter((path)=>{
2294
- return !ignore.some((suffix)=>path.endsWith(suffix));
2295
- });
2296
2365
  const arr = [];
2297
2366
  const existingIndex = readPackageCreatorIndex(location) ?? [];
2298
- const program = ts.createProgram(filtered, {
2299
- allowJs: true
2300
- });
2367
+ const manifest = readPackageCreatorManifest(location);
2368
+ const compilerOptions = readScriptPackageTSConfig(location).options;
2369
+ const isModule = compilerOptions.module === ts.ModuleKind.ES2015 || compilerOptions.module === ts.ModuleKind.ESNext;
2370
+ const files = getPackageTypescriptFiles(location).filter((path)=>!ignore.some((suffix)=>path.endsWith(suffix)));
2371
+ let program;
2372
+ let namespaces;
2373
+ if (isModule) {
2374
+ const entryFilePath = resolveScriptPackageEntryModule(location, manifest);
2375
+ if (entryFilePath === undefined) {
2376
+ throw new Error(`Could not resolve entry module`);
2377
+ }
2378
+ const host = ts.createCompilerHost({}, true);
2379
+ program = ts.createProgram([
2380
+ entryFilePath
2381
+ ], {
2382
+ allowJs: true,
2383
+ ...compilerOptions
2384
+ }, host);
2385
+ const entryFile = program.getSourceFile(entryFilePath);
2386
+ if (entryFile === undefined) {
2387
+ throw new Error(`Failed to find entry module`);
2388
+ }
2389
+ namespaces = resolveNamespaces(entryFile, program, host, manifest.Scope ?? manifest.Package);
2390
+ } else {
2391
+ program = ts.createProgram(files, {
2392
+ allowJs: true
2393
+ });
2394
+ namespaces = [];
2395
+ }
2301
2396
  const typeChecker = program.getTypeChecker();
2302
- filtered.forEach((file)=>{
2397
+ files.forEach((file)=>{
2303
2398
  // Create a Program to represent the project, then pull out the
2304
2399
  // source file to parse its AST.
2305
2400
  const sourceFile = program.getSourceFile(file);
2401
+ const namespace = namespaces.find((namespace)=>namespace.files.includes(sourceFile));
2306
2402
  // Loop through the root AST nodes of the file
2307
- ts.forEachChild(sourceFile, (node)=>{
2308
- for (const scriptingClass of findScriptingClasses(node)){
2309
- if (scriptingClass.node.name === undefined) {
2310
- throw new Error(`Expected ${scriptingClass.type} class to have a name`);
2311
- }
2312
- const name = typeChecker.getFullyQualifiedName(typeChecker.getSymbolAtLocation(scriptingClass.node.name));
2313
- if (name.length > 45) {
2314
- throw new Error(`Package name length >45 '${name}'`);
2315
- }
2316
- const parameterDeclaration = getScriptingClassParameterdeclaration(scriptingClass);
2317
- const parametersType = parameterDeclaration === undefined ? undefined : typeChecker.getTypeAtLocation(parameterDeclaration);
2318
- if (parametersType === undefined) {
2319
- console.log(`Failed to find parameters type declaration for ${scriptingClass.type} ${name}. Skipping parameter list generation`);
2320
- }
2321
- const existingIndexEntry = existingIndex.find((entry)=>entry.Name === name);
2322
- const obj = {
2323
- Name: name,
2324
- Description: (existingIndexEntry == null ? void 0 : existingIndexEntry.Description) ?? name,
2325
- Type: scriptingClass.type === "evaluator" ? "Evaluator" : "Interactor",
2326
- Parameters: []
2327
- };
2328
- const rawDocTags = ts.getJSDocTags(scriptingClass.node);
2329
- const dict = getTagDict(rawDocTags);
2330
- if (dict.summary) {
2331
- obj.Description = dict.summary;
2332
- } else {
2333
- const comment = typeChecker.getTypeAtLocation(scriptingClass.node).symbol.getDocumentationComment(typeChecker).map((comment)=>comment.text).join(" ");
2334
- if (comment) {
2335
- obj.Description = comment;
2336
- }
2403
+ for (const scriptingClass of findScriptingClasses(sourceFile)){
2404
+ if (scriptingClass.node.name === undefined) {
2405
+ throw new Error(`Expected ${scriptingClass.type} class to have a name`);
2406
+ }
2407
+ let name;
2408
+ if (isModule && namespace !== undefined) {
2409
+ const moduleNamespace = resolveNamespaceFullName(namespace);
2410
+ name = `${moduleNamespace}.${scriptingClass.node.name.text}`;
2411
+ } else {
2412
+ name = typeChecker.getFullyQualifiedName(typeChecker.getSymbolAtLocation(scriptingClass.node.name));
2413
+ }
2414
+ if (name.length > 45) {
2415
+ throw new Error(`Package name length >45 '${name}'`);
2416
+ }
2417
+ const parameterDeclaration = getScriptingClassParameterdeclaration(scriptingClass);
2418
+ const parametersType = parameterDeclaration === undefined ? undefined : typeChecker.getTypeAtLocation(parameterDeclaration);
2419
+ if (parametersType === undefined) {
2420
+ console.log(`Failed to find parameters type declaration for ${scriptingClass.type} ${name}. Skipping parameter list generation`);
2421
+ }
2422
+ const existingIndexEntry = existingIndex.find((entry)=>entry.Name === name);
2423
+ const obj = {
2424
+ Name: name,
2425
+ Description: (existingIndexEntry == null ? void 0 : existingIndexEntry.Description) ?? name,
2426
+ Type: scriptingClass.type === "evaluator" ? "Evaluator" : "Interactor",
2427
+ Parameters: []
2428
+ };
2429
+ const rawDocTags = ts.getJSDocTags(scriptingClass.node);
2430
+ const dict = getTagDict(rawDocTags);
2431
+ if (dict.summary) {
2432
+ obj.Description = dict.summary;
2433
+ } else {
2434
+ const comment = typeChecker.getTypeAtLocation(scriptingClass.node).symbol.getDocumentationComment(typeChecker).map((comment)=>comment.text).join(" ");
2435
+ if (comment) {
2436
+ obj.Description = comment;
2337
2437
  }
2338
- if (parametersType !== undefined) {
2339
- obj.Parameters = parseParametersList(typeChecker.getPropertiesOfType(parametersType), strictOptional);
2340
- if (obj.Parameters.length === 0 && parametersType.getStringIndexType() !== undefined) {
2341
- obj.Parameters = (existingIndexEntry == null ? void 0 : existingIndexEntry.Parameters) ?? [];
2342
- }
2343
- } else if (existingIndexEntry !== undefined) {
2344
- obj.Parameters = existingIndexEntry.Parameters;
2438
+ }
2439
+ if (parametersType !== undefined) {
2440
+ obj.Parameters = parseParametersList(typeChecker.getPropertiesOfType(parametersType), strictOptional);
2441
+ if (obj.Parameters.length === 0 && parametersType.getStringIndexType() !== undefined) {
2442
+ obj.Parameters = (existingIndexEntry == null ? void 0 : existingIndexEntry.Parameters) ?? [];
2345
2443
  }
2346
- arr.push(obj);
2444
+ } else if (existingIndexEntry !== undefined) {
2445
+ obj.Parameters = existingIndexEntry.Parameters;
2347
2446
  }
2348
- });
2447
+ arr.push(obj);
2448
+ }
2349
2449
  });
2350
2450
  arr.sort((a, b)=>a.Name.localeCompare(b.Name));
2351
2451
  writePackageCreatorIndex(location, arr);
@@ -2508,28 +2608,18 @@ const isScriptingClassParameterDeclaration = (scriptingClass, memberNode, parame
2508
2608
  *
2509
2609
  * @param {ts.Node} node
2510
2610
  * @return {*}
2511
- */ const findScriptingClasses = (node)=>{
2512
- let body;
2513
- if (ts.isModuleDeclaration(node)) {
2514
- body = node.body;
2515
- }
2516
- if (body !== undefined && ts.isModuleDeclaration(body)) {
2517
- body = body.body;
2518
- }
2519
- const classes = [];
2520
- if (body !== undefined) {
2521
- ts.forEachChild(body, (child)=>{
2522
- if (!ts.isClassDeclaration(child)) {
2523
- return;
2524
- }
2525
- const scriptingClass = detectScriptingClass(child);
2526
- if (scriptingClass !== undefined) {
2527
- classes.push(scriptingClass);
2528
- }
2529
- });
2611
+ */ function* findScriptingClasses(node) {
2612
+ for (const child of node.getChildren()){
2613
+ if (!ts.isClassDeclaration(child)) {
2614
+ yield* findScriptingClasses(child);
2615
+ continue;
2616
+ }
2617
+ const scriptingClass = detectScriptingClass(child);
2618
+ if (scriptingClass !== undefined) {
2619
+ yield scriptingClass;
2620
+ }
2530
2621
  }
2531
- return classes;
2532
- };
2622
+ }
2533
2623
  const detectScriptingClass = (node)=>{
2534
2624
  var _node_heritageClauses, _node_heritageClauses1;
2535
2625
  const isEvaluator = (_node_heritageClauses = node.heritageClauses) == null ? void 0 : _node_heritageClauses.some((clause)=>{
@@ -2558,5 +2648,5 @@ const detectScriptingClass = (node)=>{
2558
2648
  }
2559
2649
  };
2560
2650
 
2561
- export { buildFolders, buildFoldersWatch, createAssetServiceSessionManager, generateIndex, releaseFolder, synchronizeDependencies };
2651
+ export { buildFolders, buildFoldersWatch, createAssetServiceSessionManager, generateIndex, isScriptPackageModules, readScriptPackageTSConfig, releaseFolder, resolveScriptPackageEntryModule, synchronizeDependencies };
2562
2652
  //# sourceMappingURL=lib.mjs.map