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

@intlify/bundle-utils

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@intlify/bundle-utils - npm Package Compare versions

Comparing version 3.1.1 to 3.1.2

@@ -40,2 +40,3 @@ import { CompileError, ResourceNode } from '@intlify/message-compiler';

source: string;
path: string;
code?: CompileError['code'];

@@ -75,3 +76,3 @@ domain?: CompileError['domain'];

export declare function createCodeGenerator(options?: CodeGenOptions): CodeGenerator;
export declare function generateMessageFunction(msg: string, options: CodeGenOptions): CodeGenResult<ResourceNode>;
export declare function generateMessageFunction(msg: string, options: CodeGenOptions, path?: string[]): CodeGenResult<ResourceNode>;
export declare function mapLinesColumns(resMap: RawSourceMap, codeMaps: Map<string, RawSourceMap>, inSourceMap?: RawSourceMap): RawSourceMap | null;

@@ -97,3 +97,3 @@ "use strict";

}
function generateMessageFunction(msg, options) {
function generateMessageFunction(msg, options, path) {
const env = options.env != null ? options.env : 'development';

@@ -107,2 +107,3 @@ const onError = options.onError;

source: msg,
path: path ? path.join('.') : '',
code: err.code,

@@ -109,0 +110,0 @@ domain: err.domain,

@@ -59,2 +59,3 @@ "use strict";

const propsCountStack = [];
const pathStack = [];
const itemsCountStack = [];

@@ -101,2 +102,4 @@ const { forceStringify } = generator.context();

const lastIndex = itemsCountStack.length - 1;
const currentCount = parent.elements.length - itemsCountStack[lastIndex];
pathStack.push(currentCount.toString());
itemsCountStack[lastIndex] = --itemsCountStack[lastIndex];

@@ -113,3 +116,4 @@ }

generator.push(`${JSON.stringify(name)}: `);
const { code, map } = (0, codegen_1.generateMessageFunction)(value, options);
pathStack.push(name.toString());
const { code, map } = (0, codegen_1.generateMessageFunction)(value, options, pathStack);
sourceMap && map != null && codeMaps.set(value, map);

@@ -122,3 +126,4 @@ generator.push(`${code}`, node.value, value);

generator.push(`${JSON.stringify(name)}: `);
const { code, map } = (0, codegen_1.generateMessageFunction)(strValue, options);
pathStack.push(name.toString());
const { code, map } = (0, codegen_1.generateMessageFunction)(strValue, options, pathStack);
sourceMap && map != null && codeMaps.set(strValue, map);

@@ -129,2 +134,3 @@ generator.push(`${code}`, node.value, strValue);

generator.push(`${JSON.stringify(name)}: ${JSON.stringify(value)}`);
pathStack.push(name.toString());
}

@@ -139,2 +145,3 @@ }

generator.push(`${JSON.stringify(name)}: `);
pathStack.push(name.toString());
}

@@ -147,2 +154,8 @@ const lastIndex = propsCountStack.length - 1;

generator.indent();
if (parent.type === 'JSONArrayExpression') {
const lastIndex = itemsCountStack.length - 1;
const currentCount = parent.elements.length - itemsCountStack[lastIndex];
pathStack.push(currentCount.toString());
itemsCountStack[lastIndex] = --itemsCountStack[lastIndex];
}
itemsCountStack.push(node.elements.length);

@@ -152,6 +165,9 @@ break;

if (parent.type === 'JSONArrayExpression') {
const lastIndex = itemsCountStack.length - 1;
const currentCount = parent.elements.length - itemsCountStack[lastIndex];
pathStack.push(currentCount.toString());
if (node.type === 'JSONLiteral') {
const value = node.value;
if ((0, shared_1.isString)(value)) {
const { code, map } = (0, codegen_1.generateMessageFunction)(value, options);
const { code, map } = (0, codegen_1.generateMessageFunction)(value, options, pathStack);
sourceMap && map != null && codeMaps.set(value, map);

@@ -163,3 +179,3 @@ generator.push(`${code}`, node, value);

const strValue = JSON.stringify(value);
const { code, map } = (0, codegen_1.generateMessageFunction)(strValue, options);
const { code, map } = (0, codegen_1.generateMessageFunction)(strValue, options, pathStack);
sourceMap && map != null && codeMaps.set(strValue, map);

@@ -173,3 +189,2 @@ generator.push(`${code}`, node, strValue);

}
const lastIndex = itemsCountStack.length - 1;
itemsCountStack[lastIndex] = --itemsCountStack[lastIndex];

@@ -200,2 +215,3 @@ }

if (propsCountStack[propsCountStack.length - 1] === 0) {
pathStack.pop();
propsCountStack.pop();

@@ -207,2 +223,3 @@ }

if (itemsCountStack[itemsCountStack.length - 1] !== 0) {
pathStack.pop();
generator.pushline(`,`);

@@ -214,2 +231,3 @@ }

if (propsCountStack[propsCountStack.length - 1] !== 0) {
pathStack.pop();
generator.pushline(`,`);

@@ -220,2 +238,3 @@ }

if (itemsCountStack[itemsCountStack.length - 1] === 0) {
pathStack.pop();
itemsCountStack.pop();

@@ -227,2 +246,3 @@ }

if (itemsCountStack[itemsCountStack.length - 1] !== 0) {
pathStack.pop();
generator.pushline(`,`);

@@ -235,2 +255,3 @@ }

if (itemsCountStack[itemsCountStack.length - 1] !== 0) {
pathStack.pop();
generator.pushline(`,`);

@@ -237,0 +258,0 @@ }

@@ -49,2 +49,3 @@ "use strict";

const propsCountStack = [];
const pathStack = [];
const itemsCountStack = [];

@@ -90,2 +91,4 @@ const { forceStringify } = generator.context();

const lastIndex = itemsCountStack.length - 1;
const currentCount = parent.entries.length - itemsCountStack[lastIndex];
pathStack.push(currentCount.toString());
itemsCountStack[lastIndex] = --itemsCountStack[lastIndex];

@@ -103,3 +106,4 @@ }

