Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

typings-core

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typings-core - npm Package Compare versions

Comparing version 2.3.0 to 2.3.1

82

dist/lib/compile.js

@@ -146,15 +146,18 @@ "use strict";

})(DependencyImport || (DependencyImport = {}));
function readDependencyImport(originalPath, mode, isEntry, options, parent) {
function getDependencyImportPaths(importPath, mode) {
var paths = [];
var cwd = options.cwd, tree = options.tree, resolution = options.resolution, fileCache = options.fileCache, resolved = options.resolved, imported = options.imported, emitter = options.emitter, meta = options.meta;
if (mode === DependencyImport.DEFAULT_ONLY || mode === DependencyImport.ALL_PATHS) {
paths.push(originalPath);
paths.push(importPath);
}
if (mode === DependencyImport.SUFFIXES_ONLY || mode === DependencyImport.ALL_PATHS) {
paths.push(path_3.appendToPath(originalPath, '.d.ts'), path_3.appendToPath(originalPath, '/index.d.ts'));
paths.push(path_3.appendToPath(importPath, '.d.ts'), path_3.appendToPath(importPath, '/index.d.ts'));
}
function attempt(cause, index) {
return paths;
}
function readDependencyImport(importPath, mode, isEntry, stringifyOptions, parent) {
function attempt(cause, paths, index, isEntry, options) {
var cwd = options.cwd, tree = options.tree, resolution = options.resolution, fileCache = options.fileCache, resolved = options.resolved, imported = options.imported, emitter = options.emitter, meta = options.meta;
if (index >= paths.length) {
var authorPhrase = options.parent ? "The author of \"" + options.parent.name + "\" needs to" : 'You should';
var relativePath = path_3.isModuleName(originalPath) ? originalPath : path_3.relativeTo(options.tree.src, originalPath);
var relativePath = path_3.isModuleName(importPath) ? importPath : path_3.relativeTo(options.tree.src, importPath);
if (isEntry) {

@@ -182,34 +185,34 @@ return Promise.reject(new error_1.default("Unable to read typings for \"" + options.name + "\". " +

if (!childOptions) {
stringifyOptions.resolved[getCachePath(importPath, stringifyOptions, false)] = path;
return Promise.resolve(null);
}
if (modulePath) {
return readDependencyImport(path_3.resolveFrom(childOptions.tree.src, modulePath), DependencyImport.SUFFIXES_ONLY, false, childOptions, parent);
}
if (childOptions.entry) {
return readDependencyImport(path_3.resolveFrom(childOptions.tree.src, childOptions.entry), DependencyImport.ALL_PATHS, true, childOptions, parent);
}
return readDependencyImport(path_3.resolveFrom(childOptions.tree.src, 'index.d.ts'), DependencyImport.DEFAULT_ONLY, true, childOptions, parent);
var paths_1 = getDependencyImportPaths(path_3.resolveFrom(childOptions.tree.src, modulePath || childOptions.entry || 'index.d.ts'), modulePath ? DependencyImport.SUFFIXES_ONLY : (childOptions.entry ? DependencyImport.ALL_PATHS : DependencyImport.DEFAULT_ONLY));
return attempt(null, paths_1, 0, true, childOptions);
}
if (options.imported[path]) {
return options.imported[path].then(function () { return null; });
var cached = has(options.imported, path);
if (!cached) {
options.imported[path] = fs_1.readFileFrom(path).then(function (contents) {
var fileInfo = ts.preProcessFile(contents);
var sourceFile = ts.createSourceFile(path, contents.replace(references_1.REFERENCE_REGEXP, ''), ts.ScriptTarget.Latest, true);
var modulePath = getCachePath(path, options, true);
var moduleInfo = { path: path, modulePath: modulePath, isEntry: isEntry, parent: parent, sourceFile: sourceFile, options: options, fileInfo: fileInfo };
return moduleInfo;
}, function (err) {
if (err.code === 'ENOENT' || err.code === 'ENOTDIR' || err.code === 'EISDIR' || err.code === 'EINVALIDSTATUS') {
return attempt(err, paths, index + 1, isEntry, options);
}
return Promise.reject(err);
});
}
return options.imported[path] = fs_1.readFileFrom(path).then(function (contents) {
var fileInfo = ts.preProcessFile(contents);
var sourceFile = ts.createSourceFile(path, contents.replace(references_1.REFERENCE_REGEXP, ''), ts.ScriptTarget.Latest, true);
var moduleInfo = { path: path, originalPath: originalPath, isEntry: isEntry, parent: parent, sourceFile: sourceFile, options: options, fileInfo: fileInfo };
return moduleInfo;
}, function (err) {
if (err.code === 'ENOENT' || err.code === 'ENOTDIR' || err.code === 'EISDIR' || err.code === 'EINVALIDSTATUS') {
return attempt(err, index + 1);
}
return Promise.reject(err);
return options.imported[path].then(function (moduleInfo) {
stringifyOptions.resolved[getCachePath(importPath, stringifyOptions, false)] = moduleInfo.modulePath;
return !cached ? moduleInfo : undefined;
});
}
return attempt(null, 0).then(function (moduleInfo) {
if (moduleInfo) {
options.resolved[getCachePath(originalPath, options, false)] = getCachePath(moduleInfo.path, moduleInfo.options, true);
}
return moduleInfo;
});
return attempt(null, getDependencyImportPaths(importPath, mode), 0, isEntry, stringifyOptions);
}
function stringifyDependencyImport(importPath, mode, isEntry, options, parent) {
return readDependencyImport(importPath, mode, isEntry, options, parent)
.then(function (info) { return info ? stringifyDependencyPath(info) : undefined; });
}
function getCachePath(originalPath, options, strip) {

@@ -222,8 +225,2 @@ var path = strip ? path_3.pathFromDefinition(originalPath) : originalPath;

}
function stringifyDependencyImport(importPath, mode, isEntry, options, parent) {
return readDependencyImport(importPath, mode, isEntry, options, parent)
.then(function (info) {
return info ? stringifyDependencyPath(info) : undefined;
});
}
function stringifyDependencyPath(moduleInfo) {

@@ -267,6 +264,6 @@ var path = moduleInfo.path, options = moduleInfo.options, sourceFile = moduleInfo.sourceFile, fileInfo = moduleInfo.fileInfo;

function getImportPath(path, options) {
return options.resolved[getCachePath(path, options, false)] || path;
return options.resolved[getCachePath(path, options, false)];
}
function stringifyModuleFile(info) {
var options = info.options;
var options = info.options, modulePath = info.modulePath;
var tree = options.tree, name = options.name, prefix = options.prefix, parent = options.parent, cwd = options.cwd, global = options.global;

@@ -340,3 +337,2 @@ var source = path_3.isHttp(info.path) ? info.path : path_3.normalizeSlashes(path_1.relative(cwd, info.path));

var moduleText = path_2.normalizeEOL(processTree(info.sourceFile, replacer, read), path_2.EOL);
var modulePath = getImportPath(info.originalPath, options);
var moduleName = parent && parent.global ? name : modulePath;

@@ -347,3 +343,3 @@ if (info.isEntry && !hasLocalImports) {

var prettyPath = path_3.normalizeSlashes(path_1.join(name, path_3.relativeTo(tree.src, path_3.pathFromDefinition(info.path))));
var declared = declareText(modulePath, moduleText);
var declared = meta + declareText(modulePath, moduleText);
function alias(name) {

@@ -369,5 +365,5 @@ var imports = [];

if (info.isEntry && !parent) {
return meta + declared + alias(prettyPath) + alias(name);
return declared + alias(prettyPath) + alias(name);
}
return meta + declared + (parent ? '' : alias(prettyPath));
return declared + (parent ? '' : alias(prettyPath));
}

@@ -374,0 +370,0 @@ function declareText(name, text) {

@@ -279,3 +279,5 @@ "use strict";

'declare module \'~test~foo/x\' {',
'export const wow: boolean',
'import * as bar from \'~test~foo/index\'',
'',
'export { bar }',
'}',

@@ -372,3 +374,3 @@ '',

var emitter = new events_1.EventEmitter();
return compile_1.compile(node, ['main'], { name: 'name', cwd: __dirname, global: true, meta: false, emitter: emitter })
return compile_1.compile(node, ['main'], { name: 'node', cwd: __dirname, global: true, meta: false, emitter: emitter })
.then(function (out) {

@@ -375,0 +377,0 @@ t.equal(out.results.main, [

{
"name": "typings-core",
"version": "2.3.0",
"version": "2.3.1",
"description": "The logic of Typings",

@@ -5,0 +5,0 @@ "main": "dist/typings.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc