@jk2908/solas 0.3.1 → 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.
Files changed (71) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/dist/cli/build.d.ts +7 -0
  3. package/dist/cli/build.js +183 -0
  4. package/dist/cli/dev.d.ts +4 -0
  5. package/dist/cli/dev.js +13 -0
  6. package/dist/cli/preview.d.ts +1 -0
  7. package/dist/cli/preview.js +47 -0
  8. package/dist/cli.js +4 -238
  9. package/dist/index.js +2 -0
  10. package/dist/internal/browser-router/link.d.ts +17 -0
  11. package/dist/internal/{navigation → browser-router}/link.js +22 -16
  12. package/dist/internal/browser-router/router.d.ts +184 -0
  13. package/dist/internal/{router/router-provider.js → browser-router/router.js} +81 -12
  14. package/dist/internal/{router → browser-router}/use-router.d.ts +1 -1
  15. package/dist/internal/browser-router/use-router.js +5 -0
  16. package/dist/internal/browser-router/use-search-params.d.ts +1 -0
  17. package/dist/internal/browser-router/use-search-params.js +15 -0
  18. package/dist/internal/build.js +2 -2
  19. package/dist/internal/codegen/types.d.ts +5 -0
  20. package/dist/internal/codegen/types.js +48 -0
  21. package/dist/internal/env/browser.js +6 -6
  22. package/dist/internal/env/flight.d.ts +29 -0
  23. package/dist/internal/env/flight.js +187 -0
  24. package/dist/internal/env/request-context.d.ts +1 -1
  25. package/dist/internal/env/rsc.d.ts +1 -1
  26. package/dist/internal/env/rsc.js +23 -28
  27. package/dist/internal/env/ssr.d.ts +2 -2
  28. package/dist/internal/env/ssr.js +27 -13
  29. package/dist/internal/env/utils.js +13 -1
  30. package/dist/internal/http-router/create-http-router.d.ts +6 -0
  31. package/dist/internal/{router/create-router.js → http-router/create-http-router.js} +5 -5
  32. package/dist/internal/{router → http-router}/router.d.ts +9 -9
  33. package/dist/internal/{router → http-router}/router.js +20 -19
  34. package/dist/internal/{router → http-router}/utils.d.ts +11 -3
  35. package/dist/internal/{router → http-router}/utils.js +9 -1
  36. package/dist/internal/metadata.js +10 -10
  37. package/dist/internal/prerender.d.ts +4 -9
  38. package/dist/internal/prerender.js +6 -23
  39. package/dist/internal/render/head.js +1 -1
  40. package/dist/internal/render/tree.d.ts +1 -1
  41. package/dist/internal/render/tree.js +17 -13
  42. package/dist/internal/{router/resolver.d.ts → resolver.d.ts} +41 -41
  43. package/dist/internal/{router/resolver.js → resolver.js} +7 -7
  44. package/dist/internal/server/actions.js +1 -1
  45. package/dist/internal/server/cookies.d.ts +3 -2
  46. package/dist/internal/server/cookies.js +4 -3
  47. package/dist/internal/server/dynamic.d.ts +1 -3
  48. package/dist/internal/server/dynamic.js +3 -11
  49. package/dist/internal/server/headers.d.ts +2 -2
  50. package/dist/internal/server/headers.js +3 -3
  51. package/dist/internal/server/url.d.ts +2 -2
  52. package/dist/internal/server/url.js +3 -3
  53. package/dist/navigation.d.ts +0 -2
  54. package/dist/navigation.js +0 -2
  55. package/dist/router.d.ts +3 -4
  56. package/dist/router.js +3 -4
  57. package/dist/solas.d.ts +3 -1
  58. package/dist/solas.js +1 -1
  59. package/dist/types.d.ts +15 -7
  60. package/dist/utils/logger.js +1 -1
  61. package/package.json +2 -7
  62. package/dist/internal/navigation/link.d.ts +0 -13
  63. package/dist/internal/navigation/use-search-params.d.ts +0 -11
  64. package/dist/internal/navigation/use-search-params.js +0 -34
  65. package/dist/internal/router/create-router.d.ts +0 -6
  66. package/dist/internal/router/router-context.d.ts +0 -15
  67. package/dist/internal/router/router-context.js +0 -8
  68. package/dist/internal/router/router-provider.d.ts +0 -10
  69. package/dist/internal/router/use-router.js +0 -5
  70. /package/dist/internal/{router/prefetcher.d.ts → prefetcher.d.ts} +0 -0
  71. /package/dist/internal/{router/prefetcher.js → prefetcher.js} +0 -0
@@ -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,8 +0,0 @@
1
- 'use client';
2
- import { createContext } from 'react';
3
- export const RouterContext = createContext({
4
- go: async () => '',
5
- prefetch: () => { },
6
- isNavigating: false,
7
- url: {},
8
- });
@@ -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;
@@ -1,5 +0,0 @@
1
- import { use } from 'react';
2
- import { RouterContext } from './router-context.js';
3
- export function useRouter() {
4
- return use(RouterContext);
5
- }