/
lostSun
/
project-client-server-apps
Обзор
Документация
Войти
/
lostSun
/
project-client-server-apps
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
node_modules/eslint-plugin-import/lib/exportMap/index.js
180 строк
22 KB
1lostsun
initial commit
05 май 2025, 11:35
05 май 2025, 11:35
fe8f535
Код
Авторство
О чём код?
'use strict';Object.defineProperty(exports, "__esModule", { value: true });var _createClass = function () {function defineProperties(target, props) {for (var i = 0; i < props.length; i++) {var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor);}}return function (Constructor, protoProps, staticProps) {if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor;};}();function _classCallCheck(instance, Constructor) {if (!(instance instanceof Constructor)) {throw new TypeError("Cannot call a class as a function");}}var ExportMap = function () { function ExportMap(path) {_classCallCheck(this, ExportMap); this.path = path; this.namespace = new Map(); // todo: restructure to key on path, value is resolver + map of names this.reexports = new Map(); /** * star-exports * @type {Set<() => ExportMap>} */ this.dependencies = new Set(); /** * dependencies of this module that are not explicitly re-exported * @type {Map<string, () => ExportMap>} */ this.imports = new Map(); this.errors = []; /** * type {'ambiguous' | 'Module' | 'Script'} */ this.parseGoal = 'ambiguous'; }_createClass(ExportMap, [{ key: 'has', /** * Note that this does not check explicitly re-exported names for existence * in the base namespace, but it will expand all `export * from '...'` exports * if not found in the explicit namespace. * @param {string} name * @return {boolean} true if `name` is exported by this module. */value: function () {function has( name) { if (this.namespace.has(name)) {return true;} if (this.reexports.has(name)) {return true;} // default exports must be explicitly re-exported (#328) if (name !== 'default') {var _iteratorNormalCompletion = true;var _didIteratorError = false;var _iteratorError = undefined;try { for (var _iterator = this.dependencies[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {var dep = _step.value; var innerMap = dep(); // todo: report as unresolved? if (!innerMap) {continue;} if (innerMap.has(name)) {return true;} }} catch (err) {_didIteratorError = true;_iteratorError = err;} finally {try {if (!_iteratorNormalCompletion && _iterator['return']) {_iterator['return']();}} finally {if (_didIteratorError) {throw _iteratorError;}}} } return false; }return has;}() /** * ensure that imported name fully resolves. * @param {string} name * @return {{ found: boolean, path: ExportMap[] }} */ }, { key: 'hasDeep', value: function () {function hasDeep( name) { if (this.namespace.has(name)) {return { found: true, path: [this] };} if (this.reexports.has(name)) { var reexports = this.reexports.get(name); var imported = reexports.getImport(); // if import is ignored, return explicit 'null' if (imported == null) {return { found: true, path: [this] };} // safeguard against cycles, only if name matches if (imported.path === this.path && reexports.local === name) { return { found: false, path: [this] }; } var deep = imported.hasDeep(reexports.local); deep.path.unshift(this); return deep; } // default exports must be explicitly re-exported (#328) if (name !== 'default') {var _iteratorNormalCompletion2 = true;var _didIteratorError2 = false;var _iteratorError2 = undefined;try { for (var _iterator2 = this.dependencies[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {var dep = _step2.value; var innerMap = dep(); if (innerMap == null) {return { found: true, path: [this] };} // todo: report as unresolved? if (!innerMap) {continue;} // safeguard against cycles if (innerMap.path === this.path) {continue;} var innerValue = innerMap.hasDeep(name); if (innerValue.found) { innerValue.path.unshift(this); return innerValue; } }} catch (err) {_didIteratorError2 = true;_iteratorError2 = err;} finally {try {if (!_iteratorNormalCompletion2 && _iterator2['return']) {_iterator2['return']();}} finally {if (_didIteratorError2) {throw _iteratorError2;}}} } return { found: false, path: [this] }; }return hasDeep;}() }, { key: 'get', value: function () {function get( name) { if (this.namespace.has(name)) {return this.namespace.get(name);} if (this.reexports.has(name)) { var reexports = this.reexports.get(name); var imported = reexports.getImport(); // if import is ignored, return explicit 'null' if (imported == null) {return null;} // safeguard against cycles, only if name matches if (imported.path === this.path && reexports.local === name) {return undefined;} return imported.get(reexports.local); } // default exports must be explicitly re-exported (#328) if (name !== 'default') {var _iteratorNormalCompletion3 = true;var _didIteratorError3 = false;var _iteratorError3 = undefined;try { for (var _iterator3 = this.dependencies[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {var dep = _step3.value; var innerMap = dep(); // todo: report as unresolved? if (!innerMap) {continue;} // safeguard against cycles if (innerMap.path === this.path) {continue;} var innerValue = innerMap.get(name); if (innerValue !== undefined) {return innerValue;} }} catch (err) {_didIteratorError3 = true;_iteratorError3 = err;} finally {try {if (!_iteratorNormalCompletion3 && _iterator3['return']) {_iterator3['return']();}} finally {if (_didIteratorError3) {throw _iteratorError3;}}} } return undefined; }return get;}() }, { key: 'forEach', value: function () {function forEach( callback, thisArg) {var _this = this; this.namespace.forEach(function (v, n) {callback.call(thisArg, v, n, _this);}); this.reexports.forEach(function (reexports, name) { var reexported = reexports.getImport(); // can't look up meta for ignored re-exports (#348) callback.call(thisArg, reexported && reexported.get(reexports.local), name, _this); }); this.dependencies.forEach(function (dep) { var d = dep(); // CJS / ignored dependencies won't exist (#717) if (d == null) {return;} d.forEach(function (v, n) { if (n !== 'default') { callback.call(thisArg, v, n, _this); } }); }); }return forEach;}() // todo: keys, values, entries? }, { key: 'reportErrors', value: function () {function reportErrors( context, declaration) { var msg = this.errors. map(function (e) {return String(e.message) + ' (' + String(e.lineNumber) + ':' + String(e.column) + ')';}). join(', '); context.report({ node: declaration.source, message: 'Parse errors in imported module \'' + String(declaration.source.value) + '\': ' + String(msg) }); }return reportErrors;}() }, { key: 'hasDefault', get: function () {function get() {return this.get('default') != null;}return get;}() // stronger than this.has }, { key: 'size', get: function () {function get() {var size = this.namespace.size + this.reexports.size;this.dependencies.forEach(function (dep) {var d = dep(); // CJS / ignored dependencies won't exist (#717) if (d == null) {return;}size += d.size;});return size;}return get;}() }]);return ExportMap;}();exports['default'] = ExportMap; //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9leHBvcnRNYXAvaW5kZXguanMiXSwibmFtZXMiOlsiRXhwb3J0TWFwIiwicGF0aCIsIm5hbWVzcGFjZSIsIk1hcCIs … [Строка слишком длинная. Вы можете скачать файл]