@marko/compiler 5.33.7 → 5.34.0

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.
@@ -396,4 +396,7 @@ function isMarkoOutput(output) {
396
396
 
397
397
  function finalizeMeta(meta) {
398
398
  meta.watchFiles = [...new Set(meta.watchFiles)];
399
+ if (meta.analyzedTags) {
400
+ meta.analyzedTags = [...new Set(meta.analyzedTags)];
401
+ }
399
402
  }
@@ -208,7 +208,7 @@ function parseMarko(file) {
208
208
  );
209
209
  },
210
210
  onTagTypeParams(part) {
211
- currentTag.node.typeParameters = (0, _babelUtils.parseTypeParams)(
211
+ currentBody.node.typeParameters = (0, _babelUtils.parseTypeParams)(
212
212
  file,
213
213
  parser.read(part.value),
214
214
  part.start,
@@ -193,12 +193,12 @@ Object.assign(_printer.default.prototype, {
193
193
  }
194
194
 
195
195
  if (node.body.params.length) {
196
- if (node.typeParameters) {
196
+ if (node.body.typeParameters) {
197
197
  if (!node.typeArguments) {
198
198
  this.token(" ");
199
199
  }
200
200
  this.token("<");
201
- this.printList(node.typeParameters.params, node);
201
+ this.printList(node.body.typeParameters.params, node);
202
202
  this.token(">");
203
203
  }
204
204
  this.token("|");
@@ -147,7 +147,7 @@ const MarkoDefinitions = {
147
147
  MarkoTagBody: {
148
148
  aliases: ["Marko", "BlockParent", "Scope"],
149
149
  builder: ["body", "params"],
150
- visitor: ["params", "body"],
150
+ visitor: ["typeParameters", "params", "body"],
151
151
  fields: {
152
152
  params: {
153
153
  validate: (0, _utils.chain)(
@@ -156,6 +156,10 @@ const MarkoDefinitions = {
156
156
  ),
157
157
  default: []
158
158
  },
159
+ typeParameters: {
160
+ validate: (0, _utils.assertNodeType)("TSTypeParameterDeclaration"),
161
+ optional: true
162
+ },
159
163
  body: {
160
164
  validate: (0, _utils.arrayOfType)([
161
165
  "MarkoTag",
@@ -173,7 +177,14 @@ const MarkoDefinitions = {
173
177
  MarkoTag: {
174
178
  aliases: ["Marko", "Statement"],
175
179
  builder: ["name", "attributes", "body", "arguments", "var"],
176
- visitor: ["name", "attributes", "body", "arguments", "var"],
180
+ visitor: [
181
+ "name",
182
+ "typeArguments",
183
+ "attributes",
184
+ "body",
185
+ "arguments",
186
+ "var"],
187
+
177
188
  fields: {
178
189
  name: {
179
190
  validate: (0, _utils.assertNodeType)("Expression")
@@ -193,17 +204,7 @@ const MarkoDefinitions = {
193
204
  optional: true
194
205
  },
195
206
  typeArguments: {
196
- validate: (0, _utils.chain)(
197
- (0, _utils.assertValueType)("array"),
198
- (0, _utils.assertEach)((0, _utils.assertNodeType)("TypeAnnotation"))
199
- ),
200
- optional: true
201
- },
202
- typeParameters: {
203
- validate: (0, _utils.chain)(
204
- (0, _utils.assertValueType)("array"),
205
- (0, _utils.assertEach)((0, _utils.assertNodeType)("TypeAnnotation"))
206
- ),
207
+ validate: (0, _utils.assertNodeType)("TSTypeParameterInstantiation"),
207
208
  optional: true
208
209
  },
209
210
  rawValue: {
@@ -120,7 +120,7 @@ function find(dirname, registeredTaglibs) {
120
120
  nodePath.join(name, "marko.json")
121
121
  );
122
122
  if (taglibPath) {
123
- var taglib = taglibLoader.loadTaglibFromFile(taglibPath);
123
+ var taglib = taglibLoader.loadTaglibFromFile(taglibPath, true);
124
124
  helper.addTaglib(taglib);
125
125
  }
126
126
  }
@@ -26,9 +26,10 @@ function handleImport(taglib, importedTaglib) {
26
26
  }
27
27
 
28
28
  class Taglib {
29
- constructor(filePath) {
29
+ constructor(filePath, isFromPackageJson) {
30
30
  ok(filePath, '"filePath" expected');
31
31
  this.filePath = this.path /* deprecated */ = this.id = filePath;
32
+ this.isFromPackageJson = isFromPackageJson === true;
32
33
  this.dirname = path.dirname(this.filePath);
33
34
  this.scriptLang = undefined;
34
35
  this.tags = {};
@@ -8,8 +8,8 @@ function loadTaglibFromProps(taglib, taglibProps) {
8
8
  return loaders.loadTaglibFromProps(taglib, taglibProps);
9
9
  }
10
10
 
11
- function loadTaglibFromFile(filePath) {
12
- return loaders.loadTaglibFromFile(filePath);
11
+ function loadTaglibFromFile(filePath, isFromPackageJson) {
12
+ return loaders.loadTaglibFromFile(filePath, isFromPackageJson);
13
13
  }
14
14
 
15
15
  function loadTaglibFromDir(filePath) {
@@ -5,7 +5,7 @@ var loaders = require("./loaders");
5
5
 
6
6
  var ok = require("assert").ok;
7
7
 
8
- function loadFromFile(filePath) {
8
+ function loadFromFile(filePath, isFromPackageJson) {
9
9
  ok(filePath, '"filePath" is required');
10
10
 
11
11
  var taglib = cache.get(filePath);
@@ -13,7 +13,7 @@ function loadFromFile(filePath) {
13
13
  // Only load a taglib once by caching the loaded taglibs using the file
14
14
  // system file path as the key
15
15
  if (!taglib) {
16
- taglib = new types.Taglib(filePath);
16
+ taglib = new types.Taglib(filePath, isFromPackageJson);
17
17
  cache.put(filePath, taglib);
18
18
 
19
19
  var taglibProps = jsonFileReader.readFileSync(filePath);
@@ -252,6 +252,24 @@ class TaglibLoader {
252
252
  }
253
253
  }
254
254
 
255
+ exports(dir) {
256
+ var taglib = this.taglib;
257
+ var path = this.filePath;
258
+ var dirname = this.dirname;
259
+
260
+ if (taglib.isFromPackageJson) {
261
+ taglib.tagsDir = false;
262
+
263
+ scanTagsDir(
264
+ path,
265
+ dirname,
266
+ dir,
267
+ taglib,
268
+ this.dependencyChain.append(`exports`)
269
+ );
270
+ }
271
+ }
272
+
255
273
  taglibImports(imports) {
256
274
  // The "taglib-imports" property allows another taglib to be imported
257
275
  // into this taglib so that the tags defined in the imported taglib
package/dist/types.d.ts CHANGED
@@ -1720,6 +1720,7 @@ export interface MarkoTagBody extends BaseNode {
1720
1720
  type: "MarkoTagBody";
1721
1721
  body: Array<MarkoTag | MarkoCDATA | MarkoText | MarkoPlaceholder | MarkoScriptlet | MarkoComment>;
1722
1722
  params: Array<Identifier | Pattern | RestElement>;
1723
+ typeParameters: TSTypeParameterDeclaration | null;
1723
1724
  }
1724
1725
 
1725
1726
  export interface MarkoTag extends BaseNode {
@@ -1730,8 +1731,7 @@ export interface MarkoTag extends BaseNode {
1730
1731
  arguments: Array<Expression | SpreadElement> | null;
1731
1732
  var: LVal | null;
1732
1733
  rawValue: string | null;
1733
- typeArguments: Array<TypeAnnotation> | null;
1734
- typeParameters: Array<TypeAnnotation> | null;
1734
+ typeArguments: TSTypeParameterInstantiation | null;
1735
1735
  }
1736
1736
 
1737
1737
  /**
package/index.d.ts CHANGED
@@ -26,6 +26,7 @@ export interface MarkoMeta {
26
26
  watchFiles: string[];
27
27
  tags?: string[];
28
28
  deps: Array<string | Dep | VirtualDep>;
29
+ analyzedTags?: [string, ...string[]];
29
30
  diagnostics: Diagnostic[];
30
31
  }
31
32
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marko/compiler",
3
- "version": "5.33.7",
3
+ "version": "5.34.0",
4
4
  "description": "Marko template to JS compiler.",
5
5
  "keywords": [
6
6
  "babel",
@@ -45,7 +45,7 @@
45
45
  "@babel/runtime": "^7.16.0",
46
46
  "@babel/traverse": "^7.16.0",
47
47
  "@babel/types": "^7.16.0",
48
- "@marko/babel-utils": "^6.3.3",
48
+ "@marko/babel-utils": "^6.3.4",
49
49
  "complain": "^1.6.0",
50
50
  "he": "^1.2.0",
51
51
  "htmljs-parser": "^5.4.3",
@@ -61,7 +61,7 @@
61
61
  "strip-json-comments": "^3.1.1"
62
62
  },
63
63
  "devDependencies": {
64
- "@marko/translator-default": "^5.31.7"
64
+ "@marko/translator-default": "^5.31.8"
65
65
  },
66
66
  "publishConfig": {
67
67
  "access": "public"