@kosmojs/lib 0.0.26 → 0.0.28
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/package.json +11 -11
- package/pkg/ast.d.ts +3 -3
- package/pkg/generators.d.ts +2 -56
- package/pkg/index.d.ts +1 -2
- package/pkg/index.js +353 -246
- package/pkg/index.js.map +4 -4
- package/pkg/paths.d.ts +8 -6
- package/pkg/render.d.ts +6 -11
- package/pkg/routes/base.d.ts +12 -44
- package/pkg/routes/index.d.ts +2 -1
- package/pkg/routes/nesting.d.ts +1 -1
- package/pkg/routes/paths.d.ts +25 -0
- package/pkg/routes/resolve.d.ts +1 -1
- package/pkg/routes/templates.d.ts +2 -0
- package/pkg/typebox.d.ts +1 -1
- package/pkg/vite.d.ts +4 -0
- package/pkg/defaults.d.ts +0 -14
- package/pkg/types.d.ts +0 -314
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@kosmojs/lib",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.28",
|
|
5
5
|
"author": "Slee Woo",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"publishConfig": {
|
|
8
|
-
"access": "public"
|
|
9
|
-
},
|
|
10
7
|
"files": [
|
|
11
8
|
"pkg/*"
|
|
12
9
|
],
|
|
10
|
+
"imports": {
|
|
11
|
+
"#templates/*": "./src/templates/*"
|
|
12
|
+
},
|
|
13
13
|
"exports": {
|
|
14
14
|
".": {
|
|
15
15
|
"types": "./pkg/index.d.ts",
|
|
@@ -19,18 +19,18 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@topcli/spinner": "^4.2.1",
|
|
21
21
|
"crc": "^4.3.2",
|
|
22
|
-
"handlebars": "^4.7.
|
|
22
|
+
"handlebars": "^4.7.9",
|
|
23
23
|
"mime-types": "^3.0.2",
|
|
24
|
-
"path-to-regexp": "^8.
|
|
24
|
+
"path-to-regexp": "^8.4.2",
|
|
25
25
|
"picomatch": "^4.0.4",
|
|
26
|
-
"tfusion": "^0.0.
|
|
27
|
-
"
|
|
28
|
-
"
|
|
26
|
+
"tfusion": "^0.0.24",
|
|
27
|
+
"tinyglobby": "^0.2.16",
|
|
28
|
+
"ts-morph": "^28.0.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/mime-types": "^3.0.1",
|
|
32
|
-
"@types/picomatch": "^4.0.
|
|
33
|
-
"
|
|
32
|
+
"@types/picomatch": "^4.0.3",
|
|
33
|
+
"@kosmojs/core": "^0.0.28"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "esbuilder src/index.ts",
|
package/pkg/ast.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { flattener } from "tfusion";
|
|
2
2
|
import { type CallExpression, Project, type ProjectOptions, type SourceFile } from "ts-morph";
|
|
3
|
-
import { type
|
|
4
|
-
import
|
|
3
|
+
import { type ApiRoute, type SourceFolder, type TypeDeclaration, type ValidationDefinition } from "@kosmojs/core";
|
|
4
|
+
import { type HTTPMethod } from "@kosmojs/core/api";
|
|
5
5
|
type PathResolver = (path: string) => string;
|
|
6
6
|
export declare const astFactory: () => {
|
|
7
7
|
createProject: (opts?: ProjectOptions) => Project;
|
|
@@ -32,7 +32,7 @@ export declare const astFactory: () => {
|
|
|
32
32
|
validationDefinitions: ValidationDefinition[];
|
|
33
33
|
referencedFiles: string[] | undefined;
|
|
34
34
|
}>;
|
|
35
|
-
typeResolverFactory: ({ root }: SourceFolder) => {
|
|
35
|
+
typeResolverFactory: ({ root, name }: SourceFolder) => {
|
|
36
36
|
getSourceFile: (fileFullpath: string) => SourceFile;
|
|
37
37
|
refreshSourceFile: (fileFullpath: string) => Promise<void>;
|
|
38
38
|
literalTypesResolver: (literalTypes: string, options: Parameters<typeof flattener>[2]) => import("tfusion").ResolvedType[];
|
package/pkg/generators.d.ts
CHANGED
|
@@ -1,58 +1,4 @@
|
|
|
1
|
-
import type { DefineGenerator, DefineGeneratorFactory,
|
|
2
|
-
export declare const GENERATOR_META: unique symbol;
|
|
3
|
-
/**
|
|
4
|
-
* Define a generator with metadata stored internally.
|
|
5
|
-
*
|
|
6
|
-
* Metadata is attached to both the generator module and its instances,
|
|
7
|
-
* accessible via `getGeneratorMeta()`
|
|
8
|
-
*
|
|
9
|
-
* **User-facing API:**
|
|
10
|
-
* ```ts
|
|
11
|
-
* import { defineConfig, ssrGenerator } from "@kosmojs/dev";
|
|
12
|
-
*
|
|
13
|
-
* export default defineConfig({
|
|
14
|
-
* generators: [ssrGenerator()], // Clean instantiation
|
|
15
|
-
* });
|
|
16
|
-
* ```
|
|
17
|
-
*
|
|
18
|
-
* **Internal dev plugin usage:**
|
|
19
|
-
* ```ts
|
|
20
|
-
* import { getGeneratorMeta } from "@kosmojs/lib";
|
|
21
|
-
*
|
|
22
|
-
* // Read module metadata before instantiation
|
|
23
|
-
* const meta = getGeneratorMeta(ssrGenerator);
|
|
24
|
-
* console.log(meta?.slot); // "ssr"
|
|
25
|
-
*
|
|
26
|
-
* // Read instance metadata after instantiation
|
|
27
|
-
* for (const generator of config.generators) {
|
|
28
|
-
* const meta = getGeneratorMeta(generator);
|
|
29
|
-
* if (meta?.dependencies) {
|
|
30
|
-
* // Check/install dependencies
|
|
31
|
-
* }
|
|
32
|
-
* }
|
|
33
|
-
* ```
|
|
34
|
-
*
|
|
35
|
-
* @example Define a generator
|
|
36
|
-
* ```ts
|
|
37
|
-
* import { defineGenerator } from "@kosmojs/lib";
|
|
38
|
-
*
|
|
39
|
-
* export default defineGenerator(
|
|
40
|
-
* () => {
|
|
41
|
-
* return async (sourceFolder) => {
|
|
42
|
-
* // Generator logic
|
|
43
|
-
* };
|
|
44
|
-
* },
|
|
45
|
-
* {
|
|
46
|
-
* name: "Example",
|
|
47
|
-
* slot: "example",
|
|
48
|
-
* dependencies: {
|
|
49
|
-
* "some-package": "^1.0.0"
|
|
50
|
-
* }
|
|
51
|
-
* }
|
|
52
|
-
* );
|
|
53
|
-
* ```
|
|
54
|
-
* */
|
|
1
|
+
import type { DefineGenerator, DefineGeneratorFactory, GeneratorCustomTemplates } from "@kosmojs/core";
|
|
55
2
|
export declare const defineGenerator: DefineGenerator;
|
|
56
|
-
export declare const isGenerator: (fn: Function) => fn is Function & Record<typeof GENERATOR_META, unknown>;
|
|
57
|
-
export declare const getGeneratorMeta: (fn: Function) => GeneratorMeta | undefined;
|
|
58
3
|
export declare const defineGeneratorFactory: DefineGeneratorFactory;
|
|
4
|
+
export declare const createTemplateResolver: <T>(customTemplates: GeneratorCustomTemplates<T> | undefined, defaultTemplate: string) => (pattern: string, entry: T) => any;
|
package/pkg/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
export * from "./ast";
|
|
2
|
-
export * from "./defaults";
|
|
3
2
|
export * from "./generators";
|
|
4
3
|
export * from "./paths";
|
|
5
4
|
export * from "./render";
|
|
6
5
|
export * from "./routes";
|
|
7
6
|
export * from "./spinner";
|
|
8
7
|
export * from "./typebox";
|
|
9
|
-
export * from "./
|
|
8
|
+
export * from "./vite";
|