@lingxia/types 0.9.0 → 0.10.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/src/ui/index.ts CHANGED
@@ -38,13 +38,33 @@ export interface ActionSheetResult {
38
38
  export type PageQueryValue = string | number | boolean | null | undefined;
39
39
  export type PageQuery = Record<string, PageQueryValue>;
40
40
 
41
+ /**
42
+ * Target page for `navigateTo` / `redirectTo` / `switchTab` / `reLaunch`.
43
+ *
44
+ * Pass **exactly one** of `page` or `path` — there is **no `url` field**:
45
+ * - `page` — a configured page **name** from `lingxia.yaml` / `lxapp.json`
46
+ * (e.g. `"pullToRefresh"`), resolved to its route by the page registry.
47
+ * - `path` — the full page **route**, e.g. `"/pages/pulltorefresh/index"`.
48
+ *
49
+ * Both are discoverable with `lxdev lxapp pages`, which lists every page's
50
+ * `name` and `path`; `lxdev lxapp nav to|relaunch|redirect|switch-tab <name>`
51
+ * drives navigation by name when automating.
52
+ */
41
53
  export type PageTargetOptions =
42
54
  | {
55
+ /**
56
+ * Configured page **name** from `lingxia.yaml` / `lxapp.json`
57
+ * (e.g. `"pullToRefresh"`). Mutually exclusive with `path`.
58
+ */
43
59
  page: string;
44
60
  path?: never;
45
61
  query?: PageQuery;
46
62
  }
47
63
  | {
64
+ /**
65
+ * Full page **route**, e.g. `"/pages/pulltorefresh/index"`.
66
+ * Mutually exclusive with `page`.
67
+ */
48
68
  path: string;
49
69
  page?: never;
50
70
  query?: PageQuery;
@@ -98,77 +118,42 @@ export interface SetTabBarItemOptions {
98
118
  selectedIconPath?: string;
99
119
  }
100
120
 
101
- export type SurfaceQueryValue = PageQueryValue;
102
- export type SurfaceQuery = PageQuery;
103
-
104
- export type SurfacePageTargetOptions =
105
- | {
106
- page: string;
107
- path?: never;
108
- url?: never;
109
- query?: SurfaceQuery;
110
- }
111
- | {
112
- path: string;
113
- page?: never;
114
- url?: never;
115
- query?: SurfaceQuery;
116
- };
117
-
118
- export type SurfaceUrlTargetOptions = {
119
- url: string;
120
- page?: never;
121
- path?: never;
122
- query?: never;
123
- };
124
-
125
- export type SurfaceTargetOptions = SurfacePageTargetOptions | SurfaceUrlTargetOptions;
121
+ // ── Adaptive Surface Layout ─────────────────────────────────────────────────
122
+ // The form is expressed by the `as` field on `lx.openSurface({ page, as })`; the
123
+ // Host arbitrates the realized platform form (split pane on larger screens,
124
+ // full-screen drill-in on compact screens).
126
125
 
127
126
  /**
128
- * Overlay surface size value.
127
+ * Size hint for an overlay surface (aside / float).
129
128
  *
130
- * - number: absolute size, must be > 0
131
- * - `${number}%`: percentage size, must be > 0% and <= 100%
129
+ * - number: absolute px, must be > 0
130
+ * - `${number}%`: percentage of the container, 0 < N ≤ 100
132
131
  */
133
132
  export type OverlaySurfaceSizeValue = number | `${number}%`;
134
133
 
135
134
  export interface OverlaySurfaceSize {
136
- /** Width for overlay surface. */
135
+ /** Width hint. */
137
136
  width?: OverlaySurfaceSizeValue;
138
- /** Height for overlay surface. */
137
+ /** Height hint. */
139
138
  height?: OverlaySurfaceSizeValue;
140
139
  }
141
140
 
142
- /**
143
- * Overlay surface: a webview composited on top of the host activity's
144
- * content. Cross-platform. Covers the screen (or a fraction of it) until
145
- * closed; coexists with native media preview at the same z-tier — the
146
- * later-added overlay or preview wins compositing order.
147
- */
148
- export type OverlaySurfaceOptions = SurfaceTargetOptions & {
149
- kind: 'overlay';
150
- position?: 'center' | 'bottom' | 'left' | 'right' | 'top';
151
- size?: OverlaySurfaceSize;
152
- };
153
-
154
- export interface WindowSurfaceSize {
155
- /** Window width, must be a positive number. */
156
- width?: number;
157
- /** Window height, must be a positive number. */
158
- height?: number;
159
- }
141
+ /** Edge an aside docks to; the Host decides the realized form by screen size. */
142
+ export type SurfaceEdge = 'left' | 'right' | 'top' | 'bottom';
143
+
144
+ /** Where a float popup anchors (default `center`). */
145
+ export type SurfaceFloatPosition = 'center' | 'top' | 'bottom' | 'left' | 'right';
160
146
 
161
147
  /**
162
- * Window-kind surfaces are macOS-only. Android, iOS, and Harmony reject
163
- * `kind: 'window'` at open() and surface a `surface_open_failed` error;
164
- * use `OverlaySurfaceOptions` for cross-platform code.
148
+ * The window's adaptive context, delivered to `lx.onSurfaceContext()` so an
149
+ * lxapp can self-adapt (e.g. switch column count by `sizeClass`).
165
150
  */
166
- export type WindowSurfaceOptions = SurfaceTargetOptions & {
167
- kind: 'window';
168
- size?: WindowSurfaceSize;
169
- };
170
-
171
- export type SurfaceOpenOptions = OverlaySurfaceOptions | WindowSurfaceOptions;
151
+ export interface SurfaceContext {
152
+ /** compact (<600) / medium (600–840) / expanded (>840), with hysteresis. */
153
+ sizeClass: 'compact' | 'medium' | 'expanded';
154
+ /** In compact, the bottom region belongs to the app content. */
155
+ bottomOwner: 'app';
156
+ }
172
157
 
173
158
  export interface CapsuleRect {
174
159
  width?: number;