lecodes-cli 0.11.0 → 0.12.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/dist/index.js +48454 -7370
- package/package.json +4 -3
- package/runtime/sdk/g2/Node2D.ts +3 -0
- package/runtime/sdk/g2/SpriteAnimation.ts +101 -20
- package/runtime/sdk/g2/SpriteSheet.ts +166 -0
- package/runtime/sdk/g2/Tileset.ts +71 -0
- package/runtime/sdk/g2/autotile.ts +394 -0
- package/runtime/sdk/g2/cells.ts +91 -0
- package/runtime/sdk/g2/defineScene2d.ts +381 -0
- package/runtime/sdk/g2/scenarios2d.ts +69 -0
- package/runtime/sdk/inject.ts +16 -0
- package/runtime/sdk/runtime/app.ts +21 -3
- package/runtime/sdk/scene/defineScene.ts +10 -70
- package/runtime/sdk/scene/grammar.ts +85 -0
- package/runtime/sdk/ui/NativeView.ts +6 -12
- package/runtime/sdk/ui/UIBottomSheet.ts +0 -4
- package/runtime/sdk/ui/UIButton.ts +2 -21
- package/runtime/sdk/ui/UIContainer.ts +4 -58
- package/runtime/sdk/ui/UIImage.ts +2 -13
- package/runtime/sdk/ui/UIInput.ts +9 -21
- package/runtime/sdk/ui/UIModal.ts +0 -4
- package/runtime/sdk/ui/UINode.ts +37 -0
- package/runtime/sdk/ui/UIPager.ts +2 -13
- package/runtime/sdk/ui/UIScreen.ts +4 -20
- package/runtime/sdk/ui/UIScrollable.ts +2 -20
- package/runtime/sdk/ui/UISpacer.ts +2 -8
- package/runtime/sdk/ui/UIText.ts +2 -13
- package/runtime/sdk/ui/UIVideo.ts +6 -13
- package/runtime/sdk/ui/UIVirtualizedList.ts +10 -10
- package/runtime/sdk/ui/UIWidget.ts +3 -19
|
@@ -1,34 +1,27 @@
|
|
|
1
1
|
import type { VideoPlayer } from "../runtime/media"
|
|
2
2
|
import { _bumpNavEpoch, _navSupported, _setCurrent, Presentable, type PresentOptions } from "./presentable"
|
|
3
|
-
import { Element, type
|
|
3
|
+
import { Element, type BaseStyle, type DrawableStyle, type ElementStyle, type UIElementBase } from "./UINode"
|
|
4
4
|
|
|
5
5
|
export type UIVideoStyle = ElementStyle & DrawableStyle & { objectFit?: "cover" | "contain" | "fill" }
|
|
6
6
|
|
|
7
7
|
/** A video surface showing a `VideoPlayer`'s output — embeddable in a screen AND
|
|
8
8
|
* fullscreen-presentable (`open()`), with seamless promotion between the two. */
|
|
9
|
-
export interface UIVideo {
|
|
9
|
+
export interface UIVideo extends UIElementBase<UIVideoStyle, DrawableStyle & BaseStyle> {
|
|
10
10
|
readonly type: "video",
|
|
11
11
|
/** The player driving this surface (playback control lives on it). */
|
|
12
12
|
player: VideoPlayer
|
|
13
|
-
style: Style<this, UIVideoStyle>
|
|
14
|
-
animateTo: AnimateStyle<this, DrawableStyle & BaseStyle>
|
|
15
|
-
animateFrom: AnimateStyle<this, DrawableStyle & BaseStyle>
|
|
16
13
|
|
|
17
14
|
/** Show fullscreen as the current destination. Promotion: if this video is mounted in a screen,
|
|
18
15
|
* the SAME native player moves fullscreen — playback uninterrupted; a pop moves it back. */
|
|
19
16
|
open(options?: PresentOptions): void
|
|
17
|
+
/** Dismiss if this is the visible destination. */
|
|
20
18
|
close(): void
|
|
19
|
+
/** Became the visible destination. */
|
|
21
20
|
onOpen(callback: () => void): this
|
|
21
|
+
/** Stopped being the visible destination. */
|
|
22
22
|
onClose(callback: () => void): this
|
|
23
|
+
/** Hardware/system back while current. */
|
|
23
24
|
onBackPressed(callback: () => void): this
|
|
24
|
-
|
|
25
|
-
onLayout(onLayout: OnLayoutCallback): this
|
|
26
|
-
getBoundingClientRect(): BoundingClientRect | null
|
|
27
|
-
|
|
28
|
-
/** Style-class proxy — read `el.class.checked`, set `el.class.checked = true`, toggle with
|
|
29
|
-
* `!el.class.checked`, bind `el.class.done = () => sig.value`, batch/chain `el.class({ … })`.
|
|
30
|
-
* Classes cascade to descendants. See {@link Classes}. */
|
|
31
|
-
readonly class: Classes<this>
|
|
32
25
|
}
|
|
33
26
|
|
|
34
27
|
class VideoElement extends Element<"video"> implements Presentable {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Element, type Color, type DrawableStyle, type ElementStyle, type
|
|
1
|
+
import { Element, type Color, type DrawableStyle, type ElementStyle, type UIElementBase, type UINodeChild } from "./UINode"
|
|
2
2
|
|
|
3
3
|
export type UIVirtualizedListStyle = DrawableStyle & ElementStyle & {
|
|
4
4
|
/** Tint of the native pull-to-refresh spinner (pairs with `onRefresh`). */
|
|
@@ -27,27 +27,34 @@ export interface VListConfig<T> {
|
|
|
27
27
|
|
|
28
28
|
/** A windowed (virtualized) list: only the items near the viewport are mounted — for long feeds
|
|
29
29
|
* and chats. Items are keyed; feed it via `setData`/`append`/`prepend`. */
|
|
30
|
-
export interface UIVirtualizedList<T = unknown> {
|
|
30
|
+
export interface UIVirtualizedList<T = unknown> extends UIElementBase<UIVirtualizedListStyle> {
|
|
31
31
|
readonly type: "vlist"
|
|
32
|
-
style: Style<this, UIVirtualizedListStyle>
|
|
33
32
|
|
|
34
33
|
/** Replace the data wholesale — vanished keys are unmounted by the host's window sync. */
|
|
35
34
|
setData(items: T[]): this
|
|
35
|
+
/** Append items to the end (auto-scrolls when `inverted` and resting at the bottom). */
|
|
36
36
|
append(...items: T[]): this
|
|
37
37
|
/** Insert at the start WITHOUT a scroll jump (the host compensates the offset). */
|
|
38
38
|
prepend(...items: T[]): this
|
|
39
39
|
/** Update items with the same keys: mounted ones re-render; the cached height persists until
|
|
40
40
|
* re-measured. */
|
|
41
41
|
update(...items: T[]): this
|
|
42
|
+
/** Remove items by key. */
|
|
42
43
|
removeByKey(...keys: string[]): this
|
|
43
44
|
|
|
45
|
+
/** Number of data items (mounted or not). */
|
|
44
46
|
readonly itemCount: number
|
|
47
|
+
/** The data item under `key`, if any. */
|
|
45
48
|
getItem(key: string): T | undefined
|
|
46
49
|
|
|
50
|
+
/** Scroll to `offset` px. */
|
|
47
51
|
scrollTo(offset: number, animated?: boolean): void
|
|
52
|
+
/** Scroll to the item with `key`. */
|
|
48
53
|
scrollToKey(key: string, animated?: boolean): void
|
|
54
|
+
/** Scroll to the end of the content. */
|
|
49
55
|
scrollToEnd(animated?: boolean): void
|
|
50
56
|
|
|
57
|
+
/** Scroll position changed (px from the start edge). */
|
|
51
58
|
onScroll(callback: (scrollPosition: number) => void): this
|
|
52
59
|
/** Pull-to-refresh: the spinner stays until the returned promise settles. Attach BEFORE the
|
|
53
60
|
* node mounts (hosts read it at creation). Native hosts only — no-op on web. */
|
|
@@ -57,13 +64,6 @@ export interface UIVirtualizedList<T = unknown> {
|
|
|
57
64
|
onEndReached(thresholdPx: number, callback: () => void): this
|
|
58
65
|
/** Same, for the top edge — chat history loading. */
|
|
59
66
|
onStartReached(thresholdPx: number, callback: () => void): this
|
|
60
|
-
onLayout(onLayout: OnLayoutCallback): this
|
|
61
|
-
getBoundingClientRect(): BoundingClientRect | null
|
|
62
|
-
|
|
63
|
-
/** Style-class proxy — read `el.class.checked`, set `el.class.checked = true`, toggle with
|
|
64
|
-
* `!el.class.checked`, bind `el.class.done = () => sig.value`, batch/chain `el.class({ … })`.
|
|
65
|
-
* Classes cascade to descendants. See {@link Classes}. */
|
|
66
|
-
readonly class: Classes<this>
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
export class VListElement<T> extends Element<"vlist"> implements UIVirtualizedList<T> {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TouchStartEvent } from "../runtime/touch"
|
|
2
2
|
import { _descOf, _navSupported, Presentable } from "./presentable"
|
|
3
|
-
import { ContainerElement, buildUI, type
|
|
3
|
+
import { ContainerElement, buildUI, type BaseStyle, type Color, type ContainerStyle, type DrawableStyle, type PaddingStyle, type PositionStyle, type UIChildArg, type UIContainerBase, type UINodeChild, type ChildrenFn } from "./UINode"
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
export type UIWidgetStyle = ContainerStyle & DrawableStyle & PaddingStyle & BaseStyle & PositionStyle & {
|
|
@@ -13,11 +13,8 @@ export type UIWidgetStyle = ContainerStyle & DrawableStyle & PaddingStyle & Base
|
|
|
13
13
|
/** A floating overlay — absolutely positioned in device coordinates, mounted above the page as
|
|
14
14
|
* its own layout root (never a child of what's underneath). The base of dialogs, toasts,
|
|
15
15
|
* mini-players and scene HUDs; `UIModal`/`UIPopover`/`UIBottomSheet` build on it. */
|
|
16
|
-
export interface UIWidget {
|
|
16
|
+
export interface UIWidget extends UIContainerBase<UIWidgetStyle, DrawableStyle & BaseStyle & { overlayColor?: Color | null }> {
|
|
17
17
|
readonly type: "widget",
|
|
18
|
-
style: Style<this, UIWidgetStyle>,
|
|
19
|
-
animateTo: AnimateStyle<this, DrawableStyle & BaseStyle & { overlayColor?: Color | null }>
|
|
20
|
-
animateFrom: AnimateStyle<this, DrawableStyle & BaseStyle & { overlayColor?: Color | null }>
|
|
21
18
|
|
|
22
19
|
/**
|
|
23
20
|
* Attach this widget to a destination (a `Scene`, a `UIScreen`, …): the widget lives on that
|
|
@@ -42,25 +39,12 @@ export interface UIWidget {
|
|
|
42
39
|
/** Mounted right now (`show()` ran, `hide()` hasn't). */
|
|
43
40
|
readonly isShow: boolean,
|
|
44
41
|
|
|
45
|
-
|
|
46
|
-
insert(index: number, ...nodes: UINodeChild[]): UIWidget
|
|
47
|
-
remove(...nodes: UINodeChild[]): UIWidget
|
|
48
|
-
setContent(nodes: UINodeChild[] | ChildrenFn): this
|
|
49
|
-
|
|
50
|
-
readonly children: UINodeChild[],
|
|
51
|
-
|
|
52
|
-
onLayout(onLayout: OnLayoutCallback): this
|
|
53
|
-
getBoundingClientRect(): BoundingClientRect | null
|
|
42
|
+
/** Touch began on the widget; `ev.track(...)` takes over the rest of the gesture. */
|
|
54
43
|
onTouchStart(callback: (ev: TouchStartEvent<UIWidget>) => void): this,
|
|
55
44
|
/** Tap on the overlay layer (requires an `overlayColor`). */
|
|
56
45
|
onOverlayTap(callback: () => void): this,
|
|
57
46
|
/** Hardware/system back while the widget is shown. */
|
|
58
47
|
onBackPressed(callback: () => void): this
|
|
59
|
-
|
|
60
|
-
/** Style-class proxy — read `el.class.checked`, set `el.class.checked = true`, toggle with
|
|
61
|
-
* `!el.class.checked`, bind `el.class.done = () => sig.value`, batch/chain `el.class({ … })`.
|
|
62
|
-
* Classes cascade to descendants. See {@link Classes}. */
|
|
63
|
-
readonly class: Classes<this>
|
|
64
48
|
}
|
|
65
49
|
|
|
66
50
|
|