@jk2908/solas 0.3.0 → 0.3.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/CHANGELOG.md +12 -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/{navigation → browser-router}/use-search-params.js +1 -1
- package/dist/internal/build.js +2 -2
- package/dist/internal/codegen/config.js +17 -8
- package/dist/internal/codegen/environments.js +7 -7
- package/dist/internal/codegen/manifest.js +3 -3
- package/dist/internal/codegen/maps.js +11 -15
- package/dist/internal/codegen/types.d.ts +5 -0
- package/dist/internal/codegen/types.js +48 -0
- package/dist/internal/codegen/utils.d.ts +10 -0
- package/dist/internal/codegen/utils.js +27 -2
- package/dist/internal/env/browser.js +6 -6
- package/dist/internal/env/flight.d.ts +29 -0
- package/dist/internal/env/flight.js +187 -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 +23 -28
- 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/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 +1 -1
- 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/navigation.d.ts +2 -4
- package/dist/navigation.js +2 -4
- 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/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/{navigation → browser-router}/use-search-params.d.ts +0 -0
- /package/dist/internal/{router/prefetcher.d.ts → prefetcher.d.ts} +0 -0
- /package/dist/internal/{router/prefetcher.js → prefetcher.js} +0 -0
|
@@ -3,7 +3,5 @@
|
|
|
3
3
|
* @description in prerender mode this suspends forever so the nearest Suspense
|
|
4
4
|
* boundary renders its fallback into the static shell. In request mode this
|
|
5
5
|
* resolves immediately
|
|
6
|
-
* @returns void during normal requests or prerender not in ppr mode
|
|
7
|
-
* @throws if called in prerender mode (the desired effect)
|
|
8
6
|
*/
|
|
9
|
-
export declare function dynamic(): void
|
|
7
|
+
export declare function dynamic(): Promise<void>;
|
|
@@ -1,22 +1,14 @@
|
|
|
1
|
-
import { Logger } from '../../utils/logger.js';
|
|
2
1
|
import { RequestContext } from '../env/request-context.js';
|
|
3
|
-
const logger = new Logger();
|
|
4
2
|
const NEVER = new Promise(() => { });
|
|
5
3
|
/**
|
|
6
4
|
* Declaratively mark render below this call as request-time only
|
|
7
5
|
* @description in prerender mode this suspends forever so the nearest Suspense
|
|
8
6
|
* boundary renders its fallback into the static shell. In request mode this
|
|
9
7
|
* resolves immediately
|
|
10
|
-
* @returns void during normal requests or prerender not in ppr mode
|
|
11
|
-
* @throws if called in prerender mode (the desired effect)
|
|
12
8
|
*/
|
|
13
|
-
export function dynamic() {
|
|
9
|
+
export async function dynamic() {
|
|
14
10
|
const { prerender } = RequestContext.use();
|
|
15
|
-
if (
|
|
11
|
+
if (prerender !== 'ppr')
|
|
16
12
|
return;
|
|
17
|
-
|
|
18
|
-
logger.warn('[dynamic]', "dynamic() was called but prerender mode is not 'ppr'. This means the component will be rendered at build time, which may not be what you intended");
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
throw NEVER;
|
|
13
|
+
await NEVER;
|
|
22
14
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Get the request headers as a read-only map
|
|
3
|
-
* @returns a read-only map of request headers
|
|
3
|
+
* @returns a Promise resolving to a read-only map of request headers
|
|
4
4
|
*/
|
|
5
|
-
export declare function headers(): ReadonlyMap<string, string
|
|
5
|
+
export declare function headers(): Promise<ReadonlyMap<string, string>>;
|
|
@@ -2,10 +2,10 @@ import { RequestContext } from '../env/request-context.js';
|
|
|
2
2
|
import { dynamic } from './dynamic.js';
|
|
3
3
|
/**
|
|
4
4
|
* Get the request headers as a read-only map
|
|
5
|
-
* @returns a read-only map of request headers
|
|
5
|
+
* @returns a Promise resolving to a read-only map of request headers
|
|
6
6
|
*/
|
|
7
|
-
export function headers() {
|
|
8
|
-
dynamic();
|
|
7
|
+
export async function headers() {
|
|
8
|
+
await dynamic();
|
|
9
9
|
const { req, cache } = RequestContext.use();
|
|
10
10
|
// use request cache if possible to avoid reconstructing the map
|
|
11
11
|
if (cache.headers)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Get the request url as a URL instance
|
|
3
|
-
* @returns a URL instance containing the request url
|
|
3
|
+
* @returns a Promise resolving to a URL instance containing the request url
|
|
4
4
|
*/
|
|
5
|
-
export declare function url(): URL
|
|
5
|
+
export declare function url(): Promise<URL>;
|
|
@@ -4,10 +4,10 @@ import { dynamic } from './dynamic.js';
|
|
|
4
4
|
const logger = new Logger();
|
|
5
5
|
/**
|
|
6
6
|
* Get the request url as a URL instance
|
|
7
|
-
* @returns a URL instance containing the request url
|
|
7
|
+
* @returns a Promise resolving to a URL instance containing the request url
|
|
8
8
|
*/
|
|
9
|
-
export function url() {
|
|
10
|
-
dynamic();
|
|
9
|
+
export async function url() {
|
|
10
|
+
await dynamic();
|
|
11
11
|
const { req, cache } = RequestContext.use();
|
|
12
12
|
// always return a clone so consumers can mutate (e.g. searchParams.set)
|
|
13
13
|
// without corrupting the cached instance shared across the request
|
package/dist/navigation.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
export { HttpException, abort, isHttpException, } from './internal/navigation/http-exception.js';
|
|
2
1
|
export { HttpExceptionBoundary } from './internal/navigation/http-exception-boundary.js';
|
|
3
|
-
export {
|
|
4
|
-
export { Redirect, isRedirect, redirect } from './internal/navigation/redirect.js';
|
|
2
|
+
export { HttpException, abort, isHttpException, } from './internal/navigation/http-exception.js';
|
|
5
3
|
export { RedirectBoundary } from './internal/navigation/redirect-boundary.js';
|
|
6
|
-
export {
|
|
4
|
+
export { Redirect, isRedirect, redirect } from './internal/navigation/redirect.js';
|
package/dist/navigation.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
export { HttpException, abort, isHttpException, } from './internal/navigation/http-exception.js';
|
|
2
1
|
export { HttpExceptionBoundary } from './internal/navigation/http-exception-boundary.js';
|
|
3
|
-
export {
|
|
4
|
-
export { Redirect, isRedirect, redirect } from './internal/navigation/redirect.js';
|
|
2
|
+
export { HttpException, abort, isHttpException, } from './internal/navigation/http-exception.js';
|
|
5
3
|
export { RedirectBoundary } from './internal/navigation/redirect-boundary.js';
|
|
6
|
-
export {
|
|
4
|
+
export { Redirect, isRedirect, redirect } from './internal/navigation/redirect.js';
|
package/dist/router.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export { useRouter } from './internal/router/use-router.js';
|
|
1
|
+
export { Link } from './internal/browser-router/link.js';
|
|
2
|
+
export { useRouter } from './internal/browser-router/use-router.js';
|
|
3
|
+
export { useSearchParams } from './internal/browser-router/use-search-params.js';
|
package/dist/router.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export { useRouter } from './internal/router/use-router.js';
|
|
1
|
+
export { Link } from './internal/browser-router/link.js';
|
|
2
|
+
export { useRouter } from './internal/browser-router/use-router.js';
|
|
3
|
+
export { useSearchParams } from './internal/browser-router/use-search-params.js';
|
package/dist/solas.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { PluginConfig } from './types.js';
|
|
2
2
|
export declare namespace Solas {
|
|
3
|
+
interface Routes {
|
|
4
|
+
}
|
|
3
5
|
namespace Config {
|
|
4
6
|
const NAME = "Solas";
|
|
5
7
|
const SLUG: string;
|
|
@@ -12,7 +14,7 @@ export declare namespace Solas {
|
|
|
12
14
|
const ENTRY_BROWSER = "entry.browser.tsx";
|
|
13
15
|
const ASSETS_DIR = "assets";
|
|
14
16
|
const $: unique symbol;
|
|
15
|
-
const
|
|
17
|
+
const REQUEST_META_KEY: string;
|
|
16
18
|
const LOG_LEVELS: readonly ["debug", "info", "warn", "error", "fatal"];
|
|
17
19
|
const PRERENDER_MODES: readonly ["full", "ppr", false];
|
|
18
20
|
const TRAILING_SLASH_MODES: readonly ["always", "never", "ignore"];
|
package/dist/solas.js
CHANGED
|
@@ -14,7 +14,7 @@ var Solas;
|
|
|
14
14
|
Config.ENTRY_BROWSER = 'entry.browser.tsx';
|
|
15
15
|
Config.ASSETS_DIR = 'assets';
|
|
16
16
|
Config.$ = Symbol(Config.SLUG);
|
|
17
|
-
Config.
|
|
17
|
+
Config.REQUEST_META_KEY = `__${Config.SLUG.toUpperCase()}__`;
|
|
18
18
|
Config.LOG_LEVELS = ['debug', 'info', 'warn', 'error', 'fatal'];
|
|
19
19
|
Config.PRERENDER_MODES = ['full', 'ppr', false];
|
|
20
20
|
Config.TRAILING_SLASH_MODES = ['always', 'never', 'ignore'];
|
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.2",
|
|
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,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
|
|
File without changes
|