@intelligentgraphics/ig.gfx.packager 3.1.4 → 3.2.1
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.
- package/build/bin.js +8 -0
- package/build/bin.js.map +1 -0
- package/build/build-CMbCj7x-.js +945 -0
- package/build/build-CMbCj7x-.js.map +1 -0
- package/build/build-kkMVBBJL.js +408 -0
- package/build/build-kkMVBBJL.js.map +1 -0
- package/build/cli-Co1DhAmx.js +405 -0
- package/build/cli-Co1DhAmx.js.map +1 -0
- package/build/docs-BkGeoYY2.js +30 -0
- package/build/docs-BkGeoYY2.js.map +1 -0
- package/build/generateIndex-C_DxQ2R4.js +209 -0
- package/build/generateIndex-C_DxQ2R4.js.map +1 -0
- package/build/generateParameterType-CdCi5BWM.js +46 -0
- package/build/generateParameterType-CdCi5BWM.js.map +1 -0
- package/build/package-DHx2bvVO.js +1 -0
- package/build/postinstall-DHTlEmNr.js +35 -0
- package/build/postinstall-DHTlEmNr.js.map +1 -0
- package/build/prompter-DONgUlzS.js +20 -0
- package/build/prompter-DONgUlzS.js.map +1 -0
- package/build/publish-E5zcQAo0.js +348 -0
- package/build/publish-E5zcQAo0.js.map +1 -0
- package/build/publishNpm-CBT1819u.js +115 -0
- package/build/publishNpm-CBT1819u.js.map +1 -0
- package/build/publishedPackage-D-KiU0FG.js +1 -0
- package/build/rollup-Csyght27.js +179 -0
- package/build/rollup-Csyght27.js.map +1 -0
- package/build/scripts-CBblHIL1.js +29 -0
- package/build/scripts-CBblHIL1.js.map +1 -0
- package/build/versionFile-DViDwgCa.js +123 -0
- package/build/versionFile-DViDwgCa.js.map +1 -0
- package/build/workspace-D0XY2EMu.js +1 -0
- package/lib/lib.js +1595 -0
- package/package.json +30 -30
- package/readme.md +7 -0
- package/build/bin.mjs +0 -5
- package/build/bin.mjs.map +0 -1
- package/build/cli-CTqQeYIu.mjs +0 -768
- package/build/cli-CTqQeYIu.mjs.map +0 -1
- package/build/dependencies-CCIr5dgH.mjs +0 -129
- package/build/dependencies-CCIr5dgH.mjs.map +0 -1
- package/build/docs-DvFV9WXA.mjs +0 -37
- package/build/docs-DvFV9WXA.mjs.map +0 -1
- package/build/generateIndex-COnAgsMM.mjs +0 -306
- package/build/generateIndex-COnAgsMM.mjs.map +0 -1
- package/build/generateParameterType-BFVUv72F.mjs +0 -71
- package/build/generateParameterType-BFVUv72F.mjs.map +0 -1
- package/build/index-Ck4_b8Wk.mjs +0 -1400
- package/build/index-Ck4_b8Wk.mjs.map +0 -1
- package/build/index-DHSUlJia.mjs +0 -477
- package/build/index-DHSUlJia.mjs.map +0 -1
- package/build/postinstall-BTuIhY_F.mjs +0 -61
- package/build/postinstall-BTuIhY_F.mjs.map +0 -1
- package/build/publishNpm-A02qW1UY.mjs +0 -167
- package/build/publishNpm-A02qW1UY.mjs.map +0 -1
- package/build/rollup-BeQ0dM8U.mjs +0 -221
- package/build/rollup-BeQ0dM8U.mjs.map +0 -1
- package/build/scripts-B3noxiX3.mjs +0 -45
- package/build/scripts-B3noxiX3.mjs.map +0 -1
- package/build/versionFile-B9z_qwQL.mjs +0 -206
- package/build/versionFile-B9z_qwQL.mjs.map +0 -1
- package/lib/lib.mjs +0 -2706
|
@@ -0,0 +1,945 @@
|
|
|
1
|
+
import { A as isErrorENOENT, S as readPackageAnimationList, T as readPackageNpmManifest, i as createPackageScopedReporter, n as getPackageTypescriptFiles, r as consoleReporter, w as readPackageCreatorManifest } from "./build-kkMVBBJL.js";
|
|
2
|
+
import "./package-DHx2bvVO.js";
|
|
3
|
+
import "./workspace-D0XY2EMu.js";
|
|
4
|
+
import { t as isScriptPackageModules } from "./scripts-CBblHIL1.js";
|
|
5
|
+
import * as fs$1 from "node:fs";
|
|
6
|
+
import * as path from "node:path";
|
|
7
|
+
import * as fs from "fs/promises";
|
|
8
|
+
import * as terser from "terser";
|
|
9
|
+
import { EOL } from "node:os";
|
|
10
|
+
import ts from "typescript";
|
|
11
|
+
import EventEmitter from "events";
|
|
12
|
+
import { SourceMapConsumer, SourceMapGenerator } from "source-map-js";
|
|
13
|
+
import Ajv from "ajv";
|
|
14
|
+
//#region src/commands/build/tsc.ts
|
|
15
|
+
const tryReadTsConfig = (location) => {
|
|
16
|
+
const { config } = ts.readConfigFile(path.join(location.scriptsDir, "tsconfig.json"), (path) => {
|
|
17
|
+
try {
|
|
18
|
+
return fs$1.readFileSync(path, "utf8");
|
|
19
|
+
} catch {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
return config;
|
|
24
|
+
};
|
|
25
|
+
const createTSCBuildParticipant = (location, outputDir, skipDeclarations) => (env) => {
|
|
26
|
+
const files = getPackageTypescriptFiles(location);
|
|
27
|
+
try {
|
|
28
|
+
env.onBuildStart();
|
|
29
|
+
env.log("Compiling typescript files");
|
|
30
|
+
const compilerOptions = getCompilerOptions(location, outputDir, skipDeclarations);
|
|
31
|
+
const host = ts.createCompilerHost(compilerOptions);
|
|
32
|
+
host.getCurrentDirectory = () => location.scriptsDir;
|
|
33
|
+
let js;
|
|
34
|
+
let definitions;
|
|
35
|
+
let sourceMap;
|
|
36
|
+
host.writeFile = (fileName, data, writeByteOrderMark) => {
|
|
37
|
+
if (fileName.endsWith(".js")) js = data;
|
|
38
|
+
else if (fileName.endsWith(".d.ts")) definitions = data;
|
|
39
|
+
else if (fileName.endsWith(".js.map")) sourceMap = data;
|
|
40
|
+
};
|
|
41
|
+
const programOptions = {
|
|
42
|
+
rootNames: files,
|
|
43
|
+
options: compilerOptions,
|
|
44
|
+
host
|
|
45
|
+
};
|
|
46
|
+
const program = ts.createProgram(programOptions);
|
|
47
|
+
const emitResult = program.emit();
|
|
48
|
+
const allDiagnostics = ts.getPreEmitDiagnostics(program);
|
|
49
|
+
if (!emitResult.emitSkipped) {
|
|
50
|
+
if (allDiagnostics.length > 0) console.log(ts.formatDiagnostics(allDiagnostics, host));
|
|
51
|
+
if (js === void 0 || definitions === void 0) throw new Error(`Unexpected: no js or definitions were created`);
|
|
52
|
+
env.onBuildEnd({
|
|
53
|
+
type: "success",
|
|
54
|
+
artefacts: {
|
|
55
|
+
js: js.replace(`//# sourceMappingURL=out.js.map`, ""),
|
|
56
|
+
declarations: getDeclarationFileReferences(location, program, outputDir) + definitions,
|
|
57
|
+
sourceMap
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
} else {
|
|
61
|
+
const error = ts.formatDiagnostics(allDiagnostics, host);
|
|
62
|
+
throw new Error(error);
|
|
63
|
+
}
|
|
64
|
+
} catch (err) {
|
|
65
|
+
env.onBuildEnd({
|
|
66
|
+
type: "error",
|
|
67
|
+
error: err instanceof Error ? err : new Error(String(err))
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return { destroy: () => {} };
|
|
71
|
+
};
|
|
72
|
+
const createTSCWatchBuildParticipant = (location, outputDir, skipDeclarations) => {
|
|
73
|
+
return ({ onBuildStart, onBuildEnd }) => {
|
|
74
|
+
let state = {
|
|
75
|
+
diagnostics: [],
|
|
76
|
+
js: void 0,
|
|
77
|
+
definitions: void 0,
|
|
78
|
+
sourceMap: void 0
|
|
79
|
+
};
|
|
80
|
+
const customSys = {
|
|
81
|
+
...ts.sys,
|
|
82
|
+
writeFile: (fileName, data, writeByteOrderMark) => {
|
|
83
|
+
if (fileName.endsWith(".js")) state.js = data;
|
|
84
|
+
else if (fileName.endsWith(".d.ts")) state.definitions = data;
|
|
85
|
+
else if (fileName.endsWith(".js.map")) state.sourceMap = data;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
const registerDiagnostic = (diagnostic) => {
|
|
89
|
+
switch (diagnostic.code) {
|
|
90
|
+
case 6053: return;
|
|
91
|
+
case 18003: return;
|
|
92
|
+
}
|
|
93
|
+
state.diagnostics.push(diagnostic);
|
|
94
|
+
};
|
|
95
|
+
let currentProgram;
|
|
96
|
+
const reportWatchStatusChanged = (diagnostic) => {
|
|
97
|
+
switch (diagnostic.code) {
|
|
98
|
+
case 6031:
|
|
99
|
+
case 6032:
|
|
100
|
+
onBuildStart();
|
|
101
|
+
break;
|
|
102
|
+
case 6193:
|
|
103
|
+
case 6194:
|
|
104
|
+
const emitState = state;
|
|
105
|
+
state = {
|
|
106
|
+
diagnostics: [],
|
|
107
|
+
js: void 0,
|
|
108
|
+
definitions: void 0,
|
|
109
|
+
sourceMap: void 0
|
|
110
|
+
};
|
|
111
|
+
if (emitState.diagnostics.length > 0) {
|
|
112
|
+
const message = ts.formatDiagnostics(emitState.diagnostics, formattingHost);
|
|
113
|
+
onBuildEnd({
|
|
114
|
+
type: "error",
|
|
115
|
+
error: new Error(message)
|
|
116
|
+
});
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (emitState.js === void 0) {
|
|
120
|
+
onBuildEnd({
|
|
121
|
+
type: "success",
|
|
122
|
+
artefacts: { js: "" }
|
|
123
|
+
});
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (!currentProgram) throw new Error(`Expected a program to exist`);
|
|
127
|
+
onBuildEnd({
|
|
128
|
+
type: "success",
|
|
129
|
+
artefacts: {
|
|
130
|
+
js: emitState.js.replace(`//# sourceMappingURL=out.js.map`, ""),
|
|
131
|
+
declarations: emitState.definitions ? getDeclarationFileReferences(location, currentProgram, outputDir) + emitState.definitions : void 0,
|
|
132
|
+
sourceMap: emitState.sourceMap
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
const host = ts.createWatchCompilerHost(path.join(location.scriptsDir, "tsconfig.json"), getCompilerOptions(location, outputDir, skipDeclarations), customSys, ts.createSemanticDiagnosticsBuilderProgram, registerDiagnostic, reportWatchStatusChanged);
|
|
139
|
+
const originalAfterProgramCreate = host.afterProgramCreate;
|
|
140
|
+
host.afterProgramCreate = (program) => {
|
|
141
|
+
currentProgram = program;
|
|
142
|
+
originalAfterProgramCreate?.(program);
|
|
143
|
+
};
|
|
144
|
+
const formattingHost = {
|
|
145
|
+
getCanonicalFileName: (path) => path,
|
|
146
|
+
getCurrentDirectory: host.getCurrentDirectory,
|
|
147
|
+
getNewLine: () => ts.sys.newLine
|
|
148
|
+
};
|
|
149
|
+
const watchProgram = ts.createWatchProgram(host);
|
|
150
|
+
return { destroy: () => {
|
|
151
|
+
watchProgram.close();
|
|
152
|
+
} };
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
const getCompilerOptions = (location, outputDir, skipDeclarations) => {
|
|
156
|
+
const config = tryReadTsConfig(location);
|
|
157
|
+
config.compilerOptions.lib = ["es2018", "dom"];
|
|
158
|
+
return {
|
|
159
|
+
...ts.convertCompilerOptionsFromJson(config.compilerOptions, location.scriptsDir).options,
|
|
160
|
+
removeComments: false,
|
|
161
|
+
declaration: !skipDeclarations,
|
|
162
|
+
sourceMap: true,
|
|
163
|
+
inlineSources: false,
|
|
164
|
+
outFile: path.join(outputDir, "out.js"),
|
|
165
|
+
target: ts.ScriptTarget.ES5,
|
|
166
|
+
noEmitOnError: true
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
function getDeclarationFileReferences(location, program, outputDir) {
|
|
170
|
+
const references = /* @__PURE__ */ new Set();
|
|
171
|
+
for (const file of program.getSourceFiles()) for (const reference of file.referencedFiles) {
|
|
172
|
+
if (reference.preserve) continue;
|
|
173
|
+
const dir = path.dirname(file.fileName);
|
|
174
|
+
const absolute = path.resolve(dir, reference.fileName);
|
|
175
|
+
if (!absolute.startsWith(location.scriptsDir)) references.add(absolute);
|
|
176
|
+
}
|
|
177
|
+
let referenceString = Array.from(references, (reference) => {
|
|
178
|
+
return `/// <reference path="${path.relative(outputDir, reference).replaceAll(path.sep, "/")}" />`;
|
|
179
|
+
}).join(EOL);
|
|
180
|
+
if (referenceString) referenceString += EOL;
|
|
181
|
+
return referenceString;
|
|
182
|
+
}
|
|
183
|
+
//#endregion
|
|
184
|
+
//#region src/lib/toposort.ts
|
|
185
|
+
const toposort = (packages) => {
|
|
186
|
+
const queue = Object.getOwnPropertyNames(packages);
|
|
187
|
+
const result = [];
|
|
188
|
+
let index = 0;
|
|
189
|
+
while (queue.length > 0) {
|
|
190
|
+
if (index >= queue.length) throw new Error("Packages can not have cyclic dependencies");
|
|
191
|
+
const queueEntry = queue[index];
|
|
192
|
+
if (packages[queueEntry].some((dependency) => queue.includes(dependency))) {
|
|
193
|
+
index++;
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
queue.splice(index, 1);
|
|
197
|
+
index = 0;
|
|
198
|
+
result.push(queueEntry);
|
|
199
|
+
}
|
|
200
|
+
return result;
|
|
201
|
+
};
|
|
202
|
+
//#endregion
|
|
203
|
+
//#region src/commands/build/manager.ts
|
|
204
|
+
var BuildManager = class extends EventEmitter {
|
|
205
|
+
participants = /* @__PURE__ */ new Map();
|
|
206
|
+
states = /* @__PURE__ */ new Map();
|
|
207
|
+
participantInstances = [];
|
|
208
|
+
constructor(manifest, writer, reporter) {
|
|
209
|
+
super();
|
|
210
|
+
this.manifest = manifest;
|
|
211
|
+
this.writer = writer;
|
|
212
|
+
this.reporter = reporter;
|
|
213
|
+
}
|
|
214
|
+
addParticipant(name, participant) {
|
|
215
|
+
this.participants.set(name, participant);
|
|
216
|
+
}
|
|
217
|
+
run() {
|
|
218
|
+
for (const [name] of this.participants) this.states.set(name, { type: "busy" });
|
|
219
|
+
this.emit("start");
|
|
220
|
+
for (const [name, participant] of this.participants) {
|
|
221
|
+
const instance = participant({
|
|
222
|
+
onBuildStart: () => {
|
|
223
|
+
let alreadyBusy = false;
|
|
224
|
+
for (const [name, state] of this.states) if (state.type === "busy") {
|
|
225
|
+
alreadyBusy = true;
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
this.states.set(name, { type: "busy" });
|
|
229
|
+
if (!alreadyBusy) this.emit("start");
|
|
230
|
+
},
|
|
231
|
+
onBuildEnd: (result) => {
|
|
232
|
+
this.states.set(name, result);
|
|
233
|
+
this.maybeEmit();
|
|
234
|
+
},
|
|
235
|
+
log: (message) => this.reporter.log(message)
|
|
236
|
+
});
|
|
237
|
+
this.participantInstances.push(instance);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
destroy() {
|
|
241
|
+
for (const instance of this.participantInstances) instance.destroy();
|
|
242
|
+
}
|
|
243
|
+
maybeEmit() {
|
|
244
|
+
const errors = [];
|
|
245
|
+
const results = [];
|
|
246
|
+
for (const [_, state] of this.states) {
|
|
247
|
+
if (state.type === "busy") return;
|
|
248
|
+
if (state.type === "success") results.push(state);
|
|
249
|
+
else if (state.type === "error") errors.push(state.error);
|
|
250
|
+
}
|
|
251
|
+
if (errors.length > 0) {
|
|
252
|
+
this.emit("error", errors.length === 1 ? errors[0] : new AggregateError(errors));
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
const completeResult = { js: "" };
|
|
256
|
+
const sourceMapGenerator = new SourceMapGenerator();
|
|
257
|
+
for (const result of results) {
|
|
258
|
+
if (result.artefacts.js) {
|
|
259
|
+
if (completeResult.js) completeResult.js += "\n";
|
|
260
|
+
if (result.artefacts.sourceMap) {
|
|
261
|
+
const lines = completeResult.js.split("\n").length - 1;
|
|
262
|
+
const sourceMap = new SourceMapConsumer(JSON.parse(result.artefacts.sourceMap));
|
|
263
|
+
const sources = /* @__PURE__ */ new Set();
|
|
264
|
+
sourceMap.eachMapping((mapping) => {
|
|
265
|
+
sourceMapGenerator.addMapping({
|
|
266
|
+
generated: {
|
|
267
|
+
line: lines + mapping.generatedLine,
|
|
268
|
+
column: mapping.generatedColumn
|
|
269
|
+
},
|
|
270
|
+
original: mapping.originalLine !== null && mapping.originalColumn !== null ? {
|
|
271
|
+
line: mapping.originalLine,
|
|
272
|
+
column: mapping.originalColumn
|
|
273
|
+
} : void 0,
|
|
274
|
+
source: mapping.source,
|
|
275
|
+
name: mapping.name
|
|
276
|
+
});
|
|
277
|
+
if (mapping.source !== null) sources.add(mapping.source);
|
|
278
|
+
});
|
|
279
|
+
for (const source of sources) {
|
|
280
|
+
const content = sourceMap.sourceContentFor(source);
|
|
281
|
+
if (content !== null) sourceMapGenerator.setSourceContent(source, content);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
completeResult.js += result.artefacts.js;
|
|
285
|
+
}
|
|
286
|
+
if (result.artefacts.declarations) {
|
|
287
|
+
if (completeResult.declarations) completeResult.declarations += "\n";
|
|
288
|
+
else completeResult.declarations = "";
|
|
289
|
+
completeResult.declarations += result.artefacts.declarations;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
completeResult.sourceMap = sourceMapGenerator.toString();
|
|
293
|
+
this.writer(completeResult).then(() => {
|
|
294
|
+
this.emit("build");
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
//#endregion
|
|
299
|
+
//#region src/commands/build/animation.schema.ts
|
|
300
|
+
var animation_schema_default = {
|
|
301
|
+
$schema: "http://json-schema.org/draft-07/schema",
|
|
302
|
+
$id: "https://archive.intelligentgraphics.biz/schemas/gfx/animation.json",
|
|
303
|
+
$comment: "Version 2023-02-17, Source: ig.data.gfx/Specs/animation.json",
|
|
304
|
+
title: "Animation description format",
|
|
305
|
+
additionalProperties: false,
|
|
306
|
+
type: "object",
|
|
307
|
+
properties: {
|
|
308
|
+
$schema: { type: "string" },
|
|
309
|
+
Id: {
|
|
310
|
+
type: "string",
|
|
311
|
+
description: "Animation id, to be unique in the project scope. Needs to be a valid JavaScript identifier."
|
|
312
|
+
},
|
|
313
|
+
Animations: {
|
|
314
|
+
type: "array",
|
|
315
|
+
description: "Declaration of animation states for gfx objects",
|
|
316
|
+
items: {
|
|
317
|
+
type: "object",
|
|
318
|
+
additionalProperties: false,
|
|
319
|
+
properties: {
|
|
320
|
+
_: {
|
|
321
|
+
type: "string",
|
|
322
|
+
description: "Comment"
|
|
323
|
+
},
|
|
324
|
+
Path: { $ref: "#/definitions/igxcPath" },
|
|
325
|
+
States: {
|
|
326
|
+
type: "object",
|
|
327
|
+
additionalProperties: {
|
|
328
|
+
type: "object",
|
|
329
|
+
additionalProperties: false,
|
|
330
|
+
properties: {
|
|
331
|
+
Position: { $ref: "#/definitions/vec3" },
|
|
332
|
+
Rotation: { $ref: "#/definitions/rotation" },
|
|
333
|
+
Scaling: { $ref: "#/definitions/vec3" },
|
|
334
|
+
Visibility: { type: "boolean" },
|
|
335
|
+
Deformation: { anyOf: [{ type: "number" }, { type: "string" }] }
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
},
|
|
342
|
+
Kinematics: { oneOf: [{ $ref: "#/definitions/kinematicChain" }, {
|
|
343
|
+
type: "array",
|
|
344
|
+
items: { $ref: "#/definitions/kinematicChain" }
|
|
345
|
+
}] },
|
|
346
|
+
LinkedPoints: {
|
|
347
|
+
type: "object",
|
|
348
|
+
additionalProperties: {
|
|
349
|
+
type: "array",
|
|
350
|
+
items: { type: "string" }
|
|
351
|
+
}
|
|
352
|
+
},
|
|
353
|
+
_: {
|
|
354
|
+
type: "string",
|
|
355
|
+
description: "Comment"
|
|
356
|
+
}
|
|
357
|
+
},
|
|
358
|
+
definitions: {
|
|
359
|
+
vec3: {
|
|
360
|
+
type: "object",
|
|
361
|
+
additionalProperties: false,
|
|
362
|
+
properties: {
|
|
363
|
+
X: { anyOf: [{ type: "number" }, { type: "string" }] },
|
|
364
|
+
Y: { anyOf: [{ type: "number" }, { type: "string" }] },
|
|
365
|
+
Z: { anyOf: [{ type: "number" }, { type: "string" }] },
|
|
366
|
+
_: {
|
|
367
|
+
type: "string",
|
|
368
|
+
description: "Comment"
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
},
|
|
372
|
+
rotation: {
|
|
373
|
+
type: "object",
|
|
374
|
+
additionalProperties: false,
|
|
375
|
+
properties: {
|
|
376
|
+
Q: {
|
|
377
|
+
description: "If true, the rotation is considered to be a Quaternion. Otherwise, it's interpreted as Euler arcs and W will be ignored.",
|
|
378
|
+
type: "boolean"
|
|
379
|
+
},
|
|
380
|
+
X: { anyOf: [{ type: "number" }, { type: "string" }] },
|
|
381
|
+
Y: { anyOf: [{ type: "number" }, { type: "string" }] },
|
|
382
|
+
Z: { anyOf: [{ type: "number" }, { type: "string" }] },
|
|
383
|
+
W: { anyOf: [{ type: "number" }, { type: "string" }] },
|
|
384
|
+
_: {
|
|
385
|
+
type: "string",
|
|
386
|
+
description: "Comment"
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
},
|
|
390
|
+
igxcPath: {
|
|
391
|
+
type: "string",
|
|
392
|
+
description: "Relative path of the target object",
|
|
393
|
+
pattern: "^((o|e)\\d+(\\.(o|e)\\d+)*|\\.)$"
|
|
394
|
+
},
|
|
395
|
+
param: {
|
|
396
|
+
type: "string",
|
|
397
|
+
pattern: "^Param\\d+$"
|
|
398
|
+
},
|
|
399
|
+
kinematicChain: {
|
|
400
|
+
type: "object",
|
|
401
|
+
additionalProperties: false,
|
|
402
|
+
properties: {
|
|
403
|
+
GeometryBase: { type: "string" },
|
|
404
|
+
Joints: {
|
|
405
|
+
type: "array",
|
|
406
|
+
items: {
|
|
407
|
+
type: "object",
|
|
408
|
+
additionalProperties: false,
|
|
409
|
+
properties: {
|
|
410
|
+
Name: { oneOf: [{ $ref: "#/definitions/param" }, { type: "string" }] },
|
|
411
|
+
HeadX: { oneOf: [{ $ref: "#/definitions/param" }, { $ref: "#/definitions/igxcPath" }] },
|
|
412
|
+
HeadY: { oneOf: [{ $ref: "#/definitions/param" }, { $ref: "#/definitions/igxcPath" }] },
|
|
413
|
+
HeadZ: { oneOf: [{ $ref: "#/definitions/param" }, { $ref: "#/definitions/igxcPath" }] },
|
|
414
|
+
Tail: { oneOf: [{ $ref: "#/definitions/param" }, { $ref: "#/definitions/igxcPath" }] },
|
|
415
|
+
LimitLeft: { type: "number" },
|
|
416
|
+
LimitRight: { type: "number" },
|
|
417
|
+
LimitUp: { type: "number" },
|
|
418
|
+
LimitDown: { type: "number" },
|
|
419
|
+
FollowJointNode: { $ref: "#/definitions/igxcPath" },
|
|
420
|
+
_TargetNodeForFollow: { type: "string" }
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
},
|
|
424
|
+
Target: { oneOf: [
|
|
425
|
+
{ $ref: "#/definitions/igxcPath" },
|
|
426
|
+
{ $ref: "#/definitions/param" },
|
|
427
|
+
{
|
|
428
|
+
type: "string",
|
|
429
|
+
enum: ["subbase"]
|
|
430
|
+
}
|
|
431
|
+
] },
|
|
432
|
+
Parent: { oneOf: [{ $ref: "#/definitions/igxcPath" }, {
|
|
433
|
+
type: "string",
|
|
434
|
+
enum: ["root"]
|
|
435
|
+
}] },
|
|
436
|
+
Tolerance: { type: "number" },
|
|
437
|
+
MaxIterations: { type: "integer" },
|
|
438
|
+
_: {
|
|
439
|
+
type: "string",
|
|
440
|
+
description: "Comment"
|
|
441
|
+
},
|
|
442
|
+
__: {
|
|
443
|
+
type: "string",
|
|
444
|
+
description: "Super Comment"
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
//#endregion
|
|
451
|
+
//#region src/commands/build/animations.ts
|
|
452
|
+
const createAnimationBuildParticipant = (location, manifest) => {
|
|
453
|
+
return (env) => {
|
|
454
|
+
env.onBuildStart();
|
|
455
|
+
bundleAnimations(location, manifest, env.log).then((result) => {
|
|
456
|
+
env.onBuildEnd({
|
|
457
|
+
type: "success",
|
|
458
|
+
artefacts: { js: result?.js ?? "" }
|
|
459
|
+
});
|
|
460
|
+
}).catch((err) => {
|
|
461
|
+
env.onBuildEnd({
|
|
462
|
+
type: "error",
|
|
463
|
+
error: err.message
|
|
464
|
+
});
|
|
465
|
+
});
|
|
466
|
+
return { destroy: () => {} };
|
|
467
|
+
};
|
|
468
|
+
};
|
|
469
|
+
const createAnimationWatchBuildParticipant = (location, manifest) => (env) => {
|
|
470
|
+
env.onBuildStart();
|
|
471
|
+
bundleAnimations(location, manifest, env.log).then((result) => {
|
|
472
|
+
env.onBuildEnd({
|
|
473
|
+
type: "success",
|
|
474
|
+
artefacts: { js: result?.js ?? "" }
|
|
475
|
+
});
|
|
476
|
+
}).catch((err) => {
|
|
477
|
+
env.onBuildEnd({
|
|
478
|
+
type: "error",
|
|
479
|
+
error: err.message
|
|
480
|
+
});
|
|
481
|
+
});
|
|
482
|
+
(async () => {
|
|
483
|
+
for await (const event of fs.watch(location.scriptsDir)) if (event.filename?.endsWith(".animation.json")) {
|
|
484
|
+
env.onBuildStart();
|
|
485
|
+
try {
|
|
486
|
+
const result = await bundleAnimations(location, manifest, env.log);
|
|
487
|
+
env.onBuildEnd({
|
|
488
|
+
type: "success",
|
|
489
|
+
artefacts: { js: result?.js ?? "" }
|
|
490
|
+
});
|
|
491
|
+
} catch (err) {
|
|
492
|
+
env.onBuildEnd({
|
|
493
|
+
type: "error",
|
|
494
|
+
error: err instanceof Error ? err : new Error(String(err))
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
})();
|
|
499
|
+
return { destroy: () => {} };
|
|
500
|
+
};
|
|
501
|
+
const bundleAnimations = async (location, manifest, logStep) => {
|
|
502
|
+
const animations = /* @__PURE__ */ new Map();
|
|
503
|
+
for (const scriptFilePath of readPackageAnimationList(location)) {
|
|
504
|
+
const content = await fs.readFile(scriptFilePath, { encoding: "utf8" });
|
|
505
|
+
let data;
|
|
506
|
+
try {
|
|
507
|
+
data = JSON.parse(content);
|
|
508
|
+
} catch (err) {
|
|
509
|
+
const relativePath = path.relative(location.path, scriptFilePath);
|
|
510
|
+
if (err instanceof SyntaxError) throw new Error(`Encountered invalid syntax in file "${relativePath}": ${String(err)}`);
|
|
511
|
+
throw new Error(`Encountered an unexpected error while parsing animation json file at path "${relativePath}"`, { cause: err });
|
|
512
|
+
}
|
|
513
|
+
if (!data.Id) {
|
|
514
|
+
const fileName = path.basename(scriptFilePath, ".animation.json");
|
|
515
|
+
data.Id = fileName;
|
|
516
|
+
}
|
|
517
|
+
(await getAnimationJsonValidation())(data);
|
|
518
|
+
delete data.$schema;
|
|
519
|
+
animations.set(data.Id, JSON.stringify(data));
|
|
520
|
+
}
|
|
521
|
+
if (animations.size > 0) {
|
|
522
|
+
const scope = manifest.Scope ?? manifest.Package;
|
|
523
|
+
let js = createNamespace(scope.split("."));
|
|
524
|
+
for (const [name, content] of animations) {
|
|
525
|
+
js += `${scope}["${name}"] = ` + content + ";";
|
|
526
|
+
logStep(`Adding animation ${scope}.${name}`);
|
|
527
|
+
}
|
|
528
|
+
return { js };
|
|
529
|
+
}
|
|
530
|
+
};
|
|
531
|
+
const createNamespace = (parts) => {
|
|
532
|
+
let code = `var ${parts[0]};`;
|
|
533
|
+
for (let index = 0; index < parts.length; index++) {
|
|
534
|
+
const path = parts.slice(0, index + 1).join(".");
|
|
535
|
+
code += `\n(${path} = ${path} || {});`;
|
|
536
|
+
}
|
|
537
|
+
return code;
|
|
538
|
+
};
|
|
539
|
+
let validateAnimationJson;
|
|
540
|
+
const getAnimationJsonValidation = async () => {
|
|
541
|
+
if (validateAnimationJson === void 0) validateAnimationJson = new Ajv({
|
|
542
|
+
coerceTypes: true,
|
|
543
|
+
allErrors: true,
|
|
544
|
+
removeAdditional: true,
|
|
545
|
+
useDefaults: "empty",
|
|
546
|
+
validateSchema: "log"
|
|
547
|
+
}).compile(animation_schema_default);
|
|
548
|
+
return validateAnimationJson;
|
|
549
|
+
};
|
|
550
|
+
//#endregion
|
|
551
|
+
//#region src/lib/packageVersion.ts
|
|
552
|
+
var PackageVersion = class PackageVersion {
|
|
553
|
+
static fullTextMatcher = /(\d+)(\.(\d+)(\.(\d+)(\.(\d+))?(-([^\.]+)\.(\d+))?)?)?/;
|
|
554
|
+
static lineMatcher = /^(\d+)(\.(\d+)(\.(\d+)(\.(\d+))?(-([^\.]+)\.(\d+))?)?)?$/;
|
|
555
|
+
static extractFromText(input, description) {
|
|
556
|
+
if (input === void 0) throw new Error(`Can not parse version from undefined`);
|
|
557
|
+
const match = input.match(PackageVersion.fullTextMatcher);
|
|
558
|
+
if (!match) throw new Error(`Could not extract a version from input: ${input}`);
|
|
559
|
+
return PackageVersion.fromMatch(match, description);
|
|
560
|
+
}
|
|
561
|
+
static extractFromLine(input, description) {
|
|
562
|
+
if (input === void 0) throw new Error(`Can not parse version from undefined`);
|
|
563
|
+
const match = input.match(PackageVersion.lineMatcher);
|
|
564
|
+
if (!match) throw new Error(`Could not parse version from input: ${input}`);
|
|
565
|
+
return PackageVersion.fromMatch(match, description);
|
|
566
|
+
}
|
|
567
|
+
static equals(a, b, checkPrerelease = false) {
|
|
568
|
+
if (a.major !== b.major || a.minor !== b.minor || a.patch !== b.patch) return false;
|
|
569
|
+
if (checkPrerelease === false) return true;
|
|
570
|
+
if (a.preRelease === b.preRelease) return true;
|
|
571
|
+
if (a.preRelease === void 0 || b.preRelease === void 0) return false;
|
|
572
|
+
return a.preRelease.type === b.preRelease.type && a.preRelease.version === b.preRelease.version;
|
|
573
|
+
}
|
|
574
|
+
static fromMatch([, major, , minor = "0", , patch = "0", , build, , preReleaseType, preReleaseNumber], description) {
|
|
575
|
+
let preRelease = void 0;
|
|
576
|
+
let buildNumber = 100;
|
|
577
|
+
if (preReleaseType && preReleaseNumber) preRelease = {
|
|
578
|
+
type: preReleaseType,
|
|
579
|
+
version: parseInt(preReleaseNumber)
|
|
580
|
+
};
|
|
581
|
+
if (build) buildNumber = Number(build);
|
|
582
|
+
else if (description) {
|
|
583
|
+
const descriptionMatch = description.match(/(\d+)\)$/);
|
|
584
|
+
if (descriptionMatch) buildNumber = parseInt(descriptionMatch[1]);
|
|
585
|
+
}
|
|
586
|
+
return new PackageVersion(parseInt(major), parseInt(minor), parseInt(patch), preRelease, buildNumber);
|
|
587
|
+
}
|
|
588
|
+
static sort(a, b, ascending = true) {
|
|
589
|
+
const createSortResult = (a, b) => ascending ? a - b : b - a;
|
|
590
|
+
if (a.major !== b.major) return createSortResult(a.major, b.major);
|
|
591
|
+
if (a.minor !== b.minor) return createSortResult(a.minor, b.minor);
|
|
592
|
+
if (a.patch !== b.patch) return createSortResult(a.patch, b.patch);
|
|
593
|
+
return createSortResult(a.preRelease ? a.preRelease.version : 0, b.preRelease ? b.preRelease.version : 0);
|
|
594
|
+
}
|
|
595
|
+
static toNumber(version) {
|
|
596
|
+
return ((version.major * 1e3 + version.minor) * 1e3 + version.patch) * 1e3 + version.buildNumber;
|
|
597
|
+
}
|
|
598
|
+
constructor(major, minor, patch, preRelease, buildNumber) {
|
|
599
|
+
this.major = major;
|
|
600
|
+
this.minor = minor;
|
|
601
|
+
this.patch = patch;
|
|
602
|
+
this.preRelease = preRelease;
|
|
603
|
+
this.buildNumber = buildNumber;
|
|
604
|
+
}
|
|
605
|
+
isPreRelease() {
|
|
606
|
+
return this.preRelease !== void 0;
|
|
607
|
+
}
|
|
608
|
+
clone() {
|
|
609
|
+
return new PackageVersion(this.major, this.minor, this.patch, this.preRelease ? { ...this.preRelease } : void 0, this.buildNumber);
|
|
610
|
+
}
|
|
611
|
+
incrementMajor() {
|
|
612
|
+
this.preRelease = void 0;
|
|
613
|
+
this.patch = 0;
|
|
614
|
+
this.minor = 0;
|
|
615
|
+
this.major++;
|
|
616
|
+
}
|
|
617
|
+
incrementMinor() {
|
|
618
|
+
this.preRelease = void 0;
|
|
619
|
+
this.patch = 0;
|
|
620
|
+
this.minor++;
|
|
621
|
+
}
|
|
622
|
+
incrementPatch() {
|
|
623
|
+
this.preRelease = void 0;
|
|
624
|
+
this.patch++;
|
|
625
|
+
}
|
|
626
|
+
createPreRelease(type) {
|
|
627
|
+
if (!this.preRelease) this.buildNumber = 1;
|
|
628
|
+
else this.buildNumber++;
|
|
629
|
+
if (this.preRelease && type === this.preRelease.type) {
|
|
630
|
+
this.preRelease.version++;
|
|
631
|
+
return;
|
|
632
|
+
}
|
|
633
|
+
this.preRelease = {
|
|
634
|
+
version: 0,
|
|
635
|
+
type
|
|
636
|
+
};
|
|
637
|
+
}
|
|
638
|
+
createRelease() {
|
|
639
|
+
this.preRelease = void 0;
|
|
640
|
+
this.buildNumber = 100;
|
|
641
|
+
}
|
|
642
|
+
toVersionString({ buildNumber } = {}) {
|
|
643
|
+
let version = [
|
|
644
|
+
this.major,
|
|
645
|
+
this.minor,
|
|
646
|
+
this.patch
|
|
647
|
+
].join(".");
|
|
648
|
+
if (buildNumber) version += "." + this.buildNumber;
|
|
649
|
+
if (this.preRelease) version += `-${this.preRelease.type}.${this.preRelease.version}`;
|
|
650
|
+
return version;
|
|
651
|
+
}
|
|
652
|
+
toDescriptionString(packageName) {
|
|
653
|
+
const base = [
|
|
654
|
+
this.major,
|
|
655
|
+
this.minor,
|
|
656
|
+
this.patch
|
|
657
|
+
].join(".");
|
|
658
|
+
const parts = [packageName, base];
|
|
659
|
+
if (this.preRelease) {
|
|
660
|
+
parts.push(upperCaseFirst(this.preRelease.type));
|
|
661
|
+
parts.push(this.preRelease.version);
|
|
662
|
+
}
|
|
663
|
+
parts.push(`(${base}.${this.buildNumber})`);
|
|
664
|
+
return parts.join(" ");
|
|
665
|
+
}
|
|
666
|
+
/**
|
|
667
|
+
* Determines wether the version is lesser than the input version
|
|
668
|
+
*
|
|
669
|
+
* @param {PackageVersion} version
|
|
670
|
+
* @returns
|
|
671
|
+
*/
|
|
672
|
+
isLesserThan(version) {
|
|
673
|
+
return PackageVersion.toNumber(this) < PackageVersion.toNumber(version);
|
|
674
|
+
}
|
|
675
|
+
/**
|
|
676
|
+
* Determines wether the version is greater than the input version
|
|
677
|
+
*
|
|
678
|
+
* @param {PackageVersion} version
|
|
679
|
+
* @returns
|
|
680
|
+
*/
|
|
681
|
+
isGreaterThan(version) {
|
|
682
|
+
return PackageVersion.toNumber(this) > PackageVersion.toNumber(version);
|
|
683
|
+
}
|
|
684
|
+
};
|
|
685
|
+
const upperCaseFirst = (input) => {
|
|
686
|
+
return input.slice(0, 1).toUpperCase() + input.slice(1);
|
|
687
|
+
};
|
|
688
|
+
//#endregion
|
|
689
|
+
//#region src/commands/build/index.ts
|
|
690
|
+
async function buildFolders(options) {
|
|
691
|
+
if (options.outDir !== void 0 && options.clean) await fs.rm(options.outDir, { recursive: true });
|
|
692
|
+
const baseReporter = options.reporter ?? consoleReporter;
|
|
693
|
+
const workspace = options.workspace;
|
|
694
|
+
const folders = options.packages;
|
|
695
|
+
let sortedPackages = sortPackagesByBuildOrder(folders);
|
|
696
|
+
let index = 1;
|
|
697
|
+
const manifests = new Map(sortedPackages.map((location) => [location, readPackageCreatorManifest(location)]));
|
|
698
|
+
const maxNameLength = Array.from(manifests.values(), (manifest) => manifest.Package.length).reduce((acc, length) => Math.max(acc, length), 0);
|
|
699
|
+
const managers = [];
|
|
700
|
+
for (const location of sortedPackages) {
|
|
701
|
+
const tsConfig = await ensureTsConfig(location);
|
|
702
|
+
const data = manifests.get(location);
|
|
703
|
+
const reporter = options.preparedReporter ?? createPackageScopedReporter(baseReporter, data.Package, index, folders.length, maxNameLength);
|
|
704
|
+
const outputDirectory = options.outDir || location.scriptsDir;
|
|
705
|
+
await fs.mkdir(outputDirectory, { recursive: true });
|
|
706
|
+
const manager = new BuildManager(data, (result) => writeBuildResult(result, data, location, workspace, outputDirectory, options.minimize, reporter), reporter);
|
|
707
|
+
if (options.banner) manager.addParticipant("banner", createBannerCommentBuildParticipant(options.banner));
|
|
708
|
+
const typescriptFiles = getPackageTypescriptFiles(location);
|
|
709
|
+
if (!typescriptFiles.some((file) => path.basename(file).toLowerCase() === "version.ts")) manager.addParticipant("version", createVersionLogBuildParticipant(data));
|
|
710
|
+
if (typescriptFiles.length > 0) if (isScriptPackageModules(tsConfig.options)) {
|
|
711
|
+
const { createRollupBuildParticipant } = await import("./rollup-Csyght27.js");
|
|
712
|
+
manager.addParticipant("rollup", createRollupBuildParticipant(location, data, outputDirectory, !tsConfig.options.declaration));
|
|
713
|
+
} else manager.addParticipant("tsc", createTSCBuildParticipant(location, outputDirectory, tsConfig.options.declaration === false));
|
|
714
|
+
manager.addParticipant("animation", createAnimationBuildParticipant(location, data));
|
|
715
|
+
await new Promise((resolve, reject) => {
|
|
716
|
+
manager.addListener("start", () => {
|
|
717
|
+
reporter.log(`Build started`);
|
|
718
|
+
});
|
|
719
|
+
manager.addListener("error", (error) => {
|
|
720
|
+
reject(error);
|
|
721
|
+
});
|
|
722
|
+
manager.addListener("build", () => {
|
|
723
|
+
reporter.log(`Build complete`);
|
|
724
|
+
resolve();
|
|
725
|
+
});
|
|
726
|
+
manager.run();
|
|
727
|
+
});
|
|
728
|
+
managers.push(manager);
|
|
729
|
+
if (options.docs) {
|
|
730
|
+
if (!options.docsHandler) throw new Error("Handler for typescript docs not available");
|
|
731
|
+
reporter.log("Generating typedoc documentation");
|
|
732
|
+
await options.docsHandler(location, path.join(outputDirectory, `${data.Package}.d.ts`), path.join(workspace.path, "docs", data.Package), data.Package);
|
|
733
|
+
}
|
|
734
|
+
index++;
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
async function buildFoldersWatch(options) {
|
|
738
|
+
if (options.outDir !== void 0 && options.clean) await fs.rm(options.outDir, { recursive: true });
|
|
739
|
+
const workspace = options.workspace;
|
|
740
|
+
const folders = options.packages;
|
|
741
|
+
options.reporter;
|
|
742
|
+
let sortedPackages = sortPackagesByBuildOrder(folders);
|
|
743
|
+
let index = 1;
|
|
744
|
+
const manifests = new Map(sortedPackages.map((location) => [location, readPackageCreatorManifest(location)]));
|
|
745
|
+
const maxNameLength = Array.from(manifests.values(), (manifest) => manifest.Package.length).reduce((acc, length) => Math.max(acc, length), 0);
|
|
746
|
+
const managers = [];
|
|
747
|
+
for (const location of sortedPackages) {
|
|
748
|
+
const tsConfig = await ensureTsConfig(location);
|
|
749
|
+
const baseReporter = options.reporter ?? consoleReporter;
|
|
750
|
+
const data = manifests.get(location);
|
|
751
|
+
const reporter = options.preparedReporter ?? createPackageScopedReporter(baseReporter, data.Package, index, folders.length, maxNameLength);
|
|
752
|
+
const outputDirectory = options.outDir || location.scriptsDir;
|
|
753
|
+
await fs.mkdir(outputDirectory, { recursive: true });
|
|
754
|
+
const manager = new BuildManager(data, (result) => writeBuildResult(result, data, location, workspace, outputDirectory, options.minimize, reporter), reporter);
|
|
755
|
+
if (options.banner) manager.addParticipant("banner", createBannerCommentBuildParticipant(options.banner));
|
|
756
|
+
const typescriptFiles = getPackageTypescriptFiles(location);
|
|
757
|
+
if (!typescriptFiles.some((file) => path.basename(file).toLowerCase() === "version.ts")) manager.addParticipant("version", createVersionLogBuildParticipant(data));
|
|
758
|
+
if (typescriptFiles.length > 0) if (isScriptPackageModules(tsConfig.options)) {
|
|
759
|
+
const { createRollupWatchBuildParticipant } = await import("./rollup-Csyght27.js");
|
|
760
|
+
manager.addParticipant("rollup", createRollupWatchBuildParticipant(location, data, outputDirectory, !tsConfig.options.declaration));
|
|
761
|
+
} else manager.addParticipant("tsc", createTSCWatchBuildParticipant(location, outputDirectory, tsConfig.options.declaration === false));
|
|
762
|
+
manager.addParticipant("animation", createAnimationWatchBuildParticipant(location, data));
|
|
763
|
+
await new Promise((resolve, reject) => {
|
|
764
|
+
manager.addListener("start", () => {
|
|
765
|
+
reporter.log(`Build started`);
|
|
766
|
+
});
|
|
767
|
+
manager.addListener("error", (error) => {
|
|
768
|
+
reporter.log(`Build failed: ${EOL}${error}`);
|
|
769
|
+
resolve();
|
|
770
|
+
});
|
|
771
|
+
manager.addListener("build", () => {
|
|
772
|
+
reporter.log(`Build complete`);
|
|
773
|
+
resolve();
|
|
774
|
+
});
|
|
775
|
+
manager.run();
|
|
776
|
+
});
|
|
777
|
+
managers.push(manager);
|
|
778
|
+
index++;
|
|
779
|
+
}
|
|
780
|
+
return { destroy: () => {
|
|
781
|
+
for (const manager of managers) manager.destroy();
|
|
782
|
+
} };
|
|
783
|
+
}
|
|
784
|
+
async function writeBuildResult(buildResult, manifest, location, workspace, outputDirectory, minimize, reporter) {
|
|
785
|
+
let js = buildResult.js;
|
|
786
|
+
if (buildResult.sourceMap) js += `\n//# sourceMappingURL=${manifest.Package}.js.map`;
|
|
787
|
+
await fs.writeFile(path.join(outputDirectory, `${manifest.Package}.js`), js, { encoding: "utf8" });
|
|
788
|
+
if (buildResult.declarations !== void 0) await fs.writeFile(path.join(outputDirectory, `${manifest.Package}.d.ts`), buildResult.declarations, { encoding: "utf8" });
|
|
789
|
+
if (buildResult.sourceMap !== void 0) await fs.writeFile(path.join(outputDirectory, `${manifest.Package}.js.map`), buildResult.sourceMap, { encoding: "utf8" });
|
|
790
|
+
if (minimize) {
|
|
791
|
+
reporter.log("Minifying the output");
|
|
792
|
+
const minifyResult = await terser.minify(js, {
|
|
793
|
+
ecma: 5,
|
|
794
|
+
sourceMap: {
|
|
795
|
+
content: buildResult.sourceMap,
|
|
796
|
+
includeSources: false
|
|
797
|
+
}
|
|
798
|
+
});
|
|
799
|
+
const minifiedPath = path.join(outputDirectory, `${manifest.Package}.min.js`);
|
|
800
|
+
let code = minifyResult.code;
|
|
801
|
+
if (minifyResult.map) code += `\n//# sourceMappingURL=${manifest.Package}.min.js.map`;
|
|
802
|
+
await fs.writeFile(minifiedPath, code, { encoding: "utf8" });
|
|
803
|
+
if (minifyResult.map !== void 0) await fs.writeFile(minifiedPath + ".map", typeof minifyResult.map === "string" ? minifyResult.map : JSON.stringify(minifyResult.map), { encoding: "utf8" });
|
|
804
|
+
}
|
|
805
|
+
if (location.path.includes("Basics") && buildResult.declarations !== void 0) {
|
|
806
|
+
await fs.mkdir(path.join(workspace.path, "lib"), { recursive: true });
|
|
807
|
+
reporter.log("Copying basics definition file to the lib folder");
|
|
808
|
+
await fs.writeFile(path.join(workspace.path, "lib", `${manifest.Package}.d.ts`), buildResult.declarations, { encoding: "utf8" });
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
function createVersionLogBuildParticipant(manifest) {
|
|
812
|
+
return (env) => {
|
|
813
|
+
env.onBuildStart();
|
|
814
|
+
const parsedVersion = manifest.Version !== void 0 ? PackageVersion.extractFromLine(manifest.Version) : void 0;
|
|
815
|
+
let logText;
|
|
816
|
+
if (parsedVersion !== void 0) logText = parsedVersion.toDescriptionString(manifest.Package);
|
|
817
|
+
else logText = manifest.Package;
|
|
818
|
+
logText += ".";
|
|
819
|
+
if (manifest.Copyright !== void 0) logText += " " + manifest.Copyright;
|
|
820
|
+
env.onBuildEnd({
|
|
821
|
+
type: "success",
|
|
822
|
+
artefacts: { js: `console.log(${JSON.stringify(logText)})` }
|
|
823
|
+
});
|
|
824
|
+
return { destroy: () => {} };
|
|
825
|
+
};
|
|
826
|
+
}
|
|
827
|
+
function createBannerCommentBuildParticipant(options) {
|
|
828
|
+
return (env) => {
|
|
829
|
+
env.onBuildStart();
|
|
830
|
+
const banner = createBannerComment(options);
|
|
831
|
+
env.onBuildEnd({
|
|
832
|
+
type: "success",
|
|
833
|
+
artefacts: {
|
|
834
|
+
js: banner ?? "",
|
|
835
|
+
declarations: banner ?? ""
|
|
836
|
+
}
|
|
837
|
+
});
|
|
838
|
+
return { destroy: () => {} };
|
|
839
|
+
};
|
|
840
|
+
}
|
|
841
|
+
async function ensureTsConfig(location) {
|
|
842
|
+
const tsconfigPath = path.join(location.scriptsDir, "tsconfig.json");
|
|
843
|
+
try {
|
|
844
|
+
const content = JSON.parse(await fs.readFile(tsconfigPath, "utf8"));
|
|
845
|
+
if (applyTsConfigOptions(content)) await fs.writeFile(tsconfigPath, JSON.stringify(content, void 0, " "), "utf8");
|
|
846
|
+
return ts.parseJsonConfigFileContent(content, ts.sys, location.scriptsDir);
|
|
847
|
+
} catch (err) {
|
|
848
|
+
if (!isErrorENOENT(err)) throw err;
|
|
849
|
+
const content = {};
|
|
850
|
+
applyTsConfigOptions(content);
|
|
851
|
+
await fs.writeFile(tsconfigPath, JSON.stringify(content, void 0, " "), "utf8");
|
|
852
|
+
return ts.parseJsonConfigFileContent(content, ts.sys, location.scriptsDir);
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
function applyTsConfigOptions(data) {
|
|
856
|
+
let expectedValues;
|
|
857
|
+
if (data.compilerOptions?.module?.toLowerCase().startsWith("es")) expectedValues = {
|
|
858
|
+
target: "esnext",
|
|
859
|
+
lib: ["es2024", "dom"],
|
|
860
|
+
module: "es2015",
|
|
861
|
+
moduleResolution: "node"
|
|
862
|
+
};
|
|
863
|
+
else expectedValues = {
|
|
864
|
+
target: "es5",
|
|
865
|
+
lib: ["es2018", "dom"]
|
|
866
|
+
};
|
|
867
|
+
data.compilerOptions = data.compilerOptions ?? {};
|
|
868
|
+
data.compilerOptions.strict ??= false;
|
|
869
|
+
const writeToOptions = data.compilerOptions;
|
|
870
|
+
let changed = false;
|
|
871
|
+
for (const [key, value] of Object.entries(expectedValues)) {
|
|
872
|
+
const currentValue = writeToOptions[key];
|
|
873
|
+
switch (typeof value) {
|
|
874
|
+
case "string":
|
|
875
|
+
case "number":
|
|
876
|
+
case "boolean":
|
|
877
|
+
if (value !== currentValue) {
|
|
878
|
+
changed = true;
|
|
879
|
+
writeToOptions[key] = value;
|
|
880
|
+
}
|
|
881
|
+
break;
|
|
882
|
+
case "object":
|
|
883
|
+
if (Array.isArray(value) && (!Array.isArray(currentValue) || value.length !== currentValue.length || value.some((item, index) => item !== currentValue[index]))) {
|
|
884
|
+
changed = true;
|
|
885
|
+
writeToOptions[key] = value;
|
|
886
|
+
}
|
|
887
|
+
break;
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
return changed;
|
|
891
|
+
}
|
|
892
|
+
function sortPackagesByBuildOrder(folders) {
|
|
893
|
+
const packages = Array.from(folders).reduce((acc, location) => {
|
|
894
|
+
const data = readPackageNpmManifest(location);
|
|
895
|
+
if (data !== void 0) acc[data.name] = {
|
|
896
|
+
data,
|
|
897
|
+
location
|
|
898
|
+
};
|
|
899
|
+
else acc[location.path] = {
|
|
900
|
+
data: void 0,
|
|
901
|
+
location
|
|
902
|
+
};
|
|
903
|
+
return acc;
|
|
904
|
+
}, {});
|
|
905
|
+
const sortedPackages = toposort(Object.getOwnPropertyNames(packages).reduce((acc, packageName) => {
|
|
906
|
+
const packageData = packages[packageName];
|
|
907
|
+
if (packageData.data === void 0) acc[packageName] = [];
|
|
908
|
+
else acc[packageName] = Object.getOwnPropertyNames({
|
|
909
|
+
...packageData.data.devDependencies,
|
|
910
|
+
...packageData.data.dependencies,
|
|
911
|
+
...packageData.data.peerDependencies
|
|
912
|
+
}).filter((packageName) => packages[packageName] !== void 0);
|
|
913
|
+
return acc;
|
|
914
|
+
}, {}));
|
|
915
|
+
const result = [];
|
|
916
|
+
for (const packageName of sortedPackages) {
|
|
917
|
+
const location = packages[packageName].location;
|
|
918
|
+
if (readPackageCreatorManifest(location).Package.endsWith(".Basics")) result.unshift(location);
|
|
919
|
+
else result.push(location);
|
|
920
|
+
}
|
|
921
|
+
return result;
|
|
922
|
+
}
|
|
923
|
+
function createBannerComment(banner) {
|
|
924
|
+
const bannerParts = [];
|
|
925
|
+
if (banner.text) bannerParts.push(" * " + banner.text);
|
|
926
|
+
{
|
|
927
|
+
const details = [];
|
|
928
|
+
if (banner.version) details.push(`Version: ${banner.version}`);
|
|
929
|
+
if (banner.commit) if (banner.commitDirty) details.push(`Commit: ${banner.commit} (dirty)`);
|
|
930
|
+
else details.push(`Commit: ${banner.commit}`);
|
|
931
|
+
if (banner.date) details.push(`Date: ${banner.date.toISOString()}`);
|
|
932
|
+
const detailsText = details.map((line) => ` * ${line}`).join("\n");
|
|
933
|
+
if (detailsText) bannerParts.push(detailsText);
|
|
934
|
+
}
|
|
935
|
+
const bannerText = bannerParts.join("\n\n");
|
|
936
|
+
if (bannerText) return `/*
|
|
937
|
+
${bannerText}
|
|
938
|
+
*
|
|
939
|
+
* @preserve
|
|
940
|
+
*/`;
|
|
941
|
+
}
|
|
942
|
+
//#endregion
|
|
943
|
+
export { buildFolders, buildFoldersWatch, PackageVersion as t };
|
|
944
|
+
|
|
945
|
+
//# sourceMappingURL=build-CMbCj7x-.js.map
|