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 3.0.4 to 3.0.5

dist/cjs/inline/_/buildNestedQualifiedName.d.ts

7

dist/cjs/inline/_/collectSymbolNames.d.ts
import * as ts from 'typescript';
interface SymbolObject {
escapedName: string;
parent?: SymbolObject;
flags: number;
}
export declare function getSymbolPath(symbol: SymbolObject | undefined): string[];
export declare function collectSymbolNames(node: ts.Node): Set<string>;
export {};
//# sourceMappingURL=collectSymbolNames.d.ts.map

29

dist/cjs/inline/_/collectSymbolNames.js

@@ -28,26 +28,27 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.collectSymbolNames = exports.getSymbolPath = void 0;
/* eslint-disable no-bitwise */
exports.collectSymbolNames = void 0;
const ts = __importStar(require("typescript"));
function getSymbolPath(symbol) {
if (!symbol)
return [];
if ((symbol.parent?.flags ?? ts.SymbolFlags.ValueModule) &
ts.SymbolFlags.ValueModule) {
return [symbol.escapedName];
}
return [...getSymbolPath(symbol.parent), symbol.escapedName];
const getSymbolPath_1 = require("./getSymbolPath");
function isWithTypeParameters(node) {
return 'typeParameters' in node;
}
exports.getSymbolPath = getSymbolPath;
function collectSymbolNames(node) {
const result = new Set();
if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName)) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment
const symbol = node.typeName?.symbol;
result.add(getSymbolPath(symbol)[0] || node.typeName.text);
result.add((0, getSymbolPath_1.getSymbolPath)(symbol)[0] || node.typeName.text);
}
const typeParameters = isWithTypeParameters(node)
? node.typeParameters
: [];
const typeParameterNames = new Set(typeParameters.map(typeParameter => typeParameter.name.escapedText.toString()));
// console.log({ typeParameterNames })
node.forEachChild(child => {
const newSymbols = collectSymbolNames(child);
for (const newSymbol of newSymbols)
for (const newSymbol of newSymbols) {
if (typeParameterNames.has(newSymbol))
continue;
result.add(newSymbol);
}
});

@@ -54,0 +55,0 @@ // locally declared symbols

@@ -0,5 +1,8 @@

export * from './buildNestedQualifiedName';
export * from './canBeInlined';
export * from './collectNodesOfKind';
export * from './collectSymbolNames';
export * from './fixNamespaces';
export * from './getFirstChildOrSelf';
export * from './getSymbolPath';
export * from './hasNodeInlineComment';

@@ -10,2 +13,3 @@ export * from './hasNodeOfType';

export * from './simplifyNode';
export * from './SymbolObject';
//# sourceMappingURL=index.d.ts.map

@@ -19,6 +19,9 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./buildNestedQualifiedName"), exports);
__exportStar(require("./canBeInlined"), exports);
__exportStar(require("./collectNodesOfKind"), exports);
__exportStar(require("./collectSymbolNames"), exports);
__exportStar(require("./fixNamespaces"), exports);
__exportStar(require("./getFirstChildOrSelf"), exports);
__exportStar(require("./getSymbolPath"), exports);
__exportStar(require("./hasNodeInlineComment"), exports);

@@ -29,2 +32,3 @@ __exportStar(require("./hasNodeOfType"), exports);

__exportStar(require("./simplifyNode"), exports);
__exportStar(require("./SymbolObject"), exports);
//# sourceMappingURL=index.js.map

@@ -31,22 +31,4 @@ "use strict";

const ts = __importStar(require("typescript"));
const _1 = require(".");
const fixNamespaces_1 = require("./fixNamespaces");
const simplifyNode_1 = require("./simplifyNode");
function buildNestedQualifiedName(symbolPath) {
if (symbolPath.length === 1)
return ts.factory.createIdentifier(symbolPath[0]);
return ts.factory.createQualifiedName(buildNestedQualifiedName(symbolPath.slice(0, -1)), symbolPath.at(-1));
}
function fixNamespaces(ctx, node) {
function visitor(node) {
if (ts.isTypeReferenceNode(node)) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
const symbolPath = (0, _1.getSymbolPath)(node.typeName.symbol);
if (symbolPath.length === 0)
return node;
return buildNestedQualifiedName(symbolPath);
}
return ts.visitEachChild(node, visitor, ctx.transformationContext);
}
return ts.visitEachChild(node, visitor, ctx.transformationContext);
}
function simplifyAndAddComment(ctx, originalNode) {

@@ -60,3 +42,3 @@ let node = (0, simplifyNode_1.simplifyNode)(ctx, originalNode);

}
node = fixNamespaces(ctx, node);
node = (0, fixNamespaces_1.fixNamespaces)(ctx, node);
return node;

