melody-extension-core
Advanced tools
Comparing version 1.2.0-commit.549dcb61 to 1.2.0-commit.60c4cb49
{ | ||
"name": "melody-extension-core", | ||
"version": "1.2.0-commit.549dcb61", | ||
"version": "1.2.0-commit.60c4cb49", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -57,2 +57,3 @@ /** | ||
'url_encode', | ||
'trim', | ||
].reduce((map, filterName) => { | ||
@@ -59,0 +60,0 @@ map[filterName] = 'melody-runtime'; |
@@ -36,4 +36,6 @@ /** | ||
advice: `The type declaration for autoescape must be a simple string such as 'html' or 'js'. | ||
I expected the current string to end with a ${stringStartToken.text} but instead found ${Types | ||
.ERROR_TABLE[tokens.lat(0)] || tokens.lat(0)}.`, | ||
I expected the current string to end with a ${ | ||
stringStartToken.text | ||
} but instead found ${Types.ERROR_TABLE[tokens.lat(0)] || | ||
tokens.lat(0)}.`, | ||
}); | ||
@@ -49,5 +51,5 @@ } | ||
pos: tokens.la(0).pos, | ||
advice: `Expected type of autoescape to be a string, boolean or not specified. Found ${tokens.la( | ||
0 | ||
).type} instead.`, | ||
advice: `Expected type of autoescape to be a string, boolean or not specified. Found ${ | ||
tokens.la(0).type | ||
} instead.`, | ||
}); | ||
@@ -54,0 +56,0 @@ } |
@@ -51,5 +51,7 @@ /** | ||
unexpectedToken.type == Types.SYMBOL | ||
? `Expected end of block ${nameToken.text} but instead found end of block ${tokens.la( | ||
0 | ||
).text}.` | ||
? `Expected end of block ${ | ||
nameToken.text | ||
} but instead found end of block ${ | ||
tokens.la(0).text | ||
}.` | ||
: `endblock must be followed by either '%}' or the name of the open block. Found a token of type ${Types | ||
@@ -56,0 +58,0 @@ .ERROR_TABLE[unexpectedToken.type] || |
@@ -43,3 +43,4 @@ /** | ||
const consequent = parser.parse(matchConsequent).expressions; | ||
alternate = (alternate || ifStatement | ||
alternate = ( | ||
alternate || ifStatement | ||
).alternate = new IfStatement(test, consequent); | ||
@@ -46,0 +47,0 @@ } |
@@ -61,3 +61,5 @@ /** | ||
parser.error({ | ||
title: `Macro name mismatch, expected "${nameToken.text}" but found "${nameEndToken.text}"`, | ||
title: `Macro name mismatch, expected "${ | ||
nameToken.text | ||
}" but found "${nameEndToken.text}"`, | ||
pos: nameEndToken.pos, | ||
@@ -64,0 +66,0 @@ }); |
@@ -33,4 +33,15 @@ /** | ||
key = null, | ||
async = false, | ||
delayBy = 0, | ||
argument = null; | ||
if (tokens.test(Types.SYMBOL, 'async')) { | ||
// we might be looking at an async mount | ||
const nextToken = tokens.la(1); | ||
if (nextToken.type === Types.STRING_START) { | ||
async = true; | ||
tokens.next(); | ||
} | ||
} | ||
if (tokens.test(Types.STRING_START)) { | ||
@@ -54,4 +65,55 @@ source = parser.matchStringExpression(); | ||
const mountStatement = new MountStatement(name, source, key, argument); | ||
if (async) { | ||
if (tokens.nextIf(Types.SYMBOL, 'delay')) { | ||
tokens.expect(Types.SYMBOL, 'placeholder'); | ||
tokens.expect(Types.SYMBOL, 'by'); | ||
delayBy = Number.parseInt(tokens.expect(Types.NUMBER).text, 10); | ||
if (tokens.nextIf(Types.SYMBOL, 's')) { | ||
delayBy *= 1000; | ||
} else { | ||
tokens.expect(Types.SYMBOL, 'ms'); | ||
} | ||
} | ||
} | ||
const mountStatement = new MountStatement( | ||
name, | ||
source, | ||
key, | ||
argument, | ||
async, | ||
delayBy | ||
); | ||
if (async) { | ||
tokens.expect(Types.TAG_END); | ||
mountStatement.body = parser.parse((tokenText, token, tokens) => { | ||
return ( | ||
token.type === Types.TAG_START && | ||
(tokens.test(Types.SYMBOL, 'catch') || | ||
tokens.test(Types.SYMBOL, 'endmount')) | ||
); | ||
}); | ||
if (tokens.nextIf(Types.SYMBOL, 'catch')) { | ||
const errorVariableName = tokens.expect(Types.SYMBOL); | ||
mountStatement.errorVariableName = createNode( | ||
Identifier, | ||
errorVariableName, | ||
errorVariableName.text | ||
); | ||
tokens.expect(Types.TAG_END); | ||
mountStatement.otherwise = parser.parse( | ||
(tokenText, token, tokens) => { | ||
return ( | ||
token.type === Types.TAG_START && | ||
tokens.test(Types.SYMBOL, 'endmount') | ||
); | ||
} | ||
); | ||
} | ||
tokens.expect(Types.SYMBOL, 'endmount'); | ||
} | ||
setStartFromToken(mountStatement, token); | ||
@@ -58,0 +120,0 @@ setEndFromToken(mountStatement, tokens.expect(Types.TAG_END)); |
@@ -64,3 +64,5 @@ /** | ||
key?: Node, | ||
argument?: Node | ||
argument?: Node, | ||
async?: Boolean, | ||
delayBy?: Number | ||
) { | ||
@@ -72,7 +74,20 @@ super(); | ||
this.argument = argument; | ||
this.async = async; | ||
this.delayBy = delayBy; | ||
this.errorVariableName = null; | ||
this.body = null; | ||
this.otherwise = null; | ||
} | ||
} | ||
type(MountStatement, 'MountStatement'); | ||
alias(MountStatement, 'Statement'); | ||
visitor(MountStatement, 'name', 'source', 'key', 'argument'); | ||
alias(MountStatement, 'Statement', 'Scope'); | ||
visitor( | ||
MountStatement, | ||
'name', | ||
'source', | ||
'key', | ||
'argument', | ||
'body', | ||
'otherwise' | ||
); | ||
@@ -79,0 +94,0 @@ export class DoStatement extends Node { |
@@ -118,10 +118,2 @@ /** | ||
}, | ||
trim(path) { | ||
path.replaceWithJS( | ||
t.callExpression( | ||
t.memberExpression(path.node.target, t.identifier('trim')), | ||
path.node.arguments | ||
) | ||
); | ||
}, | ||
convert_encoding(path) { | ||
@@ -128,0 +120,0 @@ // encoding conversion is not supported |
@@ -38,3 +38,5 @@ /** | ||
path.node.pos, | ||
`The range function accepts 1 to 3 arguments but you have specified ${args.length} arguments instead.` | ||
`The range function accepts 1 to 3 arguments but you have specified ${ | ||
args.length | ||
} arguments instead.` | ||
); | ||
@@ -41,0 +43,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
255413
6372