Brunobkr commited on
Commit
6bb7d6a
·
verified ·
1 Parent(s): ca207fb

Upload folder using huggingface_hub (part 48)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. tools/ui/node_modules/recast/lib/mapping.js +197 -0
  2. tools/ui/node_modules/recast/lib/options.d.ts +147 -0
  3. tools/ui/node_modules/recast/lib/options.js +55 -0
  4. tools/ui/node_modules/recast/lib/parser.d.ts +2 -0
  5. tools/ui/node_modules/recast/lib/parser.js +250 -0
  6. tools/ui/node_modules/recast/lib/patcher.d.ts +12 -0
  7. tools/ui/node_modules/recast/lib/patcher.js +386 -0
  8. tools/ui/node_modules/recast/lib/printer.d.ts +14 -0
  9. tools/ui/node_modules/recast/lib/printer.js +0 -0
  10. tools/ui/node_modules/recast/lib/util.d.ts +18 -0
  11. tools/ui/node_modules/recast/lib/util.js +331 -0
  12. tools/ui/node_modules/recast/main.d.ts +50 -0
  13. tools/ui/node_modules/recast/main.js +65 -0
  14. tools/ui/node_modules/recast/package.json +74 -0
  15. tools/ui/node_modules/recast/parsers/_babel_options.d.ts +8 -0
  16. tools/ui/node_modules/recast/parsers/_babel_options.js +57 -0
  17. tools/ui/node_modules/recast/parsers/acorn.d.ts +1 -0
  18. tools/ui/node_modules/recast/parsers/acorn.js +33 -0
  19. tools/ui/node_modules/recast/parsers/babel-ts.d.ts +4 -0
  20. tools/ui/node_modules/recast/parsers/babel-ts.js +13 -0
  21. tools/ui/node_modules/recast/parsers/babel.d.ts +8 -0
  22. tools/ui/node_modules/recast/parsers/babel.js +33 -0
  23. tools/ui/node_modules/recast/parsers/babylon.d.ts +1 -0
  24. tools/ui/node_modules/recast/parsers/babylon.js +4 -0
  25. tools/ui/node_modules/recast/parsers/esprima.d.ts +1 -0
  26. tools/ui/node_modules/recast/parsers/esprima.js +30 -0
  27. tools/ui/node_modules/recast/parsers/flow.d.ts +2 -0
  28. tools/ui/node_modules/recast/parsers/flow.js +19 -0
  29. tools/ui/node_modules/recast/parsers/typescript.d.ts +2 -0
  30. tools/ui/node_modules/recast/parsers/typescript.js +19 -0
  31. tools/ui/node_modules/recast/tsconfig.json +18 -0
  32. tools/ui/node_modules/redent/index.d.ts +27 -0
  33. tools/ui/node_modules/redent/index.js +5 -0
  34. tools/ui/node_modules/redent/license +9 -0
  35. tools/ui/node_modules/redent/package.json +44 -0
  36. tools/ui/node_modules/redent/readme.md +61 -0
  37. tools/ui/node_modules/reflect.getprototypeof/.eslintrc +17 -0
  38. tools/ui/node_modules/reflect.getprototypeof/.nycrc +9 -0
  39. tools/ui/node_modules/reflect.getprototypeof/CHANGELOG.md +115 -0
  40. tools/ui/node_modules/reflect.getprototypeof/LICENSE +21 -0
  41. tools/ui/node_modules/reflect.getprototypeof/README.md +77 -0
  42. tools/ui/node_modules/reflect.getprototypeof/auto.js +3 -0
  43. tools/ui/node_modules/reflect.getprototypeof/implementation.js +40 -0
  44. tools/ui/node_modules/reflect.getprototypeof/index.js +18 -0
  45. tools/ui/node_modules/reflect.getprototypeof/package.json +98 -0
  46. tools/ui/node_modules/reflect.getprototypeof/polyfill.js +14 -0
  47. tools/ui/node_modules/reflect.getprototypeof/shim.js +21 -0
  48. tools/ui/node_modules/reflect.getprototypeof/test/implementation.js +11 -0
  49. tools/ui/node_modules/reflect.getprototypeof/test/index.js +11 -0
  50. tools/ui/node_modules/reflect.getprototypeof/test/shimmed.js +28 -0