@@ -63,0 +45,0 @@ }

import * as ts from 'typescript';
interface SymbolObject {
escapedName: string;
parent?: SymbolObject;
flags: number;
}
export declare function getSymbolPath(symbol: SymbolObject | undefined): string[];
export declare function collectSymbolNames(node: ts.Node): Set<string>;
export {};
//# sourceMappingURL=collectSymbolNames.d.ts.map
// ⠀ⓥ 2023 🌩 🌩 ⠀ ⠀
// ⠀ 🌩 V͛o͛͛͛lt͛͛͛i͛͛͛͛so͛͛͛.com⠀ ⠀⠀⠀
/* eslint-disable no-bitwise */
import * as ts from 'typescript';
export function getSymbolPath(symbol) {
if (!symbol)
return [];
if ((symbol.parent?.flags ?? ts.SymbolFlags.ValueModule) &
ts.SymbolFlags.ValueModule) {
return [symbol.escapedName];
}
return [...getSymbolPath(symbol.parent), symbol.escapedName];
import { getSymbolPath } from './getSymbolPath';
function isWithTypeParameters(node) {
return 'typeParameters' in node;
}

@@ -17,10 +11,18 @@ export function collectSymbolNames(node) {

if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName)) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment
const symbol = node.typeName?.symbol;
result.add(getSymbolPath(symbol)[0] || node.typeName.text);
}
const typeParameters = isWithTypeParameters(node)
? node.typeParameters
: [];
const typeParameterNames = new Set(typeParameters.map(typeParameter => typeParameter.name.escapedText.toString()));
// console.log({ typeParameterNames })
node.forEachChild(child => {
const newSymbols = collectSymbolNames(child);
for (const newSymbol of newSymbols)
for (const newSymbol of newSymbols) {
if (typeParameterNames.has(newSymbol))
continue;
result.add(newSymbol);
}
});

@@ -27,0 +29,0 @@ // locally declared symbols

@@ -0,5 +1,8 @@

export * from './buildNestedQualifiedName';
export * from './canBeInlined';
export * from './collectNodesOfKind';
export * from './collectSymbolNames';
export * from './fixNamespaces';
export * from './getFirstChildOrSelf';
export * from './getSymbolPath';
export * from './hasNodeInlineComment';

@@ -10,2 +13,3 @@ export * from './hasNodeOfType';

export * from './simplifyNode';
export * from './SymbolObject';
//# sourceMappingURL=index.d.ts.map
// ⠀ⓥ 2023 🌩 🌩 ⠀ ⠀
// ⠀ 🌩 V͛o͛͛͛lt͛͛͛i͛͛͛͛so͛͛͛.com⠀ ⠀⠀⠀
export * from './buildNestedQualifiedName';
export * from './canBeInlined';
export * from './collectNodesOfKind';
export * from './collectSymbolNames';
export * from './fixNamespaces';
export * from './getFirstChildOrSelf';
export * from './getSymbolPath';
export * from './hasNodeInlineComment';

@@ -12,2 +15,3 @@ export * from './hasNodeOfType';

export * from './simplifyNode';
export * from './SymbolObject';
//# sourceMappingURL=index.js.map

@@ -5,22 +5,4 @@ // ⠀ⓥ 2023 🌩 🌩 ⠀ ⠀

import * as ts from 'typescript';
import { getSymbolPath } from '.';
import { fixNamespaces } from './fixNamespaces';
import { simplifyNode } from './simplifyNode';
function buildNestedQualifiedName(symbolPath) {
if (symbolPath.length === 1)
return ts.factory.createIdentifier(symbolPath[0]);
return ts.factory.createQualifiedName(buildNestedQualifiedName(symbolPath.slice(0, -1)), symbolPath.at(-1));
}
function fixNamespaces(ctx, node) {
function visitor(node) {
if (ts.isTypeReferenceNode(node)) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
const symbolPath = getSymbolPath(node.typeName.symbol);
if (symbolPath.length === 0)
return node;
return buildNestedQualifiedName(symbolPath);
}
return ts.visitEachChild(node, visitor, ctx.transformationContext);
}
return ts.visitEachChild(node, visitor, ctx.transformationContext);
}
export function simplifyAndAddComment(ctx, originalNode) {

@@ -27,0 +9,0 @@ let node = simplifyNode(ctx, originalNode);

{
"name": "@voltiso/transform",
"version": "3.0.4",
"version": "3.0.5",
"license": "MIT",

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

@@ -16,2 +16,5 @@ # `@voltiso/transform/inline`

⚠️ Currently only checks if type names are in scope - but does not check if the
types are equal!
# `@voltiso/transform/strip`

@@ -18,0 +21,0 @@

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

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

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