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

@vendure/ngx-translate-extract

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vendure/ngx-translate-extract - npm Package Compare versions

Comparing version 8.3.0 to 9.0.0

0

dist/cli/cli.d.ts
export declare const cli: any;

@@ -0,0 +0,0 @@ import yargs from 'yargs';

@@ -0,0 +0,0 @@ import { TranslationCollection } from '../../utils/translation.collection.js';

@@ -0,0 +0,0 @@ import { cyan, green, bold, dim, red } from 'colorette';

export interface TaskInterface {
execute(): void;
}
export {};
//# sourceMappingURL=task.interface.js.map

@@ -0,0 +0,0 @@ import { CompilerInterface } from './compiler.interface.js';

@@ -0,0 +0,0 @@ import { JsonCompiler } from './json.compiler.js';

@@ -0,0 +0,0 @@ import { TranslationCollection } from '../utils/translation.collection.js';

export {};
//# sourceMappingURL=compiler.interface.js.map

@@ -0,0 +0,0 @@ import { CompilerInterface } from './compiler.interface.js';

@@ -0,0 +0,0 @@ import { TranslationCollection } from '../utils/translation.collection.js';

@@ -0,0 +0,0 @@ import { CompilerInterface } from './compiler.interface.js';

@@ -0,0 +0,0 @@ import { TranslationCollection } from '../utils/translation.collection.js';

@@ -0,0 +0,0 @@ import { CompilerInterface } from './compiler.interface.js';

@@ -0,0 +0,0 @@ import { TranslationCollection } from '../utils/translation.collection.js';

@@ -0,0 +0,0 @@ export * from './utils/translation.collection.js';

@@ -0,0 +0,0 @@ export * from './utils/translation.collection.js';

12

dist/parsers/directive.parser.d.ts

@@ -1,4 +0,12 @@

import { AST, LiteralPrimitive, TmplAstBoundAttribute as BoundAttribute, TmplAstElement as Element, TmplAstNode as Node, TmplAstTemplate as Template, TmplAstText as Text, TmplAstTextAttribute as TextAttribute } from '@angular/compiler';
import { AST, LiteralPrimitive, TmplAstBoundAttribute as BoundAttribute, TmplAstElement as Element, TmplAstNode as Node, TmplAstTemplate as Template, TmplAstText as Text, TmplAstTextAttribute as TextAttribute, ParseSourceSpan } from '@angular/compiler';
import { ParserInterface } from './parser.interface.js';
import { TranslationCollection } from '../utils/translation.collection.js';
interface BlockNode {
nameSpan: ParseSourceSpan;
sourceSpan: ParseSourceSpan;
startSourceSpan: ParseSourceSpan;
endSourceSpan: ParseSourceSpan | null;
children: Node[] | undefined;
visit<Result>(visitor: unknown): Result;
}
export declare const TRANSLATE_ATTR_NAMES: string[];

@@ -9,2 +17,3 @@ type ElementLike = Element | Template;

protected getElementsWithTranslateAttribute(nodes: Node[]): ElementLike[];
protected getElementsWithTranslateAttributeFromBlockNodes(blockNode: BlockNode): ElementLike[];
protected getTextNodes(element: ElementLike): Text[];

@@ -17,2 +26,3 @@ protected hasAttributes(element: ElementLike, name: string[]): boolean;

protected isElementLike(node: Node): node is ElementLike;
protected isBlockNode(node: Node): node is BlockNode;
protected isText(node: Node): node is Text;

@@ -19,0 +29,0 @@ protected parseTemplate(template: string, path: string): Node[];

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

import { ASTWithSource, Binary, BindingPipe, Conditional, Interpolation, LiteralArray, LiteralMap, LiteralPrimitive, parseTemplate, TmplAstElement as Element, TmplAstTemplate as Template, TmplAstText as Text } from '@angular/compiler';
import { ASTWithSource, Binary, BindingPipe, Conditional, Interpolation, LiteralArray, LiteralMap, LiteralPrimitive, parseTemplate, TmplAstElement as Element, TmplAstTemplate as Template, TmplAstText as Text, TmplAstIfBlock, TmplAstSwitchBlock, TmplAstForLoopBlock, TmplAstDeferredBlock } from '@angular/compiler';
import { TranslationCollection } from '../utils/translation.collection.js';

