@marko/language-tools 2.5.18 → 2.5.20

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
@@ -2226,6 +2226,19 @@ ${varShared("noop")}(`);
2226
2226
  if (!WROTE_COMMENT.has(comment)) {
2227
2227
  if (this.#code.charAt(comment.start + 1) === "/") {
2228
2228
  this.#extractor.write("//").copy(comment.value).write("\n");
2229
+ } else if (this.#code.charAt(comment.start + 1) === "!") {
2230
+ this.#extractor.write("/*");
2231
+ let startIndex = comment.value.start;
2232
+ for (const { index } of this.#read(comment.value).matchAll(
2233
+ /\*\//g
2234
+ )) {
2235
+ this.#extractor.copy({
2236
+ start: startIndex,
2237
+ end: startIndex = comment.value.start + index + 1
2238
+ }).write("\\");
2239
+ }
2240
+ this.#extractor.copy({ start: startIndex, end: comment.value.end });
2241
+ this.#extractor.write("*/");
2229
2242
  } else {
2230
2243
  this.#extractor.write("/*").copy(comment.value).write("*/");
2231
2244
  }
@@ -3218,7 +3231,7 @@ ${isMutatedVar(tag.parent, valueLiteral) ? `${varLocal("return")}.mutate.` : ""}
3218
3231
  this.#writeAttrTagTree(nested2, `input["@${name}"]`, true);
3219
3232
  }
3220
3233
  }
3221
- this.#extractor.write(`})`);
3234
+ this.#extractor.write(`});`);
3222
3235
  }
3223
3236
  #getAttrTagTree(tag, attrTags) {
3224
3237
  if (!tag.hasAttrTags || !tag.body) return attrTags;
package/dist/index.mjs CHANGED
@@ -2189,6 +2189,19 @@ ${varShared("noop")}(`);
2189
2189
  if (!WROTE_COMMENT.has(comment)) {
2190
2190
  if (this.#code.charAt(comment.start + 1) === "/") {
2191
2191
  this.#extractor.write("//").copy(comment.value).write("\n");
2192
+ } else if (this.#code.charAt(comment.start + 1) === "!") {
2193
+ this.#extractor.write("/*");
2194
+ let startIndex = comment.value.start;
2195
+ for (const { index } of this.#read(comment.value).matchAll(
2196
+ /\*\//g
2197
+ )) {
2198
+ this.#extractor.copy({
2199
+ start: startIndex,
2200
+ end: startIndex = comment.value.start + index + 1
2201
+ }).write("\\");
2202
+ }
2203
+ this.#extractor.copy({ start: startIndex, end: comment.value.end });
2204
+ this.#extractor.write("*/");
2192
2205
  } else {
2193
2206
  this.#extractor.write("/*").copy(comment.value).write("*/");
2194
2207
  }
@@ -3181,7 +3194,7 @@ ${isMutatedVar(tag.parent, valueLiteral) ? `${varLocal("return")}.mutate.` : ""}
3181
3194
  this.#writeAttrTagTree(nested2, `input["@${name}"]`, true);
3182
3195
  }
3183
3196
  }
3184
- this.#extractor.write(`})`);
3197
+ this.#extractor.write(`});`);
3185
3198
  }
3186
3199
  #getAttrTagTree(tag, attrTags) {
3187
3200
  if (!tag.hasAttrTags || !tag.body) return attrTags;
@@ -158,11 +158,11 @@ declare global {
158
158
 
159
159
  export function forOfTag<
160
160
  Value extends Iterable,
161
- Item extends Value extends
162
- | readonly (infer Item)[]
163
- | Iterable<infer Item>
164
- ? Item
165
- : unknown,
161
+ Item extends [0] extends [1 & Value]
162
+ ? any
163
+ : Value extends readonly (infer Item)[] | Iterable<infer Item>
164
+ ? Item
165
+ : never,
166
166
  BodyContent extends Marko.Body<
167
167
  [item: Item, index: number, all: Value],
168
168
  void
@@ -222,19 +222,18 @@ declare global {
222
222
  ): ReturnAndScope<BodyContentScope<BodyContent>, void>;
223
223
 
224
224
  export function forOfAttrTag<
225
- Value extends Iterable<any> | readonly any[],
225
+ Value extends Iterable,
226
+ Item extends [0] extends [1 & Value]
227
+ ? any
228
+ : Value extends readonly (infer Item)[] | Iterable<infer Item>
229
+ ? Item
230
+ : never,
226
231
  const Return,
227
232
  >(
228
233
  input: {
229
234
  of: Value | false | void | null;
230
235
  },
231
- content: (
232
- value: Value extends readonly (infer Item)[] | Iterable<infer Item>
233
- ? Item
234
- : unknown,
235
- index: number,
236
- all: Value,
237
- ) => Return,
236
+ content: (value: Item, index: number, all: Value) => Return,
238
237
  ): {
239
238
  [Key in keyof Return]: Return[Key] extends
240
239
  | readonly (infer Item)[]
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.18",
4
+ "version": "2.5.20",
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"