@intelligentgraphics/ig.gfx.packager 3.1.0-alpha.1 → 3.1.0-alpha.3

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 (37) hide show
  1. package/build/bin.mjs +1 -1
  2. package/build/{cli-fec9c069.mjs → cli-DANmLXRa.mjs} +89 -79
  3. package/build/cli-DANmLXRa.mjs.map +1 -0
  4. package/build/{dependencies-d870016d.mjs → dependencies-DusLuN7Y.mjs} +2 -2
  5. package/build/{dependencies-d870016d.mjs.map → dependencies-DusLuN7Y.mjs.map} +1 -1
  6. package/build/{generateIndex-dd0b4563.mjs → generateIndex-DWjOe92Q.mjs} +96 -83
  7. package/build/generateIndex-DWjOe92Q.mjs.map +1 -0
  8. package/build/{generateParameterType-9a671e36.mjs → generateParameterType-BQ1F7eAV.mjs} +3 -4
  9. package/build/{generateParameterType-9a671e36.mjs.map → generateParameterType-BQ1F7eAV.mjs.map} +1 -1
  10. package/build/{index-7fa42d48.mjs → index-BEREgVJP.mjs} +201 -188
  11. package/build/index-BEREgVJP.mjs.map +1 -0
  12. package/build/{index-0caf1a6e.mjs → index-CqUHGUfc.mjs} +351 -127
  13. package/build/index-CqUHGUfc.mjs.map +1 -0
  14. package/build/{postinstall-81b6f0b0.mjs → postinstall-Da3ZBnje.mjs} +3 -4
  15. package/build/{postinstall-81b6f0b0.mjs.map → postinstall-Da3ZBnje.mjs.map} +1 -1
  16. package/build/{publishNpm-c985bd6e.mjs → publishNpm-B6bEiSNV.mjs} +14 -11
  17. package/build/publishNpm-B6bEiSNV.mjs.map +1 -0
  18. package/build/rollup-BEli071h.mjs +221 -0
  19. package/build/rollup-BEli071h.mjs.map +1 -0
  20. package/build/scripts-DI0Xj5Yb.mjs +48 -0
  21. package/build/scripts-DI0Xj5Yb.mjs.map +1 -0
  22. package/build/versionFile-tyKtTvcM.mjs +208 -0
  23. package/build/versionFile-tyKtTvcM.mjs.map +1 -0
  24. package/lib/lib.mjs +2649 -18
  25. package/package.json +21 -15
  26. package/readme.md +131 -13
  27. package/build/cli-fec9c069.mjs.map +0 -1
  28. package/build/generateIndex-dd0b4563.mjs.map +0 -1
  29. package/build/index-0caf1a6e.mjs.map +0 -1
  30. package/build/index-7fa42d48.mjs.map +0 -1
  31. package/build/publishNpm-c985bd6e.mjs.map +0 -1
  32. package/build/scripts-7ed8dff6.mjs +0 -10
  33. package/build/scripts-7ed8dff6.mjs.map +0 -1
  34. package/build/swc-9ed0f3ce.mjs +0 -60
  35. package/build/swc-9ed0f3ce.mjs.map +0 -1
  36. package/build/versionFile-cbfd3f4a.mjs +0 -380
  37. package/build/versionFile-cbfd3f4a.mjs.map +0 -1
@@ -1,26 +1,42 @@
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 'resolve';
6
8
  import 'write-pkg';
7
- import { c as readPackageAnimationList, r as readPackageCreatorManifest, i as isErrorENOENT, q as readPackageNpmManifest } from './cli-fec9c069.mjs';
8
- import glob from 'glob';
9
+ import { e as readPackageAnimationList, r as readPackageCreatorManifest, q as readPackageNpmManifest, i as isErrorENOENT } from './cli-DANmLXRa.mjs';
10
+ import { g as getPackageTypescriptFiles, i as isScriptPackageModules } from './scripts-DI0Xj5Yb.mjs';
9
11
  import 'node:path';
10
12
  import 'node:fs';
11
13
  import 'axios';
12
- import ts from 'typescript';
13
- import { g as getPackageTypescriptFiles } from './scripts-7ed8dff6.mjs';
14
14
  import typedoc from 'typedoc';
15
+ import glob from 'glob';
15
16
  import require$$2 from 'events';
16
17
  import { SourceMapGenerator, SourceMapConsumer } from 'source-map-js';
17
18
  import Ajv from 'ajv';
18
19
 
