@blocksdiy/blocks-client-sdk 1.24.2 → 1.25.1
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/README.md +32 -0
- package/dist/Navigation.d.ts +40 -0
- package/dist/Navigation.d.ts.map +1 -0
- package/dist/Navigation.js +66 -0
- package/dist/ReactClientSdk.d.ts +1 -0
- package/dist/ReactClientSdk.d.ts.map +1 -1
- package/dist/ReactClientSdk.jsx +1 -0
- package/dist/app/AppRoutes.d.ts +8 -0
- package/dist/app/AppRoutes.d.ts.map +1 -0
- package/dist/app/AppRoutes.jsx +222 -0
- package/dist/app/BlocksApp.d.ts +22 -0
- package/dist/app/BlocksApp.d.ts.map +1 -0
- package/dist/app/BlocksApp.jsx +73 -0
- package/dist/app/SdkProvider.d.ts +6 -0
- package/dist/app/SdkProvider.d.ts.map +1 -0
- package/dist/app/SdkProvider.jsx +45 -0
- package/dist/app/app-shape/bundle-shape.d.ts +54 -0
- package/dist/app/app-shape/bundle-shape.d.ts.map +1 -0
- package/dist/app/app-shape/bundle-shape.js +118 -0
- package/dist/app/app-shape/route-tree.d.ts +33 -0
- package/dist/app/app-shape/route-tree.d.ts.map +1 -0
- package/dist/app/app-shape/route-tree.jsx +137 -0
- package/dist/app/app-shape/use-app-shape.d.ts +13 -0
- package/dist/app/app-shape/use-app-shape.d.ts.map +1 -0
- package/dist/app/app-shape/use-app-shape.js +13 -0
- package/dist/app/dev-server/bootstrap.d.ts +8 -0
- package/dist/app/dev-server/bootstrap.d.ts.map +1 -0
- package/dist/app/dev-server/bootstrap.js +43 -0
- package/dist/app/dev-server/fonts.d.ts +8 -0
- package/dist/app/dev-server/fonts.d.ts.map +1 -0
- package/dist/app/dev-server/fonts.js +67 -0
- package/dist/app/hooks/use-scroll-to-top-on-page-change.d.ts +17 -0
- package/dist/app/hooks/use-scroll-to-top-on-page-change.d.ts.map +1 -0
- package/dist/app/hooks/use-scroll-to-top-on-page-change.js +55 -0
- package/dist/app/host.d.ts +106 -0
- package/dist/app/host.d.ts.map +1 -0
- package/dist/app/host.js +67 -0
- package/dist/app/index.d.ts +14 -0
- package/dist/app/index.d.ts.map +1 -0
- package/dist/app/index.js +14 -0
- package/dist/app/sign-in/Login.d.ts +8 -0
- package/dist/app/sign-in/Login.d.ts.map +1 -0
- package/dist/app/sign-in/Login.jsx +194 -0
- package/dist/app/sign-in/api.d.ts +13 -0
- package/dist/app/sign-in/api.d.ts.map +1 -0
- package/dist/app/sign-in/api.js +47 -0
- package/dist/app/sign-in/auth-url.d.ts +7 -0
- package/dist/app/sign-in/auth-url.d.ts.map +1 -0
- package/dist/app/sign-in/auth-url.js +6 -0
- package/dist/app/types.d.ts +36 -0
- package/dist/app/types.d.ts.map +1 -0
- package/dist/app/types.js +1 -0
- package/dist/app/ui/icons.d.ts +12 -0
- package/dist/app/ui/icons.d.ts.map +1 -0
- package/dist/app/ui/icons.jsx +32 -0
- package/dist/app/ui/ui-styles.d.ts +15 -0
- package/dist/app/ui/ui-styles.d.ts.map +1 -0
- package/dist/app/ui/ui-styles.js +458 -0
- package/dist/dev-config.d.ts +15 -0
- package/dist/dev-config.d.ts.map +1 -0
- package/dist/dev-config.js +9 -0
- package/package.json +22 -6
package/README.md
CHANGED
|
@@ -1 +1,33 @@
|
|
|
1
1
|
# blocks-client-sdk
|
|
2
|
+
|
|
3
|
+
`@blocksdiy/blocks-client-sdk`: what a Blocks app uses to work with the platform, wherever the app runs (Blocks' hosting, `pnpm dev`, the builder's sandbox, or a host of your own).
|
|
4
|
+
|
|
5
|
+
| Entry | What it holds |
|
|
6
|
+
| ---------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
|
|
7
|
+
| `@blocksdiy/blocks-client-sdk/clientSdk` | `ClientSdk`: entities, actions, files, users. |
|
|
8
|
+
| `@blocksdiy/blocks-client-sdk/reactSdk` | React hooks over the client, and the navigation helpers (`getRouteUrl`, `getLoginUrl`, `logOut`); needs `react-router`. |
|
|
9
|
+
| `@blocksdiy/blocks-client-sdk/app` | `BlocksApp`, the app's React tree, and the host contract a page hosting Blocks apps implements; needs `react-router`. |
|
|
10
|
+
| `@blocksdiy/blocks-client-sdk/page` | Page types for legacy pages-mode apps. |
|
|
11
|
+
| `@blocksdiy/blocks-client-sdk` | Everything from `clientSdk` and `reactSdk`. |
|
|
12
|
+
|
|
13
|
+
## The app entry
|
|
14
|
+
|
|
15
|
+
An app's `src/main.tsx` renders `BlocksApp` with the modules it globbed. `BlocksApp` holds what any Blocks app needs wherever it runs: the router, the sign-in screen, the SDK client, the app's routes (file-system routes, or legacy pages) with error boundaries, and the default 404 and loading screens. On the dev server it hosts itself (`window.__BLOCKS_DEV__`, `src/app/dev-server/`).
|
|
16
|
+
|
|
17
|
+
What only Blocks' own hosting needs (the builder canvas's tools, the mobile app's wiring) is not here: it lives in `apps/app-render`, which plugs it in through the host contract (`src/app/host.ts`):
|
|
18
|
+
|
|
19
|
+
- **state** the tree reads, kept current by the host: `setBlocksHost`, `updateBlocksHost`;
|
|
20
|
+
- **extensions**, set once before rendering (`setBlocksHostExtensions`): a `RouterLayer` inside the app's router, a `Shell` around its routes, a `SignIn` screen in place of the tree's login, and the reports `onReady`, `onPageChange`, `onMissingPage`, `onAppError`, `onSignOut` and `onRoutesResolved`.
|
|
21
|
+
|
|
22
|
+
| Folder (`src/app/`) | What it holds |
|
|
23
|
+
| ------------------- | ---------------------------------------------------------------------------------------- |
|
|
24
|
+
| `BlocksApp.tsx` | The tree: router, the host's router layer, sign-in, client, routes. |
|
|
25
|
+
| `AppRoutes.tsx` | The app's routes in either mode, with the reports, error boundaries, 404 and loading. |
|
|
26
|
+
| `host.ts` | The host contract. |
|
|
27
|
+
| `SdkProvider.tsx` | The SDK client around the app's routes, on the host's token and user. |
|
|
28
|
+
| `types.ts` | The app and route types the contract and the shapes share. |
|
|
29
|
+
| `app-shape/` | What an app's code amounts to: a bundle or globbed modules, shaped into routes or pages. |
|
|
30
|
+
| `sign-in/` | The login and its platform calls. |
|
|
31
|
+
| `dev-server/` | Self-hosting on the dev server. |
|
|
32
|
+
| `ui/` | The tree's own screens' styles (shadcn's look, on the app's tokens) and icons. |
|
|
33
|
+
| `hooks/` | The tree's own hooks: scroll to the top on a page change. |
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { PageConfig } from "./Page.js";
|
|
2
|
+
/**
|
|
3
|
+
* Navigation and session helpers an app's code calls, exported with the React SDK (`reactSdk` and the
|
|
4
|
+
* package root): they need react-router (a peer, present in every app) and the browser.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* For calls in migrated apps: `getPageUrl('Dashboard')` → `/Dashboard`, the URL of that page's
|
|
8
|
+
* route.
|
|
9
|
+
*
|
|
10
|
+
* @deprecated Navigate with real URLs or {@link getRouteUrl}.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getPageUrl(page: PageConfig | string, searchParams?: Record<string, string>): string;
|
|
13
|
+
/**
|
|
14
|
+
* Builds a URL for a file-system route (`src/routes/`), filling dynamic params.
|
|
15
|
+
*
|
|
16
|
+
* Pass the route's URL pattern (what the file path under `src/routes/`
|
|
17
|
+
* resolves to), params for any `:param` segments, and optional search params.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* // src/routes/products/[productId].tsx
|
|
22
|
+
* getRouteUrl('products/:productId', { productId: '123' });
|
|
23
|
+
* // => "/products/123"
|
|
24
|
+
*
|
|
25
|
+
* getRouteUrl('/orders', undefined, { status: 'open' });
|
|
26
|
+
* // => "/orders?status=open"
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function getRouteUrl(routePath: string, params?: Record<string, string>, searchParams?: Record<string, string>): string;
|
|
30
|
+
/**
|
|
31
|
+
* Generates a URL for the login page
|
|
32
|
+
*
|
|
33
|
+
* @returns {string} The URL for the login page
|
|
34
|
+
*/
|
|
35
|
+
export declare function getLoginUrl(): string;
|
|
36
|
+
/**
|
|
37
|
+
* Logs out the user by removing the token from localStorage and reloading the page
|
|
38
|
+
*/
|
|
39
|
+
export declare function logOut(): void;
|
|
40
|
+
//# sourceMappingURL=Navigation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Navigation.d.ts","sourceRoot":"","sources":["../src/Navigation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEzC;;;GAGG;AAEH;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,EAAE,YAAY,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,UAqB9F;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,WAAW,CACzB,SAAS,EAAE,MAAM,EACjB,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,EACnC,YAAY,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,UAM1C;AAED;;;;GAIG;AACH,wBAAgB,WAAW,WAE1B;AAED;;GAEG;AACH,wBAAgB,MAAM,SAGrB"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { generatePath } from "react-router";
|
|
2
|
+
import { tokenStorageKey } from "./dev-config.js";
|
|
3
|
+
/**
|
|
4
|
+
* Navigation and session helpers an app's code calls, exported with the React SDK (`reactSdk` and the
|
|
5
|
+
* package root): they need react-router (a peer, present in every app) and the browser.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* For calls in migrated apps: `getPageUrl('Dashboard')` → `/Dashboard`, the URL of that page's
|
|
9
|
+
* route.
|
|
10
|
+
*
|
|
11
|
+
* @deprecated Navigate with real URLs or {@link getRouteUrl}.
|
|
12
|
+
*/
|
|
13
|
+
export function getPageUrl(page, searchParams = {}) {
|
|
14
|
+
const appId = window.appId;
|
|
15
|
+
if (!appId) {
|
|
16
|
+
return "";
|
|
17
|
+
}
|
|
18
|
+
const searchParamsString = new URLSearchParams(searchParams).toString();
|
|
19
|
+
const { pathname: currentPath } = window.location;
|
|
20
|
+
const pageBlockId = typeof page === "string" ? page : page.pageBlockId;
|
|
21
|
+
const pageName = typeof page === "string" ? page : page.pageName;
|
|
22
|
+
if (currentPath.startsWith("/app/")) {
|
|
23
|
+
return `/app/${pageBlockId}${searchParamsString ? `?${searchParamsString}` : ""}`;
|
|
24
|
+
}
|
|
25
|
+
if (currentPath.startsWith("/apps/")) {
|
|
26
|
+
return `/apps/${appId}/design/pages/${pageBlockId}${searchParamsString ? `?${searchParamsString}` : ""}`;
|
|
27
|
+
}
|
|
28
|
+
return `/${pageName || pageBlockId}${searchParamsString ? `?${searchParamsString}` : ""}`;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Builds a URL for a file-system route (`src/routes/`), filling dynamic params.
|
|
32
|
+
*
|
|
33
|
+
* Pass the route's URL pattern (what the file path under `src/routes/`
|
|
34
|
+
* resolves to), params for any `:param` segments, and optional search params.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* // src/routes/products/[productId].tsx
|
|
39
|
+
* getRouteUrl('products/:productId', { productId: '123' });
|
|
40
|
+
* // => "/products/123"
|
|
41
|
+
*
|
|
42
|
+
* getRouteUrl('/orders', undefined, { status: 'open' });
|
|
43
|
+
* // => "/orders?status=open"
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export function getRouteUrl(routePath, params = {}, searchParams = {}) {
|
|
47
|
+
const normalizedPath = routePath.startsWith("/") ? routePath : `/${routePath}`;
|
|
48
|
+
const pathname = generatePath(normalizedPath, params);
|
|
49
|
+
const searchParamsString = new URLSearchParams(searchParams).toString();
|
|
50
|
+
return `${pathname}${searchParamsString ? `?${searchParamsString}` : ""}`;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Generates a URL for the login page
|
|
54
|
+
*
|
|
55
|
+
* @returns {string} The URL for the login page
|
|
56
|
+
*/
|
|
57
|
+
export function getLoginUrl() {
|
|
58
|
+
return `/auth/login`;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Logs out the user by removing the token from localStorage and reloading the page
|
|
62
|
+
*/
|
|
63
|
+
export function logOut() {
|
|
64
|
+
localStorage.removeItem(tokenStorageKey());
|
|
65
|
+
window.location.href = "/auth/logout";
|
|
66
|
+
}
|
package/dist/ReactClientSdk.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import type { Integration } from "./Integration.js";
|
|
|
11
11
|
import type { PageConfig } from "./Page.js";
|
|
12
12
|
import { canManageUsers } from "./Permission.js";
|
|
13
13
|
export { canManageUsers };
|
|
14
|
+
export { getLoginUrl, getPageUrl, getRouteUrl, logOut } from "./Navigation.js";
|
|
14
15
|
export type { AppUserPermission } from "./Permission.js";
|
|
15
16
|
export declare class ReactClientSdk extends ClientSdk {
|
|
16
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReactClientSdk.d.ts","sourceRoot":"","sources":["../src/ReactClientSdk.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAiB,MAAM,qCAAqC,CAAC;AAGpF,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAE3B,MAAM,8CAA8C,CAAC;AACtD,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,iBAAiB,EAEtB,KAAK,eAAe,EAIrB,MAAM,uCAAuC,CAAC;AAY/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAenG,OAAO,EAAmB,KAAK,W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CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,UAAU,GAAI,EAAE,SAAS,UAAU,GAAG,UAAU,EAAE,YAAY,EAAE,WAI5E,CAAC"}
|
package/dist/ReactClientSdk.jsx
CHANGED
|
@@ -14,6 +14,7 @@ import { createEntityLiveSync } from "./EntityLiveSync.js";
|
|
|
14
14
|
import { isEntityQuery } from "./EntityQuery.js";
|
|
15
15
|
import { canManageUsers } from "./Permission.js";
|
|
16
16
|
export { canManageUsers };
|
|
17
|
+
export { getLoginUrl, getPageUrl, getRouteUrl, logOut } from "./Navigation.js";
|
|
17
18
|
export class ReactClientSdk extends ClientSdk {
|
|
18
19
|
}
|
|
19
20
|
const CURRENT_USER_QUERY_KEY = "currentUser";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* The app's routes, in either mode, inside the host's `Shell` when it has one. Stays mounted while
|
|
4
|
+
* a shell swaps the routes out (the builder's chat-component preview), so what it reports once per
|
|
5
|
+
* load of the code is reported once.
|
|
6
|
+
*/
|
|
7
|
+
export declare const AppRoutes: () => React.JSX.Element | null;
|
|
8
|
+
//# sourceMappingURL=AppRoutes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AppRoutes.d.ts","sourceRoot":"","sources":["../../src/app/AppRoutes.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+E,MAAM,OAAO,CAAC;AA0RpG;;;;GAIG;AACH,eAAO,MAAM,SAAS,gCAmCrB,CAAC"}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import React, { useEffect, useInsertionEffect, useMemo, useState } from "react";
|
|
2
|
+
import { ErrorBoundary } from "react-error-boundary";
|
|
3
|
+
import { Link, matchRoutes, Navigate, Outlet, Route, Routes, useLocation, useRoutes, useSearchParams, } from "react-router";
|
|
4
|
+
import { useAppShape } from "./app-shape/use-app-shape.js";
|
|
5
|
+
import { useScrollToTopOnPageChange } from "./hooks/use-scroll-to-top-on-page-change.js";
|
|
6
|
+
import { getBlocksHostExtensions, useBlocksHostField, useBlocksHostSelector } from "./host.js";
|
|
7
|
+
import { isAuthUrl } from "./sign-in/auth-url.js";
|
|
8
|
+
import { MissingPageIcon, SpinnerIcon } from "./ui/icons";
|
|
9
|
+
import { ensureUiStyles } from "./ui/ui-styles.js";
|
|
10
|
+
/**
|
|
11
|
+
* Report-only error boundary: renders nothing in place of what threw, and tells the host, which owns
|
|
12
|
+
* the error's display. Told from an effect after the commit that caught it, not from `onError`: a
|
|
13
|
+
* host that clears its errors when the app is ready (the builder) hears the ready report of that
|
|
14
|
+
* commit first, and this error after it.
|
|
15
|
+
*/
|
|
16
|
+
const ReportingBoundary = ({ blockId, resetKeys, children, }) => {
|
|
17
|
+
const [report, setReport] = useState(null);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (report) {
|
|
20
|
+
getBlocksHostExtensions().onAppError?.(report);
|
|
21
|
+
}
|
|
22
|
+
}, [report]);
|
|
23
|
+
return (<ErrorBoundary fallback={null} resetKeys={resetKeys} onReset={() => setReport(null)} onError={(error, info) => setReport({
|
|
24
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
25
|
+
componentStack: info.componentStack ?? "",
|
|
26
|
+
blockId,
|
|
27
|
+
})}>
|
|
28
|
+
{children}
|
|
29
|
+
</ErrorBoundary>);
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* An auth URL where the host keeps the viewer signed in (the only way one reaches the routes): the
|
|
33
|
+
* host hears a sign-out, and the app goes back to its start.
|
|
34
|
+
*/
|
|
35
|
+
const AuthRedirect = () => {
|
|
36
|
+
const location = useLocation();
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (location.pathname.startsWith("/auth/logout")) {
|
|
39
|
+
getBlocksHostExtensions().onSignOut?.();
|
|
40
|
+
}
|
|
41
|
+
}, [location.pathname]);
|
|
42
|
+
return <Navigate to={{ pathname: "/", search: location.search }} replace/>;
|
|
43
|
+
};
|
|
44
|
+
/** The boundary around one page or layout, naming it in the report. Resets when the block changes. */
|
|
45
|
+
const BlockErrorBoundary = ({ blockId, children }) => (<ReportingBoundary blockId={blockId} resetKeys={[blockId]}>
|
|
46
|
+
{children}
|
|
47
|
+
</ReportingBoundary>);
|
|
48
|
+
/**
|
|
49
|
+
* Automation (the builder's cover capture, browser checks, end-to-end tests) waits for this flag:
|
|
50
|
+
* set once the app's page is mounted, inside the boundary, so a render crash unmounts it and the
|
|
51
|
+
* cleanup clears the flag.
|
|
52
|
+
*/
|
|
53
|
+
const AppReadyFlag = () => {
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
const page = window;
|
|
56
|
+
page.__blocksAppReady = true;
|
|
57
|
+
return () => {
|
|
58
|
+
page.__blocksAppReady = false;
|
|
59
|
+
};
|
|
60
|
+
}, []);
|
|
61
|
+
return null;
|
|
62
|
+
};
|
|
63
|
+
const Page = ({ pageBlockId, Component }) => {
|
|
64
|
+
const [searchParams] = useSearchParams();
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
getBlocksHostExtensions().onPageChange?.({ pageId: pageBlockId, searchParams: searchParams.toString() });
|
|
67
|
+
}, [pageBlockId, searchParams]);
|
|
68
|
+
return (<BlockErrorBoundary blockId={pageBlockId}>
|
|
69
|
+
<Component />
|
|
70
|
+
<AppReadyFlag />
|
|
71
|
+
</BlockErrorBoundary>);
|
|
72
|
+
};
|
|
73
|
+
const Layout = () => {
|
|
74
|
+
const { layout } = useAppShape();
|
|
75
|
+
if (!layout) {
|
|
76
|
+
return <Outlet />;
|
|
77
|
+
}
|
|
78
|
+
const LayoutComponent = layout.component;
|
|
79
|
+
return (<BlockErrorBoundary blockId={layout.id}>
|
|
80
|
+
<LayoutComponent>
|
|
81
|
+
<Outlet />
|
|
82
|
+
</LayoutComponent>
|
|
83
|
+
</BlockErrorBoundary>);
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Routes mode: the app's file-system route tree, through useRoutes. Route components render bare;
|
|
87
|
+
* the cross-cutting concerns live at the edges: one error boundary reports render errors, and one
|
|
88
|
+
* location-driven effect reports the matched route (so a host following the app, like the
|
|
89
|
+
* builder's canvas, follows in-app navigation). Unmatched URLs render the default 404
|
|
90
|
+
* (MissingPageFallback) unless the app ships its own `not-found.tsx` or splat, which matches first.
|
|
91
|
+
*/
|
|
92
|
+
const RoutesTree = ({ routes }) => {
|
|
93
|
+
const { componentsLoadedAt } = useAppShape();
|
|
94
|
+
const location = useLocation();
|
|
95
|
+
const routeObjects = useMemo(() => {
|
|
96
|
+
// The tree IS a RouteObject tree: useRoutes renders the `Component` field natively (the extra
|
|
97
|
+
// `id`/`name` metadata is ignored). The cast bridges the nominal types; nothing is transformed.
|
|
98
|
+
const children = [...routes.routes];
|
|
99
|
+
// Default 404: an app-defined catch-all (not-found.tsx or a root splat) sits earlier in the
|
|
100
|
+
// array and wins; otherwise unmatched URLs render the fallback and report up. "/" included:
|
|
101
|
+
// apps own their landing page via routes/index.tsx (the migration generates one for legacy apps).
|
|
102
|
+
children.push({ path: "*", element: <MissingPageFallback /> });
|
|
103
|
+
return [{ id: "root", Component: routes.root?.Component ?? Outlet, children }];
|
|
104
|
+
}, [routes]);
|
|
105
|
+
const isAuthPath = isAuthUrl(location.pathname);
|
|
106
|
+
// The deepest matched APP route (ids starting with "routes/").
|
|
107
|
+
const matchedRouteId = useMemo(() => {
|
|
108
|
+
const matches = matchRoutes(routeObjects, location) ?? [];
|
|
109
|
+
return [...matches].reverse().find((match) => match.route.id?.startsWith("routes/"))?.route.id;
|
|
110
|
+
}, [routeObjects, location]);
|
|
111
|
+
// Every location is reported, the host's own first navigation included: the builder treats a
|
|
112
|
+
// report of the page it selected as a no-op, and a `:param` page's concrete ancestor as the parked
|
|
113
|
+
// boot it is (never a navigation away).
|
|
114
|
+
useEffect(() => {
|
|
115
|
+
if (!matchedRouteId || isAuthPath) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
getBlocksHostExtensions().onPageChange?.({
|
|
119
|
+
pageId: matchedRouteId,
|
|
120
|
+
searchParams: location.search.replace(/^\?/, ""),
|
|
121
|
+
});
|
|
122
|
+
}, [matchedRouteId, location.search, location.key, isAuthPath]);
|
|
123
|
+
const element = useRoutes(routeObjects);
|
|
124
|
+
if (isAuthPath) {
|
|
125
|
+
return <AuthRedirect />;
|
|
126
|
+
}
|
|
127
|
+
return (
|
|
128
|
+
// Names the matched route; resets when the user navigates or the app recompiles.
|
|
129
|
+
<ReportingBoundary blockId={matchedRouteId} resetKeys={[location.pathname, componentsLoadedAt]}>
|
|
130
|
+
{/* key remounts the whole app tree after a recompile so new code takes over cleanly */}
|
|
131
|
+
<React.Fragment key={componentsLoadedAt}>{element}</React.Fragment>
|
|
132
|
+
<AppReadyFlag />
|
|
133
|
+
</ReportingBoundary>);
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Pages mode (legacy apps): each page at its name and its id, inside the app's layout, landing on
|
|
137
|
+
* the default page; before the pages arrive, a loading screen.
|
|
138
|
+
*/
|
|
139
|
+
const PagesRoutes = ({ pages, defaultPage }) => {
|
|
140
|
+
const { componentsLoadedAt } = useAppShape();
|
|
141
|
+
const page = ({ id, component }) => (<Page pageBlockId={id} Component={component} key={`${id}-${componentsLoadedAt}`}/>);
|
|
142
|
+
return (<Routes>
|
|
143
|
+
<Route path="/" element={<Layout key={`layout-${componentsLoadedAt}`}/>}>
|
|
144
|
+
{defaultPage && <Route index element={page(defaultPage)}/>}
|
|
145
|
+
{pages.length > 0 ? (<>
|
|
146
|
+
{pages.map((block) => (<Route key={block.id} path={`/${block.id}`} element={page(block)}/>))}
|
|
147
|
+
{pages.map((block) => block.name !== block.id ? <Route key={block.name} path={`/${block.name}`} element={page(block)}/> : null)}
|
|
148
|
+
<Route path="*" element={<MissingPageFallback />}/>
|
|
149
|
+
</>) : (<Route path="*" element={<LoadingScreen />}/>)}
|
|
150
|
+
</Route>
|
|
151
|
+
{defaultPage && <Route path="/auth/*" element={<AuthRedirect />}/>}
|
|
152
|
+
</Routes>);
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* The default 404 with its report, as shadcn's empty state on the app's tokens (`ui-styles.ts`).
|
|
156
|
+
* Renders inside the app's root layout, so it inherits the app's font and text color. Apps that want
|
|
157
|
+
* their own 404 ship `routes/not-found.tsx`, which matches before this route.
|
|
158
|
+
*/
|
|
159
|
+
const MissingPageFallback = () => {
|
|
160
|
+
const { pages } = useAppShape();
|
|
161
|
+
const location = useLocation();
|
|
162
|
+
useEffect(() => {
|
|
163
|
+
getBlocksHostExtensions().onMissingPage?.({
|
|
164
|
+
url: `${location.pathname}${location.search}`,
|
|
165
|
+
pages: pages.map(({ id, name }) => ({ id, name })),
|
|
166
|
+
});
|
|
167
|
+
}, [location, pages]);
|
|
168
|
+
useInsertionEffect(ensureUiStyles, []);
|
|
169
|
+
return (<div className="blocks-ui ui-empty">
|
|
170
|
+
<div className="ui-empty-header">
|
|
171
|
+
<div className="ui-icon-tile">
|
|
172
|
+
<MissingPageIcon />
|
|
173
|
+
</div>
|
|
174
|
+
<h1 className="ui-empty-title">Page not found</h1>
|
|
175
|
+
<p className="ui-empty-description">This page doesn't exist or has moved.</p>
|
|
176
|
+
</div>
|
|
177
|
+
<Link to="/" className="ui-button ui-button-outline">
|
|
178
|
+
Back to home
|
|
179
|
+
</Link>
|
|
180
|
+
</div>);
|
|
181
|
+
};
|
|
182
|
+
/** A legacy app's routes before its pages arrive. */
|
|
183
|
+
const LoadingScreen = () => {
|
|
184
|
+
useInsertionEffect(ensureUiStyles, []);
|
|
185
|
+
return (<div role="status" className="blocks-ui ui-loading">
|
|
186
|
+
<SpinnerIcon className="ui-spinner"/>
|
|
187
|
+
Loading…
|
|
188
|
+
</div>);
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* The app's routes, in either mode, inside the host's `Shell` when it has one. Stays mounted while
|
|
192
|
+
* a shell swaps the routes out (the builder's chat-component preview), so what it reports once per
|
|
193
|
+
* load of the code is reported once.
|
|
194
|
+
*/
|
|
195
|
+
export const AppRoutes = () => {
|
|
196
|
+
const routesHeld = useBlocksHostField("routesHeld");
|
|
197
|
+
const defaultPageBlockId = useBlocksHostSelector((state) => state.app?.defaultPageBlockId);
|
|
198
|
+
const { pages, routes, componentsLoadedAt, defaultPageId } = useAppShape();
|
|
199
|
+
const landingPageId = defaultPageBlockId || defaultPageId;
|
|
200
|
+
const defaultPage = landingPageId
|
|
201
|
+
? pages.find(({ id, name }) => id === landingPageId || name === landingPageId)
|
|
202
|
+
: [...pages].sort((a, b) => a.id.localeCompare(b.id))[0];
|
|
203
|
+
const { Shell } = getBlocksHostExtensions();
|
|
204
|
+
useScrollToTopOnPageChange();
|
|
205
|
+
// Once the app is on its page, not merely loaded: a host lifts its loading cover on this, and a
|
|
206
|
+
// bundle that lands while the host holds the routes would uncover an empty page.
|
|
207
|
+
useEffect(() => {
|
|
208
|
+
if (componentsLoadedAt && !routesHeld) {
|
|
209
|
+
getBlocksHostExtensions().onReady?.();
|
|
210
|
+
}
|
|
211
|
+
}, [componentsLoadedAt, routesHeld]);
|
|
212
|
+
// After `onReady`, so a host that clears its errors on ready keeps this one. Routes mode is exempt:
|
|
213
|
+
// `pages` only counts leaf route modules, so an app that so far has only layout files loaded fine
|
|
214
|
+
// (the catch-all renders).
|
|
215
|
+
useEffect(() => {
|
|
216
|
+
if (componentsLoadedAt && !routesHeld && !routes && pages.length === 0) {
|
|
217
|
+
getBlocksHostExtensions().onAppError?.({ error: new Error("Could not load the components") });
|
|
218
|
+
}
|
|
219
|
+
}, [componentsLoadedAt, routesHeld, pages, routes]);
|
|
220
|
+
const content = routesHeld ? null : routes ? (<RoutesTree routes={routes}/>) : (<PagesRoutes pages={pages} defaultPage={defaultPage}/>);
|
|
221
|
+
return Shell ? <Shell>{content}</Shell> : content;
|
|
222
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type CompiledBundle } from "./app-shape/bundle-shape.js";
|
|
3
|
+
export interface BlocksAppProps {
|
|
4
|
+
/** A self-mounting app: the modules its `src/main.tsx` globbed (`routes/**` and `root.tsx`, or `pages/**` and `layout.tsx`, plus the chat renderer). */
|
|
5
|
+
modules?: Record<string, unknown>;
|
|
6
|
+
/** The host's import of a bundle that exports its routes (`window.compiler`). */
|
|
7
|
+
bundle?: CompiledBundle;
|
|
8
|
+
/**
|
|
9
|
+
* When the host finished importing `bundle`, or failed to: the tree remounts on a new stamp, so a
|
|
10
|
+
* recompile's code takes over cleanly. Passed with the bundle, so the two change in one render.
|
|
11
|
+
*/
|
|
12
|
+
componentsLoadedAt?: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A Blocks app's React tree: the router, the sign-in screen where the viewer must sign in, the SDK
|
|
16
|
+
* client, and the app's routes with error boundaries and the default 404. One component for every
|
|
17
|
+
* way an app runs: rendered by the app's own `src/main.tsx` into the root it creates, by app-render
|
|
18
|
+
* around a bundle that exports its routes, and on the dev server, where it hosts itself. What the
|
|
19
|
+
* host knows and adds comes from the host contract (`host.ts`).
|
|
20
|
+
*/
|
|
21
|
+
export declare const BlocksApp: ({ modules, bundle, componentsLoadedAt }: BlocksAppProps) => React.JSX.Element;
|
|
22
|
+
//# sourceMappingURL=BlocksApp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BlocksApp.d.ts","sourceRoot":"","sources":["../../src/app/BlocksApp.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA0D,MAAM,OAAO,CAAC;AAG/E,OAAO,EAAiB,KAAK,cAAc,EAAqC,MAAM,0BAA0B,CAAC;AASjH,MAAM,WAAW,cAAc;IAC7B,wJAAwJ;IACxJ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,iFAAiF;IACjF,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAgCD;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,GAAI,yCAAyC,cAAc,sBAoChF,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import React, { useInsertionEffect, useMemo } from "react";
|
|
2
|
+
import { BrowserRouter, useLocation } from "react-router";
|
|
3
|
+
import { shapeFromBundle, shapeFromModules } from "./app-shape/bundle-shape.js";
|
|
4
|
+
import { AppShapeContext } from "./app-shape/use-app-shape.js";
|
|
5
|
+
import { AppRoutes } from "./AppRoutes";
|
|
6
|
+
import { ensureSelfHost } from "./dev-server/bootstrap.js";
|
|
7
|
+
import { getBlocksHostExtensions, useBlocksHostField, useBlocksHostSelector } from "./host.js";
|
|
8
|
+
import { SdkProvider } from "./SdkProvider";
|
|
9
|
+
import { isAuthUrl } from "./sign-in/auth-url.js";
|
|
10
|
+
import { Login } from "./sign-in/Login";
|
|
11
|
+
/**
|
|
12
|
+
* Where the viewer must sign in (an app the host could not load with no token to drop, the dev
|
|
13
|
+
* server without a token, an auth URL), the sign-in screen shows in the app's place: the tree's own
|
|
14
|
+
* login, or the host's.
|
|
15
|
+
*/
|
|
16
|
+
const SignInGate = ({ SignIn, children }) => {
|
|
17
|
+
const hasAppLoadFailed = useBlocksHostField("hasAppLoadFailed");
|
|
18
|
+
const requiresSignIn = useBlocksHostField("requiresSignIn");
|
|
19
|
+
const token = useBlocksHostField("token");
|
|
20
|
+
const { pathname } = useLocation();
|
|
21
|
+
return hasAppLoadFailed || (requiresSignIn && !token) || isAuthUrl(pathname) ? <SignIn /> : children;
|
|
22
|
+
};
|
|
23
|
+
const EMPTY_SHAPE = { pages: [], isEmpty: false };
|
|
24
|
+
/**
|
|
25
|
+
* When a self-mounting bundle's modules arrived: a recompile renders new ones into the same root,
|
|
26
|
+
* and the tree remounts on the new stamp. Kept per modules object, not in component state, so it
|
|
27
|
+
* changes exactly when the modules do.
|
|
28
|
+
*/
|
|
29
|
+
const moduleStamps = new WeakMap();
|
|
30
|
+
const stampOf = (modules) => {
|
|
31
|
+
let stamp = moduleStamps.get(modules);
|
|
32
|
+
if (stamp === undefined) {
|
|
33
|
+
stamp = Date.now();
|
|
34
|
+
moduleStamps.set(modules, stamp);
|
|
35
|
+
}
|
|
36
|
+
return stamp;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* A Blocks app's React tree: the router, the sign-in screen where the viewer must sign in, the SDK
|
|
40
|
+
* client, and the app's routes with error boundaries and the default 404. One component for every
|
|
41
|
+
* way an app runs: rendered by the app's own `src/main.tsx` into the root it creates, by app-render
|
|
42
|
+
* around a bundle that exports its routes, and on the dev server, where it hosts itself. What the
|
|
43
|
+
* host knows and adds comes from the host contract (`host.ts`).
|
|
44
|
+
*/
|
|
45
|
+
export const BlocksApp = ({ modules, bundle, componentsLoadedAt }) => {
|
|
46
|
+
// The dev server renders with no host page: the app hosts itself (once; idempotent under StrictMode).
|
|
47
|
+
ensureSelfHost();
|
|
48
|
+
const { RouterLayer, SignIn = Login } = getBlocksHostExtensions();
|
|
49
|
+
const modulesLoadedAt = modules && stampOf(modules);
|
|
50
|
+
const appId = useBlocksHostSelector((state) => state.app?.id);
|
|
51
|
+
const shape = useMemo(() => {
|
|
52
|
+
if (modules) {
|
|
53
|
+
return { ...shapeFromModules(modules), componentsLoadedAt: modulesLoadedAt };
|
|
54
|
+
}
|
|
55
|
+
if (bundle || appId) {
|
|
56
|
+
return { ...shapeFromBundle(bundle, appId), componentsLoadedAt };
|
|
57
|
+
}
|
|
58
|
+
return { ...EMPTY_SHAPE, componentsLoadedAt: undefined };
|
|
59
|
+
}, [modules, bundle, appId, modulesLoadedAt, componentsLoadedAt]);
|
|
60
|
+
// Before the tree commits, so a crash on this very render is attributed to these routes.
|
|
61
|
+
useInsertionEffect(() => {
|
|
62
|
+
getBlocksHostExtensions().onRoutesResolved?.(shape.componentsLoadedAt ? shape.errorRoutes : undefined);
|
|
63
|
+
}, [shape]);
|
|
64
|
+
const app = (<SdkProvider>
|
|
65
|
+
<AppRoutes />
|
|
66
|
+
</SdkProvider>);
|
|
67
|
+
return (<BrowserRouter>
|
|
68
|
+
<AppShapeContext value={shape}>
|
|
69
|
+
{RouterLayer && <RouterLayer />}
|
|
70
|
+
{SignIn ? <SignInGate SignIn={SignIn}>{app}</SignInGate> : app}
|
|
71
|
+
</AppShapeContext>
|
|
72
|
+
</BrowserRouter>);
|
|
73
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
/** The SDK client for the app, authenticated as the host says, with the theme mode the host holds. */
|
|
3
|
+
export declare const SdkProvider: ({ children }: {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
}) => React.JSX.Element | null;
|
|
6
|
+
//# sourceMappingURL=SdkProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SdkProvider.d.ts","sourceRoot":"","sources":["../../src/app/SdkProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAKnD,sGAAsG;AACtG,eAAO,MAAM,WAAW,GAAI,cAAc;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,6BA+CtE,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
|
+
import { ClientProvider, ReactClientSdk } from "../ReactClientSdk";
|
|
3
|
+
import { setThemeMode, useBlocksHostField, useBlocksHostSelector } from "./host.js";
|
|
4
|
+
/** The SDK client for the app, authenticated as the host says, with the theme mode the host holds. */
|
|
5
|
+
export const SdkProvider = ({ children }) => {
|
|
6
|
+
const token = useBlocksHostField("token");
|
|
7
|
+
const appId = useBlocksHostSelector((state) => state.app?.id);
|
|
8
|
+
const bootUser = useBlocksHostField("bootUser");
|
|
9
|
+
const awaitsToken = useBlocksHostField("awaitsToken");
|
|
10
|
+
const themeMode = useBlocksHostField("themeMode");
|
|
11
|
+
const [client, setClient] = useState(null);
|
|
12
|
+
// A host that hands the token over after boot (the builder mints one for its own user) is waited
|
|
13
|
+
// for, rather than authenticating anonymously first and again once it lands, which would render
|
|
14
|
+
// the app signed out for a beat.
|
|
15
|
+
const isAwaitingToken = awaitsToken && !token;
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (!appId || isAwaitingToken) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
let isCurrent = true;
|
|
21
|
+
const newClient = new ReactClientSdk({
|
|
22
|
+
appId,
|
|
23
|
+
token,
|
|
24
|
+
});
|
|
25
|
+
// The host fetched the current user on the app for this boot: the same answer `authenticate()`
|
|
26
|
+
// would fetch, taken instead of asked for.
|
|
27
|
+
const authenticated = bootUser
|
|
28
|
+
? Promise.resolve(newClient.setAuthenticatedUser(bootUser))
|
|
29
|
+
: newClient.authenticate();
|
|
30
|
+
authenticated.then(() => {
|
|
31
|
+
if (isCurrent) {
|
|
32
|
+
setClient(newClient);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
return () => {
|
|
36
|
+
isCurrent = false;
|
|
37
|
+
};
|
|
38
|
+
}, [appId, token, isAwaitingToken, bootUser]);
|
|
39
|
+
if (!client) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
return (<ClientProvider client={client} themeMode={themeMode} setThemeMode={setThemeMode}>
|
|
43
|
+
{children}
|
|
44
|
+
</ClientProvider>);
|
|
45
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { ComponentType } from "react";
|
|
2
|
+
import type { RouteObject } from "react-router";
|
|
3
|
+
import type { BlocksRoutesTree } from "../types.js";
|
|
4
|
+
/** A page (or the legacy layout) as the tree routes it. */
|
|
5
|
+
export interface CodeBlock {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
component: ComponentType;
|
|
9
|
+
}
|
|
10
|
+
/** What an app's code amounts to, whichever way it arrived. */
|
|
11
|
+
export interface AppShape {
|
|
12
|
+
/** Present for routes-mode apps (file-system routing); legacy bundles leave it undefined. */
|
|
13
|
+
routes?: BlocksRoutesTree;
|
|
14
|
+
/** Legacy: one entry per page. Routes mode: the leaf routes, for missing-page reports. */
|
|
15
|
+
pages: CodeBlock[];
|
|
16
|
+
/** Legacy: the app's `AppLayout`. */
|
|
17
|
+
layout?: CodeBlock;
|
|
18
|
+
/**
|
|
19
|
+
* The app's chat-component renderer, when it has one: the module of the agent-chat item
|
|
20
|
+
* (`components/ui/agent-chat-code-component.tsx`, a bundle's `__agentChatCodeComponent`), as
|
|
21
|
+
* exported. What it renders is the host's to know.
|
|
22
|
+
*/
|
|
23
|
+
chatComponentRenderer?: unknown;
|
|
24
|
+
/** The routes for error attribution, as the tree reports them to the host. */
|
|
25
|
+
errorRoutes?: RouteObject[];
|
|
26
|
+
/** Nothing threw, yet there is no page to show: reported, since a failed import is told apart. */
|
|
27
|
+
isEmpty: boolean;
|
|
28
|
+
/** A pages-mode app's landing page where the host names none (the dev server). */
|
|
29
|
+
defaultPageId?: string;
|
|
30
|
+
}
|
|
31
|
+
/** The module `window.compiler` holds once a compiled bundle has been imported. */
|
|
32
|
+
export interface CompiledBundle {
|
|
33
|
+
[name: string]: unknown;
|
|
34
|
+
__blocksRoutes?: BlocksRoutesTree;
|
|
35
|
+
__agentChatCodeComponent?: unknown;
|
|
36
|
+
/** Legacy: the layout, shaped like a page (`{ id: "AppLayout", name, component }`). */
|
|
37
|
+
AppLayout?: CodeBlock;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The shape of a compiled bundle the host imported, in any of its three forms: a routes-mode
|
|
41
|
+
* module (`__blocksRoutes`), a legacy module (`AppLayout` plus one named export per page), or the
|
|
42
|
+
* oldest, a `window["compiler_<appId>"]` map of one-character-prefixed page ids. An EMPTY routes tree (every route module failed to derive, e.g. no default exports)
|
|
43
|
+
* takes the legacy branch, so the "Could not load the components" fatal still fires.
|
|
44
|
+
*/
|
|
45
|
+
export declare const shapeFromBundle: (bundle: CompiledBundle | undefined, appId: string | undefined) => AppShape;
|
|
46
|
+
/**
|
|
47
|
+
* The shape of a self-mounting app from the modules its `src/main.tsx` globbed, by the rule the
|
|
48
|
+
* compiler builds a bundle with: an app with a module under `routes/` is routes mode (`routes/**`
|
|
49
|
+
* and `root.tsx` make the tree), else `pages/**` are its pages, each at its file name inside
|
|
50
|
+
* `layout.tsx`. `components/ui/agent-chat-code-component.tsx`, when the app has the agent-chat
|
|
51
|
+
* item, is its chat-component renderer.
|
|
52
|
+
*/
|
|
53
|
+
export declare const shapeFromModules: (modules: Record<string, unknown>) => AppShape;
|
|
54
|
+
//# sourceMappingURL=bundle-shape.d.ts.map
|