@intelligentgraphics/ig.gfx.packager 3.0.20 → 3.0.22
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.mjs +1 -1
- package/build/{cli-c7da3faf.mjs → cli-f6586dd5.mjs} +91 -93
- package/build/cli-f6586dd5.mjs.map +1 -0
- package/build/{dependencies-93832b40.mjs → dependencies-e2aa1797.mjs} +2 -2
- package/build/{dependencies-93832b40.mjs.map → dependencies-e2aa1797.mjs.map} +1 -1
- package/build/{generateIndex-056000f0.mjs → generateIndex-019c6946.mjs} +3 -3
- package/build/{generateIndex-056000f0.mjs.map → generateIndex-019c6946.mjs.map} +1 -1
- package/build/{generateParameterType-8584bc43.mjs → generateParameterType-ae69726a.mjs} +4 -4
- package/build/{generateParameterType-8584bc43.mjs.map → generateParameterType-ae69726a.mjs.map} +1 -1
- package/build/{index-41cb0257.mjs → index-39c79102.mjs} +18 -19
- package/build/index-39c79102.mjs.map +1 -0
- package/build/index-3d1291e7.mjs +1120 -0
- package/build/index-3d1291e7.mjs.map +1 -0
- package/build/{postinstall-eb863946.mjs → postinstall-3328545c.mjs} +3 -3
- package/build/{postinstall-eb863946.mjs.map → postinstall-3328545c.mjs.map} +1 -1
- package/build/{publishNpm-0af8ba37.mjs → publishNpm-532e17a0.mjs} +12 -6
- package/build/publishNpm-532e17a0.mjs.map +1 -0
- package/build/scripts-7ed8dff6.mjs.map +1 -1
- package/build/{versionFile-4f3df7f1.mjs → versionFile-644c7ff8.mjs} +6 -10
- package/build/{versionFile-4f3df7f1.mjs.map → versionFile-644c7ff8.mjs.map} +1 -1
- package/lib/lib.mjs +581 -175
- package/package.json +7 -6
- package/readme.md +11 -0
- package/build/cli-c7da3faf.mjs.map +0 -1
- package/build/index-41cb0257.mjs.map +0 -1
- package/build/index-7d81fa31.mjs +0 -706
- package/build/index-7d81fa31.mjs.map +0 -1
- package/build/publishNpm-0af8ba37.mjs.map +0 -1
|
@@ -0,0 +1,1120 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import * as fs$1 from 'fs/promises';
|
|
3
|
+
import * as terser from 'terser';
|
|
4
|
+
import * as fs from 'fs';
|
|
5
|
+
import 'resolve';
|
|
6
|
+
import 'write-pkg';
|
|
7
|
+
import { c as readPackageAnimationList, r as readPackageCreatorManifest, i as isErrorENOENT, q as readPackageNpmManifest } from './cli-f6586dd5.mjs';
|
|
8
|
+
import glob from 'glob';
|
|
9
|
+
import 'node:path';
|
|
10
|
+
import 'node:fs';
|
|
11
|
+
import 'axios';
|
|
12
|
+
import ts from 'typescript';
|
|
13
|
+
import { g as getPackageTypescriptFiles } from './scripts-7ed8dff6.mjs';
|
|
14
|
+
import typedoc from 'typedoc';
|
|
15
|
+
import require$$2 from 'events';
|
|
16
|
+
import { SourceMapGenerator, SourceMapConsumer } from 'source-map-js';
|
|
17
|
+
import Ajv from 'ajv';
|
|
18
|
+
|
|
19
|
+
const logPackageMessage = (name, step, index, total, maxNameLength = 15)=>{
|
|
20
|
+
const numLength = total === undefined ? undefined : total.toString().length;
|
|
21
|
+
const indexString = total === undefined || total < 2 ? "" : `${index.toString().padStart(numLength, "0")}/${total} `;
|
|
22
|
+
const identifierString = `${indexString}${name.padEnd(maxNameLength)}`;
|
|
23
|
+
console.log(`${identifierString} >> ${step}`);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const tryReadTsConfig = (location)=>{
|
|
27
|
+
const { config } = ts.readConfigFile(path.join(location.scriptsDir, "tsconfig.json"), (path)=>{
|
|
28
|
+
try {
|
|
29
|
+
return fs.readFileSync(path, "utf8");
|
|
30
|
+
} catch {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
return config;
|
|
35
|
+
};
|
|
36
|
+
const createTSCBuildParticipant = (location, outputDir)=>(env)=>{
|
|
37
|
+
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
|
+
try {
|
|
52
|
+
env.onBuildStart();
|
|
53
|
+
env.log("Compiling typescript files");
|
|
54
|
+
const compilerOptions = getCompilerOptions(location, outputDir);
|
|
55
|
+
const host = ts.createCompilerHost(compilerOptions);
|
|
56
|
+
host.getCurrentDirectory = ()=>location.scriptsDir;
|
|
57
|
+
let js;
|
|
58
|
+
let definitions;
|
|
59
|
+
let sourceMap;
|
|
60
|
+
host.writeFile = (fileName, data, writeByteOrderMark)=>{
|
|
61
|
+
if (fileName.endsWith(".js")) {
|
|
62
|
+
js = data;
|
|
63
|
+
} else if (fileName.endsWith(".d.ts")) {
|
|
64
|
+
definitions = data;
|
|
65
|
+
} else if (fileName.endsWith(".js.map")) {
|
|
66
|
+
sourceMap = data;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const programOptions = {
|
|
70
|
+
rootNames: files,
|
|
71
|
+
options: compilerOptions,
|
|
72
|
+
host
|
|
73
|
+
};
|
|
74
|
+
const program = ts.createProgram(programOptions);
|
|
75
|
+
const emitResult = program.emit();
|
|
76
|
+
const allDiagnostics = ts.getPreEmitDiagnostics(program);
|
|
77
|
+
if (!emitResult.emitSkipped) {
|
|
78
|
+
if (allDiagnostics.length > 0) {
|
|
79
|
+
console.log(allDiagnostics.map(createErrorMessage).join("\n"));
|
|
80
|
+
}
|
|
81
|
+
if (js === undefined || definitions === undefined) {
|
|
82
|
+
throw new Error(`Unexpected: no js or definitions were created`);
|
|
83
|
+
}
|
|
84
|
+
env.onBuildEnd({
|
|
85
|
+
type: "success",
|
|
86
|
+
artefacts: {
|
|
87
|
+
js: js.replace(`//# sourceMappingURL=out.js.map`, ""),
|
|
88
|
+
definitions,
|
|
89
|
+
sourceMap
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
} else {
|
|
93
|
+
const error = allDiagnostics.map(createErrorMessage).join("\n");
|
|
94
|
+
throw new Error(error);
|
|
95
|
+
}
|
|
96
|
+
} catch (err) {
|
|
97
|
+
env.onBuildEnd({
|
|
98
|
+
type: "error",
|
|
99
|
+
error: err.message
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
destroy: ()=>{}
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
const createTSCWatchBuildParticipant = (location, outputDir)=>{
|
|
107
|
+
return ({ onBuildStart, onBuildEnd })=>{
|
|
108
|
+
let state = {
|
|
109
|
+
diagnostics: [],
|
|
110
|
+
js: undefined,
|
|
111
|
+
definitions: undefined,
|
|
112
|
+
sourceMap: undefined
|
|
113
|
+
};
|
|
114
|
+
const customSys = {
|
|
115
|
+
...ts.sys,
|
|
116
|
+
writeFile: (fileName, data, writeByteOrderMark)=>{
|
|
117
|
+
if (fileName.endsWith(".js")) {
|
|
118
|
+
state.js = data;
|
|
119
|
+
} else if (fileName.endsWith(".d.ts")) {
|
|
120
|
+
state.definitions = data;
|
|
121
|
+
} else if (fileName.endsWith(".js.map")) {
|
|
122
|
+
state.sourceMap = data;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
const reportDiagnostic = (diagnostic)=>{
|
|
127
|
+
switch(diagnostic.code){
|
|
128
|
+
// file not found - https://github.com/microsoft/TypeScript/blob/93e6b9da0c4cb164ca90a5a1b07415e81e97f2b1/src/compiler/diagnosticMessages.json#L4640
|
|
129
|
+
// probably deleted -> ignore
|
|
130
|
+
case 6053:
|
|
131
|
+
return;
|
|
132
|
+
// no inputs were found - https://github.com/microsoft/TypeScript/blob/93e6b9da0c4cb164ca90a5a1b07415e81e97f2b1/src/compiler/diagnosticMessages.json#L6838
|
|
133
|
+
// we don't care about this error. a user might have temporarily deleted the last ts file and will readd one later.
|
|
134
|
+
case 18003:
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
state.diagnostics.push(diagnostic);
|
|
138
|
+
};
|
|
139
|
+
const reportWatchStatusChanged = (diagnostic)=>{
|
|
140
|
+
switch(diagnostic.code){
|
|
141
|
+
// regular watch mode - https://github.com/microsoft/TypeScript/blob/93e6b9da0c4cb164ca90a5a1b07415e81e97f2b1/src/compiler/diagnosticMessages.json#L4567
|
|
142
|
+
case 6031:
|
|
143
|
+
// incremental watch mode - https://github.com/microsoft/TypeScript/blob/93e6b9da0c4cb164ca90a5a1b07415e81e97f2b1/src/compiler/diagnosticMessages.json#L4571
|
|
144
|
+
case 6032:
|
|
145
|
+
// build start
|
|
146
|
+
onBuildStart();
|
|
147
|
+
break;
|
|
148
|
+
// found one error - https://github.com/microsoft/TypeScript/blob/93e6b9da0c4cb164ca90a5a1b07415e81e97f2b1/src/compiler/diagnosticMessages.json#L5119
|
|
149
|
+
case 6193:
|
|
150
|
+
// found n or 0 errors - https://github.com/microsoft/TypeScript/blob/93e6b9da0c4cb164ca90a5a1b07415e81e97f2b1/src/compiler/diagnosticMessages.json#L5123
|
|
151
|
+
case 6194:
|
|
152
|
+
// build end
|
|
153
|
+
const emitState = state;
|
|
154
|
+
state = {
|
|
155
|
+
diagnostics: [],
|
|
156
|
+
js: undefined,
|
|
157
|
+
definitions: undefined,
|
|
158
|
+
sourceMap: undefined
|
|
159
|
+
};
|
|
160
|
+
if (emitState.diagnostics.length > 0) {
|
|
161
|
+
const message = emitState.diagnostics.map(createErrorMessage).join("\n");
|
|
162
|
+
onBuildEnd({
|
|
163
|
+
type: "error",
|
|
164
|
+
error: message
|
|
165
|
+
});
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
if (emitState.js === undefined || emitState.definitions === undefined) {
|
|
169
|
+
onBuildEnd({
|
|
170
|
+
type: "success",
|
|
171
|
+
artefacts: {
|
|
172
|
+
js: ""
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
onBuildEnd({
|
|
178
|
+
type: "success",
|
|
179
|
+
artefacts: {
|
|
180
|
+
js: emitState.js.replace(`//# sourceMappingURL=out.js.map`, ""),
|
|
181
|
+
definitions: emitState.definitions,
|
|
182
|
+
sourceMap: emitState.sourceMap
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
const host = ts.createWatchCompilerHost(path.join(location.scriptsDir, "tsconfig.json"), getCompilerOptions(location, outputDir), customSys, ts.createSemanticDiagnosticsBuilderProgram, reportDiagnostic, reportWatchStatusChanged);
|
|
189
|
+
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
|
+
return {
|
|
202
|
+
destroy: ()=>{
|
|
203
|
+
watchProgram.close();
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
};
|
|
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)=>{
|
|
217
|
+
const config = tryReadTsConfig(location);
|
|
218
|
+
config.compilerOptions.lib = [
|
|
219
|
+
"es5",
|
|
220
|
+
"dom"
|
|
221
|
+
];
|
|
222
|
+
const result = ts.convertCompilerOptionsFromJson(config.compilerOptions, location.scriptsDir);
|
|
223
|
+
const compilerOptions = {
|
|
224
|
+
...result.options,
|
|
225
|
+
removeComments: false,
|
|
226
|
+
declaration: true,
|
|
227
|
+
sourceMap: true,
|
|
228
|
+
inlineSources: false,
|
|
229
|
+
// We don't use tsc to actually emit the files, but we still need to set the correct
|
|
230
|
+
// output directory so the compiler can rewrite the `reference path` directives.
|
|
231
|
+
outFile: path.join(outputDir, "out.js"),
|
|
232
|
+
target: ts.ScriptTarget.ES5,
|
|
233
|
+
noEmitOnError: true
|
|
234
|
+
};
|
|
235
|
+
return compilerOptions;
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
const generateDocs = async (location, declarationFile, outFolder, name)=>{
|
|
239
|
+
const app = new typedoc.Application();
|
|
240
|
+
const mediaDir = path.join(location.manifestDir, "Media");
|
|
241
|
+
app.bootstrap({
|
|
242
|
+
entryPoints: [
|
|
243
|
+
declarationFile
|
|
244
|
+
],
|
|
245
|
+
media: mediaDir,
|
|
246
|
+
out: outFolder,
|
|
247
|
+
tsconfig: path.join(location.scriptsDir, "tsconfig.json"),
|
|
248
|
+
skipErrorChecking: true
|
|
249
|
+
});
|
|
250
|
+
app.options.setCompilerOptions([
|
|
251
|
+
declarationFile
|
|
252
|
+
], {
|
|
253
|
+
target: ts.ScriptTarget.ES5
|
|
254
|
+
}, undefined);
|
|
255
|
+
app.options.setValue("name", name);
|
|
256
|
+
const [readmePath] = glob.sync("**/readme.md", {
|
|
257
|
+
absolute: true,
|
|
258
|
+
cwd: location.manifestDir
|
|
259
|
+
});
|
|
260
|
+
if (readmePath) {
|
|
261
|
+
app.options.setValue("readme", readmePath);
|
|
262
|
+
}
|
|
263
|
+
const project = app.convert();
|
|
264
|
+
if (project) {
|
|
265
|
+
await app.generateDocs(project, outFolder);
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
// Stolen from ig.tools.core
|
|
270
|
+
const toposort = (packages)=>{
|
|
271
|
+
const queue = Object.getOwnPropertyNames(packages);
|
|
272
|
+
const result = [];
|
|
273
|
+
let index = 0;
|
|
274
|
+
while(queue.length > 0){
|
|
275
|
+
if (index >= queue.length) {
|
|
276
|
+
throw new Error("Packages can not have cyclic dependencies");
|
|
277
|
+
}
|
|
278
|
+
const queueEntry = queue[index];
|
|
279
|
+
const dependencies = packages[queueEntry];
|
|
280
|
+
const dependencyQueued = dependencies.some((dependency)=>queue.includes(dependency));
|
|
281
|
+
if (dependencyQueued) {
|
|
282
|
+
index++;
|
|
283
|
+
continue;
|
|
284
|
+
}
|
|
285
|
+
queue.splice(index, 1);
|
|
286
|
+
index = 0;
|
|
287
|
+
result.push(queueEntry);
|
|
288
|
+
}
|
|
289
|
+
return result;
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
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();
|
|
300
|
+
}
|
|
301
|
+
addParticipant(name, participant) {
|
|
302
|
+
this.participants.set(name, participant);
|
|
303
|
+
}
|
|
304
|
+
run() {
|
|
305
|
+
for (const [name] of this.participants){
|
|
306
|
+
this.states.set(name, {
|
|
307
|
+
type: "busy"
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
this.emit("start");
|
|
311
|
+
for (const [name, participant] of this.participants){
|
|
312
|
+
participant({
|
|
313
|
+
onBuildStart: ()=>{
|
|
314
|
+
let alreadyBusy = false;
|
|
315
|
+
for (const [name, state] of this.states){
|
|
316
|
+
if (state.type === "busy") {
|
|
317
|
+
alreadyBusy = true;
|
|
318
|
+
continue;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
this.states.set(name, {
|
|
322
|
+
type: "busy"
|
|
323
|
+
});
|
|
324
|
+
if (!alreadyBusy) {
|
|
325
|
+
this.emit("start");
|
|
326
|
+
}
|
|
327
|
+
},
|
|
328
|
+
onBuildEnd: (result)=>{
|
|
329
|
+
this.states.set(name, result);
|
|
330
|
+
this.maybeEmit();
|
|
331
|
+
},
|
|
332
|
+
log: this.logStep
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
maybeEmit() {
|
|
337
|
+
const errors = [];
|
|
338
|
+
const results = [];
|
|
339
|
+
for (const [_, state] of this.states){
|
|
340
|
+
if (state.type === "busy") {
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
if (state.type === "success") {
|
|
344
|
+
results.push(state);
|
|
345
|
+
} else if (state.type === "error") {
|
|
346
|
+
errors.push(state.error);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
if (errors.length > 0) {
|
|
350
|
+
this.emit("error", errors.join("\n"));
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
const completeResult = {
|
|
354
|
+
js: ""
|
|
355
|
+
};
|
|
356
|
+
const sourceMapGenerator = new SourceMapGenerator();
|
|
357
|
+
for (const result of results){
|
|
358
|
+
if (result.artefacts.js) {
|
|
359
|
+
if (completeResult.js) {
|
|
360
|
+
completeResult.js += "\n";
|
|
361
|
+
}
|
|
362
|
+
if (result.artefacts.sourceMap) {
|
|
363
|
+
const lines = completeResult.js.split("\n").length - 1;
|
|
364
|
+
const sourceMap = new SourceMapConsumer(JSON.parse(result.artefacts.sourceMap));
|
|
365
|
+
const sources = new Set();
|
|
366
|
+
sourceMap.eachMapping((mapping)=>{
|
|
367
|
+
sourceMapGenerator.addMapping({
|
|
368
|
+
generated: {
|
|
369
|
+
line: lines + mapping.generatedLine,
|
|
370
|
+
column: mapping.generatedColumn
|
|
371
|
+
},
|
|
372
|
+
original: {
|
|
373
|
+
line: mapping.originalLine,
|
|
374
|
+
column: mapping.originalColumn
|
|
375
|
+
},
|
|
376
|
+
source: mapping.source,
|
|
377
|
+
name: mapping.name
|
|
378
|
+
});
|
|
379
|
+
sources.add(mapping.source);
|
|
380
|
+
});
|
|
381
|
+
for (const source of sources){
|
|
382
|
+
const content = sourceMap.sourceContentFor(source);
|
|
383
|
+
if (content !== null) {
|
|
384
|
+
sourceMapGenerator.setSourceContent(source, content);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
completeResult.js += result.artefacts.js;
|
|
389
|
+
}
|
|
390
|
+
if (result.artefacts.definitions) {
|
|
391
|
+
if (completeResult.definitions) {
|
|
392
|
+
completeResult.definitions += "\n";
|
|
393
|
+
} else {
|
|
394
|
+
completeResult.definitions = "";
|
|
395
|
+
}
|
|
396
|
+
completeResult.definitions += result.artefacts.definitions;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
completeResult.sourceMap = sourceMapGenerator.toString();
|
|
400
|
+
this.writer(completeResult).then(()=>{
|
|
401
|
+
this.emit("build");
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
var animationSchema = {
|
|
407
|
+
$schema: "http://json-schema.org/draft-07/schema",
|
|
408
|
+
$id: "https://archive.intelligentgraphics.biz/schemas/gfx/animation.json",
|
|
409
|
+
$comment: "Version 2023-02-17, Source: ig.data.gfx/Specs/animation.json",
|
|
410
|
+
title: "Animation description format",
|
|
411
|
+
additionalProperties: false,
|
|
412
|
+
type: "object",
|
|
413
|
+
properties: {
|
|
414
|
+
$schema: {
|
|
415
|
+
type: "string"
|
|
416
|
+
},
|
|
417
|
+
Id: {
|
|
418
|
+
type: "string",
|
|
419
|
+
description: "Animation id, to be unique in the project scope. Needs to be a valid JavaScript identifier."
|
|
420
|
+
},
|
|
421
|
+
Animations: {
|
|
422
|
+
type: "array",
|
|
423
|
+
description: "Declaration of animation states for gfx objects",
|
|
424
|
+
items: {
|
|
425
|
+
type: "object",
|
|
426
|
+
additionalProperties: false,
|
|
427
|
+
properties: {
|
|
428
|
+
_: {
|
|
429
|
+
type: "string",
|
|
430
|
+
description: "Comment"
|
|
431
|
+
},
|
|
432
|
+
Path: {
|
|
433
|
+
$ref: "#/definitions/igxcPath"
|
|
434
|
+
},
|
|
435
|
+
States: {
|
|
436
|
+
type: "object",
|
|
437
|
+
additionalProperties: {
|
|
438
|
+
type: "object",
|
|
439
|
+
additionalProperties: false,
|
|
440
|
+
properties: {
|
|
441
|
+
Position: {
|
|
442
|
+
$ref: "#/definitions/vec3"
|
|
443
|
+
},
|
|
444
|
+
Rotation: {
|
|
445
|
+
$ref: "#/definitions/rotation"
|
|
446
|
+
},
|
|
447
|
+
Scaling: {
|
|
448
|
+
$ref: "#/definitions/vec3"
|
|
449
|
+
},
|
|
450
|
+
Visibility: {
|
|
451
|
+
type: "boolean"
|
|
452
|
+
},
|
|
453
|
+
Deformation: {
|
|
454
|
+
anyOf: [
|
|
455
|
+
{
|
|
456
|
+
type: "number"
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
type: "string"
|
|
460
|
+
}
|
|
461
|
+
]
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
},
|
|
469
|
+
Kinematics: {
|
|
470
|
+
oneOf: [
|
|
471
|
+
{
|
|
472
|
+
$ref: "#/definitions/kinematicChain"
|
|
473
|
+
},
|
|
474
|
+
{
|
|
475
|
+
type: "array",
|
|
476
|
+
items: {
|
|
477
|
+
$ref: "#/definitions/kinematicChain"
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
]
|
|
481
|
+
},
|
|
482
|
+
LinkedPoints: {
|
|
483
|
+
type: "object",
|
|
484
|
+
additionalProperties: {
|
|
485
|
+
type: "array",
|
|
486
|
+
items: {
|
|
487
|
+
type: "string"
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
},
|
|
491
|
+
_: {
|
|
492
|
+
type: "string",
|
|
493
|
+
description: "Comment"
|
|
494
|
+
}
|
|
495
|
+
},
|
|
496
|
+
definitions: {
|
|
497
|
+
vec3: {
|
|
498
|
+
type: "object",
|
|
499
|
+
additionalProperties: false,
|
|
500
|
+
properties: {
|
|
501
|
+
X: {
|
|
502
|
+
anyOf: [
|
|
503
|
+
{
|
|
504
|
+
type: "number"
|
|
505
|
+
},
|
|
506
|
+
{
|
|
507
|
+
type: "string"
|
|
508
|
+
}
|
|
509
|
+
]
|
|
510
|
+
},
|
|
511
|
+
Y: {
|
|
512
|
+
anyOf: [
|
|
513
|
+
{
|
|
514
|
+
type: "number"
|
|
515
|
+
},
|
|
516
|
+
{
|
|
517
|
+
type: "string"
|
|
518
|
+
}
|
|
519
|
+
]
|
|
520
|
+
},
|
|
521
|
+
Z: {
|
|
522
|
+
anyOf: [
|
|
523
|
+
{
|
|
524
|
+
type: "number"
|
|
525
|
+
},
|
|
526
|
+
{
|
|
527
|
+
type: "string"
|
|
528
|
+
}
|
|
529
|
+
]
|
|
530
|
+
},
|
|
531
|
+
_: {
|
|
532
|
+
type: "string",
|
|
533
|
+
description: "Comment"
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
},
|
|
537
|
+
rotation: {
|
|
538
|
+
type: "object",
|
|
539
|
+
additionalProperties: false,
|
|
540
|
+
properties: {
|
|
541
|
+
Q: {
|
|
542
|
+
description: "If true, the rotation is considered to be a Quaternion. Otherwise, it's interpreted as Euler arcs and W will be ignored.",
|
|
543
|
+
type: "boolean"
|
|
544
|
+
},
|
|
545
|
+
X: {
|
|
546
|
+
anyOf: [
|
|
547
|
+
{
|
|
548
|
+
type: "number"
|
|
549
|
+
},
|
|
550
|
+
{
|
|
551
|
+
type: "string"
|
|
552
|
+
}
|
|
553
|
+
]
|
|
554
|
+
},
|
|
555
|
+
Y: {
|
|
556
|
+
anyOf: [
|
|
557
|
+
{
|
|
558
|
+
type: "number"
|
|
559
|
+
},
|
|
560
|
+
{
|
|
561
|
+
type: "string"
|
|
562
|
+
}
|
|
563
|
+
]
|
|
564
|
+
},
|
|
565
|
+
Z: {
|
|
566
|
+
anyOf: [
|
|
567
|
+
{
|
|
568
|
+
type: "number"
|
|
569
|
+
},
|
|
570
|
+
{
|
|
571
|
+
type: "string"
|
|
572
|
+
}
|
|
573
|
+
]
|
|
574
|
+
},
|
|
575
|
+
W: {
|
|
576
|
+
anyOf: [
|
|
577
|
+
{
|
|
578
|
+
type: "number"
|
|
579
|
+
},
|
|
580
|
+
{
|
|
581
|
+
type: "string"
|
|
582
|
+
}
|
|
583
|
+
]
|
|
584
|
+
},
|
|
585
|
+
_: {
|
|
586
|
+
type: "string",
|
|
587
|
+
description: "Comment"
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
},
|
|
591
|
+
igxcPath: {
|
|
592
|
+
type: "string",
|
|
593
|
+
description: "Relative path of the target object",
|
|
594
|
+
pattern: "^((o|e)\\d+(\\.(o|e)\\d+)*|\\.)$"
|
|
595
|
+
},
|
|
596
|
+
param: {
|
|
597
|
+
type: "string",
|
|
598
|
+
pattern: "^Param\\d+$"
|
|
599
|
+
},
|
|
600
|
+
kinematicChain: {
|
|
601
|
+
type: "object",
|
|
602
|
+
additionalProperties: false,
|
|
603
|
+
properties: {
|
|
604
|
+
GeometryBase: {
|
|
605
|
+
type: "string"
|
|
606
|
+
},
|
|
607
|
+
Joints: {
|
|
608
|
+
type: "array",
|
|
609
|
+
items: {
|
|
610
|
+
type: "object",
|
|
611
|
+
additionalProperties: false,
|
|
612
|
+
properties: {
|
|
613
|
+
Name: {
|
|
614
|
+
oneOf: [
|
|
615
|
+
{
|
|
616
|
+
$ref: "#/definitions/param"
|
|
617
|
+
},
|
|
618
|
+
{
|
|
619
|
+
type: "string"
|
|
620
|
+
}
|
|
621
|
+
]
|
|
622
|
+
},
|
|
623
|
+
HeadX: {
|
|
624
|
+
oneOf: [
|
|
625
|
+
{
|
|
626
|
+
$ref: "#/definitions/param"
|
|
627
|
+
},
|
|
628
|
+
{
|
|
629
|
+
$ref: "#/definitions/igxcPath"
|
|
630
|
+
}
|
|
631
|
+
]
|
|
632
|
+
},
|
|
633
|
+
HeadY: {
|
|
634
|
+
oneOf: [
|
|
635
|
+
{
|
|
636
|
+
$ref: "#/definitions/param"
|
|
637
|
+
},
|
|
638
|
+
{
|
|
639
|
+
$ref: "#/definitions/igxcPath"
|
|
640
|
+
}
|
|
641
|
+
]
|
|
642
|
+
},
|
|
643
|
+
HeadZ: {
|
|
644
|
+
oneOf: [
|
|
645
|
+
{
|
|
646
|
+
$ref: "#/definitions/param"
|
|
647
|
+
},
|
|
648
|
+
{
|
|
649
|
+
$ref: "#/definitions/igxcPath"
|
|
650
|
+
}
|
|
651
|
+
]
|
|
652
|
+
},
|
|
653
|
+
Tail: {
|
|
654
|
+
oneOf: [
|
|
655
|
+
{
|
|
656
|
+
$ref: "#/definitions/param"
|
|
657
|
+
},
|
|
658
|
+
{
|
|
659
|
+
$ref: "#/definitions/igxcPath"
|
|
660
|
+
}
|
|
661
|
+
]
|
|
662
|
+
},
|
|
663
|
+
LimitLeft: {
|
|
664
|
+
type: "number"
|
|
665
|
+
},
|
|
666
|
+
LimitRight: {
|
|
667
|
+
type: "number"
|
|
668
|
+
},
|
|
669
|
+
LimitUp: {
|
|
670
|
+
type: "number"
|
|
671
|
+
},
|
|
672
|
+
LimitDown: {
|
|
673
|
+
type: "number"
|
|
674
|
+
},
|
|
675
|
+
FollowJointNode: {
|
|
676
|
+
$ref: "#/definitions/igxcPath"
|
|
677
|
+
},
|
|
678
|
+
_TargetNodeForFollow: {
|
|
679
|
+
type: "string"
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
},
|
|
684
|
+
Target: {
|
|
685
|
+
oneOf: [
|
|
686
|
+
{
|
|
687
|
+
$ref: "#/definitions/igxcPath"
|
|
688
|
+
},
|
|
689
|
+
{
|
|
690
|
+
$ref: "#/definitions/param"
|
|
691
|
+
},
|
|
692
|
+
{
|
|
693
|
+
type: "string",
|
|
694
|
+
enum: [
|
|
695
|
+
"subbase"
|
|
696
|
+
]
|
|
697
|
+
}
|
|
698
|
+
]
|
|
699
|
+
},
|
|
700
|
+
Parent: {
|
|
701
|
+
oneOf: [
|
|
702
|
+
{
|
|
703
|
+
$ref: "#/definitions/igxcPath"
|
|
704
|
+
},
|
|
705
|
+
{
|
|
706
|
+
type: "string",
|
|
707
|
+
enum: [
|
|
708
|
+
"root"
|
|
709
|
+
]
|
|
710
|
+
}
|
|
711
|
+
]
|
|
712
|
+
},
|
|
713
|
+
Tolerance: {
|
|
714
|
+
type: "number"
|
|
715
|
+
},
|
|
716
|
+
MaxIterations: {
|
|
717
|
+
type: "integer"
|
|
718
|
+
},
|
|
719
|
+
_: {
|
|
720
|
+
type: "string",
|
|
721
|
+
description: "Comment"
|
|
722
|
+
},
|
|
723
|
+
__: {
|
|
724
|
+
type: "string",
|
|
725
|
+
description: "Super Comment"
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
};
|
|
731
|
+
|
|
732
|
+
const createAnimationBuildParticipant = (location, manifest)=>{
|
|
733
|
+
return (env)=>{
|
|
734
|
+
env.onBuildStart();
|
|
735
|
+
bundleAnimations(location, manifest, env.log).then((result)=>{
|
|
736
|
+
env.onBuildEnd({
|
|
737
|
+
type: "success",
|
|
738
|
+
artefacts: {
|
|
739
|
+
js: (result == null ? void 0 : result.js) ?? ""
|
|
740
|
+
}
|
|
741
|
+
});
|
|
742
|
+
}).catch((err)=>{
|
|
743
|
+
env.onBuildEnd({
|
|
744
|
+
type: "error",
|
|
745
|
+
error: err.message
|
|
746
|
+
});
|
|
747
|
+
});
|
|
748
|
+
return {
|
|
749
|
+
destroy: ()=>{}
|
|
750
|
+
};
|
|
751
|
+
};
|
|
752
|
+
};
|
|
753
|
+
const createAnimationWatchBuildParticipant = (location, manifest)=>(env)=>{
|
|
754
|
+
env.onBuildStart();
|
|
755
|
+
bundleAnimations(location, manifest, env.log).then((result)=>{
|
|
756
|
+
env.onBuildEnd({
|
|
757
|
+
type: "success",
|
|
758
|
+
artefacts: {
|
|
759
|
+
js: (result == null ? void 0 : result.js) ?? ""
|
|
760
|
+
}
|
|
761
|
+
});
|
|
762
|
+
}).catch((err)=>{
|
|
763
|
+
env.onBuildEnd({
|
|
764
|
+
type: "error",
|
|
765
|
+
error: err.message
|
|
766
|
+
});
|
|
767
|
+
});
|
|
768
|
+
(async ()=>{
|
|
769
|
+
for await (const event of fs$1.watch(location.scriptsDir)){
|
|
770
|
+
if (event.filename.endsWith(".animation.json")) {
|
|
771
|
+
env.onBuildStart();
|
|
772
|
+
try {
|
|
773
|
+
const result = await bundleAnimations(location, manifest, env.log);
|
|
774
|
+
env.onBuildEnd({
|
|
775
|
+
type: "success",
|
|
776
|
+
artefacts: {
|
|
777
|
+
js: (result == null ? void 0 : result.js) ?? ""
|
|
778
|
+
}
|
|
779
|
+
});
|
|
780
|
+
} catch (err) {
|
|
781
|
+
env.onBuildEnd({
|
|
782
|
+
type: "error",
|
|
783
|
+
error: err.message
|
|
784
|
+
});
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
})();
|
|
789
|
+
return {
|
|
790
|
+
destroy: ()=>{}
|
|
791
|
+
};
|
|
792
|
+
};
|
|
793
|
+
const bundleAnimations = async (location, manifest, logStep)=>{
|
|
794
|
+
const animations = new Map();
|
|
795
|
+
for (const scriptFilePath of readPackageAnimationList(location)){
|
|
796
|
+
const content = await fs$1.readFile(scriptFilePath, {
|
|
797
|
+
encoding: "utf8"
|
|
798
|
+
});
|
|
799
|
+
let data;
|
|
800
|
+
try {
|
|
801
|
+
data = JSON.parse(content);
|
|
802
|
+
} catch (err) {
|
|
803
|
+
const relativePath = path.relative(location.path, scriptFilePath);
|
|
804
|
+
if (err instanceof SyntaxError) {
|
|
805
|
+
throw new Error(`Encountered invalid syntax in file "${relativePath}": ${String(err)}`);
|
|
806
|
+
}
|
|
807
|
+
throw new Error(`Encountered an unexpected error while parsing animation json file at path "${relativePath}"`, {
|
|
808
|
+
cause: err
|
|
809
|
+
});
|
|
810
|
+
}
|
|
811
|
+
if (!data.Id) {
|
|
812
|
+
const fileName = path.basename(scriptFilePath, ".animation.json");
|
|
813
|
+
data.Id = fileName;
|
|
814
|
+
}
|
|
815
|
+
(await getAnimationJsonValidation())(data);
|
|
816
|
+
delete data.$schema;
|
|
817
|
+
animations.set(data.Id, JSON.stringify(data));
|
|
818
|
+
}
|
|
819
|
+
if (animations.size > 0) {
|
|
820
|
+
const scope = manifest.Scope ?? manifest.Package;
|
|
821
|
+
const scopeParts = scope.split(".");
|
|
822
|
+
let js = createNamespace(scopeParts);
|
|
823
|
+
for (const [name, content] of animations){
|
|
824
|
+
js += `${scope}["${name}"] = ` + content + ";";
|
|
825
|
+
logStep(`Adding animation ${scope}.${name}`);
|
|
826
|
+
}
|
|
827
|
+
return {
|
|
828
|
+
js
|
|
829
|
+
};
|
|
830
|
+
}
|
|
831
|
+
return undefined;
|
|
832
|
+
};
|
|
833
|
+
const createNamespace = (parts)=>{
|
|
834
|
+
let code = `var ${parts[0]};`;
|
|
835
|
+
for(let index = 0; index < parts.length; index++){
|
|
836
|
+
const path = parts.slice(0, index + 1).join(".");
|
|
837
|
+
code += `\n(${path} = ${path} || {});`;
|
|
838
|
+
}
|
|
839
|
+
return code;
|
|
840
|
+
};
|
|
841
|
+
let validateAnimationJson;
|
|
842
|
+
const getAnimationJsonValidation = async ()=>{
|
|
843
|
+
if (validateAnimationJson === undefined) {
|
|
844
|
+
validateAnimationJson = new Ajv({
|
|
845
|
+
coerceTypes: true,
|
|
846
|
+
allErrors: true,
|
|
847
|
+
removeAdditional: true,
|
|
848
|
+
useDefaults: "empty",
|
|
849
|
+
validateSchema: "log"
|
|
850
|
+
}).compile(animationSchema);
|
|
851
|
+
}
|
|
852
|
+
return validateAnimationJson;
|
|
853
|
+
};
|
|
854
|
+
|
|
855
|
+
const buildFolders = async (options)=>{
|
|
856
|
+
if (options.outDir !== undefined && options.clean) {
|
|
857
|
+
await fs$1.rm(options.outDir, {
|
|
858
|
+
recursive: true
|
|
859
|
+
});
|
|
860
|
+
}
|
|
861
|
+
const workspace = options.workspace;
|
|
862
|
+
const folders = options.packages;
|
|
863
|
+
let sortedPackages = sortPackagesByBuildOrder(folders);
|
|
864
|
+
let index = 1;
|
|
865
|
+
const manifests = new Map(sortedPackages.map((location)=>[
|
|
866
|
+
location,
|
|
867
|
+
readPackageCreatorManifest(location)
|
|
868
|
+
]));
|
|
869
|
+
const maxNameLength = Array.from(manifests.values(), (manifest)=>manifest.Package.length).reduce((acc, length)=>Math.max(acc, length), 0);
|
|
870
|
+
for (const location of sortedPackages){
|
|
871
|
+
await ensureTsConfig(location);
|
|
872
|
+
const data = manifests.get(location);
|
|
873
|
+
const logStep = (step)=>logPackageMessage(data.Package, step, index, folders.length, maxNameLength);
|
|
874
|
+
const outputDirectory = options.outDir || location.scriptsDir;
|
|
875
|
+
await fs$1.mkdir(outputDirectory, {
|
|
876
|
+
recursive: true
|
|
877
|
+
});
|
|
878
|
+
const manager = new BuildManager(data, (result)=>writeBuildResult(result, data, location, workspace, outputDirectory, options.minimize, logStep), logStep);
|
|
879
|
+
if (options.banner) {
|
|
880
|
+
manager.addParticipant("banner", createBannerCommentBuildParticipant(options.banner));
|
|
881
|
+
}
|
|
882
|
+
manager.addParticipant("tsc", createTSCBuildParticipant(location, outputDirectory));
|
|
883
|
+
manager.addParticipant("animation", createAnimationBuildParticipant(location, data));
|
|
884
|
+
await new Promise((resolve, reject)=>{
|
|
885
|
+
manager.addListener("start", ()=>{
|
|
886
|
+
logStep(`Build started`);
|
|
887
|
+
});
|
|
888
|
+
manager.addListener("error", (error)=>{
|
|
889
|
+
reject(new Error(error));
|
|
890
|
+
});
|
|
891
|
+
manager.addListener("build", ()=>{
|
|
892
|
+
logStep(`Build complete`);
|
|
893
|
+
resolve();
|
|
894
|
+
});
|
|
895
|
+
manager.run();
|
|
896
|
+
});
|
|
897
|
+
if (options.docs) {
|
|
898
|
+
logStep("Generating typedoc documentation");
|
|
899
|
+
await generateDocs(location, path.join(outputDirectory, `${data.Package}.d.ts`), path.join(workspace.path, "docs", data.Package), data.Package);
|
|
900
|
+
}
|
|
901
|
+
index++;
|
|
902
|
+
}
|
|
903
|
+
};
|
|
904
|
+
const buildFoldersWatch = async (options)=>{
|
|
905
|
+
if (options.outDir !== undefined && options.clean) {
|
|
906
|
+
await fs$1.rm(options.outDir, {
|
|
907
|
+
recursive: true
|
|
908
|
+
});
|
|
909
|
+
}
|
|
910
|
+
const workspace = options.workspace;
|
|
911
|
+
const folders = options.packages;
|
|
912
|
+
let sortedPackages = sortPackagesByBuildOrder(folders);
|
|
913
|
+
let index = 1;
|
|
914
|
+
const manifests = new Map(sortedPackages.map((location)=>[
|
|
915
|
+
location,
|
|
916
|
+
readPackageCreatorManifest(location)
|
|
917
|
+
]));
|
|
918
|
+
const maxNameLength = Array.from(manifests.values(), (manifest)=>manifest.Package.length).reduce((acc, length)=>Math.max(acc, length), 0);
|
|
919
|
+
for (const location of sortedPackages){
|
|
920
|
+
await ensureTsConfig(location);
|
|
921
|
+
const data = manifests.get(location);
|
|
922
|
+
const currentIndex = index;
|
|
923
|
+
const logStep = (step)=>logPackageMessage(data.Package, step, currentIndex, folders.length, maxNameLength);
|
|
924
|
+
const outputDirectory = options.outDir || location.scriptsDir;
|
|
925
|
+
await fs$1.mkdir(outputDirectory, {
|
|
926
|
+
recursive: true
|
|
927
|
+
});
|
|
928
|
+
const manager = new BuildManager(data, (result)=>writeBuildResult(result, data, location, workspace, outputDirectory, options.minimize, logStep), logStep);
|
|
929
|
+
if (options.banner) {
|
|
930
|
+
manager.addParticipant("banner", createBannerCommentBuildParticipant(options.banner));
|
|
931
|
+
}
|
|
932
|
+
manager.addParticipant("tsc", createTSCWatchBuildParticipant(location, outputDirectory));
|
|
933
|
+
manager.addParticipant("animation", createAnimationWatchBuildParticipant(location, data));
|
|
934
|
+
await new Promise((resolve, reject)=>{
|
|
935
|
+
manager.addListener("start", ()=>{
|
|
936
|
+
logStep(`Build started`);
|
|
937
|
+
});
|
|
938
|
+
manager.addListener("error", (error)=>{
|
|
939
|
+
logStep(`Build failed: ${error}`);
|
|
940
|
+
resolve();
|
|
941
|
+
});
|
|
942
|
+
manager.addListener("build", ()=>{
|
|
943
|
+
logStep(`Build complete`);
|
|
944
|
+
resolve();
|
|
945
|
+
});
|
|
946
|
+
manager.run();
|
|
947
|
+
});
|
|
948
|
+
index++;
|
|
949
|
+
}
|
|
950
|
+
await new Promise(()=>{});
|
|
951
|
+
};
|
|
952
|
+
const writeBuildResult = async (buildResult, manifest, location, workspace, outputDirectory, minimize, logStep)=>{
|
|
953
|
+
let js = buildResult.js;
|
|
954
|
+
if (buildResult.sourceMap) {
|
|
955
|
+
js += `\n//# sourceMappingURL=${manifest.Package}.js.map`;
|
|
956
|
+
}
|
|
957
|
+
await fs$1.writeFile(path.join(outputDirectory, `${manifest.Package}.js`), js, {
|
|
958
|
+
encoding: "utf8"
|
|
959
|
+
});
|
|
960
|
+
if (buildResult.definitions !== undefined) {
|
|
961
|
+
await fs$1.writeFile(path.join(outputDirectory, `${manifest.Package}.d.ts`), buildResult.definitions, {
|
|
962
|
+
encoding: "utf8"
|
|
963
|
+
});
|
|
964
|
+
}
|
|
965
|
+
if (buildResult.sourceMap !== undefined) {
|
|
966
|
+
await fs$1.writeFile(path.join(outputDirectory, `${manifest.Package}.js.map`), buildResult.sourceMap, {
|
|
967
|
+
encoding: "utf8"
|
|
968
|
+
});
|
|
969
|
+
}
|
|
970
|
+
if (minimize) {
|
|
971
|
+
logStep("Minifying the output");
|
|
972
|
+
const minifyResult = await terser.minify(js, {
|
|
973
|
+
ecma: 5,
|
|
974
|
+
sourceMap: {
|
|
975
|
+
content: buildResult.sourceMap,
|
|
976
|
+
includeSources: false
|
|
977
|
+
}
|
|
978
|
+
});
|
|
979
|
+
const minifiedPath = path.join(outputDirectory, `${manifest.Package}.min.js`);
|
|
980
|
+
await fs$1.writeFile(minifiedPath, minifyResult.code, {
|
|
981
|
+
encoding: "utf8"
|
|
982
|
+
});
|
|
983
|
+
if (minifyResult.map !== undefined) {
|
|
984
|
+
await fs$1.writeFile(minifiedPath + ".map", typeof minifyResult.map === "string" ? minifyResult.map : JSON.stringify(minifyResult.map), {
|
|
985
|
+
encoding: "utf8"
|
|
986
|
+
});
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
if (location.path.includes("Basics") && buildResult.definitions !== undefined) {
|
|
990
|
+
await fs$1.mkdir(path.join(workspace.path, "lib"), {
|
|
991
|
+
recursive: true
|
|
992
|
+
});
|
|
993
|
+
logStep("Copying basics definition file to the lib folder");
|
|
994
|
+
await fs$1.writeFile(path.join(workspace.path, "lib", `${manifest.Package}.d.ts`), buildResult.definitions, {
|
|
995
|
+
encoding: "utf8"
|
|
996
|
+
});
|
|
997
|
+
}
|
|
998
|
+
};
|
|
999
|
+
const createBannerCommentBuildParticipant = (options)=>(env)=>{
|
|
1000
|
+
env.onBuildStart();
|
|
1001
|
+
const banner = createBannerComment(options);
|
|
1002
|
+
env.onBuildEnd({
|
|
1003
|
+
type: "success",
|
|
1004
|
+
artefacts: {
|
|
1005
|
+
js: banner ?? "",
|
|
1006
|
+
definitions: banner ?? ""
|
|
1007
|
+
}
|
|
1008
|
+
});
|
|
1009
|
+
return {
|
|
1010
|
+
destroy: ()=>{}
|
|
1011
|
+
};
|
|
1012
|
+
};
|
|
1013
|
+
const ensureTsConfig = async (location)=>{
|
|
1014
|
+
const tsconfigPath = path.join(location.scriptsDir, "tsconfig.json");
|
|
1015
|
+
try {
|
|
1016
|
+
const content = JSON.parse(await fs$1.readFile(tsconfigPath, "utf8"));
|
|
1017
|
+
applyTsConfigOption(content);
|
|
1018
|
+
await fs$1.writeFile(tsconfigPath, JSON.stringify(content, undefined, " "), "utf8");
|
|
1019
|
+
} catch (err) {
|
|
1020
|
+
if (!isErrorENOENT(err)) {
|
|
1021
|
+
throw err;
|
|
1022
|
+
}
|
|
1023
|
+
const content = {};
|
|
1024
|
+
applyTsConfigOption(content);
|
|
1025
|
+
await fs$1.writeFile(tsconfigPath, JSON.stringify(content, undefined, " "), "utf8");
|
|
1026
|
+
}
|
|
1027
|
+
};
|
|
1028
|
+
const applyTsConfigOption = (data)=>{
|
|
1029
|
+
data.compilerOptions = data.compilerOptions ?? {};
|
|
1030
|
+
data.compilerOptions.target = "es5";
|
|
1031
|
+
data.compilerOptions.lib = [
|
|
1032
|
+
"es5",
|
|
1033
|
+
"dom"
|
|
1034
|
+
];
|
|
1035
|
+
};
|
|
1036
|
+
const sortPackagesByBuildOrder = (folders)=>{
|
|
1037
|
+
const packages = Array.from(folders).reduce((acc, location)=>{
|
|
1038
|
+
const data = readPackageNpmManifest(location);
|
|
1039
|
+
if (data !== undefined) {
|
|
1040
|
+
acc[data.name] = {
|
|
1041
|
+
data,
|
|
1042
|
+
location
|
|
1043
|
+
};
|
|
1044
|
+
} else {
|
|
1045
|
+
acc[location.path] = {
|
|
1046
|
+
data: undefined,
|
|
1047
|
+
location
|
|
1048
|
+
};
|
|
1049
|
+
}
|
|
1050
|
+
return acc;
|
|
1051
|
+
}, {});
|
|
1052
|
+
const packageDependencies = Object.getOwnPropertyNames(packages).reduce((acc, packageName)=>{
|
|
1053
|
+
const packageData = packages[packageName];
|
|
1054
|
+
if (packageData.data === undefined) {
|
|
1055
|
+
acc[packageName] = [];
|
|
1056
|
+
} else {
|
|
1057
|
+
acc[packageName] = Object.getOwnPropertyNames({
|
|
1058
|
+
...packageData.data.devDependencies,
|
|
1059
|
+
...packageData.data.dependencies,
|
|
1060
|
+
...packageData.data.peerDependencies
|
|
1061
|
+
}).filter((packageName)=>packages[packageName] !== undefined);
|
|
1062
|
+
}
|
|
1063
|
+
return acc;
|
|
1064
|
+
}, {});
|
|
1065
|
+
const sortedPackages = toposort(packageDependencies);
|
|
1066
|
+
const result = [];
|
|
1067
|
+
for (const packageName of sortedPackages){
|
|
1068
|
+
const location = packages[packageName].location;
|
|
1069
|
+
if (readPackageCreatorManifest(location).Package.endsWith(".Basics")) {
|
|
1070
|
+
result.unshift(location);
|
|
1071
|
+
} else {
|
|
1072
|
+
result.push(location);
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
return result;
|
|
1076
|
+
};
|
|
1077
|
+
const createBannerComment = (banner)=>{
|
|
1078
|
+
const bannerParts = [];
|
|
1079
|
+
if (banner.text) {
|
|
1080
|
+
bannerParts.push(" * " + banner.text);
|
|
1081
|
+
}
|
|
1082
|
+
{
|
|
1083
|
+
const details = [];
|
|
1084
|
+
if (banner.version) {
|
|
1085
|
+
details.push(`Version: ${banner.version}`);
|
|
1086
|
+
}
|
|
1087
|
+
if (banner.commit) {
|
|
1088
|
+
if (banner.commitDirty) {
|
|
1089
|
+
details.push(`Commit: ${banner.commit} (dirty)`);
|
|
1090
|
+
} else {
|
|
1091
|
+
details.push(`Commit: ${banner.commit}`);
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
if (banner.date) {
|
|
1095
|
+
details.push(`Date: ${banner.date.toISOString()}`);
|
|
1096
|
+
}
|
|
1097
|
+
const detailsText = details.map((line)=>` * ${line}`).join("\n");
|
|
1098
|
+
if (detailsText) {
|
|
1099
|
+
bannerParts.push(detailsText);
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
const bannerText = bannerParts.join("\n\n");
|
|
1103
|
+
if (bannerText) {
|
|
1104
|
+
return `/*
|
|
1105
|
+
${bannerText}
|
|
1106
|
+
*
|
|
1107
|
+
* @preserve
|
|
1108
|
+
*/`;
|
|
1109
|
+
}
|
|
1110
|
+
return undefined;
|
|
1111
|
+
};
|
|
1112
|
+
|
|
1113
|
+
var index = /*#__PURE__*/Object.freeze({
|
|
1114
|
+
__proto__: null,
|
|
1115
|
+
buildFolders: buildFolders,
|
|
1116
|
+
buildFoldersWatch: buildFoldersWatch
|
|
1117
|
+
});
|
|
1118
|
+
|
|
1119
|
+
export { buildFolders as b, index as i, logPackageMessage as l };
|
|
1120
|
+
//# sourceMappingURL=index-3d1291e7.mjs.map
|