Socket
Socket
Sign inDemoInstall

@voltiso/transform

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@voltiso/transform - npm Package Compare versions

Comparing version 1.1.3 to 1.1.4

38

dist/cjs/voltisoTransform.js

@@ -63,2 +63,12 @@ "use strict";

}
function collectNodesOfKind(node, kind) {
let nodesOfKind = [];
if (node.kind === kind)
nodesOfKind.push(node);
node.forEachChild(child => {
const moreNodesOfKind = collectNodesOfKind(child, kind);
nodesOfKind = [...nodesOfKind, ...moreNodesOfKind];
});
return nodesOfKind;
}
// function getJSDocTags(type: ts.Type): readonly ts.JSDocTag[] {

@@ -182,18 +192,32 @@ // const symbol = type.symbol as ts.Symbol | undefined

}
const newSymbolNames = collectSymbolNames(newNode);
const symbolsOutOfScope = collectSymbolNames(newNode);
// console.log(newSymbolNames)
const symbolNames = collectSymbolNames(node);
for (const symbolName of symbolNames)
newSymbolNames.delete(symbolName);
symbolsOutOfScope.delete(symbolName);
// console.log('remaining symbols', newSymbolNames)
for (const symbol of newSymbolNames) {
for (const symbol of symbolsOutOfScope) {
if (typeSymbols.has(symbol))
newSymbolNames.delete(symbol);
symbolsOutOfScope.delete(symbol);
}
const canBeInlined = newSymbolNames.size === 0;
if (!canBeInlined && options?.warn) {
const message = `\n[@voltiso/transform] unable to inline ${getNodeText(node) || (0, transform_lib_1.stringFromSyntaxKind)(node.kind)} - symbols out of scope: ${[...newSymbolNames].join(', ')} \n @ ${getNodePositionStr(node)}`;
const hasSymbolsOutOfScope = symbolsOutOfScope.size > 0;
if (hasSymbolsOutOfScope && options?.warn) {
const message = `\n[@voltiso/transform] unable to inline ${getNodeText(node) || (0, transform_lib_1.stringFromSyntaxKind)(node.kind)} - symbols out of scope: ${[...symbolsOutOfScope].join(', ')} \n @ ${getNodePositionStr(node)}`;
// eslint-disable-next-line no-console
console.warn(chalk_1.default.bgRed(message));
}
const importTypeNodes = collectNodesOfKind(newNode, ts.SyntaxKind.ImportType);
let containsImportAbsolutePath = false;
for (const importTypeNode of importTypeNodes) {
const child = getFirstChildOrSelf(getFirstChildOrSelf(importTypeNode));
if (ts.isStringLiteral(child) && child.text.startsWith('/')) {
containsImportAbsolutePath = true;
if (options?.warn) {
const message = `\n[@voltiso/transform] unable to inline ${getNodeText(node) || (0, transform_lib_1.stringFromSyntaxKind)(node.kind)} - resulting node text would include absolute disk path import of '${child.text}' \n @ ${getNodePositionStr(node)}`;
// eslint-disable-next-line no-console
console.warn(chalk_1.default.bgRed(message));
}
}
}
const canBeInlined = !hasSymbolsOutOfScope && !containsImportAbsolutePath;
return canBeInlined;

@@ -200,0 +224,0 @@ }

@@ -34,2 +34,12 @@ // ⠀ⓥ 2022 🌩 🌩 ⠀ ⠀

}
function collectNodesOfKind(node, kind) {
let nodesOfKind = [];
if (node.kind === kind)
nodesOfKind.push(node);
node.forEachChild(child => {
const moreNodesOfKind = collectNodesOfKind(child, kind);
nodesOfKind = [...nodesOfKind, ...moreNodesOfKind];
});
return nodesOfKind;
}
// function getJSDocTags(type: ts.Type): readonly ts.JSDocTag[] {

@@ -153,18 +163,32 @@ // const symbol = type.symbol as ts.Symbol | undefined

}
const newSymbolNames = collectSymbolNames(newNode);
const symbolsOutOfScope = collectSymbolNames(newNode);
// console.log(newSymbolNames)
const symbolNames = collectSymbolNames(node);
for (const symbolName of symbolNames)
newSymbolNames.delete(symbolName);
symbolsOutOfScope.delete(symbolName);
// console.log('remaining symbols', newSymbolNames)
for (const symbol of newSymbolNames) {
for (const symbol of symbolsOutOfScope) {
if (typeSymbols.has(symbol))
newSymbolNames.delete(symbol);
symbolsOutOfScope.delete(symbol);
}
const canBeInlined = newSymbolNames.size === 0;
if (!canBeInlined && options?.warn) {
const message = `\n[@voltiso/transform] unable to inline ${getNodeText(node) || stringFromSyntaxKind(node.kind)} - symbols out of scope: ${[...newSymbolNames].join(', ')} \n @ ${getNodePositionStr(node)}`;
const hasSymbolsOutOfScope = symbolsOutOfScope.size > 0;
if (hasSymbolsOutOfScope && options?.warn) {
const message = `\n[@voltiso/transform] unable to inline ${getNodeText(node) || stringFromSyntaxKind(node.kind)} - symbols out of scope: ${[...symbolsOutOfScope].join(', ')} \n @ ${getNodePositionStr(node)}`;
// eslint-disable-next-line no-console
console.warn(chalk.bgRed(message));
}
const importTypeNodes = collectNodesOfKind(newNode, ts.SyntaxKind.ImportType);
let containsImportAbsolutePath = false;
for (const importTypeNode of importTypeNodes) {
const child = getFirstChildOrSelf(getFirstChildOrSelf(importTypeNode));
if (ts.isStringLiteral(child) && child.text.startsWith('/')) {
containsImportAbsolutePath = true;
if (options?.warn) {
const message = `\n[@voltiso/transform] unable to inline ${getNodeText(node) || stringFromSyntaxKind(node.kind)} - resulting node text would include absolute disk path import of '${child.text}' \n @ ${getNodePositionStr(node)}`;
// eslint-disable-next-line no-console
console.warn(chalk.bgRed(message));
}
}
}
const canBeInlined = !hasSymbolsOutOfScope && !containsImportAbsolutePath;
return canBeInlined;

@@ -171,0 +195,0 @@ }

2

package.json
{
"name": "@voltiso/transform",
"version": "1.1.3",
"version": "1.1.4",
"license": "MIT",

@@ -5,0 +5,0 @@ "repository": "git://github.com/voltiso/mono.git",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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