source: imaps-frontend/node_modules/rollup/dist/es/shared/parseAst.js@ 0c6b92a

main
Last change on this file since 0c6b92a was 0c6b92a, checked in by stefan toskovski <stefantoska84@…>, 5 weeks ago

Pred finalna verzija

  • Property mode set to 100644
File size: 81.2 KB
Line 
1/*
2 @license
3 Rollup.js v4.27.4
4 Sat, 23 Nov 2024 06:59:50 GMT - commit e805b546405a4e6cfccd3fe73e9f4df770023824
5
6 https://github.com/rollup/rollup
7
8 Released under the MIT License.
9*/
10import { parse, parseAsync } from '../../native.js';
11import { resolve, basename, extname, dirname } from 'node:path';
12
13// This file is generated by scripts/generate-node-types.js.
14// Do not edit this file directly.
15const ArrowFunctionExpression = 'ArrowFunctionExpression';
16const BlockStatement = 'BlockStatement';
17const CallExpression = 'CallExpression';
18const CatchClause = 'CatchClause';
19const ExportDefaultDeclaration = 'ExportDefaultDeclaration';
20const ExpressionStatement = 'ExpressionStatement';
21const Identifier = 'Identifier';
22const Literal = 'Literal';
23const ObjectExpression = 'ObjectExpression';
24const PanicError = 'PanicError';
25const ParseError = 'ParseError';
26const Program = 'Program';
27const Property = 'Property';
28const ReturnStatement = 'ReturnStatement';
29const StaticBlock = 'StaticBlock';
30const TemplateLiteral = 'TemplateLiteral';
31const VariableDeclarator = 'VariableDeclarator';
32
33const BLANK = Object.freeze(Object.create(null));
34const EMPTY_OBJECT = Object.freeze({});
35const EMPTY_ARRAY = Object.freeze([]);
36const EMPTY_SET = Object.freeze(new (class extends Set {
37 add() {
38 throw new Error('Cannot add to empty set');
39 }
40})());
41
42// This file is generated by scripts/generate-string-constants.js.
43// Do not edit this file directly.
44const FIXED_STRINGS = [
45 'var',
46 'let',
47 'const',
48 'init',
49 'get',
50 'set',
51 'constructor',
52 'method',
53 '-',
54 '+',
55 '!',
56 '~',
57 'typeof',
58 'void',
59 'delete',
60 '++',
61 '--',
62 '==',
63 '!=',
64 '===',
65 '!==',
66 '<',
67 '<=',
68 '>',
69 '>=',
70 '<<',
71 '>>',
72 '>>>',
73 '+',
74 '-',
75 '*',
76 '/',
77 '%',
78 '|',
79 '^',
80 '&',
81 '||',
82 '&&',
83 'in',
84 'instanceof',
85 '**',
86 '??',
87 '=',
88 '+=',
89 '-=',
90 '*=',
91 '/=',
92 '%=',
93 '<<=',
94 '>>=',
95 '>>>=',
96 '|=',
97 '^=',
98 '&=',
99 '**=',
100 '&&=',
101 '||=',
102 '??=',
103 'pure',
104 'noSideEffects',
105 'sourcemap',
106 'using',
107 'await using'
108];
109
110const ANNOTATION_KEY = '_rollupAnnotations';
111const INVALID_ANNOTATION_KEY = '_rollupRemoved';
112const convertAnnotations = (position, buffer) => {
113 if (position === 0)
114 return EMPTY_ARRAY;
115 const length = buffer[position++];
116 const list = new Array(length);
117 for (let index = 0; index < length; index++) {
118 list[index] = convertAnnotation(buffer[position++], buffer);
119 }
120 return list;
121};
122const convertAnnotation = (position, buffer) => {
123 const start = buffer[position++];
124 const end = buffer[position++];
125 const type = FIXED_STRINGS[buffer[position]];
126 return { end, start, type };
127};
128
129/** @typedef {import('./types').Location} Location */
130
131/**
132 * @param {import('./types').Range} range
133 * @param {number} index
134 */
135function rangeContains(range, index) {
136 return range.start <= index && index < range.end;
137}
138
139/**
140 * @param {string} source
141 * @param {import('./types').Options} [options]
142 */
143function getLocator(source, options = {}) {
144 const { offsetLine = 0, offsetColumn = 0 } = options;
145
146 let start = 0;
147 const ranges = source.split('\n').map((line, i) => {
148 const end = start + line.length + 1;
149
150 /** @type {import('./types').Range} */
151 const range = { start, end, line: i };
152
153 start = end;
154 return range;
155 });
156
157 let i = 0;
158
159 /**
160 * @param {string | number} search
161 * @param {number} [index]
162 * @returns {Location | undefined}
163 */
164 function locator(search, index) {
165 if (typeof search === 'string') {
166 search = source.indexOf(search, index ?? 0);
167 }
168
169 if (search === -1) return undefined;
170
171 let range = ranges[i];
172
173 const d = search >= range.end ? 1 : -1;
174
175 while (range) {
176 if (rangeContains(range, search)) {
177 return {
178 line: offsetLine + range.line,
179 column: offsetColumn + search - range.start,
180 character: search
181 };
182 }
183
184 i += d;
185 range = ranges[i];
186 }
187 }
188
189 return locator;
190}
191
192/**
193 * @param {string} source
194 * @param {string | number} search
195 * @param {import('./types').Options} [options]
196 * @returns {Location | undefined}
197 */
198function locate(source, search, options) {
199 return getLocator(source, options)(search, options && options.startIndex);
200}
201
202function spaces(index) {
203 let result = '';
204 while (index--)
205 result += ' ';
206 return result;
207}
208function tabsToSpaces(value) {
209 return value.replace(/^\t+/, match => match.split('\t').join(' '));
210}
211const LINE_TRUNCATE_LENGTH = 120;
212const MIN_CHARACTERS_SHOWN_AFTER_LOCATION = 10;
213const ELLIPSIS = '...';
214function getCodeFrame(source, line, column) {
215 let lines = source.split('\n');
216 // Needed if a plugin did not generate correct sourcemaps
217 if (line > lines.length)
218 return '';
219 const maxLineLength = Math.max(tabsToSpaces(lines[line - 1].slice(0, column)).length +
220 MIN_CHARACTERS_SHOWN_AFTER_LOCATION +
221 ELLIPSIS.length, LINE_TRUNCATE_LENGTH);
222 const frameStart = Math.max(0, line - 3);
223 let frameEnd = Math.min(line + 2, lines.length);
224 lines = lines.slice(frameStart, frameEnd);
225 while (!/\S/.test(lines[lines.length - 1])) {
226 lines.pop();
227 frameEnd -= 1;
228 }
229 const digits = String(frameEnd).length;
230 return lines
231 .map((sourceLine, index) => {
232 const isErrorLine = frameStart + index + 1 === line;
233 let lineNumber = String(index + frameStart + 1);
234 while (lineNumber.length < digits)
235 lineNumber = ` ${lineNumber}`;
236 let displayedLine = tabsToSpaces(sourceLine);
237 if (displayedLine.length > maxLineLength) {
238 displayedLine = `${displayedLine.slice(0, maxLineLength - ELLIPSIS.length)}${ELLIPSIS}`;
239 }
240 if (isErrorLine) {
241 const indicator = spaces(digits + 2 + tabsToSpaces(sourceLine.slice(0, column)).length) + '^';
242 return `${lineNumber}: ${displayedLine}\n${indicator}`;
243 }
244 return `${lineNumber}: ${displayedLine}`;
245 })
246 .join('\n');
247}
248
249const LOGLEVEL_SILENT = 'silent';
250const LOGLEVEL_ERROR = 'error';
251const LOGLEVEL_WARN = 'warn';
252const LOGLEVEL_INFO = 'info';
253const LOGLEVEL_DEBUG = 'debug';
254const logLevelPriority = {
255 [LOGLEVEL_DEBUG]: 0,
256 [LOGLEVEL_INFO]: 1,
257 [LOGLEVEL_SILENT]: 3,
258 [LOGLEVEL_WARN]: 2
259};
260
261const ABSOLUTE_PATH_REGEX = /^(?:\/|(?:[A-Za-z]:)?[/\\|])/;
262const RELATIVE_PATH_REGEX = /^\.?\.(\/|$)/;
263function isAbsolute(path) {
264 return ABSOLUTE_PATH_REGEX.test(path);
265}
266function isRelative(path) {
267 return RELATIVE_PATH_REGEX.test(path);
268}
269const BACKSLASH_REGEX = /\\/g;
270function normalize(path) {
271 return path.replace(BACKSLASH_REGEX, '/');
272}
273
274function printQuotedStringList(list, verbs) {
275 const isSingleItem = list.length <= 1;
276 const quotedList = list.map(item => `"${item}"`);
277 let output = isSingleItem
278 ? quotedList[0]
279 : `${quotedList.slice(0, -1).join(', ')} and ${quotedList.slice(-1)[0]}`;
280 if (verbs) {
281 output += ` ${isSingleItem ? verbs[0] : verbs[1]}`;
282 }
283 return output;
284}
285
286const ANY_SLASH_REGEX = /[/\\]/;
287function relative(from, to) {
288 const fromParts = from.split(ANY_SLASH_REGEX).filter(Boolean);
289 const toParts = to.split(ANY_SLASH_REGEX).filter(Boolean);
290 if (fromParts[0] === '.')
291 fromParts.shift();
292 if (toParts[0] === '.')
293 toParts.shift();
294 while (fromParts[0] && toParts[0] && fromParts[0] === toParts[0]) {
295 fromParts.shift();
296 toParts.shift();
297 }
298 while (toParts[0] === '..' && fromParts.length > 0) {
299 toParts.shift();
300 fromParts.pop();
301 }
302 while (fromParts.pop()) {
303 toParts.unshift('..');
304 }
305 return toParts.join('/');
306}
307
308function getAliasName(id) {
309 const base = basename(id);
310 return base.slice(0, Math.max(0, base.length - extname(id).length));
311}
312function relativeId(id) {
313 if (!isAbsolute(id))
314 return id;
315 return relative(resolve(), id);
316}
317function isPathFragment(name) {
318 // starting with "/", "./", "../", "C:/"
319 return (name[0] === '/' || (name[0] === '.' && (name[1] === '/' || name[1] === '.')) || isAbsolute(name));
320}
321const UPPER_DIR_REGEX = /^(\.\.\/)*\.\.$/;
322function getImportPath(importerId, targetPath, stripJsExtension, ensureFileName) {
323 while (targetPath.startsWith('../')) {
324 targetPath = targetPath.slice(3);
325 importerId = '_/' + importerId;
326 }
327 let relativePath = normalize(relative(dirname(importerId), targetPath));
328 if (stripJsExtension && relativePath.endsWith('.js')) {
329 relativePath = relativePath.slice(0, -3);
330 }
331 if (ensureFileName) {
332 if (relativePath === '')
333 return '../' + basename(targetPath);
334 if (UPPER_DIR_REGEX.test(relativePath)) {
335 return [...relativePath.split('/'), '..', basename(targetPath)].join('/');
336 }
337 }
338 return relativePath ? (relativePath.startsWith('..') ? relativePath : './' + relativePath) : '.';
339}
340
341function isValidUrl(url) {
342 try {
343 new URL(url);
344 }
345 catch {
346 return false;
347 }
348 return true;
349}
350function getRollupUrl(snippet) {
351 return `https://rollupjs.org/${snippet}`;
352}
353function addTrailingSlashIfMissed(url) {
354 if (!url.endsWith('/')) {
355 return url + '/';
356 }
357 return url;
358}
359
360// troubleshooting
361const URL_AVOIDING_EVAL = 'troubleshooting/#avoiding-eval';
362const URL_NAME_IS_NOT_EXPORTED = 'troubleshooting/#error-name-is-not-exported-by-module';
363const URL_THIS_IS_UNDEFINED = 'troubleshooting/#error-this-is-undefined';
364const URL_TREATING_MODULE_AS_EXTERNAL_DEPENDENCY = 'troubleshooting/#warning-treating-module-as-external-dependency';
365const URL_SOURCEMAP_IS_LIKELY_TO_BE_INCORRECT = 'troubleshooting/#warning-sourcemap-is-likely-to-be-incorrect';
366// configuration-options
367const URL_JSX = 'configuration-options/#jsx';
368const URL_OUTPUT_AMD_ID = 'configuration-options/#output-amd-id';
369const URL_OUTPUT_AMD_BASEPATH = 'configuration-options/#output-amd-basepath';
370const URL_OUTPUT_DIR = 'configuration-options/#output-dir';
371const URL_OUTPUT_EXPORTS = 'configuration-options/#output-exports';
372const URL_OUTPUT_EXTEND = 'configuration-options/#output-extend';
373const URL_OUTPUT_EXTERNALIMPORTATTRIBUTES = 'configuration-options/#output-externalimportattributes';
374const URL_OUTPUT_FORMAT = 'configuration-options/#output-format';
375const URL_OUTPUT_GENERATEDCODE = 'configuration-options/#output-generatedcode';
376const URL_OUTPUT_GLOBALS = 'configuration-options/#output-globals';
377const URL_OUTPUT_INLINEDYNAMICIMPORTS = 'configuration-options/#output-inlinedynamicimports';
378const URL_OUTPUT_INTEROP = 'configuration-options/#output-interop';
379const URL_OUTPUT_MANUALCHUNKS = 'configuration-options/#output-manualchunks';
380const URL_OUTPUT_NAME = 'configuration-options/#output-name';
381const URL_OUTPUT_SOURCEMAPBASEURL = 'configuration-options/#output-sourcemapbaseurl';
382const URL_OUTPUT_SOURCEMAPFILE = 'configuration-options/#output-sourcemapfile';
383const URL_PRESERVEENTRYSIGNATURES = 'configuration-options/#preserveentrysignatures';
384const URL_TREESHAKE = 'configuration-options/#treeshake';
385const URL_TREESHAKE_PURE = 'configuration-options/#pure';
386const URL_TREESHAKE_NOSIDEEFFECTS = 'configuration-options/#no-side-effects';
387const URL_TREESHAKE_MODULESIDEEFFECTS = 'configuration-options/#treeshake-modulesideeffects';
388const URL_WATCH = 'configuration-options/#watch';
389const URL_GENERATEBUNDLE = 'plugin-development/#generatebundle';
390
391function error(base) {
392 throw base instanceof Error ? base : getRollupError(base);
393}
394function getRollupError(base) {
395 augmentLogMessage(base);
396 const errorInstance = Object.assign(new Error(base.message), base);
397 Object.defineProperty(errorInstance, 'name', {
398 value: 'RollupError',
399 writable: true
400 });
401 return errorInstance;
402}
403function augmentCodeLocation(properties, pos, source, id) {
404 if (typeof pos === 'object') {
405 const { line, column } = pos;
406 properties.loc = { column, file: id, line };
407 }
408 else {
409 properties.pos = pos;
410 const location = locate(source, pos, { offsetLine: 1 });
411 if (!location) {
412 return;
413 }
414 const { line, column } = location;
415 properties.loc = { column, file: id, line };
416 }
417 if (properties.frame === undefined) {
418 const { line, column } = properties.loc;
419 properties.frame = getCodeFrame(source, line, column);
420 }
421}
422const symbolAugmented = Symbol('augmented');
423function augmentLogMessage(log) {
424 // Make sure to only augment the log message once
425 if (!(log.plugin || log.loc) || log[symbolAugmented]) {
426 return;
427 }
428 log[symbolAugmented] = true;
429 let prefix = '';
430 if (log.plugin) {
431 prefix += `[plugin ${log.plugin}] `;
432 }
433 const id = log.id || log.loc?.file;
434 if (id) {
435 const position = log.loc ? ` (${log.loc.line}:${log.loc.column})` : '';
436 prefix += `${relativeId(id)}${position}: `;
437 }
438 const oldMessage = log.message;
439 log.message = prefix + log.message;
440 tweakStackMessage(log, oldMessage);
441}
442// Error codes should be sorted alphabetically while errors should be sorted by
443// error code below
444const ADDON_ERROR = 'ADDON_ERROR', ALREADY_CLOSED = 'ALREADY_CLOSED', AMBIGUOUS_EXTERNAL_NAMESPACES = 'AMBIGUOUS_EXTERNAL_NAMESPACES', ANONYMOUS_PLUGIN_CACHE = 'ANONYMOUS_PLUGIN_CACHE', ASSET_NOT_FINALISED = 'ASSET_NOT_FINALISED', ASSET_NOT_FOUND = 'ASSET_NOT_FOUND', ASSET_SOURCE_ALREADY_SET = 'ASSET_SOURCE_ALREADY_SET', ASSET_SOURCE_MISSING = 'ASSET_SOURCE_MISSING', BAD_LOADER = 'BAD_LOADER', CANNOT_CALL_NAMESPACE = 'CANNOT_CALL_NAMESPACE', CANNOT_EMIT_FROM_OPTIONS_HOOK = 'CANNOT_EMIT_FROM_OPTIONS_HOOK', CHUNK_NOT_GENERATED = 'CHUNK_NOT_GENERATED', CHUNK_INVALID = 'CHUNK_INVALID', CIRCULAR_DEPENDENCY = 'CIRCULAR_DEPENDENCY', CIRCULAR_REEXPORT = 'CIRCULAR_REEXPORT', CONST_REASSIGN = 'CONST_REASSIGN', CYCLIC_CROSS_CHUNK_REEXPORT = 'CYCLIC_CROSS_CHUNK_REEXPORT', DEPRECATED_FEATURE = 'DEPRECATED_FEATURE', DUPLICATE_ARGUMENT_NAME = 'DUPLICATE_ARGUMENT_NAME', DUPLICATE_EXPORT = 'DUPLICATE_EXPORT', DUPLICATE_PLUGIN_NAME = 'DUPLICATE_PLUGIN_NAME', EMPTY_BUNDLE = 'EMPTY_BUNDLE', EVAL = 'EVAL', EXTERNAL_MODULES_CANNOT_BE_INCLUDED_IN_MANUAL_CHUNKS = 'EXTERNAL_MODULES_CANNOT_BE_INCLUDED_IN_MANUAL_CHUNKS', EXTERNAL_MODULES_CANNOT_BE_TRANSFORMED_TO_MODULES = 'EXTERNAL_MODULES_CANNOT_BE_TRANSFORMED_TO_MODULES', EXTERNAL_SYNTHETIC_EXPORTS = 'EXTERNAL_SYNTHETIC_EXPORTS', FILE_NAME_CONFLICT = 'FILE_NAME_CONFLICT', FILE_NOT_FOUND = 'FILE_NOT_FOUND', FIRST_SIDE_EFFECT = 'FIRST_SIDE_EFFECT', ILLEGAL_IDENTIFIER_AS_NAME = 'ILLEGAL_IDENTIFIER_AS_NAME', ILLEGAL_REASSIGNMENT = 'ILLEGAL_REASSIGNMENT', INCONSISTENT_IMPORT_ATTRIBUTES = 'INCONSISTENT_IMPORT_ATTRIBUTES', INVALID_ANNOTATION = 'INVALID_ANNOTATION', INPUT_HOOK_IN_OUTPUT_PLUGIN = 'INPUT_HOOK_IN_OUTPUT_PLUGIN', INVALID_CHUNK = 'INVALID_CHUNK', INVALID_EXPORT_OPTION = 'INVALID_EXPORT_OPTION', INVALID_EXTERNAL_ID = 'INVALID_EXTERNAL_ID', INVALID_IMPORT_ATTRIBUTE = 'INVALID_IMPORT_ATTRIBUTE', INVALID_LOG_POSITION = 'INVALID_LOG_POSITION', INVALID_OPTION = 'INVALID_OPTION', INVALID_PLUGIN_HOOK = 'INVALID_PLUGIN_HOOK', INVALID_ROLLUP_PHASE = 'INVALID_ROLLUP_PHASE', INVALID_SETASSETSOURCE = 'INVALID_SETASSETSOURCE', INVALID_TLA_FORMAT = 'INVALID_TLA_FORMAT', MISSING_EXPORT = 'MISSING_EXPORT', MISSING_GLOBAL_NAME = 'MISSING_GLOBAL_NAME', MISSING_IMPLICIT_DEPENDANT = 'MISSING_IMPLICIT_DEPENDANT', MISSING_JSX_EXPORT = 'MISSING_JSX_EXPORT', MISSING_NAME_OPTION_FOR_IIFE_EXPORT = 'MISSING_NAME_OPTION_FOR_IIFE_EXPORT', MISSING_NODE_BUILTINS = 'MISSING_NODE_BUILTINS', MISSING_OPTION = 'MISSING_OPTION', MIXED_EXPORTS = 'MIXED_EXPORTS', MODULE_LEVEL_DIRECTIVE = 'MODULE_LEVEL_DIRECTIVE', NAMESPACE_CONFLICT = 'NAMESPACE_CONFLICT', NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE = 'NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE', OPTIMIZE_CHUNK_STATUS = 'OPTIMIZE_CHUNK_STATUS', PARSE_ERROR = 'PARSE_ERROR', PLUGIN_ERROR = 'PLUGIN_ERROR', REDECLARATION_ERROR = 'REDECLARATION_ERROR', RESERVED_NAMESPACE = 'RESERVED_NAMESPACE', SHIMMED_EXPORT = 'SHIMMED_EXPORT', SOURCEMAP_BROKEN = 'SOURCEMAP_BROKEN', SOURCEMAP_ERROR = 'SOURCEMAP_ERROR', SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT = 'SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT', THIS_IS_UNDEFINED = 'THIS_IS_UNDEFINED', UNEXPECTED_NAMED_IMPORT = 'UNEXPECTED_NAMED_IMPORT', UNKNOWN_OPTION = 'UNKNOWN_OPTION', UNRESOLVED_ENTRY = 'UNRESOLVED_ENTRY', UNRESOLVED_IMPORT = 'UNRESOLVED_IMPORT', UNUSED_EXTERNAL_IMPORT = 'UNUSED_EXTERNAL_IMPORT', VALIDATION_ERROR = 'VALIDATION_ERROR';
445function logAddonNotGenerated(message, hook, plugin) {
446 return {
447 code: ADDON_ERROR,
448 message: `Could not retrieve "${hook}". Check configuration of plugin "${plugin}".
449\tError Message: ${message}`
450 };
451}
452function logAlreadyClosed() {
453 return {
454 code: ALREADY_CLOSED,
455 message: 'Bundle is already closed, no more calls to "generate" or "write" are allowed.'
456 };
457}
458function logAmbiguousExternalNamespaces(binding, reexportingModule, usedModule, sources) {
459 return {
460 binding,
461 code: AMBIGUOUS_EXTERNAL_NAMESPACES,
462 ids: sources,
463 message: `Ambiguous external namespace resolution: "${relativeId(reexportingModule)}" re-exports "${binding}" from one of the external modules ${printQuotedStringList(sources.map(module => relativeId(module)))}, guessing "${relativeId(usedModule)}".`,
464 reexporter: reexportingModule
465 };
466}
467function logAnonymousPluginCache() {
468 return {
469 code: ANONYMOUS_PLUGIN_CACHE,
470 message: 'A plugin is trying to use the Rollup cache but is not declaring a plugin name or cacheKey.'
471 };
472}
473function logAssetNotFinalisedForFileName(name) {
474 return {
475 code: ASSET_NOT_FINALISED,
476 message: `Plugin error - Unable to get file name for asset "${name}". Ensure that the source is set and that generate is called first. If you reference assets via import.meta.ROLLUP_FILE_URL_<referenceId>, you need to either have set their source after "renderStart" or need to provide an explicit "fileName" when emitting them.`
477 };
478}
479function logAssetReferenceIdNotFoundForSetSource(assetReferenceId) {
480 return {
481 code: ASSET_NOT_FOUND,
482 message: `Plugin error - Unable to set the source for unknown asset "${assetReferenceId}".`
483 };
484}
485function logAssetSourceAlreadySet(name) {
486 return {
487 code: ASSET_SOURCE_ALREADY_SET,
488 message: `Unable to set the source for asset "${name}", source already set.`
489 };
490}
491function logNoAssetSourceSet(assetName) {
492 return {
493 code: ASSET_SOURCE_MISSING,
494 message: `Plugin error creating asset "${assetName}" - no asset source set.`
495 };
496}
497function logBadLoader(id) {
498 return {
499 code: BAD_LOADER,
500 message: `Error loading "${relativeId(id)}": plugin load hook should return a string, a { code, map } object, or nothing/null.`
501 };
502}
503function logCannotCallNamespace(name) {
504 return {
505 code: CANNOT_CALL_NAMESPACE,
506 message: `Cannot call a namespace ("${name}").`
507 };
508}
509function logCannotEmitFromOptionsHook() {
510 return {
511 code: CANNOT_EMIT_FROM_OPTIONS_HOOK,
512 message: `Cannot emit files or set asset sources in the "outputOptions" hook, use the "renderStart" hook instead.`
513 };
514}
515function logChunkNotGeneratedForFileName(name) {
516 return {
517 code: CHUNK_NOT_GENERATED,
518 message: `Plugin error - Unable to get file name for emitted chunk "${name}". You can only get file names once chunks have been generated after the "renderStart" hook.`
519 };
520}
521function logChunkInvalid({ fileName, code }, { pos, message }) {
522 const errorProperties = {
523 code: CHUNK_INVALID,
524 message: `Chunk "${fileName}" is not valid JavaScript: ${message}.`
525 };
526 augmentCodeLocation(errorProperties, pos, code, fileName);
527 return errorProperties;
528}
529function logCircularDependency(cyclePath) {
530 return {
531 code: CIRCULAR_DEPENDENCY,
532 ids: cyclePath,
533 message: `Circular dependency: ${cyclePath.map(relativeId).join(' -> ')}`
534 };
535}
536function logCircularReexport(exportName, exporter) {
537 return {
538 code: CIRCULAR_REEXPORT,
539 exporter,
540 message: `"${exportName}" cannot be exported from "${relativeId(exporter)}" as it is a reexport that references itself.`
541 };
542}
543function logCyclicCrossChunkReexport(exportName, exporter, reexporter, importer, preserveModules) {
544 return {
545 code: CYCLIC_CROSS_CHUNK_REEXPORT,
546 exporter,
547 id: importer,
548 message: `Export "${exportName}" of module "${relativeId(exporter)}" was reexported through module "${relativeId(reexporter)}" while both modules are dependencies of each other and will end up in different chunks by current Rollup settings. This scenario is not well supported at the moment as it will produce a circular dependency between chunks and will likely lead to broken execution order.\nEither change the import in "${relativeId(importer)}" to point directly to the exporting module or ${preserveModules ? 'do not use "output.preserveModules"' : 'reconfigure "output.manualChunks"'} to ensure these modules end up in the same chunk.`,
549 reexporter
550 };
551}
552function logDeprecation(deprecation, urlSnippet, plugin) {
553 return {
554 code: DEPRECATED_FEATURE,
555 message: deprecation,
556 url: getRollupUrl(urlSnippet),
557 ...({})
558 };
559}
560function logConstVariableReassignError() {
561 return {
562 code: CONST_REASSIGN,
563 message: 'Cannot reassign a variable declared with `const`'
564 };
565}
566function logDuplicateArgumentNameError(name) {
567 return {
568 code: DUPLICATE_ARGUMENT_NAME,
569 message: `Duplicate argument name "${name}"`
570 };
571}
572function logDuplicateExportError(name) {
573 return { code: DUPLICATE_EXPORT, message: `Duplicate export "${name}"` };
574}
575function logDuplicatePluginName(plugin) {
576 return {
577 code: DUPLICATE_PLUGIN_NAME,
578 message: `The plugin name ${plugin} is being used twice in the same build. Plugin names must be distinct or provide a cacheKey (please post an issue to the plugin if you are a plugin user).`
579 };
580}
581function logEmptyChunk(chunkName) {
582 return {
583 code: EMPTY_BUNDLE,
584 message: `Generated an empty chunk: "${chunkName}".`,
585 names: [chunkName]
586 };
587}
588function logEval(id) {
589 return {
590 code: EVAL,
591 id,
592 message: `Use of eval in "${relativeId(id)}" is strongly discouraged as it poses security risks and may cause issues with minification.`,
593 url: getRollupUrl(URL_AVOIDING_EVAL)
594 };
595}
596function logExternalSyntheticExports(id, importer) {
597 return {
598 code: EXTERNAL_SYNTHETIC_EXPORTS,
599 exporter: id,
600 message: `External "${id}" cannot have "syntheticNamedExports" enabled (imported by "${relativeId(importer)}").`
601 };
602}
603function logFileNameConflict(fileName) {
604 return {
605 code: FILE_NAME_CONFLICT,
606 message: `The emitted file "${fileName}" overwrites a previously emitted file of the same name.`
607 };
608}
609function logFileReferenceIdNotFoundForFilename(assetReferenceId) {
610 return {
611 code: FILE_NOT_FOUND,
612 message: `Plugin error - Unable to get file name for unknown file "${assetReferenceId}".`
613 };
614}
615function logFirstSideEffect(source, id, { line, column }) {
616 return {
617 code: FIRST_SIDE_EFFECT,
618 message: `First side effect in ${relativeId(id)} is at (${line}:${column})\n${getCodeFrame(source, line, column)}`
619 };
620}
621function logIllegalIdentifierAsName(name) {
622 return {
623 code: ILLEGAL_IDENTIFIER_AS_NAME,
624 message: `Given name "${name}" is not a legal JS identifier. If you need this, you can try "output.extend: true".`,
625 url: getRollupUrl(URL_OUTPUT_EXTEND)
626 };
627}
628function logIllegalImportReassignment(name, importingId) {
629 return {
630 code: ILLEGAL_REASSIGNMENT,
631 message: `Illegal reassignment of import "${name}" in "${relativeId(importingId)}".`
632 };
633}
634function logInconsistentImportAttributes(existingAttributes, newAttributes, source, importer) {
635 return {
636 code: INCONSISTENT_IMPORT_ATTRIBUTES,
637 message: `Module "${relativeId(importer)}" tried to import "${relativeId(source)}" with ${formatAttributes(newAttributes)} attributes, but it was already imported elsewhere with ${formatAttributes(existingAttributes)} attributes. Please ensure that import attributes for the same module are always consistent.`
638 };
639}
640const formatAttributes = (attributes) => {
641 const entries = Object.entries(attributes);
642 if (entries.length === 0)
643 return 'no';
644 return entries.map(([key, value]) => `"${key}": "${value}"`).join(', ');
645};
646function logInvalidAnnotation(comment, id, type) {
647 return {
648 code: INVALID_ANNOTATION,
649 id,
650 message: `A comment\n\n"${comment}"\n\nin "${relativeId(id)}" contains an annotation that Rollup cannot interpret due to the position of the comment. The comment will be removed to avoid issues.`,
651 url: getRollupUrl(type === 'noSideEffects' ? URL_TREESHAKE_NOSIDEEFFECTS : URL_TREESHAKE_PURE)
652 };
653}
654function logInputHookInOutputPlugin(pluginName, hookName) {
655 return {
656 code: INPUT_HOOK_IN_OUTPUT_PLUGIN,
657 message: `The "${hookName}" hook used by the output plugin ${pluginName} is a build time hook and will not be run for that plugin. Either this plugin cannot be used as an output plugin, or it should have an option to configure it as an output plugin.`
658 };
659}
660function logCannotAssignModuleToChunk(moduleId, assignToAlias, currentAlias) {
661 return {
662 code: INVALID_CHUNK,
663 message: `Cannot assign "${relativeId(moduleId)}" to the "${assignToAlias}" chunk as it is already in the "${currentAlias}" chunk.`
664 };
665}
666function tweakStackMessage(error, oldMessage) {
667 if (!error.stack) {
668 return error;
669 }
670 error.stack = error.stack.replace(oldMessage, error.message);
671 return error;
672}
673function logInvalidExportOptionValue(optionValue) {
674 return {
675 code: INVALID_EXPORT_OPTION,
676 message: `"output.exports" must be "default", "named", "none", "auto", or left unspecified (defaults to "auto"), received "${optionValue}".`,
677 url: getRollupUrl(URL_OUTPUT_EXPORTS)
678 };
679}
680function logIncompatibleExportOptionValue(optionValue, keys, entryModule) {
681 return {
682 code: INVALID_EXPORT_OPTION,
683 message: `"${optionValue}" was specified for "output.exports", but entry module "${relativeId(entryModule)}" has the following exports: ${printQuotedStringList(keys)}`,
684 url: getRollupUrl(URL_OUTPUT_EXPORTS)
685 };
686}
687function logInternalIdCannotBeExternal(source, importer) {
688 return {
689 code: INVALID_EXTERNAL_ID,
690 message: `"${source}" is imported as an external by "${relativeId(importer)}", but is already an existing non-external module id.`
691 };
692}
693function logImportOptionsAreInvalid(importer) {
694 return {
695 code: INVALID_IMPORT_ATTRIBUTE,
696 message: `Rollup could not statically analyze the options argument of a dynamic import in "${relativeId(importer)}". Dynamic import options need to be an object with a nested attributes object.`
697 };
698}
699function logImportAttributeIsInvalid(importer) {
700 return {
701 code: INVALID_IMPORT_ATTRIBUTE,
702 message: `Rollup could not statically analyze an import attribute of a dynamic import in "${relativeId(importer)}". Import attributes need to have string keys and values. The attribute will be removed.`
703 };
704}
705function logInvalidLogPosition(plugin) {
706 return {
707 code: INVALID_LOG_POSITION,
708 message: `Plugin "${plugin}" tried to add a file position to a log or warning. This is only supported in the "transform" hook at the moment and will be ignored.`
709 };
710}
711function logInvalidOption(option, urlSnippet, explanation, value) {
712 return {
713 code: INVALID_OPTION,
714 message: `Invalid value ${value === undefined ? '' : `${JSON.stringify(value)} `}for option "${option}" - ${explanation}.`,
715 url: getRollupUrl(urlSnippet)
716 };
717}
718function logInvalidAddonPluginHook(hook, plugin) {
719 return {
720 code: INVALID_PLUGIN_HOOK,
721 hook,
722 message: `Error running plugin hook "${hook}" for plugin "${plugin}", expected a string, a function hook or an object with a "handler" string or function.`,
723 plugin
724 };
725}
726function logInvalidFunctionPluginHook(hook, plugin) {
727 return {
728 code: INVALID_PLUGIN_HOOK,
729 hook,
730 message: `Error running plugin hook "${hook}" for plugin "${plugin}", expected a function hook or an object with a "handler" function.`,
731 plugin
732 };
733}
734function logInvalidRollupPhaseForChunkEmission() {
735 return {
736 code: INVALID_ROLLUP_PHASE,
737 message: `Cannot emit chunks after module loading has finished.`
738 };
739}
740function logInvalidSetAssetSourceCall() {
741 return {
742 code: INVALID_SETASSETSOURCE,
743 message: `setAssetSource cannot be called in transform for caching reasons. Use emitFile with a source, or call setAssetSource in another hook.`
744 };
745}
746function logInvalidFormatForTopLevelAwait(id, format) {
747 return {
748 code: INVALID_TLA_FORMAT,
749 id,
750 message: `Module format "${format}" does not support top-level await. Use the "es" or "system" output formats rather.`
751 };
752}
753function logMissingEntryExport(binding, exporter) {
754 return {
755 binding,
756 code: MISSING_EXPORT,
757 exporter,
758 message: `Exported variable "${binding}" is not defined in "${relativeId(exporter)}".`,
759 url: getRollupUrl(URL_NAME_IS_NOT_EXPORTED)
760 };
761}
762function logMissingExport(binding, importingModule, exporter) {
763 const isJson = extname(exporter) === '.json';
764 return {
765 binding,
766 code: MISSING_EXPORT,
767 exporter,
768 id: importingModule,
769 message: `"${binding}" is not exported by "${relativeId(exporter)}", imported by "${relativeId(importingModule)}".${isJson ? ' (Note that you need @rollup/plugin-json to import JSON files)' : ''}`,
770 url: getRollupUrl(URL_NAME_IS_NOT_EXPORTED)
771 };
772}
773function logMissingGlobalName(externalId, guess) {
774 return {
775 code: MISSING_GLOBAL_NAME,
776 id: externalId,
777 message: `No name was provided for external module "${externalId}" in "output.globals" – guessing "${guess}".`,
778 names: [guess],
779 url: getRollupUrl(URL_OUTPUT_GLOBALS)
780 };
781}
782function logImplicitDependantCannotBeExternal(unresolvedId, implicitlyLoadedBefore) {
783 return {
784 code: MISSING_IMPLICIT_DEPENDANT,
785 message: `Module "${relativeId(unresolvedId)}" that should be implicitly loaded before "${relativeId(implicitlyLoadedBefore)}" cannot be external.`
786 };
787}
788function logUnresolvedImplicitDependant(unresolvedId, implicitlyLoadedBefore) {
789 return {
790 code: MISSING_IMPLICIT_DEPENDANT,
791 message: `Module "${relativeId(unresolvedId)}" that should be implicitly loaded before "${relativeId(implicitlyLoadedBefore)}" could not be resolved.`
792 };
793}
794function logImplicitDependantIsNotIncluded(module) {
795 const implicitDependencies = [...module.implicitlyLoadedBefore]
796 .map(dependency => relativeId(dependency.id))
797 .sort();
798 return {
799 code: MISSING_IMPLICIT_DEPENDANT,
800 message: `Module "${relativeId(module.id)}" that should be implicitly loaded before ${printQuotedStringList(implicitDependencies)} is not included in the module graph. Either it was not imported by an included module or only via a tree-shaken dynamic import, or no imported bindings were used and it had otherwise no side-effects.`
801 };
802}
803function logMissingJsxExport(name, exporter, importer) {
804 return {
805 code: MISSING_JSX_EXPORT,
806 exporter,
807 id: importer,
808 message: `Export "${name}" is not defined in module "${relativeId(exporter)}" even though it is needed in "${relativeId(importer)}" to provide JSX syntax. Please check your "jsx" option.`,
809 names: [name],
810 url: getRollupUrl(URL_JSX)
811 };
812}
813function logMissingNameOptionForIifeExport() {
814 return {
815 code: MISSING_NAME_OPTION_FOR_IIFE_EXPORT,
816 message: `If you do not supply "output.name", you may not be able to access the exports of an IIFE bundle.`,
817 url: getRollupUrl(URL_OUTPUT_NAME)
818 };
819}
820function logMissingNameOptionForUmdExport() {
821 return {
822 code: MISSING_NAME_OPTION_FOR_IIFE_EXPORT,
823 message: 'You must supply "output.name" for UMD bundles that have exports so that the exports are accessible in environments without a module loader.',
824 url: getRollupUrl(URL_OUTPUT_NAME)
825 };
826}
827function logMissingNodeBuiltins(externalBuiltins) {
828 return {
829 code: MISSING_NODE_BUILTINS,
830 ids: externalBuiltins,
831 message: `Creating a browser bundle that depends on Node.js built-in modules (${printQuotedStringList(externalBuiltins)}). You might need to include https://github.com/FredKSchott/rollup-plugin-polyfill-node`
832 };
833}
834function logMissingFileOrDirOption() {
835 return {
836 code: MISSING_OPTION,
837 message: 'You must specify "output.file" or "output.dir" for the build.',
838 url: getRollupUrl(URL_OUTPUT_DIR)
839 };
840}
841function logMixedExport(facadeModuleId, name) {
842 return {
843 code: MIXED_EXPORTS,
844 id: facadeModuleId,
845 message: `Entry module "${relativeId(facadeModuleId)}" is using named and default exports together. Consumers of your bundle will have to use \`${name || 'chunk'}.default\` to access the default export, which may not be what you want. Use \`output.exports: "named"\` to disable this warning.`,
846 url: getRollupUrl(URL_OUTPUT_EXPORTS)
847 };
848}
849function logModuleLevelDirective(directive, id) {
850 return {
851 code: MODULE_LEVEL_DIRECTIVE,
852 id,
853 message: `Module level directives cause errors when bundled, "${directive}" in "${relativeId(id)}" was ignored.`
854 };
855}
856function logNamespaceConflict(binding, reexportingModuleId, sources) {
857 return {
858 binding,
859 code: NAMESPACE_CONFLICT,
860 ids: sources,
861 message: `Conflicting namespaces: "${relativeId(reexportingModuleId)}" re-exports "${binding}" from one of the modules ${printQuotedStringList(sources.map(moduleId => relativeId(moduleId)))} (will be ignored).`,
862 reexporter: reexportingModuleId
863 };
864}
865function logNoTransformMapOrAstWithoutCode(pluginName) {
866 return {
867 code: NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE,
868 message: `The plugin "${pluginName}" returned a "map" or "ast" without returning ` +
869 'a "code". This will be ignored.'
870 };
871}
872function logOptimizeChunkStatus(chunks, smallChunks, pointInTime) {
873 return {
874 code: OPTIMIZE_CHUNK_STATUS,
875 message: `${pointInTime}, there are\n` +
876 `${chunks} chunks, of which\n` +
877 `${smallChunks} are below minChunkSize.`
878 };
879}
880function logParseError(message, pos) {
881 return { code: PARSE_ERROR, message, pos };
882}
883function logRedeclarationError(name) {
884 return {
885 code: REDECLARATION_ERROR,
886 message: `Identifier "${name}" has already been declared`
887 };
888}
889function logReservedNamespace(namespace) {
890 return {
891 code: RESERVED_NAMESPACE,
892 message: `You have overided reserved namespace "${namespace}"`
893 };
894}
895function logModuleParseError(error, moduleId) {
896 let message = error.message.replace(/ \(\d+:\d+\)$/, '');
897 if (moduleId.endsWith('.json')) {
898 message += ' (Note that you need @rollup/plugin-json to import JSON files)';
899 }
900 else if (!moduleId.endsWith('.js')) {
901 message += ' (Note that you need plugins to import files that are not JavaScript)';
902 }
903 return tweakStackMessage({
904 cause: error,
905 code: PARSE_ERROR,
906 id: moduleId,
907 message,
908 stack: error.stack
909 }, error.message);
910}
911function logPluginError(error, plugin, { hook, id } = {}) {
912 const code = error.code;
913 if (!error.pluginCode &&
914 code != null &&
915 (typeof code !== 'string' || !code.startsWith('PLUGIN_'))) {
916 error.pluginCode = code;
917 }
918 error.code = PLUGIN_ERROR;
919 error.plugin = plugin;
920 if (hook) {
921 error.hook = hook;
922 }
923 if (id) {
924 error.id = id;
925 }
926 return error;
927}
928function logShimmedExport(id, binding) {
929 return {
930 binding,
931 code: SHIMMED_EXPORT,
932 exporter: id,
933 message: `Missing export "${binding}" has been shimmed in module "${relativeId(id)}".`
934 };
935}
936function logSourcemapBroken(plugin) {
937 return {
938 code: SOURCEMAP_BROKEN,
939 message: `Sourcemap is likely to be incorrect: a plugin (${plugin}) was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help`,
940 plugin,
941 url: getRollupUrl(URL_SOURCEMAP_IS_LIKELY_TO_BE_INCORRECT)
942 };
943}
944function logConflictingSourcemapSources(filename) {
945 return {
946 code: SOURCEMAP_BROKEN,
947 message: `Multiple conflicting contents for sourcemap source ${filename}`
948 };
949}
950function logInvalidSourcemapForError(error, id, column, line, pos) {
951 return {
952 cause: error,
953 code: SOURCEMAP_ERROR,
954 id,
955 loc: {
956 column,
957 file: id,
958 line
959 },
960 message: `Error when using sourcemap for reporting an error: ${error.message}`,
961 pos
962 };
963}
964function logSyntheticNamedExportsNeedNamespaceExport(id, syntheticNamedExportsOption) {
965 return {
966 code: SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT,
967 exporter: id,
968 message: `Module "${relativeId(id)}" that is marked with \`syntheticNamedExports: ${JSON.stringify(syntheticNamedExportsOption)}\` needs ${typeof syntheticNamedExportsOption === 'string' && syntheticNamedExportsOption !== 'default'
969 ? `an explicit export named "${syntheticNamedExportsOption}"`
970 : 'a default export'} that does not reexport an unresolved named export of the same module.`
971 };
972}
973function logThisIsUndefined() {
974 return {
975 code: THIS_IS_UNDEFINED,
976 message: `The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten`,
977 url: getRollupUrl(URL_THIS_IS_UNDEFINED)
978 };
979}
980function logUnexpectedNamedImport(id, imported, isReexport) {
981 const importType = isReexport ? 'reexport' : 'import';
982 return {
983 code: UNEXPECTED_NAMED_IMPORT,
984 exporter: id,
985 message: `The named export "${imported}" was ${importType}ed from the external module "${relativeId(id)}" even though its interop type is "defaultOnly". Either remove or change this ${importType} or change the value of the "output.interop" option.`,
986 url: getRollupUrl(URL_OUTPUT_INTEROP)
987 };
988}
989function logUnexpectedNamespaceReexport(id) {
990 return {
991 code: UNEXPECTED_NAMED_IMPORT,
992 exporter: id,
993 message: `There was a namespace "*" reexport from the external module "${relativeId(id)}" even though its interop type is "defaultOnly". This will be ignored as namespace reexports only reexport named exports. If this is not intended, either remove or change this reexport or change the value of the "output.interop" option.`,
994 url: getRollupUrl(URL_OUTPUT_INTEROP)
995 };
996}
997function logUnknownOption(optionType, unknownOptions, validOptions) {
998 return {
999 code: UNKNOWN_OPTION,
1000 message: `Unknown ${optionType}: ${unknownOptions.join(', ')}. Allowed options: ${validOptions.join(', ')}`
1001 };
1002}
1003function logEntryCannotBeExternal(unresolvedId) {
1004 return {
1005 code: UNRESOLVED_ENTRY,
1006 message: `Entry module "${relativeId(unresolvedId)}" cannot be external.`
1007 };
1008}
1009function logExternalModulesCannotBeIncludedInManualChunks(source) {
1010 return {
1011 code: EXTERNAL_MODULES_CANNOT_BE_INCLUDED_IN_MANUAL_CHUNKS,
1012 message: `"${source}" cannot be included in manualChunks because it is resolved as an external module by the "external" option or plugins.`
1013 };
1014}
1015function logExternalModulesCannotBeTransformedToModules(source) {
1016 return {
1017 code: EXTERNAL_MODULES_CANNOT_BE_TRANSFORMED_TO_MODULES,
1018 message: `${source} is resolved as a module now, but it was an external module before. Please check whether there are conflicts in your Rollup options "external" and "manualChunks", manualChunks cannot include external modules.`
1019 };
1020}
1021function logUnresolvedEntry(unresolvedId) {
1022 return {
1023 code: UNRESOLVED_ENTRY,
1024 message: `Could not resolve entry module "${relativeId(unresolvedId)}".`
1025 };
1026}
1027function logUnresolvedImport(source, importer) {
1028 return {
1029 code: UNRESOLVED_IMPORT,
1030 exporter: source,
1031 id: importer,
1032 message: `Could not resolve "${source}" from "${relativeId(importer)}"`
1033 };
1034}
1035function logUnresolvedImportTreatedAsExternal(source, importer) {
1036 return {
1037 code: UNRESOLVED_IMPORT,
1038 exporter: source,
1039 id: importer,
1040 message: `"${source}" is imported by "${relativeId(importer)}", but could not be resolved – treating it as an external dependency.`,
1041 url: getRollupUrl(URL_TREATING_MODULE_AS_EXTERNAL_DEPENDENCY)
1042 };
1043}
1044function logUnusedExternalImports(externalId, names, importers) {
1045 return {
1046 code: UNUSED_EXTERNAL_IMPORT,
1047 exporter: externalId,
1048 ids: importers,
1049 message: `${printQuotedStringList(names, [
1050 'is',
1051 'are'
1052 ])} imported from external module "${externalId}" but never used in ${printQuotedStringList(importers.map(importer => relativeId(importer)))}.`,
1053 names
1054 };
1055}
1056function logFailedValidation(message) {
1057 return {
1058 code: VALIDATION_ERROR,
1059 message
1060 };
1061}
1062function warnDeprecation(deprecation, urlSnippet, activeDeprecation, options, plugin) {
1063 warnDeprecationWithOptions(deprecation, urlSnippet, activeDeprecation, options.onLog, options.strictDeprecations);
1064}
1065function warnDeprecationWithOptions(deprecation, urlSnippet, activeDeprecation, log, strictDeprecations, plugin) {
1066 if (activeDeprecation || strictDeprecations) {
1067 const warning = logDeprecation(deprecation, urlSnippet);
1068 if (strictDeprecations) {
1069 return error(warning);
1070 }
1071 log(LOGLEVEL_WARN, warning);
1072 }
1073}
1074
1075// This file is generated by scripts/generate-buffer-to-ast.js.
1076// Do not edit this file directly.
1077function convertProgram(buffer) {
1078 const node = convertNode(0, buffer);
1079 switch (node.type) {
1080 case PanicError: {
1081 return error(getRollupError(logParseError(node.message)));
1082 }
1083 case ParseError: {
1084 return error(getRollupError(logParseError(node.message, node.start)));
1085 }
1086 default: {
1087 return node;
1088 }
1089 }
1090}
1091/* eslint-disable sort-keys */
1092const nodeConverters = [
1093 function panicError(position, buffer) {
1094 return {
1095 type: 'PanicError',
1096 start: buffer[position],
1097 end: buffer[position + 1],
1098 message: buffer.convertString(buffer[position + 2])
1099 };
1100 },
1101 function parseError(position, buffer) {
1102 return {
1103 type: 'ParseError',
1104 start: buffer[position],
1105 end: buffer[position + 1],
1106 message: buffer.convertString(buffer[position + 2])
1107 };
1108 },
1109 function arrayExpression(position, buffer) {
1110 return {
1111 type: 'ArrayExpression',
1112 start: buffer[position],
1113 end: buffer[position + 1],
1114 elements: convertNodeList(buffer[position + 2], buffer)
1115 };
1116 },
1117 function arrayPattern(position, buffer) {
1118 return {
1119 type: 'ArrayPattern',
1120 start: buffer[position],
1121 end: buffer[position + 1],
1122 elements: convertNodeList(buffer[position + 2], buffer)
1123 };
1124 },
1125 function arrowFunctionExpression(position, buffer) {
1126 const flags = buffer[position + 2];
1127 const annotations = convertAnnotations(buffer[position + 3], buffer);
1128 return {
1129 type: 'ArrowFunctionExpression',
1130 start: buffer[position],
1131 end: buffer[position + 1],
1132 async: (flags & 1) === 1,
1133 expression: (flags & 2) === 2,
1134 generator: (flags & 4) === 4,
1135 ...(annotations.length > 0 ? { [ANNOTATION_KEY]: annotations } : {}),
1136 params: convertNodeList(buffer[position + 4], buffer),
1137 body: convertNode(buffer[position + 5], buffer),
1138 id: null
1139 };
1140 },
1141 function assignmentExpression(position, buffer) {
1142 return {
1143 type: 'AssignmentExpression',
1144 start: buffer[position],
1145 end: buffer[position + 1],
1146 operator: FIXED_STRINGS[buffer[position + 2]],
1147 left: convertNode(buffer[position + 3], buffer),
1148 right: convertNode(buffer[position + 4], buffer)
1149 };
1150 },
1151 function assignmentPattern(position, buffer) {
1152 return {
1153 type: 'AssignmentPattern',
1154 start: buffer[position],
1155 end: buffer[position + 1],
1156 left: convertNode(buffer[position + 2], buffer),
1157 right: convertNode(buffer[position + 3], buffer)
1158 };
1159 },
1160 function awaitExpression(position, buffer) {
1161 return {
1162 type: 'AwaitExpression',
1163 start: buffer[position],
1164 end: buffer[position + 1],
1165 argument: convertNode(buffer[position + 2], buffer)
1166 };
1167 },
1168 function binaryExpression(position, buffer) {
1169 return {
1170 type: 'BinaryExpression',
1171 start: buffer[position],
1172 end: buffer[position + 1],
1173 operator: FIXED_STRINGS[buffer[position + 2]],
1174 left: convertNode(buffer[position + 3], buffer),
1175 right: convertNode(buffer[position + 4], buffer)
1176 };
1177 },
1178 function blockStatement(position, buffer) {
1179 return {
1180 type: 'BlockStatement',
1181 start: buffer[position],
1182 end: buffer[position + 1],
1183 body: convertNodeList(buffer[position + 2], buffer)
1184 };
1185 },
1186 function breakStatement(position, buffer) {
1187 const labelPosition = buffer[position + 2];
1188 return {
1189 type: 'BreakStatement',
1190 start: buffer[position],
1191 end: buffer[position + 1],
1192 label: labelPosition === 0 ? null : convertNode(labelPosition, buffer)
1193 };
1194 },
1195 function callExpression(position, buffer) {
1196 const flags = buffer[position + 2];
1197 const annotations = convertAnnotations(buffer[position + 3], buffer);
1198 return {
1199 type: 'CallExpression',
1200 start: buffer[position],
1201 end: buffer[position + 1],
1202 optional: (flags & 1) === 1,
1203 ...(annotations.length > 0 ? { [ANNOTATION_KEY]: annotations } : {}),
1204 callee: convertNode(buffer[position + 4], buffer),
1205 arguments: convertNodeList(buffer[position + 5], buffer)
1206 };
1207 },
1208 function catchClause(position, buffer) {
1209 const parameterPosition = buffer[position + 2];
1210 return {
1211 type: 'CatchClause',
1212 start: buffer[position],
1213 end: buffer[position + 1],
1214 param: parameterPosition === 0 ? null : convertNode(parameterPosition, buffer),
1215 body: convertNode(buffer[position + 3], buffer)
1216 };
1217 },
1218 function chainExpression(position, buffer) {
1219 return {
1220 type: 'ChainExpression',
1221 start: buffer[position],
1222 end: buffer[position + 1],
1223 expression: convertNode(buffer[position + 2], buffer)
1224 };
1225 },
1226 function classBody(position, buffer) {
1227 return {
1228 type: 'ClassBody',
1229 start: buffer[position],
1230 end: buffer[position + 1],
1231 body: convertNodeList(buffer[position + 2], buffer)
1232 };
1233 },
1234 function classDeclaration(position, buffer) {
1235 const idPosition = buffer[position + 3];
1236 const superClassPosition = buffer[position + 4];
1237 return {
1238 type: 'ClassDeclaration',
1239 start: buffer[position],
1240 end: buffer[position + 1],
1241 decorators: convertNodeList(buffer[position + 2], buffer),
1242 id: idPosition === 0 ? null : convertNode(idPosition, buffer),
1243 superClass: superClassPosition === 0 ? null : convertNode(superClassPosition, buffer),
1244 body: convertNode(buffer[position + 5], buffer)
1245 };
1246 },
1247 function classExpression(position, buffer) {
1248 const idPosition = buffer[position + 3];
1249 const superClassPosition = buffer[position + 4];
1250 return {
1251 type: 'ClassExpression',
1252 start: buffer[position],
1253 end: buffer[position + 1],
1254 decorators: convertNodeList(buffer[position + 2], buffer),
1255 id: idPosition === 0 ? null : convertNode(idPosition, buffer),
1256 superClass: superClassPosition === 0 ? null : convertNode(superClassPosition, buffer),
1257 body: convertNode(buffer[position + 5], buffer)
1258 };
1259 },
1260 function conditionalExpression(position, buffer) {
1261 return {
1262 type: 'ConditionalExpression',
1263 start: buffer[position],
1264 end: buffer[position + 1],
1265 test: convertNode(buffer[position + 2], buffer),
1266 consequent: convertNode(buffer[position + 3], buffer),
1267 alternate: convertNode(buffer[position + 4], buffer)
1268 };
1269 },
1270 function continueStatement(position, buffer) {
1271 const labelPosition = buffer[position + 2];
1272 return {
1273 type: 'ContinueStatement',
1274 start: buffer[position],
1275 end: buffer[position + 1],
1276 label: labelPosition === 0 ? null : convertNode(labelPosition, buffer)
1277 };
1278 },
1279 function debuggerStatement(position, buffer) {
1280 return {
1281 type: 'DebuggerStatement',
1282 start: buffer[position],
1283 end: buffer[position + 1]
1284 };
1285 },
1286 function decorator(position, buffer) {
1287 return {
1288 type: 'Decorator',
1289 start: buffer[position],
1290 end: buffer[position + 1],
1291 expression: convertNode(buffer[position + 2], buffer)
1292 };
1293 },
1294 function directive(position, buffer) {
1295 return {
1296 type: 'ExpressionStatement',
1297 start: buffer[position],
1298 end: buffer[position + 1],
1299 directive: buffer.convertString(buffer[position + 2]),
1300 expression: convertNode(buffer[position + 3], buffer)
1301 };
1302 },
1303 function doWhileStatement(position, buffer) {
1304 return {
1305 type: 'DoWhileStatement',
1306 start: buffer[position],
1307 end: buffer[position + 1],
1308 body: convertNode(buffer[position + 2], buffer),
1309 test: convertNode(buffer[position + 3], buffer)
1310 };
1311 },
1312 function emptyStatement(position, buffer) {
1313 return {
1314 type: 'EmptyStatement',
1315 start: buffer[position],
1316 end: buffer[position + 1]
1317 };
1318 },
1319 function exportAllDeclaration(position, buffer) {
1320 const exportedPosition = buffer[position + 2];
1321 return {
1322 type: 'ExportAllDeclaration',
1323 start: buffer[position],
1324 end: buffer[position + 1],
1325 exported: exportedPosition === 0 ? null : convertNode(exportedPosition, buffer),
1326 source: convertNode(buffer[position + 3], buffer),
1327 attributes: convertNodeList(buffer[position + 4], buffer)
1328 };
1329 },
1330 function exportDefaultDeclaration(position, buffer) {
1331 return {
1332 type: 'ExportDefaultDeclaration',
1333 start: buffer[position],
1334 end: buffer[position + 1],
1335 declaration: convertNode(buffer[position + 2], buffer)
1336 };
1337 },
1338 function exportNamedDeclaration(position, buffer) {
1339 const sourcePosition = buffer[position + 3];
1340 const declarationPosition = buffer[position + 5];
1341 return {
1342 type: 'ExportNamedDeclaration',
1343 start: buffer[position],
1344 end: buffer[position + 1],
1345 specifiers: convertNodeList(buffer[position + 2], buffer),
1346 source: sourcePosition === 0 ? null : convertNode(sourcePosition, buffer),
1347 attributes: convertNodeList(buffer[position + 4], buffer),
1348 declaration: declarationPosition === 0 ? null : convertNode(declarationPosition, buffer)
1349 };
1350 },
1351 function exportSpecifier(position, buffer) {
1352 const local = convertNode(buffer[position + 2], buffer);
1353 const exportedPosition = buffer[position + 3];
1354 return {
1355 type: 'ExportSpecifier',
1356 start: buffer[position],
1357 end: buffer[position + 1],
1358 local,
1359 exported: exportedPosition === 0 ? { ...local } : convertNode(exportedPosition, buffer)
1360 };
1361 },
1362 function expressionStatement(position, buffer) {
1363 return {
1364 type: 'ExpressionStatement',
1365 start: buffer[position],
1366 end: buffer[position + 1],
1367 expression: convertNode(buffer[position + 2], buffer)
1368 };
1369 },
1370 function forInStatement(position, buffer) {
1371 return {
1372 type: 'ForInStatement',
1373 start: buffer[position],
1374 end: buffer[position + 1],
1375 left: convertNode(buffer[position + 2], buffer),
1376 right: convertNode(buffer[position + 3], buffer),
1377 body: convertNode(buffer[position + 4], buffer)
1378 };
1379 },
1380 function forOfStatement(position, buffer) {
1381 const flags = buffer[position + 2];
1382 return {
1383 type: 'ForOfStatement',
1384 start: buffer[position],
1385 end: buffer[position + 1],
1386 await: (flags & 1) === 1,
1387 left: convertNode(buffer[position + 3], buffer),
1388 right: convertNode(buffer[position + 4], buffer),
1389 body: convertNode(buffer[position + 5], buffer)
1390 };
1391 },
1392 function forStatement(position, buffer) {
1393 const initPosition = buffer[position + 2];
1394 const testPosition = buffer[position + 3];
1395 const updatePosition = buffer[position + 4];
1396 return {
1397 type: 'ForStatement',
1398 start: buffer[position],
1399 end: buffer[position + 1],
1400 init: initPosition === 0 ? null : convertNode(initPosition, buffer),
1401 test: testPosition === 0 ? null : convertNode(testPosition, buffer),
1402 update: updatePosition === 0 ? null : convertNode(updatePosition, buffer),
1403 body: convertNode(buffer[position + 5], buffer)
1404 };
1405 },
1406 function functionDeclaration(position, buffer) {
1407 const flags = buffer[position + 2];
1408 const annotations = convertAnnotations(buffer[position + 3], buffer);
1409 const idPosition = buffer[position + 4];
1410 return {
1411 type: 'FunctionDeclaration',
1412 start: buffer[position],
1413 end: buffer[position + 1],
1414 async: (flags & 1) === 1,
1415 generator: (flags & 2) === 2,
1416 ...(annotations.length > 0 ? { [ANNOTATION_KEY]: annotations } : {}),
1417 id: idPosition === 0 ? null : convertNode(idPosition, buffer),
1418 params: convertNodeList(buffer[position + 5], buffer),
1419 body: convertNode(buffer[position + 6], buffer),
1420 expression: false
1421 };
1422 },
1423 function functionExpression(position, buffer) {
1424 const flags = buffer[position + 2];
1425 const annotations = convertAnnotations(buffer[position + 3], buffer);
1426 const idPosition = buffer[position + 4];
1427 return {
1428 type: 'FunctionExpression',
1429 start: buffer[position],
1430 end: buffer[position + 1],
1431 async: (flags & 1) === 1,
1432 generator: (flags & 2) === 2,
1433 ...(annotations.length > 0 ? { [ANNOTATION_KEY]: annotations } : {}),
1434 id: idPosition === 0 ? null : convertNode(idPosition, buffer),
1435 params: convertNodeList(buffer[position + 5], buffer),
1436 body: convertNode(buffer[position + 6], buffer),
1437 expression: false
1438 };
1439 },
1440 function identifier(position, buffer) {
1441 return {
1442 type: 'Identifier',
1443 start: buffer[position],
1444 end: buffer[position + 1],
1445 name: buffer.convertString(buffer[position + 2])
1446 };
1447 },
1448 function ifStatement(position, buffer) {
1449 const alternatePosition = buffer[position + 4];
1450 return {
1451 type: 'IfStatement',
1452 start: buffer[position],
1453 end: buffer[position + 1],
1454 test: convertNode(buffer[position + 2], buffer),
1455 consequent: convertNode(buffer[position + 3], buffer),
1456 alternate: alternatePosition === 0 ? null : convertNode(alternatePosition, buffer)
1457 };
1458 },
1459 function importAttribute(position, buffer) {
1460 return {
1461 type: 'ImportAttribute',
1462 start: buffer[position],
1463 end: buffer[position + 1],
1464 key: convertNode(buffer[position + 2], buffer),
1465 value: convertNode(buffer[position + 3], buffer)
1466 };
1467 },
1468 function importDeclaration(position, buffer) {
1469 return {
1470 type: 'ImportDeclaration',
1471 start: buffer[position],
1472 end: buffer[position + 1],
1473 specifiers: convertNodeList(buffer[position + 2], buffer),
1474 source: convertNode(buffer[position + 3], buffer),
1475 attributes: convertNodeList(buffer[position + 4], buffer)
1476 };
1477 },
1478 function importDefaultSpecifier(position, buffer) {
1479 return {
1480 type: 'ImportDefaultSpecifier',
1481 start: buffer[position],
1482 end: buffer[position + 1],
1483 local: convertNode(buffer[position + 2], buffer)
1484 };
1485 },
1486 function importExpression(position, buffer) {
1487 const optionsPosition = buffer[position + 3];
1488 return {
1489 type: 'ImportExpression',
1490 start: buffer[position],
1491 end: buffer[position + 1],
1492 source: convertNode(buffer[position + 2], buffer),
1493 options: optionsPosition === 0 ? null : convertNode(optionsPosition, buffer)
1494 };
1495 },
1496 function importNamespaceSpecifier(position, buffer) {
1497 return {
1498 type: 'ImportNamespaceSpecifier',
1499 start: buffer[position],
1500 end: buffer[position + 1],
1501 local: convertNode(buffer[position + 2], buffer)
1502 };
1503 },
1504 function importSpecifier(position, buffer) {
1505 const importedPosition = buffer[position + 2];
1506 const local = convertNode(buffer[position + 3], buffer);
1507 return {
1508 type: 'ImportSpecifier',
1509 start: buffer[position],
1510 end: buffer[position + 1],
1511 imported: importedPosition === 0 ? { ...local } : convertNode(importedPosition, buffer),
1512 local
1513 };
1514 },
1515 function jsxAttribute(position, buffer) {
1516 const valuePosition = buffer[position + 3];
1517 return {
1518 type: 'JSXAttribute',
1519 start: buffer[position],
1520 end: buffer[position + 1],
1521 name: convertNode(buffer[position + 2], buffer),
1522 value: valuePosition === 0 ? null : convertNode(valuePosition, buffer)
1523 };
1524 },
1525 function jsxClosingElement(position, buffer) {
1526 return {
1527 type: 'JSXClosingElement',
1528 start: buffer[position],
1529 end: buffer[position + 1],
1530 name: convertNode(buffer[position + 2], buffer)
1531 };
1532 },
1533 function jsxClosingFragment(position, buffer) {
1534 return {
1535 type: 'JSXClosingFragment',
1536 start: buffer[position],
1537 end: buffer[position + 1]
1538 };
1539 },
1540 function jsxElement(position, buffer) {
1541 const closingElementPosition = buffer[position + 4];
1542 return {
1543 type: 'JSXElement',
1544 start: buffer[position],
1545 end: buffer[position + 1],
1546 openingElement: convertNode(buffer[position + 2], buffer),
1547 children: convertNodeList(buffer[position + 3], buffer),
1548 closingElement: closingElementPosition === 0 ? null : convertNode(closingElementPosition, buffer)
1549 };
1550 },
1551 function jsxEmptyExpression(position, buffer) {
1552 return {
1553 type: 'JSXEmptyExpression',
1554 start: buffer[position],
1555 end: buffer[position + 1]
1556 };
1557 },
1558 function jsxExpressionContainer(position, buffer) {
1559 return {
1560 type: 'JSXExpressionContainer',
1561 start: buffer[position],
1562 end: buffer[position + 1],
1563 expression: convertNode(buffer[position + 2], buffer)
1564 };
1565 },
1566 function jsxFragment(position, buffer) {
1567 return {
1568 type: 'JSXFragment',
1569 start: buffer[position],
1570 end: buffer[position + 1],
1571 openingFragment: convertNode(buffer[position + 2], buffer),
1572 children: convertNodeList(buffer[position + 3], buffer),
1573 closingFragment: convertNode(buffer[position + 4], buffer)
1574 };
1575 },
1576 function jsxIdentifier(position, buffer) {
1577 return {
1578 type: 'JSXIdentifier',
1579 start: buffer[position],
1580 end: buffer[position + 1],
1581 name: buffer.convertString(buffer[position + 2])
1582 };
1583 },
1584 function jsxMemberExpression(position, buffer) {
1585 return {
1586 type: 'JSXMemberExpression',
1587 start: buffer[position],
1588 end: buffer[position + 1],
1589 object: convertNode(buffer[position + 2], buffer),
1590 property: convertNode(buffer[position + 3], buffer)
1591 };
1592 },
1593 function jsxNamespacedName(position, buffer) {
1594 return {
1595 type: 'JSXNamespacedName',
1596 start: buffer[position],
1597 end: buffer[position + 1],
1598 namespace: convertNode(buffer[position + 2], buffer),
1599 name: convertNode(buffer[position + 3], buffer)
1600 };
1601 },
1602 function jsxOpeningElement(position, buffer) {
1603 const flags = buffer[position + 2];
1604 return {
1605 type: 'JSXOpeningElement',
1606 start: buffer[position],
1607 end: buffer[position + 1],
1608 selfClosing: (flags & 1) === 1,
1609 name: convertNode(buffer[position + 3], buffer),
1610 attributes: convertNodeList(buffer[position + 4], buffer)
1611 };
1612 },
1613 function jsxOpeningFragment(position, buffer) {
1614 return {
1615 type: 'JSXOpeningFragment',
1616 start: buffer[position],
1617 end: buffer[position + 1],
1618 attributes: [],
1619 selfClosing: false
1620 };
1621 },
1622 function jsxSpreadAttribute(position, buffer) {
1623 return {
1624 type: 'JSXSpreadAttribute',
1625 start: buffer[position],
1626 end: buffer[position + 1],
1627 argument: convertNode(buffer[position + 2], buffer)
1628 };
1629 },
1630 function jsxSpreadChild(position, buffer) {
1631 return {
1632 type: 'JSXSpreadChild',
1633 start: buffer[position],
1634 end: buffer[position + 1],
1635 expression: convertNode(buffer[position + 2], buffer)
1636 };
1637 },
1638 function jsxText(position, buffer) {
1639 return {
1640 type: 'JSXText',
1641 start: buffer[position],
1642 end: buffer[position + 1],
1643 value: buffer.convertString(buffer[position + 2]),
1644 raw: buffer.convertString(buffer[position + 3])
1645 };
1646 },
1647 function labeledStatement(position, buffer) {
1648 return {
1649 type: 'LabeledStatement',
1650 start: buffer[position],
1651 end: buffer[position + 1],
1652 label: convertNode(buffer[position + 2], buffer),
1653 body: convertNode(buffer[position + 3], buffer)
1654 };
1655 },
1656 function literalBigInt(position, buffer) {
1657 const bigint = buffer.convertString(buffer[position + 2]);
1658 return {
1659 type: 'Literal',
1660 start: buffer[position],
1661 end: buffer[position + 1],
1662 bigint,
1663 raw: buffer.convertString(buffer[position + 3]),
1664 value: BigInt(bigint)
1665 };
1666 },
1667 function literalBoolean(position, buffer) {
1668 const flags = buffer[position + 2];
1669 const value = (flags & 1) === 1;
1670 return {
1671 type: 'Literal',
1672 start: buffer[position],
1673 end: buffer[position + 1],
1674 value,
1675 raw: value ? 'true' : 'false'
1676 };
1677 },
1678 function literalNull(position, buffer) {
1679 return {
1680 type: 'Literal',
1681 start: buffer[position],
1682 end: buffer[position + 1],
1683 raw: 'null',
1684 value: null
1685 };
1686 },
1687 function literalNumber(position, buffer) {
1688 const rawPosition = buffer[position + 2];
1689 return {
1690 type: 'Literal',
1691 start: buffer[position],
1692 end: buffer[position + 1],
1693 raw: rawPosition === 0 ? undefined : buffer.convertString(rawPosition),
1694 value: new DataView(buffer.buffer).getFloat64((position + 3) << 2, true)
1695 };
1696 },
1697 function literalRegExp(position, buffer) {
1698 const flags = buffer.convertString(buffer[position + 2]);
1699 const pattern = buffer.convertString(buffer[position + 3]);
1700 return {
1701 type: 'Literal',
1702 start: buffer[position],
1703 end: buffer[position + 1],
1704 raw: `/${pattern}/${flags}`,
1705 regex: { flags, pattern },
1706 value: new RegExp(pattern, flags)
1707 };
1708 },
1709 function literalString(position, buffer) {
1710 const rawPosition = buffer[position + 3];
1711 return {
1712 type: 'Literal',
1713 start: buffer[position],
1714 end: buffer[position + 1],
1715 value: buffer.convertString(buffer[position + 2]),
1716 raw: rawPosition === 0 ? undefined : buffer.convertString(rawPosition)
1717 };
1718 },
1719 function logicalExpression(position, buffer) {
1720 return {
1721 type: 'LogicalExpression',
1722 start: buffer[position],
1723 end: buffer[position + 1],
1724 operator: FIXED_STRINGS[buffer[position + 2]],
1725 left: convertNode(buffer[position + 3], buffer),
1726 right: convertNode(buffer[position + 4], buffer)
1727 };
1728 },
1729 function memberExpression(position, buffer) {
1730 const flags = buffer[position + 2];
1731 return {
1732 type: 'MemberExpression',
1733 start: buffer[position],
1734 end: buffer[position + 1],
1735 computed: (flags & 1) === 1,
1736 optional: (flags & 2) === 2,
1737 object: convertNode(buffer[position + 3], buffer),
1738 property: convertNode(buffer[position + 4], buffer)
1739 };
1740 },
1741 function metaProperty(position, buffer) {
1742 return {
1743 type: 'MetaProperty',
1744 start: buffer[position],
1745 end: buffer[position + 1],
1746 meta: convertNode(buffer[position + 2], buffer),
1747 property: convertNode(buffer[position + 3], buffer)
1748 };
1749 },
1750 function methodDefinition(position, buffer) {
1751 const flags = buffer[position + 2];
1752 return {
1753 type: 'MethodDefinition',
1754 start: buffer[position],
1755 end: buffer[position + 1],
1756 static: (flags & 1) === 1,
1757 computed: (flags & 2) === 2,
1758 decorators: convertNodeList(buffer[position + 3], buffer),
1759 key: convertNode(buffer[position + 4], buffer),
1760 value: convertNode(buffer[position + 5], buffer),
1761 kind: FIXED_STRINGS[buffer[position + 6]]
1762 };
1763 },
1764 function newExpression(position, buffer) {
1765 const annotations = convertAnnotations(buffer[position + 2], buffer);
1766 return {
1767 type: 'NewExpression',
1768 start: buffer[position],
1769 end: buffer[position + 1],
1770 ...(annotations.length > 0 ? { [ANNOTATION_KEY]: annotations } : {}),
1771 callee: convertNode(buffer[position + 3], buffer),
1772 arguments: convertNodeList(buffer[position + 4], buffer)
1773 };
1774 },
1775 function objectExpression(position, buffer) {
1776 return {
1777 type: 'ObjectExpression',
1778 start: buffer[position],
1779 end: buffer[position + 1],
1780 properties: convertNodeList(buffer[position + 2], buffer)
1781 };
1782 },
1783 function objectPattern(position, buffer) {
1784 return {
1785 type: 'ObjectPattern',
1786 start: buffer[position],
1787 end: buffer[position + 1],
1788 properties: convertNodeList(buffer[position + 2], buffer)
1789 };
1790 },
1791 function privateIdentifier(position, buffer) {
1792 return {
1793 type: 'PrivateIdentifier',
1794 start: buffer[position],
1795 end: buffer[position + 1],
1796 name: buffer.convertString(buffer[position + 2])
1797 };
1798 },
1799 function program(position, buffer) {
1800 const invalidAnnotations = convertAnnotations(buffer[position + 3], buffer);
1801 return {
1802 type: 'Program',
1803 start: buffer[position],
1804 end: buffer[position + 1],
1805 body: convertNodeList(buffer[position + 2], buffer),
1806 ...(invalidAnnotations.length > 0 ? { [INVALID_ANNOTATION_KEY]: invalidAnnotations } : {}),
1807 sourceType: 'module'
1808 };
1809 },
1810 function property(position, buffer) {
1811 const flags = buffer[position + 2];
1812 const keyPosition = buffer[position + 3];
1813 const value = convertNode(buffer[position + 4], buffer);
1814 return {
1815 type: 'Property',
1816 start: buffer[position],
1817 end: buffer[position + 1],
1818 method: (flags & 1) === 1,
1819 shorthand: (flags & 2) === 2,
1820 computed: (flags & 4) === 4,
1821 key: keyPosition === 0 ? { ...value } : convertNode(keyPosition, buffer),
1822 value,
1823 kind: FIXED_STRINGS[buffer[position + 5]]
1824 };
1825 },
1826 function propertyDefinition(position, buffer) {
1827 const flags = buffer[position + 2];
1828 const valuePosition = buffer[position + 5];
1829 return {
1830 type: 'PropertyDefinition',
1831 start: buffer[position],
1832 end: buffer[position + 1],
1833 static: (flags & 1) === 1,
1834 computed: (flags & 2) === 2,
1835 decorators: convertNodeList(buffer[position + 3], buffer),
1836 key: convertNode(buffer[position + 4], buffer),
1837 value: valuePosition === 0 ? null : convertNode(valuePosition, buffer)
1838 };
1839 },
1840 function restElement(position, buffer) {
1841 return {
1842 type: 'RestElement',
1843 start: buffer[position],
1844 end: buffer[position + 1],
1845 argument: convertNode(buffer[position + 2], buffer)
1846 };
1847 },
1848 function returnStatement(position, buffer) {
1849 const argumentPosition = buffer[position + 2];
1850 return {
1851 type: 'ReturnStatement',
1852 start: buffer[position],
1853 end: buffer[position + 1],
1854 argument: argumentPosition === 0 ? null : convertNode(argumentPosition, buffer)
1855 };
1856 },
1857 function sequenceExpression(position, buffer) {
1858 return {
1859 type: 'SequenceExpression',
1860 start: buffer[position],
1861 end: buffer[position + 1],
1862 expressions: convertNodeList(buffer[position + 2], buffer)
1863 };
1864 },
1865 function spreadElement(position, buffer) {
1866 return {
1867 type: 'SpreadElement',
1868 start: buffer[position],
1869 end: buffer[position + 1],
1870 argument: convertNode(buffer[position + 2], buffer)
1871 };
1872 },
1873 function staticBlock(position, buffer) {
1874 return {
1875 type: 'StaticBlock',
1876 start: buffer[position],
1877 end: buffer[position + 1],
1878 body: convertNodeList(buffer[position + 2], buffer)
1879 };
1880 },
1881 function superElement(position, buffer) {
1882 return {
1883 type: 'Super',
1884 start: buffer[position],
1885 end: buffer[position + 1]
1886 };
1887 },
1888 function switchCase(position, buffer) {
1889 const testPosition = buffer[position + 2];
1890 return {
1891 type: 'SwitchCase',
1892 start: buffer[position],
1893 end: buffer[position + 1],
1894 test: testPosition === 0 ? null : convertNode(testPosition, buffer),
1895 consequent: convertNodeList(buffer[position + 3], buffer)
1896 };
1897 },
1898 function switchStatement(position, buffer) {
1899 return {
1900 type: 'SwitchStatement',
1901 start: buffer[position],
1902 end: buffer[position + 1],
1903 discriminant: convertNode(buffer[position + 2], buffer),
1904 cases: convertNodeList(buffer[position + 3], buffer)
1905 };
1906 },
1907 function taggedTemplateExpression(position, buffer) {
1908 return {
1909 type: 'TaggedTemplateExpression',
1910 start: buffer[position],
1911 end: buffer[position + 1],
1912 tag: convertNode(buffer[position + 2], buffer),
1913 quasi: convertNode(buffer[position + 3], buffer)
1914 };
1915 },
1916 function templateElement(position, buffer) {
1917 const flags = buffer[position + 2];
1918 const cookedPosition = buffer[position + 3];
1919 const cooked = cookedPosition === 0 ? undefined : buffer.convertString(cookedPosition);
1920 const raw = buffer.convertString(buffer[position + 4]);
1921 return {
1922 type: 'TemplateElement',
1923 start: buffer[position],
1924 end: buffer[position + 1],
1925 tail: (flags & 1) === 1,
1926 value: { cooked, raw }
1927 };
1928 },
1929 function templateLiteral(position, buffer) {
1930 return {
1931 type: 'TemplateLiteral',
1932 start: buffer[position],
1933 end: buffer[position + 1],
1934 quasis: convertNodeList(buffer[position + 2], buffer),
1935 expressions: convertNodeList(buffer[position + 3], buffer)
1936 };
1937 },
1938 function thisExpression(position, buffer) {
1939 return {
1940 type: 'ThisExpression',
1941 start: buffer[position],
1942 end: buffer[position + 1]
1943 };
1944 },
1945 function throwStatement(position, buffer) {
1946 return {
1947 type: 'ThrowStatement',
1948 start: buffer[position],
1949 end: buffer[position + 1],
1950 argument: convertNode(buffer[position + 2], buffer)
1951 };
1952 },
1953 function tryStatement(position, buffer) {
1954 const handlerPosition = buffer[position + 3];
1955 const finalizerPosition = buffer[position + 4];
1956 return {
1957 type: 'TryStatement',
1958 start: buffer[position],
1959 end: buffer[position + 1],
1960 block: convertNode(buffer[position + 2], buffer),
1961 handler: handlerPosition === 0 ? null : convertNode(handlerPosition, buffer),
1962 finalizer: finalizerPosition === 0 ? null : convertNode(finalizerPosition, buffer)
1963 };
1964 },
1965 function unaryExpression(position, buffer) {
1966 return {
1967 type: 'UnaryExpression',
1968 start: buffer[position],
1969 end: buffer[position + 1],
1970 operator: FIXED_STRINGS[buffer[position + 2]],
1971 argument: convertNode(buffer[position + 3], buffer),
1972 prefix: true
1973 };
1974 },
1975 function updateExpression(position, buffer) {
1976 const flags = buffer[position + 2];
1977 return {
1978 type: 'UpdateExpression',
1979 start: buffer[position],
1980 end: buffer[position + 1],
1981 prefix: (flags & 1) === 1,
1982 operator: FIXED_STRINGS[buffer[position + 3]],
1983 argument: convertNode(buffer[position + 4], buffer)
1984 };
1985 },
1986 function variableDeclaration(position, buffer) {
1987 return {
1988 type: 'VariableDeclaration',
1989 start: buffer[position],
1990 end: buffer[position + 1],
1991 kind: FIXED_STRINGS[buffer[position + 2]],
1992 declarations: convertNodeList(buffer[position + 3], buffer)
1993 };
1994 },
1995 function variableDeclarator(position, buffer) {
1996 const initPosition = buffer[position + 3];
1997 return {
1998 type: 'VariableDeclarator',
1999 start: buffer[position],
2000 end: buffer[position + 1],
2001 id: convertNode(buffer[position + 2], buffer),
2002 init: initPosition === 0 ? null : convertNode(initPosition, buffer)
2003 };
2004 },
2005 function whileStatement(position, buffer) {
2006 return {
2007 type: 'WhileStatement',
2008 start: buffer[position],
2009 end: buffer[position + 1],
2010 test: convertNode(buffer[position + 2], buffer),
2011 body: convertNode(buffer[position + 3], buffer)
2012 };
2013 },
2014 function yieldExpression(position, buffer) {
2015 const flags = buffer[position + 2];
2016 const argumentPosition = buffer[position + 3];
2017 return {
2018 type: 'YieldExpression',
2019 start: buffer[position],
2020 end: buffer[position + 1],
2021 delegate: (flags & 1) === 1,
2022 argument: argumentPosition === 0 ? null : convertNode(argumentPosition, buffer)
2023 };
2024 }
2025];
2026function convertNode(position, buffer) {
2027 const nodeType = buffer[position];
2028 const converter = nodeConverters[nodeType];
2029 /* istanbul ignore if: This should never be executed but is a safeguard against faulty buffers */
2030 if (!converter) {
2031 console.trace();
2032 throw new Error(`Unknown node type: ${nodeType}`);
2033 }
2034 return converter(position + 1, buffer);
2035}
2036function convertNodeList(position, buffer) {
2037 if (position === 0)
2038 return EMPTY_ARRAY;
2039 const length = buffer[position++];
2040 const list = new Array(length);
2041 for (let index = 0; index < length; index++) {
2042 const nodePosition = buffer[position++];
2043 list[index] = nodePosition ? convertNode(nodePosition, buffer) : null;
2044 }
2045 return list;
2046}
2047
2048function getAstBuffer(astBuffer) {
2049 const array = new Uint32Array(astBuffer.buffer);
2050 let convertString;
2051 if (typeof Buffer !== 'undefined' && astBuffer instanceof Buffer) {
2052 convertString = (position) => {
2053 const length = array[position++];
2054 const bytePosition = position << 2;
2055 return astBuffer.toString('utf8', bytePosition, bytePosition + length);
2056 };
2057 }
2058 else {
2059 const textDecoder = new TextDecoder();
2060 convertString = (position) => {
2061 const length = array[position++];
2062 const bytePosition = position << 2;
2063 return textDecoder.decode(astBuffer.subarray(bytePosition, bytePosition + length));
2064 };
2065 }
2066 return Object.assign(array, { convertString });
2067}
2068
2069const parseAst = (input, { allowReturnOutsideFunction = false, jsx = false } = {}) => convertProgram(getAstBuffer(parse(input, allowReturnOutsideFunction, jsx)));
2070const parseAstAsync = async (input, { allowReturnOutsideFunction = false, jsx = false, signal } = {}) => convertProgram(getAstBuffer(await parseAsync(input, allowReturnOutsideFunction, jsx, signal)));
2071
2072export { ANNOTATION_KEY, ArrowFunctionExpression, BLANK, BlockStatement, CallExpression, CatchClause, EMPTY_ARRAY, EMPTY_OBJECT, EMPTY_SET, ExportDefaultDeclaration, ExpressionStatement, FIXED_STRINGS, INVALID_ANNOTATION_KEY, Identifier, LOGLEVEL_DEBUG, LOGLEVEL_ERROR, LOGLEVEL_INFO, LOGLEVEL_WARN, Literal, ObjectExpression, Program, Property, ReturnStatement, StaticBlock, TemplateLiteral, URL_GENERATEBUNDLE, URL_JSX, URL_OUTPUT_AMD_BASEPATH, URL_OUTPUT_AMD_ID, URL_OUTPUT_DIR, URL_OUTPUT_EXTERNALIMPORTATTRIBUTES, URL_OUTPUT_FORMAT, URL_OUTPUT_GENERATEDCODE, URL_OUTPUT_INLINEDYNAMICIMPORTS, URL_OUTPUT_INTEROP, URL_OUTPUT_MANUALCHUNKS, URL_OUTPUT_SOURCEMAPBASEURL, URL_OUTPUT_SOURCEMAPFILE, URL_PRESERVEENTRYSIGNATURES, URL_TREESHAKE, URL_TREESHAKE_MODULESIDEEFFECTS, URL_WATCH, VariableDeclarator, addTrailingSlashIfMissed, augmentCodeLocation, augmentLogMessage, convertAnnotations, convertNode, error, getAliasName, getAstBuffer, getImportPath, getRollupError, isAbsolute, isPathFragment, isRelative, isValidUrl, locate, logAddonNotGenerated, logAlreadyClosed, logAmbiguousExternalNamespaces, logAnonymousPluginCache, logAssetNotFinalisedForFileName, logAssetReferenceIdNotFoundForSetSource, logAssetSourceAlreadySet, logBadLoader, logCannotAssignModuleToChunk, logCannotCallNamespace, logCannotEmitFromOptionsHook, logChunkInvalid, logChunkNotGeneratedForFileName, logCircularDependency, logCircularReexport, logConflictingSourcemapSources, logConstVariableReassignError, logCyclicCrossChunkReexport, logDuplicateArgumentNameError, logDuplicateExportError, logDuplicatePluginName, logEmptyChunk, logEntryCannotBeExternal, logEval, logExternalModulesCannotBeIncludedInManualChunks, logExternalModulesCannotBeTransformedToModules, logExternalSyntheticExports, logFailedValidation, logFileNameConflict, logFileReferenceIdNotFoundForFilename, logFirstSideEffect, logIllegalIdentifierAsName, logIllegalImportReassignment, logImplicitDependantCannotBeExternal, logImplicitDependantIsNotIncluded, logImportAttributeIsInvalid, logImportOptionsAreInvalid, logIncompatibleExportOptionValue, logInconsistentImportAttributes, logInputHookInOutputPlugin, logInternalIdCannotBeExternal, logInvalidAddonPluginHook, logInvalidAnnotation, logInvalidExportOptionValue, logInvalidFormatForTopLevelAwait, logInvalidFunctionPluginHook, logInvalidLogPosition, logInvalidOption, logInvalidRollupPhaseForChunkEmission, logInvalidSetAssetSourceCall, logInvalidSourcemapForError, logLevelPriority, logMissingEntryExport, logMissingExport, logMissingFileOrDirOption, logMissingGlobalName, logMissingJsxExport, logMissingNameOptionForIifeExport, logMissingNameOptionForUmdExport, logMissingNodeBuiltins, logMixedExport, logModuleLevelDirective, logModuleParseError, logNamespaceConflict, logNoAssetSourceSet, logNoTransformMapOrAstWithoutCode, logOptimizeChunkStatus, logParseError, logPluginError, logRedeclarationError, logReservedNamespace, logShimmedExport, logSourcemapBroken, logSyntheticNamedExportsNeedNamespaceExport, logThisIsUndefined, logUnexpectedNamedImport, logUnexpectedNamespaceReexport, logUnknownOption, logUnresolvedEntry, logUnresolvedImplicitDependant, logUnresolvedImport, logUnresolvedImportTreatedAsExternal, logUnusedExternalImports, normalize, parseAst, parseAstAsync, printQuotedStringList, relative, relativeId, warnDeprecation };
Note: See TracBrowser for help on using the repository browser.