@iyulab/modern-app 0.37.2 → 0.38.0

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 CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.38.0] - 2026-10-06
4
+
5
+ ### Added
6
+
7
+ - **`u-info-field` `tone="warning"`** — "needs attention, not wrong" (a deadline coming up, a rate under target
8
+ but within limits). Paints the value and the trend with `--u-warning-color-strong`, like `positive`/`negative`
9
+ use the success/danger tokens. It is never inferred from `trend`, so existing fields are unchanged.
10
+ - **`auth.renderUnavailable({ root, error, retry })`** on the boot auth gate — drawn when `me()` throws, that is,
11
+ when the session could not be checked (server down, offline). The gate no longer has only "signed in" or
12
+ "show the login screen": `me()` should throw rather than return `null` when it got no answer, and `retry()`
13
+ checks again. Without `renderUnavailable`, `app.load()` rejects with the error as before.
14
+
15
+ ### Documentation
16
+
17
+ - The auth gate examples follow the three-state session lookup of `@iyulab/enterprise` 0.25
18
+ (`fetchMe()` returns `{ status }`): the README example used to pass the lookup straight through, which with
19
+ 0.25 would treat every answer as signed in.
20
+
3
21
  ## [0.37.2] - 2026-10-06
4
22
 
5
23
  ### Fixed