19
- const logPackageMessage = (name, step, index, total, maxNameLength = 15)=>{
20
+ const consoleReporter = {
21
+ log (message) {
22
+ console.log(message);
23
+ },
24
+ error (message, _error) {
25
+ console.error(message);
26
+ }
27
+ };
28
+ const createPackageScopedReporter = (reporter, scope, index, total, maxNameLength = 15)=>{
20
29
  const numLength = total === undefined ? undefined : total.toString().length;
21
30
  const indexString = total === undefined || total < 2 ? "" : `${index.toString().padStart(numLength, "0")}/${total} `;
22
- const identifierString = `${indexString}${name.padEnd(maxNameLength)}`;
23
- console.log(`${identifierString} >> ${step}`);
31
+ const identifierString = `${indexString}${scope.padEnd(maxNameLength)}`;
32
+ return {
33
+ log (message) {
34
+ reporter.log(`${identifierString} >> ${message}`);
35
+ },
36
+ error (message, error) {
37
+ reporter.error(`${identifierString} >> ${message}`, error);
38
+ }
39
+ };
24
40
  };
25
41
 
26
42
  const tryReadTsConfig = (location)=>{
@@ -33,25 +49,12 @@ const tryReadTsConfig = (location)=>{
33
49
  });
34
50
  return config;
35
51
  };
