@marko/language-tools 2.5.11 → 2.5.13

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/index.js CHANGED
@@ -1994,7 +1994,7 @@ var ScriptExtractor = class {
1994
1994
  }
1995
1995
  #writeProgram(program) {
1996
1996
  this.#writeCommentPragmas(program);
1997
- const componentFileName = getComponentFilename(this.#filename);
1997
+ const componentFileName = this.#api !== RuntimeAPI.tags ? getComponentFilename(this.#filename) : void 0;
1998
1998
  const inputType = this.#getInputType(program);
1999
1999
  let componentClassBody;
2000
2000
  for (const node of program.static) {
@@ -2084,35 +2084,37 @@ var ScriptExtractor = class {
2084
2084
  );
2085
2085
  }
2086
2086
  }
2087
- if (isExternalComponentFile) {
2088
- if (this.#scriptLang === "ts" /* ts */) {
2089
- this.#extractor.write(
2090
- `import type Component from "${stripExt(
2091
- (0, import_relative_import_path.relativeImportPath)(this.#filename, componentFileName)
2092
- )}";
2087
+ if (this.#api !== RuntimeAPI.tags) {
2088
+ if (isExternalComponentFile) {
2089
+ if (this.#scriptLang === "ts" /* ts */) {
2090
+ this.#extractor.write(
2091
+ `import type Component from "${stripExt(
2092
+ (0, import_relative_import_path.relativeImportPath)(this.#filename, componentFileName)
2093
+ )}";
2093
2094
  `
2094
- );
2095
- } else {
2096
- this.#extractor.write(
2097
- `/** @typedef {import("${stripExt(
2098
- (0, import_relative_import_path.relativeImportPath)(this.#filename, componentFileName)
2099
- )}") extends infer Component ? Component extends { default: infer Component } ? Component : Component : never} Component */
2095
+ );
2096
+ } else {
2097
+ this.#extractor.write(
2098
+ `/** @typedef {import("${stripExt(
2099
+ (0, import_relative_import_path.relativeImportPath)(this.#filename, componentFileName)
2100
+ )}") extends infer Component ? Component extends { default: infer Component } ? Component : Component : never} Component */
2100
2101
  `
2101
- );
2102
- }
2103
- } else {
2104
- const body2 = componentClassBody || " {}";
2105
- if (this.#scriptLang === "ts" /* ts */) {
2106
- this.#extractor.write(
2107
- `abstract class Component${typeParamsStr} extends Marko.Component<Input${typeArgsStr}>`
2108
- ).copy(body2).write("\nexport { type Component }\n");
2102
+ );
2103
+ }
2109
2104
  } else {
2110
- this.#extractor.write(`/**${jsDocTemplateTagsStr}
2111
- * @extends {Marko.Component<Input${typeArgsStr}>}
2112
- * @abstract
2113
- */
2105
+ const body2 = componentClassBody || " {}";
2106
+ if (this.#scriptLang === "ts" /* ts */) {
2107
+ this.#extractor.write(
2108
+ `abstract class Component${typeParamsStr} extends Marko.Component<Input${typeArgsStr}>`
2109
+ ).copy(body2).write("\nexport { type Component }\n");
2110
+ } else {
2111
+ this.#extractor.write(`/**${jsDocTemplateTagsStr}
2112
+ * @extends {Marko.Component<Input${typeArgsStr}>}
2113
+ * @abstract
2114
+ */
2114
2115
  `);
2115
- this.#extractor.write(`export class Component extends Marko.Component`).copy(body2).write("\n");
2116
+ this.#extractor.write(`export class Component extends Marko.Component`).copy(body2).write("\n");
2117
+ }
2116
2118
  }
2117
2119
  }
2118
2120
  const didReturn = !!getReturnTag(program);
@@ -2132,16 +2134,16 @@ var ScriptExtractor = class {
2132
2134
  function ${templateName}() {
2133
2135
  `);
2134
2136
  }