package/README.md CHANGED
@@ -182,8 +182,13 @@ const auth = createAuthClient<User, Cred>({ meUrl: '/api/auth/me', loginUrl: '/a
182
182
  await app.load({
183
183
  layout: { type: 'sidebar', /* ... */ },
184
184
  auth: {
185
- me: () => auth.fetchMe(), // null → 미인증 → renderLogin
185
+ me: async () => {
186
+ const s = await auth.fetchMe();
187
+ if (s.status === 'unknown') throw s.error; // 모름(서버 다운·오프라인) → renderUnavailable
188
+ return s.status === 'authenticated' ? s.user : null; // null → 미인증 → renderLogin
189
+ },
186
190
  renderLogin: ({ root, onSuccess }) => renderLoginPage(root, auth, onSuccess),
191
+ renderUnavailable: ({ root, retry }) => renderOfflinePage(root, retry),
187
192
  onAuthenticated: (user) => setPermissions((user as User).Permissions),
188
193
  },
189
194
  routes: [ /* ... */ ],
@@ -193,6 +198,7 @@ app.user; // 인증된 현재 사용자(미인증/미사용 시 undefined)
193
198
  ```
194
199
 
195
200
  - `me()` 가 값을 반환하면 셸 로드, `null`/`undefined` 면 `renderLogin({ root, onSuccess })`.
201
+ - `me()` 가 **던지면** 세션을 «모름» 으로 보고 로그인 UI 를 그리지 않는다 — `renderUnavailable({ root, error, retry })` 를 그리고, 없으면 `app.load()` 가 그 오류로 실패한다. 서버가 잠깐 503 을 낸 것을 «미인증» 으로 돌려주면 로그인된 사용자가 로그인 화면으로 간다.
196
202
  - 로그인 성공 시 `onSuccess()` 를 호출하면 앱이 재로드되어 셸이 나타나고 로그인 UI 는 정리된다.
197
203
  - `auth` 미지정 시 완전히 하위호환(게이트 없이 기존대로 로드).
198
204
 
package/dist/App.d.ts CHANGED
@@ -13,7 +13,7 @@ declare class App {
13
13
  private _router?;
14
14
  private _screen?;
15
15
  private _user?;
16
- private _loginTeardown?;
16
+ private _gateTeardown?;
17
17
  private constructor();
18
18
  /** 싱글톤 인스턴스 반환 */
19
19
  static get instance(): App;
package/dist/App.js CHANGED
@@ -46,18 +46,30 @@ var l = class o {
46
46
  await t.init(a.i18n);
47
47
  }
48
48
  if (a.auth) {
49
- let e = await a.auth.me();
50
- if (e == null) {
51
- let e = a.root || document.body, t = a.auth.renderLogin({
49
+ let e = a.root || document.body, t = () => {
50
+ this.load(a);
51
+ }, n;
52
+ try {
53
+ n = await a.auth.me();
54
+ } catch (n) {
55
+ if (!a.auth.renderUnavailable) throw n;
56
+ let r = a.auth.renderUnavailable({
52
57
  root: e,
53
- onSuccess: () => {
54
- this.load(a);
55
- }
58
+ error: n,
59
+ retry: t
56
60
  });
57
- t && (this._loginTeardown = t);
61
+ r && (this._gateTeardown = r);
58
62
  return;
59
63
  }
60
- this._user = e, await a.auth.onAuthenticated?.(e);
64
+ if (n == null) {
65
+ let n = a.auth.renderLogin({
66
+ root: e,
67
+ onSuccess: t
68
+ });
69
+ n && (this._gateTeardown = n);
70
+ return;
71
+ }
72
+ this._user = n, await a.auth.onAuthenticated?.(n);
61
73
  }
62
74
  let o = a.root || document.body;
63
75
  this._layout = await this.createLayout(o, a.layout), this._screen = new e({
@@ -77,7 +89,7 @@ var l = class o {
77
89
  });
78
90
  }
79
91
  unload() {
80
- this._loginTeardown &&= (this._loginTeardown(), void 0), this._user = void 0, this._screen &&= (this._screen.destroy(), void 0), this._layout &&= (this._layout.remove(), void 0), this._router &&= (this._router.destroy(), void 0), this._config &&= void 0;
92
+ this._gateTeardown &&= (this._gateTeardown(), void 0), this._user = void 0, this._screen &&= (this._screen.destroy(), void 0), this._layout &&= (this._layout.remove(), void 0), this._router &&= (this._router.destroy(), void 0), this._config &&= void 0;
81
93
  }
82
94
  navigate(e) {
83
95
  this._router?.go(e);
@@ -3,7 +3,7 @@ type ElementParts = 'host' | 'label' | 'value' | 'unit' | 'trend';
3
3
  export type InfoFieldFormat = 'number' | 'currency' | 'date';
4
4
  export type InfoFieldSize = 'default' | 'lg';
5
5
  export type InfoFieldTrend = 'up' | 'down' | 'flat';
6
- export type InfoFieldTone = 'positive' | 'negative' | 'neutral';
6
+ export type InfoFieldTone = 'positive' | 'negative' | 'warning' | 'neutral';
7
7
  /** 값이 "아직 없음"인가 — `0` 과 `false` 는 **값이다**. */
8
8
  export declare function isBlank(v: unknown): boolean;
9
9
  /**
@@ -89,8 +89,11 @@ export declare class InfoField extends StyledElement<ElementParts> {
89
89
  * direction-to-sentiment mapping (e.g. a falling "open tickets" count is `positive`).
90
90
  *
91
91
  * Colors the value text itself, independent of `trend` — a static "balance due" figure can be
92
- * toned `negative` without a trend arrow. `neutral` has no visual effect on the value text
93
- * (it already renders at full strength; only `positive`/`negative` stand out from it).
92
+ * toned `negative` without a trend arrow. `warning` is for "needs attention, not wrong" (a
93
+ * deadline coming up, a rate under target but within limits) and is never inferred from `trend`.
94
+ * `neutral` has no visual effect on the value text (it already renders at full strength; only
95
+ * `positive`/`negative`/`warning` stand out from it). Colors come from the theme's
96
+ * `--u-success|danger|warning-color-strong`.
94
97
  */
95
98
  tone?: InfoFieldTone;
96
99
  private get hasSlotted();
@@ -73,6 +73,10 @@ var t = e`
73
73
  color: var(--u-danger-color-strong, #C62828);
74
74
  }
75
75
 
76
+ .value.tone-warning {
77
+ color: var(--u-warning-color-strong, #8A4A00);
78
+ }
79
+
76
80
  .trend {
77
81
  font-size: var(--u-text-caption-size, 12px);
78
82
  margin-top: var(--u-space-3xs, 2px);
@@ -86,6 +90,10 @@ var t = e`
86
90
  color: var(--u-danger-color-strong, #C62828);
87
91
  }
88
92
 
93
+ .trend.tone-warning {
94
+ color: var(--u-warning-color-strong, #8A4A00);
95
+ }
96
+
89
97
  .trend.tone-neutral {
90
98
  color: var(--u-txt-color-weak, #616161);
91
99
  }
@@ -102,15 +102,21 @@ export interface AppConfig {
102
102
  i18n?: I18nInitOptions;
103
103
  /**
104
104
  * 부팅 인증 게이트(선택). 지정하면 앱 셸을 만들기 전에 `me()` 로 세션을 판정하여
105
- * 인증 시 셸 로드, 미인증 시 `renderLogin` 으로 로그인 UI 를 띄운다.
105
+ * 인증 시 셸 로드, 미인증 시 `renderLogin` 으로 로그인 UI 를 띄운다. `me()` 가 던지면(세션 모름)
106
+ * `renderUnavailable` 을 그린다.
106
107
  * @see AuthGateConfig
107
108
  * @example
108
109
  * ```typescript
109
110
  * app.load({
110
111
  * layout: { type: 'sidebar', ... },
111
112
  * auth: {
112
- * me: () => authClient.fetchMe(), // null → 미인증
113
+ * me: async () => { // @iyulab/enterprise createAuthClient
114
+ * const s = await authClient.fetchMe();
115
+ * if (s.status === 'unknown') throw s.error; // 모름 — 로그인이 아니라 renderUnavailable
116
+ * return s.status === 'authenticated' ? s.user : null; // null → 미인증
117
+ * },
113
118
  * renderLogin: ({ root, onSuccess }) => renderLoginPage(root, onSuccess),
119
+ * renderUnavailable: ({ root, retry }) => renderOfflinePage(root, retry),
114
120
  * onAuthenticated: (user) => setPermissions((user as User).Permissions),
115
121
  * },
116
122
  * routes: [ ... ],
@@ -4,7 +4,9 @@
4
4
  * `app.load({ auth })` 에 넘기면, 앱 셸(레이아웃·라우터)을 만들기 전에 세션을 판정한다:
5
5
  * `me()` 가 값을 반환하면 인증된 것으로 보고 셸을 로드하고, `null`/`undefined` 면
6
6
  * 미인증으로 보고 `renderLogin` 으로 로그인 UI 를 띄운다. 로그인 성공 시 `onSuccess()` 를
7
- * 호출하면 앱이 (재)로드되어 셸이 나타난다.
7
+ * 호출하면 앱이 (재)로드되어 셸이 나타난다. `me()` 가 **던지면** 세션을 «모름»(서버 다운·오프라인)
8
+ * 으로 보고 로그인 UI 를 그리지 않는다 — `renderUnavailable` 이 있으면 그것을, 없으면 `load` 가 그
9
+ * 오류로 실패한다.
8
10
  *
9
11
  * 프레임워크는 인증의 **오케스트레이션**(판정 → 분기 → 재로드)만 소유한다. 세션 조회/로그인
10
12
  * 자체(HTTP)와 사용자·권한 형태, 세션-중 401 처리는 앱/`@iyulab/enterprise` 가 소유한다.
@@ -15,9 +17,19 @@ export interface AuthGateContext {
15
17
  /** 로그인 성공 시 호출한다. 앱이 (재)로드되어 셸을 띄운다(이때 `me()` 는 사용자를 반환해야 한다). */
16
18
  onSuccess: () => void;
17
19
  }
20
+ /** `renderUnavailable` 이 받는 맥락 — 세션을 확인하지 못했을 때. */
21
+ export interface AuthGateUnavailableContext {
22
+ /** 안내 UI 를 그릴 루트 요소(= `app.load` 의 `root`, 기본 `document.body`). */
23
+ root: Element;
24
+ /** `me()` 가 던진 값. */
25
+ error: unknown;
26
+ /** 다시 확인한다 — 앱이 (재)로드되어 `me()` 를 다시 부른다(재시도 버튼·`online` 이벤트에서). */
27
+ retry: () => void;
28
+ }
18
29
  export interface AuthGateConfig {
19
30
  /**
20
- * 현재 세션 조회. 값을 반환하면 인증, `null`/`undefined` 면 미인증으로 본다.
31
+ * 현재 세션 조회. 값을 반환하면 인증, `null`/`undefined` 면 미인증으로 본다. **세션을 확인하지
32
+ * 못했으면 던진다**(서버 다운·오프라인) — 그것을 `null` 로 돌려주면 로그인된 사용자가 로그인 화면으로 간다.
21
33
  * 동기/비동기 모두 허용한다.
22
34
  */
23
35
  me: () => Promise<unknown | null | undefined> | unknown | null | undefined;
@@ -26,6 +38,11 @@ export interface AuthGateConfig {
26
38
  * 정리 함수를 반환하면 앱 로드/`unload` 시 호출되어 로그인 UI 를 제거한다.
27
39
  */
28
40
  renderLogin: (context: AuthGateContext) => (() => void) | void;
41
+ /**
42
+ * `me()` 가 던졌을 때(세션 모름) `context.root` 에 안내 UI 를 그린다(선택). `context.retry()` 로 다시
43
+ * 확인한다. 정리 함수를 반환하면 앱 로드/`unload` 시 호출된다. 없으면 `load` 가 `me()` 의 오류로 실패한다.
44
+ */
45
+ renderUnavailable?: (context: AuthGateUnavailableContext) => (() => void) | void;
29
46
  /**
30
47
  * 인증 성공 후, 앱 셸을 만들기 직전에 호출된다(선택).
31
48
  * 사용자별 라우트/메뉴 필터 등 셸 구성 전 처리를 여기서 한다.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@iyulab/modern-app",
3
3
  "description": "web-framework by iyulab based on lit-element",
4
- "version": "0.37.2",
4
+ "version": "0.38.0",
5
5
  "keywords": [
6
6
  "iyulab",
7
7
  "web-framework",
@@ -228,7 +228,11 @@ The framework owns only the orchestration (check → branch → reload) — sess
228
228
 
229
229
  ```typescript
230
230
  interface AuthGateConfig {
231
- /** Resolve the current session. Return a value for authenticated, `null`/`undefined` for not. */
231
+ /**
232
+ * Resolve the current session. Return a value for authenticated, `null`/`undefined` for not.
233
+ * **Throw when the session could not be checked** (server down, offline) — returning `null`
234
+ * there would send a signed-in user to the login screen.
235
+ */
232
236
  me: () => Promise<unknown | null | undefined> | unknown | null | undefined;
233
237
 
234
238
  /**
@@ -237,6 +241,14 @@ interface AuthGateConfig {
237
241
  */
238
242
  renderLogin: (context: AuthGateContext) => (() => void) | void;
239
243
 
244
+ /**
245
+ * Renders a "can't reach the server" view into `context.root` when `me()` throws. Call
246
+ * `context.retry()` to check again (a retry button, the `online` event). Return a cleanup
247
+ * function to have it called on app load/`unload`. Without it, `app.load()` rejects with
248
+ * `me()`'s error.
249
+ */
250
+ renderUnavailable?: (context: AuthGateUnavailableContext) => (() => void) | void;
251
+
240
252
  /** Called once authenticated, right before the app shell is built. */
241
253
  onAuthenticated?: (user: unknown) => void | Promise<void>;
242
254
  }
@@ -247,6 +259,15 @@ interface AuthGateContext {
247
259
  /** Call on successful login — the app (re)loads and the shell appears. */
248
260
  onSuccess: () => void;
249
261
  }
262
+
263
+ interface AuthGateUnavailableContext {
264
+ /** Root element to render into (same as `AppConfig.root`, default `document.body`). */
265
+ root: Element;
266
+ /** What `me()` threw. */
267
+ error: unknown;
268
+ /** Check again — the app (re)loads and calls `me()` again. */
269
+ retry: () => void;
270
+ }
250
271
  ```
251
272
 
252
273
  ---
@@ -40,7 +40,7 @@ and those are different states of the business. So the component owns the rule.
40
40
  | `size` | `'default'\|'lg'` | `'default'` | ✓ | `'lg'` renders the value at the `title` type-scale step — for dashboard KPI tiles composed inside `u-info-section` |
41
41
  | `trend` | `'up'\|'down'\|'flat'` | — | | Trend direction; renders a trend indicator when set, alongside `trendLabel`; pair with trendLabel for an accessible name — trend alone conveys direction by color only |
42
42
  | `trendLabel` | `string` | — | | Trend copy, e.g. `"+12% vs last month"` — wording is the consumer's responsibility |
43
- | `tone` | `'positive'\|'negative'\|'neutral'` | — | | Explicit tone override; resolves from `trend` when unset (`up→positive`, `down→negative`, `flat`/unset→`neutral`) but always wins over inference. Colors the value text itself, independent of `trend` — a static figure (e.g. a balance due) can be toned `negative` with no trend arrow |
43
+ | `tone` | `'positive'\|'negative'\|'warning'\|'neutral'` | — | | Explicit tone override; resolves from `trend` when unset (`up→positive`, `down→negative`, `flat`/unset→`neutral`) but always wins over inference. Colors the value text itself, independent of `trend` — a static figure (e.g. a balance due) can be toned `negative` with no trend arrow. `warning` means "needs attention, not wrong" (a deadline coming up, a rate under target but within limits) and is never inferred |
44
44
 
45
45
  ⚠ `numeric` no longer right-aligns (it did before 0.25.0). A field is a label/value pair that owns
46
46
  one grid cell, with no neighbouring figures to line up, so right-aligning only pushed the value
@@ -73,8 +73,8 @@ stay level:
73
73
  blank="No downtime recorded for the failures"></u-info-field>
74
74
  ```
75
75
 
76
- `tone` colors a blank value too, so a reason that needs attention takes `tone="negative"`. Set it
77
- conditionally (`tone=${mttr == null ? 'negative' : undefined}`) — otherwise the value is toned
76
+ `tone` colors a blank value too, so a reason that needs attention takes `tone="warning"`. Set it
77
+ conditionally (`tone=${mttr == null ? 'warning' : undefined}`) — otherwise the value is toned
78
78
  as well once it exists.
79
79
 
80
80
  ## CSS Parts
@@ -99,3 +99,4 @@ as well once it exists.
99
99
  | `--u-text-label-size` | Unit size |
100
100
  | `--u-success-color-strong` | `tone="positive"` color (value and trend) |
101
101
  | `--u-danger-color-strong` | `tone="negative"` color (value and trend) |
102
+ | `--u-warning-color-strong` | `tone="warning"` color (value and trend) |