@weborigami/language 0.3.4-jse.9 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/compiler/origami.pegjs +10 -2
- package/src/compiler/parse.js +113 -70
- package/src/runtime/jsGlobals.js +87 -8
- package/src/runtime/ops.js +9 -4
- package/test/compiler/parse.test.js +13 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weborigami/language",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Web Origami expression language compiler and runtime",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./main.js",
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"typescript": "5.8.2"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@weborigami/async-tree": "0.
|
|
15
|
-
"@weborigami/types": "0.
|
|
14
|
+
"@weborigami/async-tree": "0.4.1",
|
|
15
|
+
"@weborigami/types": "0.4.1",
|
|
16
16
|
"watcher": "2.3.1",
|
|
17
17
|
"yaml": "2.7.0"
|
|
18
18
|
},
|
|
@@ -651,6 +651,9 @@ primary
|
|
|
651
651
|
program "Origami program"
|
|
652
652
|
= shebang? @expression
|
|
653
653
|
|
|
654
|
+
programMode
|
|
655
|
+
= &{ return options.mode === "program" }
|
|
656
|
+
|
|
654
657
|
propertyAccess
|
|
655
658
|
= __ "." __ property:identifierLiteral {
|
|
656
659
|
return annotate([markers.property, property], location());
|
|
@@ -709,7 +712,10 @@ shiftOperator
|
|
|
709
712
|
// A shorthand lambda expression: `=foo(_)`
|
|
710
713
|
shorthandFunction "lambda function"
|
|
711
714
|
// Avoid a following equal sign (for an equality)
|
|
712
|
-
= shellMode "=" !"=" __ definition:implicitParenthesesCallExpression {
|
|
715
|
+
= (shellMode / programMode) "=" !"=" __ definition:implicitParenthesesCallExpression {
|
|
716
|
+
if (options.mode === "program") {
|
|
717
|
+
console.warn("Warning: the shorthand function syntax is deprecated in Origami programs. Use arrow syntax instead.");
|
|
718
|
+
}
|
|
713
719
|
const lambdaParameters = annotate(
|
|
714
720
|
[annotate([ops.literal, "_"], location())],
|
|
715
721
|
location()
|
|
@@ -890,10 +896,12 @@ unaryOperator
|
|
|
890
896
|
/ minus
|
|
891
897
|
|
|
892
898
|
whitespace
|
|
899
|
+
= (whitespaceChar / comment)+
|
|
900
|
+
|
|
901
|
+
whitespaceChar
|
|
893
902
|
// JavaScript considers a large number of characters whitespace so we use the
|
|
894
903
|
// `/s` definition to avoid missing any.
|
|
895
904
|
= char:. &{ return /\s/.test(char); } { return char; }
|
|
896
|
-
/ comment
|
|
897
905
|
|
|
898
906
|
whitespaceWithNewLine
|
|
899
907
|
= inlineSpace* comment? newLine __
|
package/src/compiler/parse.js
CHANGED
|
@@ -205,7 +205,7 @@ function peg$parse(input, options) {
|
|
|
205
205
|
var peg$FAILED = {};
|
|
206
206
|
var peg$source = options.grammarSource;
|
|
207
207
|
|
|
208
|
-
var peg$startRuleFunctions = { __: peg$parse__, additiveExpression: peg$parseadditiveExpression, additiveOperator: peg$parseadditiveOperator, angleBracketLiteral: peg$parseangleBracketLiteral, angleBracketPath: peg$parseangleBracketPath, angleBracketKey: peg$parseangleBracketKey, angleBracketPathChar: peg$parseangleBracketPathChar, arguments: peg$parsearguments, arrayLiteral: peg$parsearrayLiteral, arrayEntries: peg$parsearrayEntries, arrayEntry: peg$parsearrayEntry, arrowFunction: peg$parsearrowFunction, bitwiseAndExpression: peg$parsebitwiseAndExpression, bitwiseAndOperator: peg$parsebitwiseAndOperator, bitwiseOrExpression: peg$parsebitwiseOrExpression, bitwiseOrOperator: peg$parsebitwiseOrOperator, bitwiseXorExpression: peg$parsebitwiseXorExpression, bitwiseXorOperator: peg$parsebitwiseXorOperator, callExpression: peg$parsecallExpression, commaExpression: peg$parsecommaExpression, comment: peg$parsecomment, computedPropertyAccess: peg$parsecomputedPropertyAccess, computedPropertySpace: peg$parsecomputedPropertySpace, conditionalExpression: peg$parseconditionalExpression, digits: peg$parsedigits, doubleArrow: peg$parsedoubleArrow, doubleQuoteString: peg$parsedoubleQuoteString, doubleQuoteStringChar: peg$parsedoubleQuoteStringChar, ellipsis: peg$parseellipsis, equalityExpression: peg$parseequalityExpression, equalityOperator: peg$parseequalityOperator, escapedChar: peg$parseescapedChar, expectBacktick: peg$parseexpectBacktick, expectClosingBrace: peg$parseexpectClosingBrace, expectClosingBracket: peg$parseexpectClosingBracket, expectClosingParenthesis: peg$parseexpectClosingParenthesis, expectDoubleQuote: peg$parseexpectDoubleQuote, expectExpression: peg$parseexpectExpression, expectFrontDelimiter: peg$parseexpectFrontDelimiter, expectGuillemet: peg$parseexpectGuillemet, expectSingleQuote: peg$parseexpectSingleQuote, expectPipelineExpression: peg$parseexpectPipelineExpression, expectUnaryExpression: peg$parseexpectUnaryExpression, exponentiationExpression: peg$parseexponentiationExpression, expression: peg$parseexpression, floatLiteral: peg$parsefloatLiteral, frontDelimiter: peg$parsefrontDelimiter, frontMatterExpression: peg$parsefrontMatterExpression, frontMatterText: peg$parsefrontMatterText, frontMatterYaml: peg$parsefrontMatterYaml, group: peg$parsegroup, guillemetString: peg$parseguillemetString, guillemetStringChar: peg$parseguillemetStringChar, host: peg$parsehost, hostname: peg$parsehostname, identifier: peg$parseidentifier, identifierLiteral: peg$parseidentifierLiteral, identifierPart: peg$parseidentifierPart, identifierStart: peg$parseidentifierStart, implicitParenthesesCallExpression: peg$parseimplicitParenthesesCallExpression, implicitParensthesesArguments: peg$parseimplicitParensthesesArguments, inlineSpace: peg$parseinlineSpace, integerLiteral: peg$parseintegerLiteral, key: peg$parsekey, keyChar: peg$parsekeyChar, keyCharStart: peg$parsekeyCharStart, list: peg$parselist, logicalAndExpression: peg$parselogicalAndExpression, logicalOrExpression: peg$parselogicalOrExpression, minus: peg$parseminus, multiLineComment: peg$parsemultiLineComment, multiplicativeExpression: peg$parsemultiplicativeExpression, multiplicativeOperator: peg$parsemultiplicativeOperator, newExpression: peg$parsenewExpression, newLine: peg$parsenewLine, numericLiteral: peg$parsenumericLiteral, nullishCoalescingExpression: peg$parsenullishCoalescingExpression, objectLiteral: peg$parseobjectLiteral, objectEntries: peg$parseobjectEntries, objectEntry: peg$parseobjectEntry, objectGetter: peg$parseobjectGetter, objectHiddenKey: peg$parseobjectHiddenKey, objectKey: peg$parseobjectKey, objectProperty: peg$parseobjectProperty, objectShorthandProperty: peg$parseobjectShorthandProperty, objectPublicKey: peg$parseobjectPublicKey, optionalChaining: peg$parseoptionalChaining, parameter: peg$parseparameter, parameterList: peg$parseparameterList, parameterSingleton: peg$parseparameterSingleton, parenthesesArguments: peg$parseparenthesesArguments, pathArguments: peg$parsepathArguments, pathKeys: peg$parsepathKeys, pathLiteral: peg$parsepathLiteral, pathSegment: peg$parsepathSegment, pipelineExpression: peg$parsepipelineExpression, primary: peg$parseprimary, program: peg$parseprogram, propertyAccess: peg$parsepropertyAccess, regexFlags: peg$parseregexFlags, regexLiteral: peg$parseregexLiteral, regexLiteralChar: peg$parseregexLiteralChar, relationalExpression: peg$parserelationalExpression, relationalOperator: peg$parserelationalOperator, separator: peg$parseseparator, shebang: peg$parseshebang, shellMode: peg$parseshellMode, shiftExpression: peg$parseshiftExpression, shiftOperator: peg$parseshiftOperator, shorthandFunction: peg$parseshorthandFunction, singleArrow: peg$parsesingleArrow, singleLineComment: peg$parsesingleLineComment, singleQuoteString: peg$parsesingleQuoteString, singleQuoteStringChar: peg$parsesingleQuoteStringChar, slash: peg$parseslash, slashes: peg$parseslashes, slashFollows: peg$parseslashFollows, spreadElement: peg$parsespreadElement, stringLiteral: peg$parsestringLiteral, templateBody: peg$parsetemplateBody, templateBodyChar: peg$parsetemplateBodyChar, templateBodyText: peg$parsetemplateBodyText, templateDocument: peg$parsetemplateDocument, templateLiteral: peg$parsetemplateLiteral, templateLiteralChar: peg$parsetemplateLiteralChar, templateLiteralText: peg$parsetemplateLiteralText, templateSubstitution: peg$parsetemplateSubstitution, textChar: peg$parsetextChar, unaryExpression: peg$parseunaryExpression, uri: peg$parseuri, uriExpression: peg$parseuriExpression, uriKey: peg$parseuriKey, uriKeyChar: peg$parseuriKeyChar, uriPath: peg$parseuriPath, uriScheme: peg$parseuriScheme, unaryOperator: peg$parseunaryOperator, whitespace: peg$parsewhitespace, whitespaceWithNewLine: peg$parsewhitespaceWithNewLine };
|
|
208
|
+
var peg$startRuleFunctions = { __: peg$parse__, additiveExpression: peg$parseadditiveExpression, additiveOperator: peg$parseadditiveOperator, angleBracketLiteral: peg$parseangleBracketLiteral, angleBracketPath: peg$parseangleBracketPath, angleBracketKey: peg$parseangleBracketKey, angleBracketPathChar: peg$parseangleBracketPathChar, arguments: peg$parsearguments, arrayLiteral: peg$parsearrayLiteral, arrayEntries: peg$parsearrayEntries, arrayEntry: peg$parsearrayEntry, arrowFunction: peg$parsearrowFunction, bitwiseAndExpression: peg$parsebitwiseAndExpression, bitwiseAndOperator: peg$parsebitwiseAndOperator, bitwiseOrExpression: peg$parsebitwiseOrExpression, bitwiseOrOperator: peg$parsebitwiseOrOperator, bitwiseXorExpression: peg$parsebitwiseXorExpression, bitwiseXorOperator: peg$parsebitwiseXorOperator, callExpression: peg$parsecallExpression, commaExpression: peg$parsecommaExpression, comment: peg$parsecomment, computedPropertyAccess: peg$parsecomputedPropertyAccess, computedPropertySpace: peg$parsecomputedPropertySpace, conditionalExpression: peg$parseconditionalExpression, digits: peg$parsedigits, doubleArrow: peg$parsedoubleArrow, doubleQuoteString: peg$parsedoubleQuoteString, doubleQuoteStringChar: peg$parsedoubleQuoteStringChar, ellipsis: peg$parseellipsis, equalityExpression: peg$parseequalityExpression, equalityOperator: peg$parseequalityOperator, escapedChar: peg$parseescapedChar, expectBacktick: peg$parseexpectBacktick, expectClosingBrace: peg$parseexpectClosingBrace, expectClosingBracket: peg$parseexpectClosingBracket, expectClosingParenthesis: peg$parseexpectClosingParenthesis, expectDoubleQuote: peg$parseexpectDoubleQuote, expectExpression: peg$parseexpectExpression, expectFrontDelimiter: peg$parseexpectFrontDelimiter, expectGuillemet: peg$parseexpectGuillemet, expectSingleQuote: peg$parseexpectSingleQuote, expectPipelineExpression: peg$parseexpectPipelineExpression, expectUnaryExpression: peg$parseexpectUnaryExpression, exponentiationExpression: peg$parseexponentiationExpression, expression: peg$parseexpression, floatLiteral: peg$parsefloatLiteral, frontDelimiter: peg$parsefrontDelimiter, frontMatterExpression: peg$parsefrontMatterExpression, frontMatterText: peg$parsefrontMatterText, frontMatterYaml: peg$parsefrontMatterYaml, group: peg$parsegroup, guillemetString: peg$parseguillemetString, guillemetStringChar: peg$parseguillemetStringChar, host: peg$parsehost, hostname: peg$parsehostname, identifier: peg$parseidentifier, identifierLiteral: peg$parseidentifierLiteral, identifierPart: peg$parseidentifierPart, identifierStart: peg$parseidentifierStart, implicitParenthesesCallExpression: peg$parseimplicitParenthesesCallExpression, implicitParensthesesArguments: peg$parseimplicitParensthesesArguments, inlineSpace: peg$parseinlineSpace, integerLiteral: peg$parseintegerLiteral, key: peg$parsekey, keyChar: peg$parsekeyChar, keyCharStart: peg$parsekeyCharStart, list: peg$parselist, logicalAndExpression: peg$parselogicalAndExpression, logicalOrExpression: peg$parselogicalOrExpression, minus: peg$parseminus, multiLineComment: peg$parsemultiLineComment, multiplicativeExpression: peg$parsemultiplicativeExpression, multiplicativeOperator: peg$parsemultiplicativeOperator, newExpression: peg$parsenewExpression, newLine: peg$parsenewLine, numericLiteral: peg$parsenumericLiteral, nullishCoalescingExpression: peg$parsenullishCoalescingExpression, objectLiteral: peg$parseobjectLiteral, objectEntries: peg$parseobjectEntries, objectEntry: peg$parseobjectEntry, objectGetter: peg$parseobjectGetter, objectHiddenKey: peg$parseobjectHiddenKey, objectKey: peg$parseobjectKey, objectProperty: peg$parseobjectProperty, objectShorthandProperty: peg$parseobjectShorthandProperty, objectPublicKey: peg$parseobjectPublicKey, optionalChaining: peg$parseoptionalChaining, parameter: peg$parseparameter, parameterList: peg$parseparameterList, parameterSingleton: peg$parseparameterSingleton, parenthesesArguments: peg$parseparenthesesArguments, pathArguments: peg$parsepathArguments, pathKeys: peg$parsepathKeys, pathLiteral: peg$parsepathLiteral, pathSegment: peg$parsepathSegment, pipelineExpression: peg$parsepipelineExpression, primary: peg$parseprimary, program: peg$parseprogram, programMode: peg$parseprogramMode, propertyAccess: peg$parsepropertyAccess, regexFlags: peg$parseregexFlags, regexLiteral: peg$parseregexLiteral, regexLiteralChar: peg$parseregexLiteralChar, relationalExpression: peg$parserelationalExpression, relationalOperator: peg$parserelationalOperator, separator: peg$parseseparator, shebang: peg$parseshebang, shellMode: peg$parseshellMode, shiftExpression: peg$parseshiftExpression, shiftOperator: peg$parseshiftOperator, shorthandFunction: peg$parseshorthandFunction, singleArrow: peg$parsesingleArrow, singleLineComment: peg$parsesingleLineComment, singleQuoteString: peg$parsesingleQuoteString, singleQuoteStringChar: peg$parsesingleQuoteStringChar, slash: peg$parseslash, slashes: peg$parseslashes, slashFollows: peg$parseslashFollows, spreadElement: peg$parsespreadElement, stringLiteral: peg$parsestringLiteral, templateBody: peg$parsetemplateBody, templateBodyChar: peg$parsetemplateBodyChar, templateBodyText: peg$parsetemplateBodyText, templateDocument: peg$parsetemplateDocument, templateLiteral: peg$parsetemplateLiteral, templateLiteralChar: peg$parsetemplateLiteralChar, templateLiteralText: peg$parsetemplateLiteralText, templateSubstitution: peg$parsetemplateSubstitution, textChar: peg$parsetextChar, unaryExpression: peg$parseunaryExpression, uri: peg$parseuri, uriExpression: peg$parseuriExpression, uriKey: peg$parseuriKey, uriKeyChar: peg$parseuriKeyChar, uriPath: peg$parseuriPath, uriScheme: peg$parseuriScheme, unaryOperator: peg$parseunaryOperator, whitespace: peg$parsewhitespace, whitespaceChar: peg$parsewhitespaceChar, whitespaceWithNewLine: peg$parsewhitespaceWithNewLine };
|
|
209
209
|
var peg$startRuleFunction = peg$parse__;
|
|
210
210
|
|
|
211
211
|
var peg$c0 = "+";
|
|
@@ -684,54 +684,58 @@ function peg$parse(input, options) {
|
|
|
684
684
|
location()
|
|
685
685
|
);
|
|
686
686
|
};
|
|
687
|
-
var peg$f83 = function(
|
|
687
|
+
var peg$f83 = function() { return options.mode === "program" };
|
|
688
|
+
var peg$f84 = function(property) {
|
|
688
689
|
return annotate([markers.property, property], location());
|
|
689
690
|
};
|
|
690
|
-
var peg$
|
|
691
|
+
var peg$f85 = function(flags) {
|
|
691
692
|
return flags.join("");
|
|
692
693
|
};
|
|
693
|
-
var peg$
|
|
694
|
+
var peg$f86 = function(chars, flags) {
|
|
694
695
|
const regex = new RegExp(chars.join(""), flags);
|
|
695
696
|
return annotate([ops.literal, regex], location());
|
|
696
697
|
};
|
|
697
|
-
var peg$
|
|
698
|
+
var peg$f87 = function(head, tail) {
|
|
698
699
|
return tail.reduce(makeBinaryOperation, head);
|
|
699
700
|
};
|
|
700
|
-
var peg$
|
|
701
|
-
var peg$
|
|
702
|
-
var peg$
|
|
701
|
+
var peg$f88 = function() { return null; };
|
|
702
|
+
var peg$f89 = function() { return options.mode === "shell" };
|
|
703
|
+
var peg$f90 = function(head, tail) {
|
|
703
704
|
return tail.reduce(makeBinaryOperation, head);
|
|
704
705
|
};
|
|
705
|
-
var peg$
|
|
706
|
+
var peg$f91 = function(definition) {
|
|
707
|
+
if (options.mode === "program") {
|
|
708
|
+
console.warn("Warning: the shorthand function syntax is deprecated in Origami programs. Use arrow syntax instead.");
|
|
709
|
+
}
|
|
706
710
|
const lambdaParameters = annotate(
|
|
707
711
|
[annotate([ops.literal, "_"], location())],
|
|
708
712
|
location()
|
|
709
713
|
);
|
|
710
714
|
return annotate([ops.lambda, lambdaParameters, definition], location());
|
|
711
715
|
};
|
|
712
|
-
var peg$
|
|
713
|
-
var peg$
|
|
716
|
+
var peg$f92 = function() { return null; };
|
|
717
|
+
var peg$f93 = function(chars) {
|
|
714
718
|
return annotate([ops.literal, chars.join("")], location());
|
|
715
719
|
};
|
|
716
|
-
var peg$
|
|
720
|
+
var peg$f94 = function() {
|
|
717
721
|
return annotate([ops.literal, "/"], location());
|
|
718
722
|
};
|
|
719
|
-
var peg$
|
|
723
|
+
var peg$f95 = function() {
|
|
720
724
|
return annotate([ops.literal, "/"], location());
|
|
721
725
|
};
|
|
722
|
-
var peg$
|
|
726
|
+
var peg$f96 = function() {
|
|
723
727
|
return true;
|
|
724
728
|
};
|
|
725
|
-
var peg$
|
|
729
|
+
var peg$f97 = function(value) {
|
|
726
730
|
return annotate([ops.spread, value], location());
|
|
727
731
|
};
|
|
728
|
-
var peg$
|
|
732
|
+
var peg$f98 = function(head, tail) {
|
|
729
733
|
return makeTemplate(ops.templateIndent, head, tail, location());
|
|
730
734
|
};
|
|
731
|
-
var peg$
|
|
735
|
+
var peg$f99 = function(chars) {
|
|
732
736
|
return annotate([ops.literal, chars.join("")], location());
|
|
733
737
|
};
|
|
734
|
-
var peg$
|
|
738
|
+
var peg$f100 = function(front, body) {
|
|
735
739
|
// TODO: Deprecate @template
|
|
736
740
|
const macroName = text().includes("@template") ? "@template" : "_template";
|
|
737
741
|
if (macroName === "@template") {
|
|
@@ -740,10 +744,10 @@ function peg$parse(input, options) {
|
|
|
740
744
|
}
|
|
741
745
|
return annotate(applyMacro(front, macroName, body), location());
|
|
742
746
|
};
|
|
743
|
-
var peg$
|
|
747
|
+
var peg$f101 = function(front, body) {
|
|
744
748
|
return makeDocument(front, body, location());
|
|
745
749
|
};
|
|
746
|
-
var peg$
|
|
750
|
+
var peg$f102 = function(body) {
|
|
747
751
|
if (options.front) {
|
|
748
752
|
return makeDocument(options.front, body, location());
|
|
749
753
|
}
|
|
@@ -753,43 +757,43 @@ function peg$parse(input, options) {
|
|
|
753
757
|
);
|
|
754
758
|
return annotate([ops.lambda, lambdaParameters, body], location());
|
|
755
759
|
};
|
|
756
|
-
var peg$
|
|
760
|
+
var peg$f103 = function(head, tail) {
|
|
757
761
|
return makeTemplate(ops.templateTree, head, tail, location());
|
|
758
762
|
};
|
|
759
|
-
var peg$
|
|
763
|
+
var peg$f104 = function(chars) {
|
|
760
764
|
return annotate([ops.literal, chars.join("")], location());
|
|
761
765
|
};
|
|
762
|
-
var peg$
|
|
766
|
+
var peg$f105 = function(expression) {
|
|
763
767
|
return annotate(expression, location());
|
|
764
768
|
};
|
|
765
|
-
var peg$
|
|
769
|
+
var peg$f106 = function(operator, expression) {
|
|
766
770
|
return makeUnaryOperation(operator, expression, location());
|
|
767
771
|
};
|
|
768
|
-
var peg$
|
|
772
|
+
var peg$f107 = function(scheme, host, path) {
|
|
769
773
|
const rest = path ? path[1] : [];
|
|
770
774
|
const keys = annotate([host, ...rest], location());
|
|
771
775
|
return makeCall(scheme, keys, location());
|
|
772
776
|
};
|
|
773
|
-
var peg$
|
|
777
|
+
var peg$f108 = function(scheme, keys) {
|
|
774
778
|
return makeCall(scheme, keys, location());
|
|
775
779
|
};
|
|
776
|
-
var peg$
|
|
780
|
+
var peg$f109 = function(chars) {
|
|
777
781
|
return annotate([ops.literal, text()], location());
|
|
778
782
|
};
|
|
779
|
-
var peg$
|
|
783
|
+
var peg$f110 = function() {
|
|
780
784
|
// A single slash is a path key
|
|
781
785
|
return annotate([ops.literal, ""], location());
|
|
782
786
|
};
|
|
783
|
-
var peg$
|
|
784
|
-
var peg$
|
|
785
|
-
var peg$
|
|
787
|
+
var peg$f111 = function(char) { return /\s/.test(char); };
|
|
788
|
+
var peg$f112 = function(char) { return char; };
|
|
789
|
+
var peg$f113 = function(keys) {
|
|
786
790
|
return annotate(keys, location());
|
|
787
791
|
};
|
|
788
|
-
var peg$
|
|
792
|
+
var peg$f114 = function() {
|
|
789
793
|
return annotate([markers.global, text()], location());
|
|
790
794
|
};
|
|
791
|
-
var peg$
|
|
792
|
-
var peg$
|
|
795
|
+
var peg$f115 = function(char) { return /\s/.test(char); };
|
|
796
|
+
var peg$f116 = function(char) { return char; };
|
|
793
797
|
var peg$currPos = options.peg$currPos | 0;
|
|
794
798
|
var peg$savedPos = peg$currPos;
|
|
795
799
|
var peg$posDetailsCache = [{ line: 1, column: 1 }];
|
|
@@ -4830,6 +4834,20 @@ function peg$parse(input, options) {
|
|
|
4830
4834
|
return s0;
|
|
4831
4835
|
}
|
|
4832
4836
|
|
|
4837
|
+
function peg$parseprogramMode() {
|
|
4838
|
+
var s0;
|
|
4839
|
+
|
|
4840
|
+
peg$savedPos = peg$currPos;
|
|
4841
|
+
s0 = peg$f83();
|
|
4842
|
+
if (s0) {
|
|
4843
|
+
s0 = undefined;
|
|
4844
|
+
} else {
|
|
4845
|
+
s0 = peg$FAILED;
|
|
4846
|
+
}
|
|
4847
|
+
|
|
4848
|
+
return s0;
|
|
4849
|
+
}
|
|
4850
|
+
|
|
4833
4851
|
function peg$parsepropertyAccess() {
|
|
4834
4852
|
var s0, s1, s2, s3, s4;
|
|
4835
4853
|
|
|
@@ -4847,7 +4865,7 @@ function peg$parse(input, options) {
|
|
|
4847
4865
|
s4 = peg$parseidentifierLiteral();
|
|
4848
4866
|
if (s4 !== peg$FAILED) {
|
|
4849
4867
|
peg$savedPos = s0;
|
|
4850
|
-
s0 = peg$
|
|
4868
|
+
s0 = peg$f84(s4);
|
|
4851
4869
|
} else {
|
|
4852
4870
|
peg$currPos = s0;
|
|
4853
4871
|
s0 = peg$FAILED;
|
|
@@ -4883,7 +4901,7 @@ function peg$parse(input, options) {
|
|
|
4883
4901
|
}
|
|
4884
4902
|
}
|
|
4885
4903
|
peg$savedPos = s0;
|
|
4886
|
-
s1 = peg$
|
|
4904
|
+
s1 = peg$f85(s1);
|
|
4887
4905
|
s0 = s1;
|
|
4888
4906
|
|
|
4889
4907
|
return s0;
|
|
@@ -4917,7 +4935,7 @@ function peg$parse(input, options) {
|
|
|
4917
4935
|
if (s3 !== peg$FAILED) {
|
|
4918
4936
|
s4 = peg$parseregexFlags();
|
|
4919
4937
|
peg$savedPos = s0;
|
|
4920
|
-
s0 = peg$
|
|
4938
|
+
s0 = peg$f86(s2, s4);
|
|
4921
4939
|
} else {
|
|
4922
4940
|
peg$currPos = s0;
|
|
4923
4941
|
s0 = peg$FAILED;
|
|
@@ -5000,7 +5018,7 @@ function peg$parse(input, options) {
|
|
|
5000
5018
|
}
|
|
5001
5019
|
}
|
|
5002
5020
|
peg$savedPos = s0;
|
|
5003
|
-
s0 = peg$
|
|
5021
|
+
s0 = peg$f87(s1, s2);
|
|
5004
5022
|
} else {
|
|
5005
5023
|
peg$currPos = s0;
|
|
5006
5024
|
s0 = peg$FAILED;
|
|
@@ -5115,7 +5133,7 @@ function peg$parse(input, options) {
|
|
|
5115
5133
|
}
|
|
5116
5134
|
}
|
|
5117
5135
|
peg$savedPos = s0;
|
|
5118
|
-
s0 = peg$
|
|
5136
|
+
s0 = peg$f88();
|
|
5119
5137
|
} else {
|
|
5120
5138
|
peg$currPos = s0;
|
|
5121
5139
|
s0 = peg$FAILED;
|
|
@@ -5128,7 +5146,7 @@ function peg$parse(input, options) {
|
|
|
5128
5146
|
var s0;
|
|
5129
5147
|
|
|
5130
5148
|
peg$savedPos = peg$currPos;
|
|
5131
|
-
s0 = peg$
|
|
5149
|
+
s0 = peg$f89();
|
|
5132
5150
|
if (s0) {
|
|
5133
5151
|
s0 = undefined;
|
|
5134
5152
|
} else {
|
|
@@ -5181,7 +5199,7 @@ function peg$parse(input, options) {
|
|
|
5181
5199
|
}
|
|
5182
5200
|
}
|
|
5183
5201
|
peg$savedPos = s0;
|
|
5184
|
-
s0 = peg$
|
|
5202
|
+
s0 = peg$f90(s1, s2);
|
|
5185
5203
|
} else {
|
|
5186
5204
|
peg$currPos = s0;
|
|
5187
5205
|
s0 = peg$FAILED;
|
|
@@ -5228,6 +5246,9 @@ function peg$parse(input, options) {
|
|
|
5228
5246
|
peg$silentFails++;
|
|
5229
5247
|
s0 = peg$currPos;
|
|
5230
5248
|
s1 = peg$parseshellMode();
|
|
5249
|
+
if (s1 === peg$FAILED) {
|
|
5250
|
+
s1 = peg$parseprogramMode();
|
|
5251
|
+
}
|
|
5231
5252
|
if (s1 !== peg$FAILED) {
|
|
5232
5253
|
if (input.charCodeAt(peg$currPos) === 61) {
|
|
5233
5254
|
s2 = peg$c54;
|
|
@@ -5258,7 +5279,7 @@ function peg$parse(input, options) {
|
|
|
5258
5279
|
s5 = peg$parseimplicitParenthesesCallExpression();
|
|
5259
5280
|
if (s5 !== peg$FAILED) {
|
|
5260
5281
|
peg$savedPos = s0;
|
|
5261
|
-
s0 = peg$
|
|
5282
|
+
s0 = peg$f91(s5);
|
|
5262
5283
|
} else {
|
|
5263
5284
|
peg$currPos = s0;
|
|
5264
5285
|
s0 = peg$FAILED;
|
|
@@ -5341,7 +5362,7 @@ function peg$parse(input, options) {
|
|
|
5341
5362
|
}
|
|
5342
5363
|
}
|
|
5343
5364
|
peg$savedPos = s0;
|
|
5344
|
-
s0 = peg$
|
|
5365
|
+
s0 = peg$f92();
|
|
5345
5366
|
} else {
|
|
5346
5367
|
peg$currPos = s0;
|
|
5347
5368
|
s0 = peg$FAILED;
|
|
@@ -5372,7 +5393,7 @@ function peg$parse(input, options) {
|
|
|
5372
5393
|
s3 = peg$parseexpectSingleQuote();
|
|
5373
5394
|
if (s3 !== peg$FAILED) {
|
|
5374
5395
|
peg$savedPos = s0;
|
|
5375
|
-
s0 = peg$
|
|
5396
|
+
s0 = peg$f93(s2);
|
|
5376
5397
|
} else {
|
|
5377
5398
|
peg$currPos = s0;
|
|
5378
5399
|
s0 = peg$FAILED;
|
|
@@ -5436,7 +5457,7 @@ function peg$parse(input, options) {
|
|
|
5436
5457
|
s1 = peg$parseslashFollows();
|
|
5437
5458
|
if (s1 !== peg$FAILED) {
|
|
5438
5459
|
peg$savedPos = s0;
|
|
5439
|
-
s1 = peg$
|
|
5460
|
+
s1 = peg$f94();
|
|
5440
5461
|
}
|
|
5441
5462
|
s0 = s1;
|
|
5442
5463
|
|
|
@@ -5471,7 +5492,7 @@ function peg$parse(input, options) {
|
|
|
5471
5492
|
}
|
|
5472
5493
|
if (s1 !== peg$FAILED) {
|
|
5473
5494
|
peg$savedPos = s0;
|
|
5474
|
-
s1 = peg$
|
|
5495
|
+
s1 = peg$f95();
|
|
5475
5496
|
}
|
|
5476
5497
|
s0 = s1;
|
|
5477
5498
|
|
|
@@ -5500,7 +5521,7 @@ function peg$parse(input, options) {
|
|
|
5500
5521
|
}
|
|
5501
5522
|
if (s1 !== peg$FAILED) {
|
|
5502
5523
|
peg$savedPos = s0;
|
|
5503
|
-
s1 = peg$
|
|
5524
|
+
s1 = peg$f96();
|
|
5504
5525
|
}
|
|
5505
5526
|
s0 = s1;
|
|
5506
5527
|
|
|
@@ -5517,7 +5538,7 @@ function peg$parse(input, options) {
|
|
|
5517
5538
|
s3 = peg$parseexpectPipelineExpression();
|
|
5518
5539
|
if (s3 !== peg$FAILED) {
|
|
5519
5540
|
peg$savedPos = s0;
|
|
5520
|
-
s0 = peg$
|
|
5541
|
+
s0 = peg$f97(s3);
|
|
5521
5542
|
} else {
|
|
5522
5543
|
peg$currPos = s0;
|
|
5523
5544
|
s0 = peg$FAILED;
|
|
@@ -5594,7 +5615,7 @@ function peg$parse(input, options) {
|
|
|
5594
5615
|
}
|
|
5595
5616
|
}
|
|
5596
5617
|
peg$savedPos = s0;
|
|
5597
|
-
s0 = peg$
|
|
5618
|
+
s0 = peg$f98(s1, s2);
|
|
5598
5619
|
peg$silentFails--;
|
|
5599
5620
|
s1 = peg$FAILED;
|
|
5600
5621
|
if (peg$silentFails === 0) { peg$fail(peg$e102); }
|
|
@@ -5650,7 +5671,7 @@ function peg$parse(input, options) {
|
|
|
5650
5671
|
s2 = peg$parsetemplateBodyChar();
|
|
5651
5672
|
}
|
|
5652
5673
|
peg$savedPos = s0;
|
|
5653
|
-
s1 = peg$
|
|
5674
|
+
s1 = peg$f99(s1);
|
|
5654
5675
|
s0 = s1;
|
|
5655
5676
|
peg$silentFails--;
|
|
5656
5677
|
s1 = peg$FAILED;
|
|
@@ -5669,7 +5690,7 @@ function peg$parse(input, options) {
|
|
|
5669
5690
|
s2 = peg$parse__();
|
|
5670
5691
|
s3 = peg$parsetemplateBody();
|
|
5671
5692
|
peg$savedPos = s0;
|
|
5672
|
-
s0 = peg$
|
|
5693
|
+
s0 = peg$f100(s1, s3);
|
|
5673
5694
|
} else {
|
|
5674
5695
|
peg$currPos = s0;
|
|
5675
5696
|
s0 = peg$FAILED;
|
|
@@ -5680,7 +5701,7 @@ function peg$parse(input, options) {
|
|
|
5680
5701
|
if (s1 !== peg$FAILED) {
|
|
5681
5702
|
s2 = peg$parsetemplateBody();
|
|
5682
5703
|
peg$savedPos = s0;
|
|
5683
|
-
s0 = peg$
|
|
5704
|
+
s0 = peg$f101(s1, s2);
|
|
5684
5705
|
} else {
|
|
5685
5706
|
peg$currPos = s0;
|
|
5686
5707
|
s0 = peg$FAILED;
|
|
@@ -5689,7 +5710,7 @@ function peg$parse(input, options) {
|
|
|
5689
5710
|
s0 = peg$currPos;
|
|
5690
5711
|
s1 = peg$parsetemplateBody();
|
|
5691
5712
|
peg$savedPos = s0;
|
|
5692
|
-
s1 = peg$
|
|
5713
|
+
s1 = peg$f102(s1);
|
|
5693
5714
|
s0 = s1;
|
|
5694
5715
|
}
|
|
5695
5716
|
}
|
|
@@ -5743,7 +5764,7 @@ function peg$parse(input, options) {
|
|
|
5743
5764
|
s4 = peg$parseexpectBacktick();
|
|
5744
5765
|
if (s4 !== peg$FAILED) {
|
|
5745
5766
|
peg$savedPos = s0;
|
|
5746
|
-
s0 = peg$
|
|
5767
|
+
s0 = peg$f103(s2, s3);
|
|
5747
5768
|
} else {
|
|
5748
5769
|
peg$currPos = s0;
|
|
5749
5770
|
s0 = peg$FAILED;
|
|
@@ -5817,7 +5838,7 @@ function peg$parse(input, options) {
|
|
|
5817
5838
|
s2 = peg$parsetemplateLiteralChar();
|
|
5818
5839
|
}
|
|
5819
5840
|
peg$savedPos = s0;
|
|
5820
|
-
s1 = peg$
|
|
5841
|
+
s1 = peg$f104(s1);
|
|
5821
5842
|
s0 = s1;
|
|
5822
5843
|
|
|
5823
5844
|
return s0;
|
|
@@ -5847,7 +5868,7 @@ function peg$parse(input, options) {
|
|
|
5847
5868
|
}
|
|
5848
5869
|
if (s3 !== peg$FAILED) {
|
|
5849
5870
|
peg$savedPos = s0;
|
|
5850
|
-
s0 = peg$
|
|
5871
|
+
s0 = peg$f105(s2);
|
|
5851
5872
|
} else {
|
|
5852
5873
|
peg$currPos = s0;
|
|
5853
5874
|
s0 = peg$FAILED;
|
|
@@ -5896,7 +5917,7 @@ function peg$parse(input, options) {
|
|
|
5896
5917
|
s3 = peg$parseexpectUnaryExpression();
|
|
5897
5918
|
if (s3 !== peg$FAILED) {
|
|
5898
5919
|
peg$savedPos = s0;
|
|
5899
|
-
s0 = peg$
|
|
5920
|
+
s0 = peg$f106(s1, s3);
|
|
5900
5921
|
} else {
|
|
5901
5922
|
peg$currPos = s0;
|
|
5902
5923
|
s0 = peg$FAILED;
|
|
@@ -5953,7 +5974,7 @@ function peg$parse(input, options) {
|
|
|
5953
5974
|
s4 = null;
|
|
5954
5975
|
}
|
|
5955
5976
|
peg$savedPos = s0;
|
|
5956
|
-
s0 = peg$
|
|
5977
|
+
s0 = peg$f107(s1, s3, s4);
|
|
5957
5978
|
} else {
|
|
5958
5979
|
peg$currPos = s0;
|
|
5959
5980
|
s0 = peg$FAILED;
|
|
@@ -5973,7 +5994,7 @@ function peg$parse(input, options) {
|
|
|
5973
5994
|
s2 = peg$parsepathKeys();
|
|
5974
5995
|
if (s2 !== peg$FAILED) {
|
|
5975
5996
|
peg$savedPos = s0;
|
|
5976
|
-
s0 = peg$
|
|
5997
|
+
s0 = peg$f108(s1, s2);
|
|
5977
5998
|
} else {
|
|
5978
5999
|
peg$currPos = s0;
|
|
5979
6000
|
s0 = peg$FAILED;
|
|
@@ -6027,7 +6048,7 @@ function peg$parse(input, options) {
|
|
|
6027
6048
|
s2 = null;
|
|
6028
6049
|
}
|
|
6029
6050
|
peg$savedPos = s0;
|
|
6030
|
-
s0 = peg$
|
|
6051
|
+
s0 = peg$f109(s1);
|
|
6031
6052
|
} else {
|
|
6032
6053
|
peg$currPos = s0;
|
|
6033
6054
|
s0 = peg$FAILED;
|
|
@@ -6043,7 +6064,7 @@ function peg$parse(input, options) {
|
|
|
6043
6064
|
}
|
|
6044
6065
|
if (s1 !== peg$FAILED) {
|
|
6045
6066
|
peg$savedPos = s0;
|
|
6046
|
-
s1 = peg$
|
|
6067
|
+
s1 = peg$f110();
|
|
6047
6068
|
}
|
|
6048
6069
|
s0 = s1;
|
|
6049
6070
|
}
|
|
@@ -6066,7 +6087,7 @@ function peg$parse(input, options) {
|
|
|
6066
6087
|
s2 = peg$currPos;
|
|
6067
6088
|
peg$silentFails++;
|
|
6068
6089
|
peg$savedPos = peg$currPos;
|
|
6069
|
-
s3 = peg$
|
|
6090
|
+
s3 = peg$f111(s1);
|
|
6070
6091
|
if (s3) {
|
|
6071
6092
|
s3 = undefined;
|
|
6072
6093
|
} else {
|
|
@@ -6081,7 +6102,7 @@ function peg$parse(input, options) {
|
|
|
6081
6102
|
}
|
|
6082
6103
|
if (s2 !== peg$FAILED) {
|
|
6083
6104
|
peg$savedPos = s0;
|
|
6084
|
-
s0 = peg$
|
|
6105
|
+
s0 = peg$f112(s1);
|
|
6085
6106
|
} else {
|
|
6086
6107
|
peg$currPos = s0;
|
|
6087
6108
|
s0 = peg$FAILED;
|
|
@@ -6117,7 +6138,7 @@ function peg$parse(input, options) {
|
|
|
6117
6138
|
}
|
|
6118
6139
|
if (s1 !== peg$FAILED) {
|
|
6119
6140
|
peg$savedPos = s0;
|
|
6120
|
-
s1 = peg$
|
|
6141
|
+
s1 = peg$f113(s1);
|
|
6121
6142
|
}
|
|
6122
6143
|
s0 = s1;
|
|
6123
6144
|
peg$silentFails--;
|
|
@@ -6168,7 +6189,7 @@ function peg$parse(input, options) {
|
|
|
6168
6189
|
}
|
|
6169
6190
|
if (s3 !== peg$FAILED) {
|
|
6170
6191
|
peg$savedPos = s0;
|
|
6171
|
-
s0 = peg$
|
|
6192
|
+
s0 = peg$f114();
|
|
6172
6193
|
} else {
|
|
6173
6194
|
peg$currPos = s0;
|
|
6174
6195
|
s0 = peg$FAILED;
|
|
@@ -6236,6 +6257,29 @@ function peg$parse(input, options) {
|
|
|
6236
6257
|
}
|
|
6237
6258
|
|
|
6238
6259
|
function peg$parsewhitespace() {
|
|
6260
|
+
var s0, s1;
|
|
6261
|
+
|
|
6262
|
+
s0 = [];
|
|
6263
|
+
s1 = peg$parsewhitespaceChar();
|
|
6264
|
+
if (s1 === peg$FAILED) {
|
|
6265
|
+
s1 = peg$parsecomment();
|
|
6266
|
+
}
|
|
6267
|
+
if (s1 !== peg$FAILED) {
|
|
6268
|
+
while (s1 !== peg$FAILED) {
|
|
6269
|
+
s0.push(s1);
|
|
6270
|
+
s1 = peg$parsewhitespaceChar();
|
|
6271
|
+
if (s1 === peg$FAILED) {
|
|
6272
|
+
s1 = peg$parsecomment();
|
|
6273
|
+
}
|
|
6274
|
+
}
|
|
6275
|
+
} else {
|
|
6276
|
+
s0 = peg$FAILED;
|
|
6277
|
+
}
|
|
6278
|
+
|
|
6279
|
+
return s0;
|
|
6280
|
+
}
|
|
6281
|
+
|
|
6282
|
+
function peg$parsewhitespaceChar() {
|
|
6239
6283
|
var s0, s1, s2;
|
|
6240
6284
|
|
|
6241
6285
|
s0 = peg$currPos;
|
|
@@ -6248,7 +6292,7 @@ function peg$parse(input, options) {
|
|
|
6248
6292
|
}
|
|
6249
6293
|
if (s1 !== peg$FAILED) {
|
|
6250
6294
|
peg$savedPos = peg$currPos;
|
|
6251
|
-
s2 = peg$
|
|
6295
|
+
s2 = peg$f115(s1);
|
|
6252
6296
|
if (s2) {
|
|
6253
6297
|
s2 = undefined;
|
|
6254
6298
|
} else {
|
|
@@ -6256,7 +6300,7 @@ function peg$parse(input, options) {
|
|
|
6256
6300
|
}
|
|
6257
6301
|
if (s2 !== peg$FAILED) {
|
|
6258
6302
|
peg$savedPos = s0;
|
|
6259
|
-
s0 = peg$
|
|
6303
|
+
s0 = peg$f116(s1);
|
|
6260
6304
|
} else {
|
|
6261
6305
|
peg$currPos = s0;
|
|
6262
6306
|
s0 = peg$FAILED;
|
|
@@ -6265,9 +6309,6 @@ function peg$parse(input, options) {
|
|
|
6265
6309
|
peg$currPos = s0;
|
|
6266
6310
|
s0 = peg$FAILED;
|
|
6267
6311
|
}
|
|
6268
|
-
if (s0 === peg$FAILED) {
|
|
6269
|
-
s0 = peg$parsecomment();
|
|
6270
|
-
}
|
|
6271
6312
|
|
|
6272
6313
|
return s0;
|
|
6273
6314
|
}
|
|
@@ -6426,6 +6467,7 @@ const peg$allowedStartRules = [
|
|
|
6426
6467
|
"pipelineExpression",
|
|
6427
6468
|
"primary",
|
|
6428
6469
|
"program",
|
|
6470
|
+
"programMode",
|
|
6429
6471
|
"propertyAccess",
|
|
6430
6472
|
"regexFlags",
|
|
6431
6473
|
"regexLiteral",
|
|
@@ -6465,6 +6507,7 @@ const peg$allowedStartRules = [
|
|
|
6465
6507
|
"uriScheme",
|
|
6466
6508
|
"unaryOperator",
|
|
6467
6509
|
"whitespace",
|
|
6510
|
+
"whitespaceChar",
|
|
6468
6511
|
"whitespaceWithNewLine"
|
|
6469
6512
|
];
|
|
6470
6513
|
|
package/src/runtime/jsGlobals.js
CHANGED
|
@@ -12,7 +12,9 @@ import path from "node:path";
|
|
|
12
12
|
* Fetch API
|
|
13
13
|
* URL API
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
const globals = {
|
|
16
|
+
AbortController,
|
|
17
|
+
AbortSignal,
|
|
16
18
|
AggregateError,
|
|
17
19
|
Array,
|
|
18
20
|
ArrayBuffer,
|
|
@@ -20,14 +22,31 @@ export default {
|
|
|
20
22
|
BigInt,
|
|
21
23
|
BigInt64Array,
|
|
22
24
|
BigUint64Array,
|
|
25
|
+
Blob,
|
|
23
26
|
Boolean,
|
|
27
|
+
BroadcastChannel,
|
|
28
|
+
Buffer,
|
|
29
|
+
ByteLengthQueuingStrategy,
|
|
30
|
+
CompressionStream,
|
|
31
|
+
CountQueuingStrategy,
|
|
32
|
+
Crypto,
|
|
33
|
+
CryptoKey,
|
|
34
|
+
CustomEvent,
|
|
35
|
+
DOMException,
|
|
24
36
|
DataView,
|
|
25
37
|
Date,
|
|
38
|
+
DecompressionStream,
|
|
39
|
+
DisposableStack: globalThis.DisposableStack,
|
|
26
40
|
Error,
|
|
27
41
|
EvalError,
|
|
42
|
+
Event,
|
|
43
|
+
EventTarget,
|
|
44
|
+
File,
|
|
28
45
|
FinalizationRegistry,
|
|
46
|
+
Float16Array: globalThis.Float16Array,
|
|
29
47
|
Float32Array,
|
|
30
48
|
Float64Array,
|
|
49
|
+
FormData,
|
|
31
50
|
Function,
|
|
32
51
|
Headers,
|
|
33
52
|
Infinity,
|
|
@@ -35,17 +54,32 @@ export default {
|
|
|
35
54
|
Int32Array,
|
|
36
55
|
Int8Array,
|
|
37
56
|
Intl,
|
|
38
|
-
|
|
39
|
-
Iterator,
|
|
57
|
+
Iterator: globalThis.Iterator,
|
|
40
58
|
JSON,
|
|
41
59
|
Map,
|
|
42
60
|
Math,
|
|
61
|
+
MessageChannel,
|
|
62
|
+
MessageEvent,
|
|
63
|
+
MessagePort,
|
|
43
64
|
NaN,
|
|
44
65
|
Number,
|
|
45
66
|
Object,
|
|
67
|
+
Performance,
|
|
68
|
+
PerformanceEntry,
|
|
69
|
+
PerformanceMark,
|
|
70
|
+
PerformanceMeasure,
|
|
71
|
+
PerformanceObserver,
|
|
72
|
+
PerformanceObserverEntryList,
|
|
73
|
+
PerformanceResourceTiming,
|
|
46
74
|
Promise,
|
|
47
75
|
Proxy,
|
|
48
76
|
RangeError,
|
|
77
|
+
ReadableByteStreamController,
|
|
78
|
+
ReadableStream,
|
|
79
|
+
ReadableStreamBYOBReader,
|
|
80
|
+
ReadableStreamBYOBRequest,
|
|
81
|
+
ReadableStreamDefaultController,
|
|
82
|
+
ReadableStreamDefaultReader,
|
|
49
83
|
ReferenceError,
|
|
50
84
|
Reflect,
|
|
51
85
|
RegExp,
|
|
@@ -54,10 +88,21 @@ export default {
|
|
|
54
88
|
Set,
|
|
55
89
|
SharedArrayBuffer,
|
|
56
90
|
String,
|
|
91
|
+
SubtleCrypto,
|
|
92
|
+
SuppressedError: globalThis.SuppressedError,
|
|
57
93
|
Symbol,
|
|
58
94
|
SyntaxError,
|
|
95
|
+
TextDecoder,
|
|
96
|
+
TextDecoderStream,
|
|
97
|
+
TextEncoder,
|
|
98
|
+
TextEncoderStream,
|
|
99
|
+
TransformStream,
|
|
100
|
+
TransformStreamDefaultController,
|
|
59
101
|
TypeError,
|
|
60
102
|
URIError,
|
|
103
|
+
URL,
|
|
104
|
+
URLPattern: globalThis.URLPattern,
|
|
105
|
+
URLSearchParams,
|
|
61
106
|
Uint16Array,
|
|
62
107
|
Uint32Array,
|
|
63
108
|
Uint8Array,
|
|
@@ -65,24 +110,58 @@ export default {
|
|
|
65
110
|
WeakMap,
|
|
66
111
|
WeakRef,
|
|
67
112
|
WeakSet,
|
|
113
|
+
WebAssembly,
|
|
114
|
+
WebSocket: globalThis.WebSocket,
|
|
115
|
+
WritableStream,
|
|
116
|
+
WritableStreamDefaultController,
|
|
117
|
+
WritableStreamDefaultWriter,
|
|
118
|
+
atob,
|
|
119
|
+
btoa,
|
|
120
|
+
clearImmediate,
|
|
121
|
+
clearInterval,
|
|
122
|
+
clearTimeout,
|
|
123
|
+
console,
|
|
124
|
+
crypto,
|
|
68
125
|
decodeURI,
|
|
69
126
|
decodeURIComponent,
|
|
70
127
|
encodeURI,
|
|
71
128
|
encodeURIComponent,
|
|
129
|
+
escape,
|
|
72
130
|
eval,
|
|
73
|
-
|
|
74
|
-
fetch: fetchWrapper, // special case
|
|
131
|
+
// fetch -- special case, see below
|
|
75
132
|
globalThis,
|
|
76
|
-
import: importWrapper, // not a function in JS but acts like one
|
|
77
133
|
isFinite,
|
|
78
134
|
isNaN,
|
|
79
|
-
null: null, // treat like a global
|
|
80
135
|
parseFloat,
|
|
81
136
|
parseInt,
|
|
82
|
-
|
|
137
|
+
performance,
|
|
138
|
+
process,
|
|
139
|
+
queueMicrotask,
|
|
140
|
+
setImmediate,
|
|
141
|
+
setInterval,
|
|
142
|
+
setTimeout,
|
|
143
|
+
structuredClone,
|
|
83
144
|
undefined,
|
|
145
|
+
unescape,
|
|
146
|
+
|
|
147
|
+
// Treat these like globals
|
|
148
|
+
false: false,
|
|
149
|
+
null: null,
|
|
150
|
+
true: true,
|
|
151
|
+
|
|
152
|
+
// Special cases
|
|
153
|
+
fetch: fetchWrapper,
|
|
154
|
+
import: importWrapper,
|
|
84
155
|
};
|
|
85
156
|
|
|
157
|
+
// Give access to our own custom globals as `globalThis`
|
|
158
|
+
Object.defineProperty(globals, "globalThis", {
|
|
159
|
+
enumerable: true,
|
|
160
|
+
value: globals,
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
export default globals;
|
|
164
|
+
|
|
86
165
|
async function fetchWrapper(resource, options) {
|
|
87
166
|
const response = await fetch(resource, options);
|
|
88
167
|
return response.ok ? await response.arrayBuffer() : undefined;
|
package/src/runtime/ops.js
CHANGED
|
@@ -99,13 +99,18 @@ cache.unevaluatedArgs = true;
|
|
|
99
99
|
/**
|
|
100
100
|
* JavaScript comma operator, returns the last argument.
|
|
101
101
|
*
|
|
102
|
-
* @
|
|
103
|
-
* @
|
|
102
|
+
* @this {AsyncTree|null}
|
|
103
|
+
* @param {...AnnotatedCode} args
|
|
104
104
|
*/
|
|
105
|
-
export function comma(...args) {
|
|
106
|
-
|
|
105
|
+
export async function comma(...args) {
|
|
106
|
+
let result;
|
|
107
|
+
for (const arg of args) {
|
|
108
|
+
result = await evaluate.call(this, arg);
|
|
109
|
+
}
|
|
110
|
+
return result;
|
|
107
111
|
}
|
|
108
112
|
addOpLabel(comma, "«ops.comma»");
|
|
113
|
+
comma.unevaluatedArgs = true;
|
|
109
114
|
|
|
110
115
|
/**
|
|
111
116
|
* Concatenate the given arguments.
|
|
@@ -1537,19 +1537,6 @@ Body text`,
|
|
|
1537
1537
|
assertParse("uriScheme", "https:", [markers.global, "https:"]);
|
|
1538
1538
|
});
|
|
1539
1539
|
|
|
1540
|
-
test("whitespace block", () => {
|
|
1541
|
-
assertParse(
|
|
1542
|
-
"__",
|
|
1543
|
-
`
|
|
1544
|
-
// First comment
|
|
1545
|
-
// Second comment
|
|
1546
|
-
`,
|
|
1547
|
-
null,
|
|
1548
|
-
"jse",
|
|
1549
|
-
false
|
|
1550
|
-
);
|
|
1551
|
-
});
|
|
1552
|
-
|
|
1553
1540
|
test("unaryExpression", () => {
|
|
1554
1541
|
assertParse("unaryExpression", "!true", [
|
|
1555
1542
|
ops.logicalNot,
|
|
@@ -1566,6 +1553,19 @@ Body text`,
|
|
|
1566
1553
|
assertParse("unaryOperator", "-", "-");
|
|
1567
1554
|
assertParse("unaryOperator", "~", "~");
|
|
1568
1555
|
});
|
|
1556
|
+
|
|
1557
|
+
test("whitespace block", () => {
|
|
1558
|
+
assertParse(
|
|
1559
|
+
"__",
|
|
1560
|
+
`
|
|
1561
|
+
// First comment
|
|
1562
|
+
// Second comment
|
|
1563
|
+
`,
|
|
1564
|
+
null,
|
|
1565
|
+
"jse",
|
|
1566
|
+
false
|
|
1567
|
+
);
|
|
1568
|
+
});
|
|
1569
1569
|
});
|
|
1570
1570
|
|
|
1571
1571
|
function assertParse(
|