tools/ui/node_modules/recast/lib/mapping.js ADDED
@@ -0,0 +1,197 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var tslib_1 = require("tslib");
4
+ var tiny_invariant_1 = tslib_1.__importDefault(require("tiny-invariant"));
5
+ var util_1 = require("./util");
6
+ var Mapping = /** @class */ (function () {
7
+ function Mapping(sourceLines, sourceLoc, targetLoc) {
8
+ if (targetLoc === void 0) { targetLoc = sourceLoc; }
9
+ this.sourceLines = sourceLines;
10
+ this.sourceLoc = sourceLoc;
11
+ this.targetLoc = targetLoc;
12
+ }
13
+ Mapping.prototype.slice = function (lines, start, end) {
14
+ if (end === void 0) { end = lines.lastPos(); }
15
+ var sourceLines = this.sourceLines;
16
+ var sourceLoc = this.sourceLoc;
17
+ var targetLoc = this.targetLoc;
18
+ function skip(name) {
19
+ var sourceFromPos = sourceLoc[name];
20
+ var targetFromPos = targetLoc[name];
21
+ var targetToPos = start;
22
+ if (name === "end") {
23
+ targetToPos = end;
24
+ }
25
+ else {
26
+ (0, tiny_invariant_1.default)(name === "start");
27
+ }
28
+ return skipChars(sourceLines, sourceFromPos, lines, targetFromPos, targetToPos);
29
+ }
30
+ if ((0, util_1.comparePos)(start, targetLoc.start) <= 0) {
31
+ if ((0, util_1.comparePos)(targetLoc.end, end) <= 0) {
32
+ targetLoc = {
33
+ start: subtractPos(targetLoc.start, start.line, start.column),
34
+ end: subtractPos(targetLoc.end, start.line, start.column),
35
+ };
36
+ // The sourceLoc can stay the same because the contents of the
37
+ // targetLoc have not changed.
38
+ }
39
+ else if ((0, util_1.comparePos)(end, targetLoc.start) <= 0) {
40
+ return null;
41
+ }
42
+ else {
43
+ sourceLoc = {
44
+ start: sourceLoc.start,
45
+ end: skip("end"),
46
+ };
47
+ targetLoc = {
48
+ start: subtractPos(targetLoc.start, start.line, start.column),
49
+ end: subtractPos(end, start.line, start.column),
50
+ };
51
+ }
52
+ }
53
+ else {
54
+ if ((0, util_1.comparePos)(targetLoc.end, start) <= 0) {
55
+ return null;
56
+ }
57
+ if ((0, util_1.comparePos)(targetLoc.end, end) <= 0) {
58
+ sourceLoc = {
59
+ start: skip("start"),
60
+ end: sourceLoc.end,
61
+ };
62
+ targetLoc = {
63
+ // Same as subtractPos(start, start.line, start.column):
64
+ start: { line: 1, column: 0 },
65
+ end: subtractPos(targetLoc.end, start.line, start.column),
66
+ };
67
+ }
68
+ else {
69
+ sourceLoc = {
70
+ start: skip("start"),
71
+ end: skip("end"),
72
+ };
73
+ targetLoc = {
74
+ // Same as subtractPos(start, start.line, start.column):
75
+ start: { line: 1, column: 0 },
76
+ end: subtractPos(end, start.line, start.column),
77
+ };
78
+ }
79
+ }
80
+ return new Mapping(this.sourceLines, sourceLoc, targetLoc);
81
+ };
82
+ Mapping.prototype.add = function (line, column) {
83
+ return new Mapping(this.sourceLines, this.sourceLoc, {
84
+ start: addPos(this.targetLoc.start, line, column),
85
+ end: addPos(this.targetLoc.end, line, column),
86
+ });
87
+ };
88
+ Mapping.prototype.subtract = function (line, column) {
89
+ return new Mapping(this.sourceLines, this.sourceLoc, {
90
+ start: subtractPos(this.targetLoc.start, line, column),
91
+ end: subtractPos(this.targetLoc.end, line, column),
92
+ });
93
+ };
94
+ Mapping.prototype.indent = function (by, skipFirstLine, noNegativeColumns) {
95
+ if (skipFirstLine === void 0) { skipFirstLine = false; }
96
+ if (noNegativeColumns === void 0) { noNegativeColumns = false; }
97
+ if (by === 0) {
98
+ return this;
99
+ }
100
+ var targetLoc = this.targetLoc;
101
+ var startLine = targetLoc.start.line;
102
+ var endLine = targetLoc.end.line;
103
+ if (skipFirstLine && startLine === 1 && endLine === 1) {
104
+ return this;
105
+ }
106
+ targetLoc = {
107
+ start: targetLoc.start,
108
+ end: targetLoc.end,
109
+ };
110
+ if (!skipFirstLine || startLine > 1) {
111
+ var startColumn = targetLoc.start.column + by;
112
+ targetLoc.start = {
113
+ line: startLine,
114
+ column: noNegativeColumns ? Math.max(0, startColumn) : startColumn,
115
+ };
116
+ }
117
+ if (!skipFirstLine || endLine > 1) {
118
+ var endColumn = targetLoc.end.column + by;
119
+ targetLoc.end = {
120
+ line: endLine,
121
+ column: noNegativeColumns ? Math.max(0, endColumn) : endColumn,
122
+ };
123
+ }
124
+ return new Mapping(this.sourceLines, this.sourceLoc, targetLoc);
125
+ };
126
+ return Mapping;
127
+ }());
128
+ exports.default = Mapping;
129
+ function addPos(toPos, line, column) {
130
+ return {
131
+ line: toPos.line + line - 1,
132
+ column: toPos.line === 1 ? toPos.column + column : toPos.column,
133
+ };
134
+ }
135
+ function subtractPos(fromPos, line, column) {
136
+ return {
137
+ line: fromPos.line - line + 1,
138
+ column: fromPos.line === line ? fromPos.column - column : fromPos.column,
139
+ };
140
+ }
141
+ function skipChars(sourceLines, sourceFromPos, targetLines, targetFromPos, targetToPos) {
142
+ var targetComparison = (0, util_1.comparePos)(targetFromPos, targetToPos);
143
+ if (targetComparison === 0) {
144
+ // Trivial case: no characters to skip.
145
+ return sourceFromPos;
146
+ }
147
+ var sourceCursor, targetCursor;
148
+ if (targetComparison < 0) {
149
+ // Skipping forward.
150
+ sourceCursor =
151
+ sourceLines.skipSpaces(sourceFromPos) || sourceLines.lastPos();
152
+ targetCursor =
153
+ targetLines.skipSpaces(targetFromPos) || targetLines.lastPos();
154
+ var lineDiff = targetToPos.line - targetCursor.line;
155
+ sourceCursor.line += lineDiff;
156
+ targetCursor.line += lineDiff;
157
+ if (lineDiff > 0) {
158
+ // If jumping to later lines, reset columns to the beginnings
159
+ // of those lines.
160
+ sourceCursor.column = 0;
161
+ targetCursor.column = 0;
162
+ }
163
+ else {
164
+ (0, tiny_invariant_1.default)(lineDiff === 0);
165
+ }
166
+ while ((0, util_1.comparePos)(targetCursor, targetToPos) < 0 &&
167
+ targetLines.nextPos(targetCursor, true)) {
168
+ (0, tiny_invariant_1.default)(sourceLines.nextPos(sourceCursor, true));
169
+ (0, tiny_invariant_1.default)(sourceLines.charAt(sourceCursor) === targetLines.charAt(targetCursor));
170
+ }
171
+ }
172
+ else {
173
+ // Skipping backward.
174
+ sourceCursor =
175
+ sourceLines.skipSpaces(sourceFromPos, true) || sourceLines.firstPos();
176
+ targetCursor =
177
+ targetLines.skipSpaces(targetFromPos, true) || targetLines.firstPos();
178
+ var lineDiff = targetToPos.line - targetCursor.line;
179
+ sourceCursor.line += lineDiff;
180
+ targetCursor.line += lineDiff;
181
+ if (lineDiff < 0) {
182
+ // If jumping to earlier lines, reset columns to the ends of
183
+ // those lines.
184
+ sourceCursor.column = sourceLines.getLineLength(sourceCursor.line);
185
+ targetCursor.column = targetLines.getLineLength(targetCursor.line);
186
+ }
187
+ else {
188
+ (0, tiny_invariant_1.default)(lineDiff === 0);
189
+ }
190
+ while ((0, util_1.comparePos)(targetToPos, targetCursor) < 0 &&
191
+ targetLines.prevPos(targetCursor, true)) {
192
+ (0, tiny_invariant_1.default)(sourceLines.prevPos(sourceCursor, true));
193
+ (0, tiny_invariant_1.default)(sourceLines.charAt(sourceCursor) === targetLines.charAt(targetCursor));
194
+ }
195
+ }
196
+ return sourceCursor;
197
+ }
tools/ui/node_modules/recast/lib/options.d.ts ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * All Recast API functions take second parameter with configuration options,
3
+ * documented in options.js
4
+ */
5
+ export interface Options extends DeprecatedOptions {
6
+ /**
7
+ * If you want to use a different branch of esprima, or any other module
8
+ * that supports a .parse function, pass that module object to
9
+ * recast.parse as options.parser (legacy synonym: options.esprima).
10
+ * @default require("recast/parsers/esprima")
11
+ */
12
+ parser?: any;
13
+ /**
14
+ * Number of spaces the pretty-printer should use per tab for
15
+ * indentation. If you do not pass this option explicitly, it will be
16
+ * (quite reliably!) inferred from the original code.
17
+ * @default 4
18
+ */
19
+ tabWidth?: number;
20
+ /**
21
+ * If you really want the pretty-printer to use tabs instead of spaces,
22
+ * make this option true.
23
+ * @default false
24
+ */
25
+ useTabs?: boolean;
26
+ /**
27
+ * The reprinting code leaves leading whitespace untouched unless it has
28
+ * to reindent a line, or you pass false for this option.
29
+ * @default true
30
+ */
31
+ reuseWhitespace?: boolean;
32
+ /**
33
+ * Override this option to use a different line terminator, e.g. \r\n.
34
+ * @default require("os").EOL || "\n"
35
+ */
36
+ lineTerminator?: string;
37
+ /**
38
+ * Some of the pretty-printer code (such as that for printing function
39
+ * parameter lists) makes a valiant attempt to prevent really long
40
+ * lines. You can adjust the limit by changing this option; however,
41
+ * there is no guarantee that line length will fit inside this limit.
42
+ * @default 74
43
+ */
44
+ wrapColumn?: number;
45
+ /**
46
+ * Pass a string as options.sourceFileName to recast.parse to tell the
47
+ * reprinter to keep track of reused code so that it can construct a
48
+ * source map automatically.
49
+ * @default null
50
+ */
51
+ sourceFileName?: string | null;
52
+ /**
53
+ * Pass a string as options.sourceMapName to recast.print, and (provided
54
+ * you passed options.sourceFileName earlier) the PrintResult of
55
+ * recast.print will have a .map property for the generated source map.
56
+ * @default null
57
+ */
58
+ sourceMapName?: string | null;
59
+ /**
60
+ * If provided, this option will be passed along to the source map
61
+ * generator as a root directory for relative source file paths.
62
+ * @default null
63
+ */
64
+ sourceRoot?: string | null;
65
+ /**
66
+ * If you provide a source map that was generated from a previous call
67
+ * to recast.print as options.inputSourceMap, the old source map will be
68
+ * composed with the new source map.
69
+ * @default null
70
+ */
71
+ inputSourceMap?: string | null;
72
+ /**
73
+ * If you want esprima to generate .range information (recast only uses
74
+ * .loc internally), pass true for this option.
75
+ * @default false
76
+ */
77
+ range?: boolean;
78
+ /**
79
+ * If you want esprima not to throw exceptions when it encounters
80
+ * non-fatal errors, keep this option true.
81
+ * @default true
82
+ */
83
+ tolerant?: boolean;
84
+ /**
85
+ * If you want to override the quotes used in string literals, specify
86
+ * either "single", "double", or "auto" here ("auto" will select the one
87
+ * which results in the shorter literal) Otherwise, use double quotes.
88
+ * @default null
89
+ */
90
+ quote?: "single" | "double" | "auto" | null;
91
+ /**
92
+ * Controls the printing of trailing commas in object literals, array
93
+ * expressions and function parameters.
94
+ *
95
+ * This option could either be:
96
+ * * Boolean - enable/disable in all contexts (objects, arrays and function params).
97
+ * * Object - enable/disable per context.
98
+ *
99
+ * Example:
100
+ * trailingComma: {
101
+ * objects: true,
102
+ * arrays: true,
103
+ * parameters: false,
104
+ * }
105
+ *
106
+ * @default false
107
+ */
108
+ trailingComma?: boolean;
109
+ /**
110
+ * Controls the printing of spaces inside array brackets.
111
+ * See: http://eslint.org/docs/rules/array-bracket-spacing
112
+ * @default false
113
+ */
114
+ arrayBracketSpacing?: boolean;
115
+ /**
116
+ * Controls the printing of spaces inside object literals,
117
+ * destructuring assignments, and import/export specifiers.
118
+ * See: http://eslint.org/docs/rules/object-curly-spacing
119
+ * @default true
120
+ */
121
+ objectCurlySpacing?: boolean;
122
+ /**
123
+ * If you want parenthesis to wrap single-argument arrow function
124
+ * parameter lists, pass true for this option.
125
+ * @default false
126
+ */
127
+ arrowParensAlways?: boolean;
128
+ /**
129
+ * There are 2 supported syntaxes (`,` and `;`) in Flow Object Types;
130
+ * The use of commas is in line with the more popular style and matches
131
+ * how objects are defined in JS, making it a bit more natural to write.
132
+ * @default true
133
+ */
134
+ flowObjectCommas?: boolean;
135
+ /**
136
+ * Whether to return an array of .tokens on the root AST node.
137
+ * @default true
138
+ */
139
+ tokens?: boolean;
140
+ }
141
+ interface DeprecatedOptions {
142
+ /** @deprecated */
143
+ esprima?: any;
144
+ }
145
+ export type NormalizedOptions = Required<Omit<Options, keyof DeprecatedOptions>>;
146
+ export declare function normalize(opts?: Options): NormalizedOptions;
147
+ export {};
tools/ui/node_modules/recast/lib/options.js ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalize = void 0;
4
+ var util_1 = require("./util");
5
+ var defaults = {
6
+ parser: require("../parsers/esprima"),
7
+ tabWidth: 4,
8
+ useTabs: false,
9
+ reuseWhitespace: true,
10
+ lineTerminator: (0, util_1.getLineTerminator)(),
11
+ wrapColumn: 74,
12
+ sourceFileName: null,
13
+ sourceMapName: null,
14
+ sourceRoot: null,
15
+ inputSourceMap: null,
16
+ range: false,
17
+ tolerant: true,
18
+ quote: null,
19
+ trailingComma: false,
20
+ arrayBracketSpacing: false,
21
+ objectCurlySpacing: true,
22
+ arrowParensAlways: false,
23
+ flowObjectCommas: true,
24
+ tokens: true,
25
+ };
26
+ var hasOwn = defaults.hasOwnProperty;
27
+ // Copy options and fill in default values.
28
+ function normalize(opts) {
29
+ var options = opts || defaults;
30
+ function get(key) {
31
+ return hasOwn.call(options, key) ? options[key] : defaults[key];
32
+ }
33
+ return {
34
+ tabWidth: +get("tabWidth"),
35
+ useTabs: !!get("useTabs"),
36
+ reuseWhitespace: !!get("reuseWhitespace"),
37
+ lineTerminator: get("lineTerminator"),
38
+ wrapColumn: Math.max(get("wrapColumn"), 0),
39
+ sourceFileName: get("sourceFileName"),
40
+ sourceMapName: get("sourceMapName"),
41
+ sourceRoot: get("sourceRoot"),
42
+ inputSourceMap: get("inputSourceMap"),
43
+ parser: get("esprima") || get("parser"),
44
+ range: get("range"),
45
+ tolerant: get("tolerant"),
46
+ quote: get("quote"),
47
+ trailingComma: get("trailingComma"),
48
+ arrayBracketSpacing: get("arrayBracketSpacing"),
49
+ objectCurlySpacing: get("objectCurlySpacing"),
50
+ arrowParensAlways: get("arrowParensAlways"),
51
+ flowObjectCommas: get("flowObjectCommas"),
52
+ tokens: !!get("tokens"),
53
+ };
54
+ }
55
+ exports.normalize = normalize;
tools/ui/node_modules/recast/lib/parser.d.ts ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ import { Options } from "./options";
2
+ export declare function parse(source: string, options?: Partial<Options>): any;
tools/ui/node_modules/recast/lib/parser.js ADDED
@@ -0,0 +1,250 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parse = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var tiny_invariant_1 = tslib_1.__importDefault(require("tiny-invariant"));
6
+ var types = tslib_1.__importStar(require("ast-types"));
7
+ var b = types.builders;
8
+ var isObject = types.builtInTypes.object;
9
+ var isArray = types.builtInTypes.array;
10
+ var options_1 = require("./options");
11
+ var lines_1 = require("./lines");
12
+ var comments_1 = require("./comments");
13
+ var util = tslib_1.__importStar(require("./util"));
14
+ function parse(source, options) {
15
+ options = (0, options_1.normalize)(options);
16
+ var lines = (0, lines_1.fromString)(source, options);
17
+ var sourceWithoutTabs = lines.toString({
18
+ tabWidth: options.tabWidth,
19
+ reuseWhitespace: false,
20
+ useTabs: false,
21
+ });
22
+ var comments = [];
23
+ var ast = options.parser.parse(sourceWithoutTabs, {
24
+ jsx: true,
25
+ loc: true,
26
+ locations: true,
27
+ range: options.range,
28
+ comment: true,
29
+ onComment: comments,
30
+ tolerant: util.getOption(options, "tolerant", true),
31
+ ecmaVersion: 6,
32
+ sourceType: util.getOption(options, "sourceType", "module"),
33
+ });
34
+ // Use ast.tokens if possible, and otherwise fall back to the Esprima
35
+ // tokenizer. All the preconfigured ../parsers/* expose ast.tokens
36
+ // automatically, but custom parsers might need additional configuration
37
+ // to avoid this fallback.
38
+ var tokens = Array.isArray(ast.tokens)
39
+ ? ast.tokens
40
+ : require("esprima").tokenize(sourceWithoutTabs, {
41
+ loc: true,
42
+ });
43
+ // We will reattach the tokens array to the file object below.
44
+ delete ast.tokens;
45
+ // Make sure every token has a token.value string.
46
+ tokens.forEach(function (token) {
47
+ if (typeof token.value !== "string") {
48
+ token.value = lines.sliceString(token.loc.start, token.loc.end);
49
+ }
50
+ });
51
+ if (Array.isArray(ast.comments)) {
52
+ comments = ast.comments;
53
+ delete ast.comments;
54
+ }
55
+ if (ast.loc) {
56
+ // If the source was empty, some parsers give loc.{start,end}.line
57
+ // values of 0, instead of the minimum of 1.
58
+ util.fixFaultyLocations(ast, lines);
59
+ }
60
+ else {
61
+ ast.loc = {
62
+ start: lines.firstPos(),
63
+ end: lines.lastPos(),
64
+ };
65
+ }
66
+ ast.loc.lines = lines;
67
+ ast.loc.indent = 0;
68
+ var file;
69
+ var program;
70
+ if (ast.type === "Program") {
71
+ program = ast;
72
+ // In order to ensure we reprint leading and trailing program
73
+ // comments, wrap the original Program node with a File node. Only
74
+ // ESTree parsers (Acorn and Esprima) return a Program as the root AST
75
+ // node. Most other (Babylon-like) parsers return a File.
76
+ file = b.file(ast, options.sourceFileName || null);
77
+ file.loc = {
78
+ start: lines.firstPos(),
79
+ end: lines.lastPos(),
80
+ lines: lines,
81
+ indent: 0,
82
+ };
83
+ }
84
+ else if (ast.type === "File") {
85
+ file = ast;
86
+ program = file.program;
87
+ }
88
+ // Expose file.tokens unless the caller passed false for options.tokens.
89
+ if (options.tokens) {
90
+ file.tokens = tokens;
91
+ }
92
+ // Expand the Program's .loc to include all comments (not just those
93
+ // attached to the Program node, as its children may have comments as
94
+ // well), since sometimes program.loc.{start,end} will coincide with the
95
+ // .loc.{start,end} of the first and last *statements*, mistakenly
96
+ // excluding comments that fall outside that region.
97
+ var trueProgramLoc = util.getTrueLoc({
98
+ type: program.type,
99
+ loc: program.loc,
100
+ body: [],
101
+ comments: comments,
102
+ }, lines);
103
+ program.loc.start = trueProgramLoc.start;
104
+ program.loc.end = trueProgramLoc.end;
105
+ // Passing file.program here instead of just file means that initial
106
+ // comments will be attached to program.body[0] instead of program.
107
+ (0, comments_1.attach)(comments, program.body.length ? file.program : file, lines);
108
+ // Return a copy of the original AST so that any changes made may be
109
+ // compared to the original.
110
+ return new TreeCopier(lines, tokens).copy(file);
111
+ }
112
+ exports.parse = parse;
113
+ var TreeCopier = function TreeCopier(lines, tokens) {
114
+ (0, tiny_invariant_1.default)(this instanceof TreeCopier);
115
+ this.lines = lines;
116
+ this.tokens = tokens;
117
+ this.startTokenIndex = 0;
118
+ this.endTokenIndex = tokens.length;
119
+ this.indent = 0;
120
+ this.seen = new Map();
121
+ };
122
+ var TCp = TreeCopier.prototype;
123
+ TCp.copy = function (node) {
124
+ if (this.seen.has(node)) {
125
+ return this.seen.get(node);
126
+ }
127
+ if (isArray.check(node)) {
128
+ var copy_1 = new Array(node.length);
129
+ this.seen.set(node, copy_1);
130
+ node.forEach(function (item, i) {
131
+ copy_1[i] = this.copy(item);
132
+ }, this);
133
+ return copy_1;
134
+ }
135
+ if (!isObject.check(node)) {
136
+ return node;
137
+ }
138
+ util.fixFaultyLocations(node, this.lines);
139
+ var copy = Object.create(Object.getPrototypeOf(node), {
140
+ original: {
141
+ // Provide a link from the copy to the original.
142
+ value: node,
143
+ configurable: false,
144
+ enumerable: false,
145
+ writable: true,
146
+ },
147
+ });
148
+ this.seen.set(node, copy);
149
+ var loc = node.loc;
150
+ var oldIndent = this.indent;
151
+ var newIndent = oldIndent;
152
+ var oldStartTokenIndex = this.startTokenIndex;
153
+ var oldEndTokenIndex = this.endTokenIndex;
154
+ if (loc) {
155
+ // When node is a comment, we set node.loc.indent to
156
+ // node.loc.start.column so that, when/if we print the comment by
157
+ // itself, we can strip that much whitespace from the left margin of
158
+ // the comment. This only really matters for multiline Block comments,
159
+ // but it doesn't hurt for Line comments.
160
+ if (node.type === "Block" ||
161
+ node.type === "Line" ||
162
+ node.type === "CommentBlock" ||
163
+ node.type === "CommentLine" ||
164
+ this.lines.isPrecededOnlyByWhitespace(loc.start)) {
165
+ newIndent = this.indent = loc.start.column;
166
+ }
167
+ // Every node.loc has a reference to the original source lines as well
168
+ // as a complete list of source tokens.
169
+ loc.lines = this.lines;
170
+ loc.tokens = this.tokens;
171
+ loc.indent = newIndent;
172
+ // Set loc.start.token and loc.end.token such that
173
+ // loc.tokens.slice(loc.start.token, loc.end.token) returns a list of
174
+ // all the tokens that make up this node.
175
+ this.findTokenRange(loc);
176
+ }
177
+ var keys = Object.keys(node);
178
+ var keyCount = keys.length;
179
+ for (var i = 0; i < keyCount; ++i) {
180
+ var key = keys[i];
181
+ if (key === "loc") {
182
+ copy[key] = node[key];
183
+ }
184
+ else if (key === "tokens" && node.type === "File") {
185
+ // Preserve file.tokens (uncopied) in case client code cares about
186
+ // it, even though Recast ignores it when reprinting.
187
+ copy[key] = node[key];
188
+ }
189
+ else {
190
+ copy[key] = this.copy(node[key]);
191
+ }
192
+ }
193
+ this.indent = oldIndent;
194
+ this.startTokenIndex = oldStartTokenIndex;
195
+ this.endTokenIndex = oldEndTokenIndex;
196
+ return copy;
197
+ };
198
+ // If we didn't have any idea where in loc.tokens to look for tokens
199
+ // contained by this loc, a binary search would be appropriate, but
200
+ // because we maintain this.startTokenIndex and this.endTokenIndex as we
201
+ // traverse the AST, we only need to make small (linear) adjustments to
202
+ // those indexes with each recursive iteration.
203
+ TCp.findTokenRange = function (loc) {
204
+ // In the unlikely event that loc.tokens[this.startTokenIndex] starts
205
+ // *after* loc.start, we need to rewind this.startTokenIndex first.
206
+ while (this.startTokenIndex > 0) {
207
+ var token = loc.tokens[this.startTokenIndex];
208
+ if (util.comparePos(loc.start, token.loc.start) < 0) {
209
+ --this.startTokenIndex;
210
+ }
211
+ else
212
+ break;
213
+ }
214
+ // In the unlikely event that loc.tokens[this.endTokenIndex - 1] ends
215
+ // *before* loc.end, we need to fast-forward this.endTokenIndex first.
216
+ while (this.endTokenIndex < loc.tokens.length) {
217
+ var token = loc.tokens[this.endTokenIndex];
218
+ if (util.comparePos(token.loc.end, loc.end) < 0) {
219
+ ++this.endTokenIndex;
220
+ }
221
+ else
222
+ break;
223
+ }
224
+ // Increment this.startTokenIndex until we've found the first token
225
+ // contained by this node.
226
+ while (this.startTokenIndex < this.endTokenIndex) {
227
+ var token = loc.tokens[this.startTokenIndex];
228
+ if (util.comparePos(token.loc.start, loc.start) < 0) {
229
+ ++this.startTokenIndex;
230
+ }
231
+ else
232
+ break;
233
+ }
234
+ // Index into loc.tokens of the first token within this node.
235
+ loc.start.token = this.startTokenIndex;
236
+ // Decrement this.endTokenIndex until we've found the first token after
237
+ // this node (not contained by the node).
238
+ while (this.endTokenIndex > this.startTokenIndex) {
239
+ var token = loc.tokens[this.endTokenIndex - 1];
240
+ if (util.comparePos(loc.end, token.loc.end) < 0) {
241
+ --this.endTokenIndex;
242
+ }
243
+ else
244
+ break;
245
+ }
246
+ // Index into loc.tokens of the first token *after* this node.
247
+ // If loc.start.token === loc.end.token, the node contains no tokens,
248
+ // and the index is that of the next token following this node.
249
+ loc.end.token = this.endTokenIndex;
250
+ };
tools/ui/node_modules/recast/lib/patcher.d.ts ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ interface PatcherType {
2
+ replace(loc: any, lines: any): any;
3
+ get(loc?: any): any;
4
+ tryToReprintComments(newNode: any, oldNode: any, print: any): any;
5
+ deleteComments(node: any): any;
6
+ }
7
+ interface PatcherConstructor {
8
+ new (lines: any): PatcherType;
9
+ }
10
+ declare const Patcher: PatcherConstructor;
11
+ export { Patcher };
12
+ export declare function getReprinter(path: any): ((print: any) => any) | undefined;
tools/ui/node_modules/recast/lib/patcher.js ADDED
@@ -0,0 +1,386 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getReprinter = exports.Patcher = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var tiny_invariant_1 = tslib_1.__importDefault(require("tiny-invariant"));
6
+ var linesModule = tslib_1.__importStar(require("./lines"));
7
+ var types = tslib_1.__importStar(require("ast-types"));
8
+ var Printable = types.namedTypes.Printable;
9
+ var Expression = types.namedTypes.Expression;
10
+ var ReturnStatement = types.namedTypes.ReturnStatement;
11
+ var SourceLocation = types.namedTypes.SourceLocation;
12
+ var util_1 = require("./util");
13
+ var fast_path_1 = tslib_1.__importDefault(require("./fast-path"));
14
+ var isObject = types.builtInTypes.object;
15
+ var isArray = types.builtInTypes.array;
16
+ var isString = types.builtInTypes.string;
17
+ var riskyAdjoiningCharExp = /[0-9a-z_$]/i;
18
+ var Patcher = function Patcher(lines) {
19
+ (0, tiny_invariant_1.default)(this instanceof Patcher);
20
+ (0, tiny_invariant_1.default)(lines instanceof linesModule.Lines);
21
+ var self = this, replacements = [];
22
+ self.replace = function (loc, lines) {
23
+ if (isString.check(lines))
24
+ lines = linesModule.fromString(lines);
25
+ replacements.push({
26
+ lines: lines,
27
+ start: loc.start,
28
+ end: loc.end,
29
+ });
30
+ };
31
+ self.get = function (loc) {
32
+ // If no location is provided, return the complete Lines object.
33
+ loc = loc || {
34
+ start: { line: 1, column: 0 },
35
+ end: { line: lines.length, column: lines.getLineLength(lines.length) },
36
+ };
37
+ var sliceFrom = loc.start, toConcat = [];
38
+ function pushSlice(from, to) {
39
+ (0, tiny_invariant_1.default)((0, util_1.comparePos)(from, to) <= 0);
40
+ toConcat.push(lines.slice(from, to));
41
+ }
42
+ replacements
43
+ .sort(function (a, b) { return (0, util_1.comparePos)(a.start, b.start); })
44
+ .forEach(function (rep) {
45
+ if ((0, util_1.comparePos)(sliceFrom, rep.start) > 0) {
46
+ // Ignore nested replacement ranges.
47
+ }
48
+ else {
49
+ pushSlice(sliceFrom, rep.start);
50
+ toConcat.push(rep.lines);
51
+ sliceFrom = rep.end;
52
+ }
53
+ });
54
+ pushSlice(sliceFrom, loc.end);
55
+ return linesModule.concat(toConcat);
56
+ };
57
+ };
58
+ exports.Patcher = Patcher;
59
+ var Pp = Patcher.prototype;
60
+ Pp.tryToReprintComments = function (newNode, oldNode, print) {
61
+ var patcher = this;
62
+ if (!newNode.comments && !oldNode.comments) {
63
+ // We were (vacuously) able to reprint all the comments!
64
+ return true;
65
+ }
66
+ var newPath = fast_path_1.default.from(newNode);
67
+ var oldPath = fast_path_1.default.from(oldNode);
68
+ newPath.stack.push("comments", getSurroundingComments(newNode));
69
+ oldPath.stack.push("comments", getSurroundingComments(oldNode));
70
+ var reprints = [];
71
+ var ableToReprintComments = findArrayReprints(newPath, oldPath, reprints);
72
+ // No need to pop anything from newPath.stack or oldPath.stack, since
73
+ // newPath and oldPath are fresh local variables.
74
+ if (ableToReprintComments && reprints.length > 0) {
75
+ reprints.forEach(function (reprint) {
76
+ var oldComment = reprint.oldPath.getValue();
77
+ (0, tiny_invariant_1.default)(oldComment.leading || oldComment.trailing);
78
+ patcher.replace(oldComment.loc,
79
+ // Comments can't have .comments, so it doesn't matter whether we
80
+ // print with comments or without.
81
+ print(reprint.newPath).indentTail(oldComment.loc.indent));
82
+ });
83
+ }
84
+ return ableToReprintComments;
85
+ };
86
+ // Get all comments that are either leading or trailing, ignoring any
87
+ // comments that occur inside node.loc. Returns an empty array for nodes
88
+ // with no leading or trailing comments.
89
+ function getSurroundingComments(node) {
90
+ var result = [];
91
+ if (node.comments && node.comments.length > 0) {
92
+ node.comments.forEach(function (comment) {
93
+ if (comment.leading || comment.trailing) {
94
+ result.push(comment);
95
+ }
96
+ });
97
+ }
98
+ return result;
99
+ }
100
+ Pp.deleteComments = function (node) {
101
+ if (!node.comments) {
102
+ return;
103
+ }
104
+ var patcher = this;
105
+ node.comments.forEach(function (comment) {
106
+ if (comment.leading) {
107
+ // Delete leading comments along with any trailing whitespace they
108
+ // might have.
109
+ patcher.replace({
110
+ start: comment.loc.start,
111
+ end: node.loc.lines.skipSpaces(comment.loc.end, false, false),
112
+ }, "");
113
+ }
114
+ else if (comment.trailing) {
115
+ // Delete trailing comments along with any leading whitespace they
116
+ // might have.
117
+ patcher.replace({
118
+ start: node.loc.lines.skipSpaces(comment.loc.start, true, false),
119
+ end: comment.loc.end,
120
+ }, "");
121
+ }
122
+ });
123
+ };
124
+ function getReprinter(path) {
125
+ (0, tiny_invariant_1.default)(path instanceof fast_path_1.default);
126
+ // Make sure that this path refers specifically to a Node, rather than
127
+ // some non-Node subproperty of a Node.
128
+ var node = path.getValue();
129
+ if (!Printable.check(node))
130
+ return;
131
+ var orig = node.original;
132
+ var origLoc = orig && orig.loc;
133
+ var lines = origLoc && origLoc.lines;
134
+ var reprints = [];
135
+ if (!lines || !findReprints(path, reprints))
136
+ return;
137
+ return function (print) {
138
+ var patcher = new Patcher(lines);
139
+ reprints.forEach(function (reprint) {
140
+ var newNode = reprint.newPath.getValue();
141
+ var oldNode = reprint.oldPath.getValue();
142
+ SourceLocation.assert(oldNode.loc, true);
143
+ var needToPrintNewPathWithComments = !patcher.tryToReprintComments(newNode, oldNode, print);
144
+ if (needToPrintNewPathWithComments) {
145
+ // Since we were not able to preserve all leading/trailing
146
+ // comments, we delete oldNode's comments, print newPath with
147
+ // comments, and then patch the resulting lines where oldNode used
148
+ // to be.
149
+ patcher.deleteComments(oldNode);
150
+ }
151
+ var newLines = print(reprint.newPath, {
152
+ includeComments: needToPrintNewPathWithComments,
153
+ // If the oldNode we're replacing already had parentheses, we may
154
+ // not need to print the new node with any extra parentheses,
155
+ // because the existing parentheses will suffice. However, if the
156
+ // newNode has a different type than the oldNode, let the printer
157
+ // decide if reprint.newPath needs parentheses, as usual.
158
+ avoidRootParens: oldNode.type === newNode.type && reprint.oldPath.hasParens(),
159
+ }).indentTail(oldNode.loc.indent);
160
+ var nls = needsLeadingSpace(lines, oldNode.loc, newLines);
161
+ var nts = needsTrailingSpace(lines, oldNode.loc, newLines);
162
+ // If we try to replace the argument of a ReturnStatement like
163
+ // return"asdf" with e.g. a literal null expression, we run the risk
164
+ // of ending up with returnnull, so we need to add an extra leading
165
+ // space in situations where that might happen. Likewise for
166
+ // "asdf"in obj. See #170.
167
+ if (nls || nts) {
168
+ var newParts = [];
169
+ nls && newParts.push(" ");
170
+ newParts.push(newLines);
171
+ nts && newParts.push(" ");
172
+ newLines = linesModule.concat(newParts);
173
+ }
174
+ patcher.replace(oldNode.loc, newLines);
175
+ });
176
+ // Recall that origLoc is the .loc of an ancestor node that is
177
+ // guaranteed to contain all the reprinted nodes and comments.
178
+ var patchedLines = patcher.get(origLoc).indentTail(-orig.loc.indent);
179
+ if (path.needsParens()) {
180
+ return linesModule.concat(["(", patchedLines, ")"]);
181
+ }
182
+ return patchedLines;
183
+ };
184
+ }
185
+ exports.getReprinter = getReprinter;
186
+ // If the last character before oldLoc and the first character of newLines
187
+ // are both identifier characters, they must be separated by a space,
188
+ // otherwise they will most likely get fused together into a single token.
189
+ function needsLeadingSpace(oldLines, oldLoc, newLines) {
190
+ var posBeforeOldLoc = (0, util_1.copyPos)(oldLoc.start);
191
+ // The character just before the location occupied by oldNode.
192
+ var charBeforeOldLoc = oldLines.prevPos(posBeforeOldLoc) && oldLines.charAt(posBeforeOldLoc);
193
+ // First character of the reprinted node.
194
+ var newFirstChar = newLines.charAt(newLines.firstPos());
195
+ return (charBeforeOldLoc &&
196
+ riskyAdjoiningCharExp.test(charBeforeOldLoc) &&
197
+ newFirstChar &&
198
+ riskyAdjoiningCharExp.test(newFirstChar));
199
+ }
200
+ // If the last character of newLines and the first character after oldLoc
201
+ // are both identifier characters, they must be separated by a space,
202
+ // otherwise they will most likely get fused together into a single token.
203
+ function needsTrailingSpace(oldLines, oldLoc, newLines) {
204
+ // The character just after the location occupied by oldNode.
205
+ var charAfterOldLoc = oldLines.charAt(oldLoc.end);
206
+ var newLastPos = newLines.lastPos();
207
+ // Last character of the reprinted node.
208
+ var newLastChar = newLines.prevPos(newLastPos) && newLines.charAt(newLastPos);
209
+ return (newLastChar &&
210
+ riskyAdjoiningCharExp.test(newLastChar) &&
211
+ charAfterOldLoc &&
212
+ riskyAdjoiningCharExp.test(charAfterOldLoc));
213
+ }
214
+ function findReprints(newPath, reprints) {
215
+ var newNode = newPath.getValue();
216
+ Printable.assert(newNode);
217
+ var oldNode = newNode.original;
218
+ Printable.assert(oldNode);
219
+ (0, tiny_invariant_1.default)(reprints.length === 0);
220
+ if (newNode.type !== oldNode.type) {
221
+ return false;
222
+ }
223
+ var oldPath = new fast_path_1.default(oldNode);
224
+ var canReprint = findChildReprints(newPath, oldPath, reprints);
225
+ if (!canReprint) {
226
+ // Make absolutely sure the calling code does not attempt to reprint
227
+ // any nodes.
228
+ reprints.length = 0;
229
+ }
230
+ return canReprint;
231
+ }
232
+ function findAnyReprints(newPath, oldPath, reprints) {
233
+ var newNode = newPath.getValue();
234
+ var oldNode = oldPath.getValue();
235
+ if (newNode === oldNode)
236
+ return true;
237
+ if (isArray.check(newNode))
238
+ return findArrayReprints(newPath, oldPath, reprints);
239
+ if (isObject.check(newNode))
240
+ return findObjectReprints(newPath, oldPath, reprints);
241
+ return false;
242
+ }
243
+ function findArrayReprints(newPath, oldPath, reprints) {
244
+ var newNode = newPath.getValue();
245
+ var oldNode = oldPath.getValue();
246
+ if (newNode === oldNode ||
247
+ newPath.valueIsDuplicate() ||
248
+ oldPath.valueIsDuplicate()) {
249
+ return true;
250
+ }
251
+ isArray.assert(newNode);
252
+ var len = newNode.length;
253
+ if (!(isArray.check(oldNode) && oldNode.length === len))
254
+ return false;
255
+ for (var i = 0; i < len; ++i) {
256
+ newPath.stack.push(i, newNode[i]);
257
+ oldPath.stack.push(i, oldNode[i]);
258
+ var canReprint = findAnyReprints(newPath, oldPath, reprints);
259
+ newPath.stack.length -= 2;
260
+ oldPath.stack.length -= 2;
261
+ if (!canReprint) {
262
+ return false;
263
+ }
264
+ }
265
+ return true;
266
+ }
267
+ function findObjectReprints(newPath, oldPath, reprints) {
268
+ var newNode = newPath.getValue();
269
+ isObject.assert(newNode);
270
+ if (newNode.original === null) {
271
+ // If newNode.original node was set to null, reprint the node.
272
+ return false;
273
+ }
274
+ var oldNode = oldPath.getValue();
275
+ if (!isObject.check(oldNode))
276
+ return false;
277
+ if (newNode === oldNode ||
278
+ newPath.valueIsDuplicate() ||
279
+ oldPath.valueIsDuplicate()) {
280
+ return true;
281
+ }
282
+ if (Printable.check(newNode)) {
283
+ if (!Printable.check(oldNode)) {
284
+ return false;
285
+ }
286
+ var newParentNode = newPath.getParentNode();
287
+ var oldParentNode = oldPath.getParentNode();
288
+ if (oldParentNode !== null &&
289
+ oldParentNode.type === "FunctionTypeAnnotation" &&
290
+ newParentNode !== null &&
291
+ newParentNode.type === "FunctionTypeAnnotation") {
292
+ var oldNeedsParens = oldParentNode.params.length !== 1 || !!oldParentNode.params[0].name;
293
+ var newNeedParens = newParentNode.params.length !== 1 || !!newParentNode.params[0].name;
294
+ if (!oldNeedsParens && newNeedParens) {
295
+ return false;
296
+ }
297
+ }
298
+ // Here we need to decide whether the reprinted code for newNode is
299
+ // appropriate for patching into the location of oldNode.
300
+ if (newNode.type === oldNode.type) {
301
+ var childReprints = [];
302
+ if (findChildReprints(newPath, oldPath, childReprints)) {
303
+ reprints.push.apply(reprints, childReprints);
304
+ }
305
+ else if (oldNode.loc) {
306
+ // If we have no .loc information for oldNode, then we won't be
307
+ // able to reprint it.
308
+ reprints.push({
309
+ oldPath: oldPath.copy(),
310
+ newPath: newPath.copy(),
311
+ });
312
+ }
313
+ else {
314
+ return false;
315
+ }
316
+ return true;
317
+ }
318
+ if (Expression.check(newNode) &&
319
+ Expression.check(oldNode) &&
320
+ // If we have no .loc information for oldNode, then we won't be
321
+ // able to reprint it.
322
+ oldNode.loc) {
323
+ // If both nodes are subtypes of Expression, then we should be able
324
+ // to fill the location occupied by the old node with code printed
325
+ // for the new node with no ill consequences.
326
+ reprints.push({
327
+ oldPath: oldPath.copy(),
328
+ newPath: newPath.copy(),
329
+ });
330
+ return true;
331
+ }
332
+ // The nodes have different types, and at least one of the types is
333
+ // not a subtype of the Expression type, so we cannot safely assume
334
+ // the nodes are syntactically interchangeable.
335
+ return false;
336
+ }
337
+ return findChildReprints(newPath, oldPath, reprints);
338
+ }
339
+ function findChildReprints(newPath, oldPath, reprints) {
340
+ var newNode = newPath.getValue();
341
+ var oldNode = oldPath.getValue();
342
+ isObject.assert(newNode);
343
+ isObject.assert(oldNode);
344
+ if (newNode.original === null) {
345
+ // If newNode.original node was set to null, reprint the node.
346
+ return false;
347
+ }
348
+ // If this node needs parentheses and will not be wrapped with
349
+ // parentheses when reprinted, then return false to skip reprinting and
350
+ // let it be printed generically.
351
+ if (newPath.needsParens() && !oldPath.hasParens()) {
352
+ return false;
353
+ }
354
+ var keys = (0, util_1.getUnionOfKeys)(oldNode, newNode);
355
+ if (oldNode.type === "File" || newNode.type === "File") {
356
+ // Don't bother traversing file.tokens, an often very large array
357
+ // returned by Babylon, and useless for our purposes.
358
+ delete keys.tokens;
359
+ }
360
+ // Don't bother traversing .loc objects looking for reprintable nodes.
361
+ delete keys.loc;
362
+ var originalReprintCount = reprints.length;
363
+ for (var k in keys) {
364
+ if (k.charAt(0) === "_") {
365
+ // Ignore "private" AST properties added by e.g. Babel plugins and
366
+ // parsers like Babylon.
367
+ continue;
368
+ }
369
+ newPath.stack.push(k, types.getFieldValue(newNode, k));
370
+ oldPath.stack.push(k, types.getFieldValue(oldNode, k));
371
+ var canReprint = findAnyReprints(newPath, oldPath, reprints);
372
+ newPath.stack.length -= 2;
373
+ oldPath.stack.length -= 2;
374
+ if (!canReprint) {
375
+ return false;
376
+ }
377
+ }
378
+ // Return statements might end up running into ASI issues due to
379
+ // comments inserted deep within the tree, so reprint them if anything
380
+ // changed within them.
381
+ if (ReturnStatement.check(newPath.getNode()) &&
382
+ reprints.length > originalReprintCount) {
383
+ return false;
384
+ }
385
+ return true;
386
+ }
tools/ui/node_modules/recast/lib/printer.d.ts ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export interface PrintResultType {
2
+ code: string;
3
+ map?: any;
4
+ toString(): string;
5
+ }
6
+ interface PrinterType {
7
+ print(ast: any): PrintResultType;
8
+ printGenerically(ast: any): PrintResultType;
9
+ }
10
+ interface PrinterConstructor {
11
+ new (config?: any): PrinterType;
12
+ }
13
+ declare const Printer: PrinterConstructor;
14
+ export { Printer };
tools/ui/node_modules/recast/lib/printer.js ADDED
The diff for this file is too large to render. See raw diff
 
