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

@dtsgenerator/replace-namespace

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dtsgenerator/replace-namespace - npm Package Compare versions

Comparing version 1.3.2 to 1.4.0

62

index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var typescript_1 = tslib_1.__importDefault(require("typescript"));
var dtsgenerator_1 = require("dtsgenerator");
// eslint-disable-next-line @typescript-eslint/no-var-requires

@@ -194,3 +194,3 @@ var packageJson = require('./package.json');

var e_5, _a;
if (typescript_1.default.isModuleDeclaration(state)) {
if (dtsgenerator_1.ts.isModuleDeclaration(state)) {
var dec = state;

@@ -208,3 +208,3 @@ var name_1 = dec.name;

if (value == null) {
if (dec.body != null && typescript_1.default.isModuleBlock(dec.body)) {
if (dec.body != null && dtsgenerator_1.ts.isModuleBlock(dec.body)) {
dec.body.statements.forEach(function (s) { return result.push(s); });

@@ -251,29 +251,35 @@ }

}
return typescript_1.default.createNodeArray(result);
return dtsgenerator_1.ts.createNodeArray(result);
}
function visit(node) {
if (typescript_1.default.isModuleDeclaration(node)) {
if (dtsgenerator_1.ts.isModuleDeclaration(node)) {
var prev = path.concat();
path.push(node.name.text);
node = typescript_1.default.visitEachChild(node, visit, context);
node = dtsgenerator_1.ts.visitEachChild(node, visit, context);
path = prev;
}
else {
node = typescript_1.default.visitEachChild(node, visit, context);
node = dtsgenerator_1.ts.visitEachChild(node, visit, context);
}
if (!typescript_1.default.isSourceFile(node) && !typescript_1.default.isModuleBlock(node)) {
if (!dtsgenerator_1.ts.isSourceFile(node) && !dtsgenerator_1.ts.isModuleBlock(node)) {
return node;
}
node.statements = replaceModuleName(node.statements);
Object.assign(node, {
statements: replaceModuleName(node.statements),
});
return node;
}
var inter = typescript_1.default.visitNode(root, visit);
var inter = dtsgenerator_1.ts.visitNode(root, visit);
return [inter, converted];
}
function setName(node, name) {
node.name = typescript_1.default.createIdentifier(name);
Object.assign(node, {
name: dtsgenerator_1.ts.createIdentifier(name),
});
}
function addChildModuleDeclaration(parent, name) {
var newModule = typescript_1.default.createModuleDeclaration(undefined, undefined, typescript_1.default.createIdentifier(name), parent.body, parent.flags);
parent.body = typescript_1.default.createModuleBlock([newModule]);
var newModule = dtsgenerator_1.ts.createModuleDeclaration(undefined, undefined, dtsgenerator_1.ts.createIdentifier(name), parent.body, parent.flags);
Object.assign(parent, {
body: dtsgenerator_1.ts.createModuleBlock([newModule]),
});
return newModule;

@@ -283,4 +289,4 @@ }

function visit(node) {
node = typescript_1.default.visitEachChild(node, visit, context);
if (!typescript_1.default.isTypeReferenceNode(node)) {
node = dtsgenerator_1.ts.visitEachChild(node, visit, context);
if (!dtsgenerator_1.ts.isTypeReferenceNode(node)) {
return node;

@@ -291,6 +297,8 @@ }

var converted = convertNames(names, mapping);
node.typeName = packEntityName(converted);
Object.assign(node, {
typeName: packEntityName(converted),
});
return node;
}
return typescript_1.default.visitNode(root, visit);
return dtsgenerator_1.ts.visitNode(root, visit);
}

@@ -300,6 +308,6 @@ function flattenEntityName(name) {

function visit(node) {
if (typescript_1.default.isIdentifier(node)) {
if (dtsgenerator_1.ts.isIdentifier(node)) {
result.push(node.escapedText.toString());
}
else if (typescript_1.default.isQualifiedName(node)) {
else if (dtsgenerator_1.ts.isQualifiedName(node)) {
visit(node.left);

@@ -313,5 +321,5 @@ visit(node.right);

function packEntityName(names) {
var result = typescript_1.default.createIdentifier(names[0]);
var result = dtsgenerator_1.ts.createIdentifier(names[0]);
for (var i = 1; i < names.length; i++) {
result = typescript_1.default.createQualifiedName(result, typescript_1.default.createIdentifier(names[i]));
result = dtsgenerator_1.ts.createQualifiedName(result, dtsgenerator_1.ts.createIdentifier(names[i]));
}

@@ -330,6 +338,6 @@ return result;

var m = modifiers_1_1.value;
if (m.kind === typescript_1.default.SyntaxKind.ExportKeyword) {
if (m.kind === dtsgenerator_1.ts.SyntaxKind.ExportKeyword) {
continue;
}
if (m.kind === typescript_1.default.SyntaxKind.DeclareKeyword) {
if (m.kind === dtsgenerator_1.ts.SyntaxKind.DeclareKeyword) {
found = true;

@@ -349,5 +357,5 @@ }

if (!found) {
result.push(typescript_1.default.createModifier(typescript_1.default.SyntaxKind.DeclareKeyword));
result.push(dtsgenerator_1.ts.createModifier(dtsgenerator_1.ts.SyntaxKind.DeclareKeyword));
}
return typescript_1.default.createNodeArray(result);
return dtsgenerator_1.ts.createNodeArray(result);
}

@@ -357,3 +365,5 @@ try {

var state = _c.value;
state.modifiers = replaceModifiers(state.modifiers);
Object.assign(state, {
modifiers: replaceModifiers(state.modifiers),
});
}

@@ -360,0 +370,0 @@ }

@@ -1,3 +0,2 @@

import { Plugin, PluginContext } from 'dtsgenerator';
import ts from 'typescript';
import { ts, Plugin, PluginContext } from 'dtsgenerator';

@@ -239,3 +238,6 @@ interface Replacer {

node.statements = replaceModuleName(node.statements);
Object.assign<typeof node, Partial<typeof node>>(node, {
statements: replaceModuleName(node.statements),
});
return node;

@@ -248,3 +250,5 @@ }

function setName(node: ts.ModuleDeclaration, name: string): void {
node.name = ts.createIdentifier(name);
Object.assign<typeof node, Partial<typeof node>>(node, {
name: ts.createIdentifier(name),
});
}

@@ -262,3 +266,5 @@ function addChildModuleDeclaration(

);
parent.body = ts.createModuleBlock([newModule]);
Object.assign<typeof parent, Partial<typeof parent>>(parent, {
body: ts.createModuleBlock([newModule]),
});
return newModule;

@@ -281,4 +287,7 @@ }

const converted = convertNames(names, mapping);
node.typeName = packEntityName(converted);
Object.assign<typeof node, Partial<typeof node>>(node, {
typeName: packEntityName(converted),
});
return node;

@@ -333,3 +342,5 @@ }

for (const state of root.statements) {
state.modifiers = replaceModifiers(state.modifiers);
Object.assign<typeof state, Partial<typeof state>>(state, {
modifiers: replaceModifiers(state.modifiers),
});
}

@@ -336,0 +347,0 @@ return root;

{
"name": "@dtsgenerator/replace-namespace",
"version": "1.3.2",
"version": "1.4.0",
"description": "replace the namespace names",

@@ -10,2 +10,3 @@ "main": "index.js",

"scripts": {
"clean": "rimraf index.js test/**/*.js *.tsbuildinfo",
"lint": "eslint *.ts **/*.ts",

@@ -38,20 +39,20 @@ "lint:fix": "npm run lint -- --fix",

"devDependencies": {
"@types/mocha": "^8.0.0",
"@types/node": "^14.0.23",
"@typescript-eslint/eslint-plugin": "^3.6.1",
"@typescript-eslint/parser": "^3.6.1",
"cross-env": "^7.0.2",
"dtsgenerator": "^3.2.0",
"eslint": "^7.5.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-prettier": "^3.1.4",
"mocha": "^8.0.1",
"@types/mocha": "^8.2.0",
"@types/node": "^14.14.14",
"@typescript-eslint/eslint-plugin": "^4.10.0",
"@typescript-eslint/parser": "^4.10.0",
"cross-env": "^7.0.3",
"dtsgenerator": "^3.5.0",
"eslint": "^7.16.0",
"eslint-config-prettier": "^7.1.0",
"eslint-plugin-prettier": "^3.3.0",
"mocha": "^8.2.1",
"nyc": "^15.1.0",
"prettier": "^2.0.5",
"ts-node": "^8.10.2",
"typescript": "^3.9.7"
"prettier": "^2.2.1",
"rimraf": "^3.0.2",
"ts-node": "^9.1.1"
},
"dependencies": {
"tslib": "^2.0.0"
"tslib": "^2.0.3"
}
}
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