36
- const createTSCBuildParticipant = (location, outputDir)=>(env)=>{
52
+ const createTSCBuildParticipant = (location, outputDir, skipDeclarations)=>(env)=>{
37
53
  const files = getPackageTypescriptFiles(location);
38
- if (files.length === 0) {
39
- env.onBuildStart();
40
- env.onBuildEnd({
41
- type: "success",
42
- artefacts: {
43
- js: "",
44
- definitions: ""
45
- }
46
- });
47
- return {
48
- destroy: ()=>{}
49
- };
50
- }
51
54
  try {
52
55
  env.onBuildStart();
53
56
  env.log("Compiling typescript files");
54
- const compilerOptions = getCompilerOptions(location, outputDir);
57
+ const compilerOptions = getCompilerOptions(location, outputDir, skipDeclarations);
55
58
  const host = ts.createCompilerHost(compilerOptions);
56
59
  host.getCurrentDirectory = ()=>location.scriptsDir;
57
60
  let js;
@@ -76,7 +79,7 @@ const createTSCBuildParticipant = (location, outputDir)=>(env)=>{
76
79
  const allDiagnostics = ts.getPreEmitDiagnostics(program);
77
80
  if (!emitResult.emitSkipped) {
78
81
  if (allDiagnostics.length > 0) {
79
- console.log(allDiagnostics.map(createErrorMessage).join("\n"));
82
+ console.log(ts.formatDiagnostics(allDiagnostics, host));
80
83
  }
81
84
  if (js === undefined || definitions === undefined) {
82
85
  throw new Error(`Unexpected: no js or definitions were created`);
@@ -85,12 +88,12 @@ const createTSCBuildParticipant = (location, outputDir)=>(env)=>{
85
88
  type: "success",
86
89
  artefacts: {
87
90
  js: js.replace(`//# sourceMappingURL=out.js.map`, ""),
88
- definitions,
91
+ declarations: definitions,
89
92
  sourceMap
90
93
  }
91
94
  });
92
95
  } else {
93
- const error = allDiagnostics.map(createErrorMessage).join("\n");
96
+ const error = ts.formatDiagnostics(allDiagnostics, host);
94
97
  throw new Error(error);
95
98
  }
96
99
  } catch (err) {
@@ -103,7 +106,7 @@ const createTSCBuildParticipant = (location, outputDir)=>(env)=>{
103
106
  destroy: ()=>{}
104
107
  };
105
108
  };
106
- const createTSCWatchBuildParticipant = (location, outputDir)=>{
109
+ const createTSCWatchBuildParticipant = (location, outputDir, skipDeclarations)=>{
107
110
  return ({ onBuildStart, onBuildEnd })=>{
108
111
  let state = {
109
112
  diagnostics: [],
@@ -123,7 +126,7 @@ const createTSCWatchBuildParticipant = (location, outputDir)=>{
123
126
  }
124
127
  }
125
128
  };
126
- const reportDiagnostic = (diagnostic)=>{
129
+ const registerDiagnostic = (diagnostic)=>{
127
130
  switch(diagnostic.code){
128
131
  // file not found - https://github.com/microsoft/TypeScript/blob/93e6b9da0c4cb164ca90a5a1b07415e81e97f2b1/src/compiler/diagnosticMessages.json#L4640
129
132
  // probably deleted -> ignore
@@ -158,10 +161,10 @@ const createTSCWatchBuildParticipant = (location, outputDir)=>{
158
161
  sourceMap: undefined
159
162
  };
160
163
  if (emitState.diagnostics.length > 0) {
161
- const message = emitState.diagnostics.map(createErrorMessage).join("\n");
164
+ const message = ts.formatDiagnostics(emitState.diagnostics, formattingHost);
162
165
  onBuildEnd({
163
166
  type: "error",
164
- error: message
167
+ error: new Error(message)
165
168
  });
166
169
  return;
167
170
  }
@@ -178,26 +181,20 @@ const createTSCWatchBuildParticipant = (location, outputDir)=>{
178
181
  type: "success",
179
182
  artefacts: {
180
183
  js: emitState.js.replace(`//# sourceMappingURL=out.js.map`, ""),
181
- definitions: emitState.definitions,
184
+ declarations: emitState.definitions,
182
185
  sourceMap: emitState.sourceMap
183
186
  }
184
187
  });
185
188
  break;
186
189
  }
187
190
  };
188
- const host = ts.createWatchCompilerHost(path.join(location.scriptsDir, "tsconfig.json"), getCompilerOptions(location, outputDir), customSys, ts.createSemanticDiagnosticsBuilderProgram, reportDiagnostic, reportWatchStatusChanged);
191
+ const host = ts.createWatchCompilerHost(path.join(location.scriptsDir, "tsconfig.json"), getCompilerOptions(location, outputDir, skipDeclarations), customSys, ts.createSemanticDiagnosticsBuilderProgram, registerDiagnostic, reportWatchStatusChanged);
192
+ const formattingHost = {
193
+ getCanonicalFileName: (path)=>path,
194
+ getCurrentDirectory: host.getCurrentDirectory,
195
+ getNewLine: ()=>ts.sys.newLine
196
+ };
189
197
  const watchProgram = ts.createWatchProgram(host);
190
- const files = getPackageTypescriptFiles(location);
191
- if (files.length === 0) {
192
- onBuildStart();
193
- onBuildEnd({
194
- type: "success",
195
- artefacts: {
196
- js: "",
197
- definitions: ""
198
- }
199
- });
200
- }
201
198
  return {
202
199
  destroy: ()=>{
203
200
  watchProgram.close();
@@ -205,15 +202,7 @@ const createTSCWatchBuildParticipant = (location, outputDir)=>{
205
202
  };
206
203
  };
207
204
  };
208
- const createErrorMessage = (diagnostic)=>{
209
- if (!diagnostic.file) {
210
- return `${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`;
211
- }
212
- const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
213
- const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
214
- return `${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`;
215
- };
216
- const getCompilerOptions = (location, outputDir)=>{
205
+ const getCompilerOptions = (location, outputDir, skipDeclarations)=>{
217
206
  const config = tryReadTsConfig(location);
218
207
  config.compilerOptions.lib = [
219
208
  "es5",
@@ -223,7 +212,7 @@ const getCompilerOptions = (location, outputDir)=>{
223
212
  const compilerOptions = {
224
213
  ...result.options,
225
214
  removeComments: false,
226
- declaration: true,
215
+ declaration: !skipDeclarations,
227
216
  sourceMap: true,
228
217
  inlineSources: false,
229
218
  // We don't use tsc to actually emit the files, but we still need to set the correct
@@ -290,13 +279,8 @@ const toposort = (packages)=>{
290
279
  };
291
280
 
292
281
  class BuildManager extends require$$2 {
293
- constructor(manifest, writer, logStep){
294
- super();
295
- this.manifest = manifest;
296
- this.writer = writer;
297
- this.logStep = logStep;
298
- this.participants = new Map();
299
- this.states = new Map();
282
+ constructor(manifest, writer, reporter){
283
+ super(), this.manifest = manifest, this.writer = writer, this.reporter = reporter, this.participants = new Map(), this.states = new Map();
300
284
  }
301
285
  addParticipant(name, participant) {
302
286
  this.participants.set(name, participant);
@@ -329,7 +313,7 @@ class BuildManager extends require$$2 {
329
313
  this.states.set(name, result);
330
314
  this.maybeEmit();
331
315
  },
332
- log: this.logStep
316
+ log: (message)=>this.reporter.log(message)
333
317
  });
334
318
  }
335
319
  }
@@ -347,7 +331,7 @@ class BuildManager extends require$$2 {
347
331
  }
348
332
  }
349
333
  if (errors.length > 0) {
350
- this.emit("error", errors.join("\n"));
334
+ this.emit("error", errors.length === 1 ? errors[0] : new AggregateError(errors));
351
335
  return;
352
336
  }
353
337
  const completeResult = {
@@ -369,14 +353,16 @@ class BuildManager extends require$$2 {
369
353
  line: lines + mapping.generatedLine,
370
354
  column: mapping.generatedColumn
371
355
  },
372
- original: {
356
+ original: mapping.originalLine !== null && mapping.originalColumn !== null ? {
373
357
  line: mapping.originalLine,
374
358
  column: mapping.originalColumn
375
- },
359
+ } : undefined,
376
360
  source: mapping.source,
377
361
  name: mapping.name
378
362
  });
379
- sources.add(mapping.source);
363
+ if (mapping.source !== null) {
364
+ sources.add(mapping.source);
365
+ }
380
366
  });
381
367
  for (const source of sources){
382
368
  const content = sourceMap.sourceContentFor(source);
@@ -387,13 +373,13 @@ class BuildManager extends require$$2 {
387
373
  }
388
374
  completeResult.js += result.artefacts.js;
389
375
  }
390
- if (result.artefacts.definitions) {
391
- if (completeResult.definitions) {
392
- completeResult.definitions += "\n";
376
+ if (result.artefacts.declarations) {
377
+ if (completeResult.declarations) {
378
+ completeResult.declarations += "\n";
393
379
  } else {
394
- completeResult.definitions = "";
380
+ completeResult.declarations = "";
395
381
  }
396
- completeResult.definitions += result.artefacts.definitions;
382
+ completeResult.declarations += result.artefacts.declarations;
397
383
  }
398
384
  }
399
385
  completeResult.sourceMap = sourceMapGenerator.toString();
@@ -736,7 +722,7 @@ const createAnimationBuildParticipant = (location, manifest)=>{
736
722
  env.onBuildEnd({
737
723
  type: "success",
738
724
  artefacts: {
739
- js: (result == null ? void 0 : result.js) ?? ""
725
+ js: result?.js ?? ""
740
726
  }
741
727
  });
742
728
  }).catch((err)=>{
@@ -756,7 +742,7 @@ const createAnimationWatchBuildParticipant = (location, manifest)=>(env)=>{
756
742
  env.onBuildEnd({
757
743
  type: "success",
758
744
  artefacts: {
759
- js: (result == null ? void 0 : result.js) ?? ""
745
+ js: result?.js ?? ""
760
746
  }
761
747
  });
762
748
  }).catch((err)=>{
@@ -767,14 +753,14 @@ const createAnimationWatchBuildParticipant = (location, manifest)=>(env)=>{
767
753
  });
768
754
  (async ()=>{
769
755
  for await (const event of fs$1.watch(location.scriptsDir)){
770
- if (event.filename.endsWith(".animation.json")) {
756
+ if (event.filename?.endsWith(".animation.json")) {
771
757
  env.onBuildStart();
772
758
  try {
773
759
  const result = await bundleAnimations(location, manifest, env.log);
774
760
  env.onBuildEnd({
775
761
  type: "success",
776
762
  artefacts: {
777
- js: (result == null ? void 0 : result.js) ?? ""
763
+ js: result?.js ?? ""
778
764
  }
779
765
  });
780
766
  } catch (err) {
@@ -852,12 +838,193 @@ const getAnimationJsonValidation = async ()=>{
852
838
  return validateAnimationJson;
853
839
  };
854
840
 
855
- const buildFolders = async (options)=>{
841
+ // Stolen from ig.tools.core
842
+ class PackageVersion {
843
+ static{
844
+ // https://regex101.com/r/90PEY9/1
845
+ this.fullTextMatcher = /(\d+)(\.(\d+)(\.(\d+)(\.(\d+))?(-([^\.]+)\.(\d+))?)?)?/;
846
+ }
847
+ static{
848
+ this.lineMatcher = /^(\d+)(\.(\d+)(\.(\d+)(\.(\d+))?(-([^\.]+)\.(\d+))?)?)?$/;
849
+ }
850
+ static extractFromText(input, description) {
851
+ if (input === undefined) {
852
+ throw new Error(`Can not parse version from undefined`);
853
+ }
854
+ const match = input.match(PackageVersion.fullTextMatcher);
855
+ if (!match) {
856
+ throw new Error(`Could not extract a version from input: ${input}`);
857
+ }
858
+ return PackageVersion.fromMatch(match, description);
859
+ }
860
+ static extractFromLine(input, description) {
861
+ if (input === undefined) {
862
+ throw new Error(`Can not parse version from undefined`);
863
+ }
864
+ const match = input.match(PackageVersion.lineMatcher);
865
+ if (!match) {
866
+ throw new Error(`Could not parse version from input: ${input}`);
867
+ }
868
+ return PackageVersion.fromMatch(match, description);
869
+ }
870
+ static equals(a, b, checkPrerelease = false) {
871
+ if (a.major !== b.major || a.minor !== b.minor || a.patch !== b.patch) {
872
+ return false;
873
+ }
874
+ if (checkPrerelease === false) {
875
+ return true;
876
+ }
877
+ if (a.preRelease === b.preRelease) {
878
+ return true;
879
+ }
880
+ if (a.preRelease === undefined || b.preRelease === undefined) {
881
+ return false;
882
+ }
883
+ return a.preRelease.type === b.preRelease.type && a.preRelease.version === b.preRelease.version;
884
+ }
885
+ static fromMatch([, major, , minor = "0", , patch = "0", , build, , preReleaseType, preReleaseNumber], description) {
886
+ let preRelease = undefined;
887
+ let buildNumber = 100;
888
+ if (preReleaseType && preReleaseNumber) {
889
+ preRelease = {
890
+ type: preReleaseType,
891
+ version: parseInt(preReleaseNumber)
892
+ };
893
+ }
894
+ if (build) {
895
+ buildNumber = Number(build);
896
+ } else if (description) {
897
+ const descriptionMatch = description.match(/(\d+)\)$/);
898
+ if (descriptionMatch) {
899
+ buildNumber = parseInt(descriptionMatch[1]);
900
+ }
901
+ }
902
+ return new PackageVersion(parseInt(major), parseInt(minor), parseInt(patch), preRelease, buildNumber);
903
+ }
904
+ static sort(a, b, ascending = true) {
905
+ const createSortResult = (a, b)=>ascending ? a - b : b - a;
906
+ if (a.major !== b.major) {
907
+ return createSortResult(a.major, b.major);
908
+ }
909
+ if (a.minor !== b.minor) {
910
+ return createSortResult(a.minor, b.minor);
911
+ }
912
+ if (a.patch !== b.patch) {
913
+ return createSortResult(a.patch, b.patch);
914
+ }
915
+ return createSortResult(a.preRelease ? a.preRelease.version : 0, b.preRelease ? b.preRelease.version : 0);
916
+ }
917
+ static toNumber(version) {
918
+ return ((version.major * 1000 + version.minor) * 1000 + version.patch) * 1000 + version.buildNumber;
919
+ }
920
+ constructor(major, minor, patch, preRelease, buildNumber){
921
+ this.major = major;
922
+ this.minor = minor;
923
+ this.patch = patch;
924
+ this.preRelease = preRelease;
925
+ this.buildNumber = buildNumber;
926
+ }
927
+ isPreRelease() {
928
+ return this.preRelease !== undefined;
929
+ }
930
+ clone() {
931
+ return new PackageVersion(this.major, this.minor, this.patch, this.preRelease ? {
932
+ ...this.preRelease
933
+ } : undefined, this.buildNumber);
934
+ }
935
+ incrementMajor() {
936
+ this.preRelease = undefined;
937
+ this.patch = 0;
938
+ this.minor = 0;
939
+ this.major++;
940
+ }
941
+ incrementMinor() {
942
+ this.preRelease = undefined;
943
+ this.patch = 0;
944
+ this.minor++;
945
+ }
946
+ incrementPatch() {
947
+ this.preRelease = undefined;
948
+ this.patch++;
949
+ }
950
+ createPreRelease(type) {
951
+ if (!this.preRelease) {
952
+ this.buildNumber = 1;
953
+ } else {
954
+ this.buildNumber++;
955
+ }
956
+ if (this.preRelease && type === this.preRelease.type) {
957
+ this.preRelease.version++;
958
+ return;
959
+ }
960
+ this.preRelease = {
961
+ version: 0,
962
+ type
963
+ };
964
+ }
965
+ createRelease() {
966
+ this.preRelease = undefined;
967
+ this.buildNumber = 100;
968
+ }
969
+ toVersionString({ buildNumber } = {}) {
970
+ let version = [
971
+ this.major,
972
+ this.minor,
973
+ this.patch
974
+ ].join(".");
975
+ if (buildNumber) {
976
+ version += "." + this.buildNumber;
977
+ }
978
+ if (this.preRelease) {
979
+ version += `-${this.preRelease.type}.${this.preRelease.version}`;
980
+ }
981
+ return version;
982
+ }
983
+ toDescriptionString(packageName) {
984
+ const base = [
985
+ this.major,
986
+ this.minor,
987
+ this.patch
988
+ ].join(".");
989
+ const parts = [
990
+ packageName,
991
+ base
992
+ ];
993
+ if (this.preRelease) {
994
+ parts.push(upperCaseFirst(this.preRelease.type));
995
+ parts.push(this.preRelease.version);
996
+ }
997
+ parts.push(`(${base}.${this.buildNumber})`);
998
+ return parts.join(" ");
999
+ }
1000
+ /**
1001
+ * Determines wether the version is lesser than the input version
1002
+ *
1003
+ * @param {PackageVersion} version
1004
+ * @returns
1005
+ */ isLesserThan(version) {
1006
+ return PackageVersion.toNumber(this) < PackageVersion.toNumber(version);
1007
+ }
1008
+ /**
1009
+ * Determines wether the version is greater than the input version
1010
+ *
1011
+ * @param {PackageVersion} version
1012
+ * @returns
1013
+ */ isGreaterThan(version) {
1014
+ return PackageVersion.toNumber(this) > PackageVersion.toNumber(version);
1015
+ }
1016
+ }
1017
+ const upperCaseFirst = (input)=>{
1018
+ return input.slice(0, 1).toUpperCase() + input.slice(1);
1019
+ };
1020
+
1021
+ async function buildFolders(options) {
856
1022
  if (options.outDir !== undefined && options.clean) {
857
1023
  await fs$1.rm(options.outDir, {
858
1024
  recursive: true
859
1025
  });
860
1026
  }
1027
+ const baseReporter = options.reporter ?? consoleReporter;
861
1028
  const workspace = options.workspace;
862
1029
  const folders = options.packages;
863
1030
  let sortedPackages = sortPackagesByBuildOrder(folders);
@@ -868,45 +1035,51 @@ const buildFolders = async (options)=>{
868
1035
  ]));
869
1036
  const maxNameLength = Array.from(manifests.values(), (manifest)=>manifest.Package.length).reduce((acc, length)=>Math.max(acc, length), 0);
870
1037
  for (const location of sortedPackages){
871
- await ensureTsConfig(location);
1038
+ const tsConfig = await ensureTsConfig(location);
872
1039
  const data = manifests.get(location);
873
- const logStep = (step)=>logPackageMessage(data.Package, step, index, folders.length, maxNameLength);
1040
+ const reporter = options.preparedReporter ?? createPackageScopedReporter(baseReporter, data.Package, index, folders.length, maxNameLength);
874
1041
  const outputDirectory = options.outDir || location.scriptsDir;
875
1042
  await fs$1.mkdir(outputDirectory, {
876
1043
  recursive: true
877
1044
  });
878
- const manager = new BuildManager(data, (result)=>writeBuildResult(result, data, location, workspace, outputDirectory, options.minimize, logStep), logStep);
1045
+ const manager = new BuildManager(data, (result)=>writeBuildResult(result, data, location, workspace, outputDirectory, options.minimize, reporter), reporter);
879
1046
  if (options.banner) {
880
1047
  manager.addParticipant("banner", createBannerCommentBuildParticipant(options.banner));
881
1048
  }
882
- if (options.experimentalSwc) {
883
- const { createSWCBuildParticipant } = await import('./swc-9ed0f3ce.mjs');
884
- manager.addParticipant("swc", createSWCBuildParticipant(location));
885
- } else {
886
- manager.addParticipant("tsc", createTSCBuildParticipant(location, outputDirectory));
1049
+ const typescriptFiles = getPackageTypescriptFiles(location);
1050
+ if (!typescriptFiles.some((file)=>path.basename(file).toLowerCase() === "version.ts")) {
1051
+ manager.addParticipant("version", createVersionLogBuildParticipant(data));
1052
+ }
1053
+ if (typescriptFiles.length > 0) {
1054
+ if (isScriptPackageModules(tsConfig.options)) {
1055
+ const { createRollupBuildParticipant } = await import('./rollup-BEli071h.mjs');
1056
+ manager.addParticipant("rollup", createRollupBuildParticipant(location, data, outputDirectory, options.skipDeclarations ?? false));
1057
+ } else {
1058
+ manager.addParticipant("tsc", createTSCBuildParticipant(location, outputDirectory, options.skipDeclarations ?? false));
1059
+ }
887
1060
  }
888
1061
  manager.addParticipant("animation", createAnimationBuildParticipant(location, data));
889
1062
  await new Promise((resolve, reject)=>{
890
1063
  manager.addListener("start", ()=>{
891
- logStep(`Build started`);
1064
+ reporter.log(`Build started`);
892
1065
  });
893
1066
  manager.addListener("error", (error)=>{
894
- reject(new Error(error));
1067
+ reject(error);
895
1068
  });
896
1069
  manager.addListener("build", ()=>{
897
- logStep(`Build complete`);
1070
+ reporter.log(`Build complete`);
898
1071
  resolve();
899
1072
  });
900
1073
  manager.run();
901
1074
  });
902
1075
  if (options.docs) {
903
- logStep("Generating typedoc documentation");
1076
+ reporter.log("Generating typedoc documentation");
904
1077
  await generateDocs(location, path.join(outputDirectory, `${data.Package}.d.ts`), path.join(workspace.path, "docs", data.Package), data.Package);
905
1078
  }
906
1079
  index++;
907
1080
  }
908
- };
909
- const buildFoldersWatch = async (options)=>{
1081
+ }
1082
+ async function buildFoldersWatch(options) {
910
1083
  if (options.outDir !== undefined && options.clean) {
911
1084
  await fs$1.rm(options.outDir, {
912
1085
  recursive: true
@@ -922,30 +1095,41 @@ const buildFoldersWatch = async (options)=>{
922
1095
  ]));
923
1096
  const maxNameLength = Array.from(manifests.values(), (manifest)=>manifest.Package.length).reduce((acc, length)=>Math.max(acc, length), 0);
924
1097
  for (const location of sortedPackages){
925
- await ensureTsConfig(location);
1098
+ const tsConfig = await ensureTsConfig(location);
1099
+ const baseReporter = options.reporter ?? consoleReporter;
926
1100
  const data = manifests.get(location);
927
- const currentIndex = index;
928
- const logStep = (step)=>logPackageMessage(data.Package, step, currentIndex, folders.length, maxNameLength);
1101
+ const reporter = createPackageScopedReporter(baseReporter, data.Package, index, folders.length, maxNameLength);
929
1102
  const outputDirectory = options.outDir || location.scriptsDir;
930
1103
  await fs$1.mkdir(outputDirectory, {
931
1104
  recursive: true
932
1105
  });
933
- const manager = new BuildManager(data, (result)=>writeBuildResult(result, data, location, workspace, outputDirectory, options.minimize, logStep), logStep);
1106
+ const manager = new BuildManager(data, (result)=>writeBuildResult(result, data, location, workspace, outputDirectory, options.minimize, reporter), reporter);
934
1107
  if (options.banner) {
935
1108
  manager.addParticipant("banner", createBannerCommentBuildParticipant(options.banner));
936
1109
  }
937
- manager.addParticipant("tsc", createTSCWatchBuildParticipant(location, outputDirectory));
1110
+ const typescriptFiles = getPackageTypescriptFiles(location);
1111
+ if (!typescriptFiles.some((file)=>path.basename(file).toLowerCase() === "version.ts")) {
1112
+ manager.addParticipant("version", createVersionLogBuildParticipant(data));
1113
+ }
1114
+ if (typescriptFiles.length > 0) {
1115
+ if (isScriptPackageModules(tsConfig.options)) {
1116
+ const { createRollupWatchBuildParticipant } = await import('./rollup-BEli071h.mjs');
1117
+ manager.addParticipant("rollup", createRollupWatchBuildParticipant(location, data, outputDirectory, options.skipDeclarations ?? false));
1118
+ } else {
1119
+ manager.addParticipant("tsc", createTSCWatchBuildParticipant(location, outputDirectory, options.skipDeclarations ?? false));
1120
+ }
1121
+ }
938
1122
  manager.addParticipant("animation", createAnimationWatchBuildParticipant(location, data));
939
1123
  await new Promise((resolve, reject)=>{
940
1124
  manager.addListener("start", ()=>{
941
- logStep(`Build started`);
1125
+ reporter.log(`Build started`);
942
1126
  });
943
1127
  manager.addListener("error", (error)=>{
944
- logStep(`Build failed: ${error}`);
1128
+ reporter.log(`Build failed: ${EOL}${error}`);
945
1129
  resolve();
946
1130
  });
947
1131
  manager.addListener("build", ()=>{
948
- logStep(`Build complete`);
1132
+ reporter.log(`Build complete`);
949
1133
  resolve();
950
1134
  });
951
1135
  manager.run();
@@ -953,8 +1137,8 @@ const buildFoldersWatch = async (options)=>{
953
1137
  index++;
954
1138
  }
955
1139
  await new Promise(()=>{});
956
- };
957
- const writeBuildResult = async (buildResult, manifest, location, workspace, outputDirectory, minimize, logStep)=>{
1140
+ }
1141
+ async function writeBuildResult(buildResult, manifest, location, workspace, outputDirectory, minimize, reporter) {
958
1142
  let js = buildResult.js;
959
1143
  if (buildResult.sourceMap) {
960
1144
  js += `\n//# sourceMappingURL=${manifest.Package}.js.map`;
@@ -962,8 +1146,8 @@ const writeBuildResult = async (buildResult, manifest, location, workspace, outp
962
1146
  await fs$1.writeFile(path.join(outputDirectory, `${manifest.Package}.js`), js, {
963
1147
  encoding: "utf8"
964
1148
  });
965
- if (buildResult.definitions !== undefined) {
966
- await fs$1.writeFile(path.join(outputDirectory, `${manifest.Package}.d.ts`), buildResult.definitions, {
1149
+ if (buildResult.declarations !== undefined) {
1150
+ await fs$1.writeFile(path.join(outputDirectory, `${manifest.Package}.d.ts`), buildResult.declarations, {
967
1151
  encoding: "utf8"
968
1152
  });
969
1153
  }
@@ -973,7 +1157,7 @@ const writeBuildResult = async (buildResult, manifest, location, workspace, outp
973
1157
  });
974
1158
  }
975
1159
  if (minimize) {
976
- logStep("Minifying the output");
1160
+ reporter.log("Minifying the output");
977
1161
  const minifyResult = await terser.minify(js, {
978
1162
  ecma: 5,
979
1163
  sourceMap: {
@@ -991,54 +1175,94 @@ const writeBuildResult = async (buildResult, manifest, location, workspace, outp
991
1175
  });
992
1176
  }
993
1177
  }
994
- if (location.path.includes("Basics") && buildResult.definitions !== undefined) {
1178
+ if (location.path.includes("Basics") && buildResult.declarations !== undefined) {
995
1179
  await fs$1.mkdir(path.join(workspace.path, "lib"), {
996
1180
  recursive: true
997
1181
  });
998
- logStep("Copying basics definition file to the lib folder");
999
- await fs$1.writeFile(path.join(workspace.path, "lib", `${manifest.Package}.d.ts`), buildResult.definitions, {
1182
+ reporter.log("Copying basics definition file to the lib folder");
1183
+ await fs$1.writeFile(path.join(workspace.path, "lib", `${manifest.Package}.d.ts`), buildResult.declarations, {
1000
1184
  encoding: "utf8"
1001
1185
  });
1002
1186
  }
1003
- };
1004
- const createBannerCommentBuildParticipant = (options)=>(env)=>{
1187
+ }
1188
+ function createVersionLogBuildParticipant(manifest) {
1189
+ return (env)=>{
1190
+ env.onBuildStart();
1191
+ const parsedVersion = manifest.Version !== undefined ? PackageVersion.extractFromLine(manifest.Version) : undefined;
1192
+ let logText;
1193
+ if (parsedVersion !== undefined) {
1194
+ logText = parsedVersion.toDescriptionString(manifest.Package);
1195
+ } else {
1196
+ logText = manifest.Package;
1197
+ }
1198
+ logText += ".";
1199
+ if (manifest.Copyright !== undefined) {
1200
+ logText += " " + manifest.Copyright;
1201
+ }
1202
+ env.onBuildEnd({
1203
+ type: "success",
1204
+ artefacts: {
1205
+ js: `console.log(${JSON.stringify(logText)})`
1206
+ }
1207
+ });
1208
+ return {
1209
+ destroy: ()=>{}
1210
+ };
1211
+ };
1212
+ }
1213
+ function createBannerCommentBuildParticipant(options) {
1214
+ return (env)=>{
1005
1215
  env.onBuildStart();
1006
1216
  const banner = createBannerComment(options);
1007
1217
  env.onBuildEnd({
1008
1218
  type: "success",
1009
1219
  artefacts: {
1010
1220
  js: banner ?? "",
1011
- definitions: banner ?? ""
1221
+ declarations: banner ?? ""
1012
1222
  }
1013
1223
  });
1014
1224
  return {
1015
1225
  destroy: ()=>{}
1016
1226
  };
1017
1227
  };
1018
- const ensureTsConfig = async (location)=>{
1228
+ }
1229
+ async function ensureTsConfig(location) {
1019
1230
  const tsconfigPath = path.join(location.scriptsDir, "tsconfig.json");
1020
1231
  try {
1021
1232
  const content = JSON.parse(await fs$1.readFile(tsconfigPath, "utf8"));
1022
- applyTsConfigOption(content);
1023
- await fs$1.writeFile(tsconfigPath, JSON.stringify(content, undefined, " "), "utf8");
1233
+ applyTsConfigOptions(content);
1234
+ await fs$1.writeFile(tsconfigPath, JSON.stringify(content, undefined, "\t"), "utf8");
1235
+ return ts.parseJsonConfigFileContent(content, ts.sys, location.scriptsDir);
1024
1236
  } catch (err) {
1025
1237
  if (!isErrorENOENT(err)) {
1026
1238
  throw err;
1027
1239
  }
1028
1240
  const content = {};
1029
- applyTsConfigOption(content);
1030
- await fs$1.writeFile(tsconfigPath, JSON.stringify(content, undefined, " "), "utf8");
1241
+ applyTsConfigOptions(content);
1242
+ await fs$1.writeFile(tsconfigPath, JSON.stringify(content, undefined, "\t"), "utf8");
1243
+ return ts.parseJsonConfigFileContent(content, ts.sys, location.scriptsDir);
1031
1244
  }
1032
- };
1033
- const applyTsConfigOption = (data)=>{
1034
- data.compilerOptions = data.compilerOptions ?? {};
1035
- data.compilerOptions.target = "es5";
1036
- data.compilerOptions.lib = [
1037
- "es5",
1038
- "dom"
1039
- ];
1040
- };
1041
- const sortPackagesByBuildOrder = (folders)=>{
1245
+ }
1246
+ function applyTsConfigOptions(data) {
1247
+ if (data.compilerOptions?.module?.toLowerCase().startsWith("es")) {
1248
+ data.compilerOptions = data.compilerOptions ?? {};
1249
+ data.compilerOptions.target = "esnext";
1250
+ data.compilerOptions.lib = [
1251
+ "esnext",
1252
+ "dom"
1253
+ ];
1254
+ data.compilerOptions.module = "es2015";
1255
+ data.compilerOptions.moduleResolution = "node";
1256
+ } else {
1257
+ data.compilerOptions = data.compilerOptions ?? {};
1258
+ data.compilerOptions.target = "es5";
1259
+ data.compilerOptions.lib = [
1260
+ "es5",
1261
+ "dom"
1262
+ ];
1263
+ }
1264
+ }
1265
+ function sortPackagesByBuildOrder(folders) {
1042
1266
  const packages = Array.from(folders).reduce((acc, location)=>{
1043
1267
  const data = readPackageNpmManifest(location);
1044
1268
  if (data !== undefined) {
@@ -1078,8 +1302,8 @@ const sortPackagesByBuildOrder = (folders)=>{
1078
1302
  }
1079
1303
  }
1080
1304
  return result;
1081
- };
1082
- const createBannerComment = (banner)=>{
1305
+ }
1306
+ function createBannerComment(banner) {
1083
1307
  const bannerParts = [];
1084
1308
  if (banner.text) {
1085
1309
  bannerParts.push(" * " + banner.text);
@@ -1113,7 +1337,7 @@ ${bannerText}
1113
1337
  */`;
1114
1338
  }
1115
1339
  return undefined;
1116
- };
1340
+ }
1117
1341
 
1118
1342
  var index = /*#__PURE__*/Object.freeze({
1119
1343
  __proto__: null,
@@ -1121,5 +1345,5 @@ var index = /*#__PURE__*/Object.freeze({
1121
1345
  buildFoldersWatch: buildFoldersWatch
1122
1346
  });
1123
1347
 
1124
- export { buildFolders as b, index as i, logPackageMessage as l };
1125
- //# sourceMappingURL=index-0caf1a6e.mjs.map
1348
+ export { PackageVersion as P, consoleReporter as a, buildFolders as b, createPackageScopedReporter as c, index as i };
1349
+ //# sourceMappingURL=index-CqUHGUfc.mjs.map