@lingxia/elements 0.15.0 → 0.17.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.d.ts +3 -2
- package/dist/index.js +1 -0
- package/dist/inline-native/commit.d.ts +39 -0
- package/dist/inline-native/commit.js +94 -0
- package/dist/inline-native/elements.d.ts +104 -0
- package/dist/inline-native/elements.js +749 -0
- package/dist/inline-native/errors.d.ts +8 -0
- package/dist/inline-native/errors.js +23 -0
- package/dist/inline-native/events.d.ts +10 -0
- package/dist/inline-native/events.js +16 -0
- package/dist/inline-native/geometry.d.ts +78 -0
- package/dist/inline-native/geometry.js +40 -0
- package/dist/inline-native/identity.d.ts +28 -0
- package/dist/inline-native/identity.js +51 -0
- package/dist/inline-native/index.d.ts +14 -0
- package/dist/inline-native/index.js +19 -0
- package/dist/inline-native/layout.d.ts +2 -0
- package/dist/inline-native/layout.js +58 -0
- package/dist/inline-native/lease.d.ts +13 -0
- package/dist/inline-native/lease.js +31 -0
- package/dist/inline-native/runtime.d.ts +64 -0
- package/dist/inline-native/runtime.js +119 -0
- package/dist/inline-native/schema.d.ts +111 -0
- package/dist/inline-native/schema.js +210 -0
- package/dist/inline-native/structure.d.ts +22 -0
- package/dist/inline-native/structure.js +706 -0
- package/dist/inline-native/style.d.ts +7 -0
- package/dist/inline-native/style.js +119 -0
- package/dist/inline-native/types.d.ts +82 -0
- package/dist/inline-native/types.js +7 -0
- package/dist/inline-native/unwrap.d.ts +10 -0
- package/dist/inline-native/unwrap.js +32 -0
- package/dist/inline-native/video.d.ts +65 -0
- package/dist/inline-native/video.js +69 -0
- package/dist/native_component_wrapper_shared.d.ts +3 -2
- package/dist/native_component_wrapper_shared.js +6 -3
- package/dist/nativecomponent.d.ts +1 -1
- package/dist/nativecomponent.js +8 -11
- package/dist/navigator.d.ts +2 -2
- package/dist/navigator.js +5 -5
- package/dist/video-events.d.ts +2 -0
- package/dist/video-events.js +18 -0
- package/dist/video.d.ts +98 -79
- package/dist/video.js +182 -757
- package/package.json +2 -1
- package/src/index.ts +58 -1
- package/src/inline-native/commit.ts +141 -0
- package/src/inline-native/elements.ts +829 -0
- package/src/inline-native/errors.ts +35 -0
- package/src/inline-native/events.ts +31 -0
- package/src/inline-native/geometry.ts +86 -0
- package/src/inline-native/identity.ts +102 -0
- package/src/inline-native/index.ts +103 -0
- package/src/inline-native/layout.ts +58 -0
- package/src/inline-native/lease.ts +48 -0
- package/src/inline-native/runtime.ts +185 -0
- package/src/inline-native/schema.ts +247 -0
- package/src/inline-native/structure.ts +823 -0
- package/src/inline-native/style.ts +111 -0
- package/src/inline-native/types.ts +105 -0
- package/src/inline-native/unwrap.ts +34 -0
- package/src/inline-native/video.ts +125 -0
- package/src/native_component_wrapper_shared.ts +8 -6
- package/src/nativecomponent.ts +8 -13
- package/src/navigator.ts +9 -9
- package/src/video-events.ts +16 -0
- package/src/video.ts +245 -839
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export { registerVideoComponent, LxVideoElement, type LxVideoAttributes, } from "./video.js";
|
|
1
|
+
export { registerVideoComponent, LxVideoElement, type LxVideoAttributes, type LxVideoEventPayloads, type LxVideoEventHandlers, } from "./video.js";
|
|
2
2
|
export { registerMediaSwiperComponent, LxMediaSwiperElement, type LxMediaSwiperAttributes, type LxMediaSwiperItem, type LxMediaSwiperChangeEvent, type LxMediaSwiperChangeEventDetail, type LxMediaSwiperTransitionEndEvent, type LxMediaSwiperTransitionEndEventDetail, type LxMediaSwiperItemEvent, type LxMediaSwiperEventDetail, type LxMediaSwiperEndReachedEvent, type LxMediaSwiperEndReachedEventDetail, type LxMediaSwiperErrorEvent, type LxMediaSwiperErrorEventDetail, type LxMediaSwiperChangeSource, type LxMediaSwiperErrorCode, } from "./media_swiper.js";
|
|
3
3
|
export { registerPickerComponent, LxPickerElement, type LxPickerAttributes, type LxPickerColumn, type LxPickerCascadingColumns, type LxPickerEvent, type LxPickerEventDetail, } from "./picker.js";
|
|
4
|
-
export { LxNavigatorElement, type LxNavigatorAttributes, type LxNavigatorEvent, type
|
|
4
|
+
export { LxNavigatorElement, type LxNavigatorAttributes, type LxNavigatorEvent, type NavigatorChannel, type NavigatorOpenType, type NavigatorQuery, type NavigatorQueryValue, type NavigatorTarget, } from "./navigator.js";
|
|
5
5
|
export { buildVideoNativeAttrs, buildMediaSwiperNativeAttrs, buildNavigatorNativeAttrs, buildPickerNativeAttrs, getPickerDisplayText, getPickerValueFromIndex, VIDEO_DOM_EVENT_MAP, MEDIA_SWIPER_DOM_EVENT_MAP, } from "./native_component_wrapper_shared.js";
|
|
6
6
|
export { isHarmony, isIOS, isAndroid, isMacOS, isDesktop, getOS, } from "./platform.js";
|
|
7
7
|
export { ensureComponentId, rectEquals, NativeComponentUpdateState, type Rect, } from "./component.js";
|
|
8
|
+
export { INLINE_NATIVE_SCHEMA, NATIVE_ERROR_CODES, PUBLIC_COMPONENT_NAMES, PUBLIC_ELEMENT_TAGS, CORE_KINDS, HOST_FACTORY_KINDS, compileInlineNativeRoot, compileInlineNativeForest, identifyCompiledRoot, buildRootCommit, buildGeometrySnapshot, publishCompiledRoot, applyHostLeaseMessage, createRootRuntimeState, viewCanShowFallback, collectVideoResourceUrls, buildVideoCommandRequest, collectAuthorTreeFromElement, normalizeAuthorType, parseBooleanAttr, unwrapNativeEventPayload, bindPayloadHandler, nativeError, registerInlineNativeComponents, registerInlineNativeAuthorComponents, registerNativeRootComponent, registerNativeViewComponent, registerNativeCoverComponent, registerNativeTextComponent, registerNativeButtonComponent, LxNativeRootElement, LxNativeViewElement, LxNativeCoverElement, LxNativeTextElement, LxNativeButtonElement, EMPTY_ROOT_REF, type NativeErrorCode, type PublicComponentName, type RootRef, type NodeRef, type NativeError, type AuthorNode, type CoreNode, type CompiledNativeRoot, type CompileInlineNativeResult, type PressPayload, type ValuePayload, type FocusPayload, type PointerPayload, type NativeHandler, type NativeActionIcon, type NativeStyleProperty, } from "./inline-native/index.js";
|
package/dist/index.js
CHANGED
|
@@ -5,3 +5,4 @@ export { LxNavigatorElement, } from "./navigator.js";
|
|
|
5
5
|
export { buildVideoNativeAttrs, buildMediaSwiperNativeAttrs, buildNavigatorNativeAttrs, buildPickerNativeAttrs, getPickerDisplayText, getPickerValueFromIndex, VIDEO_DOM_EVENT_MAP, MEDIA_SWIPER_DOM_EVENT_MAP, } from "./native_component_wrapper_shared.js";
|
|
6
6
|
export { isHarmony, isIOS, isAndroid, isMacOS, isDesktop, getOS, } from "./platform.js";
|
|
7
7
|
export { ensureComponentId, rectEquals, NativeComponentUpdateState, } from "./component.js";
|
|
8
|
+
export { INLINE_NATIVE_SCHEMA, NATIVE_ERROR_CODES, PUBLIC_COMPONENT_NAMES, PUBLIC_ELEMENT_TAGS, CORE_KINDS, HOST_FACTORY_KINDS, compileInlineNativeRoot, compileInlineNativeForest, identifyCompiledRoot, buildRootCommit, buildGeometrySnapshot, publishCompiledRoot, applyHostLeaseMessage, createRootRuntimeState, viewCanShowFallback, collectVideoResourceUrls, buildVideoCommandRequest, collectAuthorTreeFromElement, normalizeAuthorType, parseBooleanAttr, unwrapNativeEventPayload, bindPayloadHandler, nativeError, registerInlineNativeComponents, registerInlineNativeAuthorComponents, registerNativeRootComponent, registerNativeViewComponent, registerNativeCoverComponent, registerNativeTextComponent, registerNativeButtonComponent, LxNativeRootElement, LxNativeViewElement, LxNativeCoverElement, LxNativeTextElement, LxNativeButtonElement, EMPTY_ROOT_REF, } from "./inline-native/index.js";
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { IdentifiedNode, IdentifiedRoot } from "./identity.js";
|
|
2
|
+
import type { RootRef } from "./types.js";
|
|
3
|
+
export interface NativeRootCommitJson {
|
|
4
|
+
action: "root.commit";
|
|
5
|
+
root: RootRef;
|
|
6
|
+
baseRevision: number;
|
|
7
|
+
revision: number;
|
|
8
|
+
operations: NativeRootOperationJson[];
|
|
9
|
+
}
|
|
10
|
+
export type NativeRootOperationJson = {
|
|
11
|
+
op: "mount";
|
|
12
|
+
node: NativeNodeJson;
|
|
13
|
+
} | {
|
|
14
|
+
op: "update";
|
|
15
|
+
node: IdentifiedNode["nodeRef"];
|
|
16
|
+
patch: Record<string, unknown>;
|
|
17
|
+
} | {
|
|
18
|
+
op: "reparent";
|
|
19
|
+
node: IdentifiedNode["nodeRef"];
|
|
20
|
+
parent: IdentifiedNode["nodeRef"] | null;
|
|
21
|
+
} | {
|
|
22
|
+
op: "reorder";
|
|
23
|
+
node: IdentifiedNode["nodeRef"];
|
|
24
|
+
order: number;
|
|
25
|
+
} | {
|
|
26
|
+
op: "unmount";
|
|
27
|
+
node: IdentifiedNode["nodeRef"];
|
|
28
|
+
};
|
|
29
|
+
export interface NativeNodeJson {
|
|
30
|
+
ref: IdentifiedNode["nodeRef"];
|
|
31
|
+
kind: string;
|
|
32
|
+
parent: IdentifiedNode["nodeRef"] | null;
|
|
33
|
+
order: number;
|
|
34
|
+
authorType: string;
|
|
35
|
+
authorId?: string;
|
|
36
|
+
automationId?: string;
|
|
37
|
+
props: Record<string, unknown>;
|
|
38
|
+
}
|
|
39
|
+
export declare function buildRootCommit(next: IdentifiedRoot, previous: IdentifiedRoot | null, revision: number): NativeRootCommitJson;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
export function buildRootCommit(next, previous, revision) {
|
|
2
|
+
const baseRevision = previous ? revision - 1 : 0;
|
|
3
|
+
const operations = [];
|
|
4
|
+
const prevIndex = previous ? indexIdentified(previous) : new Map();
|
|
5
|
+
const nextIndex = indexIdentified(next);
|
|
6
|
+
walkMounts(next.children, prevIndex, operations);
|
|
7
|
+
for (const [key, current] of nextIndex) {
|
|
8
|
+
const prev = prevIndex.get(key);
|
|
9
|
+
if (!prev)
|
|
10
|
+
continue;
|
|
11
|
+
if (parentKey(prev) !== parentKey(current)) {
|
|
12
|
+
operations.push({
|
|
13
|
+
op: "reparent",
|
|
14
|
+
node: current.nodeRef,
|
|
15
|
+
parent: current.parentRef,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
if (prev.order !== current.order) {
|
|
19
|
+
operations.push({ op: "reorder", node: current.nodeRef, order: current.order });
|
|
20
|
+
}
|
|
21
|
+
const patch = propsPatch(effectiveProps(prev), effectiveProps(current));
|
|
22
|
+
if (patch) {
|
|
23
|
+
operations.push({ op: "update", node: current.nodeRef, patch });
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
// Retained children must leave removed parents before the host cascades unmount.
|
|
27
|
+
for (const [key, prev] of prevIndex) {
|
|
28
|
+
if (!nextIndex.has(key)) {
|
|
29
|
+
operations.push({ op: "unmount", node: prev.nodeRef });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
action: "root.commit",
|
|
34
|
+
root: next.rootRef,
|
|
35
|
+
baseRevision,
|
|
36
|
+
revision,
|
|
37
|
+
operations,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function walkMounts(nodes, prevIndex, operations) {
|
|
41
|
+
for (const node of nodes) {
|
|
42
|
+
if (!prevIndex.has(node.nodeRef.nodeKey)) {
|
|
43
|
+
operations.push({
|
|
44
|
+
op: "mount",
|
|
45
|
+
node: {
|
|
46
|
+
ref: node.nodeRef,
|
|
47
|
+
kind: node.node.kind,
|
|
48
|
+
parent: node.parentRef,
|
|
49
|
+
order: node.order,
|
|
50
|
+
authorType: node.node.authorType,
|
|
51
|
+
authorId: node.node.authorId,
|
|
52
|
+
automationId: node.node.automationId,
|
|
53
|
+
props: effectiveProps(node),
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
walkMounts(node.children, prevIndex, operations);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function indexIdentified(root) {
|
|
61
|
+
const map = new Map();
|
|
62
|
+
const walk = (nodes) => {
|
|
63
|
+
for (const node of nodes) {
|
|
64
|
+
map.set(node.nodeRef.nodeKey, node);
|
|
65
|
+
walk(node.children);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
walk(root.children);
|
|
69
|
+
return map;
|
|
70
|
+
}
|
|
71
|
+
function parentKey(node) {
|
|
72
|
+
var _a, _b;
|
|
73
|
+
return (_b = (_a = node.parentRef) === null || _a === void 0 ? void 0 : _a.nodeKey) !== null && _b !== void 0 ? _b : "";
|
|
74
|
+
}
|
|
75
|
+
/// `text` is a sibling of `props` on the core node, but the host reads it from
|
|
76
|
+
/// props. Fold it in for both the mount and the diff, or a caption that changes
|
|
77
|
+
/// after mount emits no update and the host keeps painting the first string.
|
|
78
|
+
function effectiveProps(node) {
|
|
79
|
+
return node.node.text !== undefined
|
|
80
|
+
? { ...node.node.props, text: node.node.text }
|
|
81
|
+
: node.node.props;
|
|
82
|
+
}
|
|
83
|
+
function propsPatch(prev, next) {
|
|
84
|
+
const patch = {};
|
|
85
|
+
let changed = false;
|
|
86
|
+
const keys = new Set([...Object.keys(prev), ...Object.keys(next)]);
|
|
87
|
+
for (const key of keys) {
|
|
88
|
+
if (JSON.stringify(prev[key]) === JSON.stringify(next[key]))
|
|
89
|
+
continue;
|
|
90
|
+
patch[key] = next[key] === undefined ? null : next[key];
|
|
91
|
+
changed = true;
|
|
92
|
+
}
|
|
93
|
+
return changed ? patch : null;
|
|
94
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { CompileInlineNativeResult, NativeError } from "./types.js";
|
|
2
|
+
declare class LxNativeBaseElement extends HTMLElement {
|
|
3
|
+
static get observedAttributes(): string[];
|
|
4
|
+
connectedCallback(): void;
|
|
5
|
+
get automationId(): string | null;
|
|
6
|
+
set automationId(value: string | null | undefined);
|
|
7
|
+
get pointerEvents(): string | null;
|
|
8
|
+
set pointerEvents(value: string | null | undefined);
|
|
9
|
+
}
|
|
10
|
+
export declare class LxNativeRootElement extends LxNativeBaseElement {
|
|
11
|
+
static get observedAttributes(): string[];
|
|
12
|
+
private pending;
|
|
13
|
+
private observer?;
|
|
14
|
+
private documentObserver?;
|
|
15
|
+
private resizeObserver?;
|
|
16
|
+
private stopLayoutObservation?;
|
|
17
|
+
private lastResult;
|
|
18
|
+
private styleDiagnostics;
|
|
19
|
+
private rootKey;
|
|
20
|
+
private rootEpoch;
|
|
21
|
+
private runtime;
|
|
22
|
+
private unregisterHost?;
|
|
23
|
+
private fallbackTimer;
|
|
24
|
+
lastCompileResult(): CompileInlineNativeResult | null;
|
|
25
|
+
retry(): Promise<void>;
|
|
26
|
+
connectedCallback(): void;
|
|
27
|
+
disconnectedCallback(): void;
|
|
28
|
+
private scheduleCompile;
|
|
29
|
+
compileNow(): CompileInlineNativeResult;
|
|
30
|
+
private compileMeasured;
|
|
31
|
+
private onHostMessage;
|
|
32
|
+
private armFallbackDeadline;
|
|
33
|
+
private updateFallbackVisibility;
|
|
34
|
+
private rootRef;
|
|
35
|
+
private destroyPublishedRoot;
|
|
36
|
+
private onViewportGeometryChanged;
|
|
37
|
+
private syncResizeObservation;
|
|
38
|
+
}
|
|
39
|
+
export declare class LxNativeViewElement extends LxNativeBaseElement {
|
|
40
|
+
static get observedAttributes(): string[];
|
|
41
|
+
}
|
|
42
|
+
export declare class LxNativeCoverElement extends LxNativeBaseElement {
|
|
43
|
+
static get observedAttributes(): string[];
|
|
44
|
+
connectedCallback(): void;
|
|
45
|
+
get scrim(): string;
|
|
46
|
+
set scrim(value: string | null | undefined);
|
|
47
|
+
get scrimOpacity(): number;
|
|
48
|
+
set scrimOpacity(value: number | string | null | undefined);
|
|
49
|
+
}
|
|
50
|
+
export declare class LxNativeTextElement extends LxNativeBaseElement {
|
|
51
|
+
private typography?;
|
|
52
|
+
static get observedAttributes(): string[];
|
|
53
|
+
connectedCallback(): void;
|
|
54
|
+
attributeChangedCallback(): void;
|
|
55
|
+
private syncTypography;
|
|
56
|
+
get maxLines(): number | null;
|
|
57
|
+
set maxLines(value: number | string | null | undefined);
|
|
58
|
+
}
|
|
59
|
+
export declare class LxNativeButtonElement extends LxNativeBaseElement {
|
|
60
|
+
private unregisterHost?;
|
|
61
|
+
private registeredId?;
|
|
62
|
+
private measuredLabel?;
|
|
63
|
+
private measuredIcon?;
|
|
64
|
+
private contentSlot?;
|
|
65
|
+
private dispatchAccessiblePress;
|
|
66
|
+
private readonly onAccessibleClick;
|
|
67
|
+
private readonly onAccessibleKeyDown;
|
|
68
|
+
connectedCallback(): void;
|
|
69
|
+
private registerEventBridge;
|
|
70
|
+
disconnectedCallback(): void;
|
|
71
|
+
attributeChangedCallback(name: string): void;
|
|
72
|
+
private syncMeasurement;
|
|
73
|
+
private syncAccessibility;
|
|
74
|
+
static get observedAttributes(): string[];
|
|
75
|
+
get label(): string | null;
|
|
76
|
+
set label(value: string | null | undefined);
|
|
77
|
+
get icon(): string | null;
|
|
78
|
+
set icon(value: string | null | undefined);
|
|
79
|
+
get disabled(): boolean;
|
|
80
|
+
set disabled(value: unknown);
|
|
81
|
+
get pressed(): boolean;
|
|
82
|
+
set pressed(value: unknown);
|
|
83
|
+
get expanded(): boolean;
|
|
84
|
+
set expanded(value: unknown);
|
|
85
|
+
get loading(): boolean;
|
|
86
|
+
set loading(value: unknown);
|
|
87
|
+
}
|
|
88
|
+
export declare function registerNativeRootComponent(): void;
|
|
89
|
+
export declare function registerNativeViewComponent(): void;
|
|
90
|
+
export declare function registerNativeCoverComponent(): void;
|
|
91
|
+
export declare function registerNativeTextComponent(): void;
|
|
92
|
+
export declare function registerNativeButtonComponent(): void;
|
|
93
|
+
export declare function registerInlineNativeAuthorComponents(): void;
|
|
94
|
+
export declare function structureErrorFromUnknown(message: string): NativeError;
|
|
95
|
+
declare global {
|
|
96
|
+
interface HTMLElementTagNameMap {
|
|
97
|
+
"lx-native-root": LxNativeRootElement;
|
|
98
|
+
"lx-native-view": LxNativeViewElement;
|
|
99
|
+
"lx-native-cover": LxNativeCoverElement;
|
|
100
|
+
"lx-native-text": LxNativeTextElement;
|
|
101
|
+
"lx-native-button": LxNativeButtonElement;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
export {};
|