melody-extension-core
Advanced tools
Comparing version 1.2.0-commit.f9b4ed0d to 1.2.0-e395b88.5
{ | ||
"name": "melody-extension-core", | ||
"version": "1.2.0-commit.f9b4ed0d", | ||
"version": "1.2.0-e395b88.5+e395b88", | ||
"description": "", | ||
@@ -18,7 +18,2 @@ "main": "./lib/index.js", | ||
}, | ||
"bundledDependencies": [ | ||
"babel-types", | ||
"babel-template", | ||
"shortid" | ||
], | ||
"peerDependencies": { | ||
@@ -31,5 +26,3 @@ "melody-idom": "^1.1.0", | ||
}, | ||
"devDependencies": { | ||
"rollup-plugin-babel": "^2.6.1" | ||
} | ||
"gitHead": "e395b8869e8b75fec7b9211e99bdaaf7963a11c7" | ||
} |
@@ -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 { |
@@ -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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
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
0
28
211382
4544
3
1