@player-tools/cli 0.4.2-next.1 → 0.5.0-next.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/dist/commands/dependency-versions/check.d.ts +18 -0
- package/dist/commands/dependency-versions/check.js +271 -0
- package/dist/commands/dsl/compile.d.ts +2 -2
- package/dist/commands/dsl/compile.js +136 -141
- package/dist/commands/dsl/validate.d.ts +12 -0
- package/dist/commands/dsl/validate.js +76 -0
- package/dist/commands/json/validate.d.ts +1 -1
- package/dist/commands/json/validate.js +62 -73
- package/dist/commands/xlr/compile.d.ts +1 -1
- package/dist/commands/xlr/compile.js +73 -79
- package/dist/commands/xlr/convert.d.ts +1 -1
- package/dist/commands/xlr/convert.js +59 -68
- package/dist/config.d.ts +2 -2
- package/dist/config.js +1 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +6 -18
- package/dist/plugins/LSPAssetsPlugin.d.ts +2 -2
- package/dist/plugins/LSPAssetsPlugin.js +3 -13
- package/dist/plugins/LSPPluginPlugin.d.ts +2 -2
- package/dist/plugins/LSPPluginPlugin.js +3 -13
- package/dist/plugins/LSPTransformsPlugin.d.ts +3 -3
- package/dist/plugins/LSPTransformsPlugin.js +3 -13
- package/dist/plugins/index.d.ts +9 -9
- package/dist/plugins/index.js +5 -17
- package/dist/utils/babel-register.js +8 -9
- package/dist/utils/base-command.d.ts +7 -7
- package/dist/utils/base-command.js +107 -136
- package/dist/utils/compilation-context.d.ts +2 -2
- package/dist/utils/compilation-context.js +3 -11
- package/dist/utils/compile-renderer.d.ts +2 -2
- package/dist/utils/compile-renderer.js +14 -16
- package/dist/utils/compiler-options.d.ts +3 -0
- package/dist/utils/compiler-options.js +16 -0
- package/dist/utils/diag-renderer.d.ts +2 -2
- package/dist/utils/diag-renderer.js +35 -36
- package/dist/utils/fs.js +4 -5
- package/dist/utils/task-runner.d.ts +4 -4
- package/dist/utils/task-runner.js +15 -22
- package/dist/utils/xlr/consts.js +9 -8
- package/dist/utils/xlr/visitors/file.d.ts +2 -2
- package/dist/utils/xlr/visitors/file.js +6 -7
- package/dist/utils/xlr/visitors/index.d.ts +3 -3
- package/dist/utils/xlr/visitors/index.js +5 -17
- package/dist/utils/xlr/visitors/plugin.d.ts +2 -2
- package/dist/utils/xlr/visitors/plugin.js +29 -37
- package/dist/utils/xlr/visitors/types.d.ts +2 -2
- package/dist/utils/xlr/visitors/types.js +1 -0
- package/package.json +46 -36
- package/oclif.manifest.json +0 -1
|
@@ -1,44 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.compileRenderer = void 0;
|
|
7
|
-
const
|
|
8
|
-
const
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
6
|
+
const figures_1 = tslib_1.__importDefault(require("figures"));
|
|
9
7
|
const diag_renderer_1 = require("./diag-renderer");
|
|
10
8
|
exports.compileRenderer = {
|
|
11
9
|
onUpdate: (ctx) => {
|
|
12
|
-
const output = [
|
|
10
|
+
const output = [""];
|
|
13
11
|
ctx.tasks.forEach((task) => {
|
|
14
|
-
|
|
15
|
-
const outputType = task.state === 'completed' && ((_a = task.output) === null || _a === void 0 ? void 0 : _a.contentType)
|
|
12
|
+
const outputType = task.state === "completed" && task.output?.contentType
|
|
16
13
|
? task.output.contentType
|
|
17
14
|
: undefined;
|
|
18
15
|
let titleLine = [
|
|
19
16
|
(0, diag_renderer_1.getTaskSymbol)(task),
|
|
20
17
|
outputType && `(${outputType})`,
|
|
21
|
-
|
|
18
|
+
task.data?.file,
|
|
22
19
|
]
|
|
23
20
|
.filter(Boolean)
|
|
24
|
-
.join(
|
|
25
|
-
if (
|
|
21
|
+
.join(" ");
|
|
22
|
+
if (task.data?.outputFile) {
|
|
26
23
|
titleLine = [
|
|
27
24
|
titleLine,
|
|
28
25
|
figures_1.default.arrowRight,
|
|
29
26
|
task.data.outputFile,
|
|
30
|
-
].join(
|
|
27
|
+
].join(" ");
|
|
31
28
|
}
|
|
32
29
|
output.push(titleLine);
|
|
33
|
-
if (task.state ===
|
|
30
|
+
if (task.state === "completed") {
|
|
34
31
|
if (task.error) {
|
|
35
|
-
output.push(` ${figures_1.default.arrowRight} ${chalk_1.default.red(
|
|
32
|
+
output.push(` ${figures_1.default.arrowRight} ${chalk_1.default.red("bad")}`);
|
|
36
33
|
}
|
|
37
34
|
}
|
|
38
35
|
});
|
|
39
|
-
return output.join(
|
|
36
|
+
return output.join("\n");
|
|
40
37
|
},
|
|
41
38
|
onEnd: (ctx) => {
|
|
42
|
-
return [exports.compileRenderer.onUpdate(ctx)].join(
|
|
39
|
+
return [exports.compileRenderer.onUpdate(ctx)].join("\n");
|
|
43
40
|
},
|
|
44
41
|
};
|
|
42
|
+
//# sourceMappingURL=compile-renderer.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_COMPILER_OPTIONS = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const typescript_1 = tslib_1.__importDefault(require("typescript"));
|
|
6
|
+
exports.DEFAULT_COMPILER_OPTIONS = {
|
|
7
|
+
strict: true,
|
|
8
|
+
target: typescript_1.default.ScriptTarget.ES2016,
|
|
9
|
+
allowJs: false,
|
|
10
|
+
jsx: typescript_1.default.JsxEmit.ReactJSX,
|
|
11
|
+
moduleResolution: typescript_1.default.ModuleResolutionKind.NodeJs,
|
|
12
|
+
allowSyntheticDefaultImports: true,
|
|
13
|
+
module: typescript_1.default.ModuleKind.ES2015,
|
|
14
|
+
skipLibCheck: true,
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=compiler-options.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Diagnostic } from
|
|
2
|
-
import type { Task, TaskProgressRenderer } from
|
|
1
|
+
import type { Diagnostic } from "vscode-languageserver-types";
|
|
2
|
+
import type { Task, TaskProgressRenderer } from "./task-runner";
|
|
3
3
|
/** Get the lines representing the summary of the results */
|
|
4
4
|
export declare function getSummary({ errors, warnings, skipped, fileCount, duration, }: {
|
|
5
5
|
/** Error count */
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.validationRenderer = exports.getTaskSymbol = exports.formatDiagnosticResults = exports.getSummary = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
7
5
|
const vscode_languageserver_types_1 = require("vscode-languageserver-types");
|
|
8
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
-
const log_symbols_1 = __importDefault(require("log-symbols"));
|
|
10
|
-
const elegant_spinner_1 = __importDefault(require("elegant-spinner"));
|
|
6
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
7
|
+
const log_symbols_1 = tslib_1.__importDefault(require("log-symbols"));
|
|
8
|
+
const elegant_spinner_1 = tslib_1.__importDefault(require("elegant-spinner"));
|
|
11
9
|
const fs_1 = require("./fs");
|
|
12
10
|
/** Compare the ranges and return the one that starts of finishes first */
|
|
13
11
|
function rangeComparator(first, second) {
|
|
@@ -43,19 +41,19 @@ function maybePlural(word, count) {
|
|
|
43
41
|
/** Get the lines representing the summary of the results */
|
|
44
42
|
function getSummary({ errors, warnings, skipped, fileCount, duration, }) {
|
|
45
43
|
return [
|
|
46
|
-
|
|
44
|
+
"\n",
|
|
47
45
|
(errors > 0 || warnings === 0) &&
|
|
48
|
-
chalk_1.default.red(`${errors} ${maybePlural(
|
|
46
|
+
chalk_1.default.red(`${errors} ${maybePlural("error", errors)}`),
|
|
49
47
|
warnings > 0 &&
|
|
50
|
-
chalk_1.default.yellow(`${warnings} ${maybePlural(
|
|
48
|
+
chalk_1.default.yellow(`${warnings} ${maybePlural("warning", warnings)}`),
|
|
51
49
|
skipped !== undefined &&
|
|
52
50
|
skipped > 0 &&
|
|
53
|
-
chalk_1.default.gray(`${skipped} ${maybePlural(
|
|
54
|
-
chalk_1.default.gray(`in ${fileCount} ${maybePlural(
|
|
51
|
+
chalk_1.default.gray(`${skipped} ${maybePlural("skipped", skipped)}`),
|
|
52
|
+
chalk_1.default.gray(`in ${fileCount} ${maybePlural("file", fileCount)}`),
|
|
55
53
|
chalk_1.default.gray(`took ${duration}ms`),
|
|
56
54
|
]
|
|
57
55
|
.filter(Boolean)
|
|
58
|
-
.join(
|
|
56
|
+
.join(" ");
|
|
59
57
|
}
|
|
60
58
|
exports.getSummary = getSummary;
|
|
61
59
|
/** Format a diag for printing on the console */
|
|
@@ -70,7 +68,7 @@ function formatDiagnostic(diag, longestLine, fName) {
|
|
|
70
68
|
range.padEnd(longestLine),
|
|
71
69
|
msg,
|
|
72
70
|
`${fName}:${range.padEnd(longestLine)}`,
|
|
73
|
-
].join(
|
|
71
|
+
].join(" ");
|
|
74
72
|
}
|
|
75
73
|
/** Format the results for printing on the console */
|
|
76
74
|
function formatDiagnosticResults(filePath, results, verbose = false) {
|
|
@@ -78,7 +76,7 @@ function formatDiagnosticResults(filePath, results, verbose = false) {
|
|
|
78
76
|
errors: 0,
|
|
79
77
|
warnings: 0,
|
|
80
78
|
};
|
|
81
|
-
const linePrefix =
|
|
79
|
+
const linePrefix = " ";
|
|
82
80
|
const longestLine = Math.max(...results.map((r) => getLineRange(r.range).length));
|
|
83
81
|
let lines = results
|
|
84
82
|
.map((diag) => {
|
|
@@ -91,61 +89,62 @@ function formatDiagnosticResults(filePath, results, verbose = false) {
|
|
|
91
89
|
if (diag.severity === vscode_languageserver_types_1.DiagnosticSeverity.Error || verbose) {
|
|
92
90
|
return linePrefix + formatDiagnostic(diag, longestLine + 1, filePath);
|
|
93
91
|
}
|
|
94
|
-
return
|
|
92
|
+
return "";
|
|
95
93
|
})
|
|
96
|
-
.filter((line) => line !==
|
|
94
|
+
.filter((line) => line !== "");
|
|
97
95
|
if (count.errors > 0) {
|
|
98
|
-
lines = [
|
|
96
|
+
lines = ["", `${chalk_1.default.red(log_symbols_1.default.error)} ${filePath}`, ...lines, ""];
|
|
99
97
|
}
|
|
100
98
|
else if (verbose) {
|
|
101
99
|
if (count.warnings > 0) {
|
|
102
100
|
lines = [
|
|
103
|
-
|
|
101
|
+
"",
|
|
104
102
|
`${chalk_1.default.yellow(log_symbols_1.default.warning)} ${filePath}`,
|
|
105
103
|
...lines,
|
|
106
|
-
|
|
104
|
+
"",
|
|
107
105
|
];
|
|
108
106
|
}
|
|
109
107
|
else {
|
|
110
108
|
lines = [`${chalk_1.default.green(log_symbols_1.default.success)} ${filePath}`, ...lines];
|
|
111
109
|
}
|
|
112
110
|
}
|
|
113
|
-
return
|
|
111
|
+
return {
|
|
112
|
+
...count,
|
|
113
|
+
lines,
|
|
114
|
+
};
|
|
114
115
|
}
|
|
115
116
|
exports.formatDiagnosticResults = formatDiagnosticResults;
|
|
116
117
|
const spinnerState = new WeakMap();
|
|
117
118
|
/** Get the symbol for a given task */
|
|
118
119
|
const getTaskSymbol = (task) => {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const spinner = (_a = spinnerState.get(task)) !== null && _a !== void 0 ? _a : (0, elegant_spinner_1.default)();
|
|
120
|
+
if (task.state === "pending" || task.state === "idle") {
|
|
121
|
+
const spinner = spinnerState.get(task) ?? (0, elegant_spinner_1.default)();
|
|
122
122
|
spinnerState.set(task, spinner);
|
|
123
123
|
return chalk_1.default.yellow(spinner());
|
|
124
124
|
}
|
|
125
|
-
if (task.state ===
|
|
125
|
+
if (task.state === "completed" && task.error) {
|
|
126
126
|
return log_symbols_1.default.error;
|
|
127
127
|
}
|
|
128
|
-
if (task.state ===
|
|
128
|
+
if (task.state === "completed") {
|
|
129
129
|
return chalk_1.default.yellow(log_symbols_1.default.success);
|
|
130
130
|
}
|
|
131
|
-
return
|
|
131
|
+
return " ";
|
|
132
132
|
};
|
|
133
133
|
exports.getTaskSymbol = getTaskSymbol;
|
|
134
134
|
exports.validationRenderer = {
|
|
135
135
|
onUpdate(ctx) {
|
|
136
136
|
const { tasks } = ctx;
|
|
137
|
-
const output = [
|
|
137
|
+
const output = ["Validating content"];
|
|
138
138
|
tasks.forEach((task) => {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
const formattedDiags = formatDiagnosticResults(((_a = task.data) === null || _a === void 0 ? void 0 : _a.file) ? (0, fs_1.normalizePath)(task.data.file) : '', sortDiagnostics(task.output), true);
|
|
139
|
+
if (task.state === "completed" && task.output) {
|
|
140
|
+
const formattedDiags = formatDiagnosticResults(task.data?.file ? (0, fs_1.normalizePath)(task.data.file) : "", sortDiagnostics(task.output), true);
|
|
142
141
|
output.push(...formattedDiags.lines);
|
|
143
142
|
}
|
|
144
143
|
else {
|
|
145
|
-
output.push(`${(0, exports.getTaskSymbol)(task)} ${
|
|
144
|
+
output.push(`${(0, exports.getTaskSymbol)(task)} ${task.data?.file ? (0, fs_1.normalizePath)(task.data.file) : ""}`);
|
|
146
145
|
}
|
|
147
146
|
});
|
|
148
|
-
return output.join(
|
|
147
|
+
return output.join("\n");
|
|
149
148
|
},
|
|
150
149
|
onEnd(ctx) {
|
|
151
150
|
const count = {
|
|
@@ -156,13 +155,13 @@ exports.validationRenderer = {
|
|
|
156
155
|
duration: ctx.duration,
|
|
157
156
|
};
|
|
158
157
|
ctx.tasks.forEach((t) => {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
const formattedDiags = formatDiagnosticResults((_b = (_a = t.data) === null || _a === void 0 ? void 0 : _a.file) !== null && _b !== void 0 ? _b : '', t.output, true);
|
|
158
|
+
if (t.state === "completed" && t.output) {
|
|
159
|
+
const formattedDiags = formatDiagnosticResults(t.data?.file ?? "", t.output, true);
|
|
162
160
|
count.errors += formattedDiags.errors;
|
|
163
161
|
count.warnings += formattedDiags.warnings;
|
|
164
162
|
}
|
|
165
163
|
});
|
|
166
|
-
return [exports.validationRenderer.onUpdate(ctx), getSummary(count)].join(
|
|
164
|
+
return [exports.validationRenderer.onUpdate(ctx), getSummary(count)].join("\n");
|
|
167
165
|
},
|
|
168
166
|
};
|
|
167
|
+
//# sourceMappingURL=diag-renderer.js.map
|
package/dist/utils/fs.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.normalizePath = exports.convertToFileGlob = void 0;
|
|
7
|
-
const
|
|
8
|
-
const
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
6
|
+
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
9
7
|
/** To handle globby issue on windows https://github.com/sindresorhus/globby/issues/152 */
|
|
10
8
|
function forcePathSeparatorToPosix(input) {
|
|
11
9
|
return path_1.default.sep === path_1.default.win32.sep
|
|
@@ -30,3 +28,4 @@ const normalizePath = (p) => {
|
|
|
30
28
|
return path_1.default.relative(process.cwd(), p);
|
|
31
29
|
};
|
|
32
30
|
exports.normalizePath = normalizePath;
|
|
31
|
+
//# sourceMappingURL=fs.js.map
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
interface BaseTask<Results, Data> {
|
|
2
2
|
/** The state of the task */
|
|
3
|
-
state:
|
|
3
|
+
state: "idle" | "pending";
|
|
4
4
|
/** A function to run */
|
|
5
5
|
run: () => Promise<Results>;
|
|
6
6
|
/** other metadata about the task */
|
|
7
7
|
data?: Data;
|
|
8
8
|
}
|
|
9
|
-
export
|
|
9
|
+
export type CompletedTask<Results, Data> = Omit<BaseTask<Results, Data>, "state"> & {
|
|
10
10
|
/** The state of the task */
|
|
11
|
-
state:
|
|
11
|
+
state: "completed";
|
|
12
12
|
} & ({
|
|
13
13
|
/** The results */
|
|
14
14
|
output: Results;
|
|
@@ -20,7 +20,7 @@ export declare type CompletedTask<Results, Data> = Omit<BaseTask<Results, Data>,
|
|
|
20
20
|
/** No output on error */
|
|
21
21
|
output?: never;
|
|
22
22
|
});
|
|
23
|
-
export
|
|
23
|
+
export type Task<ResultsType, Data> = BaseTask<ResultsType, Data> | CompletedTask<ResultsType, Data>;
|
|
24
24
|
export interface TaskProgressRenderer<ResultType, Data = unknown> {
|
|
25
25
|
/** Call back to paint update on the page */
|
|
26
26
|
onUpdate: (ctx: {
|
|
@@ -1,26 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
3
|
exports.createTaskRunner = void 0;
|
|
16
|
-
const
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const log_update_1 = tslib_1.__importDefault(require("log-update"));
|
|
17
6
|
/** Create a runner to kick off tasks in parallel */
|
|
18
7
|
const createTaskRunner = ({ tasks, renderer, }) => {
|
|
19
8
|
const statefulTasks = tasks.map((t) => {
|
|
20
|
-
return
|
|
9
|
+
return {
|
|
10
|
+
...t,
|
|
11
|
+
state: "idle",
|
|
12
|
+
};
|
|
21
13
|
});
|
|
22
14
|
/** Kick off the task list */
|
|
23
|
-
const run = () =>
|
|
15
|
+
const run = async () => {
|
|
24
16
|
const startTime = Date.now();
|
|
25
17
|
let ended = false;
|
|
26
18
|
const paintInterval = setInterval(() => {
|
|
@@ -32,20 +24,20 @@ const createTaskRunner = ({ tasks, renderer, }) => {
|
|
|
32
24
|
(0, log_update_1.default)(output);
|
|
33
25
|
}
|
|
34
26
|
}, 10);
|
|
35
|
-
|
|
36
|
-
t.state =
|
|
27
|
+
await Promise.all(statefulTasks.map(async (t) => {
|
|
28
|
+
t.state = "pending";
|
|
37
29
|
try {
|
|
38
|
-
const r =
|
|
39
|
-
t.state =
|
|
30
|
+
const r = await t.run();
|
|
31
|
+
t.state = "completed";
|
|
40
32
|
t.output = r;
|
|
41
33
|
}
|
|
42
34
|
catch (e) {
|
|
43
35
|
if (e instanceof Error) {
|
|
44
|
-
t.state =
|
|
36
|
+
t.state = "completed";
|
|
45
37
|
t.error = e;
|
|
46
38
|
}
|
|
47
39
|
}
|
|
48
|
-
}))
|
|
40
|
+
}));
|
|
49
41
|
ended = true;
|
|
50
42
|
clearInterval(paintInterval);
|
|
51
43
|
const duration = Date.now() - startTime;
|
|
@@ -56,10 +48,11 @@ const createTaskRunner = ({ tasks, renderer, }) => {
|
|
|
56
48
|
console.log(output);
|
|
57
49
|
log_update_1.default.done();
|
|
58
50
|
return statefulTasks;
|
|
59
|
-
}
|
|
51
|
+
};
|
|
60
52
|
return {
|
|
61
53
|
tasks: statefulTasks,
|
|
62
54
|
run,
|
|
63
55
|
};
|
|
64
56
|
};
|
|
65
57
|
exports.createTaskRunner = createTaskRunner;
|
|
58
|
+
//# sourceMappingURL=task-runner.js.map
|
package/dist/utils/xlr/consts.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Mode = exports.customPrimitives = exports.PLAYER_PLUGIN_INTERFACE_NAME = void 0;
|
|
4
|
-
exports.PLAYER_PLUGIN_INTERFACE_NAME =
|
|
4
|
+
exports.PLAYER_PLUGIN_INTERFACE_NAME = "ExtendedPlayerPlugin";
|
|
5
5
|
exports.customPrimitives = [
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
"Expression",
|
|
7
|
+
"Asset",
|
|
8
|
+
"Binding",
|
|
9
|
+
"AssetWrapper",
|
|
10
|
+
"Schema.DataType",
|
|
11
|
+
"ExpressionHandler",
|
|
12
12
|
];
|
|
13
13
|
var Mode;
|
|
14
14
|
(function (Mode) {
|
|
15
15
|
Mode["PLUGIN"] = "plugin";
|
|
16
16
|
Mode["TYPES"] = "types";
|
|
17
|
-
})(Mode
|
|
17
|
+
})(Mode || (exports.Mode = Mode = {}));
|
|
18
|
+
//# sourceMappingURL=consts.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Manifest } from
|
|
2
|
-
import type { VisitorProps } from
|
|
1
|
+
import type { Manifest } from "@player-tools/xlr";
|
|
2
|
+
import type { VisitorProps } from "./types";
|
|
3
3
|
/** export all exported types in the file */
|
|
4
4
|
export declare function fileVisitor(args: VisitorProps): Manifest | undefined;
|
|
5
5
|
//# sourceMappingURL=file.d.ts.map
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.fileVisitor = void 0;
|
|
7
|
-
const
|
|
8
|
-
const
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
6
|
+
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
9
7
|
/** export all exported types in the file */
|
|
10
8
|
function fileVisitor(args) {
|
|
11
9
|
const { sourceFile, converter, outputDirectory } = args;
|
|
@@ -14,14 +12,15 @@ function fileVisitor(args) {
|
|
|
14
12
|
return undefined;
|
|
15
13
|
}
|
|
16
14
|
const capabilities = {
|
|
17
|
-
pluginName:
|
|
15
|
+
pluginName: "Types",
|
|
18
16
|
};
|
|
19
17
|
convertedTypes.data.types.forEach((type) => {
|
|
20
18
|
fs_1.default.writeFileSync(path_1.default.join(outputDirectory, `${type.name}.json`), JSON.stringify(type, undefined, 4));
|
|
21
19
|
});
|
|
22
20
|
capabilities.capabilities = new Map([
|
|
23
|
-
[
|
|
21
|
+
["Types", convertedTypes.convertedTypes],
|
|
24
22
|
]);
|
|
25
23
|
return capabilities;
|
|
26
24
|
}
|
|
27
25
|
exports.fileVisitor = fileVisitor;
|
|
26
|
+
//# sourceMappingURL=file.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
1
|
+
export * from "./file";
|
|
2
|
+
export * from "./plugin";
|
|
3
|
+
export * from "./types";
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,19 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
18
|
-
__exportStar(require("./
|
|
19
|
-
__exportStar(require("./
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./file"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./plugin"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./types"), exports);
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Manifest } from
|
|
2
|
-
import type { VisitorProps } from
|
|
1
|
+
import type { Manifest } from "@player-tools/xlr";
|
|
2
|
+
import type { VisitorProps } from "./types";
|
|
3
3
|
/** visit nodes finding exported classes */
|
|
4
4
|
export declare function pluginVisitor(args: VisitorProps): Manifest | undefined;
|
|
5
5
|
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.pluginVisitor = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
7
5
|
const xlr_utils_1 = require("@player-tools/xlr-utils");
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const typescript_1 = __importDefault(require("typescript"));
|
|
10
|
-
const fs_1 = __importDefault(require("fs"));
|
|
6
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
|
+
const typescript_1 = tslib_1.__importDefault(require("typescript"));
|
|
8
|
+
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
11
9
|
const consts_1 = require("../consts");
|
|
12
10
|
/**
|
|
13
11
|
* Follows references to get the actual underlying declaration
|
|
14
12
|
*/
|
|
15
13
|
function getUnderlyingNode(element, checker) {
|
|
16
|
-
var _a, _b;
|
|
17
14
|
let referencedSymbol;
|
|
18
15
|
if (typescript_1.default.isTypeReferenceNode(element)) {
|
|
19
16
|
referencedSymbol = checker.getSymbolAtLocation(element.typeName);
|
|
@@ -30,10 +27,10 @@ function getUnderlyingNode(element, checker) {
|
|
|
30
27
|
* so if we are getting a variable, we need to grab the variable declaration
|
|
31
28
|
*/
|
|
32
29
|
if (typescript_1.default.isTypeReferenceNode(element)) {
|
|
33
|
-
varDecl =
|
|
30
|
+
varDecl = alias?.declarations?.[0];
|
|
34
31
|
}
|
|
35
32
|
else {
|
|
36
|
-
varDecl =
|
|
33
|
+
varDecl = alias?.declarations?.[0].parent.parent;
|
|
37
34
|
}
|
|
38
35
|
if (varDecl && (0, xlr_utils_1.isTopLevelNode)(varDecl)) {
|
|
39
36
|
return varDecl;
|
|
@@ -43,8 +40,7 @@ function getUnderlyingNode(element, checker) {
|
|
|
43
40
|
* Fixes ExpressionHandler ref nodes that don't have argument names because some way of writing ExpressionHandler prevent the ts compiler from inferring them
|
|
44
41
|
*/
|
|
45
42
|
function fixExpressionArgNames(sourceNode, generatedTypeRef, checker) {
|
|
46
|
-
|
|
47
|
-
const typeRefCopy = Object.assign({}, generatedTypeRef);
|
|
43
|
+
const typeRefCopy = { ...generatedTypeRef };
|
|
48
44
|
const { initializer } = sourceNode.declarationList.declarations[0];
|
|
49
45
|
let offset;
|
|
50
46
|
let arrowFunction;
|
|
@@ -60,17 +56,16 @@ function fixExpressionArgNames(sourceNode, generatedTypeRef, checker) {
|
|
|
60
56
|
offset = 1;
|
|
61
57
|
arrowFunction = initializer;
|
|
62
58
|
}
|
|
63
|
-
const paramsNode =
|
|
64
|
-
if (paramsNode && paramsNode.type ===
|
|
65
|
-
const functionArg =
|
|
59
|
+
const paramsNode = typeRefCopy.genericArguments?.[0];
|
|
60
|
+
if (paramsNode && paramsNode.type === "array") {
|
|
61
|
+
const functionArg = arrowFunction.parameters?.[offset];
|
|
66
62
|
if (!paramsNode.name && functionArg) {
|
|
67
63
|
paramsNode.name = functionArg.name.getText();
|
|
68
64
|
}
|
|
69
65
|
}
|
|
70
|
-
else if (paramsNode && paramsNode.type ===
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const functionArg = (_a = arrowFunction.parameters) === null || _a === void 0 ? void 0 : _a[index + offset];
|
|
66
|
+
else if (paramsNode && paramsNode.type === "tuple") {
|
|
67
|
+
paramsNode.elementTypes?.forEach((gArg, index) => {
|
|
68
|
+
const functionArg = arrowFunction.parameters?.[index + offset];
|
|
74
69
|
if (!gArg.name && functionArg) {
|
|
75
70
|
// eslint-disable-next-line no-param-reassign
|
|
76
71
|
gArg.name = functionArg.name.getText();
|
|
@@ -84,8 +79,8 @@ function fixExpressionArgNames(sourceNode, generatedTypeRef, checker) {
|
|
|
84
79
|
* Most of this is _definitely not_ best practice.
|
|
85
80
|
*/
|
|
86
81
|
function runPlayerPostProcessing(node, xlr, checker) {
|
|
87
|
-
if (xlr.type ===
|
|
88
|
-
xlr.ref.includes(
|
|
82
|
+
if (xlr.type === "ref" &&
|
|
83
|
+
xlr.ref.includes("ExpressionHandler") &&
|
|
89
84
|
typescript_1.default.isVariableStatement(node)) {
|
|
90
85
|
return fixExpressionArgNames(node, xlr, checker);
|
|
91
86
|
}
|
|
@@ -95,13 +90,12 @@ function runPlayerPostProcessing(node, xlr, checker) {
|
|
|
95
90
|
* Generated the XLR for a Capability, writes it to the specified path, and returns the name
|
|
96
91
|
*/
|
|
97
92
|
function generateXLR(node, checker, converter, outputDirectory) {
|
|
98
|
-
var _a;
|
|
99
93
|
if (typescript_1.default.isTypeReferenceNode(node) || typescript_1.default.isTypeQueryNode(node)) {
|
|
100
94
|
const varDecl = getUnderlyingNode(node, checker);
|
|
101
95
|
if (varDecl) {
|
|
102
96
|
let capabilityDescription = converter.convertTopLevelNode(varDecl);
|
|
103
97
|
capabilityDescription = runPlayerPostProcessing(varDecl, capabilityDescription, checker);
|
|
104
|
-
const capabilityName =
|
|
98
|
+
const capabilityName = capabilityDescription?.name ?? "error";
|
|
105
99
|
fs_1.default.writeFileSync(path_1.default.join(outputDirectory, `${capabilityName}.json`), JSON.stringify(capabilityDescription, undefined, 4));
|
|
106
100
|
return capabilityName;
|
|
107
101
|
}
|
|
@@ -113,7 +107,6 @@ function pluginVisitor(args) {
|
|
|
113
107
|
const { sourceFile, checker, converter, outputDirectory } = args;
|
|
114
108
|
let capabilities;
|
|
115
109
|
typescript_1.default.forEachChild(sourceFile, (node) => {
|
|
116
|
-
var _a;
|
|
117
110
|
// Only consider exported nodes
|
|
118
111
|
if (!(0, xlr_utils_1.isNodeExported)(node)) {
|
|
119
112
|
return;
|
|
@@ -123,34 +116,32 @@ function pluginVisitor(args) {
|
|
|
123
116
|
const symbol = checker.getSymbolAtLocation(node.name);
|
|
124
117
|
if (symbol) {
|
|
125
118
|
// look at what they implement
|
|
126
|
-
|
|
119
|
+
node.heritageClauses?.forEach((heritage) => {
|
|
127
120
|
heritage.types.forEach((hInterface) => {
|
|
128
|
-
var _a, _b, _c, _d;
|
|
129
121
|
// check if heritage is right one
|
|
130
122
|
if (hInterface.expression.getText() !== consts_1.PLAYER_PLUGIN_INTERFACE_NAME) {
|
|
131
123
|
return;
|
|
132
124
|
}
|
|
133
125
|
capabilities = {
|
|
134
|
-
pluginName:
|
|
126
|
+
pluginName: "Unknown Plugin",
|
|
135
127
|
};
|
|
136
128
|
// Get registration name of plugin
|
|
137
|
-
const nameProperty = node.members.find((member) =>
|
|
138
|
-
|
|
139
|
-
return typescript_1.default.isPropertyDeclaration(member) &&
|
|
140
|
-
((_a = member.name) === null || _a === void 0 ? void 0 : _a.getText()) === 'name';
|
|
141
|
-
});
|
|
129
|
+
const nameProperty = node.members.find((member) => typescript_1.default.isPropertyDeclaration(member) &&
|
|
130
|
+
member.name?.getText() === "name");
|
|
142
131
|
if (nameProperty && nameProperty.initializer) {
|
|
143
|
-
capabilities.pluginName =
|
|
132
|
+
capabilities.pluginName = nameProperty.initializer
|
|
133
|
+
?.getText()
|
|
134
|
+
.replace(/[""]+/g, "");
|
|
144
135
|
}
|
|
145
136
|
const provides = new Map();
|
|
146
137
|
const typeArgs = hInterface.typeArguments;
|
|
147
|
-
const pluginDec =
|
|
138
|
+
const pluginDec = checker.getTypeAtLocation(hInterface).symbol
|
|
139
|
+
?.declarations?.[0];
|
|
148
140
|
// process type parameters to figure out what capabilities are provided
|
|
149
|
-
|
|
150
|
-
var _a;
|
|
141
|
+
pluginDec?.typeParameters?.forEach((param, index) => {
|
|
151
142
|
const capabilityType = param.name.getText();
|
|
152
|
-
if (index < (
|
|
153
|
-
const exportedCapabilities = typeArgs
|
|
143
|
+
if (index < (typeArgs?.length ?? 0)) {
|
|
144
|
+
const exportedCapabilities = typeArgs?.[index];
|
|
154
145
|
// if its an array process each type
|
|
155
146
|
if (typescript_1.default.isTupleTypeNode(exportedCapabilities)) {
|
|
156
147
|
const capabilityNames = exportedCapabilities.elements.map((element) => generateXLR(element, checker, converter, outputDirectory));
|
|
@@ -175,3 +166,4 @@ function pluginVisitor(args) {
|
|
|
175
166
|
return capabilities;
|
|
176
167
|
}
|
|
177
168
|
exports.pluginVisitor = pluginVisitor;
|
|
169
|
+
//# sourceMappingURL=plugin.js.map
|