New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@montajs/compiler

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@montajs/compiler - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

14

dist/functions/parserFunctions/attr.js

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

if (varName === undefined) {
throw new Error('Invalid input for attr: ' + input.value);
throw new Error(`Invalid input for attr`);
}

@@ -17,3 +17,3 @@ let name = varName.toString();

if (required && value === undefined) {
throw new Error('Undefined attr: ' + input.value);
throw new Error(`Undefined attr`);
}

@@ -26,9 +26,9 @@ if (value === undefined) {

if (value.type === "T_LIT" /* Literal */ && typeof value.value !== type) {
throw new Error('Invalid attr type for ' + input.value + ', expected ' + type + ' got ' + typeof value);
throw new Error(`Invalid attr type, expected ${type} got ${typeof value}`);
}
}
if (value.type === "T_LIT" /* Literal */) {
return [assignAttributeLiteral.bind(null, name, value.value)];
return [assignAttributeLiteral.bind(undefined, name, value.value)];
}
return [validateAttribute.bind(null, name, value, required, type)];
return [validateAttribute.bind(undefined, name, value, required, type)];
}

@@ -43,6 +43,6 @@ exports.attr = attr;

if (required && value === undefined) {
throw new Error('Undefined attr: ' + name);
throw new Error(`Undefined attr: ${name}`);
}
if (type !== undefined && typeof value !== type) {
throw new Error('Invalid attr type for ' + name + ', expected ' + type + ' got ' + typeof value);
throw new Error(`Invalid attr type for ${name}, expected ${type} got ${typeof value}`);
}

@@ -49,0 +49,0 @@ renderContext.setVariable(name, renderContext.getValue(token));

@@ -6,5 +6,10 @@ "use strict";

async function component(context) {
if (!context.input.value.startsWith('.')) {
context.input.value = 'components/' + context.input.value;
let token = context?.input;
if (token === undefined) {
throw new Error(`Invalid input for 'component'`);
}
if (!token.value.toString().startsWith('.')) {
token.value = `components/${token.value.toString()}`;
context.input = token;
}
return include_1.include(context);

@@ -11,0 +16,0 @@ }

@@ -6,5 +6,10 @@ "use strict";

async function extend(context) {
if (!context.input.value.startsWith('.')) {
context.input.value = 'layouts/' + context.input.value;
let token = context?.input;
if (token === undefined) {
throw new Error(`Invalid input for 'extend'`);
}
if (!token.value.toString().startsWith('.')) {
token.value = `layouts/${token.value.toString()}`;
context.input = token;
}
return include_1.include(context);

@@ -11,0 +16,0 @@ }

@@ -21,19 +21,19 @@ "use strict";

case '==':
return renderComparisonNode.bind(null, left, right, (a, b) => a == b);
return renderComparisonNode.bind(undefined, left, right, (a, b) => a == b);
case '===':
return renderComparisonNode.bind(null, left, right, (a, b) => a === b);
return renderComparisonNode.bind(undefined, left, right, (a, b) => a === b);
case '!=':
return renderComparisonNode.bind(null, left, right, (a, b) => a != b);
return renderComparisonNode.bind(undefined, left, right, (a, b) => a != b);
case '!==':
return renderComparisonNode.bind(null, left, right, (a, b) => a !== b);
return renderComparisonNode.bind(undefined, left, right, (a, b) => a !== b);
case '>':
return renderComparisonNode.bind(null, left, right, (a, b) => a > b);
return renderComparisonNode.bind(undefined, left, right, (a, b) => a > b);
case '<':
return renderComparisonNode.bind(null, left, right, (a, b) => a < b);
return renderComparisonNode.bind(undefined, left, right, (a, b) => a < b);
case '>=':
return renderComparisonNode.bind(null, left, right, (a, b) => a >= b);
return renderComparisonNode.bind(undefined, left, right, (a, b) => a >= b);
case '<=':
return renderComparisonNode.bind(null, left, right, (a, b) => a <= b);
return renderComparisonNode.bind(undefined, left, right, (a, b) => a <= b);
}
throw new Error('Invalid comparison operator: ' + this.operator.value);
throw new Error(`Invalid comparison operator: ${this.operator.value.toString()}`);
}

