@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
package/build/index-7d81fa31.mjs
DELETED
|
@@ -1,706 +0,0 @@
|
|
|
1
|
-
import * as path from 'path';
|
|
2
|
-
import * as fs from 'fs';
|
|
3
|
-
import * as terser from 'terser';
|
|
4
|
-
import 'resolve';
|
|
5
|
-
import 'write-pkg';
|
|
6
|
-
import { r as readPackageCreatorManifest, c as readPackageAnimationList, q as readPackageNpmManifest } from './cli-c7da3faf.mjs';
|
|
7
|
-
import { g as getPackageTypescriptFiles } from './scripts-7ed8dff6.mjs';
|
|
8
|
-
import 'node:path';
|
|
9
|
-
import 'node:fs';
|
|
10
|
-
import 'axios';
|
|
11
|
-
import ts from 'typescript';
|
|
12
|
-
import typedoc from 'typedoc';
|
|
13
|
-
import glob from 'glob';
|
|
14
|
-
import Ajv from 'ajv';
|
|
15
|
-
|
|
16
|
-
const logPackageMessage = (name, step, index, total)=>{
|
|
17
|
-
const numLength = total === undefined ? undefined : total.toString().length;
|
|
18
|
-
const indexString = total === undefined || total < 2 ? "" : `${index.toString().padStart(numLength, "0")}/${total} `;
|
|
19
|
-
const identifierString = `${indexString}${name.padEnd(15)}`;
|
|
20
|
-
console.log(`${identifierString} >> ${step}`);
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const tryReadTsConfig = (location)=>{
|
|
24
|
-
const { config } = ts.readConfigFile(path.join(location.scriptsDir, "tsconfig.json"), (path)=>{
|
|
25
|
-
try {
|
|
26
|
-
return fs.readFileSync(path, "utf8");
|
|
27
|
-
} catch {
|
|
28
|
-
return undefined;
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
return config;
|
|
32
|
-
};
|
|
33
|
-
const build = async (location, outputDir)=>{
|
|
34
|
-
const config = tryReadTsConfig(location);
|
|
35
|
-
config.compilerOptions.lib = [
|
|
36
|
-
"es5",
|
|
37
|
-
"dom"
|
|
38
|
-
];
|
|
39
|
-
const result = ts.convertCompilerOptionsFromJson(config.compilerOptions, location.scriptsDir);
|
|
40
|
-
const compilerOptions = {
|
|
41
|
-
...result.options,
|
|
42
|
-
removeComments: false,
|
|
43
|
-
declaration: true,
|
|
44
|
-
sourceMap: false,
|
|
45
|
-
// We don't use tsc to actually emit the files, but we still need to set the correct
|
|
46
|
-
// output directory so the compiler can rewrite the `reference path` directives.
|
|
47
|
-
outFile: path.join(outputDir, "out.js"),
|
|
48
|
-
target: ts.ScriptTarget.ES5,
|
|
49
|
-
noEmitOnError: true
|
|
50
|
-
};
|
|
51
|
-
const host = ts.createCompilerHost(compilerOptions);
|
|
52
|
-
host.getCurrentDirectory = ()=>location.scriptsDir;
|
|
53
|
-
let js;
|
|
54
|
-
let definitions;
|
|
55
|
-
host.writeFile = (fileName, data, writeByteOrderMark)=>{
|
|
56
|
-
if (fileName.endsWith(".js")) {
|
|
57
|
-
js = data;
|
|
58
|
-
} else if (fileName.endsWith(".d.ts")) {
|
|
59
|
-
definitions = data;
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
const files = getPackageTypescriptFiles(location);
|
|
63
|
-
if (files.length === 0) {
|
|
64
|
-
throw new Error(`Expected typescript files to exist when building a package. Packages only consisting of animation jsons do not need to be built.`);
|
|
65
|
-
}
|
|
66
|
-
const programOptions = {
|
|
67
|
-
rootNames: files,
|
|
68
|
-
options: compilerOptions,
|
|
69
|
-
host
|
|
70
|
-
};
|
|
71
|
-
const program = ts.createProgram(programOptions);
|
|
72
|
-
const emitResult = program.emit();
|
|
73
|
-
const allDiagnostics = ts.getPreEmitDiagnostics(program);
|
|
74
|
-
if (!emitResult.emitSkipped) {
|
|
75
|
-
if (allDiagnostics.length > 0) {
|
|
76
|
-
console.log(allDiagnostics.map(createErrorMessage).join("\n"));
|
|
77
|
-
}
|
|
78
|
-
if (js === undefined || definitions === undefined) {
|
|
79
|
-
throw new Error(`Unexpected: no js or definitions were created`);
|
|
80
|
-
}
|
|
81
|
-
return {
|
|
82
|
-
js,
|
|
83
|
-
definitions
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
const error = allDiagnostics.map(createErrorMessage).join("\n");
|
|
87
|
-
throw new Error(error);
|
|
88
|
-
};
|
|
89
|
-
const createErrorMessage = (diagnostic)=>{
|
|
90
|
-
if (!diagnostic.file) {
|
|
91
|
-
return `${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`;
|
|
92
|
-
}
|
|
93
|
-
const { line , character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
|
|
94
|
-
const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
|
|
95
|
-
return `${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`;
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
const generateDocs = async (location, declarationFile, outFolder, name)=>{
|
|
99
|
-
const app = new typedoc.Application();
|
|
100
|
-
const mediaDir = path.join(location.manifestDir, "Media");
|
|
101
|
-
app.bootstrap({
|
|
102
|
-
entryPoints: [
|
|
103
|
-
declarationFile
|
|
104
|
-
],
|
|
105
|
-
media: mediaDir,
|
|
106
|
-
out: outFolder,
|
|
107
|
-
tsconfig: path.join(location.scriptsDir, "tsconfig.json"),
|
|
108
|
-
skipErrorChecking: true
|
|
109
|
-
});
|
|
110
|
-
app.options.setCompilerOptions([
|
|
111
|
-
declarationFile
|
|
112
|
-
], {
|
|
113
|
-
target: ts.ScriptTarget.ES5
|
|
114
|
-
}, undefined);
|
|
115
|
-
app.options.setValue("name", name);
|
|
116
|
-
const [readmePath] = glob.sync("**/readme.md", {
|
|
117
|
-
absolute: true,
|
|
118
|
-
cwd: location.manifestDir
|
|
119
|
-
});
|
|
120
|
-
if (readmePath) {
|
|
121
|
-
app.options.setValue("readme", readmePath);
|
|
122
|
-
}
|
|
123
|
-
const project = app.convert();
|
|
124
|
-
if (project) {
|
|
125
|
-
await app.generateDocs(project, outFolder);
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
// Stolen from ig.tools.core
|
|
130
|
-
const toposort = (packages)=>{
|
|
131
|
-
const queue = Object.getOwnPropertyNames(packages);
|
|
132
|
-
const result = [];
|
|
133
|
-
let index = 0;
|
|
134
|
-
while(queue.length > 0){
|
|
135
|
-
if (index >= queue.length) {
|
|
136
|
-
throw new Error("Packages can not have cyclic dependencies");
|
|
137
|
-
}
|
|
138
|
-
const queueEntry = queue[index];
|
|
139
|
-
const dependencies = packages[queueEntry];
|
|
140
|
-
const dependencyQueued = dependencies.some((dependency)=>queue.includes(dependency));
|
|
141
|
-
if (dependencyQueued) {
|
|
142
|
-
index++;
|
|
143
|
-
continue;
|
|
144
|
-
}
|
|
145
|
-
queue.splice(index, 1);
|
|
146
|
-
index = 0;
|
|
147
|
-
result.push(queueEntry);
|
|
148
|
-
}
|
|
149
|
-
return result;
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
var animationSchema = {
|
|
153
|
-
$schema: "http://json-schema.org/draft-07/schema",
|
|
154
|
-
$id: "https://archive.intelligentgraphics.biz/schemas/gfx/animation.json",
|
|
155
|
-
$comment: "Version 2023-02-17, Source: ig.data.gfx/Specs/animation.json",
|
|
156
|
-
title: "Animation description format",
|
|
157
|
-
additionalProperties: false,
|
|
158
|
-
type: "object",
|
|
159
|
-
properties: {
|
|
160
|
-
$schema: {
|
|
161
|
-
type: "string"
|
|
162
|
-
},
|
|
163
|
-
Id: {
|
|
164
|
-
type: "string",
|
|
165
|
-
description: "Animation id, to be unique in the project scope. Needs to be a valid JavaScript identifier."
|
|
166
|
-
},
|
|
167
|
-
Animations: {
|
|
168
|
-
type: "array",
|
|
169
|
-
description: "Declaration of animation states for gfx objects",
|
|
170
|
-
items: {
|
|
171
|
-
type: "object",
|
|
172
|
-
additionalProperties: false,
|
|
173
|
-
properties: {
|
|
174
|
-
_: {
|
|
175
|
-
type: "string",
|
|
176
|
-
description: "Comment"
|
|
177
|
-
},
|
|
178
|
-
Path: {
|
|
179
|
-
$ref: "#/definitions/igxcPath"
|
|
180
|
-
},
|
|
181
|
-
States: {
|
|
182
|
-
type: "object",
|
|
183
|
-
additionalProperties: {
|
|
184
|
-
type: "object",
|
|
185
|
-
additionalProperties: false,
|
|
186
|
-
properties: {
|
|
187
|
-
Position: {
|
|
188
|
-
$ref: "#/definitions/vec3"
|
|
189
|
-
},
|
|
190
|
-
Rotation: {
|
|
191
|
-
$ref: "#/definitions/rotation"
|
|
192
|
-
},
|
|
193
|
-
Scaling: {
|
|
194
|
-
$ref: "#/definitions/vec3"
|
|
195
|
-
},
|
|
196
|
-
Visibility: {
|
|
197
|
-
type: "boolean"
|
|
198
|
-
},
|
|
199
|
-
Deformation: {
|
|
200
|
-
anyOf: [
|
|
201
|
-
{
|
|
202
|
-
type: "number"
|
|
203
|
-
},
|
|
204
|
-
{
|
|
205
|
-
type: "string"
|
|
206
|
-
}
|
|
207
|
-
]
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
},
|
|
215
|
-
Kinematics: {
|
|
216
|
-
oneOf: [
|
|
217
|
-
{
|
|
218
|
-
$ref: "#/definitions/kinematicChain"
|
|
219
|
-
},
|
|
220
|
-
{
|
|
221
|
-
type: "array",
|
|
222
|
-
items: {
|
|
223
|
-
$ref: "#/definitions/kinematicChain"
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
]
|
|
227
|
-
},
|
|
228
|
-
LinkedPoints: {
|
|
229
|
-
type: "object",
|
|
230
|
-
additionalProperties: {
|
|
231
|
-
type: "array",
|
|
232
|
-
items: {
|
|
233
|
-
type: "string"
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
},
|
|
237
|
-
_: {
|
|
238
|
-
type: "string",
|
|
239
|
-
description: "Comment"
|
|
240
|
-
}
|
|
241
|
-
},
|
|
242
|
-
definitions: {
|
|
243
|
-
vec3: {
|
|
244
|
-
type: "object",
|
|
245
|
-
additionalProperties: false,
|
|
246
|
-
properties: {
|
|
247
|
-
X: {
|
|
248
|
-
anyOf: [
|
|
249
|
-
{
|
|
250
|
-
type: "number"
|
|
251
|
-
},
|
|
252
|
-
{
|
|
253
|
-
type: "string"
|
|
254
|
-
}
|
|
255
|
-
]
|
|
256
|
-
},
|
|
257
|
-
Y: {
|
|
258
|
-
anyOf: [
|
|
259
|
-
{
|
|
260
|
-
type: "number"
|
|
261
|
-
},
|
|
262
|
-
{
|
|
263
|
-
type: "string"
|
|
264
|
-
}
|
|
265
|
-
]
|
|
266
|
-
},
|
|
267
|
-
Z: {
|
|
268
|
-
anyOf: [
|
|
269
|
-
{
|
|
270
|
-
type: "number"
|
|
271
|
-
},
|
|
272
|
-
{
|
|
273
|
-
type: "string"
|
|
274
|
-
}
|
|
275
|
-
]
|
|
276
|
-
},
|
|
277
|
-
_: {
|
|
278
|
-
type: "string",
|
|
279
|
-
description: "Comment"
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
},
|
|
283
|
-
rotation: {
|
|
284
|
-
type: "object",
|
|
285
|
-
additionalProperties: false,
|
|
286
|
-
properties: {
|
|
287
|
-
Q: {
|
|
288
|
-
description: "If true, the rotation is considered to be a Quaternion. Otherwise, it's interpreted as Euler arcs and W will be ignored.",
|
|
289
|
-
type: "boolean"
|
|
290
|
-
},
|
|
291
|
-
X: {
|
|
292
|
-
anyOf: [
|
|
293
|
-
{
|
|
294
|
-
type: "number"
|
|
295
|
-
},
|
|
296
|
-
{
|
|
297
|
-
type: "string"
|
|
298
|
-
}
|
|
299
|
-
]
|
|
300
|
-
},
|
|
301
|
-
Y: {
|
|
302
|
-
anyOf: [
|
|
303
|
-
{
|
|
304
|
-
type: "number"
|
|
305
|
-
},
|
|
306
|
-
{
|
|
307
|
-
type: "string"
|
|
308
|
-
}
|
|
309
|
-
]
|
|
310
|
-
},
|
|
311
|
-
Z: {
|
|
312
|
-
anyOf: [
|
|
313
|
-
{
|
|
314
|
-
type: "number"
|
|
315
|
-
},
|
|
316
|
-
{
|
|
317
|
-
type: "string"
|
|
318
|
-
}
|
|
319
|
-
]
|
|
320
|
-
},
|
|
321
|
-
W: {
|
|
322
|
-
anyOf: [
|
|
323
|
-
{
|
|
324
|
-
type: "number"
|
|
325
|
-
},
|
|
326
|
-
{
|
|
327
|
-
type: "string"
|
|
328
|
-
}
|
|
329
|
-
]
|
|
330
|
-
},
|
|
331
|
-
_: {
|
|
332
|
-
type: "string",
|
|
333
|
-
description: "Comment"
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
},
|
|
337
|
-
igxcPath: {
|
|
338
|
-
type: "string",
|
|
339
|
-
description: "Relative path of the target object",
|
|
340
|
-
pattern: "^((o|e)\\d+(\\.(o|e)\\d+)*|\\.)$"
|
|
341
|
-
},
|
|
342
|
-
param: {
|
|
343
|
-
type: "string",
|
|
344
|
-
pattern: "^Param\\d+$"
|
|
345
|
-
},
|
|
346
|
-
kinematicChain: {
|
|
347
|
-
type: "object",
|
|
348
|
-
additionalProperties: false,
|
|
349
|
-
properties: {
|
|
350
|
-
GeometryBase: {
|
|
351
|
-
type: "string"
|
|
352
|
-
},
|
|
353
|
-
Joints: {
|
|
354
|
-
type: "array",
|
|
355
|
-
items: {
|
|
356
|
-
type: "object",
|
|
357
|
-
additionalProperties: false,
|
|
358
|
-
properties: {
|
|
359
|
-
Name: {
|
|
360
|
-
oneOf: [
|
|
361
|
-
{
|
|
362
|
-
$ref: "#/definitions/param"
|
|
363
|
-
},
|
|
364
|
-
{
|
|
365
|
-
type: "string"
|
|
366
|
-
}
|
|
367
|
-
]
|
|
368
|
-
},
|
|
369
|
-
HeadX: {
|
|
370
|
-
oneOf: [
|
|
371
|
-
{
|
|
372
|
-
$ref: "#/definitions/param"
|
|
373
|
-
},
|
|
374
|
-
{
|
|
375
|
-
$ref: "#/definitions/igxcPath"
|
|
376
|
-
}
|
|
377
|
-
]
|
|
378
|
-
},
|
|
379
|
-
HeadY: {
|
|
380
|
-
oneOf: [
|
|
381
|
-
{
|
|
382
|
-
$ref: "#/definitions/param"
|
|
383
|
-
},
|
|
384
|
-
{
|
|
385
|
-
$ref: "#/definitions/igxcPath"
|
|
386
|
-
}
|
|
387
|
-
]
|
|
388
|
-
},
|
|
389
|
-
HeadZ: {
|
|
390
|
-
oneOf: [
|
|
391
|
-
{
|
|
392
|
-
$ref: "#/definitions/param"
|
|
393
|
-
},
|
|
394
|
-
{
|
|
395
|
-
$ref: "#/definitions/igxcPath"
|
|
396
|
-
}
|
|
397
|
-
]
|
|
398
|
-
},
|
|
399
|
-
Tail: {
|
|
400
|
-
oneOf: [
|
|
401
|
-
{
|
|
402
|
-
$ref: "#/definitions/param"
|
|
403
|
-
},
|
|
404
|
-
{
|
|
405
|
-
$ref: "#/definitions/igxcPath"
|
|
406
|
-
}
|
|
407
|
-
]
|
|
408
|
-
},
|
|
409
|
-
LimitLeft: {
|
|
410
|
-
type: "number"
|
|
411
|
-
},
|
|
412
|
-
LimitRight: {
|
|
413
|
-
type: "number"
|
|
414
|
-
},
|
|
415
|
-
LimitUp: {
|
|
416
|
-
type: "number"
|
|
417
|
-
},
|
|
418
|
-
LimitDown: {
|
|
419
|
-
type: "number"
|
|
420
|
-
},
|
|
421
|
-
FollowJointNode: {
|
|
422
|
-
$ref: "#/definitions/igxcPath"
|
|
423
|
-
},
|
|
424
|
-
_TargetNodeForFollow: {
|
|
425
|
-
type: "string"
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
},
|
|
430
|
-
Target: {
|
|
431
|
-
oneOf: [
|
|
432
|
-
{
|
|
433
|
-
$ref: "#/definitions/igxcPath"
|
|
434
|
-
},
|
|
435
|
-
{
|
|
436
|
-
$ref: "#/definitions/param"
|
|
437
|
-
},
|
|
438
|
-
{
|
|
439
|
-
type: "string",
|
|
440
|
-
enum: [
|
|
441
|
-
"subbase"
|
|
442
|
-
]
|
|
443
|
-
}
|
|
444
|
-
]
|
|
445
|
-
},
|
|
446
|
-
Parent: {
|
|
447
|
-
oneOf: [
|
|
448
|
-
{
|
|
449
|
-
$ref: "#/definitions/igxcPath"
|
|
450
|
-
},
|
|
451
|
-
{
|
|
452
|
-
type: "string",
|
|
453
|
-
enum: [
|
|
454
|
-
"root"
|
|
455
|
-
]
|
|
456
|
-
}
|
|
457
|
-
]
|
|
458
|
-
},
|
|
459
|
-
Tolerance: {
|
|
460
|
-
type: "number"
|
|
461
|
-
},
|
|
462
|
-
MaxIterations: {
|
|
463
|
-
type: "integer"
|
|
464
|
-
},
|
|
465
|
-
_: {
|
|
466
|
-
type: "string",
|
|
467
|
-
description: "Comment"
|
|
468
|
-
},
|
|
469
|
-
__: {
|
|
470
|
-
type: "string",
|
|
471
|
-
description: "Super Comment"
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
};
|
|
477
|
-
|
|
478
|
-
let validateAnimationJson;
|
|
479
|
-
const getAnimationJsonValidation = async ()=>{
|
|
480
|
-
if (validateAnimationJson === undefined) {
|
|
481
|
-
validateAnimationJson = new Ajv({
|
|
482
|
-
coerceTypes: true,
|
|
483
|
-
allErrors: true,
|
|
484
|
-
removeAdditional: true,
|
|
485
|
-
useDefaults: "empty",
|
|
486
|
-
validateSchema: "log"
|
|
487
|
-
}).compile(animationSchema);
|
|
488
|
-
}
|
|
489
|
-
return validateAnimationJson;
|
|
490
|
-
};
|
|
491
|
-
const buildFolders = async (options)=>{
|
|
492
|
-
if (options.outDir !== undefined && options.clean) {
|
|
493
|
-
fs.rmSync(options.outDir, {
|
|
494
|
-
recursive: true
|
|
495
|
-
});
|
|
496
|
-
}
|
|
497
|
-
const workspace = options.workspace;
|
|
498
|
-
const folders = options.packages;
|
|
499
|
-
let sortedPackages = sortPackagesByBuildOrder(folders);
|
|
500
|
-
let index = 1;
|
|
501
|
-
for (const location of sortedPackages){
|
|
502
|
-
const hasTypescript = getPackageTypescriptFiles(location).length > 0;
|
|
503
|
-
ensureTsConfig(location);
|
|
504
|
-
const data = readPackageCreatorManifest(location);
|
|
505
|
-
const logStep = (step)=>logPackageMessage(data.Package, step, index, folders.length);
|
|
506
|
-
const outputDirectory = options.outDir || location.scriptsDir;
|
|
507
|
-
fs.mkdirSync(outputDirectory, {
|
|
508
|
-
recursive: true
|
|
509
|
-
});
|
|
510
|
-
let buildResult;
|
|
511
|
-
if (hasTypescript) {
|
|
512
|
-
logStep("Compiling typescript to javascript");
|
|
513
|
-
buildResult = await build(location, outputDirectory);
|
|
514
|
-
} else {
|
|
515
|
-
buildResult = {
|
|
516
|
-
js: ""
|
|
517
|
-
};
|
|
518
|
-
}
|
|
519
|
-
const banner = options.banner ? createBannerComment(options.banner) : undefined;
|
|
520
|
-
if (banner) {
|
|
521
|
-
buildResult.js = banner + "\n" + buildResult.js;
|
|
522
|
-
if (buildResult.definitions !== undefined) {
|
|
523
|
-
buildResult.definitions = banner + "\n" + buildResult.definitions;
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
const animations = new Map();
|
|
527
|
-
for (const scriptFilePath of readPackageAnimationList(location)){
|
|
528
|
-
const content = fs.readFileSync(scriptFilePath, {
|
|
529
|
-
encoding: "utf8"
|
|
530
|
-
});
|
|
531
|
-
let data;
|
|
532
|
-
try {
|
|
533
|
-
data = JSON.parse(content);
|
|
534
|
-
} catch (err) {
|
|
535
|
-
const relativePath = path.relative(options.workspace.path, scriptFilePath);
|
|
536
|
-
if (err instanceof SyntaxError) {
|
|
537
|
-
throw new Error(`Encountered invalid syntax in file "${relativePath}": ${String(err)}`);
|
|
538
|
-
}
|
|
539
|
-
throw new Error(`Encountered an unexpected error while parsing animation json file at path "${relativePath}"`, {
|
|
540
|
-
cause: err
|
|
541
|
-
});
|
|
542
|
-
}
|
|
543
|
-
if (!data.Id) {
|
|
544
|
-
const fileName = path.basename(scriptFilePath, ".animation.json");
|
|
545
|
-
data.Id = fileName;
|
|
546
|
-
}
|
|
547
|
-
(await getAnimationJsonValidation())(data);
|
|
548
|
-
delete data.$schema;
|
|
549
|
-
animations.set(data.Id, JSON.stringify(data));
|
|
550
|
-
}
|
|
551
|
-
if (animations.size > 0) {
|
|
552
|
-
const scope = data.Scope ?? data.Package;
|
|
553
|
-
const scopeParts = scope.split(".");
|
|
554
|
-
buildResult.js += createNamespace(scopeParts);
|
|
555
|
-
for (const [name, content] of animations){
|
|
556
|
-
buildResult.js += `${scope}["${name}"] = ` + content + ";";
|
|
557
|
-
logPackageMessage(data.Package, `Adding animation ${scope}.${name}`);
|
|
558
|
-
}
|
|
559
|
-
} else if (!hasTypescript) {
|
|
560
|
-
throw new Error(`Expected package to have a least one ts file or one animation.json file`);
|
|
561
|
-
}
|
|
562
|
-
fs.writeFileSync(path.join(outputDirectory, `${data.Package}.js`), buildResult.js, {
|
|
563
|
-
encoding: "utf8"
|
|
564
|
-
});
|
|
565
|
-
if (buildResult.definitions !== undefined) {
|
|
566
|
-
fs.writeFileSync(path.join(outputDirectory, `${data.Package}.d.ts`), buildResult.definitions, {
|
|
567
|
-
encoding: "utf8"
|
|
568
|
-
});
|
|
569
|
-
}
|
|
570
|
-
if (options.minimize) {
|
|
571
|
-
const minifyResult = await terser.minify(buildResult.js, {
|
|
572
|
-
ecma: 5
|
|
573
|
-
});
|
|
574
|
-
const minifiedPath = path.join(outputDirectory, `${data.Package}.min.js`);
|
|
575
|
-
fs.writeFileSync(minifiedPath, minifyResult.code, {
|
|
576
|
-
encoding: "utf8"
|
|
577
|
-
});
|
|
578
|
-
}
|
|
579
|
-
if (location.path.includes("Basics") && buildResult.definitions !== undefined) {
|
|
580
|
-
fs.mkdirSync(path.join(workspace.path, "lib"), {
|
|
581
|
-
recursive: true
|
|
582
|
-
});
|
|
583
|
-
logStep("Copying basics definition file to the lib folder");
|
|
584
|
-
fs.writeFileSync(path.join(workspace.path, "lib", `${data.Package}.d.ts`), buildResult.definitions, {
|
|
585
|
-
encoding: "utf8"
|
|
586
|
-
});
|
|
587
|
-
}
|
|
588
|
-
if (options.docs) {
|
|
589
|
-
logStep("Generating typedoc documentation");
|
|
590
|
-
await generateDocs(location, path.join(outputDirectory, `${data.Package}.d.ts`), path.join(workspace.path, "docs", data.Package), data.Package);
|
|
591
|
-
}
|
|
592
|
-
index++;
|
|
593
|
-
}
|
|
594
|
-
};
|
|
595
|
-
const createNamespace = (parts)=>{
|
|
596
|
-
let code = `var ${parts[0]};`;
|
|
597
|
-
for(let index = 0; index < parts.length; index++){
|
|
598
|
-
const path = parts.slice(0, index + 1).join(".");
|
|
599
|
-
code += `\n(${path} = ${path} || {});`;
|
|
600
|
-
}
|
|
601
|
-
return code;
|
|
602
|
-
};
|
|
603
|
-
const ensureTsConfig = (location)=>{
|
|
604
|
-
const tsconfigPath = path.join(location.scriptsDir, "tsconfig.json");
|
|
605
|
-
if (!fs.existsSync(tsconfigPath)) {
|
|
606
|
-
const content = {};
|
|
607
|
-
applyTsConfigOption(content);
|
|
608
|
-
fs.writeFileSync(tsconfigPath, JSON.stringify(content, undefined, "\t"), "utf8");
|
|
609
|
-
} else {
|
|
610
|
-
const content = JSON.parse(fs.readFileSync(tsconfigPath, "utf8"));
|
|
611
|
-
applyTsConfigOption(content);
|
|
612
|
-
fs.writeFileSync(tsconfigPath, JSON.stringify(content, undefined, "\t"), "utf8");
|
|
613
|
-
}
|
|
614
|
-
};
|
|
615
|
-
const applyTsConfigOption = (data)=>{
|
|
616
|
-
data.compilerOptions = data.compilerOptions ?? {};
|
|
617
|
-
data.compilerOptions.target = "es5";
|
|
618
|
-
data.compilerOptions.lib = [
|
|
619
|
-
"es5",
|
|
620
|
-
"dom"
|
|
621
|
-
];
|
|
622
|
-
};
|
|
623
|
-
const sortPackagesByBuildOrder = (folders)=>{
|
|
624
|
-
const packages = Array.from(folders).reduce((acc, location)=>{
|
|
625
|
-
const data = readPackageNpmManifest(location);
|
|
626
|
-
if (data !== undefined) {
|
|
627
|
-
acc[data.name] = {
|
|
628
|
-
data,
|
|
629
|
-
location
|
|
630
|
-
};
|
|
631
|
-
} else {
|
|
632
|
-
acc[location.path] = {
|
|
633
|
-
data: undefined,
|
|
634
|
-
location
|
|
635
|
-
};
|
|
636
|
-
}
|
|
637
|
-
return acc;
|
|
638
|
-
}, {});
|
|
639
|
-
const packageDependencies = Object.getOwnPropertyNames(packages).reduce((acc, packageName)=>{
|
|
640
|
-
const packageData = packages[packageName];
|
|
641
|
-
if (packageData.data === undefined) {
|
|
642
|
-
acc[packageName] = [];
|
|
643
|
-
} else {
|
|
644
|
-
acc[packageName] = Object.getOwnPropertyNames({
|
|
645
|
-
...packageData.data.devDependencies,
|
|
646
|
-
...packageData.data.dependencies,
|
|
647
|
-
...packageData.data.peerDependencies
|
|
648
|
-
}).filter((packageName)=>packages[packageName] !== undefined);
|
|
649
|
-
}
|
|
650
|
-
return acc;
|
|
651
|
-
}, {});
|
|
652
|
-
const sortedPackages = toposort(packageDependencies);
|
|
653
|
-
const result = [];
|
|
654
|
-
for (const packageName of sortedPackages){
|
|
655
|
-
const location = packages[packageName].location;
|
|
656
|
-
if (readPackageCreatorManifest(location).Package.endsWith(".Basics")) {
|
|
657
|
-
result.unshift(location);
|
|
658
|
-
} else {
|
|
659
|
-
result.push(location);
|
|
660
|
-
}
|
|
661
|
-
}
|
|
662
|
-
return result;
|
|
663
|
-
};
|
|
664
|
-
const createBannerComment = (banner)=>{
|
|
665
|
-
const bannerParts = [];
|
|
666
|
-
if (banner.text) {
|
|
667
|
-
bannerParts.push(" * " + banner.text);
|
|
668
|
-
}
|
|
669
|
-
{
|
|
670
|
-
const details = [];
|
|
671
|
-
if (banner.version) {
|
|
672
|
-
details.push(`Version: ${banner.version}`);
|
|
673
|
-
}
|
|
674
|
-
if (banner.commit) {
|
|
675
|
-
if (banner.commitDirty) {
|
|
676
|
-
details.push(`Commit: ${banner.commit} (dirty)`);
|
|
677
|
-
} else {
|
|
678
|
-
details.push(`Commit: ${banner.commit}`);
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
if (banner.date) {
|
|
682
|
-
details.push(`Date: ${banner.date.toISOString()}`);
|
|
683
|
-
}
|
|
684
|
-
const detailsText = details.map((line)=>` * ${line}`).join("\n");
|
|
685
|
-
if (detailsText) {
|
|
686
|
-
bannerParts.push(detailsText);
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
const bannerText = bannerParts.join("\n\n");
|
|
690
|
-
if (bannerText) {
|
|
691
|
-
return `/*
|
|
692
|
-
${bannerText}
|
|
693
|
-
*
|
|
694
|
-
* @preserve
|
|
695
|
-
*/`;
|
|
696
|
-
}
|
|
697
|
-
return undefined;
|
|
698
|
-
};
|
|
699
|
-
|
|
700
|
-
var index = /*#__PURE__*/Object.freeze({
|
|
701
|
-
__proto__: null,
|
|
702
|
-
buildFolders: buildFolders
|
|
703
|
-
});
|
|
704
|
-
|
|
705
|
-
export { buildFolders as b, index as i, logPackageMessage as l };
|
|
706
|
-
//# sourceMappingURL=index-7d81fa31.mjs.map
|