generator.push(`${JSON.stringify(name)}: `);
const { code, map } = (0, codegen_1.generateMessageFunction)(value, options);
name && pathStack.push(name.toString());
const { code, map } = (0, codegen_1.generateMessageFunction)(value, options, pathStack);
sourceMap && map != null && codeMaps.set(value, map);

@@ -112,3 +116,4 @@ generator.push(`${code}`, node.value, value);

generator.push(`${JSON.stringify(name)}: `);
const { code, map } = (0, codegen_1.generateMessageFunction)(strValue, options);
name && pathStack.push(name.toString());
const { code, map } = (0, codegen_1.generateMessageFunction)(strValue, options, pathStack);
sourceMap && map != null && codeMaps.set(strValue, map);

@@ -119,2 +124,3 @@ generator.push(`${code}`, node.value, strValue);

generator.push(`${JSON.stringify(name)}: ${JSON.stringify(value)}`);
name && pathStack.push(name.toString());
}

@@ -130,2 +136,3 @@ }

generator.push(`${JSON.stringify(name)}: `);
name && pathStack.push(name.toString());
}

@@ -138,2 +145,8 @@ const lastIndex = propsCountStack.length - 1;

generator.indent();
if (parent.type === 'YAMLSequence') {
const lastIndex = itemsCountStack.length - 1;
const currentCount = parent.entries.length - itemsCountStack[lastIndex];
pathStack.push(currentCount.toString());
itemsCountStack[lastIndex] = --itemsCountStack[lastIndex];
}
itemsCountStack.push(node.entries.length);

@@ -143,6 +156,9 @@ break;

if (parent.type === 'YAMLSequence') {
const lastIndex = itemsCountStack.length - 1;
const currentCount = parent.entries.length - itemsCountStack[lastIndex];
pathStack.push(currentCount.toString());
if (node.type === 'YAMLScalar') {
const value = node.value;
if ((0, shared_1.isString)(value)) {
const { code, map } = (0, codegen_1.generateMessageFunction)(value, options);
const { code, map } = (0, codegen_1.generateMessageFunction)(value, options, pathStack);
sourceMap && map != null && codeMaps.set(value, map);

@@ -154,3 +170,3 @@ generator.push(`${code}`, node, value);

const strValue = JSON.stringify(value);
const { code, map } = (0, codegen_1.generateMessageFunction)(strValue, options);
const { code, map } = (0, codegen_1.generateMessageFunction)(strValue, options, pathStack);
sourceMap && map != null && codeMaps.set(strValue, map);

@@ -164,3 +180,2 @@ generator.push(`${code}`, node, strValue);

}
const lastIndex = itemsCountStack.length - 1;
itemsCountStack[lastIndex] = --itemsCountStack[lastIndex];

@@ -191,2 +206,3 @@ }

if (propsCountStack[propsCountStack.length - 1] === 0) {
pathStack.pop();
propsCountStack.pop();

@@ -198,2 +214,3 @@ }

if (itemsCountStack[itemsCountStack.length - 1] !== 0) {
pathStack.pop();
generator.pushline(`,`);

@@ -205,2 +222,3 @@ }

if (propsCountStack[propsCountStack.length - 1] !== 0) {
pathStack.pop();
generator.pushline(`,`);

@@ -211,2 +229,3 @@ }

if (itemsCountStack[itemsCountStack.length - 1] === 0) {
pathStack.pop();
itemsCountStack.pop();

@@ -218,2 +237,3 @@ }

if (itemsCountStack[itemsCountStack.length - 1] !== 0) {
pathStack.pop();
generator.pushline(`,`);

@@ -226,2 +246,3 @@ }

if (itemsCountStack[itemsCountStack.length - 1] !== 0) {
pathStack.pop();
generator.pushline(`,`);

@@ -228,0 +249,0 @@ }

{
"name": "@intlify/bundle-utils",
"description": "Bundle utilities for Intlify project",
"version": "3.1.1",
"version": "3.1.2",
"author": {

@@ -6,0 +6,0 @@ "name": "kazuya kawaguchi",