tools/ui/node_modules/recast/lib/util.d.ts ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export declare function getLineTerminator(): any;
2
+ export declare function isBrowser(): boolean;
3
+ export declare function getOption(options: any, key: any, defaultValue: any): any;
4
+ export declare function getUnionOfKeys(...args: any[]): any;
5
+ export declare function comparePos(pos1: any, pos2: any): number;
6
+ export declare function copyPos(pos: any): {
7
+ line: any;
8
+ column: any;
9
+ };
10
+ export declare function composeSourceMaps(formerMap: any, latterMap: any): any;
11
+ export declare function getTrueLoc(node: any, lines: any): {
12
+ start: any;
13
+ end: any;
14
+ } | null;
15
+ export declare function fixFaultyLocations(node: any, lines: any): void;
16
+ export declare function isExportDeclaration(node: any): boolean;
17
+ export declare function getParentExportDeclaration(path: any): any;
18
+ export declare function isTrailingCommaEnabled(options: any, context: any): boolean;
tools/ui/node_modules/recast/lib/util.js ADDED
@@ -0,0 +1,331 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isTrailingCommaEnabled = exports.getParentExportDeclaration = exports.isExportDeclaration = exports.fixFaultyLocations = exports.getTrueLoc = exports.composeSourceMaps = exports.copyPos = exports.comparePos = exports.getUnionOfKeys = exports.getOption = exports.isBrowser = exports.getLineTerminator = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var tiny_invariant_1 = tslib_1.__importDefault(require("tiny-invariant"));
6
+ var types = tslib_1.__importStar(require("ast-types"));
7
+ var n = types.namedTypes;
8
+ var source_map_1 = tslib_1.__importDefault(require("source-map"));
9
+ var SourceMapConsumer = source_map_1.default.SourceMapConsumer;
10
+ var SourceMapGenerator = source_map_1.default.SourceMapGenerator;
11
+ var hasOwn = Object.prototype.hasOwnProperty;
12
+ function getLineTerminator() {
13
+ return isBrowser() ? "\n" : require("os").EOL || "\n";
14
+ }
15
+ exports.getLineTerminator = getLineTerminator;
16
+ function isBrowser() {
17
+ return (typeof window !== "undefined" && typeof window.document !== "undefined");
18
+ }
19
+ exports.isBrowser = isBrowser;
20
+ function getOption(options, key, defaultValue) {
21
+ if (options && hasOwn.call(options, key)) {
22
+ return options[key];
23
+ }
24
+ return defaultValue;
25
+ }
26
+ exports.getOption = getOption;
27
+ function getUnionOfKeys() {
28
+ var args = [];
29
+ for (var _i = 0; _i < arguments.length; _i++) {
30
+ args[_i] = arguments[_i];
31
+ }
32
+ var result = {};
33
+ var argc = args.length;
34
+ for (var i = 0; i < argc; ++i) {
35
+ var keys = Object.keys(args[i]);
36
+ var keyCount = keys.length;
37
+ for (var j = 0; j < keyCount; ++j) {
38
+ result[keys[j]] = true;
39
+ }
40
+ }
41
+ return result;
42
+ }
43
+ exports.getUnionOfKeys = getUnionOfKeys;
44
+ function comparePos(pos1, pos2) {
45
+ return pos1.line - pos2.line || pos1.column - pos2.column;
46
+ }
47
+ exports.comparePos = comparePos;
48
+ function copyPos(pos) {
49
+ return {
50
+ line: pos.line,
51
+ column: pos.column,
52
+ };
53
+ }
54
+ exports.copyPos = copyPos;
55
+ function composeSourceMaps(formerMap, latterMap) {
56
+ if (formerMap) {
57
+ if (!latterMap) {
58
+ return formerMap;
59
+ }
60
+ }
61
+ else {
62
+ return latterMap || null;
63
+ }
64
+ var smcFormer = new SourceMapConsumer(formerMap);
65
+ var smcLatter = new SourceMapConsumer(latterMap);
66
+ var smg = new SourceMapGenerator({
67
+ file: latterMap.file,
68
+ sourceRoot: latterMap.sourceRoot,
69
+ });
70
+ var sourcesToContents = {};
71
+ smcLatter.eachMapping(function (mapping) {
72
+ var origPos = smcFormer.originalPositionFor({
73
+ line: mapping.originalLine,
74
+ column: mapping.originalColumn,
75
+ });
76
+ var sourceName = origPos.source;
77
+ if (sourceName === null) {
78
+ return;
79
+ }
80
+ smg.addMapping({
81
+ source: sourceName,
82
+ original: copyPos(origPos),
83
+ generated: {
84
+ line: mapping.generatedLine,
85
+ column: mapping.generatedColumn,
86
+ },
87
+ name: mapping.name,
88
+ });
89
+ var sourceContent = smcFormer.sourceContentFor(sourceName);
90
+ if (sourceContent && !hasOwn.call(sourcesToContents, sourceName)) {
91
+ sourcesToContents[sourceName] = sourceContent;
92
+ smg.setSourceContent(sourceName, sourceContent);
93
+ }
94
+ });
95
+ return smg.toJSON();
96
+ }
97
+ exports.composeSourceMaps = composeSourceMaps;
98
+ function getTrueLoc(node, lines) {
99
+ // It's possible that node is newly-created (not parsed by Esprima),
100
+ // in which case it probably won't have a .loc property (or an
101
+ // .original property for that matter). That's fine; we'll just
102
+ // pretty-print it as usual.
103
+ if (!node.loc) {
104
+ return null;
105
+ }
106
+ var result = {
107
+ start: node.loc.start,
108
+ end: node.loc.end,
109
+ };
110
+ function include(node) {
111
+ expandLoc(result, node.loc);
112
+ }
113
+ // If the node is an export declaration and its .declaration has any
114
+ // decorators, their locations might contribute to the true start/end
115
+ // positions of the export declaration node.
116
+ if (node.declaration &&
117
+ node.declaration.decorators &&
118
+ isExportDeclaration(node)) {
119
+ node.declaration.decorators.forEach(include);
120
+ }
121
+ if (comparePos(result.start, result.end) < 0) {
122
+ // Trim leading whitespace.
123
+ result.start = copyPos(result.start);
124
+ lines.skipSpaces(result.start, false, true);
125
+ if (comparePos(result.start, result.end) < 0) {
126
+ // Trim trailing whitespace, if the end location is not already the
127
+ // same as the start location.
128
+ result.end = copyPos(result.end);
129
+ lines.skipSpaces(result.end, true, true);
130
+ }
131
+ }
132
+ // If the node has any comments, their locations might contribute to
133
+ // the true start/end positions of the node.
134
+ if (node.comments) {
135
+ node.comments.forEach(include);
136
+ }
137
+ return result;
138
+ }
139
+ exports.getTrueLoc = getTrueLoc;
140
+ function expandLoc(parentLoc, childLoc) {
141
+ if (parentLoc && childLoc) {
142
+ if (comparePos(childLoc.start, parentLoc.start) < 0) {
143
+ parentLoc.start = childLoc.start;
144
+ }
145
+ if (comparePos(parentLoc.end, childLoc.end) < 0) {
146
+ parentLoc.end = childLoc.end;
147
+ }
148
+ }
149
+ }
150
+ function fixFaultyLocations(node, lines) {
151
+ var loc = node.loc;
152
+ if (loc) {
153
+ if (loc.start.line < 1) {
154
+ loc.start.line = 1;
155
+ }
156
+ if (loc.end.line < 1) {
157
+ loc.end.line = 1;
158
+ }
159
+ }
160
+ if (node.type === "File") {
161
+ // Babylon returns File nodes whose .loc.{start,end} do not include
162
+ // leading or trailing whitespace.
163
+ loc.start = lines.firstPos();
164
+ loc.end = lines.lastPos();
165
+ }
166
+ fixForLoopHead(node, lines);
167
+ fixTemplateLiteral(node, lines);
168
+ if (loc && node.decorators) {
169
+ // Expand the .loc of the node responsible for printing the decorators
170
+ // (here, the decorated node) so that it includes node.decorators.
171
+ node.decorators.forEach(function (decorator) {
172
+ expandLoc(loc, decorator.loc);
173
+ });
174
+ }
175
+ else if (node.declaration && isExportDeclaration(node)) {
176
+ // Nullify .loc information for the child declaration so that we never
177
+ // try to reprint it without also reprinting the export declaration.
178
+ node.declaration.loc = null;
179
+ // Expand the .loc of the node responsible for printing the decorators
180
+ // (here, the export declaration) so that it includes node.decorators.
181
+ var decorators = node.declaration.decorators;
182
+ if (decorators) {
183
+ decorators.forEach(function (decorator) {
184
+ expandLoc(loc, decorator.loc);
185
+ });
186
+ }
187
+ }
188
+ else if ((n.MethodDefinition && n.MethodDefinition.check(node)) ||
189
+ (n.Property.check(node) && (node.method || node.shorthand))) {
190
+ // If the node is a MethodDefinition or a .method or .shorthand
191
+ // Property, then the location information stored in
192
+ // node.value.loc is very likely untrustworthy (just the {body}
193
+ // part of a method, or nothing in the case of shorthand
194
+ // properties), so we null out that information to prevent
195
+ // accidental reuse of bogus source code during reprinting.
196
+ node.value.loc = null;
197
+ if (n.FunctionExpression.check(node.value)) {
198
+ // FunctionExpression method values should be anonymous,
199
+ // because their .id fields are ignored anyway.
200
+ node.value.id = null;
201
+ }
202
+ }
203
+ else if (node.type === "ObjectTypeProperty") {
204
+ var loc_1 = node.loc;
205
+ var end = loc_1 && loc_1.end;
206
+ if (end) {
207
+ end = copyPos(end);
208
+ if (lines.prevPos(end) && lines.charAt(end) === ",") {
209
+ // Some parsers accidentally include trailing commas in the
210
+ // .loc.end information for ObjectTypeProperty nodes.
211
+ if ((end = lines.skipSpaces(end, true, true))) {
212
+ loc_1.end = end;
213
+ }
214
+ }
215
+ }
216
+ }
217
+ }
218
+ exports.fixFaultyLocations = fixFaultyLocations;
219
+ function fixForLoopHead(node, lines) {
220
+ if (node.type !== "ForStatement") {
221
+ return;
222
+ }
223
+ function fix(child) {
224
+ var loc = child && child.loc;
225
+ var start = loc && loc.start;
226
+ var end = loc && copyPos(loc.end);
227
+ while (start && end && comparePos(start, end) < 0) {
228
+ lines.prevPos(end);
229
+ if (lines.charAt(end) === ";") {
230
+ // Update child.loc.end to *exclude* the ';' character.
231
+ loc.end.line = end.line;
232
+ loc.end.column = end.column;
233
+ }
234
+ else {
235
+ break;
236
+ }
237
+ }
238
+ }
239
+ fix(node.init);
240
+ fix(node.test);
241
+ fix(node.update);
242
+ }
243
+ function fixTemplateLiteral(node, lines) {
244
+ if (node.type !== "TemplateLiteral") {
245
+ return;
246
+ }
247
+ if (node.quasis.length === 0) {
248
+ // If there are no quasi elements, then there is nothing to fix.
249
+ return;
250
+ }
251
+ // node.loc is not present when using export default with a template literal
252
+ if (node.loc) {
253
+ // First we need to exclude the opening ` from the .loc of the first
254
+ // quasi element, in case the parser accidentally decided to include it.
255
+ var afterLeftBackTickPos = copyPos(node.loc.start);
256
+ (0, tiny_invariant_1.default)(lines.charAt(afterLeftBackTickPos) === "`");
257
+ (0, tiny_invariant_1.default)(lines.nextPos(afterLeftBackTickPos));
258
+ var firstQuasi = node.quasis[0];
259
+ if (comparePos(firstQuasi.loc.start, afterLeftBackTickPos) < 0) {
260
+ firstQuasi.loc.start = afterLeftBackTickPos;
261
+ }
262
+ // Next we need to exclude the closing ` from the .loc of the last quasi
263
+ // element, in case the parser accidentally decided to include it.
264
+ var rightBackTickPos = copyPos(node.loc.end);
265
+ (0, tiny_invariant_1.default)(lines.prevPos(rightBackTickPos));
266
+ (0, tiny_invariant_1.default)(lines.charAt(rightBackTickPos) === "`");
267
+ var lastQuasi = node.quasis[node.quasis.length - 1];
268
+ if (comparePos(rightBackTickPos, lastQuasi.loc.end) < 0) {
269
+ lastQuasi.loc.end = rightBackTickPos;
270
+ }
271
+ }
272
+ // Now we need to exclude ${ and } characters from the .loc's of all
273
+ // quasi elements, since some parsers accidentally include them.
274
+ node.expressions.forEach(function (expr, i) {
275
+ // Rewind from expr.loc.start over any whitespace and the ${ that
276
+ // precedes the expression. The position of the $ should be the same
277
+ // as the .loc.end of the preceding quasi element, but some parsers
278
+ // accidentally include the ${ in the .loc of the quasi element.
279
+ var dollarCurlyPos = lines.skipSpaces(expr.loc.start, true, false);
280
+ if (lines.prevPos(dollarCurlyPos) &&
281
+ lines.charAt(dollarCurlyPos) === "{" &&
282
+ lines.prevPos(dollarCurlyPos) &&
283
+ lines.charAt(dollarCurlyPos) === "$") {
284
+ var quasiBefore = node.quasis[i];
285
+ if (comparePos(dollarCurlyPos, quasiBefore.loc.end) < 0) {
286
+ quasiBefore.loc.end = dollarCurlyPos;
287
+ }
288
+ }
289
+ // Likewise, some parsers accidentally include the } that follows
290
+ // the expression in the .loc of the following quasi element.
291
+ var rightCurlyPos = lines.skipSpaces(expr.loc.end, false, false);
292
+ if (lines.charAt(rightCurlyPos) === "}") {
293
+ (0, tiny_invariant_1.default)(lines.nextPos(rightCurlyPos));
294
+ // Now rightCurlyPos is technically the position just after the }.
295
+ var quasiAfter = node.quasis[i + 1];
296
+ if (comparePos(quasiAfter.loc.start, rightCurlyPos) < 0) {
297
+ quasiAfter.loc.start = rightCurlyPos;
298
+ }
299
+ }
300
+ });
301
+ }
302
+ function isExportDeclaration(node) {
303
+ if (node)
304
+ switch (node.type) {
305
+ case "ExportDeclaration":
306
+ case "ExportDefaultDeclaration":
307
+ case "ExportDefaultSpecifier":
308
+ case "DeclareExportDeclaration":
309
+ case "ExportNamedDeclaration":
310
+ case "ExportAllDeclaration":
311
+ return true;
312
+ }
313
+ return false;
314
+ }
315
+ exports.isExportDeclaration = isExportDeclaration;
316
+ function getParentExportDeclaration(path) {
317
+ var parentNode = path.getParentNode();
318
+ if (path.getName() === "declaration" && isExportDeclaration(parentNode)) {
319
+ return parentNode;
320
+ }
321
+ return null;
322
+ }
323
+ exports.getParentExportDeclaration = getParentExportDeclaration;
324
+ function isTrailingCommaEnabled(options, context) {
325
+ var trailingComma = options.trailingComma;
326
+ if (typeof trailingComma === "object") {
327
+ return !!trailingComma[context];
328
+ }
329
+ return !!trailingComma;
330
+ }
331
+ exports.isTrailingCommaEnabled = isTrailingCommaEnabled;
tools/ui/node_modules/recast/main.d.ts ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as types from "ast-types";
2
+ import { parse } from "./lib/parser";
3
+ import { Options } from "./lib/options";
4
+ export {
5
+ /**
6
+ * Parse a string of code into an augmented syntax tree suitable for
7
+ * arbitrary modification and reprinting.
8
+ */
9
+ parse,
10
+ /**
11
+ * Convenient shorthand for the ast-types package.
12
+ */
13
+ types, };
14
+ /**
15
+ * Traverse and potentially modify an abstract syntax tree using a
16
+ * convenient visitor syntax:
17
+ *
18
+ * recast.visit(ast, {
19
+ * names: [],
20
+ * visitIdentifier: function(path) {
21
+ * var node = path.value;
22
+ * this.visitor.names.push(node.name);
23
+ * this.traverse(path);
24
+ * }
25
+ * });
26
+ */
27
+ export { visit } from "ast-types";
28
+ /**
29
+ * Options shared between parsing and printing.
30
+ */
31
+ export { Options } from "./lib/options";
32
+ /**
33
+ * Reprint a modified syntax tree using as much of the original source
34
+ * code as possible.
35
+ */
36
+ export declare function print(node: types.ASTNode, options?: Options): import("./lib/printer").PrintResultType;
37
+ /**
38
+ * Print without attempting to reuse any original source code.
39
+ */
40
+ export declare function prettyPrint(node: types.ASTNode, options?: Options): import("./lib/printer").PrintResultType;
41
+ /**
42
+ * Convenient command-line interface (see e.g. example/add-braces).
43
+ */
44
+ export declare function run(transformer: Transformer, options?: RunOptions): void;
45
+ export interface Transformer {
46
+ (ast: types.ASTNode, callback: (ast: types.ASTNode) => void): void;
47
+ }
48
+ export interface RunOptions extends Options {
49
+ writeback?(code: string): void;
50
+ }
tools/ui/node_modules/recast/main.js ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.run = exports.prettyPrint = exports.print = exports.visit = exports.types = exports.parse = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var fs_1 = tslib_1.__importDefault(require("fs"));
6
+ var types = tslib_1.__importStar(require("ast-types"));
7
+ exports.types = types;
8
+ var parser_1 = require("./lib/parser");
9
+ Object.defineProperty(exports, "parse", { enumerable: true, get: function () { return parser_1.parse; } });
10
+ var printer_1 = require("./lib/printer");
11
+ /**
12
+ * Traverse and potentially modify an abstract syntax tree using a
13
+ * convenient visitor syntax:
14
+ *
15
+ * recast.visit(ast, {
16
+ * names: [],
17
+ * visitIdentifier: function(path) {
18
+ * var node = path.value;
19
+ * this.visitor.names.push(node.name);
20
+ * this.traverse(path);
21
+ * }
22
+ * });
23
+ */
24
+ var ast_types_1 = require("ast-types");
25
+ Object.defineProperty(exports, "visit", { enumerable: true, get: function () { return ast_types_1.visit; } });
26
+ /**
27
+ * Reprint a modified syntax tree using as much of the original source
28
+ * code as possible.
29
+ */
30
+ function print(node, options) {
31
+ return new printer_1.Printer(options).print(node);
32
+ }
33
+ exports.print = print;
34
+ /**
35
+ * Print without attempting to reuse any original source code.
36
+ */
37
+ function prettyPrint(node, options) {
38
+ return new printer_1.Printer(options).printGenerically(node);
39
+ }
40
+ exports.prettyPrint = prettyPrint;
41
+ /**
42
+ * Convenient command-line interface (see e.g. example/add-braces).
43
+ */
44
+ function run(transformer, options) {
45
+ return runFile(process.argv[2], transformer, options);
46
+ }
47
+ exports.run = run;
48
+ function runFile(path, transformer, options) {
49
+ fs_1.default.readFile(path, "utf-8", function (err, code) {
50
+ if (err) {
51
+ console.error(err);
52
+ return;
53
+ }
54
+ runString(code, transformer, options);
55
+ });
56
+ }
57
+ function defaultWriteback(output) {
58
+ process.stdout.write(output);
59
+ }
60
+ function runString(code, transformer, options) {
61
+ var writeback = (options && options.writeback) || defaultWriteback;
62
+ transformer((0, parser_1.parse)(code, options), function (node) {
63
+ writeback(print(node, options).code);
64
+ });
65
+ }
tools/ui/node_modules/recast/package.json ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "author": "Ben Newman <bn@cs.stanford.edu>",
3
+ "name": "recast",
4
+ "version": "0.23.11",
5
+ "description": "JavaScript syntax tree transformer, nondestructive pretty-printer, and automatic source map generator",
6
+ "keywords": [
7
+ "ast",
8
+ "rewriting",
9
+ "refactoring",
10
+ "codegen",
11
+ "syntax",
12
+ "transformation",
13
+ "parsing",
14
+ "pretty-printing"
15
+ ],
16
+ "homepage": "http://github.com/benjamn/recast",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git://github.com/benjamn/recast.git"
20
+ },
21
+ "license": "MIT",
22
+ "main": "main.js",
23
+ "types": "main.d.ts",
24
+ "scripts": {
25
+ "mocha": "test/run.sh",
26
+ "debug": "test/run.sh --inspect-brk",
27
+ "test": "npm run lint && npm run build && npm run mocha",
28
+ "build": "npm run clean && tsc",
29
+ "lint": "eslint --ext .ts .",
30
+ "format": "prettier --write .",
31
+ "format:check": "prettier --check .",
32
+ "clean": "tsc --build --clean",
33
+ "prepare": "npm run build",
34
+ "postpack": "npm run clean"
35
+ },
36
+ "lint-staged": {
37
+ "*.ts": [
38
+ "eslint",
39
+ "prettier -c"
40
+ ]
41
+ },
42
+ "browser": {
43
+ "fs": false
44
+ },
45
+ "dependencies": {
46
+ "ast-types": "^0.16.1",
47
+ "esprima": "~4.0.0",
48
+ "source-map": "~0.6.1",
49
+ "tiny-invariant": "^1.3.3",
50
+ "tslib": "^2.0.1"
51
+ },
52
+ "devDependencies": {
53
+ "@babel/core": "7.20.5",
54
+ "@babel/parser": "7.20.5",
55
+ "@babel/preset-env": "7.20.2",
56
+ "@types/esprima": "4.0.3",
57
+ "@types/glob": "8.0.0",
58
+ "@types/mocha": "10.0.1",
59
+ "@types/node": "18.11.15",
60
+ "@typescript-eslint/parser": "^5.47.1",
61
+ "eslint": "^8.40.0",
62
+ "esprima-fb": "15001.1001.0-dev-harmony-fb",
63
+ "flow-parser": "0.195.0",
64
+ "glob": "8.0.3",
65
+ "lint-staged": "^13.2.2",
66
+ "mocha": "^10.2.0",
67
+ "prettier": "^2.6.2",
68
+ "reify": "0.20.12",
69
+ "typescript": "^4.9.4"
70
+ },
71
+ "engines": {
72
+ "node": ">= 4"
73
+ }
74
+ }
tools/ui/node_modules/recast/parsers/_babel_options.d.ts ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ import { ParserOptions, ParserPlugin } from "@babel/parser";
2
+ export type Overrides = Partial<{
3
+ sourceType: ParserOptions["sourceType"];
4
+ strictMode: ParserOptions["strictMode"];
5
+ }>;
6
+ export default function getBabelOptions(options?: Overrides): ParserOptions & {
7
+ plugins: ParserPlugin[];
8
+ };
tools/ui/node_modules/recast/parsers/_babel_options.js ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var util_1 = require("../lib/util");
4
+ function getBabelOptions(options) {
5
+ // The goal here is to tolerate as much syntax as possible, since Recast
6
+ // is not in the business of forbidding anything. If you want your
7
+ // parser to be more restrictive for some reason, you can always pass
8
+ // your own parser object to recast.parse.
9
+ return {
10
+ sourceType: (0, util_1.getOption)(options, "sourceType", "module"),
11
+ strictMode: (0, util_1.getOption)(options, "strictMode", false),
12
+ allowImportExportEverywhere: true,
13
+ allowReturnOutsideFunction: true,
14
+ startLine: 1,
15
+ tokens: true,
16
+ plugins: [
17
+ "asyncGenerators",
18
+ "bigInt",
19
+ "classPrivateMethods",
20
+ "classPrivateProperties",
21
+ "classProperties",
22
+ "classStaticBlock",
23
+ "decimal",
24
+ "decorators-legacy",
25
+ "doExpressions",
26
+ "dynamicImport",
27
+ "exportDefaultFrom",
28
+ "exportExtensions",
29
+ "exportNamespaceFrom",
30
+ "functionBind",
31
+ "functionSent",
32
+ "importAssertions",
33
+ "importMeta",
34
+ "nullishCoalescingOperator",
35
+ "numericSeparator",
36
+ "objectRestSpread",
37
+ "optionalCatchBinding",
38
+ "optionalChaining",
39
+ [
40
+ "pipelineOperator",
41
+ {
42
+ proposal: "minimal",
43
+ },
44
+ ],
45
+ [
46
+ "recordAndTuple",
47
+ {
48
+ syntaxType: "hash",
49
+ },
50
+ ],
51
+ "throwExpressions",
52
+ "topLevelAwait",
53
+ "v8intrinsic",
54
+ ],
55
+ };
56
+ }
57
+ exports.default = getBabelOptions;
tools/ui/node_modules/recast/parsers/acorn.d.ts ADDED
@@ -0,0 +1 @@
 
 
1
+ export declare function parse(source: string, options?: any): any;
tools/ui/node_modules/recast/parsers/acorn.js ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parse = void 0;
4
+ // This module is suitable for passing as options.parser when calling
5
+ // recast.parse to process JavaScript code with Acorn:
6
+ //
7
+ // const ast = recast.parse(source, {
8
+ // parser: require("recast/parsers/acorn")
9
+ // });
10
+ //
11
+ var util_1 = require("../lib/util");
12
+ function parse(source, options) {
13
+ var comments = [];
14
+ var tokens = [];
15
+ var ast = require("acorn").parse(source, {
16
+ allowHashBang: true,
17
+ allowImportExportEverywhere: true,
18
+ allowReturnOutsideFunction: true,
19
+ ecmaVersion: (0, util_1.getOption)(options, "ecmaVersion", 8),
20
+ sourceType: (0, util_1.getOption)(options, "sourceType", "module"),
21
+ locations: true,
22
+ onComment: comments,
23
+ onToken: tokens,
24
+ });
25
+ if (!ast.comments) {
26
+ ast.comments = comments;
27
+ }
28
+ if (!ast.tokens) {
29
+ ast.tokens = tokens;
30
+ }
31
+ return ast;
32
+ }
33
+ exports.parse = parse;
tools/ui/node_modules/recast/parsers/babel-ts.d.ts ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ import { parser } from "./babel";
2
+ import { Overrides } from "./_babel_options";
3
+ export { parser };
4
+ export declare function parse(source: string, options?: Overrides): import("@babel/parser").ParseResult<import("@babel/types").File>;
tools/ui/node_modules/recast/parsers/babel-ts.js ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parse = exports.parser = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var babel_1 = require("./babel");
6
+ Object.defineProperty(exports, "parser", { enumerable: true, get: function () { return babel_1.parser; } });
7
+ var _babel_options_1 = tslib_1.__importDefault(require("./_babel_options"));
8
+ function parse(source, options) {
9
+ var babelOptions = (0, _babel_options_1.default)(options);
10
+ babelOptions.plugins.push("jsx", "typescript");
11
+ return babel_1.parser.parse(source, babelOptions);
12
+ }
13
+ exports.parse = parse;
tools/ui/node_modules/recast/parsers/babel.d.ts ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ import { parse as babelParse } from "@babel/parser";
2
+ import { Overrides } from "./_babel_options";
3
+ type BabelParser = {
4
+ parse: typeof babelParse;
5
+ };
6
+ export declare const parser: BabelParser;
7
+ export declare function parse(source: string, options?: Overrides): import("@babel/parser").ParseResult<import("@babel/types").File>;
8
+ export {};
tools/ui/node_modules/recast/parsers/babel.js ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parse = exports.parser = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var _babel_options_1 = tslib_1.__importDefault(require("./_babel_options"));
6
+ // Prefer the new @babel/parser package, but fall back to babylon if
7
+ // that's what's available.
8
+ exports.parser = (function () {
9
+ try {
10
+ return require("@babel/parser");
11
+ }
12
+ catch (_a) {
13
+ try {
14
+ return require("babylon");
15
+ }
16
+ catch (_b) {
17
+ throw new Error("Install @babel/parser to use the `typescript`, `flow`, or `babel` parsers");
18
+ }
19
+ }
20
+ })();
21
+ // This module is suitable for passing as options.parser when calling
22
+ // recast.parse to process JavaScript code with Babel:
23
+ //
24
+ // const ast = recast.parse(source, {
25
+ // parser: require("recast/parsers/babel")
26
+ // });
27
+ //
28
+ function parse(source, options) {
29
+ var babelOptions = (0, _babel_options_1.default)(options);
30
+ babelOptions.plugins.push("jsx", "flow", "decoratorAutoAccessors");
31
+ return exports.parser.parse(source, babelOptions);
32
+ }
33
+ exports.parse = parse;
tools/ui/node_modules/recast/parsers/babylon.d.ts ADDED
@@ -0,0 +1 @@
 
 
1
+ export * from "./babel";
tools/ui/node_modules/recast/parsers/babylon.js ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./babel"), exports);
tools/ui/node_modules/recast/parsers/esprima.d.ts ADDED
@@ -0,0 +1 @@
 
 
1
+ export declare function parse(source: string, options?: any): any;
tools/ui/node_modules/recast/parsers/esprima.js ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parse = void 0;
4
+ // This module is suitable for passing as options.parser when calling
5
+ // recast.parse to process ECMAScript code with Esprima:
6
+ //
7
+ // const ast = recast.parse(source, {
8
+ // parser: require("recast/parsers/esprima")
9
+ // });
10
+ //
11
+ var util_1 = require("../lib/util");
12
+ function parse(source, options) {
13
+ var comments = [];
14
+ var ast = require("esprima").parse(source, {
15
+ loc: true,
16
+ locations: true,
17
+ comment: true,
18
+ onComment: comments,
19
+ range: (0, util_1.getOption)(options, "range", false),
20
+ tolerant: (0, util_1.getOption)(options, "tolerant", true),
21
+ tokens: true,
22
+ jsx: (0, util_1.getOption)(options, "jsx", false),
23
+ sourceType: (0, util_1.getOption)(options, "sourceType", "module"),
24
+ });
25
+ if (!Array.isArray(ast.comments)) {
26
+ ast.comments = comments;
27
+ }
28
+ return ast;
29
+ }
30
+ exports.parse = parse;
tools/ui/node_modules/recast/parsers/flow.d.ts ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ import { Overrides } from "./_babel_options";
2
+ export declare function parse(source: string, options?: Overrides): import("@babel/parser").ParseResult<import("@babel/types").File>;
tools/ui/node_modules/recast/parsers/flow.js ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parse = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var babel_1 = require("./babel");
6
+ var _babel_options_1 = tslib_1.__importDefault(require("./_babel_options"));
7
+ // This module is suitable for passing as options.parser when calling
8
+ // recast.parse to process Flow code:
9
+ //
10
+ // const ast = recast.parse(source, {
11
+ // parser: require("recast/parsers/flow")
12
+ // });
13
+ //
14
+ function parse(source, options) {
15
+ var babelOptions = (0, _babel_options_1.default)(options);
16
+ babelOptions.plugins.push("jsx", "flow");
17
+ return babel_1.parser.parse(source, babelOptions);
18
+ }
19
+ exports.parse = parse;
tools/ui/node_modules/recast/parsers/typescript.d.ts ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ import { Overrides } from "./_babel_options";
2
+ export declare function parse(source: string, options?: Overrides): import("@babel/parser").ParseResult<import("@babel/types").File>;
tools/ui/node_modules/recast/parsers/typescript.js ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parse = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var babel_1 = require("./babel");
6
+ var _babel_options_1 = tslib_1.__importDefault(require("./_babel_options"));
7
+ // This module is suitable for passing as options.parser when calling
8
+ // recast.parse to process TypeScript code:
9
+ //
10
+ // const ast = recast.parse(source, {
11
+ // parser: require("recast/parsers/typescript")
12
+ // });
13
+ //
14
+ function parse(source, options) {
15
+ var babelOptions = (0, _babel_options_1.default)(options);
16
+ babelOptions.plugins.push("typescript");
17
+ return babel_1.parser.parse(source, babelOptions);
18
+ }
19
+ exports.parse = parse;
tools/ui/node_modules/recast/tsconfig.json ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es5",
4
+ "lib": ["es2015"],
5
+ "module": "commonjs",
6
+ "declaration": true,
7
+ "rootDir": ".",
8
+ "strict": true,
9
+ "noUnusedLocals": true,
10
+ "noUnusedParameters": true,
11
+ "noImplicitReturns": true,
12
+ "moduleResolution": "node",
13
+ "esModuleInterop": true,
14
+ "importHelpers": true,
15
+ "stripInternal": true
16
+ },
17
+ "exclude": ["node_modules", "test/data"]
18
+ }
tools/ui/node_modules/redent/index.d.ts ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import {Options as IndentStringOptions} from 'indent-string';
2
+
3
+ declare namespace redent {
4
+ type Options = IndentStringOptions;
5
+ }
6
+
7
+ /**
8
+ [Strip redundant indentation](https://github.com/sindresorhus/strip-indent) and [indent the string](https://github.com/sindresorhus/indent-string).
9
+
10
+ @param string - The string to normalize indentation.
11
+ @param count - How many times you want `options.indent` repeated. Default: `0`.
12
+
13
+ @example
14
+ ```
15
+ import redent = require('redent');
16
+
17
+ redent('\n foo\n bar\n', 1);
18
+ //=> '\n foo\n bar\n'
19
+ ```
20
+ */
21
+ declare function redent(
22
+ string: string,
23
+ count?: number,
24
+ options?: redent.Options
25
+ ): string;
26
+
27
+ export = redent;
tools/ui/node_modules/redent/index.js ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ 'use strict';
2
+ const stripIndent = require('strip-indent');
3
+ const indentString = require('indent-string');
4
+
5
+ module.exports = (string, count = 0, options) => indentString(stripIndent(string), count, options);
tools/ui/node_modules/redent/license ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
tools/ui/node_modules/redent/package.json ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "redent",
3
+ "version": "3.0.0",
4
+ "description": "Strip redundant indentation and indent the string",
5
+ "license": "MIT",
6
+ "repository": "sindresorhus/redent",
7
+ "author": {
8
+ "name": "Sindre Sorhus",
9
+ "email": "sindresorhus@gmail.com",
10
+ "url": "sindresorhus.com"
11
+ },
12
+ "engines": {
13
+ "node": ">=8"
14
+ },
15
+ "scripts": {
16
+ "test": "xo && ava && tsd"
17
+ },
18
+ "files": [
19
+ "index.js",
20
+ "index.d.ts"
21
+ ],
22
+ "keywords": [
23
+ "string",
24
+ "strip",
25
+ "trim",
26
+ "indent",
27
+ "indentation",
28
+ "add",
29
+ "reindent",
30
+ "normalize",
31
+ "remove",
32
+ "whitespace",
33
+ "space"
34
+ ],
35
+ "dependencies": {
36
+ "indent-string": "^4.0.0",
37
+ "strip-indent": "^3.0.0"
38
+ },
39
+ "devDependencies": {
40
+ "ava": "^1.4.1",
41
+ "tsd": "^0.7.2",
42
+ "xo": "^0.24.0"
43
+ }
44
+ }
tools/ui/node_modules/redent/readme.md ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # redent [![Build Status](https://travis-ci.org/sindresorhus/redent.svg?branch=master)](https://travis-ci.org/sindresorhus/redent)
2
+
3
+ > [Strip redundant indentation](https://github.com/sindresorhus/strip-indent) and [indent the string](https://github.com/sindresorhus/indent-string)
4
+
5
+
6
+ ## Install
7
+
8
+ ```
9
+ $ npm install redent
10
+ ```
11
+
12
+
13
+ ## Usage
14
+
15
+ ```js
16
+ const redent = require('redent');
17
+
18
+ redent('\n foo\n bar\n', 1);
19
+ //=> '\n foo\n bar\n'
20
+ ```
21
+
22
+
23
+ ## API
24
+
25
+ ### redent(string, [count], [options])
26
+
27
+ #### string
28
+
29
+ Type: `string`
30
+
31
+ The string to normalize indentation.
32
+
33
+ #### count
34
+
35
+ Type: `number`<br>
36
+ Default: `0`
37
+
38
+ How many times you want `options.indent` repeated.
39
+
40
+ #### options
41
+
42
+ Type: `object`
43
+
44
+ ##### indent
45
+
46
+ Type: `string`<br>
47
+ Default: `' '`
48
+
49
+ The string to use for the indent.
50
+
51
+ ##### includeEmptyLines
52
+
53
+ Type: `boolean`<br>
54
+ Default: `false`
55
+
56
+ Also indent empty lines.
57
+
58
+
59
+ ## License
60
+
61
+ MIT © [Sindre Sorhus](https://sindresorhus.com)
tools/ui/node_modules/reflect.getprototypeof/.eslintrc ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "root": true,
3
+
4
+ "extends": "@ljharb",
5
+
6
+ "rules": {
7
+ "id-length": 0,
8
+ "max-statements": [2, 25],
9
+ "new-cap": [2, {
10
+ "capIsNewExceptions": [
11
+ "GetIntrinsic",
12
+ "IsCallable",
13
+ "Type",
14
+ ],
15
+ }],
16
+ },
17
+ }
tools/ui/node_modules/reflect.getprototypeof/.nycrc ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "all": true,
3
+ "check-coverage": false,
4
+ "reporter": ["text-summary", "text", "html", "json"],
5
+ "exclude": [
6
+ "coverage",
7
+ "test"
8
+ ]
9
+ }
tools/ui/node_modules/reflect.getprototypeof/CHANGELOG.md ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [v1.0.10](https://github.com/es-shims/Reflect.getPrototypeOf/compare/v1.0.9...v1.0.10) - 2025-01-02
9
+
10
+ ### Commits
11
+
12
+ - [Refactor] use `es-object-atoms` and `get-proto` directly [`2c55da0`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/2c55da02fb56d9ce7a19e505f487dfb088256d24)
13
+ - [Refactor] use `isObject` helper instead of `Type` [`e4c24a4`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/e4c24a4cc1b9928da3eb1f0a032703235d32855e)
14
+ - [Deps] update `es-abstract`, `get-intrinsic` [`54005fb`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/54005fb9df56fb399e0c526600cb7799d23ef64f)
15
+ - [Deps] update `es-abstract` [`e71b3b7`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/e71b3b75847d4af71e42ff049bd2b4d55f0324fc)
16
+
17
+ ## [v1.0.9](https://github.com/es-shims/Reflect.getPrototypeOf/compare/v1.0.8...v1.0.9) - 2024-12-18
18
+
19
+ ### Commits
20
+
21
+ - [Fix] avoid a crash with node `--disable-proto=throw` flag [`73f449d`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/73f449dff08fe574a4cd937d7265aceb1774de05)
22
+ - [Deps] update `dunder-proto`, `es-abstract`, `get-intrinsic`, `which-builtin-type` [`80c8227`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/80c8227aac6cef446ac8460f8bbdd9a83bd1d131)
23
+
24
+ ## [v1.0.8](https://github.com/es-shims/Reflect.getPrototypeOf/compare/v1.0.7...v1.0.8) - 2024-12-06
25
+
26
+ ### Commits
27
+
28
+ - [Refactor] share the getDunderProto helper [`f4be71b`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/f4be71b2941f217311210a00d84d8338b4880e2a)
29
+ - [Refactor] extract helper to `dunder-proto` [`51dcd35`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/51dcd3547ef9808c9fee7aa4a638d3d5d93db70c)
30
+ - [Deps] update `call-bind` [`c06e8d3`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/c06e8d3c1c9b567ca5bd6bb8542ae2e342f276ff)
31
+ - [Deps] update `gopd` [`c951a70`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/c951a709d5483fecc4041287a676d881295d1940)
32
+ - [Deps] update `gopd` [`8bd7b85`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/8bd7b8524aacc0574c979e3fe4f82adc51b03f3f)
33
+ - [Deps] update `which-builtin-type` [`f46f624`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/f46f62423c1c452063f73d34a363c127410742b2)
34
+
35
+ ## [v1.0.7](https://github.com/es-shims/Reflect.getPrototypeOf/compare/v1.0.6...v1.0.7) - 2024-11-23
36
+
37
+ ### Commits
38
+
39
+ - [Fix] cache `Object.prototype[__proto__]` getter [`68acea1`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/68acea171951197f83bb107af9e186ce68a5a78f)
40
+ - [Tests] remove unused test file [`055596a`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/055596aa2e050e08d35f8f19aa642e9b61a54f7f)
41
+ - [actions] split out node 10-20, and 20+ [`99a57c2`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/99a57c2551d11de70ea90b934e02b04ff3cec6c0)
42
+ - [Dev Deps] update `@es-shims/api`, `@ljharb/eslint-config`, `auto-changelog`, `tape` [`fe4bb92`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/fe4bb92a4d629e629f42f76567d837f8f17643a4)
43
+ - [Deps] update `es-abstract`, `globalthis`, `which-builtin-type` [`867aeb3`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/867aeb3c434ee03fd819da09d23a32a2c71290dc)
44
+ - [Tests] replace `aud` with `npm audit` [`5129c11`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/5129c112e18e3475afe42a836ac5d4d7ddfcfc18)
45
+ - [Deps] remove unused dep; add missing dev dep [`23cf537`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/23cf537aeac98bf27a8d39e24048e1c9fa4df7a7)
46
+ - [Dev Deps] add missing peer dep [`18862fa`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/18862fa57d2aa86825998db935ac6ffe23dec113)
47
+
48
+ ## [v1.0.6](https://github.com/es-shims/Reflect.getPrototypeOf/compare/v1.0.5...v1.0.6) - 2024-03-16
49
+
50
+ ### Commits
51
+
52
+ - [meta] remove useless ESM [`cc16ab1`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/cc16ab1f3b050c9465b41fbbf79e284e8e9084ff)
53
+ - [Deps] update `call-bind`, `es-abstract`, `es-errors`, `get-intrinsic` [`ece7445`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/ece7445f03d148c67f5fc91ea455a05731b54cea)
54
+ - [Dev Deps] update `tape` [`a894b62`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/a894b624c16247cbb76a00e76a39e3d44ac5bccf)
55
+
56
+ ## [v1.0.5](https://github.com/es-shims/Reflect.getPrototypeOf/compare/v1.0.4...v1.0.5) - 2024-02-04
57
+
58
+ ### Commits
59
+
60
+ - [Refactor] use `es-errors` where possible, so things that only need those do not need `get-intrinsic` [`08735cb`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/08735cba1dfeabae4e362b61e6de36843a472d22)
61
+ - [Deps] update `call-bind`, `define-properties`, `es-abstract`, `get-intrinsic` [`b5700ec`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/b5700eca8af88bbc693b304567d6124d13c03827)
62
+ - [Dev Deps] update `aud`, `npmignore`, `tape` [`f80fcbb`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/f80fcbb140661c07aa2a94547ffae0a5a8f937ac)
63
+
64
+ ## [v1.0.4](https://github.com/es-shims/Reflect.getPrototypeOf/compare/v1.0.3...v1.0.4) - 2023-08-30
65
+
66
+ ### Commits
67
+
68
+ - [Deps] update `define-properties`, `es-abstract`, `get-intrinsic` [`325044f`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/325044f152c87f18344ba558b5967e69298a5dd2)
69
+ - [Dev Deps] update `@es-shims/api`, `@ljharb/eslint-config`, `aud`, `tape` [`56b9555`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/56b9555a536207493c4e2c17f1fee2390535a659)
70
+
71
+ ## [v1.0.3](https://github.com/es-shims/Reflect.getPrototypeOf/compare/v1.0.2...v1.0.3) - 2022-11-07
72
+
73
+ ### Commits
74
+
75
+ - [actions] reuse common workflows [`0a76d97`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/0a76d972c13cd319504d3eecf8e7e00e39327c88)
76
+ - [meta] use `npmignore` to autogenerate an npmignore file [`c4861b4`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/c4861b45aeebddd1d998bdd44438b29e4bf974e8)
77
+ - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `@es-shims/api`, `safe-publish-latest`, `tape` [`e5352ab`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/e5352ab099f7104c085ffd2ee8fbfec69546fa2c)
78
+ - [actions] update codecov uploader [`dbcedf8`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/dbcedf83e967e17316fc98fb18011c603bb54823)
79
+ - [Deps] update `define-properties`, `es-abstract`, `globalthis`, `which-builtin-type` [`84fbfab`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/84fbfabe53774587be4748df303cec8acded7c0f)
80
+ - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog`, `tape` [`75dc8a3`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/75dc8a337f11f11a947241c968bb7f5b843a1d17)
81
+ - [actions] update rebase action to use reusable workflow [`49463a7`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/49463a7a6d9aaa08c201ff4206efcade7a997175)
82
+ - [Dev Deps] update `@es-shims/api` [`adf75cb`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/adf75cb9dbda9052437a8e48e33da28dc52aa63c)
83
+
84
+ ## [v1.0.2](https://github.com/es-shims/Reflect.getPrototypeOf/compare/v1.0.1...v1.0.2) - 2021-10-03
85
+
86
+ ### Commits
87
+
88
+ - [Deps] update `es-abstract` [`947bbb1`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/947bbb1bff0cc08ab80bb809a19771c6087e9fda)
89
+ - [actions] update workflows` [`af4708d`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/af4708d75212ee5781b549b1ff86f903fc659e3f)
90
+
91
+ ## [v1.0.1](https://github.com/es-shims/Reflect.getPrototypeOf/compare/v1.0.0...v1.0.1) - 2021-09-08
92
+
93
+ ### Commits
94
+
95
+ - [actions] use `node/install` instead of `node/run`; use `codecov` action [`86f4aa3`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/86f4aa392c73220ecb561d644def5c3efab4f9f5)
96
+ - [Refactor] remove unnecessary ESM files [`162e4bf`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/162e4bfb58fb4eba6f2f26f11b0f46a8ea6587a7)
97
+ - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `@es-shims/api`, `aud`, `auto-changelog`, `tape` [`5515a8d`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/5515a8d17fc1978792db7e57a79f7f2fa60dc55e)
98
+ - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `tape` [`db05b43`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/db05b43dff616acab04544ab04bd385d462b8572)
99
+ - [readme] add github actions/codecov badges [`d9ea295`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/d9ea295264f1d415b5083b3d4116b14a5a8ee7ff)
100
+ - [Deps] update `es-abstract`, `which-builtin-type` [`1753dee`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/1753deeaadbd66bb65e140e4bc81cee6652f07cd)
101
+ - [Dev Deps] update `eslint`, `tape` [`4bce2db`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/4bce2db34c4182edd0bf3610eaeb1ea42844ee15)
102
+ - [Deps] update `es-abstract`, `get-intrinsic` [`1dca685`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/1dca685d1e5305b6720882ac8f4d5038a8309431)
103
+ - [meta] use `prepublishOnly` script for npm 7+ [`1108273`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/1108273eba643ac8b135d177c21dd371ccb32901)
104
+ - [actions] update workflows [`8674d66`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/8674d662705675531d216bdba2b7e1e26be1b12b)
105
+ - [Deps] update `es-abstract` [`4e4fdcf`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/4e4fdcf854f3cd71d71aa80723664f5d2b814dad)
106
+
107
+ ## v1.0.0 - 2021-01-12
108
+
109
+ ### Commits
110
+
111
+ - es-shims initial commit [`ffd0b98`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/ffd0b980b47f0b2db6bc3373364e950f6fce33cb)
112
+ - Initial commit [`64c868f`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/64c868fa1bb3630f4ab823aaba98d0f28b3f8078)
113
+ - [meta] add Automatic Rebase and Require Allow Edits workflows [`6a006b4`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/6a006b4ddebfe68fd23b2870c83aadefecf80b04)
114
+ - [meta] Only apps should have lockfiles [`d1a29b5`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/d1a29b5b37d31129ecc1fecac1922d4c4935f9fa)
115
+ - [Deps] update `call-bind` [`bfcc1a0`](https://github.com/es-shims/Reflect.getPrototypeOf/commit/bfcc1a0bd04fffe5fe53e791dd40f7988bbd5d03)
tools/ui/node_modules/reflect.getprototypeof/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2021 ECMAScript Shims
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
tools/ui/node_modules/reflect.getprototypeof/README.md ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # reflect.getprototypeof <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
2
+
3
+ [![github actions][actions-image]][actions-url]
4
+ [![coverage][codecov-image]][codecov-url]
5
+ [![dependency status][deps-svg]][deps-url]
6
+ [![dev dependency status][dev-deps-svg]][dev-deps-url]
7
+ [![License][license-image]][license-url]
8
+ [![Downloads][downloads-image]][downloads-url]
9
+
10
+ [![npm badge][npm-badge-png]][package-url]
11
+
12
+ An ES2015 mostly-spec-compliant `Reflect.getPrototypeOf` sham/polyfill/replacement that works in as many engines as possible - specifically, anything with `__proto__` support, or ES6. Built-in types will also work correctly in older engines.
13
+
14
+ This package implements the [es-shim API](https://github.com/es-shims/api) interface. It works in an ES3-supported environment and complies with the [spec](https://www.ecma-international.org/ecma-262/5.1/).
15
+
16
+ ## Example
17
+
18
+ ```js
19
+ var getPrototypeOf = require('reflect.getprototypeof');
20
+ var assert = require('assert');
21
+
22
+ assert.throws(() => getPrototypeOf(true));
23
+ assert.throws(() => getPrototypeOf(42));
24
+ assert.throws(() => getPrototypeOf(''));
25
+ assert.equal(getPrototypeOf(/a/g), RegExp.prototype);
26
+ assert.equal(getPrototypeOf(new Date()), Date.prototype);
27
+ assert.equal(getPrototypeOf(function () {}), Function.prototype);
28
+ assert.equal(getPrototypeOf([]), Array.prototype);
29
+ assert.equal(getPrototypeOf({}), Object.prototype);
30
+ ```
31
+
32
+ ```js
33
+ var getPrototypeOf = require('reflect.getprototypeof');
34
+ var assert = require('assert');
35
+ /* when Reflect or Reflect.getPrototypeOf is not present */
36
+ if (typeof Reflect === 'object') { delete Reflect.getPrototypeOf; }
37
+ delete globalThis.Reflect;
38
+ var shimmed = getPrototypeOf.shim();
39
+ assert.equal(shimmed, getPrototypeOf.getPolyfill());
40
+
41
+ assert.throws(() => Reflect.getPrototypeOf(true));
42
+ assert.throws(() => Reflect.getPrototypeOf(42));
43
+ assert.throws(() => Reflect.getPrototypeOf(''));
44
+ assert.equal(Reflect.getPrototypeOf(/a/g), RegExp.prototype);
45
+ assert.equal(Reflect.getPrototypeOf(new Date()), Date.prototype);
46
+ assert.equal(Reflect.getPrototypeOf(function () {}), Function.prototype);
47
+ assert.equal(Reflect.getPrototypeOf([]), Array.prototype);
48
+ assert.equal(Reflect.getPrototypeOf({}), Object.prototype);
49
+ ```
50
+
51
+ ```js
52
+ var getPrototypeOf = require('reflect.getprototypeof');
53
+ var assert = require('assert');
54
+ /* when Reflect.getPrototypeOf is present */
55
+ var shimmedGetPrototypeOf = getPrototypeOf.shim();
56
+ assert.equal(shimmedGetPrototypeOf, Reflect.getPrototypeOf);
57
+ assert.equal(Reflect.getPrototypeOf([]), Array.prototype);
58
+ ```
59
+
60
+ ## Tests
61
+ Simply clone the repo, `npm install`, and run `npm test`
62
+
63
+ [package-url]: https://npmjs.org/package/reflect.getprototypeof
64
+ [npm-version-svg]: https://versionbadg.es/es-shims/Reflect.getPrototypeOf.svg
65
+ [deps-svg]: https://david-dm.org/es-shims/Reflect.getPrototypeOf.svg
66
+ [deps-url]: https://david-dm.org/es-shims/Reflect.getPrototypeOf
67
+ [dev-deps-svg]: https://david-dm.org/es-shims/Reflect.getPrototypeOf/dev-status.svg
68
+ [dev-deps-url]: https://david-dm.org/es-shims/Reflect.getPrototypeOf#info=devDependencies
69
+ [npm-badge-png]: https://nodei.co/npm/reflect.getprototypeof.png?downloads=true&stars=true
70
+ [license-image]: https://img.shields.io/npm/l/reflect.getprototypeof.svg
71
+ [license-url]: LICENSE
72
+ [downloads-image]: https://img.shields.io/npm/dm/reflect.getprototypeof.svg
73
+ [downloads-url]: https://npm-stat.com/charts.html?package=reflect.getprototypeof
74
+ [codecov-image]: https://codecov.io/gh/es-shims/Reflect.getPrototypeOf/branch/main/graphs/badge.svg
75
+ [codecov-url]: https://app.codecov.io/gh/es-shims/Reflect.getPrototypeOf/
76
+ [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/es-shims/Reflect.getPrototypeOf
77
+ [actions-url]: https://github.com/es-shims/Reflect.getPrototypeOf/actions
tools/ui/node_modules/reflect.getprototypeof/auto.js ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ 'use strict';
2
+
3
+ require('./shim')();
tools/ui/node_modules/reflect.getprototypeof/implementation.js ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+
3
+ var GetIntrinsic = require('get-intrinsic');
4
+ var IsCallable = require('es-abstract/2024/IsCallable');
5
+ var isObject = require('es-abstract/helpers/isObject');
6
+ var whichBuiltinType = require('which-builtin-type');
7
+ var $TypeError = require('es-errors/type');
8
+
9
+ var gPO = require('get-proto');
10
+ var $Object = require('es-object-atoms');
11
+
12
+ module.exports = function getPrototypeOf(O) {
13
+ if (!isObject(O)) {
14
+ throw new $TypeError('Reflect.getPrototypeOf called on non-object');
15
+ }
16
+
17
+ if (gPO) {
18
+ return gPO(O);
19
+ }
20
+
21
+ var type = whichBuiltinType(O);
22
+ if (type) {
23
+ var intrinsic = GetIntrinsic('%' + type + '.prototype%', true);
24
+ if (intrinsic) {
25
+ return intrinsic;
26
+ }
27
+ }
28
+ if (IsCallable(O.constructor)) {
29
+ return O.constructor.prototype;
30
+ }
31
+ if (O instanceof Object) {
32
+ return $Object.prototype;
33
+ }
34
+
35
+ /*
36
+ * Correctly return null for Objects created with `Object.create(null)` (shammed or native) or `{ __proto__: null}`. Also returns null for
37
+ * cross-realm objects on browsers that lack `__proto__` support (like IE <11), but that's the best we can do.
38
+ */
39
+ return null;
40
+ };
tools/ui/node_modules/reflect.getprototypeof/index.js ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+
3
+ var callBind = require('call-bind');
4
+ var define = require('define-properties');
5
+
6
+ var implementation = require('./implementation');
7
+ var getPolyfill = require('./polyfill');
8
+ var shim = require('./shim');
9
+
10
+ var bound = callBind(getPolyfill(), typeof Reflect === 'object' ? Reflect : Object);
11
+
12
+ define(bound, {
13
+ getPolyfill: getPolyfill,
14
+ implementation: implementation,
15
+ shim: shim
16
+ });
17
+
18
+ module.exports = bound;
tools/ui/node_modules/reflect.getprototypeof/package.json ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "reflect.getprototypeof",
3
+ "version": "1.0.10",
4
+ "description": "An ES2015 mostly-spec-compliant `Reflect.getPrototypeOf` sham/polyfill/replacement that works in as many engines as possible",
5
+ "main": "index.js",
6
+ "type": "commonjs",
7
+ "exports": {
8
+ ".": "./index.js",
9
+ "./auto": "./auto.js",
10
+ "./polyfill": "./polyfill.js",
11
+ "./implementation": "./implementation.js",
12
+ "./shim": "./shim.js",
13
+ "./package.json": "./package.json"
14
+ },
15
+ "scripts": {
16
+ "prepack": "npmignore --auto --commentLines=autogenerated",
17
+ "prepublish": "not-in-publish || npm run prepublishOnly",
18
+ "prepublishOnly": "safe-publish-latest",
19
+ "prelint": "evalmd README.md",
20
+ "lint": "eslint --ext=js,mjs .",
21
+ "postlint": "es-shim-api --bound",
22
+ "pretest": "npm run lint",
23
+ "tests-only": "nyc tape 'test/**/*.js'",
24
+ "test": "npm run tests-only",
25
+ "posttest": "npx npm@'>=10.2' audit --production",
26
+ "version": "auto-changelog && git add CHANGELOG.md",
27
+ "postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\""
28
+ },
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "git+https://github.com/es-shims/Reflect.getPrototypeOf.git"
32
+ },
33
+ "keywords": [
34
+ "Reflect.getPrototypeOf",
35
+ "Object.getPrototypeOf",
36
+ "proto",
37
+ "__proto__",
38
+ "[[Prototype]]",
39
+ "getPrototypeOf",
40
+ "ES5",
41
+ "shim",
42
+ "polyfill",
43
+ "es-shim API",
44
+ "browser"
45
+ ],
46
+ "author": "Jordan Harband <ljharb@gmail.com>",
47
+ "funding": {
48
+ "url": "https://github.com/sponsors/ljharb"
49
+ },
50
+ "license": "MIT",
51
+ "bugs": {
52
+ "url": "https://github.com/es-shims/Reflect.getPrototypeOf/issues"
53
+ },
54
+ "homepage": "https://github.com/es-shims/Reflect.getPrototypeOf",
55
+ "engines": {
56
+ "node": ">= 0.4"
57
+ },
58
+ "dependencies": {
59
+ "call-bind": "^1.0.8",
60
+ "define-properties": "^1.2.1",
61
+ "es-abstract": "^1.23.9",
62
+ "es-errors": "^1.3.0",
63
+ "es-object-atoms": "^1.0.0",
64
+ "get-intrinsic": "^1.2.7",
65
+ "get-proto": "^1.0.1",
66
+ "which-builtin-type": "^1.2.1"
67
+ },
68
+ "devDependencies": {
69
+ "@es-shims/api": "^2.5.1",
70
+ "@ljharb/eslint-config": "^21.1.1",
71
+ "auto-changelog": "^2.5.0",
72
+ "encoding": "^0.1.13",
73
+ "eslint": "=8.8.0",
74
+ "evalmd": "^0.0.19",
75
+ "functions-have-names": "^1.2.3",
76
+ "in-publish": "^2.0.1",
77
+ "npmignore": "^0.3.1",
78
+ "nyc": "^10.3.2",
79
+ "safe-publish-latest": "^2.0.0",
80
+ "tape": "^5.9.0"
81
+ },
82
+ "auto-changelog": {
83
+ "output": "CHANGELOG.md",
84
+ "template": "keepachangelog",
85
+ "unreleased": false,
86
+ "commitLimit": false,
87
+ "backfillLimit": false,
88
+ "hideCredit": true
89
+ },
90
+ "publishConfig": {
91
+ "ignore": [
92
+ ".github/workflows"
93
+ ]
94
+ },
95
+ "testling": {
96
+ "files": "test/implementation.js"
97
+ }
98
+ }
tools/ui/node_modules/reflect.getprototypeof/polyfill.js ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+
3
+ var implementation = require('./implementation');
4
+
5
+ var getProto = require('get-proto');
6
+
7
+ module.exports = function getPolyfill() {
8
+ if (typeof Reflect === 'object' && Reflect && Reflect.getPrototypeOf) {
9
+ return Reflect.getPrototypeOf;
10
+ }
11
+ return getProto
12
+ ? function getPrototypeOf(O) { return getProto(O); }
13
+ : implementation;
14
+ };
tools/ui/node_modules/reflect.getprototypeof/shim.js ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+
3
+ var define = require('define-properties');
4
+ var getPolyfill = require('./polyfill');
5
+
6
+ module.exports = function shimGetPrototypeOf() {
7
+ define(
8
+ global,
9
+ { Reflect: {} },
10
+ { Reflect: function () { return typeof Reflect !== 'object' || !Reflect; } }
11
+ );
12
+
13
+ var polyfill = getPolyfill();
14
+ define(
15
+ Reflect,
16
+ { getPrototypeOf: polyfill },
17
+ { getPrototypeOf: function () { return Reflect.getPrototypeOf !== polyfill; } }
18
+ );
19
+
20
+ return polyfill;
21
+ };
tools/ui/node_modules/reflect.getprototypeof/test/implementation.js ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+
3
+ var getPrototypeOf = require('../implementation');
4
+ var test = require('tape');
5
+ var runTests = require('./tests');
6
+
7
+ test('as a function', function (t) {
8
+ runTests(getPrototypeOf, t);
9
+
10
+ t.end();
11
+ });
tools/ui/node_modules/reflect.getprototypeof/test/index.js ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+
3
+ var getPrototypeOf = require('../');
4
+ var test = require('tape');
5
+ var runTests = require('./tests');
6
+
7
+ test('as a function', function (t) {
8
+ runTests(getPrototypeOf, t);
9
+
10
+ t.end();
11
+ });
tools/ui/node_modules/reflect.getprototypeof/test/shimmed.js ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+
3
+ require('../auto');
4
+
5
+ var test = require('tape');
6
+ var defineProperties = require('define-properties');
7
+
8
+ var isEnumerable = Object.prototype.propertyIsEnumerable;
9
+ var functionsHaveNames = require('functions-have-names')();
10
+
11
+ var runTests = require('./tests');
12
+
13
+ test('shimmed', function (t) {
14
+ t.equal(Reflect.getPrototypeOf.length, 1, 'Reflect.getPrototypeOf has length of 1');
15
+ t.test('Function name', { skip: !functionsHaveNames }, function (st) {
16
+ st.equal(Reflect.getPrototypeOf.name, 'getPrototypeOf', 'Reflect.getPrototypeOf has name "getPrototypeOf"');
17
+ st.end();
18
+ });
19
+
20
+ t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
21
+ et.equal(false, isEnumerable.call(Reflect, 'getPrototypeOf'), 'Reflect.getPrototypeOf is not enumerable');
22
+ et.end();
23
+ });
24
+
25
+ runTests(Reflect.getPrototypeOf, t);
26
+
27
+ t.end();
28
+ });