@venizia/dev-configs 0.5.0-10 → 0.5.0-12
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/README.md +3 -3
- package/dist/cli/codemod/async-context.d.ts +22 -0
- package/dist/cli/codemod/async-context.js +146 -0
- package/dist/cli/codemod/async-context.js.map +1 -0
- package/dist/cli/codemod/class-renames.d.ts +63 -0
- package/dist/cli/codemod/class-renames.js +208 -17
- package/dist/cli/codemod/class-renames.js.map +1 -1
- package/dist/cli/codemod/execution-class.d.ts +14 -0
- package/dist/cli/codemod/execution-class.js +46 -0
- package/dist/cli/codemod/execution-class.js.map +1 -0
- package/dist/cli/codemod/execution-scope.d.ts +68 -0
- package/dist/cli/codemod/execution-scope.js +727 -0
- package/dist/cli/codemod/execution-scope.js.map +1 -0
- package/dist/cli/codemod/index.js +25 -0
- package/dist/cli/codemod/index.js.map +1 -1
- package/dist/cli/codemod/namespace-functions/mapping.d.ts +6 -0
- package/dist/cli/codemod/namespace-functions/mapping.js.map +1 -1
- package/dist/cli/codemod/namespace-functions/mappings/connectors.d.ts +2 -0
- package/dist/cli/codemod/namespace-functions/mappings/connectors.js +19 -1
- package/dist/cli/codemod/namespace-functions/mappings/connectors.js.map +1 -1
- package/dist/cli/codemod/namespace-functions/mappings/guards.d.ts +4 -0
- package/dist/cli/codemod/namespace-functions/mappings/guards.js +15 -0
- package/dist/cli/codemod/namespace-functions/mappings/guards.js.map +1 -0
- package/dist/cli/codemod/namespace-functions/mappings/helpers.d.ts +3 -2
- package/dist/cli/codemod/namespace-functions/mappings/helpers.js +30 -9
- package/dist/cli/codemod/namespace-functions/mappings/helpers.js.map +1 -1
- package/dist/cli/codemod/namespace-functions/mappings/inversion.d.ts +6 -2
- package/dist/cli/codemod/namespace-functions/mappings/inversion.js +42 -3
- package/dist/cli/codemod/namespace-functions/mappings/inversion.js.map +1 -1
- package/dist/cli/codemod/namespace-functions/mappings/kernel.d.ts +4 -2
- package/dist/cli/codemod/namespace-functions/mappings/kernel.js +16 -3
- package/dist/cli/codemod/namespace-functions/mappings/kernel.js.map +1 -1
- package/dist/cli/codemod/namespace-functions/rewriter.d.ts +7 -0
- package/dist/cli/codemod/namespace-functions/rewriter.js +75 -8
- package/dist/cli/codemod/namespace-functions/rewriter.js.map +1 -1
- package/dist/cli/codemod/public-names.d.ts +25 -0
- package/dist/cli/codemod/public-names.js +134 -0
- package/dist/cli/codemod/public-names.js.map +1 -0
- package/dist/cli/index.js +1 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/compilers/bun.js +8 -1
- package/dist/compilers/bun.js.map +1 -1
- package/dist/linters/eslint.js.map +1 -1
- package/dist/linters/house/configs.js +8 -4
- package/dist/linters/house/configs.js.map +1 -1
- package/dist/linters/house/execution-support.d.ts +66 -0
- package/dist/linters/house/execution-support.js +161 -0
- package/dist/linters/house/execution-support.js.map +1 -0
- package/dist/linters/house/framework-api-patterns.js +1 -1
- package/dist/linters/house/framework-api-patterns.js.map +1 -1
- package/dist/linters/house/index.d.ts +3 -1
- package/dist/linters/house/index.js +3 -1
- package/dist/linters/house/index.js.map +1 -1
- package/dist/linters/house/no-shadow-framework-type.rule.d.ts +1 -1
- package/dist/linters/house/no-shadow-framework-type.rule.js +1 -1
- package/dist/linters/house/no-shadow-framework-type.rule.js.map +1 -1
- package/dist/linters/house/plugin.js +6 -2
- package/dist/linters/house/plugin.js.map +1 -1
- package/dist/linters/house/prefer-execution-sleep.rule.d.ts +31 -0
- package/dist/linters/house/{prefer-promise-sleep.rule.js → prefer-execution-sleep.rule.js} +57 -20
- package/dist/linters/house/prefer-execution-sleep.rule.js.map +1 -0
- package/dist/linters/house/prefer-http-method.rule.d.ts +6 -3
- package/dist/linters/house/prefer-http-method.rule.js +116 -9
- package/dist/linters/house/prefer-http-method.rule.js.map +1 -1
- package/dist/linters/house/restrict-execution-call-sites.rule.d.ts +30 -0
- package/dist/linters/house/restrict-execution-call-sites.rule.js +142 -0
- package/dist/linters/house/restrict-execution-call-sites.rule.js.map +1 -0
- package/dist/linters/house/static-execution-reason.rule.d.ts +27 -0
- package/dist/linters/house/static-execution-reason.rule.js +152 -0
- package/dist/linters/house/static-execution-reason.rule.js.map +1 -0
- package/dist/linters/rules/naming-convention.rule.js +1 -1
- package/dist/linters/rules/naming-convention.rule.js.map +1 -1
- package/dist/linters/rules/no-restricted-imports.rule.d.ts +4 -2
- package/dist/linters/rules/no-restricted-imports.rule.js.map +1 -1
- package/dist/linters/rules/no-unused-vars.rule.d.ts +13 -2
- package/dist/linters/rules/no-unused-vars.rule.js.map +1 -1
- package/package.json +2 -2
- package/dist/linters/house/prefer-promise-sleep.rule.d.ts +0 -26
- package/dist/linters/house/prefer-promise-sleep.rule.js.map +0 -1
|
@@ -0,0 +1,727 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExecutionScopeCommand = exports.ExecutionScopeRewrite = exports.ExecutionScopeMapReader = void 0;
|
|
4
|
+
const node_fs_1 = require("node:fs");
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
6
|
+
const class_renames_1 = require("./class-renames");
|
|
7
|
+
const cli_output_1 = require("../../common/cli-output");
|
|
8
|
+
const USAGE = `Usage: devz codemod execution-scope --map <file.json> [paths...] [--write [--all] | --check] [--rewrite-nested]
|
|
9
|
+
|
|
10
|
+
An application's own scope helpers become Execution.run (@venizia/ignis). The map names them:
|
|
11
|
+
|
|
12
|
+
{
|
|
13
|
+
"runElevated": { "mode": "system" },
|
|
14
|
+
"runPinned": { "mode": "scoped", "values": { "tenantIds": "tenantIds" } }
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
A key is the exported name of a helper, or "Class.method". "values" names the value of the frame (left) and the
|
|
18
|
+
option of the helper that holds it (right). A helper is read when it is imported from a module of the application
|
|
19
|
+
(a path starting ".", "@/", "~/" or "#"); for one that comes from a package, name the package with "from":
|
|
20
|
+
|
|
21
|
+
{ "runElevated": { "mode": "system", "from": "@acme/core" } }
|
|
22
|
+
|
|
23
|
+
With "from", only that module is read. The same name imported from anywhere else is listed. It reads a call of an imported helper, an aliased import included, in
|
|
24
|
+
one of these shapes, where the task is an arrow or a function with no parameter, written in the call:
|
|
25
|
+
|
|
26
|
+
helper(task) a helper with no "values"
|
|
27
|
+
helper({ tenantIds, task }) the options of "values" and one other property, the task
|
|
28
|
+
helper({ tenantIds }, task) the options of "values", then the task
|
|
29
|
+
|
|
30
|
+
A system call gets the reason "TODO: reason (<file>:<method>)" for you to write. It lists by file and line what it
|
|
31
|
+
leaves for you: those reasons, every call it cannot read (a helper passed as a value, a spread argument, a task by
|
|
32
|
+
reference), and every system call lexically inside a scoped one, which would see more under "the innermost frame
|
|
33
|
+
wins". It does not follow calls across functions. A file that defines a mapped helper is not touched. Event
|
|
34
|
+
handlers and queue consumers are listed as "review": they no longer inherit system rights.
|
|
35
|
+
|
|
36
|
+
Execution.run always returns a promise: where a helper was synchronous, your typecheck and tests must confirm the call.
|
|
37
|
+
|
|
38
|
+
--map the JSON file of your helpers (required), relative to the working directory
|
|
39
|
+
--write write the changed files (without it, nothing is written); it needs a path, or --all
|
|
40
|
+
--all with --write and no path: rewrite every source file under the working directory
|
|
41
|
+
--check dry run that exits 1 while a file would change or a line is left for you (for CI)
|
|
42
|
+
--rewrite-nested rewrite the system calls inside scoped ones too, after you reviewed them
|
|
43
|
+
--help print this text and exit
|
|
44
|
+
|
|
45
|
+
There is no --reverse: a downgrade restores the files from git.`;
|
|
46
|
+
/** A usage error: nothing was read or written. */
|
|
47
|
+
const USAGE_ERROR_CODE = 2;
|
|
48
|
+
const MAP_FLAG = '--map';
|
|
49
|
+
const NESTED_FLAG = '--rewrite-nested';
|
|
50
|
+
const TODO_PREFIX = 'TODO: reason (';
|
|
51
|
+
const IGNIS_MODULE = '@venizia/ignis';
|
|
52
|
+
const IGNIS_PACKAGES = [IGNIS_MODULE, '@venizia/ignis-helpers'];
|
|
53
|
+
const EXECUTION = 'Execution';
|
|
54
|
+
const EXECUTION_MODES = 'ExecutionModes';
|
|
55
|
+
const IDENTIFIER_PATTERN = /^[A-Za-z_$][\w$]*$/;
|
|
56
|
+
const KEY_PATTERN = /^[A-Za-z_$][\w$]*(\.[A-Za-z_$][\w$]*)?$/;
|
|
57
|
+
/** The callbacks of a queue consumer: BullMQ, Kafka, MQTT and the in-memory queue. */
|
|
58
|
+
const CONSUMER_CALLBACKS = new Set([
|
|
59
|
+
'onWorkerData',
|
|
60
|
+
'onWorkerDataCompleted',
|
|
61
|
+
'onWorkerDataFail',
|
|
62
|
+
'onMessage',
|
|
63
|
+
'onMessageDone',
|
|
64
|
+
'onMessageError',
|
|
65
|
+
]);
|
|
66
|
+
/** Reads and checks the JSON of `--map`. */
|
|
67
|
+
class ExecutionScopeMapReader {
|
|
68
|
+
static isRecord(value) {
|
|
69
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
70
|
+
}
|
|
71
|
+
/** The values of a scoped entry, or `undefined` when one is not an option name. */
|
|
72
|
+
static readValues(value) {
|
|
73
|
+
if (!ExecutionScopeMapReader.isRecord(value)) {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
const values = {};
|
|
77
|
+
for (const [key, option] of Object.entries(value)) {
|
|
78
|
+
if (typeof option !== 'string' || option === '') {
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
values[key] = option;
|
|
82
|
+
}
|
|
83
|
+
return values;
|
|
84
|
+
}
|
|
85
|
+
static readEntry(value) {
|
|
86
|
+
if (!ExecutionScopeMapReader.isRecord(value)) {
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
const { mode, values, from, ...rest } = value;
|
|
90
|
+
const isModule = from === undefined || (typeof from === 'string' && from !== '');
|
|
91
|
+
if (Object.keys(rest).length > 0 || !isModule) {
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
const origin = typeof from === 'string' ? { from } : {};
|
|
95
|
+
if (mode === 'system') {
|
|
96
|
+
return values === undefined ? { mode, ...origin } : undefined;
|
|
97
|
+
}
|
|
98
|
+
if (mode !== 'scoped') {
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
if (values === undefined) {
|
|
102
|
+
return { mode, ...origin };
|
|
103
|
+
}
|
|
104
|
+
const read = ExecutionScopeMapReader.readValues(values);
|
|
105
|
+
return read ? { mode, values: read, ...origin } : undefined;
|
|
106
|
+
}
|
|
107
|
+
/** The map in `text`, or why it is not one. */
|
|
108
|
+
static parse(opts) {
|
|
109
|
+
let data;
|
|
110
|
+
try {
|
|
111
|
+
data = JSON.parse(opts.text);
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
return { error: `not JSON: ${String(error)}` };
|
|
115
|
+
}
|
|
116
|
+
if (!ExecutionScopeMapReader.isRecord(data) || Object.keys(data).length === 0) {
|
|
117
|
+
return { error: 'an object with one entry per helper is expected' };
|
|
118
|
+
}
|
|
119
|
+
const map = {};
|
|
120
|
+
for (const [name, value] of Object.entries(data)) {
|
|
121
|
+
const entry = ExecutionScopeMapReader.readEntry(value);
|
|
122
|
+
if (!KEY_PATTERN.test(name) || !entry) {
|
|
123
|
+
return {
|
|
124
|
+
error: `"${name}": the key is a name or "Class.method", the value { "mode": "system" } or { "mode": "scoped", "values"?: { "<value>": "<option>" } }, either with an optional "from"`,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
map[name] = entry;
|
|
128
|
+
}
|
|
129
|
+
return { map };
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
exports.ExecutionScopeMapReader = ExecutionScopeMapReader;
|
|
133
|
+
/** Rewrites the calls of one file. */
|
|
134
|
+
class ExecutionScopeRewrite {
|
|
135
|
+
/** Whether a helper imported from `module` is the one the entry means: another package may use the same name. */
|
|
136
|
+
static isHelperModule(opts) {
|
|
137
|
+
const { entry, module } = opts;
|
|
138
|
+
return entry.from === undefined ? /^(\.|@\/|~\/|#)/.test(module) : module === entry.from;
|
|
139
|
+
}
|
|
140
|
+
/** Whether `node` names a member or a property, and is no use of a binding. */
|
|
141
|
+
static isMemberName(opts) {
|
|
142
|
+
const { typescript: ts, node } = opts;
|
|
143
|
+
const parent = node.parent;
|
|
144
|
+
if (ts.isQualifiedName(parent)) {
|
|
145
|
+
return parent.right === node;
|
|
146
|
+
}
|
|
147
|
+
if (ts.isBindingElement(parent)) {
|
|
148
|
+
return parent.propertyName === node;
|
|
149
|
+
}
|
|
150
|
+
return ((ts.isPropertyAccessExpression(parent) ||
|
|
151
|
+
ts.isPropertyAssignment(parent) ||
|
|
152
|
+
ts.isPropertyDeclaration(parent) ||
|
|
153
|
+
ts.isPropertySignature(parent) ||
|
|
154
|
+
ts.isMethodDeclaration(parent) ||
|
|
155
|
+
ts.isMethodSignature(parent) ||
|
|
156
|
+
ts.isGetAccessorDeclaration(parent) ||
|
|
157
|
+
ts.isSetAccessorDeclaration(parent) ||
|
|
158
|
+
ts.isEnumMember(parent) ||
|
|
159
|
+
ts.isJsxAttribute(parent)) &&
|
|
160
|
+
parent.name === node);
|
|
161
|
+
}
|
|
162
|
+
/** The mapped helpers this file defines itself: its calls are the helper's own, and stay. */
|
|
163
|
+
static definitions(opts) {
|
|
164
|
+
const { typescript: ts, file, map } = opts;
|
|
165
|
+
const found = [];
|
|
166
|
+
const check = (node, name) => {
|
|
167
|
+
if (Object.hasOwn(map, name)) {
|
|
168
|
+
found.push({ node, name });
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
for (const statement of file.statements) {
|
|
172
|
+
if (ts.isFunctionDeclaration(statement) && statement.name) {
|
|
173
|
+
check(statement, statement.name.text);
|
|
174
|
+
}
|
|
175
|
+
if (ts.isClassDeclaration(statement) && statement.name) {
|
|
176
|
+
for (const member of statement.members) {
|
|
177
|
+
check(member, `${statement.name.text}.${member.name?.getText(file)}`);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
if (!ts.isVariableStatement(statement)) {
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
for (const { name, initializer } of statement.declarationList.declarations) {
|
|
184
|
+
if (!ts.isIdentifier(name)) {
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
check(statement, name.text);
|
|
188
|
+
if (initializer && ts.isObjectLiteralExpression(initializer)) {
|
|
189
|
+
for (const property of initializer.properties) {
|
|
190
|
+
check(property, `${name.text}.${property.name?.getText(file)}`);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return found;
|
|
196
|
+
}
|
|
197
|
+
/** The event handlers and queue consumers of the file: they ran with their starter's rights, and no longer do. */
|
|
198
|
+
static listeners(opts) {
|
|
199
|
+
const { typescript: ts, file } = opts;
|
|
200
|
+
const found = [];
|
|
201
|
+
const lost = 'it no longer inherits system rights';
|
|
202
|
+
const visit = (node) => {
|
|
203
|
+
if (ts.isHeritageClause(node) &&
|
|
204
|
+
node.types.some((type) => type.expression.getText(file) === 'IEventHandler')) {
|
|
205
|
+
found.push({ node, note: `event handler: ${lost}` });
|
|
206
|
+
}
|
|
207
|
+
if (ts.isCallExpression(node) &&
|
|
208
|
+
ts.isPropertyAccessExpression(node.expression) &&
|
|
209
|
+
node.expression.name.text === 'register') {
|
|
210
|
+
const [options] = node.arguments;
|
|
211
|
+
const names = options && ts.isObjectLiteralExpression(options)
|
|
212
|
+
? options.properties.map((property) => property.name?.getText(file))
|
|
213
|
+
: [];
|
|
214
|
+
if (names.includes('name') && names.includes('handler')) {
|
|
215
|
+
found.push({ node, note: `event handler registration: ${lost}` });
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
const isMember = ts.isPropertyAssignment(node) ||
|
|
219
|
+
ts.isShorthandPropertyAssignment(node) ||
|
|
220
|
+
ts.isMethodDeclaration(node) ||
|
|
221
|
+
ts.isPropertyDeclaration(node);
|
|
222
|
+
if (isMember && CONSUMER_CALLBACKS.has(node.name.getText(file))) {
|
|
223
|
+
found.push({ node, note: `queue consumer (${node.name.getText(file)}): ${lost}` });
|
|
224
|
+
}
|
|
225
|
+
ts.forEachChild(node, visit);
|
|
226
|
+
};
|
|
227
|
+
visit(file);
|
|
228
|
+
return found;
|
|
229
|
+
}
|
|
230
|
+
/** The method or function a node stands in; without one, the variable or property it is written under. */
|
|
231
|
+
static methodOf(opts) {
|
|
232
|
+
const { typescript: ts, node, file } = opts;
|
|
233
|
+
let holder;
|
|
234
|
+
for (let at = node.parent; !ts.isSourceFile(at); at = at.parent) {
|
|
235
|
+
if (ts.isConstructorDeclaration(at)) {
|
|
236
|
+
return 'constructor';
|
|
237
|
+
}
|
|
238
|
+
if ((ts.isMethodDeclaration(at) ||
|
|
239
|
+
ts.isFunctionDeclaration(at) ||
|
|
240
|
+
ts.isGetAccessorDeclaration(at) ||
|
|
241
|
+
ts.isSetAccessorDeclaration(at)) &&
|
|
242
|
+
at.name) {
|
|
243
|
+
return at.name.getText(file);
|
|
244
|
+
}
|
|
245
|
+
if ((ts.isVariableDeclaration(at) ||
|
|
246
|
+
ts.isPropertyDeclaration(at) ||
|
|
247
|
+
ts.isPropertyAssignment(at)) &&
|
|
248
|
+
ts.isIdentifier(at.name)) {
|
|
249
|
+
holder ??= at.name.text;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return holder ?? 'module';
|
|
253
|
+
}
|
|
254
|
+
/** Whether a comment stands in a part of the call that the rewrite replaces. */
|
|
255
|
+
static hasComment(opts) {
|
|
256
|
+
const { typescript: ts, source, span, kept } = opts;
|
|
257
|
+
let text = '';
|
|
258
|
+
let at = span.start;
|
|
259
|
+
for (const part of [...kept].sort((a, b) => a.start - b.start)) {
|
|
260
|
+
text += `${source.slice(at, part.start)} 0 `;
|
|
261
|
+
at = part.end;
|
|
262
|
+
}
|
|
263
|
+
text += source.slice(at, span.end);
|
|
264
|
+
const scanner = ts.createScanner(ts.ScriptTarget.Latest, false, ts.LanguageVariant.Standard, text);
|
|
265
|
+
for (let token = scanner.scan(); token !== ts.SyntaxKind.EndOfFileToken; token = scanner.scan()) {
|
|
266
|
+
if (token === ts.SyntaxKind.SingleLineCommentTrivia ||
|
|
267
|
+
token === ts.SyntaxKind.MultiLineCommentTrivia) {
|
|
268
|
+
return true;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return false;
|
|
272
|
+
}
|
|
273
|
+
/** The task and the values of a call, or why the call cannot be read. */
|
|
274
|
+
static readCall(opts) {
|
|
275
|
+
const { typescript: ts, file, call, entry } = opts;
|
|
276
|
+
const wanted = Object.entries(entry.mode === 'scoped' ? (entry.values ?? {}) : {});
|
|
277
|
+
const args = [...call.arguments];
|
|
278
|
+
if (args.some((argument) => ts.isSpreadElement(argument))) {
|
|
279
|
+
return { reason: 'a spread argument' };
|
|
280
|
+
}
|
|
281
|
+
const [first, second] = args;
|
|
282
|
+
if (!first || args.length > 2) {
|
|
283
|
+
return { reason: `${args.length} arguments` };
|
|
284
|
+
}
|
|
285
|
+
const values = [];
|
|
286
|
+
const others = [];
|
|
287
|
+
if (ts.isObjectLiteralExpression(first)) {
|
|
288
|
+
const options = new Map();
|
|
289
|
+
for (const property of first.properties) {
|
|
290
|
+
if (ts.isShorthandPropertyAssignment(property) && !property.objectAssignmentInitializer) {
|
|
291
|
+
options.set(property.name.text, property.name);
|
|
292
|
+
}
|
|
293
|
+
else if (ts.isPropertyAssignment(property) && ts.isIdentifier(property.name)) {
|
|
294
|
+
options.set(property.name.text, property.initializer);
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
297
|
+
return { reason: 'an option that is not "name" or "name: value"' };
|
|
298
|
+
}
|
|
299
|
+
if (!wanted.some(([, option]) => option === property.name?.getText(file))) {
|
|
300
|
+
others.push(property);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
for (const [key, option] of wanted) {
|
|
304
|
+
const node = options.get(option);
|
|
305
|
+
if (!node) {
|
|
306
|
+
return { reason: `no "${option}" option` };
|
|
307
|
+
}
|
|
308
|
+
values.push({ key, node });
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
else if (second || wanted.length > 0) {
|
|
312
|
+
return { reason: 'its options are not an object written in the call' };
|
|
313
|
+
}
|
|
314
|
+
let task = second;
|
|
315
|
+
if (second && others.length > 0) {
|
|
316
|
+
return { reason: 'an option the map does not name' };
|
|
317
|
+
}
|
|
318
|
+
if (!second && ts.isObjectLiteralExpression(first)) {
|
|
319
|
+
const [property] = others;
|
|
320
|
+
task =
|
|
321
|
+
others.length === 1 && property && ts.isPropertyAssignment(property)
|
|
322
|
+
? property.initializer
|
|
323
|
+
: undefined;
|
|
324
|
+
}
|
|
325
|
+
else if (!second) {
|
|
326
|
+
task = first;
|
|
327
|
+
}
|
|
328
|
+
const isInline = task &&
|
|
329
|
+
(ts.isArrowFunction(task) || (ts.isFunctionExpression(task) && !task.asteriskToken)) &&
|
|
330
|
+
task.parameters.length === 0;
|
|
331
|
+
if (!task || !isInline) {
|
|
332
|
+
return { reason: 'the task is not one function with no parameter, written in the call' };
|
|
333
|
+
}
|
|
334
|
+
return { task, values };
|
|
335
|
+
}
|
|
336
|
+
static rewrite(opts) {
|
|
337
|
+
const { typescript: ts, fileName, shownName, source, map, isNestedRewritten } = opts;
|
|
338
|
+
const scriptKind = fileName.endsWith('.tsx') ? ts.ScriptKind.TSX : ts.ScriptKind.TS;
|
|
339
|
+
const file = ts.createSourceFile(fileName, source, ts.ScriptTarget.Latest, true, scriptKind);
|
|
340
|
+
const manual = [];
|
|
341
|
+
const lineOf = (node) => file.getLineAndCharacterOfPosition(node.getStart(file)).line + 1;
|
|
342
|
+
const info = ExecutionScopeRewrite.listeners({ typescript: ts, file }).map(({ node, note }) => ({ line: lineOf(node), note }));
|
|
343
|
+
const definitions = ExecutionScopeRewrite.definitions({ typescript: ts, file, map });
|
|
344
|
+
if (definitions.length > 0) {
|
|
345
|
+
for (const { node, name } of definitions) {
|
|
346
|
+
info.push({
|
|
347
|
+
line: lineOf(node),
|
|
348
|
+
note: `defines the mapped helper "${name}": the file is left as written`,
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
return { output: source, changed: false, rewritten: 0, manual, info };
|
|
352
|
+
}
|
|
353
|
+
const imports = file.statements.filter((statement) => ts.isImportDeclaration(statement));
|
|
354
|
+
const moduleOf = (node) => ts.isStringLiteralLike(node.moduleSpecifier) ? node.moduleSpecifier.text : '';
|
|
355
|
+
const isIgnis = (node) => IGNIS_PACKAGES.some((name) => moduleOf(node) === name || moduleOf(node).startsWith(`${name}/`));
|
|
356
|
+
/** Local name of an import to the name it was exported as, and the module. */
|
|
357
|
+
const bindings = new Map();
|
|
358
|
+
const bind = (binding) => {
|
|
359
|
+
const { node, local, imported } = binding;
|
|
360
|
+
const module = moduleOf(node);
|
|
361
|
+
bindings.set(local, { imported, module });
|
|
362
|
+
const isForeign = Object.entries(map).some(([key, entry]) => key.split('.')[0] === imported &&
|
|
363
|
+
!ExecutionScopeRewrite.isHelperModule({ entry, module }));
|
|
364
|
+
if (isForeign) {
|
|
365
|
+
manual.push({
|
|
366
|
+
line: lineOf(node),
|
|
367
|
+
note: `"${imported}" is imported from "${module}": to rewrite its calls, name that module with "from" in the map`,
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
/** The local names `Execution` and `ExecutionModes` already have as values from the framework. */
|
|
372
|
+
const framework = new Map();
|
|
373
|
+
for (const statement of imports) {
|
|
374
|
+
const clause = statement.importClause;
|
|
375
|
+
if (clause?.name) {
|
|
376
|
+
bind({ node: statement, local: clause.name.text, imported: clause.name.text });
|
|
377
|
+
}
|
|
378
|
+
if (!clause?.namedBindings || !ts.isNamedImports(clause.namedBindings)) {
|
|
379
|
+
continue;
|
|
380
|
+
}
|
|
381
|
+
for (const element of clause.namedBindings.elements) {
|
|
382
|
+
const imported = (element.propertyName ?? element.name).text;
|
|
383
|
+
if (!isIgnis(statement)) {
|
|
384
|
+
bind({ node: statement, local: element.name.text, imported });
|
|
385
|
+
}
|
|
386
|
+
else if (!clause.isTypeOnly && !element.isTypeOnly) {
|
|
387
|
+
framework.set(imported, element.name.text);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
/** Every use of a name outside the imports, and every name the file declares. */
|
|
392
|
+
const uses = new Map();
|
|
393
|
+
const declared = new Set();
|
|
394
|
+
const collect = (node) => {
|
|
395
|
+
if (ts.isImportDeclaration(node)) {
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
const isDeclaration = ts.isVariableDeclaration(node) ||
|
|
399
|
+
ts.isBindingElement(node) ||
|
|
400
|
+
ts.isParameter(node) ||
|
|
401
|
+
ts.isFunctionDeclaration(node) ||
|
|
402
|
+
ts.isClassDeclaration(node) ||
|
|
403
|
+
ts.isInterfaceDeclaration(node) ||
|
|
404
|
+
ts.isTypeAliasDeclaration(node) ||
|
|
405
|
+
ts.isEnumDeclaration(node);
|
|
406
|
+
if (isDeclaration && node.name && ts.isIdentifier(node.name)) {
|
|
407
|
+
declared.add(node.name.text);
|
|
408
|
+
}
|
|
409
|
+
if (ts.isIdentifier(node) && !ExecutionScopeRewrite.isMemberName({ typescript: ts, node })) {
|
|
410
|
+
const found = uses.get(node.text) ?? [];
|
|
411
|
+
found.push(node);
|
|
412
|
+
uses.set(node.text, found);
|
|
413
|
+
}
|
|
414
|
+
ts.forEachChild(node, collect);
|
|
415
|
+
};
|
|
416
|
+
collect(file);
|
|
417
|
+
/** The mapped helper an expression names: `helper`, or `Class.method`. */
|
|
418
|
+
const helperOf = (node) => {
|
|
419
|
+
let local;
|
|
420
|
+
let member = '';
|
|
421
|
+
if (ts.isIdentifier(node)) {
|
|
422
|
+
local = node;
|
|
423
|
+
}
|
|
424
|
+
else if (ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.expression)) {
|
|
425
|
+
local = node.expression;
|
|
426
|
+
member = `.${node.name.text}`;
|
|
427
|
+
}
|
|
428
|
+
else {
|
|
429
|
+
return undefined;
|
|
430
|
+
}
|
|
431
|
+
const binding = bindings.get(local.text);
|
|
432
|
+
if (!binding) {
|
|
433
|
+
return undefined;
|
|
434
|
+
}
|
|
435
|
+
const { imported, module } = binding;
|
|
436
|
+
const key = `${imported}${member}`;
|
|
437
|
+
return Object.hasOwn(map, key) &&
|
|
438
|
+
ExecutionScopeRewrite.isHelperModule({ entry: map[key], module })
|
|
439
|
+
? { key, local, entry: map[key] }
|
|
440
|
+
: undefined;
|
|
441
|
+
};
|
|
442
|
+
/** Whether `call` opens a scoped frame: a mapped scoped helper, or `Execution.run` in scoped mode. */
|
|
443
|
+
const isScopedCall = (call) => {
|
|
444
|
+
if (helperOf(call.expression)?.entry.mode === 'scoped') {
|
|
445
|
+
return true;
|
|
446
|
+
}
|
|
447
|
+
const [options] = call.arguments;
|
|
448
|
+
const execution = framework.get(EXECUTION);
|
|
449
|
+
if (!execution ||
|
|
450
|
+
call.expression.getText(file) !== `${execution}.run` ||
|
|
451
|
+
!options ||
|
|
452
|
+
!ts.isObjectLiteralExpression(options)) {
|
|
453
|
+
return false;
|
|
454
|
+
}
|
|
455
|
+
return options.properties.some((property) => ts.isPropertyAssignment(property) &&
|
|
456
|
+
property.name.getText(file) === 'mode' &&
|
|
457
|
+
/(\.SCOPED|^['"]scoped['"])$/.test(property.initializer.getText(file)));
|
|
458
|
+
};
|
|
459
|
+
const isInsideScoped = (node) => {
|
|
460
|
+
for (let at = node; !ts.isSourceFile(at); at = at.parent) {
|
|
461
|
+
const parent = at.parent;
|
|
462
|
+
if (ts.isCallExpression(parent) && parent.expression !== at && isScopedCall(parent)) {
|
|
463
|
+
return true;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
return false;
|
|
467
|
+
};
|
|
468
|
+
const mentionsHelper = (node) => helperOf(node) !== undefined || (ts.forEachChild(node, mentionsHelper) ?? false);
|
|
469
|
+
/** The local name for an export of the framework, and the import specifier to add when it has none. */
|
|
470
|
+
const localOf = (name) => {
|
|
471
|
+
const existing = framework.get(name);
|
|
472
|
+
if (existing) {
|
|
473
|
+
return { local: existing, specifier: undefined };
|
|
474
|
+
}
|
|
475
|
+
const isTaken = (candidate) => declared.has(candidate) || bindings.has(candidate);
|
|
476
|
+
const local = isTaken(name) ? `Ignis${name}` : name;
|
|
477
|
+
return { local, specifier: local === name ? name : `${name} as ${local}` };
|
|
478
|
+
};
|
|
479
|
+
const execution = localOf(EXECUTION);
|
|
480
|
+
const modes = localOf(EXECUTION_MODES);
|
|
481
|
+
const edits = [];
|
|
482
|
+
const consumed = new Map();
|
|
483
|
+
let rewritten = 0;
|
|
484
|
+
/** Rewrites one call, or lists why it is left. */
|
|
485
|
+
const handle = (call, helper) => {
|
|
486
|
+
const { key, local, entry } = helper;
|
|
487
|
+
const leave = (note) => manual.push({ line: lineOf(call), note });
|
|
488
|
+
if (declared.has(local.text)) {
|
|
489
|
+
leave(`${key} is left: the file declares "${local.text}" too`);
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
if (entry.mode === 'system' && !isNestedRewritten && isInsideScoped(call)) {
|
|
493
|
+
leave(`${key} is a system call inside a scoped one, so it would see more: review it, then run with ${NESTED_FLAG}`);
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
if (call.questionDotToken || (call.typeArguments?.length ?? 0) > 1) {
|
|
497
|
+
leave(`cannot read this call of ${key}: an optional call or several type arguments`);
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
const read = ExecutionScopeRewrite.readCall({ typescript: ts, file, call, entry });
|
|
501
|
+
if ('reason' in read) {
|
|
502
|
+
leave(`cannot read this call of ${key}: ${read.reason}`);
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
505
|
+
const { task, values } = read;
|
|
506
|
+
const spanOf = (node) => ({
|
|
507
|
+
start: node.getStart(file),
|
|
508
|
+
end: node.getEnd(),
|
|
509
|
+
});
|
|
510
|
+
const taskSpan = spanOf(task);
|
|
511
|
+
const kept = [...values.map(({ node }) => spanOf(node)), taskSpan];
|
|
512
|
+
const typeArguments = call.typeArguments?.map(spanOf) ?? [];
|
|
513
|
+
const span = { start: call.expression.getEnd(), end: call.getEnd() };
|
|
514
|
+
if (ExecutionScopeRewrite.hasComment({
|
|
515
|
+
typescript: ts,
|
|
516
|
+
source,
|
|
517
|
+
span,
|
|
518
|
+
kept: [...kept, ...typeArguments],
|
|
519
|
+
})) {
|
|
520
|
+
leave(`cannot read this call of ${key}: a comment between its arguments would be lost`);
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
if (values.some(({ node }) => mentionsHelper(node))) {
|
|
524
|
+
leave(`cannot read this call of ${key}: a value uses a mapped helper`);
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
const parts = [`mode: ${modes.local}.${entry.mode.toUpperCase()}`];
|
|
528
|
+
if (entry.mode === 'system') {
|
|
529
|
+
const method = ExecutionScopeRewrite.methodOf({ typescript: ts, node: call, file });
|
|
530
|
+
const reason = `${TODO_PREFIX}${shownName}:${method})`;
|
|
531
|
+
parts.push(`reason: '${reason.replace(/[\\']/g, '\\$&')}'`);
|
|
532
|
+
leave(`write the reason: '${reason}'`);
|
|
533
|
+
}
|
|
534
|
+
if (values.length > 0) {
|
|
535
|
+
const written = values.map(({ key: name, node }) => {
|
|
536
|
+
const value = node.getText(file);
|
|
537
|
+
const property = IDENTIFIER_PATTERN.test(name) ? name : JSON.stringify(name);
|
|
538
|
+
return property === value ? value : `${property}: ${value}`;
|
|
539
|
+
});
|
|
540
|
+
parts.push(`values: { ${written.join(', ')} }`);
|
|
541
|
+
}
|
|
542
|
+
edits.push({ ...spanOf(call.expression), text: `${execution.local}.run` }, {
|
|
543
|
+
start: call.arguments.pos,
|
|
544
|
+
end: taskSpan.start,
|
|
545
|
+
text: `{ ${parts.join(', ')}, task: `,
|
|
546
|
+
}, { start: taskSpan.end, end: call.getEnd() - 1, text: ' }' });
|
|
547
|
+
consumed.set(local.text, (consumed.get(local.text) ?? 0) + 1);
|
|
548
|
+
rewritten += 1;
|
|
549
|
+
};
|
|
550
|
+
const visit = (node) => {
|
|
551
|
+
if (ts.isImportDeclaration(node)) {
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
554
|
+
if (ts.isStringLiteralLike(node) && node.text.startsWith(TODO_PREFIX)) {
|
|
555
|
+
manual.push({ line: lineOf(node), note: `write the reason: '${node.text}'` });
|
|
556
|
+
}
|
|
557
|
+
if (ts.isCallExpression(node)) {
|
|
558
|
+
const callee = node.expression;
|
|
559
|
+
const helper = helperOf(callee);
|
|
560
|
+
if (helper) {
|
|
561
|
+
handle(node, helper);
|
|
562
|
+
// The callee is read: only the arguments may hold more.
|
|
563
|
+
node.arguments.forEach(visit);
|
|
564
|
+
return;
|
|
565
|
+
}
|
|
566
|
+
if (ts.isPropertyAccessExpression(callee) && Object.hasOwn(map, callee.name.text)) {
|
|
567
|
+
manual.push({
|
|
568
|
+
line: lineOf(node),
|
|
569
|
+
note: `cannot read this call of ${callee.name.text}: it is called as a member`,
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
const isUse = (ts.isIdentifier(node) &&
|
|
574
|
+
!ExecutionScopeRewrite.isMemberName({ typescript: ts, node }) &&
|
|
575
|
+
!declared.has(node.text) &&
|
|
576
|
+
!ts.isTypeQueryNode(node.parent)) ||
|
|
577
|
+
ts.isPropertyAccessExpression(node);
|
|
578
|
+
const passed = isUse ? helperOf(node) : undefined;
|
|
579
|
+
if (passed) {
|
|
580
|
+
manual.push({
|
|
581
|
+
line: lineOf(node),
|
|
582
|
+
note: `cannot read this use of ${passed.key}: it is passed as a value`,
|
|
583
|
+
});
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
586
|
+
ts.forEachChild(node, visit);
|
|
587
|
+
};
|
|
588
|
+
visit(file);
|
|
589
|
+
if (rewritten === 0) {
|
|
590
|
+
return { output: source, changed: false, rewritten, manual, info };
|
|
591
|
+
}
|
|
592
|
+
/** The imports of the helpers nothing uses any more. */
|
|
593
|
+
const isDone = (name) => consumed.has(name.text) && consumed.get(name.text) === uses.get(name.text)?.length;
|
|
594
|
+
const added = [execution.specifier, modes.specifier].filter((entry) => entry !== undefined);
|
|
595
|
+
const target = imports.find((statement) => {
|
|
596
|
+
const clause = statement.importClause;
|
|
597
|
+
return (moduleOf(statement) === IGNIS_MODULE &&
|
|
598
|
+
!clause?.isTypeOnly &&
|
|
599
|
+
clause?.namedBindings &&
|
|
600
|
+
ts.isNamedImports(clause.namedBindings));
|
|
601
|
+
});
|
|
602
|
+
const addedImport = added.length > 0 && !target
|
|
603
|
+
? `import { ${added.join(', ')} } from '${IGNIS_MODULE}';`
|
|
604
|
+
: undefined;
|
|
605
|
+
let isImportPlaced = false;
|
|
606
|
+
if (added.length > 0 && target?.importClause?.namedBindings) {
|
|
607
|
+
const named = target.importClause.namedBindings;
|
|
608
|
+
if (ts.isNamedImports(named)) {
|
|
609
|
+
const last = named.elements.at(-1);
|
|
610
|
+
const at = last ? last.getEnd() : named.getStart(file) + 1;
|
|
611
|
+
const text = last ? `, ${added.join(', ')}` : ` ${added.join(', ')} `;
|
|
612
|
+
edits.push({ start: at, end: at, text });
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
for (const statement of imports) {
|
|
616
|
+
const clause = statement.importClause;
|
|
617
|
+
if (!clause || isIgnis(statement)) {
|
|
618
|
+
continue;
|
|
619
|
+
}
|
|
620
|
+
const named = clause.namedBindings && ts.isNamedImports(clause.namedBindings)
|
|
621
|
+
? clause.namedBindings
|
|
622
|
+
: undefined;
|
|
623
|
+
const elements = [...(named?.elements ?? [])];
|
|
624
|
+
const remaining = elements.filter((element) => !isDone(element.name));
|
|
625
|
+
const isDefaultDone = clause.name !== undefined && isDone(clause.name);
|
|
626
|
+
if (remaining.length === elements.length && !isDefaultDone) {
|
|
627
|
+
continue;
|
|
628
|
+
}
|
|
629
|
+
const defaultName = isDefaultDone ? undefined : clause.name?.text;
|
|
630
|
+
const namespace = clause.namedBindings && !named;
|
|
631
|
+
if (!defaultName && !namespace && remaining.length === 0) {
|
|
632
|
+
// The whole statement goes: the new import takes its place, or its line goes with it.
|
|
633
|
+
const start = statement.getStart(file);
|
|
634
|
+
const newline = /^[ \t]*\r?\n/.exec(source.slice(statement.getEnd()));
|
|
635
|
+
if (addedImport && !isImportPlaced) {
|
|
636
|
+
edits.push({ start, end: statement.getEnd(), text: addedImport });
|
|
637
|
+
isImportPlaced = true;
|
|
638
|
+
}
|
|
639
|
+
else {
|
|
640
|
+
edits.push({ start, end: statement.getEnd() + (newline?.[0].length ?? 0), text: '' });
|
|
641
|
+
}
|
|
642
|
+
continue;
|
|
643
|
+
}
|
|
644
|
+
const names = remaining.map((element) => element.getText(file));
|
|
645
|
+
const braces = names.length > 0 ? `{ ${names.join(', ')} }` : undefined;
|
|
646
|
+
const rest = namespace ? clause.namedBindings?.getText(file) : braces;
|
|
647
|
+
const type = clause.isTypeOnly ? 'type ' : '';
|
|
648
|
+
edits.push({
|
|
649
|
+
start: clause.getStart(file),
|
|
650
|
+
end: clause.getEnd(),
|
|
651
|
+
text: `${type}${[defaultName, rest].filter(Boolean).join(', ')}`,
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
if (addedImport && !isImportPlaced) {
|
|
655
|
+
const last = imports.at(-1);
|
|
656
|
+
const at = last ? last.getEnd() : (file.statements[0]?.getStart(file) ?? 0);
|
|
657
|
+
const text = last ? `\n${addedImport}` : `${addedImport}\n`;
|
|
658
|
+
edits.push({ start: at, end: at, text });
|
|
659
|
+
}
|
|
660
|
+
let output = source;
|
|
661
|
+
for (const edit of edits.sort((a, b) => b.start - a.start || b.end - a.end)) {
|
|
662
|
+
output = output.slice(0, edit.start) + edit.text + output.slice(edit.end);
|
|
663
|
+
}
|
|
664
|
+
return { output, changed: output !== source, rewritten, manual, info };
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
exports.ExecutionScopeRewrite = ExecutionScopeRewrite;
|
|
668
|
+
/** `devz codemod execution-scope`: an application's own scope helpers to `Execution.run`. */
|
|
669
|
+
class ExecutionScopeCommand {
|
|
670
|
+
static { this.USAGE = USAGE; }
|
|
671
|
+
static refuse(message) {
|
|
672
|
+
cli_output_1.CliOutput.error(`devz codemod execution-scope: ${message}\n${USAGE}`);
|
|
673
|
+
return USAGE_ERROR_CODE;
|
|
674
|
+
}
|
|
675
|
+
static async run(opts) {
|
|
676
|
+
const { root, args } = opts;
|
|
677
|
+
const isNestedRewritten = args.includes(NESTED_FLAG);
|
|
678
|
+
const rest = args.filter((argument) => argument !== NESTED_FLAG);
|
|
679
|
+
const at = rest.indexOf(MAP_FLAG);
|
|
680
|
+
const mapPath = at < 0 ? undefined : rest.splice(at, 2)[1];
|
|
681
|
+
let map = {};
|
|
682
|
+
if (!args.includes('--help') && !args.includes('-h')) {
|
|
683
|
+
if (!mapPath || mapPath.startsWith('-')) {
|
|
684
|
+
return ExecutionScopeCommand.refuse(`${MAP_FLAG} <file.json> is required`);
|
|
685
|
+
}
|
|
686
|
+
let text;
|
|
687
|
+
try {
|
|
688
|
+
text = (0, node_fs_1.readFileSync)((0, node_path_1.resolve)(root, mapPath), 'utf8');
|
|
689
|
+
}
|
|
690
|
+
catch (error) {
|
|
691
|
+
return ExecutionScopeCommand.refuse(`cannot read ${mapPath}: ${String(error)}`);
|
|
692
|
+
}
|
|
693
|
+
const parsed = ExecutionScopeMapReader.parse({ text });
|
|
694
|
+
if ('error' in parsed) {
|
|
695
|
+
return ExecutionScopeCommand.refuse(`${mapPath}: ${parsed.error}`);
|
|
696
|
+
}
|
|
697
|
+
map = parsed.map;
|
|
698
|
+
}
|
|
699
|
+
return class_renames_1.ClassRenamesCommand.run({
|
|
700
|
+
root,
|
|
701
|
+
args: rest,
|
|
702
|
+
codemod: {
|
|
703
|
+
name: 'execution-scope',
|
|
704
|
+
usage: USAGE,
|
|
705
|
+
isReversible: false,
|
|
706
|
+
unit: { noun: 'call(s)', verb: 'rewritten' },
|
|
707
|
+
// The names of the helpers, and what marks a handler, a consumer or a reason still to write.
|
|
708
|
+
marks: () => [
|
|
709
|
+
...Object.keys(map).flatMap((key) => key.split('.').slice(-1)),
|
|
710
|
+
'IEventHandler',
|
|
711
|
+
'.register(',
|
|
712
|
+
'onWorkerData',
|
|
713
|
+
'onMessage',
|
|
714
|
+
TODO_PREFIX,
|
|
715
|
+
],
|
|
716
|
+
rewrite: (input) => ExecutionScopeRewrite.rewrite({
|
|
717
|
+
...input,
|
|
718
|
+
shownName: (0, node_path_1.relative)(root, input.fileName).split('\\').join('/'),
|
|
719
|
+
map,
|
|
720
|
+
isNestedRewritten,
|
|
721
|
+
}),
|
|
722
|
+
},
|
|
723
|
+
});
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
exports.ExecutionScopeCommand = ExecutionScopeCommand;
|
|
727
|
+
//# sourceMappingURL=execution-scope.js.map
|