react-lib-tools 0.0.10 → 0.0.12
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/GettingStartedRoute-Da-KZIf6.cjs +2 -0
- package/dist/GettingStartedRoute-Da-KZIf6.cjs.map +1 -0
- package/dist/GettingStartedRoute-n1iZy0On.js +38 -0
- package/dist/GettingStartedRoute-n1iZy0On.js.map +1 -0
- package/dist/PageNotFound-BbBqPkkF.js +24 -0
- package/dist/PageNotFound-BbBqPkkF.js.map +1 -0
- package/dist/PageNotFound-BhQMB2FT.cjs +2 -0
- package/dist/PageNotFound-BhQMB2FT.cjs.map +1 -0
- package/dist/SupportRoute-CmcE6ZZa.cjs +2 -0
- package/dist/SupportRoute-CmcE6ZZa.cjs.map +1 -0
- package/dist/SupportRoute-DuPMzYIe.js +44 -0
- package/dist/SupportRoute-DuPMzYIe.js.map +1 -0
- package/dist/index-BiL6y7tb.cjs +8 -0
- package/dist/index-BiL6y7tb.cjs.map +1 -0
- package/dist/index-CUStiGoe.js +9403 -0
- package/dist/index-CUStiGoe.js.map +1 -0
- package/dist/react-lib-tools.cjs +1 -7
- package/dist/react-lib-tools.cjs.map +1 -1
- package/dist/react-lib-tools.d.ts +28 -1
- package/dist/react-lib-tools.js +25 -9385
- package/dist/react-lib-tools.js.map +1 -1
- package/package.json +1 -1
- package/scripts/compile-docs.ts +16 -9
- package/scripts/compile-examples.ts +4 -2
- package/scripts/utils/docs/compileComponents.ts +3 -1
- package/scripts/utils/docs/compileImperativeHandles.ts +8 -5
- package/scripts/utils/syntax-highlight.ts +7 -1
- package/styles.css +1 -0
package/package.json
CHANGED
package/scripts/compile-docs.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AnalyserOptions } from "@ts-ast-parser/core";
|
|
1
2
|
import { compileComponents } from "./utils/docs/compileComponents.ts";
|
|
2
3
|
import { compileImperativeHandles } from "./utils/docs/compileImperativeHandles.ts";
|
|
3
4
|
import type { CompilerOptions } from "typescript";
|
|
@@ -10,19 +11,25 @@ import {
|
|
|
10
11
|
} from "typescript";
|
|
11
12
|
|
|
12
13
|
export async function compileDocs({
|
|
13
|
-
|
|
14
|
-
componentNames,
|
|
15
|
-
imperativeHandleNames,
|
|
14
|
+
analyserOptions: analyserOptionsParam,
|
|
15
|
+
componentNames = [],
|
|
16
|
+
imperativeHandleNames = [],
|
|
16
17
|
outputDirName = "docs"
|
|
17
18
|
}: {
|
|
18
|
-
|
|
19
|
-
componentNames
|
|
20
|
-
imperativeHandleNames
|
|
19
|
+
analyserOptions?: Partial<AnalyserOptions>;
|
|
20
|
+
componentNames?: string[] | undefined;
|
|
21
|
+
imperativeHandleNames?: string[] | undefined;
|
|
21
22
|
outputDirName?: string | undefined;
|
|
22
23
|
}) {
|
|
23
|
-
const compilerOptions = {
|
|
24
|
+
const compilerOptions: Partial<CompilerOptions> = {
|
|
24
25
|
...defaultCompilerOptions,
|
|
25
|
-
...
|
|
26
|
+
...(analyserOptionsParam?.compilerOptions as CompilerOptions)
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const analyserOptions: Partial<AnalyserOptions> = {
|
|
30
|
+
...analyserOptionsParam,
|
|
31
|
+
compilerOptions,
|
|
32
|
+
include: ["lib"]
|
|
26
33
|
};
|
|
27
34
|
|
|
28
35
|
await compileComponents({
|
|
@@ -32,7 +39,7 @@ export async function compileDocs({
|
|
|
32
39
|
});
|
|
33
40
|
|
|
34
41
|
await compileImperativeHandles({
|
|
35
|
-
|
|
42
|
+
analyserOptions,
|
|
36
43
|
names: imperativeHandleNames,
|
|
37
44
|
outputDirName
|
|
38
45
|
});
|
|
@@ -5,7 +5,7 @@ import { syntaxHighlight } from "./utils/syntax-highlight.ts";
|
|
|
5
5
|
import { trimExcludedText } from "./utils/examples/trimExcludedText.ts";
|
|
6
6
|
|
|
7
7
|
export async function compileExamples({
|
|
8
|
-
fileExtensions = [".html", ".ts", ".tsx"],
|
|
8
|
+
fileExtensions = [".css", ".html", ".ts", ".tsx"],
|
|
9
9
|
inputPath = ["src", "routes"],
|
|
10
10
|
outputDirName = "examples"
|
|
11
11
|
}: {
|
|
@@ -45,7 +45,9 @@ export async function compileExamples({
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
let html;
|
|
48
|
-
if (file.endsWith(".
|
|
48
|
+
if (file.endsWith(".css")) {
|
|
49
|
+
html = await syntaxHighlight(rawText, "CSS");
|
|
50
|
+
} else if (file.endsWith(".html")) {
|
|
49
51
|
html = await syntaxHighlight(rawText, "HTML");
|
|
50
52
|
} else if (file.endsWith(".js") || file.endsWith(".jsx")) {
|
|
51
53
|
html = await syntaxHighlight(
|
|
@@ -26,7 +26,9 @@ export async function compileComponents({
|
|
|
26
26
|
const { files, outputDir } = await initialize({
|
|
27
27
|
fileExtensions: [".ts", ".tsx"],
|
|
28
28
|
fileFilter: (file) =>
|
|
29
|
-
componentNames.some((componentName) =>
|
|
29
|
+
componentNames.some((componentName) =>
|
|
30
|
+
file.includes(`${componentName}.ts`)
|
|
31
|
+
),
|
|
30
32
|
inputPath: ["lib", "components"],
|
|
31
33
|
outputDirName
|
|
32
34
|
});
|
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
parseFromProject,
|
|
3
|
+
type AnalyserOptions,
|
|
4
|
+
type InterfaceNode
|
|
5
|
+
} from "@ts-ast-parser/core";
|
|
2
6
|
import { join } from "node:path";
|
|
3
7
|
import { cwd } from "node:process";
|
|
4
|
-
import type { CompilerOptions } from "typescript";
|
|
5
8
|
import { compileImperativeHandle } from "./compileImperativeHandle.ts";
|
|
6
9
|
|
|
7
10
|
export async function compileImperativeHandles({
|
|
8
|
-
|
|
11
|
+
analyserOptions,
|
|
9
12
|
names,
|
|
10
13
|
outputDirName
|
|
11
14
|
}: {
|
|
12
|
-
|
|
15
|
+
analyserOptions: Partial<AnalyserOptions>;
|
|
13
16
|
names: string[];
|
|
14
17
|
outputDirName: string;
|
|
15
18
|
}) {
|
|
16
19
|
const outputDir = join(cwd(), "public", "generated", outputDirName);
|
|
17
20
|
|
|
18
|
-
const result = await parseFromProject(
|
|
21
|
+
const result = await parseFromProject(analyserOptions);
|
|
19
22
|
const reflectedModules = result.project?.getModules() ?? [];
|
|
20
23
|
|
|
21
24
|
const nodes: {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { cssLanguage } from "@codemirror/lang-css";
|
|
1
2
|
import { htmlLanguage } from "@codemirror/lang-html";
|
|
2
3
|
import {
|
|
3
4
|
jsxLanguage,
|
|
@@ -16,7 +17,7 @@ type Token = {
|
|
|
16
17
|
value: string;
|
|
17
18
|
};
|
|
18
19
|
|
|
19
|
-
export type Language = "HTML" | "JS" | "JSX" | "TS" | "TSX";
|
|
20
|
+
export type Language = "CSS" | "HTML" | "JS" | "JSX" | "TS" | "TSX";
|
|
20
21
|
|
|
21
22
|
type State = {
|
|
22
23
|
parsedTokens: Token[];
|
|
@@ -30,6 +31,11 @@ export async function syntaxHighlight(code: string, language: Language) {
|
|
|
30
31
|
let extension: LRLanguage;
|
|
31
32
|
let prettierParser: BuiltInParserName;
|
|
32
33
|
switch (language) {
|
|
34
|
+
case "CSS": {
|
|
35
|
+
extension = cssLanguage.configure({ dialect: "selfClosing" });
|
|
36
|
+
prettierParser = "css";
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
33
39
|
case "HTML": {
|
|
34
40
|
extension = htmlLanguage.configure({ dialect: "selfClosing" });
|
|
35
41
|
prettierParser = "html";
|