@marko/compiler 5.39.49 → 5.39.51

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.
@@ -1,254 +0,0 @@
1
- "use strict";exports.__esModule = true;exports.default = exports.MARKO_TYPES = exports.MARKO_ALIAS_TYPES = void 0;var _utils = require("@babel/types/lib/definitions/utils");
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
- const valueFieldCommon = {
10
- value: {
11
- validate: (0, _utils.assertValueType)("string")
12
- }
13
- };
14
-
15
- const MarkoDefinitions = {
16
- MarkoParseError: {
17
- aliases: ["Marko", "Expression", "Statement"],
18
- builder: ["source", "label", "errorLoc"],
19
- fields: {
20
- source: {
21
- validate: (0, _utils.assertValueType)("string")
22
- },
23
- label: {
24
- validate: (0, _utils.assertValueType)("string")
25
- },
26
- errorLoc: {
27
- optional: true,
28
- validate: (0, _utils.assertValueType)("object")
29
- }
30
- }
31
- },
32
- MarkoDocumentType: {
33
- aliases: ["Marko", "Statement"],
34
- builder: ["value"],
35
- fields: { ...valueFieldCommon }
36
- },
37
-
38
- MarkoDeclaration: {
39
- aliases: ["Marko", "Statement"],
40
- builder: ["value"],
41
- fields: { ...valueFieldCommon }
42
- },
43
-
44
- MarkoCDATA: {
45
- aliases: ["Marko", "Statement"],
46
- builder: ["value"],
47
- fields: { ...valueFieldCommon }
48
- },
49
-
50
- MarkoComment: {
51
- aliases: ["Marko", "Statement"],
52
- builder: ["value"],
53
- fields: { ...valueFieldCommon }
54
- },
55
-
56
- MarkoText: {
57
- aliases: ["Marko", "Statement"],
58
- builder: ["value"],
59
- fields: { ...valueFieldCommon }
60
- },
61
-
62
- MarkoPlaceholder: {
63
- aliases: ["Marko", "Statement"],
64
- builder: ["value", "escape"],
65
- visitor: ["value"],
66
- fields: {
67
- value: {
68
- validate: (0, _utils.assertNodeType)("Expression")
69
- },
70
- escape: {
71
- validate: (0, _utils.assertValueType)("boolean"),
72
- default: true
73
- }
74
- }
75
- },
76
-
77
- MarkoScriptlet: {
78
- aliases: ["Marko", "Statement"],
79
- builder: ["body", "static", "target"],
80
- visitor: ["body"],
81
- fields: {
82
- body: {
83
- validate: arrayOfType(["Statement"])
84
- },
85
- static: {
86
- validate: (0, _utils.assertValueType)("boolean"),
87
- default: false
88
- },
89
- target: {
90
- validate: (0, _utils.assertOneOf)("server", "client"),
91
- optional: true
92
- }
93
- }
94
- },
95
-
96
- MarkoClass: {
97
- aliases: ["Marko", "Statement", "Class"],
98
- builder: ["body"],
99
- visitor: ["body"],
100
- fields: {
101
- body: {
102
- validate: (0, _utils.assertNodeType)("ClassBody")
103
- }
104
- }
105
- },
106
-
107
- MarkoAttribute: {
108
- aliases: ["Marko"],
109
- builder: ["name", "value", "modifier", "arguments", "default", "bound"],
110
- visitor: ["value", "arguments"],
111
- fields: {
112
- name: {
113
- validate: (0, _utils.assertValueType)("string")
114
- },
115
- value: {
116
- validate: (0, _utils.assertNodeType)("Expression")
117
- },
118
- modifier: {
119
- validate: (0, _utils.assertValueType)("string"),
120
- optional: true
121
- },
122
- arguments: {
123
- validate: (0, _utils.chain)(
124
- (0, _utils.assertValueType)("array"),
125
- (0, _utils.assertEach)((0, _utils.assertNodeType)("Expression", "SpreadElement"))
126
- ),
127
- optional: true
128
- },
129
- default: {
130
- validate: (0, _utils.assertValueType)("boolean"),
131
- optional: true
132
- },
133
- bound: {
134
- validate: (0, _utils.assertValueType)("boolean"),
135
- optional: true
136
- }
137
- }
138
- },
139
-
140
- MarkoSpreadAttribute: {
141
- aliases: ["Marko"],
142
- builder: ["value"],
143
- visitor: ["value"],
144
- fields: {
145
- value: {
146
- validate: (0, _utils.assertNodeType)("Expression")
147
- }
148
- }
149
- },
150
-
151
- MarkoTagBody: {
152
- aliases: ["Marko", "BlockParent", "FunctionParent", "Scope"],
153
- builder: ["body", "params"],
154
- visitor: ["typeParameters", "params", "body"],
155
- fields: {
156
- params: {
157
- validate: (0, _utils.chain)(
158
- (0, _utils.assertValueType)("array"),
159
- (0, _utils.assertEach)((0, _utils.assertNodeType)("Identifier", "Pattern", "RestElement"))
160
- ),
161
- default: []
162
- },
163
- typeParameters: {
164
- validate: (0, _utils.assertNodeType)("TSTypeParameterDeclaration"),
165
- optional: true
166
- },
167
- body: {
168
- validate: arrayOfType([
169
- "MarkoTag",
170
- "MarkoCDATA",
171
- "MarkoText",
172
- "MarkoPlaceholder",
173
- "MarkoScriptlet",
174
- "MarkoComment"]
175
- ),
176
- default: []
177
- },
178
- attributeTags: {
179
- validate: (0, _utils.assertValueType)("boolean"),
180
- default: false
181
- }
182
- }
183
- },
184
-
185
- MarkoTag: {
186
- aliases: ["Marko", "Statement"],
187
- builder: [
188
- "name",
189
- "attributes",
190
- "body",
191
- "arguments",
192
- "var",
193
- "attributeTags"],
194
-
195
- visitor: [
196
- "name",
197
- "typeArguments",
198
- "arguments",
199
- "attributes",
200
- "attributeTags",
201
- "var",
202
- "body"],
203
-
204
- fields: {
205
- name: {
206
- validate: (0, _utils.assertNodeType)("Expression")
207
- },
208
- attributes: {
209
- validate: arrayOfType(["MarkoAttribute", "MarkoSpreadAttribute"]),
210
- default: []
211
- },
212
- body: {
213
- validate: (0, _utils.assertNodeType)("MarkoTagBody")
214
- },
215
- arguments: {
216
- validate: (0, _utils.chain)(
217
- (0, _utils.assertValueType)("array"),
218
- (0, _utils.assertEach)((0, _utils.assertNodeType)("Expression", "SpreadElement"))
219
- ),
220
- optional: true
221
- },
222
- typeArguments: {
223
- validate: (0, _utils.assertNodeType)("TSTypeParameterInstantiation"),
224
- optional: true
225
- },
226
- rawValue: {
227
- validate: (0, _utils.assertValueType)("string"),
228
- optional: true
229
- },
230
- var: {
231
- validate: (0, _utils.assertNodeType)("LVal"),
232
- optional: true
233
- },
234
- attributeTags: {
235
- validate: arrayOfType(["MarkoTag", "MarkoScriptlet", "MarkoComment"]),
236
- default: []
237
- }
238
- }
239
- }
240
- };var _default = exports.default =
241
-
242
- MarkoDefinitions;
243
- const MARKO_TYPES = exports.MARKO_TYPES = Object.keys(MarkoDefinitions);
244
- const MARKO_ALIAS_TYPES = exports.MARKO_ALIAS_TYPES = Array.from(
245
- new Set(
246
- MARKO_TYPES.reduce((all, t) => all.concat(MarkoDefinitions[t].aliases), [])
247
- )
248
- );
249
-
250
- // Note this is inline because a change in babel caused a regression with this api.
251
- // TODO: we should not rely on babels validators or builders.
252
- function arrayOfType(types) {
253
- return (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)(...types)));
254
- }
@@ -1,122 +0,0 @@
1
- "use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
2
- var babelTypes = _interopRequireWildcard(require("@babel/types"));
3
- var definitionUtils = _interopRequireWildcard(require("@babel/types/lib/definitions/utils"));
4
- var generatedValidators = _interopRequireWildcard(require("@babel/types/lib/validators/generated"));
5
- var referencedValidators = _interopRequireWildcard(require("@babel/types/lib/validators/isReferenced"));
6
- var _validate = _interopRequireDefault(require("@babel/types/lib/validators/validate"));
7
-
8
- var _definitions = _interopRequireWildcard(require("./definitions"));function _interopRequireWildcard(e, t) {if ("function" == typeof WeakMap) var r = new WeakMap(),n = new WeakMap();return (_interopRequireWildcard = function (e, t) {if (!t && e && e.__esModule) return e;var o,i,f = { __proto__: null, default: e };if (null === e || "object" != typeof e && "function" != typeof e) return f;if (o = t ? n : r) {if (o.has(e)) return o.get(e);o.set(e, f);}for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]);return f;})(e, t);} /* eslint-disable no-import-assign */
9
-
10
- const {
11
- TYPES,
12
- VISITOR_KEYS,
13
- FLIPPED_ALIAS_KEYS,
14
- DEPRECATED_KEYS,
15
- is,
16
- getBindingIdentifiers
17
- } = babelTypes;
18
-
19
- getBindingIdentifiers.keys.Program = ["params"];
20
- getBindingIdentifiers.keys.MarkoTag = ["var"];
21
- getBindingIdentifiers.keys.MarkoTagBody = ["params"];
22
- getBindingIdentifiers.keys.MarkoScriptlet = ["body"];
23
-
24
- _definitions.MARKO_TYPES.forEach((typeName) => {
25
- definitionUtils.default(typeName, _definitions.default[typeName]);
26
- });
27
-
28
- babelTypes.NODE_FIELDS.Program.params =
29
- babelTypes.NODE_FIELDS.MarkoTagBody.params;
30
-
31
- for (const type of [
32
- ...Object.keys(VISITOR_KEYS),
33
- ...Object.keys(FLIPPED_ALIAS_KEYS),
34
- ...Object.keys(DEPRECATED_KEYS)])
35
- {
36
- if (!TYPES.includes(type)) TYPES.push(type);
37
- }
38
-
39
- _definitions.MARKO_TYPES.forEach((typeName) => {
40
- const lowerName = typeName[0].toLowerCase() + typeName.slice(1);
41
- const checkKey = `is${typeName}`;
42
- const assertKey = `assert${typeName}`;
43
- babelTypes[checkKey] = (node, opts) => is(typeName, node, opts);
44
- babelTypes[assertKey] = (node, opts) => assert(typeName, node, opts);
45
- babelTypes[typeName] = babelTypes[lowerName] = function () {
46
- return builder(typeName, arguments);
47
- };
48
- });
49
-
50
- _definitions.MARKO_ALIAS_TYPES.forEach((aliasName) => {
51
- const checkKey = `is${aliasName}`;
52
- const originalCheck = generatedValidators[checkKey];
53
- generatedValidators[checkKey] = (node, opts) =>
54
- is(aliasName, node, opts) || originalCheck(node, opts);
55
- });
56
-
57
- const originalIsReferenced = referencedValidators.default;
58
- referencedValidators.default = (node, parent, grandparent) => {
59
- switch (parent.type) {
60
- case "MarkoTag":
61
- return parent.var !== node;
62
- case "MarkoTagBody":
63
- return false;
64
- default:
65
- return originalIsReferenced(node, parent, grandparent);
66
- }
67
- };
68
-
69
- for (const { types, set } of definitionUtils.allExpandedTypes || []) {
70
- for (const type of types) {
71
- const aliases = FLIPPED_ALIAS_KEYS[type];
72
- if (aliases) {
73
- aliases.forEach(set.add, set);
74
- } else {
75
- set.add(type);
76
- }
77
- }
78
- }
79
-
80
- function assert(typeName, node, opts) {
81
- if (!is(typeName, node, opts)) {
82
- throw new Error(
83
- `Expected type "${typeName}" with option ${JSON.stringify(
84
- opts
85
- )}, but instead got "${node.type}".`
86
- );
87
- }
88
- }
89
-
90
- function builder(type, args) {
91
- const definition = _definitions.default[type];
92
- const keys = definition.builder;
93
- const countArgs = args.length;
94
- if (countArgs > keys.length) {
95
- throw new Error(
96
- `${type}: Too many arguments passed. Received ${countArgs} but can receive no more than ${keys.length}`
97
- );
98
- }
99
-
100
- const node = { type };
101
-
102
- for (let i = 0; i < keys.length; ++i) {
103
- const key = keys[i];
104
- const field = definition.fields[key];
105
-
106
- let arg;
107
- if (i < countArgs) arg = args[i];
108
- if (arg === undefined) {
109
- arg = Array.isArray(field.default) ? [] : field.default;
110
- }
111
-
112
- node[key] = arg;
113
- }
114
-
115
- // (assume all enumerable properties are own)
116
-
117
- for (const key in node) {
118
- (0, _validate.default)(node, key, node[key]);
119
- }
120
-
121
- return node;
122
- }