@marko/language-tools 1.0.1 → 1.0.3
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 +24 -9
- package/dist/index.mjs +24 -9
- package/marko.internal.d.ts +6 -8
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -1748,6 +1748,7 @@ var ScriptExtractor = class {
|
|
|
1748
1748
|
let typeParamsStr = "";
|
|
1749
1749
|
let typeArgsStr = "";
|
|
1750
1750
|
let jsDocTemplateTagsStr = "";
|
|
1751
|
+
const isExternalComponentFile = !componentClassBody && componentFileName !== void 0;
|
|
1751
1752
|
if (inputType) {
|
|
1752
1753
|
if (inputType.typeParameters) {
|
|
1753
1754
|
let sep = SEP_EMPTY;
|
|
@@ -1767,26 +1768,34 @@ var ScriptExtractor = class {
|
|
|
1767
1768
|
}
|
|
1768
1769
|
}
|
|
1769
1770
|
} else {
|
|
1770
|
-
const hasComponent = componentClassBody || componentFileName;
|
|
1771
1771
|
if (this.#scriptLang === "ts" /* ts */) {
|
|
1772
1772
|
this.#extractor.write(
|
|
1773
|
-
|
|
1773
|
+
isExternalComponentFile ? "export type Input = Component['input'];\n" : `export interface Input {}
|
|
1774
1774
|
`
|
|
1775
1775
|
);
|
|
1776
1776
|
} else {
|
|
1777
1777
|
this.#extractor.write(
|
|
1778
|
-
`/** @typedef {${
|
|
1778
|
+
`/** @typedef {${isExternalComponentFile ? "Component['input']" : "Record<string, unknown>"}} Input */
|
|
1779
1779
|
`
|
|
1780
1780
|
);
|
|
1781
1781
|
}
|
|
1782
1782
|
}
|
|
1783
|
-
if (
|
|
1784
|
-
this.#
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1783
|
+
if (isExternalComponentFile) {
|
|
1784
|
+
if (this.#scriptLang === "ts" /* ts */) {
|
|
1785
|
+
this.#extractor.write(
|
|
1786
|
+
`import type Component from "${stripExt(
|
|
1787
|
+
(0, import_relative_import_path.relativeImportPath)(this.#filename, componentFileName)
|
|
1788
|
+
)}";
|
|
1788
1789
|
`
|
|
1789
|
-
|
|
1790
|
+
);
|
|
1791
|
+
} else {
|
|
1792
|
+
this.#extractor.write(
|
|
1793
|
+
`/** @typedef {import("${stripExt(
|
|
1794
|
+
(0, import_relative_import_path.relativeImportPath)(this.#filename, componentFileName)
|
|
1795
|
+
)}").default} Component */
|
|
1796
|
+
`
|
|
1797
|
+
);
|
|
1798
|
+
}
|
|
1790
1799
|
} else {
|
|
1791
1800
|
const body2 = componentClassBody || " {}";
|
|
1792
1801
|
if (this.#scriptLang === "ts" /* ts */) {
|
|
@@ -2512,6 +2521,12 @@ const attrTags = ${varShared(
|
|
|
2512
2521
|
} else {
|
|
2513
2522
|
this.#extractor.write("}\n})()");
|
|
2514
2523
|
}
|
|
2524
|
+
this.#extractor.write(SEP_COMMA_NEW_LINE);
|
|
2525
|
+
}
|
|
2526
|
+
if (tag.type === 16 /* AttrTag */) {
|
|
2527
|
+
this.#extractor.write(
|
|
2528
|
+
`[Symbol.iterator]: ${varShared("any")}${SEP_COMMA_NEW_LINE}`
|
|
2529
|
+
);
|
|
2515
2530
|
}
|
|
2516
2531
|
if (!hasInput) {
|
|
2517
2532
|
this.#writeTagNameComment(tag);
|
package/dist/index.mjs
CHANGED
|
@@ -1715,6 +1715,7 @@ var ScriptExtractor = class {
|
|
|
1715
1715
|
let typeParamsStr = "";
|
|
1716
1716
|
let typeArgsStr = "";
|
|
1717
1717
|
let jsDocTemplateTagsStr = "";
|
|
1718
|
+
const isExternalComponentFile = !componentClassBody && componentFileName !== void 0;
|
|
1718
1719
|
if (inputType) {
|
|
1719
1720
|
if (inputType.typeParameters) {
|
|
1720
1721
|
let sep = SEP_EMPTY;
|
|
@@ -1734,26 +1735,34 @@ var ScriptExtractor = class {
|
|
|
1734
1735
|
}
|
|
1735
1736
|
}
|
|
1736
1737
|
} else {
|
|
1737
|
-
const hasComponent = componentClassBody || componentFileName;
|
|
1738
1738
|
if (this.#scriptLang === "ts" /* ts */) {
|
|
1739
1739
|
this.#extractor.write(
|
|
1740
|
-
|
|
1740
|
+
isExternalComponentFile ? "export type Input = Component['input'];\n" : `export interface Input {}
|
|
1741
1741
|
`
|
|
1742
1742
|
);
|
|
1743
1743
|
} else {
|
|
1744
1744
|
this.#extractor.write(
|
|
1745
|
-
`/** @typedef {${
|
|
1745
|
+
`/** @typedef {${isExternalComponentFile ? "Component['input']" : "Record<string, unknown>"}} Input */
|
|
1746
1746
|
`
|
|
1747
1747
|
);
|
|
1748
1748
|
}
|
|
1749
1749
|
}
|
|
1750
|
-
if (
|
|
1751
|
-
this.#
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1750
|
+
if (isExternalComponentFile) {
|
|
1751
|
+
if (this.#scriptLang === "ts" /* ts */) {
|
|
1752
|
+
this.#extractor.write(
|
|
1753
|
+
`import type Component from "${stripExt(
|
|
1754
|
+
relativeImportPath(this.#filename, componentFileName)
|
|
1755
|
+
)}";
|
|
1755
1756
|
`
|
|
1756
|
-
|
|
1757
|
+
);
|
|
1758
|
+
} else {
|
|
1759
|
+
this.#extractor.write(
|
|
1760
|
+
`/** @typedef {import("${stripExt(
|
|
1761
|
+
relativeImportPath(this.#filename, componentFileName)
|
|
1762
|
+
)}").default} Component */
|
|
1763
|
+
`
|
|
1764
|
+
);
|
|
1765
|
+
}
|
|
1757
1766
|
} else {
|
|
1758
1767
|
const body2 = componentClassBody || " {}";
|
|
1759
1768
|
if (this.#scriptLang === "ts" /* ts */) {
|
|
@@ -2479,6 +2488,12 @@ const attrTags = ${varShared(
|
|
|
2479
2488
|
} else {
|
|
2480
2489
|
this.#extractor.write("}\n})()");
|
|
2481
2490
|
}
|
|
2491
|
+
this.#extractor.write(SEP_COMMA_NEW_LINE);
|
|
2492
|
+
}
|
|
2493
|
+
if (tag.type === 16 /* AttrTag */) {
|
|
2494
|
+
this.#extractor.write(
|
|
2495
|
+
`[Symbol.iterator]: ${varShared("any")}${SEP_COMMA_NEW_LINE}`
|
|
2496
|
+
);
|
|
2482
2497
|
}
|
|
2483
2498
|
if (!hasInput) {
|
|
2484
2499
|
this.#writeTagNameComment(tag);
|
package/marko.internal.d.ts
CHANGED
|
@@ -393,22 +393,20 @@ type ComponentEventHandlers<Component extends Marko.Component> = {
|
|
|
393
393
|
>]: Component[K] extends (...args: any) => any ? Component[K] : never;
|
|
394
394
|
};
|
|
395
395
|
|
|
396
|
-
type FlatScopes<
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
396
|
+
type FlatScopes<Input extends object, Objects = Input> = Input[keyof Input &
|
|
397
|
+
(string | number)] extends infer Prop
|
|
398
|
+
? 0 extends 1 & Prop
|
|
399
|
+
? unknown
|
|
400
|
+
: Prop extends (...args: any) => { [Marko._.scope]: infer Scope }
|
|
401
401
|
? unknown extends Scope
|
|
402
402
|
? never
|
|
403
403
|
: Scope
|
|
404
|
-
: 0 extends 1 & Prop
|
|
405
|
-
? never
|
|
406
404
|
: Prop extends object
|
|
407
405
|
? Prop extends Extract<Objects, Prop>
|
|
408
406
|
? never
|
|
409
407
|
: FlatScopes<Prop, Objects | Prop>
|
|
410
408
|
: never
|
|
411
|
-
:
|
|
409
|
+
: unknown;
|
|
412
410
|
|
|
413
411
|
type MergeScopes<Scopes> = {
|
|
414
412
|
[K in Scopes extends Scopes ? keyof Scopes : never]: Scopes extends Scopes
|
package/package.json
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marko/language-tools",
|
|
3
3
|
"description": "Marko Language Tools",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.3",
|
|
5
5
|
"bugs": "https://github.com/marko-js/language-server/issues/new?template=Bug_report.md",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@babel/helper-validator-identifier": "^7.19.1",
|
|
8
|
-
"@babel/parser": "^7.21.
|
|
9
|
-
"htmljs-parser": "^5.4.
|
|
8
|
+
"@babel/parser": "^7.21.3",
|
|
9
|
+
"htmljs-parser": "^5.4.3",
|
|
10
10
|
"relative-import-path": "^1.0.0"
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
|
13
13
|
"@babel/code-frame": "^7.18.6",
|
|
14
|
-
"@marko/compiler": "^5.
|
|
14
|
+
"@marko/compiler": "^5.27.1",
|
|
15
15
|
"@types/babel__code-frame": "^7.0.3",
|
|
16
16
|
"@types/babel__helper-validator-identifier": "^7.15.0",
|
|
17
17
|
"@typescript/vfs": "^1.4.0",
|
|
18
|
-
"marko": "^5.
|
|
18
|
+
"marko": "^5.25.1",
|
|
19
19
|
"mitata": "^0.1.6",
|
|
20
|
-
"tsx": "^3.12.
|
|
20
|
+
"tsx": "^3.12.5"
|
|
21
21
|
},
|
|
22
22
|
"exports": {
|
|
23
23
|
".": {
|