@@ -40,0 +40,0 @@ }

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

Logger_1.Logger.groupEnd();
return renderExpressionNode.bind(null, members);
return renderExpressionNode.bind(undefined, members);
}

@@ -46,4 +46,7 @@ }

Logger_1.Logger.groupEnd();
if (!Array.isArray(value)) {
return [value];
}
return value;
}
//# sourceMappingURL=ExpressionNode.js.map

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

Logger_1.Logger.groupEnd();
return renderFunctionNode.bind(null, runtimeFunction, functionName, {
return renderFunctionNode.bind(undefined, runtimeFunction, functionName, {
input: this.input,

@@ -77,0 +77,0 @@ params: this.params,

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

Logger_1.Logger.groupEnd();
return renderGroupNode.bind(null, children);
return renderGroupNode.bind(undefined, children);
}

@@ -30,0 +30,0 @@ }

@@ -9,3 +9,3 @@ import { ParseContext } from '../ParseContext';

/** Value of the node */
readonly value: any;
private readonly value;
constructor(value: any);

@@ -12,0 +12,0 @@ createRenderFunction(parseContext: ParseContext): Promise<RenderFn>;

@@ -15,4 +15,3 @@ "use strict";

async createRenderFunction(parseContext) {
let type = typeof this.value;
if (type === 'string' || type === 'number' || type === 'boolean') {
if (typeof this.value === 'string' || typeof this.value === 'number' || typeof this.value === 'boolean') {
Logger_1.Logger.info('CRF OutputNode');

@@ -19,0 +18,0 @@ let value = this.value.toString();

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

Logger_1.Logger.groupEnd();
return renderVariableNode.bind(null, this.keyword);
return renderVariableNode.bind(undefined, this.keyword);
}

@@ -25,0 +25,0 @@ Logger_1.Logger.info('| type: parse');

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

if (next.type !== "T_PIPE" /* Pipe */) {
throw new Error(`Unexpected token at ${next.line}:${next.col}. Expected '|', found: ${next.value}`);
throw new Error(`Unexpected token at ${next.line}:${next.col}. Expected '|', found: ${next.value.toString()}`);
}

@@ -51,3 +51,3 @@ if (!tokens.hasNext()) {

if (!Token_1.isTokenType(next, "T_LIT" /* Literal */, "T_IDENT" /* Keyword */)) {
throw new Error(`Unexpected token at ${next.line}:${next.col}. Expected value or keyword, found: ${next.value}`);
throw new Error(`Unexpected token at ${next.line}:${next.col}. Expected value or keyword, found: ${next.value.toString()}`);
}

@@ -94,3 +94,3 @@ if (peek === undefined) {

}
throw new Error(`Unexpected token in expression: ${next.value}`);
throw new Error(`Unexpected token in expression: ${next.value.toString()}`);
}

@@ -123,3 +123,3 @@ return [node];

if (next.type !== "T_COMMA" /* Comma */) {
throw new Error(`Unexpected token '${next.value}' at ${next.line}:${next.col}, expected ','`);
throw new Error(`Unexpected token '${next.value.toString()}' at ${next.line}:${next.col}, expected ','`);
}

@@ -155,6 +155,6 @@ if (!tokens.hasNext()) {

if (peek.type !== "T_ASSIGN" /* Assignment */) {
throw new Error(`Unexpected token '${peek.value}' at ${peek.line}:${peek.col}, expected '='`);
throw new Error(`Unexpected token '${peek.value.toString()}' at ${peek.line}:${peek.col}, expected '='`);
}
if (!Token_1.isTokenType(parameterValue, "T_LIT" /* Literal */, "T_IDENT" /* Keyword */)) {
throw new Error(`Unexpected token '${peek.value}' at ${peek.line}:${peek.col}, expected literal or variable name`);
throw new Error(`Unexpected token '${peek.value.toString()}' at ${peek.line}:${peek.col}, expected literal or variable name`);
}

@@ -161,0 +161,0 @@ functionNode.params.set(parameterName.value.toString(), parameterValue);

@@ -38,4 +38,12 @@ "use strict";

let next = source.next();
let escaped = false;
if (next === '\\' && (source.peekMatch('{') ||
source.peekMatch('\\') ||
(isBlock && source.peekMatch('}')) ||
(isBlock && source.peekMatch(':')))) {
escaped = true;
next = source.next();
}
// Start of a code section
if (next === '{' && source.peekBack() !== '\\') {
if (next === '{' && !escaped) {
if (currentSection.content.length > 0) {

@@ -49,3 +57,3 @@ sections.push(currentBlockName, currentSection);

// End of a function block (when in a block)
if (isBlock && next === '}' && source.peekBack() !== '\\') {
if (isBlock && next === '}' && !escaped) {
if (currentSection.content.length > 0) {

@@ -57,3 +65,3 @@ sections.push(currentBlockName, currentSection);

// New block name (when in a block)
if (isBlock && next === ':' && source.peekBack() !== '\\') {
if (isBlock && next === ':' && !escaped) {
let { name, isValid } = getBlockName(source);

@@ -60,0 +68,0 @@ if (isValid) {

@@ -51,2 +51,16 @@ "use strict";

});
test('skip escaped code section', () => {
let sections = scan_1.scan('\\{ foo }'); // Double `\\` to escape the backslash in the string
expect(sections).toHaveLength(1);
expect(sections[0]).toHaveProperty('isCode', false);
expect(sections[0]).toHaveProperty('content', '{ foo }');
});
test('do not skip doubly escaped code section', () => {
let sections = scan_1.scan('\\\\{ foo }'); // Double `\\` to escape the backslash in the string
expect(sections).toHaveLength(2);
expect(sections[0]).toHaveProperty('isCode', false);
expect(sections[0]).toHaveProperty('content', '\\');
expect(sections[1]).toHaveProperty('isCode', true);
expect(sections[1]).toHaveProperty('content', ' foo ');
});
//# sourceMappingURL=scan.spec.js.map

@@ -96,2 +96,5 @@ "use strict";

let peek = source.peek();
if (peek === undefined) {
throw new Error('Unexpected end of input');
}
let isNumberLiteral = NUMBER_MIDDLE.test(peek);

@@ -154,2 +157,5 @@ if (!isNumberLiteral) {

let peek = source.peek();
if (peek === undefined) {
throw new Error('Unexpected end of input');
}
let isValidKeyword = KEYWORD_MIDDLE.test(peek);

@@ -156,0 +162,0 @@ if (!isValidKeyword) {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RenderContext = void 0;
const Logger_1 = require("./utils/Logger");
class RenderContext {

@@ -40,3 +41,3 @@ constructor(file, variables = {}) {

if (!scopeChanged && typeof this.data !== 'object') {
throw new Error(`Cannot get property '${path}' of primitive value '${this.data}'`);
throw new Error(`Cannot get property '${path}' of primitive value`);
}

@@ -48,8 +49,11 @@ while (keys.length > 0) {

}
if (typeof data !== 'object') {
throw new TypeError(`Cannot get property '${key}' of primitive value`);
}
data = data[key];
}
if (data === undefined) {
return this.parent?.getVariable(path);
return this.parent?.getVariable(path); // eslint-disable-line @typescript-eslint/no-unsafe-return
}
return data;
return data; // eslint-disable-line @typescript-eslint/no-unsafe-return
}

@@ -70,3 +74,3 @@ setVariable(key, value) {

}
return this.getVariable(ident.value.toString());
return this.getVariable(ident.value.toString()); // eslint-disable-line @typescript-eslint/no-unsafe-return
}

@@ -105,3 +109,4 @@ createChildContext(file) {

}
throw new Error('Not renderable: ' + child);
Logger_1.Logger.error('Not renderable:', child);
throw new Error(`Not renderable`);
}));

@@ -108,0 +113,0 @@ }

@@ -10,3 +10,3 @@ {

"bugs": "https://github.com/montajs/compiler/issues",
"version": "0.1.0",
"version": "0.1.1",
"main": "dist/index.js",

@@ -13,0 +13,0 @@ "files": [

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

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

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