@coreframe/dashboard 0.4.2 → 0.4.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/README.md
CHANGED
|
@@ -157,46 +157,23 @@ adapter instance across pages. The adapter implements `SettingsSync` from
|
|
|
157
157
|
If the app switches between accounts or tenants without a page reload, scope the adapter instance
|
|
158
158
|
to the active identity and remount any open forms so stale drafts cannot carry over.
|
|
159
159
|
|
|
160
|
-
##
|
|
160
|
+
## Dashboard routing
|
|
161
161
|
|
|
162
|
-
|
|
163
|
-
|
|
162
|
+
The dashboard uses React Router's browser Data Router by default. `coreframe dev` serves it
|
|
163
|
+
with Vite, and `coreframe dashboard build` builds the static entry and assets that the app
|
|
164
|
+
serves under `/__dashboard/`. Client routes use router hooks and ordinary TypeScript types.
|
|
164
165
|
|
|
165
|
-
|
|
166
|
+
If an existing dashboard uses a custom document or Framework route features, set
|
|
167
|
+
`dashboard.router` to `"framework"` in `coreframe.config.ts`:
|
|
166
168
|
|
|
167
169
|
```ts
|
|
168
170
|
export default defineConfig({
|
|
169
|
-
dashboard: {
|
|
171
|
+
dashboard: { router: "framework" },
|
|
170
172
|
})
|
|
171
173
|
```
|
|
172
174
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
must adopt this Vite adapter as well as the setting. The relevant adapter shape is:
|
|
176
|
-
|
|
177
|
-
```ts
|
|
178
|
-
const clientRouter =
|
|
179
|
-
env.command === "serve" && process.env.COREFRAME_DASHBOARD_DEV_ROUTER === "client"
|
|
180
|
-
|
|
181
|
-
const routerPlugins = clientRouter
|
|
182
|
-
? [coreframeDashboardClientPlugin({ projectRoot })]
|
|
183
|
-
: [coreframeDashboardAppPlugin({ projectRoot }), reactRouter()]
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
Spread `routerPlugins` into the existing plugins array, preserving Panda and other project
|
|
187
|
-
transforms. Import both dashboard adapters and `reactRouter` in this config.
|
|
188
|
-
|
|
189
|
-
Run the ordinary `pnpm dev` or `pnpm exec coreframe dashboard dev --port 5174` command. Coreframe
|
|
190
|
-
starts plain Vite for the dashboard UI, generates its browser route list from the same pages and
|
|
191
|
-
plugins as Framework Mode, and runs Framework type generation initially and after changes under
|
|
192
|
-
`dashboard/pages/` or to `dashboard/dashboard.config.ts`. Generation failures stop dashboard
|
|
193
|
-
development with an error. Changes to configuration dependencies outside these paths may require
|
|
194
|
-
restarting development. The setting defaults to `"framework"`.
|
|
195
|
-
|
|
196
|
-
`coreframe typegen` and `coreframe dashboard build` continue to use Framework Mode. Keep
|
|
197
|
-
`react-router.config.ts`, including `ssr: false`. Production builds still evaluate modules in a
|
|
198
|
-
server environment and render the root document at build time, so successful client development
|
|
199
|
-
does not establish production build compatibility. Run the dashboard build before deploying.
|
|
175
|
+
Framework mode uses `dashboard/react-router.config.ts` and generates dashboard route types.
|
|
176
|
+
The older `dashboard.devRouter` setting is accepted when `dashboard.router` is omitted.
|
|
200
177
|
|
|
201
178
|
Client-compatible dashboard pages:
|
|
202
179
|
|
|
@@ -205,10 +182,9 @@ Client-compatible dashboard pages:
|
|
|
205
182
|
component or error-boundary props.
|
|
206
183
|
- Use `clientLoader` and `clientAction` for browser data work, calling the app API or dashboard
|
|
207
184
|
plugin APIs directly. These functions receive Data Router arguments; `serverLoader` and
|
|
208
|
-
`serverAction` are unavailable. Data Router
|
|
185
|
+
`serverAction` are unavailable. Data Router uses its standard revalidation behavior.
|
|
209
186
|
- May export `ErrorBoundary`, `HydrateFallback`, `handle`, and `shouldRevalidate`.
|
|
210
|
-
- Must keep imports and page code browser-safe.
|
|
211
|
-
or server-only imports. Exports named `loader`, `action`, `headers`, `meta`, `links`, `middleware`,
|
|
187
|
+
- Must keep imports and page code browser-safe. Vite includes page modules in the browser build. Exports named `loader`, `action`, `headers`, `meta`, `links`, `middleware`,
|
|
212
188
|
and `clientMiddleware` produce an unsupported-feature error when the page loads.
|
|
213
189
|
- Must avoid Framework-only components and link features such as `Meta`, `Links`, `Scripts`,
|
|
214
190
|
`prefetch`, and `discover`. Use React document metadata elements where needed.
|
|
@@ -230,12 +206,11 @@ export default function Overview() {
|
|
|
230
206
|
}
|
|
231
207
|
```
|
|
232
208
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
checks and same-origin request rules apply to both router modes.
|
|
209
|
+
For the client router, put custom wrappers and content in page components. Coreframe
|
|
210
|
+
supplies the browser entry, query provider, navigation, title, favicon, and styles, along
|
|
211
|
+
with the Sculpted runtime and managed development overlay in development. The local
|
|
212
|
+
dashboard API loads Node implementations separately. The app's admin session checks and
|
|
213
|
+
same-origin request rules apply in both modes.
|
|
239
214
|
|
|
240
215
|
## Style overrides
|
|
241
216
|
|
|
@@ -2,6 +2,6 @@ import { NonIndexRouteObject } from "react-router";
|
|
|
2
2
|
|
|
3
3
|
//#region src/app/client-route.d.ts
|
|
4
4
|
/** Adapts the supported browser-only subset of Framework route modules. */
|
|
5
|
-
declare function adaptClientRoute(module: Record<string, unknown>,
|
|
5
|
+
declare function adaptClientRoute(module: Record<string, unknown>, path: string): Pick<NonIndexRouteObject, "Component" | "loader" | "action" | "ErrorBoundary" | "HydrateFallback" | "handle" | "shouldRevalidate">;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { adaptClientRoute };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e,t){for(let n of[`loader`,`action`,`headers`,`meta`,`links`,`middleware`,`clientMiddleware`])if(n in e)throw Error(`Dashboard client routing does not support the ${n} export in ${t}. Use clientLoader/clientAction
|
|
1
|
+
function e(e,t){for(let n of[`loader`,`action`,`headers`,`meta`,`links`,`middleware`,`clientMiddleware`])if(n in e)throw Error(`Dashboard client routing does not support the ${n} export in ${t}. Use clientLoader/clientAction and router hooks, or set dashboard.router to "framework" in coreframe.config.ts.`);return{Component:e.default,loader:e.clientLoader,action:e.clientAction,ErrorBoundary:e.ErrorBoundary,HydrateFallback:e.HydrateFallback,handle:e.handle,shouldRevalidate:e.shouldRevalidate}}export{e as adaptClientRoute};
|