@jk2908/solas 0.3.1 → 0.3.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/CHANGELOG.md +9 -0
- package/dist/cli/build.d.ts +7 -0
- package/dist/cli/build.js +183 -0
- package/dist/cli/dev.d.ts +4 -0
- package/dist/cli/dev.js +13 -0
- package/dist/cli/preview.d.ts +1 -0
- package/dist/cli/preview.js +47 -0
- package/dist/cli.js +4 -238
- package/dist/index.js +2 -0
- package/dist/internal/browser-router/link.d.ts +17 -0
- package/dist/internal/{navigation → browser-router}/link.js +22 -16
- package/dist/internal/browser-router/router.d.ts +184 -0
- package/dist/internal/{router/router-provider.js → browser-router/router.js} +81 -12
- package/dist/internal/{router → browser-router}/use-router.d.ts +1 -1
- package/dist/internal/browser-router/use-router.js +5 -0
- package/dist/internal/browser-router/use-search-params.d.ts +1 -0
- package/dist/internal/browser-router/use-search-params.js +15 -0
- package/dist/internal/build.js +2 -2
- package/dist/internal/codegen/types.d.ts +5 -0
- package/dist/internal/codegen/types.js +48 -0
- package/dist/internal/env/browser.js +6 -6
- package/dist/internal/env/flight.d.ts +29 -0
- package/dist/internal/env/flight.js +190 -0
- package/dist/internal/env/request-context.d.ts +1 -1
- package/dist/internal/env/rsc.d.ts +1 -1
- package/dist/internal/env/rsc.js +29 -33
- package/dist/internal/env/ssr.d.ts +2 -2
- package/dist/internal/env/ssr.js +27 -13
- package/dist/internal/env/utils.js +13 -1
- package/dist/internal/http-router/create-http-router.d.ts +6 -0
- package/dist/internal/{router/create-router.js → http-router/create-http-router.js} +5 -5
- package/dist/internal/{router → http-router}/router.d.ts +9 -9
- package/dist/internal/{router → http-router}/router.js +20 -19
- package/dist/internal/{router → http-router}/utils.d.ts +11 -3
- package/dist/internal/{router → http-router}/utils.js +9 -1
- package/dist/internal/metadata.js +10 -10
- package/dist/internal/navigation/http-exception.d.ts +6 -1
- package/dist/internal/navigation/http-exception.js +18 -1
- package/dist/internal/prerender.d.ts +4 -9
- package/dist/internal/prerender.js +6 -23
- package/dist/internal/render/head.js +1 -1
- package/dist/internal/render/tree.d.ts +3 -2
- package/dist/internal/render/tree.js +17 -13
- package/dist/internal/{router/resolver.d.ts → resolver.d.ts} +41 -41
- package/dist/internal/{router/resolver.js → resolver.js} +7 -7
- package/dist/internal/server/actions.js +1 -1
- package/dist/internal/server/cookies.d.ts +3 -2
- package/dist/internal/server/cookies.js +4 -3
- package/dist/internal/server/dynamic.d.ts +1 -3
- package/dist/internal/server/dynamic.js +3 -11
- package/dist/internal/server/headers.d.ts +2 -2
- package/dist/internal/server/headers.js +3 -3
- package/dist/internal/server/url.d.ts +2 -2
- package/dist/internal/server/url.js +3 -3
- package/dist/internal/ui/defaults/error.d.ts +2 -2
- package/dist/navigation.d.ts +0 -2
- package/dist/navigation.js +0 -2
- package/dist/router.d.ts +3 -4
- package/dist/router.js +3 -4
- package/dist/solas.d.ts +3 -1
- package/dist/solas.js +1 -1
- package/dist/types.d.ts +15 -7
- package/dist/utils/logger.js +1 -1
- package/package.json +2 -7
- package/dist/internal/navigation/link.d.ts +0 -13
- package/dist/internal/navigation/use-search-params.d.ts +0 -11
- package/dist/internal/navigation/use-search-params.js +0 -34
- package/dist/internal/router/create-router.d.ts +0 -6
- package/dist/internal/router/router-context.d.ts +0 -15
- package/dist/internal/router/router-context.js +0 -8
- package/dist/internal/router/router-provider.d.ts +0 -10
- package/dist/internal/router/use-router.js +0 -5
- /package/dist/internal/{router/prefetcher.d.ts → prefetcher.d.ts} +0 -0
- /package/dist/internal/{router/prefetcher.js → prefetcher.js} +0 -0
package/dist/types.d.ts
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
type BunRequest = Request & {
|
|
2
2
|
params?: Record<string, string | string[]>;
|
|
3
3
|
};
|
|
4
|
-
import { Solas } from './solas.js';
|
|
5
4
|
import { ExportReader } from './utils/export-reader.js';
|
|
6
5
|
import type { Build } from './internal/build.js';
|
|
6
|
+
import type { HttpRouter } from './internal/http-router/router.js';
|
|
7
7
|
import type { Metadata } from './internal/metadata.js';
|
|
8
8
|
import type { HttpException } from './internal/navigation/http-exception.js';
|
|
9
|
-
import
|
|
9
|
+
import { BrowserRouter } from './internal/browser-router/router.js';
|
|
10
|
+
import { Solas } from './solas.js';
|
|
10
11
|
export type LogLevel = (typeof Solas.Config.LOG_LEVELS)[number];
|
|
11
12
|
type PluginConfigBase = {
|
|
12
13
|
port?: number;
|
|
13
14
|
precompress?: boolean;
|
|
14
15
|
prerender?: Route.Prerender;
|
|
15
16
|
metadata?: Metadata.Item;
|
|
16
|
-
trailingSlash?:
|
|
17
|
+
trailingSlash?: (typeof Solas.Config.TRAILING_SLASH_MODES)[number];
|
|
17
18
|
readonly logger?: {
|
|
18
19
|
level?: LogLevel;
|
|
19
20
|
};
|
|
@@ -36,6 +37,13 @@ export type BuildContext = {
|
|
|
36
37
|
knownRoutes: Set<string>;
|
|
37
38
|
exportReader: ExportReader;
|
|
38
39
|
};
|
|
40
|
+
export type RequestMeta = {
|
|
41
|
+
error?: HttpException | Error;
|
|
42
|
+
action?: boolean;
|
|
43
|
+
match: HttpRouter.Match | null;
|
|
44
|
+
parsedFormData?: FormData | null;
|
|
45
|
+
url?: URL;
|
|
46
|
+
};
|
|
39
47
|
export type SolasRequest = Request & {};
|
|
40
48
|
export type Segment = {
|
|
41
49
|
__id: string;
|
|
@@ -68,6 +76,7 @@ export type Endpoint = {
|
|
|
68
76
|
middlewares: (string | null)[];
|
|
69
77
|
};
|
|
70
78
|
export type ManifestEntry = Segment | Endpoint;
|
|
79
|
+
export type ManifestEntryGroup = ManifestEntry | [ManifestEntry, ...ManifestEntry[]];
|
|
71
80
|
export type Manifest = Awaited<ReturnType<typeof Build.Finder.prototype.process>>['manifest'];
|
|
72
81
|
export type View<TProps> = React.ComponentType<TProps> | React.LazyExoticComponent<React.ComponentType<TProps>>;
|
|
73
82
|
export type StaticImport = Record<string, unknown>;
|
|
@@ -81,7 +90,7 @@ export type MapEntry = {
|
|
|
81
90
|
'404s'?: readonly (DynamicImport | null)[];
|
|
82
91
|
'500s'?: readonly (DynamicImport | null)[];
|
|
83
92
|
loaders?: readonly (DynamicImport | null)[];
|
|
84
|
-
middlewares?: readonly (
|
|
93
|
+
middlewares?: readonly (HttpRouter.Middleware | null)[];
|
|
85
94
|
endpoint?: (req?: BunRequest) => unknown;
|
|
86
95
|
};
|
|
87
96
|
export type ImportMap = Record<string, MapEntry>;
|
|
@@ -92,13 +101,12 @@ export type BuildManifest = {
|
|
|
92
101
|
prerenderRoutes: string[];
|
|
93
102
|
sitemapRoutes: string[];
|
|
94
103
|
precompress: boolean;
|
|
95
|
-
trailingSlash:
|
|
104
|
+
trailingSlash: (typeof Solas.Config.TRAILING_SLASH_MODES)[number];
|
|
96
105
|
url?: PluginConfig['url'];
|
|
97
106
|
};
|
|
98
107
|
export declare namespace Route {
|
|
99
|
-
type Metadata = Metadata.Item | ((input: Metadata.Input<
|
|
108
|
+
type Metadata = Metadata.Item | ((input: Metadata.Input<BrowserRouter.Params>) => Promise<Metadata.Item> | Metadata.Item);
|
|
100
109
|
type Prerender = (typeof Solas.Config.PRERENDER_MODES)[number];
|
|
101
|
-
type TrailingSlash = (typeof Solas.Config.TRAILING_SLASH_MODES)[number];
|
|
102
110
|
}
|
|
103
111
|
export type BoundaryError = Error & {
|
|
104
112
|
digest?: string;
|
package/dist/utils/logger.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jk2908/solas",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "A React Server Components meta-framework powered by Vite",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"framework",
|
|
@@ -71,10 +71,6 @@
|
|
|
71
71
|
"./error-boundary": {
|
|
72
72
|
"types": "./dist/error-boundary.d.ts",
|
|
73
73
|
"import": "./dist/error-boundary.js"
|
|
74
|
-
},
|
|
75
|
-
"./solas": {
|
|
76
|
-
"types": "./dist/solas.d.ts",
|
|
77
|
-
"import": "./dist/solas.js"
|
|
78
74
|
}
|
|
79
75
|
},
|
|
80
76
|
"scripts": {
|
|
@@ -89,8 +85,7 @@
|
|
|
89
85
|
},
|
|
90
86
|
"dependencies": {
|
|
91
87
|
"@vitejs/plugin-rsc": "^0.5.20",
|
|
92
|
-
"path-to-regexp": "^8.3.0"
|
|
93
|
-
"rsc-html-stream": "^0.0.7"
|
|
88
|
+
"path-to-regexp": "^8.3.0"
|
|
94
89
|
},
|
|
95
90
|
"devDependencies": {
|
|
96
91
|
"@prettier/plugin-oxc": "^0.1.3",
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
type Props = {
|
|
2
|
-
href: string;
|
|
3
|
-
prefetch?: 'intent' | 'hover' | 'none';
|
|
4
|
-
} & React.ComponentPropsWithRef<'a'>;
|
|
5
|
-
/**
|
|
6
|
-
* A link component that navigates to a given href
|
|
7
|
-
* @param href - the href to navigate to
|
|
8
|
-
* @param prefetch - when to prefetch the linked page, defaults to 'none'
|
|
9
|
-
* @param rest - other props to pass to the underlying anchor element
|
|
10
|
-
* @returns a link element that navigates to the given href
|
|
11
|
-
*/
|
|
12
|
-
export declare function Link({ children, href, prefetch, ...rest }: Props): import("react/jsx-runtime").JSX.Element;
|
|
13
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export type ReadonlySearchParams = Iterable<[string, string]> & {
|
|
2
|
-
entries(): IterableIterator<[string, string]>;
|
|
3
|
-
forEach(callbackfn: (value: string, key: string, parent: ReadonlySearchParams) => void, thisArg?: unknown): void;
|
|
4
|
-
get(name: string): string | null;
|
|
5
|
-
getAll(name: string): string[];
|
|
6
|
-
has(name: string, value?: string): boolean;
|
|
7
|
-
keys(): IterableIterator<string>;
|
|
8
|
-
toString(): string;
|
|
9
|
-
values(): IterableIterator<string>;
|
|
10
|
-
};
|
|
11
|
-
export declare function useSearchParams(): ReadonlySearchParams;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { useMemo, useSyncExternalStore } from 'react';
|
|
2
|
-
import { Solas } from '../../solas.js';
|
|
3
|
-
import { useRouter } from '../router/use-router.js';
|
|
4
|
-
function createReadonlySearchParams(search) {
|
|
5
|
-
const params = new URLSearchParams(search);
|
|
6
|
-
const readonlyParams = {
|
|
7
|
-
[Symbol.iterator]: () => params[Symbol.iterator](),
|
|
8
|
-
entries: () => params.entries(),
|
|
9
|
-
forEach: (callbackfn, thisArg) => {
|
|
10
|
-
params.forEach((value, key) => {
|
|
11
|
-
callbackfn.call(thisArg, value, key, readonlyParams);
|
|
12
|
-
});
|
|
13
|
-
},
|
|
14
|
-
get: name => params.get(name),
|
|
15
|
-
getAll: name => params.getAll(name),
|
|
16
|
-
has: (name, value) => params.has(name, value),
|
|
17
|
-
keys: () => params.keys(),
|
|
18
|
-
toString: () => params.toString(),
|
|
19
|
-
values: () => params.values(),
|
|
20
|
-
};
|
|
21
|
-
return readonlyParams;
|
|
22
|
-
}
|
|
23
|
-
export function useSearchParams() {
|
|
24
|
-
const { url } = useRouter();
|
|
25
|
-
const search = useSyncExternalStore(fn => {
|
|
26
|
-
window.addEventListener('popstate', fn);
|
|
27
|
-
window.addEventListener(Solas.Events.names.NAVIGATION, fn);
|
|
28
|
-
return () => {
|
|
29
|
-
window.removeEventListener('popstate', fn);
|
|
30
|
-
window.removeEventListener(Solas.Events.names.NAVIGATION, fn);
|
|
31
|
-
};
|
|
32
|
-
}, () => window.location.search, () => url?.search);
|
|
33
|
-
return useMemo(() => createReadonlySearchParams(search), [search]);
|
|
34
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { ImportMap, Manifest, PluginConfig, SolasRequest } from '../../types.js';
|
|
2
|
-
import { Router } from './router.js';
|
|
3
|
-
/**
|
|
4
|
-
* Create the application router from the generated manifest and import map
|
|
5
|
-
*/
|
|
6
|
-
export declare function createRouter(config: Pick<PluginConfig, 'precompress' | 'trailingSlash'>, manifest: Manifest, importMap: ImportMap, rsc: (req: SolasRequest) => Response | Promise<Response>): Router;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export declare namespace Navigation {
|
|
2
|
-
type GoOptions = {
|
|
3
|
-
replace?: boolean;
|
|
4
|
-
query?: Record<string, string | number | boolean>;
|
|
5
|
-
};
|
|
6
|
-
}
|
|
7
|
-
export declare const RouterContext: import("react").Context<{
|
|
8
|
-
go: (to: string, opts?: Navigation.GoOptions | undefined) => Promise<string>;
|
|
9
|
-
prefetch: (path: string) => void;
|
|
10
|
-
isNavigating: boolean;
|
|
11
|
-
url: {
|
|
12
|
-
pathname?: string | undefined;
|
|
13
|
-
search?: string | undefined;
|
|
14
|
-
};
|
|
15
|
-
}>;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { RSCPayload } from '../env/rsc.js';
|
|
2
|
-
export declare function RouterProvider({ children, setPayload, isNavigating, url }: {
|
|
3
|
-
children: React.ReactNode;
|
|
4
|
-
setPayload?: (payload: RSCPayload) => void;
|
|
5
|
-
isNavigating?: boolean;
|
|
6
|
-
url?: {
|
|
7
|
-
pathname?: string;
|
|
8
|
-
search?: string;
|
|
9
|
-
};
|
|
10
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
File without changes
|
|
File without changes
|