lecodes-sdk 2.0.8 → 2.0.10
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/dist/global.d.ts +3 -0
- package/dist/host.d.ts +6 -2
- package/dist/types/g2/Scene2D.d.ts +4 -0
- package/dist/types/gl/Light.d.ts +31 -7
- package/dist/types/gl/Scene.d.ts +4 -0
- package/dist/types/inject.d.ts +1 -1
- package/dist/types/runtime/misc.d.ts +4 -0
- package/dist/types/ui/NativeView.d.ts +3 -0
- package/dist/types/ui/UI.d.ts +1 -0
- package/dist/types/ui/UILayer.d.ts +25 -0
- package/dist/types/ui/UIModal.d.ts +20 -16
- package/dist/types/ui/UIPopover.d.ts +5 -3
- package/dist/types/ui/UIVideo.d.ts +3 -0
- package/dist/types/ui/UIWidget.d.ts +25 -24
- package/dist/types/ui/presentable.d.ts +10 -0
- package/dist/types/ui/transitions.d.ts +2 -1
- package/dist/types/ui/tree.d.ts +1 -0
- package/dist/types/version.d.ts +1 -1
- package/dist/types.json +1 -1
- package/package.json +1 -1
- package/prompts/3d-scene-files.md +3 -3
- package/prompts/3d-scene.md +1 -1
- package/prompts/core.md +1 -1
- package/prompts/dist/3d-app.md +4 -4
- package/prompts/ui.md +3 -7
- package/src/bridges/gl.d.ts +5 -0
- package/src/bridges/tree.d.ts +24 -12
- package/src/chisel.ts +1 -1
- package/src/compile/assetMacro.ts +69 -4
- package/src/compile/bundler.ts +10 -3
- package/src/g2/Scene2D.ts +10 -0
- package/src/gl/Light.ts +257 -194
- package/src/gl/Material.ts +3 -0
- package/src/gl/Scene.ts +11 -1
- package/src/host.d.ts +6 -2
- package/src/inject.ts +1 -0
- package/src/runtime/misc.ts +4 -0
- package/src/ui/NativeView.ts +11 -0
- package/src/ui/UI.ts +1 -0
- package/src/ui/UIBottomSheet.ts +8 -7
- package/src/ui/UILayer.ts +88 -0
- package/src/ui/UIModal.ts +59 -43
- package/src/ui/UINode.ts +9 -1
- package/src/ui/UIPopover.ts +23 -9
- package/src/ui/UIVideo.ts +11 -0
- package/src/ui/UIWidget.ts +70 -44
- package/src/ui/presentable.ts +11 -1
- package/src/ui/transitions.ts +36 -7
- package/src/ui/tree.ts +4 -0
- package/src/version.ts +1 -1
- package/tests/helpers/fakeTree.ts +7 -3
package/dist/global.d.ts
CHANGED
|
@@ -124,6 +124,7 @@ declare global {
|
|
|
124
124
|
const UIImage: typeof SDK.UIImage
|
|
125
125
|
const UIInput: typeof SDK.UIInput
|
|
126
126
|
const UIModal: typeof SDK.UIModal
|
|
127
|
+
const UIOverlay: typeof SDK.UIOverlay
|
|
127
128
|
const UIPager: typeof SDK.UIPager
|
|
128
129
|
const UIPopover: typeof SDK.UIPopover
|
|
129
130
|
const UIRow: typeof SDK.UIRow
|
|
@@ -482,6 +483,7 @@ declare global {
|
|
|
482
483
|
type StopOptions = SDK.StopOptions
|
|
483
484
|
type StoredFile = SDK.StoredFile
|
|
484
485
|
type StoredImage = SDK.StoredImage
|
|
486
|
+
type SvgSource = SDK.SvgSource
|
|
485
487
|
type System<K extends string, S extends SystemHost = Scene, E extends EventMap = {}> = SDK.System<K, S, E>
|
|
486
488
|
type SystemHost = SDK.SystemHost
|
|
487
489
|
type TabDef = SDK.TabDef
|
|
@@ -556,6 +558,7 @@ declare global {
|
|
|
556
558
|
type UIVideoStyle = SDK.UIVideoStyle
|
|
557
559
|
type UIVirtualizedList<T = unknown> = SDK.UIVirtualizedList<T>
|
|
558
560
|
type UIWidget = SDK.UIWidget
|
|
561
|
+
type UIWidgetContent = SDK.UIWidgetContent
|
|
559
562
|
type UIWidgetStyle = SDK.UIWidgetStyle
|
|
560
563
|
type Unit = SDK.Unit
|
|
561
564
|
type UnlitMaterialDef = SDK.UnlitMaterialDef
|
package/dist/host.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
// JS-runtime globals provided by the host engine (web viewer / desktop / iOS), NOT by the SDK.
|
|
2
2
|
// Declared only so SDK and user code type-check — never bundled or injected.
|
|
3
3
|
|
|
4
|
+
// The one SDK type the macros return: an SVG image source, the same `SvgSource` a project has as
|
|
5
|
+
// a global (build-types.ts points this import into dist/types when it copies the file).
|
|
6
|
+
import type { SvgSource } from "./types/runtime/misc"
|
|
7
|
+
|
|
4
8
|
declare global {
|
|
5
9
|
function setTimeout(handler: (...args: any[]) => void, timeout?: number): number
|
|
6
10
|
function setInterval(handler: (...args: any[]) => void, timeout?: number): number
|
|
@@ -33,7 +37,7 @@ declare global {
|
|
|
33
37
|
function asset(path: `${string}.json`): any
|
|
34
38
|
/** Compile-time macro: `asset('./logo.svg')` yields the file as an SVG image source — for
|
|
35
39
|
* `UIImage(...)` and `bgImage`. */
|
|
36
|
-
function asset(path: `${string}.svg`):
|
|
40
|
+
function asset(path: `${string}.svg`): SvgSource
|
|
37
41
|
/** Compile-time macro: `asset('./hero.png')` is desugared by the bundler into the module import
|
|
38
42
|
* for that resource. The file must exist — a path that resolves to nothing fails the compile
|
|
39
43
|
* (`asset not found: ./hero.png (main.ts:3)`); there is no runtime fallback. Calls inside
|
|
@@ -53,7 +57,7 @@ declare global {
|
|
|
53
57
|
* (e.g. `"lucide:bell"`), string literal only. Recolor via `{ color }`: a hex LITERAL is baked
|
|
54
58
|
* into the SVG at compile time, a token/expression is applied as a tint (as is the `tintColor`
|
|
55
59
|
* style prop). */
|
|
56
|
-
function assetIcon(id: string, opts?: { color?: string }):
|
|
60
|
+
function assetIcon(id: string, opts?: { color?: string }): SvgSource
|
|
57
61
|
|
|
58
62
|
/** Type-only editor convenience: the style object type of a UI element. `Style<UIButton>` (or
|
|
59
63
|
* `Style<typeof myButton>`) is what you'd pass to `el.style(...)` — for typing reusable style
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type ColorInput } from "../core/color";
|
|
2
2
|
import { type Aspect, type AspectCtor, type FieldOf, type TargetOf } from "../core/Aspect";
|
|
3
3
|
import { Presentable, type DismissOptions, type PresentOptions } from "../ui/presentable";
|
|
4
|
+
import { type UIWidgetContent } from "../ui/UILayer";
|
|
4
5
|
import { type Vec2Like } from "../math/vec";
|
|
5
6
|
import type { ClickEvent, TouchStartEvent } from "../runtime/touch";
|
|
6
7
|
import { Camera2D } from "./Camera2D";
|
|
@@ -67,6 +68,9 @@ export declare class Scene2D implements Presentable {
|
|
|
67
68
|
/** @deprecated Renamed `onBack` (2026-09-26). An alias for the projects compiled before the
|
|
68
69
|
* rename; removed with the release that recompiles them. */
|
|
69
70
|
onBackPressed(callback: () => void): this;
|
|
71
|
+
/** The UI over the scene — widgets (a HUD, a dialog), laid out over the scene while it is
|
|
72
|
+
* presented; touches outside a widget's box reach the scene. */
|
|
73
|
+
setContent(content: UIWidgetContent): this;
|
|
70
74
|
/** Make this the active scene — shows it as the current destination (replaces a screen /
|
|
71
75
|
* another scene; only the active scene renders). */
|
|
72
76
|
open(options?: PresentOptions): this;
|
package/dist/types/gl/Light.d.ts
CHANGED
|
@@ -73,6 +73,23 @@ export type PointOptions = {
|
|
|
73
73
|
*/
|
|
74
74
|
bakeArea?: readonly [number, number];
|
|
75
75
|
};
|
|
76
|
+
export type SpotOptions = {
|
|
77
|
+
/**
|
|
78
|
+
* Luminous power in lumens, as a point light's. The cone does not change the brightness: widen it and the
|
|
79
|
+
* same lumens light a larger patch at the same level. On its axis a spot is 4x brighter than a point light of
|
|
80
|
+
* the same lumens (its light is not spread over the whole sphere). Default 1000.
|
|
81
|
+
*/
|
|
82
|
+
intensity?: number;
|
|
83
|
+
color?: ColorInput;
|
|
84
|
+
/** Metres of influence along the cone, the performance knob as for a point light. Default 10. */
|
|
85
|
+
range?: number;
|
|
86
|
+
/** The cone's full angle in degrees, up to 180: past it the light contributes nothing. Default 45. */
|
|
87
|
+
angle?: number;
|
|
88
|
+
/** The full angle in degrees of the cone's fully lit core; the light fades from it out to `angle`. Default 0.75 x `angle`. */
|
|
89
|
+
innerAngle?: number;
|
|
90
|
+
/** A spot's shadow is one 2D shadow map (a point light's is a cubemap); off by default. */
|
|
91
|
+
castShadows?: boolean;
|
|
92
|
+
};
|
|
76
93
|
export declare class Light extends Node {
|
|
77
94
|
private _intensity;
|
|
78
95
|
/** Tween `intensity` / `color` (a flash, a sunrise) and the transform — see {@link Node.animateTo}. */
|
|
@@ -86,15 +103,22 @@ export declare class Light extends Node {
|
|
|
86
103
|
static sun(options?: SunOptions): Light;
|
|
87
104
|
/**
|
|
88
105
|
* A point light — a lamp, a muzzle flash, a fireball. Position it like any node.
|
|
89
|
-
*
|
|
90
|
-
* Feature-detected: hosts that predate it create the node and light nothing, which keeps a scene
|
|
91
|
-
* that adds atmosphere on top of its sun renderable everywhere. Check `Light.supportsPoint`
|
|
92
|
-
* before making one carry the scene.
|
|
93
106
|
*/
|
|
94
107
|
static point(options?: PointOptions): Light;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
108
|
+
_innerAngle: number;
|
|
109
|
+
/**
|
|
110
|
+
* A spot light — a flashlight, a headlight, a stage light. It shines along the node's forward (-Z): position
|
|
111
|
+
* it like any node and aim it with `lookAt`. Real time only: the lightmap bake takes no spot lights, so a spot
|
|
112
|
+
* lights the baked statics live too.
|
|
113
|
+
*/
|
|
114
|
+
static spot(options?: SpotOptions): Light;
|
|
115
|
+
/** A spot's full cone angle in degrees — live (a flashlight's focus). */
|
|
116
|
+
get angle(): number;
|
|
117
|
+
set angle(value: number);
|
|
118
|
+
/** A spot's fully lit core, full angle in degrees — live. Setting `angle` scales it along. */
|
|
119
|
+
get innerAngle(): number;
|
|
120
|
+
set innerAngle(value: number);
|
|
121
|
+
/** Live intensity (sun: lux, point / spot: lumens) — animate a flash without rebuilding the light. */
|
|
98
122
|
get intensity(): number;
|
|
99
123
|
set intensity(value: number);
|
|
100
124
|
_holdDark(dark: boolean): void;
|
package/dist/types/gl/Scene.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type ColorInput } from "../core/color";
|
|
2
2
|
import { type Aspect, type AspectCtor, type FieldOf, type TargetOf } from "../core/Aspect";
|
|
3
3
|
import { Presentable, type DismissOptions, type PresentOptions } from "../ui/presentable";
|
|
4
|
+
import { type UIWidgetContent } from "../ui/UILayer";
|
|
4
5
|
import type { ClickEvent, TouchStartEvent } from "../runtime/touch";
|
|
5
6
|
import type { FetchResponse } from "../runtime/fetch";
|
|
6
7
|
import { Camera } from "./Camera";
|
|
@@ -247,6 +248,9 @@ export declare class Scene implements Presentable {
|
|
|
247
248
|
/** @deprecated Renamed `onBack` (2026-09-26). An alias for the projects compiled before the
|
|
248
249
|
* rename; removed with the release that recompiles them. */
|
|
249
250
|
onBackPressed(callback: () => void): this;
|
|
251
|
+
/** The UI over the scene — widgets (a HUD, a dialog), laid out over the scene while it is
|
|
252
|
+
* presented; touches outside a widget's box reach the scene. `scene.setContent([hud])`. */
|
|
253
|
+
setContent(content: UIWidgetContent): this;
|
|
250
254
|
/** Make this the active scene — shows it as the current destination (replaces a screen /
|
|
251
255
|
* another scene; only the active scene renders). The runtime activates the engine as part of
|
|
252
256
|
* presenting the destination. */
|
package/dist/types/inject.d.ts
CHANGED
|
@@ -55,7 +55,7 @@ export { defineScene2d, Scene2dHandle } from "./g2/defineScene2d";
|
|
|
55
55
|
export type { Scene2dDef, Scene2dNodeDef, Scene2dEnv, SpriteSourceDef, TilemapSourceDef, Camera2dNodeDef, LoadedScene2d } from "./g2/defineScene2d";
|
|
56
56
|
export { cells, encodeCells, type CellsData } from "./g2/cells";
|
|
57
57
|
export { CameraFollow } from "./g2/scenarios2d";
|
|
58
|
-
export { UIScreen, type UIScreenStyle, UIRow, UIColumn, UIBox, type UIContainerStyle, UIText, type UITextStyle, UIButton, type UIButtonStyle, UIImage, type UIImageStyle, UIVideo, type UIVideoStyle, UIInput, UITextArea, type UIInputStyle, UIScrollable, type UIScrollableStyle, UIPager, type UIPagerStyle, UITabs, type UITabDef, defineTabs, type TabDef, type TabsHandle, UIWidget, type UIWidgetStyle, UIModal, type UIModalStyle, UIBottomSheet, type UIBottomSheetStyle, UIPopover, type UIPopoverStyle, UISpacer, type UISpacerStyle, UIVirtualizedList, Router, NativeView, type UINativeViewStyle, registerFont, __uiMap, __UIColumn, __UIRow, __UIBox, __UIButton, __UIScreen, __UIScrollable, __UIWidget, } from "./ui/UI";
|
|
58
|
+
export { UIScreen, type UIScreenStyle, UIRow, UIColumn, UIBox, type UIContainerStyle, UIText, type UITextStyle, UIButton, type UIButtonStyle, UIImage, type UIImageStyle, UIVideo, type UIVideoStyle, UIInput, UITextArea, type UIInputStyle, UIScrollable, type UIScrollableStyle, UIPager, type UIPagerStyle, UITabs, type UITabDef, defineTabs, type TabDef, type TabsHandle, UIWidget, type UIWidgetStyle, UIOverlay, type UIWidgetContent, UIModal, type UIModalStyle, UIBottomSheet, type UIBottomSheetStyle, UIPopover, type UIPopoverStyle, UISpacer, type UISpacerStyle, UIVirtualizedList, Router, NativeView, type UINativeViewStyle, registerFont, __uiMap, __UIColumn, __UIRow, __UIBox, __UIButton, __UIScreen, __UIScrollable, __UIWidget, } from "./ui/UI";
|
|
59
59
|
export { Presentable } from "./ui/UI";
|
|
60
60
|
export type { DismissOptions, PresentOptions, Transition, TransitionName, TransitionPose, TransitionSpec } from "./ui/UI";
|
|
61
61
|
export type { UINode, UINodeChild } from "./ui/UINode";
|
|
@@ -12,3 +12,7 @@ export type SvgSourceValue = {
|
|
|
12
12
|
};
|
|
13
13
|
/** Wrap raw SVG XML so it can be used as an image source. */
|
|
14
14
|
export declare const SvgSource: (svg: string) => SvgSourceValue;
|
|
15
|
+
/** The type of the value: what `SvgSource(xml)`, `assetIcon("lucide:bell")` and `asset("./logo.svg")`
|
|
16
|
+
* all return, and what `UIImage` / `bgImage` take — ONE name for an SVG image source, global to a
|
|
17
|
+
* project like the function (host.d.ts names it for the macros). */
|
|
18
|
+
export type SvgSource = SvgSourceValue;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type UIWidgetContent } from "./UILayer";
|
|
1
2
|
import { type DismissOptions, type PresentOptions } from "./presentable";
|
|
2
3
|
import { type BaseStyle, type DrawableStyle, type ElementStyle, type UIElementBase } from "./UINode";
|
|
3
4
|
export type UINativeViewStyle = ElementStyle & DrawableStyle;
|
|
@@ -26,6 +27,8 @@ export interface NativeView extends UIElementBase<UINativeViewStyle, DrawableSty
|
|
|
26
27
|
/** Subscribe to an event the native view emits (`map.on("markerTap", cb)`). */
|
|
27
28
|
on(event: string, callback: (data?: any) => void): this;
|
|
28
29
|
off(event: string, callback: (data?: any) => void): this;
|
|
30
|
+
/** The UI over the view when presented: widgets over it (`Presentable.setContent`). */
|
|
31
|
+
setContent(content: UIWidgetContent): this;
|
|
29
32
|
}
|
|
30
33
|
/**
|
|
31
34
|
* Create an instance of a host-registered platform view. `NativeView.isSupported(name)` reports
|
package/dist/types/ui/UI.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export { UIImage, type UIImageStyle } from './UIImage';
|
|
|
7
7
|
export { UIVideo, type UIVideoStyle } from './UIVideo';
|
|
8
8
|
export { UIInput, UITextArea, type UIInputStyle } from './UIInput';
|
|
9
9
|
export { UIWidget, type UIWidgetStyle } from './UIWidget';
|
|
10
|
+
export { UIOverlay, type UIWidgetContent } from './UILayer';
|
|
10
11
|
export { UIModal, type UIModalStyle } from './UIModal';
|
|
11
12
|
export { UIBottomSheet, type UIBottomSheetStyle } from './UIBottomSheet';
|
|
12
13
|
export { UIPopover, type UIPopoverStyle, type UIPopoverAnchor } from './UIPopover';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { UIWidget } from "./UIWidget";
|
|
2
|
+
export type UIWidgetContent = (UIWidget | null | undefined | false)[] | (() => (UIWidget | null | undefined | false)[]);
|
|
3
|
+
/**
|
|
4
|
+
* The app layer: the widgets above EVERY destination, always shown — a global loader, a mini-player
|
|
5
|
+
* that follows the user across screens, a toast with actions. Widgets that belong to a place go in
|
|
6
|
+
* that place instead: a dialog among its screen's children (`UIScreen(..., dialog)`), a HUD in
|
|
7
|
+
* `scene.setContent([hud])`. A widget shown with `show()` while it has no parent lands here.
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* UIOverlay.append(miniPlayer)
|
|
11
|
+
* miniPlayer.hide() // display: none — still here, ready for show()
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare const UIOverlay: Readonly<{
|
|
15
|
+
/** Add widgets at the end (on top). */
|
|
16
|
+
append(...widgets: (UIWidget | null | undefined | false)[]): void;
|
|
17
|
+
/** Insert widgets at `index` (0 = the bottom of the layer). */
|
|
18
|
+
insert(index: number, ...widgets: (UIWidget | null | undefined | false)[]): void;
|
|
19
|
+
/** Take widgets out of the layer (they stay valid; a dropped one is freed). */
|
|
20
|
+
remove(...widgets: (UIWidget | null | undefined | false)[]): void;
|
|
21
|
+
/** Replace the layer's widgets — a list, or a function for reactive content. */
|
|
22
|
+
setContent(content: UIWidgetContent): void;
|
|
23
|
+
/** The layer's widgets, bottom to top (a snapshot read from the runtime). */
|
|
24
|
+
readonly children: UIWidget[];
|
|
25
|
+
}>;
|
|
@@ -11,17 +11,20 @@ export type UIModalTransition = DrawableStyle & BaseStyle & {
|
|
|
11
11
|
};
|
|
12
12
|
/**
|
|
13
13
|
* A dialog: a `UIWidget` with the modal boilerplate built in. Comes with a scrim
|
|
14
|
-
* (`overlayColor: "rgba(0, 0, 0, 0.5)"` unless overridden), animates on `show()`/`hide()`
|
|
15
|
-
* (a 200 ms fade by default — swap the pose via
|
|
16
|
-
* `
|
|
17
|
-
* or the Android back button (disable via `dismissible(false)`). Everything else
|
|
18
|
-
* widget
|
|
19
|
-
*
|
|
14
|
+
* (`overlayColor: "rgba(0, 0, 0, 0.5)"` unless overridden), animates on `show()`/`hide()` and on
|
|
15
|
+
* a state block flipping its `display` (a 200 ms fade by default — swap the pose via
|
|
16
|
+
* `transition()`; the runtime plays it as tracks that never touch the style), and closes itself
|
|
17
|
+
* on a scrim tap or the Android back button (disable via `dismissible(false)`). Everything else
|
|
18
|
+
* is a plain widget: declare it where it belongs — among its screen's children, hidden until a
|
|
19
|
+
* tap (`display: "none"`), or shown with `show()` from anywhere, which puts a parentless modal in
|
|
20
|
+
* the app layer. A dialog bound to data (its display from a binding) is declared
|
|
21
|
+
* `dismissible(false)` and routes `onOverlayTap` / `onBack` into the data's dismiss, so the data
|
|
22
|
+
* stays what the screen shows.
|
|
20
23
|
*/
|
|
21
24
|
export interface UIModal extends UIWidget {
|
|
22
|
-
/**
|
|
25
|
+
/** Show and play the entrance transition. No-op while already open. */
|
|
23
26
|
show(): void;
|
|
24
|
-
/** Play the exit transition, then
|
|
27
|
+
/** Play the exit transition, then hide. No-op while closed or already closing. */
|
|
25
28
|
hide(): void;
|
|
26
29
|
/** True from `show()` until `hide()` starts (already false during the exit animation). */
|
|
27
30
|
readonly isOpen: boolean;
|
|
@@ -36,24 +39,24 @@ export interface UIModal extends UIWidget {
|
|
|
36
39
|
* ```
|
|
37
40
|
*/
|
|
38
41
|
transition(hidden: UIModalTransition): this;
|
|
39
|
-
/** Called when `show()
|
|
42
|
+
/** Called when the modal opens — `show()`, or a state block flipping its display. */
|
|
40
43
|
onOpen(callback: () => void): this;
|
|
41
|
-
/** Called when the modal starts closing — scrim tap, back button,
|
|
44
|
+
/** Called when the modal starts closing — scrim tap, back button, a `hide()` call, or a state
|
|
45
|
+
* block flipping its display. */
|
|
42
46
|
onClose(callback: () => void): this;
|
|
43
47
|
/** `dismissible(false)` keeps scrim taps and the back button from closing the modal
|
|
44
|
-
* (forced-choice dialogs). Default `true`. */
|
|
48
|
+
* (forced-choice dialogs, a dialog whose display is bound to data). Default `true`. */
|
|
45
49
|
dismissible(enabled: boolean): this;
|
|
46
50
|
}
|
|
47
51
|
export declare class ModalElement extends WidgetElement {
|
|
48
|
-
_open: boolean;
|
|
49
52
|
_dismissible: boolean;
|
|
50
53
|
_transition: UIModalTransition;
|
|
51
|
-
_closeTimer?: ReturnType<typeof setTimeout>;
|
|
52
54
|
readonly _openListeners: (() => void)[];
|
|
53
55
|
readonly _closeListeners: (() => void)[];
|
|
56
|
+
private _poseObj?;
|
|
57
|
+
private _poseKey;
|
|
54
58
|
constructor(style: UIModalStyle, children: UINodeChild[] | ChildrenFn);
|
|
55
59
|
private _pose;
|
|
56
|
-
private get _duration();
|
|
57
60
|
transition(hidden: UIModalTransition): this;
|
|
58
61
|
show(): void;
|
|
59
62
|
hide(): void;
|
|
@@ -62,7 +65,8 @@ export declare class ModalElement extends WidgetElement {
|
|
|
62
65
|
onClose(callback: () => void): this;
|
|
63
66
|
dismissible(enabled: boolean): this;
|
|
64
67
|
}
|
|
65
|
-
/** Create a modal dialog (see {@link UIModal})
|
|
66
|
-
* `show()
|
|
68
|
+
/** Create a modal dialog (see {@link UIModal}): declare it among its screen's children with
|
|
69
|
+
* `display: "none"` and `show()` it from a tap, or `show()` a parentless one from anywhere.
|
|
70
|
+
* Same argument forms as `UIColumn`. */
|
|
67
71
|
export declare function UIModal(...children: UIChildArg[]): UIModal;
|
|
68
72
|
export declare function UIModal(children: UINodeChild[] | ChildrenFn): UIModal;
|
|
@@ -18,9 +18,11 @@ export type UIPopoverAnchor = {
|
|
|
18
18
|
* tooltips; create it **once** at module scope and reuse it.
|
|
19
19
|
*/
|
|
20
20
|
export interface UIPopover extends UIModal {
|
|
21
|
-
/** Position next to `anchor` (an element or an `{x, y}` point),
|
|
22
|
-
*
|
|
23
|
-
*
|
|
21
|
+
/** Position next to `anchor` (an element or an `{x, y}` point), put the popover where the
|
|
22
|
+
* anchor is — the anchor's screen, page or surface content, found through the tree, so the
|
|
23
|
+
* menu lands where it was opened and goes with it — and play the entrance transition. A
|
|
24
|
+
* popover with no anchor and no parent goes to the app layer; without an anchor it shows
|
|
25
|
+
* wherever its own style puts it. */
|
|
24
26
|
show(anchor?: UIPopoverAnchor): void;
|
|
25
27
|
}
|
|
26
28
|
export declare class PopoverElement extends ModalElement {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { VideoPlayer } from "../runtime/media";
|
|
2
|
+
import { type UIWidgetContent } from "./UILayer";
|
|
2
3
|
import { type DismissOptions, type PresentOptions } from "./presentable";
|
|
3
4
|
import { type BaseStyle, type DrawableStyle, type ElementStyle, type UIElementBase } from "./UINode";
|
|
4
5
|
export type UIVideoStyle = ElementStyle & DrawableStyle & {
|
|
@@ -21,6 +22,8 @@ export interface UIVideo extends UIElementBase<UIVideoStyle, DrawableStyle & Bas
|
|
|
21
22
|
onClose(callback: () => void): this;
|
|
22
23
|
/** Hardware/system back while current. */
|
|
23
24
|
onBack(callback: () => void): this;
|
|
25
|
+
/** The UI over the video when presented: widgets over it (`Presentable.setContent`). */
|
|
26
|
+
setContent(content: UIWidgetContent): this;
|
|
24
27
|
}
|
|
25
28
|
/** Create a video node showing `player`'s output. */
|
|
26
29
|
export declare function UIVideo(player: VideoPlayer): UIVideo;
|
|
@@ -1,36 +1,39 @@
|
|
|
1
1
|
import { TouchStartEvent } from "../runtime/touch";
|
|
2
|
-
import { Presentable } from "./presentable";
|
|
3
2
|
import { ContainerElement, type BaseStyle, type Color, type ContainerStyle, type DrawableStyle, type PaddingStyle, type PositionStyle, type UIChildArg, type UIContainerBase, type UINodeChild, type ChildrenFn } from "./UINode";
|
|
4
3
|
export type UIWidgetStyle = ContainerStyle & DrawableStyle & PaddingStyle & BaseStyle & PositionStyle & {
|
|
4
|
+
/** Shown (`"flex"`, the default) or not: what `show()` / `hide()` write, what a state block may
|
|
5
|
+
* flip (`$open: { display: "flex" }`). */
|
|
6
|
+
display?: "none" | "flex";
|
|
5
7
|
/** A layer behind the widget that intercepts clicks — `"transparent"` still intercepts, `null`
|
|
6
8
|
* removes the layer. A tap on it fires `onOverlayTap`. */
|
|
7
9
|
overlayColor?: Color | null;
|
|
8
10
|
};
|
|
9
|
-
/** A floating overlay
|
|
10
|
-
*
|
|
11
|
-
*
|
|
11
|
+
/** A floating overlay that belongs to a WINDOW, not to a box (docs/plans/widgets-plan.md): a dialog,
|
|
12
|
+
* a sheet, a HUD, a mini-player. A widget is a CHILD of the place it belongs to — a `UIScreen`
|
|
13
|
+
* (among its children), a surface's content (`scene.setContent([hud])`) or the app layer
|
|
14
|
+
* (`UIOverlay`) — and is laid out and painted in the box of the outermost presented destination
|
|
15
|
+
* that contains it: absolutely positioned in that box, above everything else in it. A widget on a
|
|
16
|
+
* tab page covers the tab bar and rides the shell's push and pop. A widget inside a `UIColumn` or
|
|
17
|
+
* any other box is an error: a floating element of a box is an absolute child, not a widget.
|
|
18
|
+
*
|
|
19
|
+
* It shows with its place unless its style says `display: "none"`; `show()` / `hide()` flip that,
|
|
20
|
+
* and so does a state block (`$class: { display: "flex" }`). `UIModal` / `UIPopover` /
|
|
21
|
+
* `UIBottomSheet` build on it. */
|
|
12
22
|
export interface UIWidget extends UIContainerBase<UIWidgetStyle, DrawableStyle & BaseStyle & {
|
|
13
23
|
overlayColor?: Color | null;
|
|
14
24
|
}> {
|
|
15
25
|
readonly type: "widget";
|
|
16
|
-
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* (= back to a global overlay). Set it while the widget is hidden. The widget is always its own
|
|
21
|
-
* overlay root mounted into the owner's page view — it never becomes a child of the owner, so it
|
|
22
|
-
* stays topmost and its updates never trigger the owner's relayout. Works with a `UIScreen` that
|
|
23
|
-
* is a page inside a `UIPager`: the widget mounts into that tab and rides its swipe.
|
|
24
|
-
*/
|
|
25
|
-
attachTo(owner: Presentable | null): this;
|
|
26
|
-
/** Show the widget. By default it is a global overlay above every destination — it stays
|
|
27
|
-
* visible across navigation until `hide()` (dialogs, mini-player, global loader). If the
|
|
28
|
-
* widget was attached via `attachTo(owner)`, it mounts on that page's layer instead and is
|
|
29
|
-
* only visible while the owner is presented. */
|
|
26
|
+
/** Show the widget: `display: "flex"`, on top of its root — it moves to the end of its parent's
|
|
27
|
+
* children, so a dialog opened later covers an earlier one and a HUD declared after it. A widget
|
|
28
|
+
* with no parent is appended to the app layer first (`UIOverlay`) — a global overlay above every
|
|
29
|
+
* destination, up until `hide()`. */
|
|
30
30
|
show(): void;
|
|
31
|
-
/**
|
|
31
|
+
/** Hide the widget: `display: "none"`. It stays where it is (its place, the app layer), ready
|
|
32
|
+
* for the next `show()`. */
|
|
32
33
|
hide(): void;
|
|
33
|
-
/**
|
|
34
|
+
/** Shown right now by its own display (`show()` ran, `hide()` hasn't, no state block hides
|
|
35
|
+
* it). True for a widget hidden WITH its page or its covered screen: that is its place's
|
|
36
|
+
* visibility, not the widget's. */
|
|
34
37
|
readonly isShown: boolean;
|
|
35
38
|
/** Touch began on the widget; `ev.track(...)` takes over the rest of the gesture. */
|
|
36
39
|
onTouchStart(callback: (ev: TouchStartEvent<UIWidget>) => void): this;
|
|
@@ -44,10 +47,7 @@ export interface UIWidget extends UIContainerBase<UIWidgetStyle, DrawableStyle &
|
|
|
44
47
|
}
|
|
45
48
|
export declare class WidgetElement extends ContainerElement<"widget"> {
|
|
46
49
|
scrollable: false;
|
|
47
|
-
_owner?: Presentable;
|
|
48
|
-
private _shown;
|
|
49
50
|
constructor(type: "widget", style: UIWidgetStyle, children: UINodeChild[] | ChildrenFn);
|
|
50
|
-
attachTo(owner: Presentable | null): this;
|
|
51
51
|
show(): void;
|
|
52
52
|
hide(): void;
|
|
53
53
|
get isShown(): boolean;
|
|
@@ -60,7 +60,8 @@ export declare class WidgetElement extends ContainerElement<"widget"> {
|
|
|
60
60
|
/** @deprecated see the interface */
|
|
61
61
|
onBackPressed(callback: any): this;
|
|
62
62
|
}
|
|
63
|
-
/** Create a widget (same argument forms as `UIColumn`).
|
|
63
|
+
/** Create a widget (same argument forms as `UIColumn`). Put it where it belongs — among a screen's
|
|
64
|
+
* children, in `scene.setContent([...])`, or `UIOverlay` — position it with absolute-style props
|
|
64
65
|
* (`top`/`left`/`bottom`/`right`), then `show()`/`hide()`. */
|
|
65
66
|
export declare function UIWidget(...children: UIChildArg[]): UIWidget;
|
|
66
67
|
export declare function UIWidget(children: UINodeChild[] | ChildrenFn): UIWidget;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { EasingInput } from "../animate/tween/easing";
|
|
2
|
+
import type { UIWidget } from "./UIWidget";
|
|
2
3
|
/** The built-in transitions (ui/transitions.ts holds what each one is). `push` / `pop` are the
|
|
3
4
|
* stacked-navigation pair — the incoming screen slides over the other one, which drifts and dims;
|
|
4
5
|
* the rest are two-screen moves. */
|
|
@@ -14,6 +15,9 @@ export type TransitionPose = {
|
|
|
14
15
|
opacity?: number | number[];
|
|
15
16
|
/** Black over this screen, 0..1: how dark the screen UNDER the other one gets. */
|
|
16
17
|
dim?: number | number[];
|
|
18
|
+
/** A widget's overlay layer (its scrim) in the pose — a widget's enter / exit pose only
|
|
19
|
+
* (`UIModal.transition`): `"transparent"` fades the scrim in with the dialog. */
|
|
20
|
+
overlayColor?: string | string[];
|
|
17
21
|
/** ms (default 300). */
|
|
18
22
|
duration?: number;
|
|
19
23
|
/** ms to wait; the screen holds its first pose through it. */
|
|
@@ -70,6 +74,12 @@ export interface Presentable {
|
|
|
70
74
|
onOpen(callback: () => void): this;
|
|
71
75
|
onClose(callback: () => void): this;
|
|
72
76
|
onBack(callback: () => void): this;
|
|
77
|
+
/** The destination's widgets (docs/plans/widgets-plan.md): a dialog, a HUD, a sheet declared as
|
|
78
|
+
* CONTENT of the place they belong to. A `UIScreen` takes them among its children; a surface — a
|
|
79
|
+
* `Scene`, a `Scene2D`, a `NativeView`, a `UIVideo` — takes widgets alone, laid out over it while
|
|
80
|
+
* it is presented (touches outside a widget's box reach the surface). A widget shows with its
|
|
81
|
+
* destination unless its style says `display: "none"`; `show()` / `hide()` flip that. */
|
|
82
|
+
setContent(content: (UIWidget | null | undefined | false)[] | (() => (UIWidget | null | undefined | false)[])): this;
|
|
73
83
|
}
|
|
74
84
|
/** Runtime companion of the `Presentable` interface (declaration merging): the navigation
|
|
75
85
|
* state that isn't tied to the Router. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TransitionSpec } from "./presentable";
|
|
1
|
+
import type { TransitionPose, TransitionSpec } from "./presentable";
|
|
2
2
|
/** Wire ids: a registered transition is > 0. */
|
|
3
3
|
export declare const TRANSITION_NONE = 0;
|
|
4
4
|
/** "The caller names none": the runtime plays what the stack entry remembers (a pop), or keeps
|
|
@@ -16,3 +16,4 @@ export declare const TRANSITION_ENTER_ON_TOP = 1;
|
|
|
16
16
|
* one that left comes back from its `exit` pose, the same screen stays on top — and the timing and
|
|
17
17
|
* the curves stay as written. Not a rewind: that would turn an ease-out into a slow start. */
|
|
18
18
|
export declare const mirrored: (s: TransitionSpec) => TransitionSpec;
|
|
19
|
+
export declare const _widgetPoseId: (pose: TransitionPose | null) => number;
|
package/dist/types/ui/tree.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ export declare const TREE_EVENT_HOVER_ENTER = 32;
|
|
|
33
33
|
export declare const TREE_EVENT_HOVER_MOVE = 33;
|
|
34
34
|
export declare const TREE_EVENT_HOVER_END = 34;
|
|
35
35
|
export declare const TREE_EVENT_HOVER_CANCEL = 35;
|
|
36
|
+
export declare const TREE_EVENT_WIDGET_VISIBLE = 36;
|
|
36
37
|
export declare const TREE_FLAG_INTERACTIVE: number;
|
|
37
38
|
export declare const TREE_FLAG_CLICK: number;
|
|
38
39
|
export declare const TREE_FLAG_LONG_PRESS: number;
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "2.0.
|
|
1
|
+
export declare const SDK_VERSION = "2.0.10";
|
|
2
2
|
/** The major of a semver string, or null when it is not one. */
|
|
3
3
|
export declare const sdkMajor: (version: string | null | undefined) => number | null;
|
|
4
4
|
/** The `// sdk: <version>` line of a compiled bundle's header (sdk/src/compile/header.ts), read from
|