@astralsight/astroforge-core 0.0.1

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/apis.mjs ADDED
@@ -0,0 +1,103 @@
1
+ //#region src/apis.ts
2
+ const ScanDuty = {
3
+ SCAN_MODE_LOW_POWER: 0,
4
+ SCAN_MODE_BALANCED: 1,
5
+ SCAN_MODE_LOW_LATENCY: 2
6
+ };
7
+ const ScanState = {
8
+ STATE_NON_SCAN: 0,
9
+ STATE_SCANING: 1
10
+ };
11
+ const NOT_REACHABLE = "AstroForge: 系统 API 仅可在设备运行时使用。请确认当前代码已进入目标平台 bridge。";
12
+ function feature(_name) {
13
+ return new Proxy({}, {
14
+ get(_target, prop) {
15
+ if (prop === "then") return void 0;
16
+ return () => {
17
+ throw new Error(NOT_REACHABLE);
18
+ };
19
+ },
20
+ set() {
21
+ throw new Error(NOT_REACHABLE);
22
+ }
23
+ });
24
+ }
25
+ const router = feature("system.router");
26
+ const app = feature("system.app");
27
+ const prompt = feature("system.prompt");
28
+ const network = feature("network");
29
+ const storage = feature("system.storage");
30
+ const cipher = feature("system.cipher");
31
+ const sensor = feature("system.sensor");
32
+ const geolocation = feature("system.geolocation");
33
+ const vibrator = feature("system.vibrator");
34
+ const file = feature("system.file");
35
+ const zip = feature("system.zip");
36
+ const device = feature("system.device");
37
+ const audio = feature("system.audio");
38
+ const record = feature("system.record");
39
+ const velaLocale = feature("locale");
40
+ const velaExchange = feature("system.exchange");
41
+ const velaCrypto = feature("system.crypto");
42
+ const velaConfiguration = feature("system.configuration");
43
+ const velaZlib = feature("system.zlib");
44
+ const velaServiceClient = feature("system.serviceclient");
45
+ const velaEvent = feature("system.event");
46
+ const velaFolme = feature("system.folme");
47
+ const velaVolume = feature("system.volume");
48
+ const velaMediaSession = feature("system.media.session");
49
+ const velaProtobuf = feature("system.protobuf");
50
+ const velaMqttMessage = feature("system.mqttmessage");
51
+ const velaDebug = feature("system.debug");
52
+ const velaInterconnect = feature("system.interconnect");
53
+ const velaBattery = feature("system.battery");
54
+ const velaBrightness = feature("system.brightness");
55
+ const velaBluetoothBLE = feature("system.bluetooth.ble");
56
+ const velaJumpApp = feature("jumpApp");
57
+ const velaInternals = {
58
+ power: feature("system.internal.power"),
59
+ package: feature("system.internal.package"),
60
+ activity: feature("system.internal.activity"),
61
+ messageChannel: feature("system.messageChannel")
62
+ };
63
+ const VelaInternals = velaInternals;
64
+ const vela = {
65
+ locale: velaLocale,
66
+ exchange: velaExchange,
67
+ crypto: velaCrypto,
68
+ configuration: velaConfiguration,
69
+ zlib: velaZlib,
70
+ serviceclient: velaServiceClient,
71
+ event: velaEvent,
72
+ folme: velaFolme,
73
+ volume: velaVolume,
74
+ mediaSession: velaMediaSession,
75
+ protobuf: velaProtobuf,
76
+ mqttmessage: velaMqttMessage,
77
+ debug: velaDebug,
78
+ interconnect: velaInterconnect,
79
+ battery: velaBattery,
80
+ brightness: velaBrightness,
81
+ bluetoothBLE: velaBluetoothBLE,
82
+ jumpApp: velaJumpApp,
83
+ internals: velaInternals
84
+ };
85
+ const system = {
86
+ app,
87
+ prompt,
88
+ router,
89
+ storage,
90
+ network,
91
+ cipher,
92
+ sensor,
93
+ geolocation,
94
+ vibrator,
95
+ file,
96
+ zip,
97
+ device,
98
+ audio,
99
+ record,
100
+ vela
101
+ };
102
+ //#endregion
103
+ export { ScanDuty, ScanState, VelaInternals, app, audio, cipher, device, file, geolocation, network, prompt, record, router, sensor, storage, system, vela, velaBattery, velaBluetoothBLE, velaBrightness, velaConfiguration, velaCrypto, velaDebug, velaEvent, velaExchange, velaFolme, velaInterconnect, velaInternals, velaJumpApp, velaLocale, velaMediaSession, velaMqttMessage, velaProtobuf, velaServiceClient, velaVolume, velaZlib, vibrator, zip };
@@ -0,0 +1,249 @@
1
+ import { FC, PropsWithChildren } from "./jsx-runtime.mjs";
2
+
3
+ //#region src/components.d.ts
4
+ type StyleValue = string | number | boolean | null | undefined;
5
+ type StyleObject = Record<string, StyleValue>;
6
+ type EventHandler<T = Event> = (evt: T) => void;
7
+ interface CommonProps extends PropsWithChildren {
8
+ id?: string;
9
+ className?: string;
10
+ class?: string;
11
+ style?: StyleObject;
12
+ show?: boolean;
13
+ tid?: string;
14
+ onClick?: EventHandler;
15
+ }
16
+ interface AProps extends CommonProps {
17
+ href?: string;
18
+ }
19
+ interface BarcodeProps extends CommonProps {
20
+ value?: string;
21
+ }
22
+ interface CanvasProps extends CommonProps {}
23
+ interface ChartProps extends CommonProps {
24
+ datasets?: unknown;
25
+ option?: unknown;
26
+ type?: string;
27
+ }
28
+ interface ViewProps extends CommonProps {
29
+ renderOffsetBottom?: string | number;
30
+ renderOffsetTop?: string | number;
31
+ scrollSnapX?: unknown;
32
+ scrollSnapY?: unknown;
33
+ onScroll?: EventHandler;
34
+ onScrollBegin?: EventHandler;
35
+ onScrollEnd?: EventHandler;
36
+ onScrollTouchUp?: EventHandler;
37
+ onTouchDown?: EventHandler;
38
+ }
39
+ interface TextProps extends CommonProps {
40
+ value?: string;
41
+ }
42
+ interface ImageProps extends CommonProps {
43
+ src: string;
44
+ alt?: string;
45
+ }
46
+ interface ImageAnimatorProps extends CommonProps {
47
+ duration?: number;
48
+ fillmode?: string;
49
+ fixedsize?: boolean;
50
+ images?: unknown[];
51
+ iteration?: number | string;
52
+ reverse?: boolean;
53
+ }
54
+ interface InputProps extends CommonProps {
55
+ autocomplete?: string | boolean;
56
+ checked?: boolean;
57
+ enterkeytype?: string;
58
+ maxlength?: number;
59
+ name?: string;
60
+ placeholder?: string;
61
+ show?: boolean;
62
+ type?: string;
63
+ value?: string | number | boolean;
64
+ }
65
+ interface LabelProps extends CommonProps {}
66
+ interface ListProps extends CommonProps {
67
+ scrollElastic?: boolean;
68
+ scrollIndex?: number;
69
+ scrollPage?: number;
70
+ scrollbar?: boolean;
71
+ scrollbarType?: string;
72
+ type?: string;
73
+ onScroll?: EventHandler;
74
+ onScrollBegin?: EventHandler;
75
+ onScrollEnd?: EventHandler;
76
+ onScrollFly?: EventHandler;
77
+ onTouchDown?: EventHandler;
78
+ onTouchUp?: EventHandler;
79
+ }
80
+ interface ListItemProps extends CommonProps {
81
+ type?: string;
82
+ }
83
+ interface MarqueeProps extends CommonProps {
84
+ autoplay?: boolean;
85
+ loop?: boolean;
86
+ scrollStartPosition?: number;
87
+ scrollamount?: number;
88
+ textOffset?: number;
89
+ textValue?: string;
90
+ onChange?: EventHandler;
91
+ onUpdate?: EventHandler;
92
+ }
93
+ interface MediaProps extends CommonProps {
94
+ current?: number;
95
+ screenShape?: string;
96
+ uris?: string[];
97
+ }
98
+ interface OptionProps extends CommonProps {}
99
+ interface PickerProps extends CommonProps {
100
+ range?: unknown[];
101
+ selected?: number | string | unknown;
102
+ type?: string;
103
+ }
104
+ interface PopupProps extends CommonProps {}
105
+ interface ProgressProps extends CommonProps {
106
+ percent?: number;
107
+ type?: string;
108
+ }
109
+ interface PromptProps extends CommonProps {
110
+ buttons?: unknown[];
111
+ duration?: number;
112
+ msg?: string;
113
+ position?: string;
114
+ title?: string;
115
+ type?: string;
116
+ }
117
+ interface QRProps extends CommonProps {
118
+ type?: string;
119
+ value?: string;
120
+ }
121
+ interface RatingProps extends CommonProps {}
122
+ interface RefreshProps extends CommonProps {
123
+ animationDuration?: number;
124
+ enablePulldown?: boolean;
125
+ enablePullup?: boolean;
126
+ gesture?: string;
127
+ offset?: number;
128
+ pulldownRefreshing?: boolean;
129
+ pullupRefreshing?: boolean;
130
+ reboundable?: boolean;
131
+ refreshing?: boolean;
132
+ type?: string;
133
+ onPulldown?: EventHandler;
134
+ onPullup?: EventHandler;
135
+ }
136
+ interface RefreshFooterProps extends CommonProps {}
137
+ interface RefreshHeaderProps extends CommonProps {
138
+ autoRefresh?: boolean;
139
+ dragRate?: number;
140
+ maxDragRatio?: number;
141
+ maxDragSize?: number;
142
+ refreshDisplayRadio?: number;
143
+ refreshDisplaySize?: number;
144
+ spinnerStyle?: string;
145
+ translationWithContent?: boolean;
146
+ triggerRatio?: number;
147
+ triggerSize?: number;
148
+ }
149
+ interface RichTextProps extends CommonProps {
150
+ value?: string;
151
+ }
152
+ interface ScreenProps extends CommonProps {}
153
+ interface ScrollProps extends CommonProps {
154
+ bounces?: boolean;
155
+ scrollBottom?: number;
156
+ scrollLeft?: number;
157
+ scrollRight?: number;
158
+ scrollTop?: number;
159
+ scrollX?: boolean;
160
+ scrollY?: boolean;
161
+ }
162
+ interface SelectProps extends CommonProps {}
163
+ interface SliderProps extends CommonProps {
164
+ disabled?: boolean;
165
+ max?: number;
166
+ min?: number;
167
+ step?: number;
168
+ value?: number;
169
+ onChange?: EventHandler;
170
+ onUpdate?: EventHandler;
171
+ }
172
+ interface SpanProps extends CommonProps {}
173
+ interface StackProps extends CommonProps {}
174
+ interface SwiperProps extends CommonProps {
175
+ autoPlay?: boolean;
176
+ bounces?: boolean;
177
+ duration?: number;
178
+ enableSwipe?: boolean;
179
+ index?: number;
180
+ indicator?: boolean;
181
+ interval?: number;
182
+ loop?: boolean;
183
+ nextMargin?: string | number;
184
+ previousMargin?: string | number;
185
+ reportSwipeRightOnLeftEdge?: boolean;
186
+ vertical?: boolean;
187
+ onChange?: EventHandler;
188
+ onUpdate?: EventHandler;
189
+ }
190
+ interface SwitchProps extends CommonProps {
191
+ checked?: boolean;
192
+ }
193
+ interface TabContentProps extends CommonProps {}
194
+ interface TabBarProps extends CommonProps {}
195
+ interface TabsProps extends CommonProps {}
196
+ interface TextareaProps extends CommonProps {
197
+ value?: string;
198
+ placeholder?: string;
199
+ }
200
+ interface VideoProps extends CommonProps {
201
+ autoPlay?: boolean;
202
+ muted?: boolean;
203
+ option?: unknown;
204
+ playCount?: number;
205
+ poster?: string;
206
+ src?: string;
207
+ }
208
+ declare const A: FC<AProps>;
209
+ declare const Barcode: FC<BarcodeProps>;
210
+ declare const Canvas: FC<CanvasProps>;
211
+ declare const Chart: FC<ChartProps>;
212
+ declare const View: FC<ViewProps>;
213
+ declare const Div: FC<ViewProps>;
214
+ declare const Text: FC<TextProps>;
215
+ declare const Image: FC<ImageProps>;
216
+ declare const ImageAnimator: FC<ImageAnimatorProps>;
217
+ declare const Input: FC<InputProps>;
218
+ declare const Label: FC<LabelProps>;
219
+ declare const List: FC<ListProps>;
220
+ declare const ListItem: FC<ListItemProps>;
221
+ declare const Marquee: FC<MarqueeProps>;
222
+ declare const Media: FC<MediaProps>;
223
+ declare const Option: FC<OptionProps>;
224
+ declare const Picker: FC<PickerProps>;
225
+ declare const Popup: FC<PopupProps>;
226
+ declare const Progress: FC<ProgressProps>;
227
+ declare const Prompt: FC<PromptProps>;
228
+ declare const QR: FC<QRProps>;
229
+ declare const Qr: FC<QRProps>;
230
+ declare const Rating: FC<RatingProps>;
231
+ declare const Refresh: FC<RefreshProps>;
232
+ declare const RefreshFooter: FC<RefreshFooterProps>;
233
+ declare const RefreshHeader: FC<RefreshHeaderProps>;
234
+ declare const RichText: FC<RichTextProps>;
235
+ declare const Screen: FC<ScreenProps>;
236
+ declare const Scroll: FC<ScrollProps>;
237
+ declare const Select: FC<SelectProps>;
238
+ declare const Slider: FC<SliderProps>;
239
+ declare const Span: FC<SpanProps>;
240
+ declare const Stack: FC<StackProps>;
241
+ declare const Swiper: FC<SwiperProps>;
242
+ declare const Switch: FC<SwitchProps>;
243
+ declare const TabContent: FC<TabContentProps>;
244
+ declare const TabBar: FC<TabBarProps>;
245
+ declare const Tabs: FC<TabsProps>;
246
+ declare const Textarea: FC<TextareaProps>;
247
+ declare const Video: FC<VideoProps>;
248
+ //#endregion
249
+ export { A, AProps, Barcode, BarcodeProps, Canvas, CanvasProps, Chart, ChartProps, CommonProps, Div, EventHandler, Image, ImageAnimator, ImageAnimatorProps, ImageProps, Input, InputProps, Label, LabelProps, List, ListItem, ListItemProps, ListProps, Marquee, MarqueeProps, Media, MediaProps, Option, OptionProps, Picker, PickerProps, Popup, PopupProps, Progress, ProgressProps, Prompt, PromptProps, QR, QRProps, Qr, Rating, RatingProps, Refresh, RefreshFooter, RefreshFooterProps, RefreshHeader, RefreshHeaderProps, RefreshProps, RichText, RichTextProps, Screen, ScreenProps, Scroll, ScrollProps, Select, SelectProps, Slider, SliderProps, Span, SpanProps, Stack, StackProps, StyleObject, StyleValue, Swiper, SwiperProps, Switch, SwitchProps, TabBar, TabBarProps, TabContent, TabContentProps, Tabs, TabsProps, Text, TextProps, Textarea, TextareaProps, Video, VideoProps, View, ViewProps };
@@ -0,0 +1,49 @@
1
+ //#region src/components.ts
2
+ const NOT_REACHABLE = "AstroForge: 内置组件在运行时不应被实际调用。请确认已启用 @astralsight/astroforge-rsbuild-plugin。";
3
+ function component() {
4
+ return () => {
5
+ throw new Error(NOT_REACHABLE);
6
+ };
7
+ }
8
+ const A = component();
9
+ const Barcode = component();
10
+ const Canvas = component();
11
+ const Chart = component();
12
+ const View = component();
13
+ const Div = View;
14
+ const Text = component();
15
+ const Image = component();
16
+ const ImageAnimator = component();
17
+ const Input = component();
18
+ const Label = component();
19
+ const List = component();
20
+ const ListItem = component();
21
+ const Marquee = component();
22
+ const Media = component();
23
+ const Option = component();
24
+ const Picker = component();
25
+ const Popup = component();
26
+ const Progress = component();
27
+ const Prompt = component();
28
+ const QR = component();
29
+ const Qr = QR;
30
+ const Rating = component();
31
+ const Refresh = component();
32
+ const RefreshFooter = component();
33
+ const RefreshHeader = component();
34
+ const RichText = component();
35
+ const Screen = component();
36
+ const Scroll = component();
37
+ const Select = component();
38
+ const Slider = component();
39
+ const Span = component();
40
+ const Stack = component();
41
+ const Swiper = component();
42
+ const Switch = component();
43
+ const TabContent = component();
44
+ const TabBar = component();
45
+ const Tabs = component();
46
+ const Textarea = component();
47
+ const Video = component();
48
+ //#endregion
49
+ export { A, Barcode, Canvas, Chart, Div, Image, ImageAnimator, Input, Label, List, ListItem, Marquee, Media, Option, Picker, Popup, Progress, Prompt, QR, Qr, Rating, Refresh, RefreshFooter, RefreshHeader, RichText, Screen, Scroll, Select, Slider, Span, Stack, Swiper, Switch, TabBar, TabContent, Tabs, Text, Textarea, Video, View };
@@ -0,0 +1,12 @@
1
+ //#region src/hooks.d.ts
2
+ type Updater<S> = S | ((prev: S) => S);
3
+ type SetState<S> = (next: Updater<S>) => void;
4
+ declare function useState<S>(_initial: S | (() => S)): [S, SetState<S>];
5
+ declare function useEffect(_fn: () => void | (() => void), _deps?: readonly unknown[]): void;
6
+ declare function useRef<T>(_initial: T | null): {
7
+ current: T | null;
8
+ };
9
+ declare function useMemo<T>(_fn: () => T, _deps: readonly unknown[]): T;
10
+ declare function useCallback<T extends (...args: never[]) => unknown>(_fn: T, _deps: readonly unknown[]): T;
11
+ //#endregion
12
+ export { useCallback, useEffect, useMemo, useRef, useState };
package/dist/hooks.mjs ADDED
@@ -0,0 +1,18 @@
1
+ //#region src/hooks.ts
2
+ function useState(_initial) {
3
+ throw new Error("AstroForge: useState 仅可在 .tsx 源码中使用,由编译器静态展开。");
4
+ }
5
+ function useEffect(_fn, _deps) {
6
+ throw new Error("AstroForge: useEffect 仅可在 .tsx 源码中使用,由编译器静态展开。");
7
+ }
8
+ function useRef(_initial) {
9
+ throw new Error("AstroForge: useRef 仅可在 .tsx 源码中使用,由编译器静态展开。");
10
+ }
11
+ function useMemo(_fn, _deps) {
12
+ throw new Error("AstroForge: useMemo 仅可在 .tsx 源码中使用,由编译器静态展开。");
13
+ }
14
+ function useCallback(_fn, _deps) {
15
+ throw new Error("AstroForge: useCallback 仅可在 .tsx 源码中使用,由编译器静态展开。");
16
+ }
17
+ //#endregion
18
+ export { useCallback, useEffect, useMemo, useRef, useState };
@@ -0,0 +1,6 @@
1
+ import { AccelerometerData, ActivityApi, AppApi, AppInfo, AppSource, AudioApi, AudioMetaInfo, AudioState, BLEAddressType, BLEGattCharacteristic, BLEGattClientDevice, BLEGattDescriptor, BLEGattOptions, BLEGattService, BLEScanFilter, BLEScanOptions, BLEScanResult, BLEScanStateResult, BLEScanner, BLEStartScanOptions, BatteryApi, BatteryStatus, BluetoothBLEApi, BridgeCallback, BridgeFailCallback, BridgeValue, BrightnessApi, BrightnessMode, BrightnessValue, CallbackOptions, CipherAESOptions, CipherApi, CipherDigestOptions, CipherMd5Options, CipherRSAOptions, CipherVerifyOptions, CompassData, CryptoApi, CryptoCryptOptions, CryptoHashDigestOptions, CryptoHmacDigestOptions, CryptoSignOptions, CryptoVerifyOptions, DebugApi, DeviceApi, DeviceCommonOptions, DeviceInfo, DownloadCompleteOptions, DownloadCompleteSuccess, DownloadNotifyData, DownloadOptions, DownloadSuccess, ExchangeApi, ExchangeOptions, FetchOptions, FileApi, FileCallbacks, FileGetOptions, FileListOptions, FileMkdirOptions, FileMoveOptions, FileReadArrayBufferOptions, FileReadTextOptions, FileUriOptions, FileWriteArrayBufferOptions, FileWriteTextOptions, FolmeAnimationOptions, FolmeApi, GenericSensorSubscribeOptions, GeolocationApi, GeolocationOptions, InterconnectApi, InterconnectConnect, InterconnectDiagnosisResult, InterconnectError, InterconnectMessage, InterconnectReadyState, JumpAppApi, LightData, LocaleInfo, LocationInfo, MediaSession, MediaSessionApi, MediaSessionFeedback, MessageChannelApi, MessageCodecApi, NetworkApi, NetworkType, NetworkTypeInfo, PackageApi, PackageInfo, PowerApi, PromptApi, PromptDialogOptions, PromptDialogResult, PromptToastOptions, ProtobufApi, ProtobufLoadOptions, ProtobufRoot, ProtobufType, ProximityData, RecordApi, RecordStartOptions, RouteObject, RouteStack, RouteState, RouterApi, RouterBackOptions, ScalarSensorData, ScanDuty, ScanState, SensorApi, SensorCallbackOptions, SensorRecentDataOptions, ServiceClientApi, ServiceClientConnectOptions, ServiceInstance, StorageApi, StorageDeleteOptions, StorageGetOptions, StorageKeyOptions, StorageSetOptions, SystemApi, SystemEventApi, UploadFileOptions, UploadProgress, UploadSuccess, UploadTask, VelaApi, VelaInternals, VelaInternalsApi, VibrateOptions, VibrateStartOptions, VibratorApi, VolumeApi, VolumeValue, ZipApi, ZlibApi, app, audio, cipher, device, file, geolocation, network, prompt, record, router, sensor, storage, system, vela, velaBattery, velaBluetoothBLE, velaBrightness, velaConfiguration, velaCrypto, velaDebug, velaEvent, velaExchange, velaFolme, velaInterconnect, velaInternals, velaJumpApp, velaLocale, velaMediaSession, velaMqttMessage, velaProtobuf, velaServiceClient, velaVolume, velaZlib, vibrator, zip } from "./apis.mjs";
2
+ import { JSX } from "./jsx-runtime.mjs";
3
+ import { A, AProps, Barcode, BarcodeProps, Canvas, CanvasProps, Chart, ChartProps, CommonProps, Div, EventHandler, Image, ImageAnimator, ImageAnimatorProps, ImageProps, Input, InputProps, Label, LabelProps, List, ListItem, ListItemProps, ListProps, Marquee, MarqueeProps, Media, MediaProps, Option, OptionProps, Picker, PickerProps, Popup, PopupProps, Progress, ProgressProps, Prompt, PromptProps, QR, QRProps, Qr, Rating, RatingProps, Refresh, RefreshFooter, RefreshFooterProps, RefreshHeader, RefreshHeaderProps, RefreshProps, RichText, RichTextProps, Screen, ScreenProps, Scroll, ScrollProps, Select, SelectProps, Slider, SliderProps, Span, SpanProps, Stack, StackProps, StyleObject, StyleValue, Swiper, SwiperProps, Switch, SwitchProps, TabBar, TabBarProps, TabContent, TabContentProps, Tabs, TabsProps, Text, TextProps, Textarea, TextareaProps, Video, VideoProps, View, ViewProps } from "./components.mjs";
4
+ import { useCallback, useEffect, useMemo, useRef, useState } from "./hooks.mjs";
5
+ import { CapabilityIssue, CapabilityKind, CapabilityScope, JS_FEATURES, PlatformId, PlatformSupport, RENDER_COMPONENTS, RUNTIME_CAPABILITIES, RuntimeCapability, checkCapability, findCapability, unsupportedCapabilities } from "./platform.mjs";
6
+ export { A, AProps, AccelerometerData, ActivityApi, AppApi, AppInfo, AppSource, AudioApi, AudioMetaInfo, AudioState, BLEAddressType, BLEGattCharacteristic, BLEGattClientDevice, BLEGattDescriptor, BLEGattOptions, BLEGattService, BLEScanFilter, BLEScanOptions, BLEScanResult, BLEScanStateResult, BLEScanner, BLEStartScanOptions, Barcode, BarcodeProps, BatteryApi, BatteryStatus, BluetoothBLEApi, BridgeCallback, BridgeFailCallback, BridgeValue, BrightnessApi, BrightnessMode, BrightnessValue, CallbackOptions, Canvas, CanvasProps, CapabilityIssue, CapabilityKind, CapabilityScope, Chart, ChartProps, CipherAESOptions, CipherApi, CipherDigestOptions, CipherMd5Options, CipherRSAOptions, CipherVerifyOptions, CommonProps, CompassData, CryptoApi, CryptoCryptOptions, CryptoHashDigestOptions, CryptoHmacDigestOptions, CryptoSignOptions, CryptoVerifyOptions, DebugApi, DeviceApi, DeviceCommonOptions, DeviceInfo, Div, DownloadCompleteOptions, DownloadCompleteSuccess, DownloadNotifyData, DownloadOptions, DownloadSuccess, EventHandler, ExchangeApi, ExchangeOptions, FetchOptions, FileApi, FileCallbacks, FileGetOptions, FileListOptions, FileMkdirOptions, FileMoveOptions, FileReadArrayBufferOptions, FileReadTextOptions, FileUriOptions, FileWriteArrayBufferOptions, FileWriteTextOptions, FolmeAnimationOptions, FolmeApi, GenericSensorSubscribeOptions, GeolocationApi, GeolocationOptions, Image, ImageAnimator, ImageAnimatorProps, ImageProps, Input, InputProps, InterconnectApi, InterconnectConnect, InterconnectDiagnosisResult, InterconnectError, InterconnectMessage, InterconnectReadyState, type JSX, JS_FEATURES, JumpAppApi, Label, LabelProps, LightData, List, ListItem, ListItemProps, ListProps, LocaleInfo, LocationInfo, Marquee, MarqueeProps, Media, MediaProps, MediaSession, MediaSessionApi, MediaSessionFeedback, MessageChannelApi, MessageCodecApi, NetworkApi, NetworkType, NetworkTypeInfo, Option, OptionProps, PackageApi, PackageInfo, Picker, PickerProps, PlatformId, PlatformSupport, Popup, PopupProps, PowerApi, Progress, ProgressProps, Prompt, PromptApi, PromptDialogOptions, PromptDialogResult, PromptProps, PromptToastOptions, ProtobufApi, ProtobufLoadOptions, ProtobufRoot, ProtobufType, ProximityData, QR, QRProps, Qr, RENDER_COMPONENTS, RUNTIME_CAPABILITIES, Rating, RatingProps, RecordApi, RecordStartOptions, Refresh, RefreshFooter, RefreshFooterProps, RefreshHeader, RefreshHeaderProps, RefreshProps, RichText, RichTextProps, RouteObject, RouteStack, RouteState, RouterApi, RouterBackOptions, RuntimeCapability, ScalarSensorData, ScanDuty, ScanState, Screen, ScreenProps, Scroll, ScrollProps, Select, SelectProps, SensorApi, SensorCallbackOptions, SensorRecentDataOptions, ServiceClientApi, ServiceClientConnectOptions, ServiceInstance, Slider, SliderProps, Span, SpanProps, Stack, StackProps, StorageApi, StorageDeleteOptions, StorageGetOptions, StorageKeyOptions, StorageSetOptions, StyleObject, StyleValue, Swiper, SwiperProps, Switch, SwitchProps, SystemApi, SystemEventApi, TabBar, TabBarProps, TabContent, TabContentProps, Tabs, TabsProps, Text, TextProps, Textarea, TextareaProps, UploadFileOptions, UploadProgress, UploadSuccess, UploadTask, VelaApi, VelaInternals, VelaInternalsApi, VibrateOptions, VibrateStartOptions, VibratorApi, Video, VideoProps, View, ViewProps, VolumeApi, VolumeValue, ZipApi, ZlibApi, app, audio, checkCapability, cipher, device, file, findCapability, geolocation, network, prompt, record, router, sensor, storage, system, unsupportedCapabilities, useCallback, useEffect, useMemo, useRef, useState, vela, velaBattery, velaBluetoothBLE, velaBrightness, velaConfiguration, velaCrypto, velaDebug, velaEvent, velaExchange, velaFolme, velaInterconnect, velaInternals, velaJumpApp, velaLocale, velaMediaSession, velaMqttMessage, velaProtobuf, velaServiceClient, velaVolume, velaZlib, vibrator, zip };
package/dist/index.mjs ADDED
@@ -0,0 +1,5 @@
1
+ import { A, Barcode, Canvas, Chart, Div, Image, ImageAnimator, Input, Label, List, ListItem, Marquee, Media, Option, Picker, Popup, Progress, Prompt, QR, Qr, Rating, Refresh, RefreshFooter, RefreshHeader, RichText, Screen, Scroll, Select, Slider, Span, Stack, Swiper, Switch, TabBar, TabContent, Tabs, Text, Textarea, Video, View } from "./components.mjs";
2
+ import { useCallback, useEffect, useMemo, useRef, useState } from "./hooks.mjs";
3
+ import { ScanDuty, ScanState, VelaInternals, app, audio, cipher, device, file, geolocation, network, prompt, record, router, sensor, storage, system, vela, velaBattery, velaBluetoothBLE, velaBrightness, velaConfiguration, velaCrypto, velaDebug, velaEvent, velaExchange, velaFolme, velaInterconnect, velaInternals, velaJumpApp, velaLocale, velaMediaSession, velaMqttMessage, velaProtobuf, velaServiceClient, velaVolume, velaZlib, vibrator, zip } from "./apis.mjs";
4
+ import { JS_FEATURES, RENDER_COMPONENTS, RUNTIME_CAPABILITIES, checkCapability, findCapability, unsupportedCapabilities } from "./platform.mjs";
5
+ export { A, Barcode, Canvas, Chart, Div, Image, ImageAnimator, Input, JS_FEATURES, Label, List, ListItem, Marquee, Media, Option, Picker, Popup, Progress, Prompt, QR, Qr, RENDER_COMPONENTS, RUNTIME_CAPABILITIES, Rating, Refresh, RefreshFooter, RefreshHeader, RichText, ScanDuty, ScanState, Screen, Scroll, Select, Slider, Span, Stack, Swiper, Switch, TabBar, TabContent, Tabs, Text, Textarea, VelaInternals, Video, View, app, audio, checkCapability, cipher, device, file, findCapability, geolocation, network, prompt, record, router, sensor, storage, system, unsupportedCapabilities, useCallback, useEffect, useMemo, useRef, useState, vela, velaBattery, velaBluetoothBLE, velaBrightness, velaConfiguration, velaCrypto, velaDebug, velaEvent, velaExchange, velaFolme, velaInterconnect, velaInternals, velaJumpApp, velaLocale, velaMediaSession, velaMqttMessage, velaProtobuf, velaServiceClient, velaVolume, velaZlib, vibrator, zip };
@@ -0,0 +1,19 @@
1
+ //#region src/jsx-runtime.d.ts
2
+ type FC<P = {}> = (props: P) => unknown;
3
+ type PropsWithChildren<P = {}> = P & {
4
+ children?: unknown;
5
+ };
6
+ declare namespace JSX {
7
+ interface IntrinsicAttributes {
8
+ key?: unknown;
9
+ }
10
+ interface IntrinsicElements {
11
+ [tag: string]: Record<string, unknown>;
12
+ }
13
+ type Element = unknown;
14
+ }
15
+ declare function jsx(_type: unknown, _props: unknown, _key?: unknown): never;
16
+ declare function jsxs(_type: unknown, _props: unknown, _key?: unknown): never;
17
+ declare const Fragment: unique symbol;
18
+ //#endregion
19
+ export { FC, Fragment, JSX, PropsWithChildren, jsx, jsxs };
@@ -0,0 +1,11 @@
1
+ //#region src/jsx-runtime.ts
2
+ const NOT_REACHABLE = "AstroForge: jsx 运行时不应被执行。请确认已启用 @astralsight/astroforge-rsbuild-plugin。";
3
+ function jsx(_type, _props, _key) {
4
+ throw new Error(NOT_REACHABLE);
5
+ }
6
+ function jsxs(_type, _props, _key) {
7
+ throw new Error(NOT_REACHABLE);
8
+ }
9
+ const Fragment = Symbol("astroforge.Fragment");
10
+ //#endregion
11
+ export { Fragment, jsx, jsxs };
@@ -0,0 +1,33 @@
1
+ //#region src/platform.d.ts
2
+ type PlatformId = "vela" | "blueos";
3
+ type CapabilityKind = "component" | "feature";
4
+ type CapabilityScope = "shared" | "vela" | "vela-internal";
5
+ interface PlatformSupport {
6
+ since?: number;
7
+ note?: string;
8
+ }
9
+ interface RuntimeCapability {
10
+ name: string;
11
+ kind: CapabilityKind;
12
+ group: string;
13
+ scope: CapabilityScope;
14
+ platforms: Partial<Record<PlatformId, PlatformSupport>>;
15
+ }
16
+ interface CapabilityIssue {
17
+ name: string;
18
+ kind: CapabilityKind;
19
+ platform: PlatformId;
20
+ reason: "unsupported" | "api-level";
21
+ required?: number;
22
+ }
23
+ declare const RENDER_COMPONENTS: readonly [RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability];
24
+ declare const JS_FEATURES: readonly [RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability];
25
+ declare const RUNTIME_CAPABILITIES: readonly [RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability, RuntimeCapability];
26
+ declare function findCapability(kind: CapabilityKind, name: string): RuntimeCapability | undefined;
27
+ declare function checkCapability(capability: RuntimeCapability, platform: PlatformId, apiLevel?: number): CapabilityIssue | undefined;
28
+ declare function unsupportedCapabilities(names: Iterable<{
29
+ kind: CapabilityKind;
30
+ name: string;
31
+ }>, platform: PlatformId, apiLevel?: number): CapabilityIssue[];
32
+ //#endregion
33
+ export { CapabilityIssue, CapabilityKind, CapabilityScope, JS_FEATURES, PlatformId, PlatformSupport, RENDER_COMPONENTS, RUNTIME_CAPABILITIES, RuntimeCapability, checkCapability, findCapability, unsupportedCapabilities };
@@ -0,0 +1,138 @@
1
+ //#region src/platform.ts
2
+ const vela = (since) => ({ vela: since ? { since } : {} });
3
+ const velaShared = (since) => ({ vela: since ? { since } : {} });
4
+ const component = (name, group, scope, platforms) => ({
5
+ name,
6
+ kind: "component",
7
+ group,
8
+ scope,
9
+ platforms
10
+ });
11
+ const feature = (name, group, scope, platforms) => ({
12
+ name,
13
+ kind: "feature",
14
+ group,
15
+ scope,
16
+ platforms
17
+ });
18
+ const RENDER_COMPONENTS = [
19
+ component("a", "basic", "shared", velaShared()),
20
+ component("barcode", "basic", "shared", velaShared()),
21
+ component("canvas", "canvas", "shared", velaShared()),
22
+ component("chart", "visualization", "vela", vela()),
23
+ component("div", "container", "shared", velaShared()),
24
+ component("image", "basic", "shared", velaShared()),
25
+ component("image-animator", "basic", "shared", velaShared()),
26
+ component("input", "form", "shared", velaShared()),
27
+ component("label", "form", "shared", velaShared()),
28
+ component("list", "container", "shared", velaShared()),
29
+ component("list-item", "container", "shared", velaShared()),
30
+ component("marquee", "basic", "shared", velaShared()),
31
+ component("media", "media", "vela", vela()),
32
+ component("option", "form", "vela", vela()),
33
+ component("picker", "form", "shared", velaShared()),
34
+ component("popup", "overlay", "vela", vela()),
35
+ component("progress", "basic", "shared", velaShared()),
36
+ component("prompt", "overlay", "vela", vela()),
37
+ component("qr", "basic", "vela", vela()),
38
+ component("rating", "form", "vela", vela()),
39
+ component("refresh", "container", "vela", vela()),
40
+ component("refresh-footer", "container", "vela", vela()),
41
+ component("refresh-header", "container", "vela", vela()),
42
+ component("richtext", "basic", "vela", vela()),
43
+ component("screen", "container", "vela", vela()),
44
+ component("scroll", "container", "shared", velaShared()),
45
+ component("select", "form", "vela", vela()),
46
+ component("slider", "form", "shared", velaShared()),
47
+ component("span", "basic", "vela", vela()),
48
+ component("stack", "container", "shared", velaShared()),
49
+ component("swiper", "container", "shared", velaShared()),
50
+ component("switch", "form", "shared", velaShared()),
51
+ component("tab-content", "container", "vela", vela()),
52
+ component("tabbar", "container", "vela", vela()),
53
+ component("tabs", "container", "vela", vela()),
54
+ component("text", "basic", "shared", velaShared()),
55
+ component("textarea", "form", "vela", vela()),
56
+ component("video", "media", "vela", vela())
57
+ ];
58
+ const JS_FEATURES = [
59
+ feature("locale", "i18n", "vela", vela()),
60
+ feature("system.fetch", "network", "shared", velaShared()),
61
+ feature("system.uploadtask", "network", "vela", vela()),
62
+ feature("system.request", "network", "vela", vela()),
63
+ feature("system.network", "network", "vela", vela()),
64
+ feature("system.interconnect", "interconnect", "vela", vela()),
65
+ feature("system.bluetooth.ble", "connectivity", "vela", vela()),
66
+ feature("system.router", "navigation", "shared", velaShared()),
67
+ feature("system.app", "app", "shared", velaShared()),
68
+ feature("system.prompt", "ui", "shared", velaShared()),
69
+ feature("system.storage", "storage", "shared", velaShared()),
70
+ feature("system.file", "file", "shared", velaShared()),
71
+ feature("system.zip", "file", "shared", velaShared()),
72
+ feature("system.zlib", "file", "vela", vela()),
73
+ feature("system.event", "event", "vela", vela()),
74
+ feature("system.device", "device", "shared", velaShared()),
75
+ feature("system.configuration", "device", "vela", vela()),
76
+ feature("system.battery", "device", "vela", vela()),
77
+ feature("system.brightness", "device", "vela", vela()),
78
+ feature("system.sensor", "sensor", "shared", velaShared()),
79
+ feature("system.geolocation", "location", "shared", velaShared()),
80
+ feature("system.vibrator", "device", "shared", velaShared()),
81
+ feature("system.volume", "media", "vela", vela()),
82
+ feature("system.audio", "media", "shared", velaShared()),
83
+ feature("system.media.session", "media", "vela", vela()),
84
+ feature("system.record", "media", "shared", velaShared()),
85
+ feature("system.crypto", "crypto", "vela", vela()),
86
+ feature("system.cipher", "crypto", "shared", velaShared()),
87
+ feature("system.protobuf", "codec", "vela", vela()),
88
+ feature("system.mqttmessage", "codec", "vela", vela()),
89
+ feature("system.exchange", "storage", "vela", vela()),
90
+ feature("system.serviceclient", "service", "vela", vela()),
91
+ feature("system.folme", "animation", "vela", vela()),
92
+ feature("system.debug", "diagnostics", "vela", vela()),
93
+ feature("jumpApp", "navigation", "vela", vela()),
94
+ feature("system.internal.power", "internal", "vela-internal", vela()),
95
+ feature("system.internal.package", "internal", "vela-internal", vela()),
96
+ feature("system.internal.activity", "internal", "vela-internal", vela()),
97
+ feature("system.messageChannel", "internal", "vela-internal", vela())
98
+ ];
99
+ const RUNTIME_CAPABILITIES = [...RENDER_COMPONENTS, ...JS_FEATURES];
100
+ function findCapability(kind, name) {
101
+ return RUNTIME_CAPABILITIES.find((item) => item.kind === kind && item.name === name);
102
+ }
103
+ function checkCapability(capability, platform, apiLevel) {
104
+ const support = capability.platforms[platform];
105
+ if (!support) return {
106
+ name: capability.name,
107
+ kind: capability.kind,
108
+ platform,
109
+ reason: "unsupported"
110
+ };
111
+ if (typeof apiLevel === "number" && typeof support.since === "number" && apiLevel < support.since) return {
112
+ name: capability.name,
113
+ kind: capability.kind,
114
+ platform,
115
+ reason: "api-level",
116
+ required: support.since
117
+ };
118
+ }
119
+ function unsupportedCapabilities(names, platform, apiLevel) {
120
+ const issues = [];
121
+ for (const item of names) {
122
+ const capability = findCapability(item.kind, item.name);
123
+ if (!capability) {
124
+ issues.push({
125
+ name: item.name,
126
+ kind: item.kind,
127
+ platform,
128
+ reason: "unsupported"
129
+ });
130
+ continue;
131
+ }
132
+ const issue = checkCapability(capability, platform, apiLevel);
133
+ if (issue) issues.push(issue);
134
+ }
135
+ return issues;
136
+ }
137
+ //#endregion
138
+ export { JS_FEATURES, RENDER_COMPONENTS, RUNTIME_CAPABILITIES, checkCapability, findCapability, unsupportedCapabilities };