2135
- this.#extractor.write(` const input = ${this.#getCastedType(`Input${typeArgsStr}`)};
2137
+ this.#extractor.write(` const input = ${this.#getCastedType(`Input${typeArgsStr}`)};${this.#api !== RuntimeAPI.tags ? `
2136
2138
  const component = ${this.#getCastedType(`Component${typeArgsStr}`)};
2137
2139
  const state = ${varShared("state")}(component);
2140
+ const out = ${varShared("out")};` : ""}
2138
2141
  const $signal = ${this.#getCastedType("AbortSignal")};
2139
2142
  const $global = ${varShared("getGlobal")}(
2140
2143
  // @ts-expect-error We expect the compiler to error because we are checking if the MarkoRun.Context is defined.
2141
2144
  (${varShared("error")}, ${this.#getCastedType("MarkoRun.Context")})
2142
2145
  );
2143
- const out = ${varShared("out")};
2144
- ${varShared("noop")}({ input, component, state, out, $global, $signal });
2146
+ ${varShared("noop")}({ ${this.#api !== RuntimeAPI.tags ? "component, state, out, " : ""}input, $global, $signal });
2145
2147
  `);
2146
2148
  const body = this.#processBody(program);
2147
2149
  if (body == null ? void 0 : body.content) {
@@ -2613,7 +2615,7 @@ ${isMutatedVar(tag.parent, valueLiteral) ? `${varLocal("return")}.mutate.` : ""}
2613
2615
  }
2614
2616
  } else if (attr.args) {
2615
2617
  this.#extractor.write('"').copy(name).write('": ');
2616
- if (typeof name !== "string" && this.#read(name).startsWith("on")) {
2618
+ if (this.#api !== RuntimeAPI.tags && typeof name !== "string" && this.#read(name).startsWith("on")) {
2617
2619
  const stringLiteralFirstArgMatch = this.#execAtIndex(
2618
2620
  REG_ATTR_ARG_LITERAL,
2619
2621
  attr.args.value.start
package/dist/index.mjs CHANGED
@@ -1957,7 +1957,7 @@ var ScriptExtractor = class {
1957
1957
  }
1958
1958
  #writeProgram(program) {
1959
1959
  this.#writeCommentPragmas(program);
1960
- const componentFileName = getComponentFilename(this.#filename);
1960
+ const componentFileName = this.#api !== RuntimeAPI.tags ? getComponentFilename(this.#filename) : void 0;
1961
1961
  const inputType = this.#getInputType(program);
1962
1962
  let componentClassBody;
1963
1963
  for (const node of program.static) {
@@ -2047,35 +2047,37 @@ var ScriptExtractor = class {
2047
2047
  );
2048
2048
  }
2049
2049
  }
2050
- if (isExternalComponentFile) {
2051
- if (this.#scriptLang === "ts" /* ts */) {
2052
- this.#extractor.write(
2053
- `import type Component from "${stripExt(
2054
- relativeImportPath(this.#filename, componentFileName)
2055
- )}";
2050
+ if (this.#api !== RuntimeAPI.tags) {
2051
+ if (isExternalComponentFile) {
2052
+ if (this.#scriptLang === "ts" /* ts */) {
2053
+ this.#extractor.write(
2054
+ `import type Component from "${stripExt(
2055
+ relativeImportPath(this.#filename, componentFileName)
2056
+ )}";
2056
2057
  `
2057
- );
2058
- } else {
2059
- this.#extractor.write(
2060
- `/** @typedef {import("${stripExt(
2061
- relativeImportPath(this.#filename, componentFileName)
2062
- )}") extends infer Component ? Component extends { default: infer Component } ? Component : Component : never} Component */
2058
+ );
2059
+ } else {
2060
+ this.#extractor.write(
2061
+ `/** @typedef {import("${stripExt(
2062
+ relativeImportPath(this.#filename, componentFileName)
2063
+ )}") extends infer Component ? Component extends { default: infer Component } ? Component : Component : never} Component */
2063
2064
  `
2064
- );
2065
- }
2066
- } else {
2067
- const body2 = componentClassBody || " {}";
2068
- if (this.#scriptLang === "ts" /* ts */) {
2069
- this.#extractor.write(
2070
- `abstract class Component${typeParamsStr} extends Marko.Component<Input${typeArgsStr}>`
2071
- ).copy(body2).write("\nexport { type Component }\n");
2065
+ );
2066
+ }
2072
2067
  } else {
2073
- this.#extractor.write(`/**${jsDocTemplateTagsStr}
2074
- * @extends {Marko.Component<Input${typeArgsStr}>}
2075
- * @abstract
2076
- */
2068
+ const body2 = componentClassBody || " {}";
2069
+ if (this.#scriptLang === "ts" /* ts */) {
2070
+ this.#extractor.write(
2071
+ `abstract class Component${typeParamsStr} extends Marko.Component<Input${typeArgsStr}>`
2072
+ ).copy(body2).write("\nexport { type Component }\n");
2073
+ } else {
2074
+ this.#extractor.write(`/**${jsDocTemplateTagsStr}
2075
+ * @extends {Marko.Component<Input${typeArgsStr}>}
2076
+ * @abstract
2077
+ */
2077
2078
  `);
2078
- this.#extractor.write(`export class Component extends Marko.Component`).copy(body2).write("\n");
2079
+ this.#extractor.write(`export class Component extends Marko.Component`).copy(body2).write("\n");
2080
+ }
2079
2081
  }
2080
2082
  }
2081
2083
  const didReturn = !!getReturnTag(program);
@@ -2095,16 +2097,16 @@ var ScriptExtractor = class {
2095
2097
  function ${templateName}() {
2096
2098
  `);
