@iyulab/modern-app 0.18.16 → 0.18.17
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 +15 -0
- package/package.json +1 -1
- package/skills/modern-app/references/api.md +53 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.18.17] - 2026-09-03
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- **`AppConfig.auth` (the boot-time auth gate) and its `AuthGateConfig`/`AuthGateContext`
|
|
8
|
+
types were entirely undocumented in both reference docs** — the feature has a full worked
|
|
9
|
+
example in the README but no type reference anywhere a consumer would look one up. Also
|
|
10
|
+
documented `app.user` (the authenticated-user getter), and added `enter`/`initialLoad`/
|
|
11
|
+
`useIntercept` — three more real `AppConfig` fields missing specifically from
|
|
12
|
+
`skills/modern-app/references/api.md`.
|
|
13
|
+
- **`FallbackRouteConfig.title` was dropped by `0.18.13`**, which only touched the `render`
|
|
14
|
+
callback's context type and didn't notice it removed the field. Restored in both docs.
|
|
15
|
+
Found by a new internal tool (`type-doc-check.js`) that diffs hand-copied TS interface doc
|
|
16
|
+
snippets against source.
|
|
17
|
+
|
|
3
18
|
## [0.18.16] - 2026-09-03
|
|
4
19
|
|
|
5
20
|
### Fixed
|
package/package.json
CHANGED
|
@@ -19,6 +19,18 @@ interface AppConfig {
|
|
|
19
19
|
/** Fallback rendered on 404 or unhandled errors. */
|
|
20
20
|
fallback?: FallbackRouteConfig;
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Global auth/authorization guard, called before every navigation.
|
|
24
|
+
* `string` = redirect, `false` = cancel (403), `true`/undefined = proceed.
|
|
25
|
+
*/
|
|
26
|
+
enter?: (ctx: RouteContext) => Promise<string | boolean> | string | boolean;
|
|
27
|
+
|
|
28
|
+
/** Auto-navigate to the current URL on load. Default: true */
|
|
29
|
+
initialLoad?: boolean;
|
|
30
|
+
|
|
31
|
+
/** Intercept `<a>` tag clicks for client-side routing. Default: true */
|
|
32
|
+
useIntercept?: boolean;
|
|
33
|
+
|
|
22
34
|
/** Layout configuration. Currently only 'sidebar' is supported. */
|
|
23
35
|
layout: LayoutConfig;
|
|
24
36
|
|
|
@@ -27,6 +39,12 @@ interface AppConfig {
|
|
|
27
39
|
|
|
28
40
|
/** i18next options plus optional plugins array. Omit to skip i18n. */
|
|
29
41
|
i18n?: I18nInitOptions;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Boot-time auth gate. When set, resolves the session via `me()` before the app shell
|
|
45
|
+
* is built. Omit for full backward compatibility (no gate). See `AuthGateConfig` below.
|
|
46
|
+
*/
|
|
47
|
+
auth?: AuthGateConfig;
|
|
30
48
|
}
|
|
31
49
|
```
|
|
32
50
|
|
|
@@ -162,6 +180,9 @@ interface RouteContext {
|
|
|
162
180
|
|
|
163
181
|
```typescript
|
|
164
182
|
interface FallbackRouteConfig {
|
|
183
|
+
/** Sets `document.title` when the fallback renders. */
|
|
184
|
+
title?: string;
|
|
185
|
+
|
|
165
186
|
render: (context: RouteContext & { error: RouteError }) => RenderResult | Promise<RenderResult>;
|
|
166
187
|
}
|
|
167
188
|
```
|
|
@@ -196,6 +217,37 @@ interface NotificationOptions {
|
|
|
196
217
|
|
|
197
218
|
---
|
|
198
219
|
|
|
220
|
+
## `AuthGateConfig` / `AuthGateContext`
|
|
221
|
+
|
|
222
|
+
The framework owns only the orchestration (check → branch → reload) — session lookup/login itself
|
|
223
|
+
(HTTP), the user/permission shape, and mid-session 401 handling belong to the app (or
|
|
224
|
+
`@iyulab/enterprise`'s `createAuthClient`/`createODataService`).
|
|
225
|
+
|
|
226
|
+
```typescript
|
|
227
|
+
interface AuthGateConfig {
|
|
228
|
+
/** Resolve the current session. Return a value for authenticated, `null`/`undefined` for not. */
|
|
229
|
+
me: () => Promise<unknown | null | undefined> | unknown | null | undefined;
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Renders login UI into `context.root` when unauthenticated. Call `context.onSuccess()` on
|
|
233
|
+
* success. Return a cleanup function to have it called on app load/`unload`.
|
|
234
|
+
*/
|
|
235
|
+
renderLogin: (context: AuthGateContext) => (() => void) | void;
|
|
236
|
+
|
|
237
|
+
/** Called once authenticated, right before the app shell is built. */
|
|
238
|
+
onAuthenticated?: (user: unknown) => void | Promise<void>;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
interface AuthGateContext {
|
|
242
|
+
/** Root element to render the login UI into (same as `AppConfig.root`, default `document.body`). */
|
|
243
|
+
root: Element;
|
|
244
|
+
/** Call on successful login — the app (re)loads and the shell appears. */
|
|
245
|
+
onSuccess: () => void;
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
199
251
|
## `app` singleton methods
|
|
200
252
|
|
|
201
253
|
| Method | Signature | Description |
|
|
@@ -216,5 +268,6 @@ interface NotificationOptions {
|
|
|
216
268
|
| `config` | `AppConfig \| undefined` | Current config passed to `load()` |
|
|
217
269
|
| `router` | `Router \| undefined` | Underlying `@iyulab/router` instance |
|
|
218
270
|
| `screen` | `ScreenSize \| undefined` | Current responsive screen size |
|
|
271
|
+
| `user` | `unknown` | Authenticated user when the `auth` boot gate is used; `undefined` if unauthenticated or unused |
|
|
219
272
|
| `theme` | `Theme` (static) | Theme utility (`get`, `set`, `isInitialized`) |
|
|
220
273
|
| `i18n` | `i18next` | Raw i18next instance |
|