@kosmojs/lib 0.5.0 → 0.6.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/pkg/paths.d.ts CHANGED
@@ -1,11 +1,9 @@
1
- import { type SourceFolder } from "@kosmojs/core";
1
+ import { type ProjectSettings, type SourceFolder } from "@kosmojs/core";
2
2
  type Options = {
3
3
  origin: "src" | "lib";
4
4
  };
5
5
  type CreateImport = Record<"src" | "api" | "entry" | "pages" | "lib" | "libCore" | "libApi" | "libEntry", (a: Array<string>, o: Options) => string>;
6
- export declare const pathResolver: (sourceFolder: Omit<SourceFolder, "root"> & {
7
- root?: string | undefined;
8
- }) => {
6
+ export declare const pathResolver: ({ root, distDir }: ProjectSettings, { name }: SourceFolder) => {
9
7
  createPath: Record<"src" | "api" | "pages" | "entry" | "lib" | "libCore" | "libApi" | "libEntry" | "libPages" | "distDir", (...a: Array<string>) => string>;
10
8
  createImport: CreateImport;
11
9
  createImportHelpers: (o: Options) => {
package/pkg/ports.d.ts ADDED
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Probe whether a single TCP port is free on given host.
3
+ *
4
+ * Resolves `true` only after the probe server has fully closed,
5
+ * so the caller can immediately rebind without racing the OS.
6
+ * `unref()` keeps a dangling probe from holding the event loop open.
7
+ * */
8
+ export declare const isPortFree: (host: string, port: number, timeoutMs?: number) => Promise<boolean>;
9
+ /**
10
+ * Find `count` consecutive free ports by probing random offsets within minPort..maxPort.
11
+ * Each attempt picks a uniformly random start, probes the whole window,
12
+ * and returns it only if every port is free.
13
+ * Failed attempts are cheap because only the window is probed - no full-range scan.
14
+ * */
15
+ export declare const findFreePortRange: (host: string, count: number, { minPort, maxPort, attempts, }?: {
16
+ minPort?: number;
17
+ maxPort?: number;
18
+ attempts?: number;
19
+ }) => Promise<Array<number>>;
@@ -1,4 +1,4 @@
1
- import { type ResolvedEntry, type RouteEntry, type SourceFolder } from "@kosmojs/core";
1
+ import { type ProjectSettings, type ResolvedEntry, type RouteEntry, type SourceFolder } from "@kosmojs/core";
2
2
  export type ResolverSignature = {
3
3
  name: string;
4
4
  handler: (updatedFile?: string) => Promise<ResolvedEntry>;
@@ -11,13 +11,13 @@ export declare const PAGE_INDEX_BASENAME = "index";
11
11
  export declare const PAGE_INDEX_PATTERN = "index.{tsx,vue,svelte,mdx,md}";
12
12
  export declare const PAGE_LAYOUT_BASENAME = "layout";
13
13
  export declare const PAGE_LAYOUT_PATTERN = "layout.{tsx,vue,svelte,mdx}";
14
- export declare const scanRoutes: (sourceFolder: SourceFolder) => Promise<string[]>;
15
- export declare const isRouteFile: (file: string, sourceFolder: SourceFolder) => [folder: string, file: string] | false;
14
+ export declare const scanRoutes: (projectSettings: ProjectSettings, sourceFolder: SourceFolder) => Promise<string[]>;
15
+ export declare const isRouteFile: (projectSettings: ProjectSettings, sourceFolder: SourceFolder, file: string) => [folder: string, file: string] | false;
16
16
  export declare const isApiRoute: (file: string) => boolean;
17
17
  export declare const isApiUse: (file: string) => boolean;
18
18
  export declare const isPageRoute: (file: string) => boolean;
19
19
  export declare const isPageLayout: (file: string) => boolean;
20
- export declare const createRouteEntry: (fileFullpath: string, sourceFolder: SourceFolder) => RouteEntry | undefined;
20
+ export declare const createRouteEntry: (projectSettings: ProjectSettings, sourceFolder: SourceFolder, fileFullpath: string) => RouteEntry | undefined;
21
21
  /**
22
22
  * Compare two route entries for registration order.
23
23
  *
@@ -1,9 +1,9 @@
1
- import { type RouteResolverCacheFactory, type SourceFolder } from "@kosmojs/core";
1
+ import { type ProjectSettings, type RouteResolverCacheFactory, type SourceFolder } from "@kosmojs/core";
2
2
  import { type ResolverSignature } from "./base";
3
3
  export * from "./base";
4
4
  export * from "./nesting";
5
5
  export * from "./paths";
6
- export declare const routesFactory: (sourceFolder: SourceFolder, cacheFactory?: RouteResolverCacheFactory) => Promise<{
6
+ export declare const routesFactory: (projectSettings: ProjectSettings, sourceFolder: SourceFolder, cacheFactory?: RouteResolverCacheFactory) => Promise<{
7
7
  resolvers: Map<string, ResolverSignature>;
8
8
  resolversFactory: (routeFiles: Array<string>) => Map<string, ResolverSignature>;
9
9
  }>;
@@ -1,3 +1,3 @@
1
- import { type RouteEntry, type RouteResolverCacheFactory, type SourceFolder } from "@kosmojs/core";
1
+ import { type ProjectSettings, type RouteEntry, type RouteResolverCacheFactory, type SourceFolder } from "@kosmojs/core";
2
2
  import type { ResolverSignature } from "./base";
3
- export declare const resolverFactory: (sourceFolder: SourceFolder, cacheFactory?: RouteResolverCacheFactory) => Record<"pageLayoutResolver" | "pageRouteResolver" | "apiUseResolver" | "apiRouteResolver", (entry: RouteEntry) => ResolverSignature>;
3
+ export declare const resolverFactory: (projectSettings: ProjectSettings, sourceFolder: SourceFolder, cacheFactory?: RouteResolverCacheFactory) => Record<"pageLayoutResolver" | "pageRouteResolver" | "apiUseResolver" | "apiRouteResolver", (entry: RouteEntry) => ResolverSignature>;
@@ -0,0 +1,65 @@
1
+ export declare const generateTsconfig: ({ dependencies, devDependencies, }: Record<"dependencies" | "devDependencies", Record<string, string>>, sourceFolder?: string) => {
2
+ include: string[];
3
+ compilerOptions: {
4
+ moduleResolution: string;
5
+ module: string;
6
+ target: string;
7
+ strict: boolean;
8
+ exactOptionalPropertyTypes: boolean;
9
+ noImplicitAny: boolean;
10
+ noImplicitThis: boolean;
11
+ noImplicitOverride: boolean;
12
+ noImplicitReturns: boolean;
13
+ noUnusedLocals: boolean;
14
+ noUnusedParameters: boolean;
15
+ allowArbitraryExtensions: boolean;
16
+ allowImportingTsExtensions: boolean;
17
+ allowUnreachableCode: boolean;
18
+ allowUnusedLabels: boolean;
19
+ useUnknownInCatchVariables: boolean;
20
+ noFallthroughCasesInSwitch: boolean;
21
+ noUncheckedSideEffectImports: boolean;
22
+ resolveJsonModule: boolean;
23
+ esModuleInterop: boolean;
24
+ verbatimModuleSyntax: boolean;
25
+ skipLibCheck: boolean;
26
+ noEmit: boolean;
27
+ types: string[];
28
+ paths: {
29
+ [x: string]: string[];
30
+ };
31
+ };
32
+ exclude?: never;
33
+ } | {
34
+ include?: never;
35
+ exclude: string[];
36
+ compilerOptions: {
37
+ types: string[];
38
+ moduleResolution: string;
39
+ module: string;
40
+ target: string;
41
+ strict: boolean;
42
+ exactOptionalPropertyTypes: boolean;
43
+ noImplicitAny: boolean;
44
+ noImplicitThis: boolean;
45
+ noImplicitOverride: boolean;
46
+ noImplicitReturns: boolean;
47
+ noUnusedLocals: boolean;
48
+ noUnusedParameters: boolean;
49
+ allowArbitraryExtensions: boolean;
50
+ allowImportingTsExtensions: boolean;
51
+ allowUnreachableCode: boolean;
52
+ allowUnusedLabels: boolean;
53
+ useUnknownInCatchVariables: boolean;
54
+ noFallthroughCasesInSwitch: boolean;
55
+ noUncheckedSideEffectImports: boolean;
56
+ resolveJsonModule: boolean;
57
+ esModuleInterop: boolean;
58
+ verbatimModuleSyntax: boolean;
59
+ skipLibCheck: boolean;
60
+ noEmit: boolean;
61
+ paths: {
62
+ [x: string]: string[];
63
+ };
64
+ };
65
+ };
package/pkg/vite.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Plugin } from "vite";
2
- import { type ProjectSettings, type SourceFolder } from "@kosmojs/core";
2
+ import type { ChassisCommand, ProjectSettings, SourceFolder } from "@kosmojs/core";
3
3
  /**
4
4
  * Resolves Kosmo's generated import prefixes to absolute file paths.
5
5
  *
@@ -52,7 +52,7 @@ import { type ProjectSettings, type SourceFolder } from "@kosmojs/core";
52
52
  * tsconfig generator uses, so alias resolution here can never drift from the
53
53
  * paths that were written into the generated tsconfig.
54
54
  * */
55
- export declare const tsconfigPaths: (sourceFolder: SourceFolder) => Plugin;
55
+ export declare const tsconfigPaths: (projectSettings: ProjectSettings, sourceFolder: SourceFolder) => Plugin;
56
56
  declare const nodePrefix: () => Plugin;
57
57
  /**
58
58
  * Resolves the CSR/SSR variant of env-sensitive modules.
@@ -68,13 +68,14 @@ declare const nodePrefix: () => Plugin;
68
68
  *
69
69
  * Generators declare their modules via `factory.virtualModules()`.
70
70
  * */
71
- export declare const virtualModules: (sourceFolder: SourceFolder, { kind, command, }: {
71
+ export declare const virtualModules: (projectSettings: ProjectSettings, sourceFolder: SourceFolder, { kind, command }: {
72
72
  kind: "csr" | "ssr";
73
- command: ProjectSettings["command"];
73
+ command: ChassisCommand;
74
74
  }) => Plugin;
75
75
  export declare const vitePlugins: {
76
76
  tsconfigPaths: typeof tsconfigPaths;
77
77
  nodePrefix: typeof nodePrefix;
78
78
  virtualModules: typeof virtualModules;
79
79
  };
80
+ export declare const cacheDir: ({ root }: ProjectSettings, { name }: SourceFolder, target: `frontend:${ChassisCommand}` | `backend:${ChassisCommand}` | "sidecar") => string;
80
81
  export {};