@marko/language-tools 2.4.1 → 2.4.2

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
@@ -2492,23 +2492,22 @@ const attrTags = ${varShared(
2492
2492
  }
2493
2493
  #writeTagInputObject(tag) {
2494
2494
  if (!tag.params) this.#writeComments(tag);
2495
- const body = this.#processBody(tag);
2496
- let writeInputObj = true;
2497
2495
  let hasInput = false;
2496
+ this.#extractor.write("{\n");
2498
2497
  if (tag.args) {
2499
2498
  hasInput = true;
2500
- this.#extractor.copy(tag.args.value);
2501
- if (body || tag.attrs || tag.shorthandId || tag.shorthandClassNames) {
2502
- this.#extractor.write(",\n{\n");
2503
- } else {
2504
- writeInputObj = false;
2505
- }
2506
- } else {
2507
- this.#extractor.write("{\n");
2499
+ this.#extractor.write("[").copy({
2500
+ start: tag.args.start,
2501
+ end: tag.args.start + 1
2502
+ }).write('"value"').copy({
2503
+ start: tag.args.end - 1,
2504
+ end: tag.args.end
2505
+ }).write(`]: ${varShared("tuple")}(`).copy(tag.args.value).write(")").write(",\n");
2508
2506
  }
2509
2507
  if (this.#writeAttrs(tag)) {
2510
2508
  hasInput = true;
2511
2509
  }
2510
+ const body = this.#processBody(tag);
2512
2511
  let hasRenderBody = false;
2513
2512
  if (body) {
2514
2513
  hasInput = true;
@@ -2554,9 +2553,7 @@ const attrTags = ${varShared(
2554
2553
  if (!hasInput) {
2555
2554
  this.#writeTagNameComment(tag);
2556
2555
  }
2557
- if (writeInputObj) {
2558
- this.#extractor.write("\n}");
2559
- }
2556
+ this.#extractor.write("\n}");
2560
2557
  }
2561
2558
  #writeObjectKeys(keys) {
2562
2559
  this.#extractor.write("{");
package/dist/index.mjs CHANGED
@@ -2456,23 +2456,22 @@ const attrTags = ${varShared(
2456
2456
  }
2457
2457
  #writeTagInputObject(tag) {
2458
2458
  if (!tag.params) this.#writeComments(tag);
2459
- const body = this.#processBody(tag);
2460
- let writeInputObj = true;
2461
2459
  let hasInput = false;
2460
+ this.#extractor.write("{\n");
2462
2461
  if (tag.args) {
2463
2462
  hasInput = true;
2464
- this.#extractor.copy(tag.args.value);
2465
- if (body || tag.attrs || tag.shorthandId || tag.shorthandClassNames) {
2466
- this.#extractor.write(",\n{\n");
2467
- } else {
2468
- writeInputObj = false;
2469
- }
2470
- } else {
2471
- this.#extractor.write("{\n");
2463
+ this.#extractor.write("[").copy({
2464
+ start: tag.args.start,
2465
+ end: tag.args.start + 1
2466
+ }).write('"value"').copy({
2467
+ start: tag.args.end - 1,
2468
+ end: tag.args.end
2469
+ }).write(`]: ${varShared("tuple")}(`).copy(tag.args.value).write(")").write(",\n");
2472
2470
  }
2473
2471
  if (this.#writeAttrs(tag)) {
2474
2472
  hasInput = true;
2475
2473
  }
2474
+ const body = this.#processBody(tag);
2476
2475
  let hasRenderBody = false;
2477
2476
  if (body) {
2478
2477
  hasInput = true;
@@ -2518,9 +2517,7 @@ const attrTags = ${varShared(
2518
2517
  if (!hasInput) {
2519
2518
  this.#writeTagNameComment(tag);
2520
2519
  }
2521
- if (writeInputObj) {
2522
- this.#extractor.write("\n}");
2523
- }
2520
+ this.#extractor.write("\n}");
2524
2521
  }
2525
2522
  #writeObjectKeys(keys) {
2526
2523
  this.#extractor.write("{");
@@ -310,10 +310,14 @@ declare global {
310
310
  ? NativeTagRenderer<Name>
311
311
  : [Name] extends [AnyMarkoBody]
312
312
  ? BodyRenderer<Name>
313
- : [Name] extends [
314
- { renderBody?: infer Name extends AnyMarkoBody },
315
- ]
316
- ? BodyRenderer<Name>
313
+ : [Name] extends [{ renderBody?: AnyMarkoBody }]
314
+ ? [Name["renderBody"]] extends [AnyMarkoBody]
315
+ ? BodyRenderer<Name["renderBody"]>
316
+ : BaseRenderer<
317
+ RenderBodyInput<
318
+ BodyParameters<Exclude<Name["renderBody"], void>>
319
+ >
320
+ >
317
321
  : DefaultRenderer;
318
322
 
319
323
  export type TemplateRenderer<Template> = Template extends {
@@ -345,8 +349,12 @@ declare global {
345
349
  export interface BodyRenderer<Body extends AnyMarkoBody> {
346
350
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint
347
351
  (): () => <__marko_internal_input extends unknown>(
348
- ...args: BodyParamsWithDefault<Body> &
349
- Relate<__marko_internal_input, BodyParamsWithDefault<Body>>
352
+ input: Marko.Directives &
353
+ RenderBodyInput<BodyParameters<Body>> &
354
+ Relate<
355
+ __marko_internal_input,
356
+ Marko.Directives & RenderBodyInput<BodyParameters<Body>>
357
+ >,
350
358
  ) => ReturnAndScope<
351
359
  Scopes<__marko_internal_input>,
352
360
  BodyReturnType<Body>
@@ -393,12 +401,15 @@ type ReturnAndScope<Scope, Return> = {
393
401
  scope: Scope;
394
402
  };
395
403
 
396
- type BodyParamsWithDefault<Body extends AnyMarkoBody> =
397
- Body extends Marko.Body<infer Params, any>
398
- ? Params extends []
399
- ? [input?: Record<string, never>]
400
- : Params
401
- : never;
404
+ type RenderBodyInput<Args extends readonly unknown[]> = Args extends {
405
+ length: infer Length;
406
+ }
407
+ ? number extends Length
408
+ ? { value?: Args }
409
+ : 0 extends Length
410
+ ? { value?: [] }
411
+ : { value: Args }
412
+ : never;
402
413
 
403
414
  type Scopes<Input> = [0] extends [1 & Input]
404
415
  ? never
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.4.1",
4
+ "version": "2.4.2",
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"