@marko/compiler 5.21.2 → 5.21.3
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/dist/babel-types/types/patch.js +36 -2
- package/dist/types.d.ts +13 -10
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
2
2
|
var babelTypes = _interopRequireWildcard(require("@babel/types"));
|
|
3
|
-
var _builder = _interopRequireDefault(require("@babel/types/lib/builders/builder"));
|
|
4
3
|
var _utils = _interopRequireDefault(require("@babel/types/lib/definitions/utils"));
|
|
4
|
+
var _validate = _interopRequireDefault(require("@babel/types/lib/validators/validate"));
|
|
5
5
|
var generatedValidators = _interopRequireWildcard(require("@babel/types/lib/validators/generated"));
|
|
6
6
|
var referencedValidators = _interopRequireWildcard(require("@babel/types/lib/validators/isReferenced"));
|
|
7
7
|
var _definitions = _interopRequireWildcard(require("./definitions"));function _getRequireWildcardCache(nodeInterop) {if (typeof WeakMap !== "function") return null;var cacheBabelInterop = new WeakMap();var cacheNodeInterop = new WeakMap();return (_getRequireWildcardCache = function (nodeInterop) {return nodeInterop ? cacheNodeInterop : cacheBabelInterop;})(nodeInterop);}function _interopRequireWildcard(obj, nodeInterop) {if (!nodeInterop && obj && obj.__esModule) {return obj;}if (obj === null || typeof obj !== "object" && typeof obj !== "function") {return { default: obj };}var cache = _getRequireWildcardCache(nodeInterop);if (cache && cache.has(obj)) {return cache.get(obj);}var newObj = {};var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;for (var key in obj) {if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;if (desc && (desc.get || desc.set)) {Object.defineProperty(newObj, key, desc);} else {newObj[key] = obj[key];}}}newObj.default = obj;if (cache) {cache.set(obj, newObj);}return newObj;} /* eslint-disable no-import-assign */
|
|
@@ -37,7 +37,7 @@ _definitions.MARKO_TYPES.forEach((typeName) => {
|
|
|
37
37
|
babelTypes[checkKey] = (node, opts) => is(typeName, node, opts);
|
|
38
38
|
babelTypes[assertKey] = (node, opts) => assert(typeName, node, opts);
|
|
39
39
|
babelTypes[typeName] = babelTypes[lowerName] = function () {
|
|
40
|
-
return
|
|
40
|
+
return builder(typeName, arguments);
|
|
41
41
|
};
|
|
42
42
|
});
|
|
43
43
|
|
|
@@ -68,4 +68,38 @@ function assert(typeName, node, opts) {
|
|
|
68
68
|
}, but instead got "${node.type}".`);
|
|
69
69
|
|
|
70
70
|
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function builder(type, args) {
|
|
74
|
+
const definition = _definitions.default[type];
|
|
75
|
+
const keys = definition.builder;
|
|
76
|
+
const countArgs = args.length;
|
|
77
|
+
if (countArgs > keys.length) {
|
|
78
|
+
throw new Error(
|
|
79
|
+
`${type}: Too many arguments passed. Received ${countArgs} but can receive no more than ${keys.length}`);
|
|
80
|
+
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const node = { type };
|
|
84
|
+
|
|
85
|
+
for (let i = 0; i < keys.length; ++i) {
|
|
86
|
+
const key = keys[i];
|
|
87
|
+
const field = definition.fields[key];
|
|
88
|
+
|
|
89
|
+
let arg;
|
|
90
|
+
if (i < countArgs) arg = args[i];
|
|
91
|
+
if (arg === undefined) {
|
|
92
|
+
arg = Array.isArray(field.default) ? [] : field.default;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
node[key] = arg;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// (assume all enumerable properties are own)
|
|
99
|
+
// eslint-disable-next-line guard-for-in
|
|
100
|
+
for (const key in node) {
|
|
101
|
+
(0, _validate.default)(node, key, node[key]);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return node;
|
|
71
105
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -58,7 +58,7 @@ export interface AssignmentExpression extends BaseNode {
|
|
|
58
58
|
|
|
59
59
|
export interface BinaryExpression extends BaseNode {
|
|
60
60
|
type: "BinaryExpression";
|
|
61
|
-
operator: "+" | "-" | "/" | "%" | "*" | "**" | "&" | "|" | ">>" | ">>>" | "<<" | "^" | "==" | "===" | "!=" | "!==" | "in" | "instanceof" | ">" | "<" | ">=" | "<=";
|
|
61
|
+
operator: "+" | "-" | "/" | "%" | "*" | "**" | "&" | "|" | ">>" | ">>>" | "<<" | "^" | "==" | "===" | "!=" | "!==" | "in" | "instanceof" | ">" | "<" | ">=" | "<=" | "|>";
|
|
62
62
|
left: Expression | PrivateName;
|
|
63
63
|
right: Expression;
|
|
64
64
|
}
|
|
@@ -165,6 +165,7 @@ export interface FunctionDeclaration extends BaseNode {
|
|
|
165
165
|
generator: boolean;
|
|
166
166
|
async: boolean;
|
|
167
167
|
declare: boolean | null;
|
|
168
|
+
predicate: DeclaredPredicate | InferredPredicate | null;
|
|
168
169
|
returnType: TypeAnnotation | TSTypeAnnotation | Noop | null;
|
|
169
170
|
typeParameters: TypeParameterDeclaration | TSTypeParameterDeclaration | Noop | null;
|
|
170
171
|
}
|
|
@@ -176,6 +177,7 @@ export interface FunctionExpression extends BaseNode {
|
|
|
176
177
|
body: BlockStatement;
|
|
177
178
|
generator: boolean;
|
|
178
179
|
async: boolean;
|
|
180
|
+
predicate: DeclaredPredicate | InferredPredicate | null;
|
|
179
181
|
returnType: TypeAnnotation | TSTypeAnnotation | Noop | null;
|
|
180
182
|
typeParameters: TypeParameterDeclaration | TSTypeParameterDeclaration | Noop | null;
|
|
181
183
|
}
|
|
@@ -380,7 +382,7 @@ export interface WithStatement extends BaseNode {
|
|
|
380
382
|
|
|
381
383
|
export interface AssignmentPattern extends BaseNode {
|
|
382
384
|
type: "AssignmentPattern";
|
|
383
|
-
left: Identifier | ObjectPattern | ArrayPattern | MemberExpression;
|
|
385
|
+
left: Identifier | ObjectPattern | ArrayPattern | MemberExpression | TSAsExpression | TSTypeAssertion | TSNonNullExpression;
|
|
384
386
|
right: Expression;
|
|
385
387
|
decorators: Array<Decorator> | null;
|
|
386
388
|
typeAnnotation: TypeAnnotation | TSTypeAnnotation | Noop | null;
|
|
@@ -401,6 +403,7 @@ export interface ArrowFunctionExpression extends BaseNode {
|
|
|
401
403
|
async: boolean;
|
|
402
404
|
expression: boolean;
|
|
403
405
|
generator: boolean;
|
|
406
|
+
predicate: DeclaredPredicate | InferredPredicate | null;
|
|
404
407
|
returnType: TypeAnnotation | TSTypeAnnotation | Noop | null;
|
|
405
408
|
typeParameters: TypeParameterDeclaration | TSTypeParameterDeclaration | Noop | null;
|
|
406
409
|
}
|
|
@@ -866,9 +869,9 @@ export interface NumberTypeAnnotation extends BaseNode {
|
|
|
866
869
|
export interface ObjectTypeAnnotation extends BaseNode {
|
|
867
870
|
type: "ObjectTypeAnnotation";
|
|
868
871
|
properties: Array<ObjectTypeProperty | ObjectTypeSpreadProperty>;
|
|
869
|
-
indexers: Array<ObjectTypeIndexer
|
|
870
|
-
callProperties: Array<ObjectTypeCallProperty
|
|
871
|
-
internalSlots: Array<ObjectTypeInternalSlot
|
|
872
|
+
indexers: Array<ObjectTypeIndexer>;
|
|
873
|
+
callProperties: Array<ObjectTypeCallProperty>;
|
|
874
|
+
internalSlots: Array<ObjectTypeInternalSlot>;
|
|
872
875
|
exact: boolean;
|
|
873
876
|
inexact: boolean | null;
|
|
874
877
|
}
|
|
@@ -1743,8 +1746,8 @@ export type Function = FunctionDeclaration | FunctionExpression | ObjectMethod |
|
|
|
1743
1746
|
export type FunctionParent = FunctionDeclaration | FunctionExpression | ObjectMethod | ArrowFunctionExpression | ClassMethod | ClassPrivateMethod | StaticBlock;
|
|
1744
1747
|
export type Pureish = FunctionDeclaration | FunctionExpression | StringLiteral | NumericLiteral | NullLiteral | BooleanLiteral | RegExpLiteral | ArrowFunctionExpression | BigIntLiteral | DecimalLiteral;
|
|
1745
1748
|
export type Declaration = FunctionDeclaration | VariableDeclaration | ClassDeclaration | ExportAllDeclaration | ExportDefaultDeclaration | ExportNamedDeclaration | ImportDeclaration | DeclareClass | DeclareFunction | DeclareInterface | DeclareModule | DeclareModuleExports | DeclareTypeAlias | DeclareOpaqueType | DeclareVariable | DeclareExportDeclaration | DeclareExportAllDeclaration | InterfaceDeclaration | OpaqueType | TypeAlias | EnumDeclaration | TSDeclareFunction | TSInterfaceDeclaration | TSTypeAliasDeclaration | TSEnumDeclaration | TSModuleDeclaration;
|
|
1746
|
-
export type PatternLike = Identifier | RestElement | AssignmentPattern | ArrayPattern | ObjectPattern;
|
|
1747
|
-
export type LVal = Identifier | MemberExpression | RestElement | AssignmentPattern | ArrayPattern | ObjectPattern | TSParameterProperty;
|
|
1749
|
+
export type PatternLike = Identifier | RestElement | AssignmentPattern | ArrayPattern | ObjectPattern | TSAsExpression | TSTypeAssertion | TSNonNullExpression;
|
|
1750
|
+
export type LVal = Identifier | MemberExpression | RestElement | AssignmentPattern | ArrayPattern | ObjectPattern | TSParameterProperty | TSAsExpression | TSTypeAssertion | TSNonNullExpression;
|
|
1748
1751
|
export type TSEntityName = Identifier | TSQualifiedName;
|
|
1749
1752
|
export type Literal = StringLiteral | NumericLiteral | NullLiteral | BooleanLiteral | RegExpLiteral | TemplateLiteral | BigIntLiteral | DecimalLiteral;
|
|
1750
1753
|
export type Immutable = StringLiteral | NumericLiteral | NullLiteral | BooleanLiteral | BigIntLiteral | JSXAttribute | JSXClosingElement | JSXElement | JSXExpressionContainer | JSXSpreadChild | JSXOpeningElement | JSXText | JSXFragment | JSXOpeningFragment | JSXClosingFragment | DecimalLiteral;
|
|
@@ -1832,7 +1835,7 @@ export interface Aliases {
|
|
|
1832
1835
|
|
|
1833
1836
|
export function arrayExpression(elements?: Array<null | Expression | SpreadElement>): ArrayExpression;
|
|
1834
1837
|
export function assignmentExpression(operator: string, left: LVal, right: Expression): AssignmentExpression;
|
|
1835
|
-
export function binaryExpression(operator: "+" | "-" | "/" | "%" | "*" | "**" | "&" | "|" | ">>" | ">>>" | "<<" | "^" | "==" | "===" | "!=" | "!==" | "in" | "instanceof" | ">" | "<" | ">=" | "<=", left: Expression | PrivateName, right: Expression): BinaryExpression;
|
|
1838
|
+
export function binaryExpression(operator: "+" | "-" | "/" | "%" | "*" | "**" | "&" | "|" | ">>" | ">>>" | "<<" | "^" | "==" | "===" | "!=" | "!==" | "in" | "instanceof" | ">" | "<" | ">=" | "<=" | "|>", left: Expression | PrivateName, right: Expression): BinaryExpression;
|
|
1836
1839
|
export function interpreterDirective(value: string): InterpreterDirective;
|
|
1837
1840
|
export function directive(value: DirectiveLiteral): Directive;
|
|
1838
1841
|
export function directiveLiteral(value: string): DirectiveLiteral;
|
|
@@ -1881,7 +1884,7 @@ export function variableDeclaration(kind: "var" | "let" | "const", declarations:
|
|
|
1881
1884
|
export function variableDeclarator(id: LVal, init?: Expression | null): VariableDeclarator;
|
|
1882
1885
|
export function whileStatement(test: Expression, body: Statement): WhileStatement;
|
|
1883
1886
|
export function withStatement(object: Expression, body: Statement): WithStatement;
|
|
1884
|
-
export function assignmentPattern(left: Identifier | ObjectPattern | ArrayPattern | MemberExpression, right: Expression): AssignmentPattern;
|
|
1887
|
+
export function assignmentPattern(left: Identifier | ObjectPattern | ArrayPattern | MemberExpression | TSAsExpression | TSTypeAssertion | TSNonNullExpression, right: Expression): AssignmentPattern;
|
|
1885
1888
|
export function arrayPattern(elements: Array<null | PatternLike>): ArrayPattern;
|
|
1886
1889
|
export function arrowFunctionExpression(params: Array<Identifier | Pattern | RestElement>, body: BlockStatement | Expression, async?: boolean): ArrowFunctionExpression;
|
|
1887
1890
|
export function classBody(body: Array<ClassMethod | ClassPrivateMethod | ClassProperty | ClassPrivateProperty | ClassAccessorProperty | TSDeclareMethod | TSIndexSignature | StaticBlock>): ClassBody;
|
|
@@ -1950,7 +1953,7 @@ export function emptyTypeAnnotation(): EmptyTypeAnnotation;
|
|
|
1950
1953
|
export function nullableTypeAnnotation(typeAnnotation: FlowType): NullableTypeAnnotation;
|
|
1951
1954
|
export function numberLiteralTypeAnnotation(value: number): NumberLiteralTypeAnnotation;
|
|
1952
1955
|
export function numberTypeAnnotation(): NumberTypeAnnotation;
|
|
1953
|
-
export function objectTypeAnnotation(properties: Array<ObjectTypeProperty | ObjectTypeSpreadProperty>, indexers?: Array<ObjectTypeIndexer
|
|
1956
|
+
export function objectTypeAnnotation(properties: Array<ObjectTypeProperty | ObjectTypeSpreadProperty>, indexers?: Array<ObjectTypeIndexer>, callProperties?: Array<ObjectTypeCallProperty>, internalSlots?: Array<ObjectTypeInternalSlot>, exact?: boolean): ObjectTypeAnnotation;
|
|
1954
1957
|
export function objectTypeInternalSlot(id: Identifier, value: FlowType, optional: boolean, _static: boolean, method: boolean): ObjectTypeInternalSlot;
|
|
1955
1958
|
export function objectTypeCallProperty(value: FlowType): ObjectTypeCallProperty;
|
|
1956
1959
|
export function objectTypeIndexer(id: Identifier | null | undefined, key: FlowType, value: FlowType, variance?: Variance | null): ObjectTypeIndexer;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marko/compiler",
|
|
3
3
|
"description": "Marko template to JS compiler.",
|
|
4
|
-
"version": "5.21.
|
|
4
|
+
"version": "5.21.3",
|
|
5
5
|
"author": "Dylan Piercey <dpiercey@ebay.com>",
|
|
6
6
|
"bugs": "https://github.com/marko-js/marko/issues/new?template=Bug_report.md",
|
|
7
7
|
"dependencies": {
|