2097
2099
  }
2098
- this.#extractor.write(` const input = ${this.#getCastedType(`Input${typeArgsStr}`)};
2100
+ this.#extractor.write(` const input = ${this.#getCastedType(`Input${typeArgsStr}`)};${this.#api !== RuntimeAPI.tags ? `
2099
2101
  const component = ${this.#getCastedType(`Component${typeArgsStr}`)};
2100
2102
  const state = ${varShared("state")}(component);
2103
+ const out = ${varShared("out")};` : ""}
2101
2104
  const $signal = ${this.#getCastedType("AbortSignal")};
2102
2105
  const $global = ${varShared("getGlobal")}(
2103
2106
  // @ts-expect-error We expect the compiler to error because we are checking if the MarkoRun.Context is defined.
2104
2107
  (${varShared("error")}, ${this.#getCastedType("MarkoRun.Context")})
2105
2108
  );
2106
- const out = ${varShared("out")};
2107
- ${varShared("noop")}({ input, component, state, out, $global, $signal });
2109
+ ${varShared("noop")}({ ${this.#api !== RuntimeAPI.tags ? "component, state, out, " : ""}input, $global, $signal });
2108
2110
  `);
2109
2111
  const body = this.#processBody(program);
2110
2112
  if (body == null ? void 0 : body.content) {
@@ -2576,7 +2578,7 @@ ${isMutatedVar(tag.parent, valueLiteral) ? `${varLocal("return")}.mutate.` : ""}
2576
2578
  }
2577
2579
  } else if (attr.args) {
2578
2580
  this.#extractor.write('"').copy(name).write('": ');
2579
- if (typeof name !== "string" && this.#read(name).startsWith("on")) {
2581
+ if (this.#api !== RuntimeAPI.tags && typeof name !== "string" && this.#read(name).startsWith("on")) {
2580
2582
  const stringLiteralFirstArgMatch = this.#execAtIndex(
2581
2583
  REG_ATTR_ARG_LITERAL,
2582
2584
  attr.args.value.start
@@ -328,18 +328,19 @@ declare global {
328
328
  export function attrTagFor<Tag, Path extends readonly string[]>(
329
329
  tag: Tag,
330
330
  ...path: Path
331
- ): <AttrTag>(
332
- attrTags: Relate<
333
- AttrTag,
334
- [0] extends [1 & Tag]
335
- ? Marko.AttrTag<unknown>
336
- : Marko.Input<Tag> extends infer Input
337
- ? [0] extends [1 & Input]
338
- ? Marko.AttrTag<unknown>
339
- : AttrTagValue<Marko.Input<Tag>, Path>
340
- : Marko.AttrTag<unknown>
341
- >[],
342
- ) => AttrTag;
331
+ ): <
332
+ AttrTag extends [0] extends [1 & Tag]
333
+ ? Marko.AttrTag<unknown>
334
+ : Marko.Input<Tag> extends infer Input
335
+ ? [0] extends [1 & Input]
336
+ ? Marko.AttrTag<unknown>
337
+ : AttrTagValue<Marko.Input<Tag>, Path>
338
+ : Marko.AttrTag<unknown>,
339
+ >(
340
+ attrTags: AttrTag[],
341
+ ) => AttrTag extends Marko.AttrTag<infer Input>
342
+ ? Marko.AttrTag<Input>
343
+ : any;
343
344
 
344
345
  // TODO: this could be improved.
345
346
  // currently falls back to DefaultRenderer too eagerly.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@marko/language-tools",
3
3
  "description": "Marko Language Tools",
4
- "version": "2.5.11",
4
+ "version": "2.5.13",
5
5
  "bugs": "https://github.com/marko-js/language-server/issues/new?template=Bug_report.md",
6
6
  "peerDependencies": {
7
7
  "@marko/compiler": "^5.28.4"