@@ -47,4 +47,25 @@ import { extractComponentInlineTemplate, isPathAngularComponent } from '../utils/utils.js';

});
nodes.filter(this.isBlockNode).forEach((node) => elements.push(...this.getElementsWithTranslateAttributeFromBlockNodes(node)));
return elements;
}
getElementsWithTranslateAttributeFromBlockNodes(blockNode) {
let blockChildren = blockNode.children;
if (blockNode instanceof TmplAstIfBlock) {
blockChildren = blockNode.branches.map((branch) => branch.children).flat();
}
if (blockNode instanceof TmplAstSwitchBlock) {
blockChildren = blockNode.cases.map((branch) => branch.children).flat();
}
if (blockNode instanceof TmplAstForLoopBlock) {
const emptyBlockChildren = blockNode.empty?.children ?? [];
blockChildren.push(...emptyBlockChildren);
}
if (blockNode instanceof TmplAstDeferredBlock) {
const placeholderBlockChildren = blockNode.placeholder?.children ?? [];
const loadingBlockChildren = blockNode.loading?.children ?? [];
const errorBlockChildren = blockNode.error?.children ?? [];
blockChildren.push(...placeholderBlockChildren, ...loadingBlockChildren, ...errorBlockChildren);
}
return this.getElementsWithTranslateAttribute(blockChildren);
}
getTextNodes(element) {

@@ -100,2 +121,8 @@ return element.children.filter(this.isText);

}
isBlockNode(node) {
return (node.hasOwnProperty('nameSpan') &&
node.hasOwnProperty('sourceSpan') &&
node.hasOwnProperty('startSourceSpan') &&
node.hasOwnProperty('endSourceSpan'));
}
isText(node) {

@@ -102,0 +129,0 @@ return node instanceof Text;

@@ -0,0 +0,0 @@ import { ParserInterface } from './parser.interface.js';

@@ -0,0 +0,0 @@ import { tsquery } from '@phenomnomnominal/tsquery';

@@ -0,0 +0,0 @@ import { ParserInterface } from './parser.interface.js';

@@ -0,0 +0,0 @@ import { tsquery } from '@phenomnomnominal/tsquery';

@@ -0,0 +0,0 @@ import { TranslationCollection } from '../utils/translation.collection.js';

export {};
//# sourceMappingURL=parser.interface.js.map

3

dist/parsers/pipe.parser.d.ts

@@ -6,4 +6,5 @@ import { AST, TmplAstNode, BindingPipe, LiteralPrimitive, Conditional } from '@angular/compiler';

export declare class PipeParser implements ParserInterface {
extract(source: string, filePath: string): TranslationCollection | null;
extract(source: string, filePath: string): TranslationCollection;
protected findPipesInNode(node: any): BindingPipe[];
protected extractPipesFromChildNodes(nodeChildren: TmplAstNode[]): BindingPipe[];
protected parseTranslationKeysFromPipe(pipeContent: BindingPipe | LiteralPrimitive | Conditional): string[];

@@ -10,0 +11,0 @@ protected getTranslatablesFromAst(ast: AST): BindingPipe[];

@@ -21,9 +21,16 @@ import { parseTemplate, BindingPipe, LiteralPrimitive, Conditional, Binary, LiteralMap, LiteralArray, Interpolation, Call } from '@angular/compiler';

findPipesInNode(node) {
let ret = [];
if (node?.children) {
ret = node.children.reduce((result, childNode) => {
const children = this.findPipesInNode(childNode);
return result.concat(children);
}, [ret]);
const ret = [];
const nodeChildren = node?.children ?? [];
const nodeBranchesOrCases = node?.branches ?? node?.cases ?? [];
const emptyBlockChildren = node?.empty?.children ?? [];
const errorBlockChildren = node?.error?.children ?? [];
const loadingBlockChildren = node?.loading?.children ?? [];
const placeholderBlockChildren = node?.placeholder?.children ?? [];
nodeChildren.push(...emptyBlockChildren, ...errorBlockChildren, ...loadingBlockChildren, ...placeholderBlockChildren);
if (nodeChildren.length > 0) {
ret.push(...this.extractPipesFromChildNodes(nodeChildren));
}
nodeBranchesOrCases.forEach((branch) => {
ret.push(...this.extractPipesFromChildNodes(branch.children));
});
if (node?.value?.ast) {

@@ -34,3 +41,3 @@ ret.push(...this.getTranslatablesFromAst(node.value.ast));

const translateableAttributes = node.attributes.filter((attr) => TRANSLATE_PIPE_NAMES.includes(attr.name));
ret = [...ret, ...translateableAttributes];
ret.push(...ret, ...translateableAttributes);
}

@@ -53,2 +60,5 @@ if (node?.inputs) {

}
extractPipesFromChildNodes(nodeChildren) {
return nodeChildren.map((childNode) => this.findPipesInNode(childNode)).flat();
}
parseTranslationKeysFromPipe(pipeContent) {

@@ -55,0 +65,0 @@ const ret = [];

@@ -0,0 +0,0 @@ import { ClassDeclaration, CallExpression, SourceFile } from 'typescript';

@@ -0,0 +0,0 @@ import { tsquery } from '@phenomnomnominal/tsquery';

@@ -0,0 +0,0 @@ import { TranslationCollection } from '../utils/translation.collection.js';

@@ -0,0 +0,0 @@ export class KeyAsDefaultValuePostProcessor {

@@ -0,0 +0,0 @@ import { TranslationCollection } from '../utils/translation.collection.js';

@@ -0,0 +0,0 @@ export class NullAsDefaultValuePostProcessor {

@@ -0,0 +0,0 @@ import { TranslationCollection } from '../utils/translation.collection.js';

export {};
//# sourceMappingURL=post-processor.interface.js.map

@@ -0,0 +0,0 @@ import { TranslationCollection } from '../utils/translation.collection.js';

@@ -0,0 +0,0 @@ export class PurgeObsoleteKeysPostProcessor {

@@ -0,0 +0,0 @@ import { TranslationCollection } from '../utils/translation.collection.js';

@@ -0,0 +0,0 @@ export class SortByKeyPostProcessor {

@@ -0,0 +0,0 @@ import { TranslationCollection } from '../utils/translation.collection.js';

@@ -0,0 +0,0 @@ export class StringAsDefaultValuePostProcessor {

@@ -0,0 +0,0 @@ import { TranslationCollection } from '../utils/translation.collection.js';

@@ -0,0 +0,0 @@ export class StripPrefixPostProcessor {

@@ -0,0 +0,0 @@ import pkg, { Node, NamedImports, ClassDeclaration, ConstructorDeclaration, CallExpression, Expression } from 'typescript';

@@ -0,0 +0,0 @@ import { tsquery } from '@phenomnomnominal/tsquery';

@@ -0,0 +0,0 @@ declare module 'braces' {

@@ -0,0 +0,0 @@ import * as os from 'os';

@@ -0,0 +0,0 @@ export interface TranslationType {

@@ -0,0 +0,0 @@ export class TranslationCollection {

export declare function isPathAngularComponent(path: string): boolean;
export declare function extractComponentInlineTemplate(contents: string): string;
export declare function stripBOM(contents: string): string;

@@ -0,0 +0,0 @@ export function isPathAngularComponent(path) {

{
"name": "@vendure/ngx-translate-extract",
"version": "8.3.0",
"version": "9.0.0",
"description": "Extract strings from projects using ngx-translate",

@@ -28,2 +28,3 @@ "author": "Kim Biesbjerg <kim@biesbjerg.com>",

"devDependencies": {
"@angular/compiler": "^17.0.3",
"@types/braces": "^3.0.1",

@@ -37,5 +38,5 @@ "@types/chai": "^4.3.3",

"@types/yargs": "^17.0.20",
"@typescript-eslint/eslint-plugin": "^5.48.2",
"@typescript-eslint/eslint-plugin-tslint": "^5.48.2",
"@typescript-eslint/parser": "^5.48.2",
"@typescript-eslint/eslint-plugin": "^6.12.0",
"@typescript-eslint/eslint-plugin-tslint": "^6.12.0",
"@typescript-eslint/parser": "^6.12.0",
"chai": "^4.3.6",

@@ -51,7 +52,7 @@ "cross-env": "^7.0.3",

"ts-node": "^10.4.0",
"typescript": "^4.5.2"
"typescript": "~5.2.2"
},
"peerDependencies": {
"@angular/compiler": ">=13.1.2",
"typescript": ">=4.4.0"
"@angular/compiler": ">=17.0.0",
"typescript": ">=5.2.0"
},

@@ -93,3 +94,3 @@ "main": "dist/index.js",

"engines": {
"node": ">=16",
"node": ">=18.13.0",
"npm": ">=8"

@@ -96,0 +97,0 @@ },

@@ -29,5 +29,5 @@ # ngx-translate-extract

| ---------- | ------------------------------------------------------------------------------------------ |
| 14 | 8.x.x+ |
| 13 | 8.x.x+ |
| 8.x – 12.x | [@biesbjerg/ngx-translate-extract](https://github.com/biesbjerg/ngx-translate-extract) 7.x |
| >=17 | 9.x |
| 13 – 16 | 8.x |
| 8 – 12 | [@biesbjerg/ngx-translate-extract](https://github.com/biesbjerg/ngx-translate-extract) 7.x |

@@ -34,0 +34,0 @@ Add a script to your project's `package.json`:

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