@intelligentgraphics/ig.gfx.packager 3.1.3 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/bin.js +7 -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 +11 -0
- package/build/bin.mjs +0 -5
- package/build/bin.mjs.map +0 -1
- package/build/cli-CPzBOjl0.mjs +0 -768
- package/build/cli-CPzBOjl0.mjs.map +0 -1
- package/build/dependencies-CYuZmWpt.mjs +0 -129
- package/build/dependencies-CYuZmWpt.mjs.map +0 -1
- package/build/docs-BlCIta3Y.mjs +0 -37
- package/build/docs-BlCIta3Y.mjs.map +0 -1
- package/build/generateIndex-D5rR39-Z.mjs +0 -306
- package/build/generateIndex-D5rR39-Z.mjs.map +0 -1
- package/build/generateParameterType-BDyh-daC.mjs +0 -69
- package/build/generateParameterType-BDyh-daC.mjs.map +0 -1
- package/build/index-Dn5_iPca.mjs +0 -1370
- package/build/index-Dn5_iPca.mjs.map +0 -1
- package/build/index-Uwhzx9k9.mjs +0 -477
- package/build/index-Uwhzx9k9.mjs.map +0 -1
- package/build/postinstall-BkmY43I5.mjs +0 -61
- package/build/postinstall-BkmY43I5.mjs.map +0 -1
- package/build/publishNpm-S60dL_YV.mjs +0 -167
- package/build/publishNpm-S60dL_YV.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-HrFQXwyU.mjs +0 -206
- package/build/versionFile-HrFQXwyU.mjs.map +0 -1
- package/lib/lib.mjs +0 -2676
package/build/index-Dn5_iPca.mjs
DELETED
|
@@ -1,1370 +0,0 @@
|
|
|
1
|
-
import * as path from 'path';
|
|
2
|
-
import * as fs$1 from 'fs/promises';
|
|
3
|
-
import * as terser from 'terser';
|
|
4
|
-
import { EOL } from 'os';
|
|
5
|
-
import ts from 'typescript';
|
|
6
|
-
import * as fs from 'fs';
|
|
7
|
-
import 'resolve';
|
|
8
|
-
import 'write-package';
|
|
9
|
-
import { e as readPackageAnimationList, r as readPackageCreatorManifest, q as readPackageNpmManifest, i as isErrorENOENT } from './cli-CPzBOjl0.mjs';
|
|
10
|
-
import { g as getPackageTypescriptFiles, i as isScriptPackageModules } from './scripts-B3noxiX3.mjs';
|
|
11
|
-
import 'axios';
|
|
12
|
-
import EventEmitter from 'events';
|
|
13
|
-
import { SourceMapGenerator, SourceMapConsumer } from 'source-map-js';
|
|
14
|
-
import 'glob';
|
|
15
|
-
import Ajv from 'ajv';
|
|
16
|
-
|
|
17
|
-
const consoleReporter = {
|
|
18
|
-
log (message) {
|
|
19
|
-
console.log(message);
|
|
20
|
-
},
|
|
21
|
-
error (message, _error) {
|
|
22
|
-
console.error(message);
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
const createPackageScopedReporter = (reporter, scope, index, total, maxNameLength = 15)=>{
|
|
26
|
-
const numLength = total === undefined ? undefined : total.toString().length;
|
|
27
|
-
const indexString = total === undefined || total < 2 ? "" : `${index.toString().padStart(numLength, "0")}/${total} `;
|
|
28
|
-
const identifierString = `${indexString}${scope.padEnd(maxNameLength)}`;
|
|
29
|
-
return {
|
|
30
|
-
log (message) {
|
|
31
|
-
reporter.log(`${identifierString} >> ${message}`);
|
|
32
|
-
},
|
|
33
|
-
error (message, error) {
|
|
34
|
-
reporter.error(`${identifierString} >> ${message}`, error);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const tryReadTsConfig = (location)=>{
|
|
40
|
-
const { config } = ts.readConfigFile(path.join(location.scriptsDir, "tsconfig.json"), (path)=>{
|
|
41
|
-
try {
|
|
42
|
-
return fs.readFileSync(path, "utf8");
|
|
43
|
-
} catch {
|
|
44
|
-
return undefined;
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
return config;
|
|
48
|
-
};
|
|
49
|
-
const createTSCBuildParticipant = (location, outputDir, skipDeclarations)=>(env)=>{
|
|
50
|
-
const files = getPackageTypescriptFiles(location);
|
|
51
|
-
try {
|
|
52
|
-
env.onBuildStart();
|
|
53
|
-
env.log("Compiling typescript files");
|
|
54
|
-
const compilerOptions = getCompilerOptions(location, outputDir, skipDeclarations);
|
|
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(ts.formatDiagnostics(allDiagnostics, host));
|
|
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
|
-
declarations: getDeclarationFileReferences(location, program, outputDir) + definitions,
|
|
89
|
-
sourceMap
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
} else {
|
|
93
|
-
const error = ts.formatDiagnostics(allDiagnostics, host);
|
|
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, skipDeclarations)=>{
|
|
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 registerDiagnostic = (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
|
-
let currentProgram;
|
|
140
|
-
const reportWatchStatusChanged = (diagnostic)=>{
|
|
141
|
-
switch(diagnostic.code){
|
|
142
|
-
// regular watch mode - https://github.com/microsoft/TypeScript/blob/93e6b9da0c4cb164ca90a5a1b07415e81e97f2b1/src/compiler/diagnosticMessages.json#L4567
|
|
143
|
-
case 6031:
|
|
144
|
-
// incremental watch mode - https://github.com/microsoft/TypeScript/blob/93e6b9da0c4cb164ca90a5a1b07415e81e97f2b1/src/compiler/diagnosticMessages.json#L4571
|
|
145
|
-
case 6032:
|
|
146
|
-
// build start
|
|
147
|
-
onBuildStart();
|
|
148
|
-
break;
|
|
149
|
-
// found one error - https://github.com/microsoft/TypeScript/blob/93e6b9da0c4cb164ca90a5a1b07415e81e97f2b1/src/compiler/diagnosticMessages.json#L5119
|
|
150
|
-
case 6193:
|
|
151
|
-
// found n or 0 errors - https://github.com/microsoft/TypeScript/blob/93e6b9da0c4cb164ca90a5a1b07415e81e97f2b1/src/compiler/diagnosticMessages.json#L5123
|
|
152
|
-
case 6194:
|
|
153
|
-
// build end
|
|
154
|
-
const emitState = state;
|
|
155
|
-
state = {
|
|
156
|
-
diagnostics: [],
|
|
157
|
-
js: undefined,
|
|
158
|
-
definitions: undefined,
|
|
159
|
-
sourceMap: undefined
|
|
160
|
-
};
|
|
161
|
-
if (emitState.diagnostics.length > 0) {
|
|
162
|
-
const message = ts.formatDiagnostics(emitState.diagnostics, formattingHost);
|
|
163
|
-
onBuildEnd({
|
|
164
|
-
type: "error",
|
|
165
|
-
error: new Error(message)
|
|
166
|
-
});
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
if (emitState.js === undefined) {
|
|
170
|
-
onBuildEnd({
|
|
171
|
-
type: "success",
|
|
172
|
-
artefacts: {
|
|
173
|
-
js: ""
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
if (!currentProgram) {
|
|
179
|
-
throw new Error(`Expected a program to exist`);
|
|
180
|
-
}
|
|
181
|
-
onBuildEnd({
|
|
182
|
-
type: "success",
|
|
183
|
-
artefacts: {
|
|
184
|
-
js: emitState.js.replace(`//# sourceMappingURL=out.js.map`, ""),
|
|
185
|
-
declarations: emitState.definitions ? getDeclarationFileReferences(location, currentProgram, outputDir) + emitState.definitions : undefined,
|
|
186
|
-
sourceMap: emitState.sourceMap
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
break;
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
const host = ts.createWatchCompilerHost(path.join(location.scriptsDir, "tsconfig.json"), getCompilerOptions(location, outputDir, skipDeclarations), customSys, ts.createSemanticDiagnosticsBuilderProgram, registerDiagnostic, reportWatchStatusChanged);
|
|
193
|
-
const originalAfterProgramCreate = host.afterProgramCreate;
|
|
194
|
-
host.afterProgramCreate = (program)=>{
|
|
195
|
-
currentProgram = program;
|
|
196
|
-
originalAfterProgramCreate?.(program);
|
|
197
|
-
};
|
|
198
|
-
const formattingHost = {
|
|
199
|
-
getCanonicalFileName: (path)=>path,
|
|
200
|
-
getCurrentDirectory: host.getCurrentDirectory,
|
|
201
|
-
getNewLine: ()=>ts.sys.newLine
|
|
202
|
-
};
|
|
203
|
-
const watchProgram = ts.createWatchProgram(host);
|
|
204
|
-
return {
|
|
205
|
-
destroy: ()=>{
|
|
206
|
-
watchProgram.close();
|
|
207
|
-
}
|
|
208
|
-
};
|
|
209
|
-
};
|
|
210
|
-
};
|
|
211
|
-
const getCompilerOptions = (location, outputDir, skipDeclarations)=>{
|
|
212
|
-
const config = tryReadTsConfig(location);
|
|
213
|
-
config.compilerOptions.lib = [
|
|
214
|
-
"es5",
|
|
215
|
-
"dom"
|
|
216
|
-
];
|
|
217
|
-
const result = ts.convertCompilerOptionsFromJson(config.compilerOptions, location.scriptsDir);
|
|
218
|
-
const compilerOptions = {
|
|
219
|
-
...result.options,
|
|
220
|
-
removeComments: false,
|
|
221
|
-
declaration: !skipDeclarations,
|
|
222
|
-
sourceMap: true,
|
|
223
|
-
inlineSources: false,
|
|
224
|
-
// We don't use tsc to actually emit the files, but we still need to set the correct
|
|
225
|
-
// output directory so the compiler can rewrite the `reference path` directives.
|
|
226
|
-
outFile: path.join(outputDir, "out.js"),
|
|
227
|
-
target: ts.ScriptTarget.ES5,
|
|
228
|
-
noEmitOnError: true
|
|
229
|
-
};
|
|
230
|
-
return compilerOptions;
|
|
231
|
-
};
|
|
232
|
-
function getDeclarationFileReferences(location, program, outputDir) {
|
|
233
|
-
const references = new Set();
|
|
234
|
-
for (const file of program.getSourceFiles()){
|
|
235
|
-
for (const reference of file.referencedFiles){
|
|
236
|
-
if (reference.preserve) {
|
|
237
|
-
continue;
|
|
238
|
-
}
|
|
239
|
-
const dir = path.dirname(file.fileName);
|
|
240
|
-
const absolute = path.resolve(dir, reference.fileName);
|
|
241
|
-
if (!absolute.startsWith(location.scriptsDir)) {
|
|
242
|
-
references.add(absolute);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
let referenceString = Array.from(references, (reference)=>`/// <reference path="${path.relative(outputDir, reference)}" />`).join(EOL);
|
|
247
|
-
if (referenceString) {
|
|
248
|
-
referenceString += EOL;
|
|
249
|
-
}
|
|
250
|
-
return referenceString;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
// Stolen from ig.tools.core
|
|
254
|
-
const toposort = (packages)=>{
|
|
255
|
-
const queue = Object.getOwnPropertyNames(packages);
|
|
256
|
-
const result = [];
|
|
257
|
-
let index = 0;
|
|
258
|
-
while(queue.length > 0){
|
|
259
|
-
if (index >= queue.length) {
|
|
260
|
-
throw new Error("Packages can not have cyclic dependencies");
|
|
261
|
-
}
|
|
262
|
-
const queueEntry = queue[index];
|
|
263
|
-
const dependencies = packages[queueEntry];
|
|
264
|
-
const dependencyQueued = dependencies.some((dependency)=>queue.includes(dependency));
|
|
265
|
-
if (dependencyQueued) {
|
|
266
|
-
index++;
|
|
267
|
-
continue;
|
|
268
|
-
}
|
|
269
|
-
queue.splice(index, 1);
|
|
270
|
-
index = 0;
|
|
271
|
-
result.push(queueEntry);
|
|
272
|
-
}
|
|
273
|
-
return result;
|
|
274
|
-
};
|
|
275
|
-
|
|
276
|
-
class BuildManager extends EventEmitter {
|
|
277
|
-
constructor(manifest, writer, reporter){
|
|
278
|
-
super(), this.manifest = manifest, this.writer = writer, this.reporter = reporter, this.participants = new Map(), this.states = new Map(), this.participantInstances = [];
|
|
279
|
-
}
|
|
280
|
-
addParticipant(name, participant) {
|
|
281
|
-
this.participants.set(name, participant);
|
|
282
|
-
}
|
|
283
|
-
run() {
|
|
284
|
-
for (const [name] of this.participants){
|
|
285
|
-
this.states.set(name, {
|
|
286
|
-
type: "busy"
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
|
-
this.emit("start");
|
|
290
|
-
for (const [name, participant] of this.participants){
|
|
291
|
-
const instance = participant({
|
|
292
|
-
onBuildStart: ()=>{
|
|
293
|
-
let alreadyBusy = false;
|
|
294
|
-
for (const [name, state] of this.states){
|
|
295
|
-
if (state.type === "busy") {
|
|
296
|
-
alreadyBusy = true;
|
|
297
|
-
continue;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
this.states.set(name, {
|
|
301
|
-
type: "busy"
|
|
302
|
-
});
|
|
303
|
-
if (!alreadyBusy) {
|
|
304
|
-
this.emit("start");
|
|
305
|
-
}
|
|
306
|
-
},
|
|
307
|
-
onBuildEnd: (result)=>{
|
|
308
|
-
this.states.set(name, result);
|
|
309
|
-
this.maybeEmit();
|
|
310
|
-
},
|
|
311
|
-
log: (message)=>this.reporter.log(message)
|
|
312
|
-
});
|
|
313
|
-
this.participantInstances.push(instance);
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
destroy() {
|
|
317
|
-
for (const instance of this.participantInstances){
|
|
318
|
-
instance.destroy();
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
maybeEmit() {
|
|
322
|
-
const errors = [];
|
|
323
|
-
const results = [];
|
|
324
|
-
for (const [_, state] of this.states){
|
|
325
|
-
if (state.type === "busy") {
|
|
326
|
-
return;
|
|
327
|
-
}
|
|
328
|
-
if (state.type === "success") {
|
|
329
|
-
results.push(state);
|
|
330
|
-
} else if (state.type === "error") {
|
|
331
|
-
errors.push(state.error);
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
if (errors.length > 0) {
|
|
335
|
-
this.emit("error", errors.length === 1 ? errors[0] : new AggregateError(errors));
|
|
336
|
-
return;
|
|
337
|
-
}
|
|
338
|
-
const completeResult = {
|
|
339
|
-
js: ""
|
|
340
|
-
};
|
|
341
|
-
const sourceMapGenerator = new SourceMapGenerator();
|
|
342
|
-
for (const result of results){
|
|
343
|
-
if (result.artefacts.js) {
|
|
344
|
-
if (completeResult.js) {
|
|
345
|
-
completeResult.js += "\n";
|
|
346
|
-
}
|
|
347
|
-
if (result.artefacts.sourceMap) {
|
|
348
|
-
const lines = completeResult.js.split("\n").length - 1;
|
|
349
|
-
const sourceMap = new SourceMapConsumer(JSON.parse(result.artefacts.sourceMap));
|
|
350
|
-
const sources = new Set();
|
|
351
|
-
sourceMap.eachMapping((mapping)=>{
|
|
352
|
-
sourceMapGenerator.addMapping({
|
|
353
|
-
generated: {
|
|
354
|
-
line: lines + mapping.generatedLine,
|
|
355
|
-
column: mapping.generatedColumn
|
|
356
|
-
},
|
|
357
|
-
original: mapping.originalLine !== null && mapping.originalColumn !== null ? {
|
|
358
|
-
line: mapping.originalLine,
|
|
359
|
-
column: mapping.originalColumn
|
|
360
|
-
} : undefined,
|
|
361
|
-
source: mapping.source,
|
|
362
|
-
name: mapping.name
|
|
363
|
-
});
|
|
364
|
-
if (mapping.source !== null) {
|
|
365
|
-
sources.add(mapping.source);
|
|
366
|
-
}
|
|
367
|
-
});
|
|
368
|
-
for (const source of sources){
|
|
369
|
-
const content = sourceMap.sourceContentFor(source);
|
|
370
|
-
if (content !== null) {
|
|
371
|
-
sourceMapGenerator.setSourceContent(source, content);
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
completeResult.js += result.artefacts.js;
|
|
376
|
-
}
|
|
377
|
-
if (result.artefacts.declarations) {
|
|
378
|
-
if (completeResult.declarations) {
|
|
379
|
-
completeResult.declarations += "\n";
|
|
380
|
-
} else {
|
|
381
|
-
completeResult.declarations = "";
|
|
382
|
-
}
|
|
383
|
-
completeResult.declarations += result.artefacts.declarations;
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
completeResult.sourceMap = sourceMapGenerator.toString();
|
|
387
|
-
this.writer(completeResult).then(()=>{
|
|
388
|
-
this.emit("build");
|
|
389
|
-
});
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
var animationSchema = {
|
|
394
|
-
$schema: "http://json-schema.org/draft-07/schema",
|
|
395
|
-
$id: "https://archive.intelligentgraphics.biz/schemas/gfx/animation.json",
|
|
396
|
-
$comment: "Version 2023-02-17, Source: ig.data.gfx/Specs/animation.json",
|
|
397
|
-
title: "Animation description format",
|
|
398
|
-
additionalProperties: false,
|
|
399
|
-
type: "object",
|
|
400
|
-
properties: {
|
|
401
|
-
$schema: {
|
|
402
|
-
type: "string"
|
|
403
|
-
},
|
|
404
|
-
Id: {
|
|
405
|
-
type: "string",
|
|
406
|
-
description: "Animation id, to be unique in the project scope. Needs to be a valid JavaScript identifier."
|
|
407
|
-
},
|
|
408
|
-
Animations: {
|
|
409
|
-
type: "array",
|
|
410
|
-
description: "Declaration of animation states for gfx objects",
|
|
411
|
-
items: {
|
|
412
|
-
type: "object",
|
|
413
|
-
additionalProperties: false,
|
|
414
|
-
properties: {
|
|
415
|
-
_: {
|
|
416
|
-
type: "string",
|
|
417
|
-
description: "Comment"
|
|
418
|
-
},
|
|
419
|
-
Path: {
|
|
420
|
-
$ref: "#/definitions/igxcPath"
|
|
421
|
-
},
|
|
422
|
-
States: {
|
|
423
|
-
type: "object",
|
|
424
|
-
additionalProperties: {
|
|
425
|
-
type: "object",
|
|
426
|
-
additionalProperties: false,
|
|
427
|
-
properties: {
|
|
428
|
-
Position: {
|
|
429
|
-
$ref: "#/definitions/vec3"
|
|
430
|
-
},
|
|
431
|
-
Rotation: {
|
|
432
|
-
$ref: "#/definitions/rotation"
|
|
433
|
-
},
|
|
434
|
-
Scaling: {
|
|
435
|
-
$ref: "#/definitions/vec3"
|
|
436
|
-
},
|
|
437
|
-
Visibility: {
|
|
438
|
-
type: "boolean"
|
|
439
|
-
},
|
|
440
|
-
Deformation: {
|
|
441
|
-
anyOf: [
|
|
442
|
-
{
|
|
443
|
-
type: "number"
|
|
444
|
-
},
|
|
445
|
-
{
|
|
446
|
-
type: "string"
|
|
447
|
-
}
|
|
448
|
-
]
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
},
|
|
456
|
-
Kinematics: {
|
|
457
|
-
oneOf: [
|
|
458
|
-
{
|
|
459
|
-
$ref: "#/definitions/kinematicChain"
|
|
460
|
-
},
|
|
461
|
-
{
|
|
462
|
-
type: "array",
|
|
463
|
-
items: {
|
|
464
|
-
$ref: "#/definitions/kinematicChain"
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
]
|
|
468
|
-
},
|
|
469
|
-
LinkedPoints: {
|
|
470
|
-
type: "object",
|
|
471
|
-
additionalProperties: {
|
|
472
|
-
type: "array",
|
|
473
|
-
items: {
|
|
474
|
-
type: "string"
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
},
|
|
478
|
-
_: {
|
|
479
|
-
type: "string",
|
|
480
|
-
description: "Comment"
|
|
481
|
-
}
|
|
482
|
-
},
|
|
483
|
-
definitions: {
|
|
484
|
-
vec3: {
|
|
485
|
-
type: "object",
|
|
486
|
-
additionalProperties: false,
|
|
487
|
-
properties: {
|
|
488
|
-
X: {
|
|
489
|
-
anyOf: [
|
|
490
|
-
{
|
|
491
|
-
type: "number"
|
|
492
|
-
},
|
|
493
|
-
{
|
|
494
|
-
type: "string"
|
|
495
|
-
}
|
|
496
|
-
]
|
|
497
|
-
},
|
|
498
|
-
Y: {
|
|
499
|
-
anyOf: [
|
|
500
|
-
{
|
|
501
|
-
type: "number"
|
|
502
|
-
},
|
|
503
|
-
{
|
|
504
|
-
type: "string"
|
|
505
|
-
}
|
|
506
|
-
]
|
|
507
|
-
},
|
|
508
|
-
Z: {
|
|
509
|
-
anyOf: [
|
|
510
|
-
{
|
|
511
|
-
type: "number"
|
|
512
|
-
},
|
|
513
|
-
{
|
|
514
|
-
type: "string"
|
|
515
|
-
}
|
|
516
|
-
]
|
|
517
|
-
},
|
|
518
|
-
_: {
|
|
519
|
-
type: "string",
|
|
520
|
-
description: "Comment"
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
},
|
|
524
|
-
rotation: {
|
|
525
|
-
type: "object",
|
|
526
|
-
additionalProperties: false,
|
|
527
|
-
properties: {
|
|
528
|
-
Q: {
|
|
529
|
-
description: "If true, the rotation is considered to be a Quaternion. Otherwise, it's interpreted as Euler arcs and W will be ignored.",
|
|
530
|
-
type: "boolean"
|
|
531
|
-
},
|
|
532
|
-
X: {
|
|
533
|
-
anyOf: [
|
|
534
|
-
{
|
|
535
|
-
type: "number"
|
|
536
|
-
},
|
|
537
|
-
{
|
|
538
|
-
type: "string"
|
|
539
|
-
}
|
|
540
|
-
]
|
|
541
|
-
},
|
|
542
|
-
Y: {
|
|
543
|
-
anyOf: [
|
|
544
|
-
{
|
|
545
|
-
type: "number"
|
|
546
|
-
},
|
|
547
|
-
{
|
|
548
|
-
type: "string"
|
|
549
|
-
}
|
|
550
|
-
]
|
|
551
|
-
},
|
|
552
|
-
Z: {
|
|
553
|
-
anyOf: [
|
|
554
|
-
{
|
|
555
|
-
type: "number"
|
|
556
|
-
},
|
|
557
|
-
{
|
|
558
|
-
type: "string"
|
|
559
|
-
}
|
|
560
|
-
]
|
|
561
|
-
},
|
|
562
|
-
W: {
|
|
563
|
-
anyOf: [
|
|
564
|
-
{
|
|
565
|
-
type: "number"
|
|
566
|
-
},
|
|
567
|
-
{
|
|
568
|
-
type: "string"
|
|
569
|
-
}
|
|
570
|
-
]
|
|
571
|
-
},
|
|
572
|
-
_: {
|
|
573
|
-
type: "string",
|
|
574
|
-
description: "Comment"
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
},
|
|
578
|
-
igxcPath: {
|
|
579
|
-
type: "string",
|
|
580
|
-
description: "Relative path of the target object",
|
|
581
|
-
pattern: "^((o|e)\\d+(\\.(o|e)\\d+)*|\\.)$"
|
|
582
|
-
},
|
|
583
|
-
param: {
|
|
584
|
-
type: "string",
|
|
585
|
-
pattern: "^Param\\d+$"
|
|
586
|
-
},
|
|
587
|
-
kinematicChain: {
|
|
588
|
-
type: "object",
|
|
589
|
-
additionalProperties: false,
|
|
590
|
-
properties: {
|
|
591
|
-
GeometryBase: {
|
|
592
|
-
type: "string"
|
|
593
|
-
},
|
|
594
|
-
Joints: {
|
|
595
|
-
type: "array",
|
|
596
|
-
items: {
|
|
597
|
-
type: "object",
|
|
598
|
-
additionalProperties: false,
|
|
599
|
-
properties: {
|
|
600
|
-
Name: {
|
|
601
|
-
oneOf: [
|
|
602
|
-
{
|
|
603
|
-
$ref: "#/definitions/param"
|
|
604
|
-
},
|
|
605
|
-
{
|
|
606
|
-
type: "string"
|
|
607
|
-
}
|
|
608
|
-
]
|
|
609
|
-
},
|
|
610
|
-
HeadX: {
|
|
611
|
-
oneOf: [
|
|
612
|
-
{
|
|
613
|
-
$ref: "#/definitions/param"
|
|
614
|
-
},
|
|
615
|
-
{
|
|
616
|
-
$ref: "#/definitions/igxcPath"
|
|
617
|
-
}
|
|
618
|
-
]
|
|
619
|
-
},
|
|
620
|
-
HeadY: {
|
|
621
|
-
oneOf: [
|
|
622
|
-
{
|
|
623
|
-
$ref: "#/definitions/param"
|
|
624
|
-
},
|
|
625
|
-
{
|
|
626
|
-
$ref: "#/definitions/igxcPath"
|
|
627
|
-
}
|
|
628
|
-
]
|
|
629
|
-
},
|
|
630
|
-
HeadZ: {
|
|
631
|
-
oneOf: [
|
|
632
|
-
{
|
|
633
|
-
$ref: "#/definitions/param"
|
|
634
|
-
},
|
|
635
|
-
{
|
|
636
|
-
$ref: "#/definitions/igxcPath"
|
|
637
|
-
}
|
|
638
|
-
]
|
|
639
|
-
},
|
|
640
|
-
Tail: {
|
|
641
|
-
oneOf: [
|
|
642
|
-
{
|
|
643
|
-
$ref: "#/definitions/param"
|
|
644
|
-
},
|
|
645
|
-
{
|
|
646
|
-
$ref: "#/definitions/igxcPath"
|
|
647
|
-
}
|
|
648
|
-
]
|
|
649
|
-
},
|
|
650
|
-
LimitLeft: {
|
|
651
|
-
type: "number"
|
|
652
|
-
},
|
|
653
|
-
LimitRight: {
|
|
654
|
-
type: "number"
|
|
655
|
-
},
|
|
656
|
-
LimitUp: {
|
|
657
|
-
type: "number"
|
|
658
|
-
},
|
|
659
|
-
LimitDown: {
|
|
660
|
-
type: "number"
|
|
661
|
-
},
|
|
662
|
-
FollowJointNode: {
|
|
663
|
-
$ref: "#/definitions/igxcPath"
|
|
664
|
-
},
|
|
665
|
-
_TargetNodeForFollow: {
|
|
666
|
-
type: "string"
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
|
-
},
|
|
671
|
-
Target: {
|
|
672
|
-
oneOf: [
|
|
673
|
-
{
|
|
674
|
-
$ref: "#/definitions/igxcPath"
|
|
675
|
-
},
|
|
676
|
-
{
|
|
677
|
-
$ref: "#/definitions/param"
|
|
678
|
-
},
|
|
679
|
-
{
|
|
680
|
-
type: "string",
|
|
681
|
-
enum: [
|
|
682
|
-
"subbase"
|
|
683
|
-
]
|
|
684
|
-
}
|
|
685
|
-
]
|
|
686
|
-
},
|
|
687
|
-
Parent: {
|
|
688
|
-
oneOf: [
|
|
689
|
-
{
|
|
690
|
-
$ref: "#/definitions/igxcPath"
|
|
691
|
-
},
|
|
692
|
-
{
|
|
693
|
-
type: "string",
|
|
694
|
-
enum: [
|
|
695
|
-
"root"
|
|
696
|
-
]
|
|
697
|
-
}
|
|
698
|
-
]
|
|
699
|
-
},
|
|
700
|
-
Tolerance: {
|
|
701
|
-
type: "number"
|
|
702
|
-
},
|
|
703
|
-
MaxIterations: {
|
|
704
|
-
type: "integer"
|
|
705
|
-
},
|
|
706
|
-
_: {
|
|
707
|
-
type: "string",
|
|
708
|
-
description: "Comment"
|
|
709
|
-
},
|
|
710
|
-
__: {
|
|
711
|
-
type: "string",
|
|
712
|
-
description: "Super Comment"
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
};
|
|
718
|
-
|
|
719
|
-
const createAnimationBuildParticipant = (location, manifest)=>{
|
|
720
|
-
return (env)=>{
|
|
721
|
-
env.onBuildStart();
|
|
722
|
-
bundleAnimations(location, manifest, env.log).then((result)=>{
|
|
723
|
-
env.onBuildEnd({
|
|
724
|
-
type: "success",
|
|
725
|
-
artefacts: {
|
|
726
|
-
js: result?.js ?? ""
|
|
727
|
-
}
|
|
728
|
-
});
|
|
729
|
-
}).catch((err)=>{
|
|
730
|
-
env.onBuildEnd({
|
|
731
|
-
type: "error",
|
|
732
|
-
error: err.message
|
|
733
|
-
});
|
|
734
|
-
});
|
|
735
|
-
return {
|
|
736
|
-
destroy: ()=>{}
|
|
737
|
-
};
|
|
738
|
-
};
|
|
739
|
-
};
|
|
740
|
-
const createAnimationWatchBuildParticipant = (location, manifest)=>(env)=>{
|
|
741
|
-
env.onBuildStart();
|
|
742
|
-
bundleAnimations(location, manifest, env.log).then((result)=>{
|
|
743
|
-
env.onBuildEnd({
|
|
744
|
-
type: "success",
|
|
745
|
-
artefacts: {
|
|
746
|
-
js: result?.js ?? ""
|
|
747
|
-
}
|
|
748
|
-
});
|
|
749
|
-
}).catch((err)=>{
|
|
750
|
-
env.onBuildEnd({
|
|
751
|
-
type: "error",
|
|
752
|
-
error: err.message
|
|
753
|
-
});
|
|
754
|
-
});
|
|
755
|
-
(async ()=>{
|
|
756
|
-
for await (const event of fs$1.watch(location.scriptsDir)){
|
|
757
|
-
if (event.filename?.endsWith(".animation.json")) {
|
|
758
|
-
env.onBuildStart();
|
|
759
|
-
try {
|
|
760
|
-
const result = await bundleAnimations(location, manifest, env.log);
|
|
761
|
-
env.onBuildEnd({
|
|
762
|
-
type: "success",
|
|
763
|
-
artefacts: {
|
|
764
|
-
js: result?.js ?? ""
|
|
765
|
-
}
|
|
766
|
-
});
|
|
767
|
-
} catch (err) {
|
|
768
|
-
env.onBuildEnd({
|
|
769
|
-
type: "error",
|
|
770
|
-
error: err.message
|
|
771
|
-
});
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
})();
|
|
776
|
-
return {
|
|
777
|
-
destroy: ()=>{}
|
|
778
|
-
};
|
|
779
|
-
};
|
|
780
|
-
const bundleAnimations = async (location, manifest, logStep)=>{
|
|
781
|
-
const animations = new Map();
|
|
782
|
-
for (const scriptFilePath of readPackageAnimationList(location)){
|
|
783
|
-
const content = await fs$1.readFile(scriptFilePath, {
|
|
784
|
-
encoding: "utf8"
|
|
785
|
-
});
|
|
786
|
-
let data;
|
|
787
|
-
try {
|
|
788
|
-
data = JSON.parse(content);
|
|
789
|
-
} catch (err) {
|
|
790
|
-
const relativePath = path.relative(location.path, scriptFilePath);
|
|
791
|
-
if (err instanceof SyntaxError) {
|
|
792
|
-
throw new Error(`Encountered invalid syntax in file "${relativePath}": ${String(err)}`);
|
|
793
|
-
}
|
|
794
|
-
throw new Error(`Encountered an unexpected error while parsing animation json file at path "${relativePath}"`, {
|
|
795
|
-
cause: err
|
|
796
|
-
});
|
|
797
|
-
}
|
|
798
|
-
if (!data.Id) {
|
|
799
|
-
const fileName = path.basename(scriptFilePath, ".animation.json");
|
|
800
|
-
data.Id = fileName;
|
|
801
|
-
}
|
|
802
|
-
(await getAnimationJsonValidation())(data);
|
|
803
|
-
delete data.$schema;
|
|
804
|
-
animations.set(data.Id, JSON.stringify(data));
|
|
805
|
-
}
|
|
806
|
-
if (animations.size > 0) {
|
|
807
|
-
const scope = manifest.Scope ?? manifest.Package;
|
|
808
|
-
const scopeParts = scope.split(".");
|
|
809
|
-
let js = createNamespace(scopeParts);
|
|
810
|
-
for (const [name, content] of animations){
|
|
811
|
-
js += `${scope}["${name}"] = ` + content + ";";
|
|
812
|
-
logStep(`Adding animation ${scope}.${name}`);
|
|
813
|
-
}
|
|
814
|
-
return {
|
|
815
|
-
js
|
|
816
|
-
};
|
|
817
|
-
}
|
|
818
|
-
return undefined;
|
|
819
|
-
};
|
|
820
|
-
const createNamespace = (parts)=>{
|
|
821
|
-
let code = `var ${parts[0]};`;
|
|
822
|
-
for(let index = 0; index < parts.length; index++){
|
|
823
|
-
const path = parts.slice(0, index + 1).join(".");
|
|
824
|
-
code += `\n(${path} = ${path} || {});`;
|
|
825
|
-
}
|
|
826
|
-
return code;
|
|
827
|
-
};
|
|
828
|
-
let validateAnimationJson;
|
|
829
|
-
const getAnimationJsonValidation = async ()=>{
|
|
830
|
-
if (validateAnimationJson === undefined) {
|
|
831
|
-
validateAnimationJson = new Ajv({
|
|
832
|
-
coerceTypes: true,
|
|
833
|
-
allErrors: true,
|
|
834
|
-
removeAdditional: true,
|
|
835
|
-
useDefaults: "empty",
|
|
836
|
-
validateSchema: "log"
|
|
837
|
-
}).compile(animationSchema);
|
|
838
|
-
}
|
|
839
|
-
return validateAnimationJson;
|
|
840
|
-
};
|
|
841
|
-
|
|
842
|
-
// Stolen from ig.tools.core
|
|
843
|
-
class PackageVersion {
|
|
844
|
-
static{
|
|
845
|
-
// https://regex101.com/r/90PEY9/1
|
|
846
|
-
this.fullTextMatcher = /(\d+)(\.(\d+)(\.(\d+)(\.(\d+))?(-([^\.]+)\.(\d+))?)?)?/;
|
|
847
|
-
}
|
|
848
|
-
static{
|
|
849
|
-
this.lineMatcher = /^(\d+)(\.(\d+)(\.(\d+)(\.(\d+))?(-([^\.]+)\.(\d+))?)?)?$/;
|
|
850
|
-
}
|
|
851
|
-
static extractFromText(input, description) {
|
|
852
|
-
if (input === undefined) {
|
|
853
|
-
throw new Error(`Can not parse version from undefined`);
|
|
854
|
-
}
|
|
855
|
-
const match = input.match(PackageVersion.fullTextMatcher);
|
|
856
|
-
if (!match) {
|
|
857
|
-
throw new Error(`Could not extract a version from input: ${input}`);
|
|
858
|
-
}
|
|
859
|
-
return PackageVersion.fromMatch(match, description);
|
|
860
|
-
}
|
|
861
|
-
static extractFromLine(input, description) {
|
|
862
|
-
if (input === undefined) {
|
|
863
|
-
throw new Error(`Can not parse version from undefined`);
|
|
864
|
-
}
|
|
865
|
-
const match = input.match(PackageVersion.lineMatcher);
|
|
866
|
-
if (!match) {
|
|
867
|
-
throw new Error(`Could not parse version from input: ${input}`);
|
|
868
|
-
}
|
|
869
|
-
return PackageVersion.fromMatch(match, description);
|
|
870
|
-
}
|
|
871
|
-
static equals(a, b, checkPrerelease = false) {
|
|
872
|
-
if (a.major !== b.major || a.minor !== b.minor || a.patch !== b.patch) {
|
|
873
|
-
return false;
|
|
874
|
-
}
|
|
875
|
-
if (checkPrerelease === false) {
|
|
876
|
-
return true;
|
|
877
|
-
}
|
|
878
|
-
if (a.preRelease === b.preRelease) {
|
|
879
|
-
return true;
|
|
880
|
-
}
|
|
881
|
-
if (a.preRelease === undefined || b.preRelease === undefined) {
|
|
882
|
-
return false;
|
|
883
|
-
}
|
|
884
|
-
return a.preRelease.type === b.preRelease.type && a.preRelease.version === b.preRelease.version;
|
|
885
|
-
}
|
|
886
|
-
static fromMatch([, major, , minor = "0", , patch = "0", , build, , preReleaseType, preReleaseNumber], description) {
|
|
887
|
-
let preRelease = undefined;
|
|
888
|
-
let buildNumber = 100;
|
|
889
|
-
if (preReleaseType && preReleaseNumber) {
|
|
890
|
-
preRelease = {
|
|
891
|
-
type: preReleaseType,
|
|
892
|
-
version: parseInt(preReleaseNumber)
|
|
893
|
-
};
|
|
894
|
-
}
|
|
895
|
-
if (build) {
|
|
896
|
-
buildNumber = Number(build);
|
|
897
|
-
} else if (description) {
|
|
898
|
-
const descriptionMatch = description.match(/(\d+)\)$/);
|
|
899
|
-
if (descriptionMatch) {
|
|
900
|
-
buildNumber = parseInt(descriptionMatch[1]);
|
|
901
|
-
}
|
|
902
|
-
}
|
|
903
|
-
return new PackageVersion(parseInt(major), parseInt(minor), parseInt(patch), preRelease, buildNumber);
|
|
904
|
-
}
|
|
905
|
-
static sort(a, b, ascending = true) {
|
|
906
|
-
const createSortResult = (a, b)=>ascending ? a - b : b - a;
|
|
907
|
-
if (a.major !== b.major) {
|
|
908
|
-
return createSortResult(a.major, b.major);
|
|
909
|
-
}
|
|
910
|
-
if (a.minor !== b.minor) {
|
|
911
|
-
return createSortResult(a.minor, b.minor);
|
|
912
|
-
}
|
|
913
|
-
if (a.patch !== b.patch) {
|
|
914
|
-
return createSortResult(a.patch, b.patch);
|
|
915
|
-
}
|
|
916
|
-
return createSortResult(a.preRelease ? a.preRelease.version : 0, b.preRelease ? b.preRelease.version : 0);
|
|
917
|
-
}
|
|
918
|
-
static toNumber(version) {
|
|
919
|
-
return ((version.major * 1000 + version.minor) * 1000 + version.patch) * 1000 + version.buildNumber;
|
|
920
|
-
}
|
|
921
|
-
constructor(major, minor, patch, preRelease, buildNumber){
|
|
922
|
-
this.major = major;
|
|
923
|
-
this.minor = minor;
|
|
924
|
-
this.patch = patch;
|
|
925
|
-
this.preRelease = preRelease;
|
|
926
|
-
this.buildNumber = buildNumber;
|
|
927
|
-
}
|
|
928
|
-
isPreRelease() {
|
|
929
|
-
return this.preRelease !== undefined;
|
|
930
|
-
}
|
|
931
|
-
clone() {
|
|
932
|
-
return new PackageVersion(this.major, this.minor, this.patch, this.preRelease ? {
|
|
933
|
-
...this.preRelease
|
|
934
|
-
} : undefined, this.buildNumber);
|
|
935
|
-
}
|
|
936
|
-
incrementMajor() {
|
|
937
|
-
this.preRelease = undefined;
|
|
938
|
-
this.patch = 0;
|
|
939
|
-
this.minor = 0;
|
|
940
|
-
this.major++;
|
|
941
|
-
}
|
|
942
|
-
incrementMinor() {
|
|
943
|
-
this.preRelease = undefined;
|
|
944
|
-
this.patch = 0;
|
|
945
|
-
this.minor++;
|
|
946
|
-
}
|
|
947
|
-
incrementPatch() {
|
|
948
|
-
this.preRelease = undefined;
|
|
949
|
-
this.patch++;
|
|
950
|
-
}
|
|
951
|
-
createPreRelease(type) {
|
|
952
|
-
if (!this.preRelease) {
|
|
953
|
-
this.buildNumber = 1;
|
|
954
|
-
} else {
|
|
955
|
-
this.buildNumber++;
|
|
956
|
-
}
|
|
957
|
-
if (this.preRelease && type === this.preRelease.type) {
|
|
958
|
-
this.preRelease.version++;
|
|
959
|
-
return;
|
|
960
|
-
}
|
|
961
|
-
this.preRelease = {
|
|
962
|
-
version: 0,
|
|
963
|
-
type
|
|
964
|
-
};
|
|
965
|
-
}
|
|
966
|
-
createRelease() {
|
|
967
|
-
this.preRelease = undefined;
|
|
968
|
-
this.buildNumber = 100;
|
|
969
|
-
}
|
|
970
|
-
toVersionString({ buildNumber } = {}) {
|
|
971
|
-
let version = [
|
|
972
|
-
this.major,
|
|
973
|
-
this.minor,
|
|
974
|
-
this.patch
|
|
975
|
-
].join(".");
|
|
976
|
-
if (buildNumber) {
|
|
977
|
-
version += "." + this.buildNumber;
|
|
978
|
-
}
|
|
979
|
-
if (this.preRelease) {
|
|
980
|
-
version += `-${this.preRelease.type}.${this.preRelease.version}`;
|
|
981
|
-
}
|
|
982
|
-
return version;
|
|
983
|
-
}
|
|
984
|
-
toDescriptionString(packageName) {
|
|
985
|
-
const base = [
|
|
986
|
-
this.major,
|
|
987
|
-
this.minor,
|
|
988
|
-
this.patch
|
|
989
|
-
].join(".");
|
|
990
|
-
const parts = [
|
|
991
|
-
packageName,
|
|
992
|
-
base
|
|
993
|
-
];
|
|
994
|
-
if (this.preRelease) {
|
|
995
|
-
parts.push(upperCaseFirst(this.preRelease.type));
|
|
996
|
-
parts.push(this.preRelease.version);
|
|
997
|
-
}
|
|
998
|
-
parts.push(`(${base}.${this.buildNumber})`);
|
|
999
|
-
return parts.join(" ");
|
|
1000
|
-
}
|
|
1001
|
-
/**
|
|
1002
|
-
* Determines wether the version is lesser than the input version
|
|
1003
|
-
*
|
|
1004
|
-
* @param {PackageVersion} version
|
|
1005
|
-
* @returns
|
|
1006
|
-
*/ isLesserThan(version) {
|
|
1007
|
-
return PackageVersion.toNumber(this) < PackageVersion.toNumber(version);
|
|
1008
|
-
}
|
|
1009
|
-
/**
|
|
1010
|
-
* Determines wether the version is greater than the input version
|
|
1011
|
-
*
|
|
1012
|
-
* @param {PackageVersion} version
|
|
1013
|
-
* @returns
|
|
1014
|
-
*/ isGreaterThan(version) {
|
|
1015
|
-
return PackageVersion.toNumber(this) > PackageVersion.toNumber(version);
|
|
1016
|
-
}
|
|
1017
|
-
}
|
|
1018
|
-
const upperCaseFirst = (input)=>{
|
|
1019
|
-
return input.slice(0, 1).toUpperCase() + input.slice(1);
|
|
1020
|
-
};
|
|
1021
|
-
|
|
1022
|
-
async function buildFolders(options) {
|
|
1023
|
-
if (options.outDir !== undefined && options.clean) {
|
|
1024
|
-
await fs$1.rm(options.outDir, {
|
|
1025
|
-
recursive: true
|
|
1026
|
-
});
|
|
1027
|
-
}
|
|
1028
|
-
const baseReporter = options.reporter ?? consoleReporter;
|
|
1029
|
-
const workspace = options.workspace;
|
|
1030
|
-
const folders = options.packages;
|
|
1031
|
-
let sortedPackages = sortPackagesByBuildOrder(folders);
|
|
1032
|
-
let index = 1;
|
|
1033
|
-
const manifests = new Map(sortedPackages.map((location)=>[
|
|
1034
|
-
location,
|
|
1035
|
-
readPackageCreatorManifest(location)
|
|
1036
|
-
]));
|
|
1037
|
-
const maxNameLength = Array.from(manifests.values(), (manifest)=>manifest.Package.length).reduce((acc, length)=>Math.max(acc, length), 0);
|
|
1038
|
-
for (const location of sortedPackages){
|
|
1039
|
-
const tsConfig = await ensureTsConfig(location);
|
|
1040
|
-
const data = manifests.get(location);
|
|
1041
|
-
const reporter = options.preparedReporter ?? createPackageScopedReporter(baseReporter, data.Package, index, folders.length, maxNameLength);
|
|
1042
|
-
const outputDirectory = options.outDir || location.scriptsDir;
|
|
1043
|
-
await fs$1.mkdir(outputDirectory, {
|
|
1044
|
-
recursive: true
|
|
1045
|
-
});
|
|
1046
|
-
const manager = new BuildManager(data, (result)=>writeBuildResult(result, data, location, workspace, outputDirectory, options.minimize, reporter), reporter);
|
|
1047
|
-
if (options.banner) {
|
|
1048
|
-
manager.addParticipant("banner", createBannerCommentBuildParticipant(options.banner));
|
|
1049
|
-
}
|
|
1050
|
-
const typescriptFiles = getPackageTypescriptFiles(location);
|
|
1051
|
-
if (!typescriptFiles.some((file)=>path.basename(file).toLowerCase() === "version.ts")) {
|
|
1052
|
-
manager.addParticipant("version", createVersionLogBuildParticipant(data));
|
|
1053
|
-
}
|
|
1054
|
-
if (typescriptFiles.length > 0) {
|
|
1055
|
-
if (isScriptPackageModules(tsConfig.options)) {
|
|
1056
|
-
const { createRollupBuildParticipant } = await import('./rollup-BeQ0dM8U.mjs');
|
|
1057
|
-
manager.addParticipant("rollup", createRollupBuildParticipant(location, data, outputDirectory, !tsConfig.options.declaration));
|
|
1058
|
-
} else {
|
|
1059
|
-
manager.addParticipant("tsc", createTSCBuildParticipant(location, outputDirectory, // in the past we always created declaration files,
|
|
1060
|
-
// so we'll use it as the default for legacy modules
|
|
1061
|
-
tsConfig.options.declaration === false));
|
|
1062
|
-
}
|
|
1063
|
-
}
|
|
1064
|
-
manager.addParticipant("animation", createAnimationBuildParticipant(location, data));
|
|
1065
|
-
await new Promise((resolve, reject)=>{
|
|
1066
|
-
manager.addListener("start", ()=>{
|
|
1067
|
-
reporter.log(`Build started`);
|
|
1068
|
-
});
|
|
1069
|
-
manager.addListener("error", (error)=>{
|
|
1070
|
-
reject(error);
|
|
1071
|
-
});
|
|
1072
|
-
manager.addListener("build", ()=>{
|
|
1073
|
-
reporter.log(`Build complete`);
|
|
1074
|
-
resolve();
|
|
1075
|
-
});
|
|
1076
|
-
manager.run();
|
|
1077
|
-
});
|
|
1078
|
-
if (options.docs) {
|
|
1079
|
-
if (!options.docsHandler) {
|
|
1080
|
-
throw new Error("Handler for typescript docs not available");
|
|
1081
|
-
}
|
|
1082
|
-
reporter.log("Generating typedoc documentation");
|
|
1083
|
-
await options.docsHandler(location, path.join(outputDirectory, `${data.Package}.d.ts`), path.join(workspace.path, "docs", data.Package), data.Package);
|
|
1084
|
-
}
|
|
1085
|
-
index++;
|
|
1086
|
-
}
|
|
1087
|
-
}
|
|
1088
|
-
async function buildFoldersWatch(options) {
|
|
1089
|
-
if (options.outDir !== undefined && options.clean) {
|
|
1090
|
-
await fs$1.rm(options.outDir, {
|
|
1091
|
-
recursive: true
|
|
1092
|
-
});
|
|
1093
|
-
}
|
|
1094
|
-
const workspace = options.workspace;
|
|
1095
|
-
const folders = options.packages;
|
|
1096
|
-
options.reporter ?? consoleReporter;
|
|
1097
|
-
let sortedPackages = sortPackagesByBuildOrder(folders);
|
|
1098
|
-
let index = 1;
|
|
1099
|
-
const manifests = new Map(sortedPackages.map((location)=>[
|
|
1100
|
-
location,
|
|
1101
|
-
readPackageCreatorManifest(location)
|
|
1102
|
-
]));
|
|
1103
|
-
const maxNameLength = Array.from(manifests.values(), (manifest)=>manifest.Package.length).reduce((acc, length)=>Math.max(acc, length), 0);
|
|
1104
|
-
const managers = [];
|
|
1105
|
-
for (const location of sortedPackages){
|
|
1106
|
-
const tsConfig = await ensureTsConfig(location);
|
|
1107
|
-
const baseReporter = options.reporter ?? consoleReporter;
|
|
1108
|
-
const data = manifests.get(location);
|
|
1109
|
-
const reporter = options.preparedReporter ?? createPackageScopedReporter(baseReporter, data.Package, index, folders.length, maxNameLength);
|
|
1110
|
-
const outputDirectory = options.outDir || location.scriptsDir;
|
|
1111
|
-
await fs$1.mkdir(outputDirectory, {
|
|
1112
|
-
recursive: true
|
|
1113
|
-
});
|
|
1114
|
-
const manager = new BuildManager(data, (result)=>writeBuildResult(result, data, location, workspace, outputDirectory, options.minimize, reporter), reporter);
|
|
1115
|
-
if (options.banner) {
|
|
1116
|
-
manager.addParticipant("banner", createBannerCommentBuildParticipant(options.banner));
|
|
1117
|
-
}
|
|
1118
|
-
const typescriptFiles = getPackageTypescriptFiles(location);
|
|
1119
|
-
if (!typescriptFiles.some((file)=>path.basename(file).toLowerCase() === "version.ts")) {
|
|
1120
|
-
manager.addParticipant("version", createVersionLogBuildParticipant(data));
|
|
1121
|
-
}
|
|
1122
|
-
if (typescriptFiles.length > 0) {
|
|
1123
|
-
if (isScriptPackageModules(tsConfig.options)) {
|
|
1124
|
-
const { createRollupWatchBuildParticipant } = await import('./rollup-BeQ0dM8U.mjs');
|
|
1125
|
-
manager.addParticipant("rollup", createRollupWatchBuildParticipant(location, data, outputDirectory, !tsConfig.options.declaration));
|
|
1126
|
-
} else {
|
|
1127
|
-
manager.addParticipant("tsc", createTSCWatchBuildParticipant(location, outputDirectory, // in the past we always created declaration files,
|
|
1128
|
-
// so we'll use it as the default for legacy modules
|
|
1129
|
-
tsConfig.options.declaration === false));
|
|
1130
|
-
}
|
|
1131
|
-
}
|
|
1132
|
-
manager.addParticipant("animation", createAnimationWatchBuildParticipant(location, data));
|
|
1133
|
-
await new Promise((resolve, reject)=>{
|
|
1134
|
-
manager.addListener("start", ()=>{
|
|
1135
|
-
reporter.log(`Build started`);
|
|
1136
|
-
});
|
|
1137
|
-
manager.addListener("error", (error)=>{
|
|
1138
|
-
reporter.log(`Build failed: ${EOL}${error}`);
|
|
1139
|
-
resolve();
|
|
1140
|
-
});
|
|
1141
|
-
manager.addListener("build", ()=>{
|
|
1142
|
-
reporter.log(`Build complete`);
|
|
1143
|
-
resolve();
|
|
1144
|
-
});
|
|
1145
|
-
manager.run();
|
|
1146
|
-
});
|
|
1147
|
-
managers.push(manager);
|
|
1148
|
-
index++;
|
|
1149
|
-
}
|
|
1150
|
-
return {
|
|
1151
|
-
destroy: ()=>{
|
|
1152
|
-
for (const manager of managers){
|
|
1153
|
-
manager.destroy();
|
|
1154
|
-
}
|
|
1155
|
-
}
|
|
1156
|
-
};
|
|
1157
|
-
}
|
|
1158
|
-
async function writeBuildResult(buildResult, manifest, location, workspace, outputDirectory, minimize, reporter) {
|
|
1159
|
-
let js = buildResult.js;
|
|
1160
|
-
if (buildResult.sourceMap) {
|
|
1161
|
-
js += `\n//# sourceMappingURL=${manifest.Package}.js.map`;
|
|
1162
|
-
}
|
|
1163
|
-
await fs$1.writeFile(path.join(outputDirectory, `${manifest.Package}.js`), js, {
|
|
1164
|
-
encoding: "utf8"
|
|
1165
|
-
});
|
|
1166
|
-
if (buildResult.declarations !== undefined) {
|
|
1167
|
-
await fs$1.writeFile(path.join(outputDirectory, `${manifest.Package}.d.ts`), buildResult.declarations, {
|
|
1168
|
-
encoding: "utf8"
|
|
1169
|
-
});
|
|
1170
|
-
}
|
|
1171
|
-
if (buildResult.sourceMap !== undefined) {
|
|
1172
|
-
await fs$1.writeFile(path.join(outputDirectory, `${manifest.Package}.js.map`), buildResult.sourceMap, {
|
|
1173
|
-
encoding: "utf8"
|
|
1174
|
-
});
|
|
1175
|
-
}
|
|
1176
|
-
if (minimize) {
|
|
1177
|
-
reporter.log("Minifying the output");
|
|
1178
|
-
const minifyResult = await terser.minify(js, {
|
|
1179
|
-
ecma: 5,
|
|
1180
|
-
sourceMap: {
|
|
1181
|
-
content: buildResult.sourceMap,
|
|
1182
|
-
includeSources: false
|
|
1183
|
-
}
|
|
1184
|
-
});
|
|
1185
|
-
const minifiedPath = path.join(outputDirectory, `${manifest.Package}.min.js`);
|
|
1186
|
-
let code = minifyResult.code;
|
|
1187
|
-
if (minifyResult.map) {
|
|
1188
|
-
code += `\n//# sourceMappingURL=${manifest.Package}.min.js.map`;
|
|
1189
|
-
}
|
|
1190
|
-
await fs$1.writeFile(minifiedPath, code, {
|
|
1191
|
-
encoding: "utf8"
|
|
1192
|
-
});
|
|
1193
|
-
if (minifyResult.map !== undefined) {
|
|
1194
|
-
await fs$1.writeFile(minifiedPath + ".map", typeof minifyResult.map === "string" ? minifyResult.map : JSON.stringify(minifyResult.map), {
|
|
1195
|
-
encoding: "utf8"
|
|
1196
|
-
});
|
|
1197
|
-
}
|
|
1198
|
-
}
|
|
1199
|
-
if (location.path.includes("Basics") && buildResult.declarations !== undefined) {
|
|
1200
|
-
await fs$1.mkdir(path.join(workspace.path, "lib"), {
|
|
1201
|
-
recursive: true
|
|
1202
|
-
});
|
|
1203
|
-
reporter.log("Copying basics definition file to the lib folder");
|
|
1204
|
-
await fs$1.writeFile(path.join(workspace.path, "lib", `${manifest.Package}.d.ts`), buildResult.declarations, {
|
|
1205
|
-
encoding: "utf8"
|
|
1206
|
-
});
|
|
1207
|
-
}
|
|
1208
|
-
}
|
|
1209
|
-
function createVersionLogBuildParticipant(manifest) {
|
|
1210
|
-
return (env)=>{
|
|
1211
|
-
env.onBuildStart();
|
|
1212
|
-
const parsedVersion = manifest.Version !== undefined ? PackageVersion.extractFromLine(manifest.Version) : undefined;
|
|
1213
|
-
let logText;
|
|
1214
|
-
if (parsedVersion !== undefined) {
|
|
1215
|
-
logText = parsedVersion.toDescriptionString(manifest.Package);
|
|
1216
|
-
} else {
|
|
1217
|
-
logText = manifest.Package;
|
|
1218
|
-
}
|
|
1219
|
-
logText += ".";
|
|
1220
|
-
if (manifest.Copyright !== undefined) {
|
|
1221
|
-
logText += " " + manifest.Copyright;
|
|
1222
|
-
}
|
|
1223
|
-
env.onBuildEnd({
|
|
1224
|
-
type: "success",
|
|
1225
|
-
artefacts: {
|
|
1226
|
-
js: `console.log(${JSON.stringify(logText)})`
|
|
1227
|
-
}
|
|
1228
|
-
});
|
|
1229
|
-
return {
|
|
1230
|
-
destroy: ()=>{}
|
|
1231
|
-
};
|
|
1232
|
-
};
|
|
1233
|
-
}
|
|
1234
|
-
function createBannerCommentBuildParticipant(options) {
|
|
1235
|
-
return (env)=>{
|
|
1236
|
-
env.onBuildStart();
|
|
1237
|
-
const banner = createBannerComment(options);
|
|
1238
|
-
env.onBuildEnd({
|
|
1239
|
-
type: "success",
|
|
1240
|
-
artefacts: {
|
|
1241
|
-
js: banner ?? "",
|
|
1242
|
-
declarations: banner ?? ""
|
|
1243
|
-
}
|
|
1244
|
-
});
|
|
1245
|
-
return {
|
|
1246
|
-
destroy: ()=>{}
|
|
1247
|
-
};
|
|
1248
|
-
};
|
|
1249
|
-
}
|
|
1250
|
-
async function ensureTsConfig(location) {
|
|
1251
|
-
const tsconfigPath = path.join(location.scriptsDir, "tsconfig.json");
|
|
1252
|
-
try {
|
|
1253
|
-
const content = JSON.parse(await fs$1.readFile(tsconfigPath, "utf8"));
|
|
1254
|
-
applyTsConfigOptions(content);
|
|
1255
|
-
await fs$1.writeFile(tsconfigPath, JSON.stringify(content, undefined, "\t"), "utf8");
|
|
1256
|
-
return ts.parseJsonConfigFileContent(content, ts.sys, location.scriptsDir);
|
|
1257
|
-
} catch (err) {
|
|
1258
|
-
if (!isErrorENOENT(err)) {
|
|
1259
|
-
throw err;
|
|
1260
|
-
}
|
|
1261
|
-
const content = {};
|
|
1262
|
-
applyTsConfigOptions(content);
|
|
1263
|
-
await fs$1.writeFile(tsconfigPath, JSON.stringify(content, undefined, "\t"), "utf8");
|
|
1264
|
-
return ts.parseJsonConfigFileContent(content, ts.sys, location.scriptsDir);
|
|
1265
|
-
}
|
|
1266
|
-
}
|
|
1267
|
-
function applyTsConfigOptions(data) {
|
|
1268
|
-
if (data.compilerOptions?.module?.toLowerCase().startsWith("es")) {
|
|
1269
|
-
data.compilerOptions = data.compilerOptions ?? {};
|
|
1270
|
-
data.compilerOptions.target = "esnext";
|
|
1271
|
-
data.compilerOptions.lib = [
|
|
1272
|
-
"es2024",
|
|
1273
|
-
"dom"
|
|
1274
|
-
];
|
|
1275
|
-
data.compilerOptions.module = "es2015";
|
|
1276
|
-
data.compilerOptions.moduleResolution = "node";
|
|
1277
|
-
} else {
|
|
1278
|
-
data.compilerOptions = data.compilerOptions ?? {};
|
|
1279
|
-
data.compilerOptions.target = "es5";
|
|
1280
|
-
data.compilerOptions.lib = [
|
|
1281
|
-
"es5",
|
|
1282
|
-
"dom"
|
|
1283
|
-
];
|
|
1284
|
-
}
|
|
1285
|
-
}
|
|
1286
|
-
function sortPackagesByBuildOrder(folders) {
|
|
1287
|
-
const packages = Array.from(folders).reduce((acc, location)=>{
|
|
1288
|
-
const data = readPackageNpmManifest(location);
|
|
1289
|
-
if (data !== undefined) {
|
|
1290
|
-
acc[data.name] = {
|
|
1291
|
-
data,
|
|
1292
|
-
location
|
|
1293
|
-
};
|
|
1294
|
-
} else {
|
|
1295
|
-
acc[location.path] = {
|
|
1296
|
-
data: undefined,
|
|
1297
|
-
location
|
|
1298
|
-
};
|
|
1299
|
-
}
|
|
1300
|
-
return acc;
|
|
1301
|
-
}, {});
|
|
1302
|
-
const packageDependencies = Object.getOwnPropertyNames(packages).reduce((acc, packageName)=>{
|
|
1303
|
-
const packageData = packages[packageName];
|
|
1304
|
-
if (packageData.data === undefined) {
|
|
1305
|
-
acc[packageName] = [];
|
|
1306
|
-
} else {
|
|
1307
|
-
acc[packageName] = Object.getOwnPropertyNames({
|
|
1308
|
-
...packageData.data.devDependencies,
|
|
1309
|
-
...packageData.data.dependencies,
|
|
1310
|
-
...packageData.data.peerDependencies
|
|
1311
|
-
}).filter((packageName)=>packages[packageName] !== undefined);
|
|
1312
|
-
}
|
|
1313
|
-
return acc;
|
|
1314
|
-
}, {});
|
|
1315
|
-
const sortedPackages = toposort(packageDependencies);
|
|
1316
|
-
const result = [];
|
|
1317
|
-
for (const packageName of sortedPackages){
|
|
1318
|
-
const location = packages[packageName].location;
|
|
1319
|
-
if (readPackageCreatorManifest(location).Package.endsWith(".Basics")) {
|
|
1320
|
-
result.unshift(location);
|
|
1321
|
-
} else {
|
|
1322
|
-
result.push(location);
|
|
1323
|
-
}
|
|
1324
|
-
}
|
|
1325
|
-
return result;
|
|
1326
|
-
}
|
|
1327
|
-
function createBannerComment(banner) {
|
|
1328
|
-
const bannerParts = [];
|
|
1329
|
-
if (banner.text) {
|
|
1330
|
-
bannerParts.push(" * " + banner.text);
|
|
1331
|
-
}
|
|
1332
|
-
{
|
|
1333
|
-
const details = [];
|
|
1334
|
-
if (banner.version) {
|
|
1335
|
-
details.push(`Version: ${banner.version}`);
|
|
1336
|
-
}
|
|
1337
|
-
if (banner.commit) {
|
|
1338
|
-
if (banner.commitDirty) {
|
|
1339
|
-
details.push(`Commit: ${banner.commit} (dirty)`);
|
|
1340
|
-
} else {
|
|
1341
|
-
details.push(`Commit: ${banner.commit}`);
|
|
1342
|
-
}
|
|
1343
|
-
}
|
|
1344
|
-
if (banner.date) {
|
|
1345
|
-
details.push(`Date: ${banner.date.toISOString()}`);
|
|
1346
|
-
}
|
|
1347
|
-
const detailsText = details.map((line)=>` * ${line}`).join("\n");
|
|
1348
|
-
if (detailsText) {
|
|
1349
|
-
bannerParts.push(detailsText);
|
|
1350
|
-
}
|
|
1351
|
-
}
|
|
1352
|
-
const bannerText = bannerParts.join("\n\n");
|
|
1353
|
-
if (bannerText) {
|
|
1354
|
-
return `/*
|
|
1355
|
-
${bannerText}
|
|
1356
|
-
*
|
|
1357
|
-
* @preserve
|
|
1358
|
-
*/`;
|
|
1359
|
-
}
|
|
1360
|
-
return undefined;
|
|
1361
|
-
}
|
|
1362
|
-
|
|
1363
|
-
var index = /*#__PURE__*/Object.freeze({
|
|
1364
|
-
__proto__: null,
|
|
1365
|
-
buildFolders: buildFolders,
|
|
1366
|
-
buildFoldersWatch: buildFoldersWatch
|
|
1367
|
-
});
|
|
1368
|
-
|
|
1369
|
-
export { PackageVersion as P, consoleReporter as a, buildFolders as b, createPackageScopedReporter as c, index as i };
|
|
1370
|
-
//# sourceMappingURL=index-Dn5_iPca.mjs.map
|