marko 5.40.3 → 5.41.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.
@@ -24,18 +24,12 @@ const lassoDepPrefix = "package: ";var _default =
24
24
  return;
25
25
  }
26
26
 
27
- const visitedFiles = new Set([
28
- (0, _babelUtils.resolveRelativePath)(entryFile, entryFile.opts.filename)]
29
- );
30
- entryBuilder.visit(entryFile, entryFile, function visitChild(resolved) {
31
- if (!visitedFiles.has(resolved)) {
32
- visitedFiles.add(resolved);
33
- const file = (0, _babelUtils.loadFileForImport)(entryFile, resolved);
34
- if (file) {
35
- entryBuilder.visit(file, entryFile, (id) =>
36
- visitChild(resolveRelativeToEntry(entryFile, file, id))
37
- );
38
- }
27
+ const visitedFiles = new Set([entryFile.opts.filename]);
28
+ entryBuilder.visit(entryFile, entryFile, function visitChild(file) {
29
+ const { filename } = file.opts;
30
+ if (!visitedFiles.has(filename)) {
31
+ visitedFiles.add(filename);
32
+ entryBuilder.visit(file, entryFile, visitChild);
39
33
  }
40
34
  });
41
35
 
@@ -170,14 +164,14 @@ const entryBuilder = exports.entryBuilder = {
170
164
  for (const tag of fileMeta.tags) {
171
165
  if (loadImports?.has(tag)) continue;
172
166
  if (tag.endsWith(".marko")) {
173
- visitChild(tag);
167
+ visitTemplate(entryFile, file, tag, visitChild);
174
168
  } else if (/^@lasso\/marko-taglib\//.test(tag)) {
175
169
  state.hasComponents = true;
176
170
  } else {
177
171
  const importedTemplates = tryGetTemplateImports(file, tag);
178
172
  if (importedTemplates) {
179
173
  for (const templateFile of importedTemplates) {
180
- visitChild(templateFile);
174
+ visitTemplate(entryFile, file, templateFile, visitChild);
181
175
  }
182
176
  }
183
177
  }
@@ -208,6 +202,15 @@ const entryBuilder = exports.entryBuilder = {
208
202
  }
209
203
  };
210
204
 
205
+ // A template `file` names, loaded through the entry as its analysis may not have.
206
+ function visitTemplate(entryFile, file, request, visitChild) {
207
+ const childFile = (0, _babelUtils.loadFileForImport)(
208
+ entryFile,
209
+ resolveRelativeToEntry(entryFile, file, request)
210
+ );
211
+ if (childFile) visitChild(childFile);
212
+ }
213
+
211
214
  function addBrowserImports(seenImports, lassoDeps, body, file, entryFile) {
212
215
  const { filename, sourceMaps } = file.opts;
213
216
  let s;
package/index.d.ts CHANGED
@@ -338,6 +338,17 @@ declare global {
338
338
  removeAllListeners(eventName?: PropertyKey): this;
339
339
  }
340
340
 
341
+ /**
342
+ * A template typed by its signature as a tag (eg `<T>(input: Input<T>) => Return<T>`),
343
+ * from which a tag using a generic template infers its type arguments.
344
+ */
345
+ export interface TemplateOf<
346
+ Signature extends (input: any) => any,
347
+ > extends Template<Parameters<Signature>[0], ReturnType<Signature>> {
348
+ /** Types only: its signature as a tag, never one to call. */
349
+ readonly _: Signature;
350
+ }
351
+
341
352
  export type AttrTag<T> = T & {
342
353
  [Symbol.iterator](): Iterator<T>;
343
354
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "5.40.3",
3
+ "version": "5.41.0",
4
4
  "private": false,
5
5
  "description": "UI Components + streaming, async, high performance, HTML templating for Node.js and the browser.",
6
6
  "keywords": [
@@ -67,8 +67,8 @@
67
67
  },
68
68
  "types": "index.d.ts",
69
69
  "dependencies": {
70
- "@marko/compiler": "^5.43.0",
71
- "@marko/runtime-tags": "6.4.15",
70
+ "@marko/compiler": "^5.43.5",
71
+ "@marko/runtime-tags": "6.5.0",
72
72
  "app-module-path": "^2.2.0",
73
73
  "argly": "^1.2.0",
74
74
  "browser-refresh-client": "1.1.4",
@@ -83,7 +83,7 @@
83
83
  "warp10": "^2.1.0"
84
84
  },
85
85
  "devDependencies": {
86
- "marko": "5.40.3"
86
+ "marko": "5.41.0"
87
87
  },
88
88
  "engines": {
89
89
  "node": ">=22.12.0"
@@ -24,18 +24,12 @@ export default (entryFile, isHydrate) => {
24
24
  return;
25
25
  }
26
26
 
27
- const visitedFiles = new Set([
28
- resolveRelativePath(entryFile, entryFile.opts.filename),
29
- ]);
30
- entryBuilder.visit(entryFile, entryFile, function visitChild(resolved) {
31
- if (!visitedFiles.has(resolved)) {
32
- visitedFiles.add(resolved);
33
- const file = loadFileForImport(entryFile, resolved);
34
- if (file) {
35
- entryBuilder.visit(file, entryFile, (id) =>
36
- visitChild(resolveRelativeToEntry(entryFile, file, id)),
37
- );
38
- }
27
+ const visitedFiles = new Set([entryFile.opts.filename]);
28
+ entryBuilder.visit(entryFile, entryFile, function visitChild(file) {
29
+ const { filename } = file.opts;
30
+ if (!visitedFiles.has(filename)) {
31
+ visitedFiles.add(filename);
32
+ entryBuilder.visit(file, entryFile, visitChild);
39
33
  }
40
34
  });
41
35
 
@@ -170,14 +164,14 @@ export const entryBuilder = {
170
164
  for (const tag of fileMeta.tags) {
171
165
  if (loadImports?.has(tag)) continue;
172
166
  if (tag.endsWith(".marko")) {
173
- visitChild(tag);
167
+ visitTemplate(entryFile, file, tag, visitChild);
174
168
  } else if (/^@lasso\/marko-taglib\//.test(tag)) {
175
169
  state.hasComponents = true;
176
170
  } else {
177
171
  const importedTemplates = tryGetTemplateImports(file, tag);
178
172
  if (importedTemplates) {
179
173
  for (const templateFile of importedTemplates) {
180
- visitChild(templateFile);
174
+ visitTemplate(entryFile, file, templateFile, visitChild);
181
175
  }
182
176
  }
183
177
  }
@@ -208,6 +202,15 @@ export const entryBuilder = {
208
202
  },
209
203
  };
210
204
 
205
+ // A template `file` names, loaded through the entry as its analysis may not have.
206
+ function visitTemplate(entryFile, file, request, visitChild) {
207
+ const childFile = loadFileForImport(
208
+ entryFile,
209
+ resolveRelativeToEntry(entryFile, file, request),
210
+ );
211
+ if (childFile) visitChild(childFile);
212
+ }
213
+
211
214
  function addBrowserImports(seenImports, lassoDeps, body, file, entryFile) {
212
215
  const { filename, sourceMaps } = file.opts;
213
216
  let s;