@open-mova/core 0.1.9 → 0.2.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/README.md +42 -5
- package/dist/index.d.ts +1 -1
- package/dist/native.d.ts +137 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,8 +8,9 @@
|
|
|
8
8
|
contratos, tipos y utilidades transversales que puedan utilizar la shell y los
|
|
9
9
|
microfrontales.
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
Define el contrato `NativeCapabilities` v1, el token de DI Angular y
|
|
12
|
+
`injectNativeCapabilities()`. No depende de Capacitor: los plugins reales solo
|
|
13
|
+
se instalan y se ejecutan dentro de la shell.
|
|
13
14
|
|
|
14
15
|
## Instalación
|
|
15
16
|
|
|
@@ -71,6 +72,42 @@ const selected = await native.camera.choosePhoto();
|
|
|
71
72
|
móvil. `choosePhoto()` devuelve `undefined` si la galería devuelve una lista
|
|
72
73
|
vacía; cancelar el diálogo puede rechazar la promesa según la plataforma.
|
|
73
74
|
Angular muestra un error de provider ausente si la shell no ofrece el contrato.
|
|
74
|
-
Los MF que usan capacidades nativas dependen de `@open-mova/core
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
Los MF que usan capacidades nativas dependen de `@open-mova/core` desde npm.
|
|
76
|
+
Shell y MF deben compartir una sola instancia de core mediante Native
|
|
77
|
+
Federation.
|
|
78
|
+
|
|
79
|
+
## Capacidades nativas
|
|
80
|
+
|
|
81
|
+
Cada plugin oficial se representa como una capacidad con tres operaciones
|
|
82
|
+
comunes:
|
|
83
|
+
|
|
84
|
+
- `isAvailable()` comprueba si el plugin está disponible en la plataforma.
|
|
85
|
+
- `invoke(nombre, opciones)` ejecuta una operación del plugin.
|
|
86
|
+
- `subscribe(evento, listener)` registra un evento y devuelve un handle con
|
|
87
|
+
`remove()` para cancelarlo.
|
|
88
|
+
|
|
89
|
+
Los nombres de capacidad están en camelCase y no dependen del nombre del
|
|
90
|
+
paquete npm. Por ejemplo, un MF puede consultar conectividad así:
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
const native = injectNativeCapabilities();
|
|
94
|
+
|
|
95
|
+
if (native.network.isAvailable()) {
|
|
96
|
+
const status = await native.network.invoke('getStatus');
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
El contrato expone: `actionSheet`, `app`, `appLauncher`, `backgroundRunner`,
|
|
101
|
+
`barcodeScanner`, `browser`, `calendar`, `camera`, `clipboard`, `contacts`,
|
|
102
|
+
`cookies`, `device`, `dialog`, `fileTransfer`, `fileViewer`, `filesystem`,
|
|
103
|
+
`geolocation`, `googleMaps`, `haptics`, `healthFitness`, `http`,
|
|
104
|
+
`inAppBrowser`, `keyboard`, `localLlm`, `localNotifications`, `motion`,
|
|
105
|
+
`network`, `preferences`, `privacyScreen`, `pushNotifications`,
|
|
106
|
+
`screenOrientation`, `screenReader`, `share`, `splashScreen`, `statusBar`,
|
|
107
|
+
`systemBars`, `textZoom` y `toast`.
|
|
108
|
+
|
|
109
|
+
Las opciones y el resultado no exponen tipos de Capacitor. Esto evita que el MF
|
|
110
|
+
se acople a su versión; algunas operaciones avanzadas pueden requerir valores
|
|
111
|
+
propios de plataforma, como `Date` o `Blob`. Las operaciones más estables y
|
|
112
|
+
habituales conservan métodos explícitos: `device.getInfo()`,
|
|
113
|
+
`camera.takePhoto()` y `camera.choosePhoto()`.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type { CameraCapability, DeviceCapability, DeviceDetails, NativeCapabilities, PhotoResult, } from './native.js';
|
|
1
|
+
export type { ActionSheetCapability, AppCapability, AppLauncherCapability, BackgroundRunnerCapability, BarcodeScannerCapability, BrowserCapability, CameraCapability, CalendarCapability, ClipboardCapability, ContactsCapability, CookiesCapability, DeviceCapability, DeviceDetails, DialogCapability, FileTransferCapability, FileViewerCapability, FilesystemCapability, GeolocationCapability, GoogleMapsCapability, HapticsCapability, HealthFitnessCapability, HttpCapability, InAppBrowserCapability, KeyboardCapability, LocalLlmCapability, LocalNotificationsCapability, MotionCapability, NativeCapabilities, NativeOptions, NativePluginCapability, NativeSubscription, NetworkCapability, PhotoResult, PreferencesCapability, PrivacyScreenCapability, PushNotificationsCapability, ScreenOrientationCapability, ScreenReaderCapability, ShareCapability, SplashScreenCapability, StatusBarCapability, SystemBarsCapability, TextZoomCapability, ToastCapability, } from './native.js';
|
|
2
2
|
export { NATIVE_CAPABILITIES, injectNativeCapabilities } from './native.js';
|
package/dist/native.d.ts
CHANGED
|
@@ -1,24 +1,158 @@
|
|
|
1
1
|
import { InjectionToken } from '@angular/core';
|
|
2
|
+
/**
|
|
3
|
+
* Options passed across the framework boundary. Some official plugins need
|
|
4
|
+
* platform values such as Date, Blob or an element reference, so this cannot
|
|
5
|
+
* be restricted to JSON alone.
|
|
6
|
+
*/
|
|
7
|
+
export type NativeOptions = Readonly<Record<string, unknown>>;
|
|
8
|
+
export interface NativeSubscription {
|
|
9
|
+
remove(): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Base contract shared by every plugin capability. Capacitor stays private to
|
|
13
|
+
* the shell, so this public API can be versioned independently.
|
|
14
|
+
*/
|
|
15
|
+
export interface NativePluginCapability<TOperation extends string = string, TEvent extends string = never> {
|
|
16
|
+
isAvailable(): boolean;
|
|
17
|
+
invoke<TResult = unknown>(operation: TOperation, options?: NativeOptions): Promise<TResult>;
|
|
18
|
+
subscribe(event: TEvent, listener: (payload: unknown) => void): Promise<NativeSubscription>;
|
|
19
|
+
}
|
|
20
|
+
type ExtensibleOperation<TKnown extends string> = TKnown | (string & {});
|
|
2
21
|
export interface DeviceDetails {
|
|
3
22
|
readonly model: string;
|
|
4
23
|
readonly platform: 'ios' | 'android' | 'web';
|
|
5
24
|
readonly osVersion: string;
|
|
6
25
|
}
|
|
7
|
-
export interface DeviceCapability {
|
|
26
|
+
export interface DeviceCapability extends NativePluginCapability<ExtensibleOperation<'getId' | 'getInfo' | 'getBatteryInfo' | 'getLanguageCode' | 'getLanguageTag'>> {
|
|
8
27
|
getInfo(): Promise<DeviceDetails>;
|
|
9
28
|
}
|
|
10
29
|
export interface PhotoResult {
|
|
11
30
|
readonly webPath?: string;
|
|
12
31
|
readonly uri?: string;
|
|
13
32
|
}
|
|
14
|
-
export interface CameraCapability {
|
|
33
|
+
export interface CameraCapability extends NativePluginCapability<ExtensibleOperation<'takePhoto' | 'recordVideo' | 'playVideo' | 'chooseFromGallery' | 'editPhoto' | 'editURIPhoto' | 'pickLimitedLibraryPhotos' | 'getLimitedLibraryPhotos' | 'checkPermissions' | 'requestPermissions' | 'getPhoto' | 'pickImages'>> {
|
|
15
34
|
takePhoto(): Promise<PhotoResult>;
|
|
16
35
|
choosePhoto(): Promise<PhotoResult | undefined>;
|
|
17
36
|
}
|
|
37
|
+
export interface ActionSheetCapability extends NativePluginCapability<ExtensibleOperation<'showActions'>> {
|
|
38
|
+
}
|
|
39
|
+
export interface AppLauncherCapability extends NativePluginCapability<ExtensibleOperation<'canOpenUrl' | 'openUrl'>> {
|
|
40
|
+
}
|
|
41
|
+
export interface AppCapability extends NativePluginCapability<ExtensibleOperation<'exitApp' | 'getInfo' | 'getState' | 'getLaunchUrl' | 'minimizeApp' | 'getAppLanguage' | 'toggleBackButtonHandler' | 'removeAllListeners'>, 'appStateChange' | 'pause' | 'resume' | 'appUrlOpen' | 'appRestoredResult' | 'backButton'> {
|
|
42
|
+
}
|
|
43
|
+
export interface BackgroundRunnerCapability extends NativePluginCapability<ExtensibleOperation<'checkPermissions' | 'requestPermissions' | 'removeNotificationListeners'>, 'backgroundRunnerNotificationReceived'> {
|
|
44
|
+
}
|
|
45
|
+
export interface BarcodeScannerCapability extends NativePluginCapability<ExtensibleOperation<'scanBarcode'>> {
|
|
46
|
+
}
|
|
47
|
+
export interface BrowserCapability extends NativePluginCapability<ExtensibleOperation<'open' | 'close' | 'removeAllListeners'>, 'browserFinished' | 'browserPageLoaded'> {
|
|
48
|
+
}
|
|
49
|
+
export interface CalendarCapability extends NativePluginCapability<ExtensibleOperation<'checkPermissions' | 'requestPermissions' | 'createEvent' | 'createEventInteractively' | 'modifyEvent' | 'findEvents' | 'deleteEvent' | 'listCalendars' | 'createCalendar' | 'deleteCalendar' | 'openCalendar'>> {
|
|
50
|
+
}
|
|
51
|
+
export interface ClipboardCapability extends NativePluginCapability<ExtensibleOperation<'write' | 'read'>> {
|
|
52
|
+
}
|
|
53
|
+
export interface ContactsCapability extends NativePluginCapability<ExtensibleOperation<'find' | 'save' | 'remove' | 'pickContact'>> {
|
|
54
|
+
}
|
|
55
|
+
/** Cookies is bundled in @capacitor/core. */
|
|
56
|
+
export interface CookiesCapability extends NativePluginCapability<ExtensibleOperation<'getCookies' | 'setCookie' | 'deleteCookie' | 'clearCookies' | 'clearAllCookies'>> {
|
|
57
|
+
}
|
|
58
|
+
export interface DialogCapability extends NativePluginCapability<ExtensibleOperation<'alert' | 'prompt' | 'confirm'>> {
|
|
59
|
+
}
|
|
60
|
+
export interface FileTransferCapability extends NativePluginCapability<ExtensibleOperation<'downloadFile' | 'uploadFile' | 'removeAllListeners'>, 'progress'> {
|
|
61
|
+
}
|
|
62
|
+
export interface FileViewerCapability extends NativePluginCapability<ExtensibleOperation<'openDocumentFromLocalPath' | 'openDocumentFromResources' | 'openDocumentFromUrl' | 'previewMediaContentFromLocalPath' | 'previewMediaContentFromResources' | 'previewMediaContentFromUrl'>> {
|
|
63
|
+
}
|
|
64
|
+
export interface FilesystemCapability extends NativePluginCapability<ExtensibleOperation<'checkPermissions' | 'requestPermissions' | 'readFile' | 'writeFile' | 'appendFile' | 'deleteFile' | 'mkdir' | 'rmdir' | 'readdir' | 'getUri' | 'stat' | 'rename' | 'copy' | 'downloadFile'>, 'progress'> {
|
|
65
|
+
}
|
|
66
|
+
export interface GeolocationCapability extends NativePluginCapability<ExtensibleOperation<'getCurrentPosition' | 'watchPosition' | 'clearWatch' | 'checkPermissions' | 'requestPermissions'>> {
|
|
67
|
+
}
|
|
68
|
+
/** Google Maps creates stateful map instances behind this same capability boundary. */
|
|
69
|
+
export interface GoogleMapsCapability extends NativePluginCapability<ExtensibleOperation<'create' | 'destroy' | 'setCamera' | 'addMarker' | 'addMarkers' | 'removeMarker' | 'removeMarkers'>> {
|
|
70
|
+
}
|
|
71
|
+
export interface HapticsCapability extends NativePluginCapability<ExtensibleOperation<'impact' | 'notification' | 'vibrate' | 'selectionStart' | 'selectionChanged' | 'selectionEnd'>> {
|
|
72
|
+
}
|
|
73
|
+
export interface HealthFitnessCapability extends NativePluginCapability<ExtensibleOperation<'isAvailable' | 'requestAuthorization' | 'checkAuthorization' | 'query' | 'save' | 'delete' | 'setBackgroundJob' | 'disableBackgroundJob'>> {
|
|
74
|
+
}
|
|
75
|
+
/** HTTP is bundled in @capacitor/core. */
|
|
76
|
+
export interface HttpCapability extends NativePluginCapability<ExtensibleOperation<'request' | 'get' | 'post' | 'put' | 'patch' | 'delete' | 'setCookie' | 'clearCookies' | 'deleteCookie' | 'clearAllCookies'>> {
|
|
77
|
+
}
|
|
78
|
+
export interface InAppBrowserCapability extends NativePluginCapability<ExtensibleOperation<'openInWebView' | 'openInSystemBrowser' | 'openInExternalBrowser' | 'close' | 'removeAllListeners'>, 'browserPageLoaded' | 'browserPageNavigationCompleted' | 'browserClosed' | 'urlChange'> {
|
|
79
|
+
}
|
|
80
|
+
export interface KeyboardCapability extends NativePluginCapability<ExtensibleOperation<'show' | 'hide' | 'setAccessoryBarVisible' | 'setScroll' | 'setResizeMode' | 'getResizeMode' | 'removeAllListeners'>, 'keyboardWillShow' | 'keyboardDidShow' | 'keyboardWillHide' | 'keyboardDidHide'> {
|
|
81
|
+
}
|
|
82
|
+
/** Experimental Capacitor plugin. Always call isAvailable before invoking it. */
|
|
83
|
+
export interface LocalLlmCapability extends NativePluginCapability<ExtensibleOperation<'systemAvailability' | 'download' | 'prompt' | 'endSession' | 'generateImage' | 'warmup' | 'removeAllListeners'>, 'systemAvailabilityChange'> {
|
|
84
|
+
}
|
|
85
|
+
export interface LocalNotificationsCapability extends NativePluginCapability<ExtensibleOperation<'schedule' | 'update' | 'getPending' | 'registerActionTypes' | 'cancel' | 'cancelAll' | 'areEnabled' | 'getDeliveredNotifications' | 'removeDeliveredNotifications' | 'removeDeliveredNotificationsById' | 'removeAllDeliveredNotifications' | 'getByIds' | 'getAll' | 'createChannel' | 'deleteChannel' | 'listChannels' | 'checkPermissions' | 'requestPermissions' | 'changeExactNotificationSetting' | 'checkExactNotificationSetting' | 'removeAllListeners'>, 'localNotificationReceived' | 'localNotificationActionPerformed'> {
|
|
86
|
+
}
|
|
87
|
+
export interface MotionCapability extends NativePluginCapability<ExtensibleOperation<'removeAllListeners'>, 'accel' | 'orientation'> {
|
|
88
|
+
}
|
|
89
|
+
export interface NetworkCapability extends NativePluginCapability<ExtensibleOperation<'getStatus' | 'removeAllListeners'>, 'networkStatusChange'> {
|
|
90
|
+
}
|
|
91
|
+
export interface PreferencesCapability extends NativePluginCapability<ExtensibleOperation<'configure' | 'get' | 'set' | 'remove' | 'clear' | 'keys' | 'migrate' | 'removeOld'>> {
|
|
92
|
+
}
|
|
93
|
+
export interface PrivacyScreenCapability extends NativePluginCapability<ExtensibleOperation<'enable' | 'disable' | 'isEnabled'>> {
|
|
94
|
+
}
|
|
95
|
+
export interface PushNotificationsCapability extends NativePluginCapability<ExtensibleOperation<'register' | 'unregister' | 'getDeliveredNotifications' | 'removeDeliveredNotifications' | 'removeAllDeliveredNotifications' | 'createChannel' | 'deleteChannel' | 'listChannels' | 'checkPermissions' | 'requestPermissions' | 'removeAllListeners'>, 'registration' | 'registrationError' | 'pushNotificationReceived' | 'pushNotificationActionPerformed'> {
|
|
96
|
+
}
|
|
97
|
+
export interface ScreenOrientationCapability extends NativePluginCapability<ExtensibleOperation<'orientation' | 'lock' | 'unlock' | 'removeAllListeners'>, 'screenOrientationChange'> {
|
|
98
|
+
}
|
|
99
|
+
export interface ScreenReaderCapability extends NativePluginCapability<ExtensibleOperation<'isEnabled' | 'speak' | 'removeAllListeners'>, 'stateChange'> {
|
|
100
|
+
}
|
|
101
|
+
export interface ShareCapability extends NativePluginCapability<ExtensibleOperation<'canShare' | 'share'>> {
|
|
102
|
+
}
|
|
103
|
+
export interface SplashScreenCapability extends NativePluginCapability<ExtensibleOperation<'show' | 'hide'>> {
|
|
104
|
+
}
|
|
105
|
+
export interface StatusBarCapability extends NativePluginCapability<ExtensibleOperation<'setStyle' | 'setBackgroundColor' | 'show' | 'hide' | 'getInfo' | 'setOverlaysWebView'>, 'statusBarVisibilityChanged' | 'statusBarOverlayChanged'> {
|
|
106
|
+
}
|
|
107
|
+
/** System Bars is bundled in @capacitor/core and supersedes Status Bar for edge-to-edge layouts. */
|
|
108
|
+
export interface SystemBarsCapability extends NativePluginCapability<ExtensibleOperation<'setStyle' | 'show' | 'hide' | 'setAnimation'>> {
|
|
109
|
+
}
|
|
110
|
+
export interface TextZoomCapability extends NativePluginCapability<ExtensibleOperation<'get' | 'getPreferred' | 'set'>> {
|
|
111
|
+
}
|
|
112
|
+
export interface ToastCapability extends NativePluginCapability<ExtensibleOperation<'show'>> {
|
|
113
|
+
}
|
|
18
114
|
export interface NativeCapabilities {
|
|
115
|
+
/** Version 1 remains compatible with the original Device and Camera contract. */
|
|
19
116
|
readonly version: 1;
|
|
20
|
-
readonly
|
|
117
|
+
readonly actionSheet: ActionSheetCapability;
|
|
118
|
+
readonly app: AppCapability;
|
|
119
|
+
readonly appLauncher: AppLauncherCapability;
|
|
120
|
+
readonly backgroundRunner: BackgroundRunnerCapability;
|
|
121
|
+
readonly barcodeScanner: BarcodeScannerCapability;
|
|
122
|
+
readonly browser: BrowserCapability;
|
|
123
|
+
readonly calendar: CalendarCapability;
|
|
21
124
|
readonly camera: CameraCapability;
|
|
125
|
+
readonly clipboard: ClipboardCapability;
|
|
126
|
+
readonly contacts: ContactsCapability;
|
|
127
|
+
readonly cookies: CookiesCapability;
|
|
128
|
+
readonly device: DeviceCapability;
|
|
129
|
+
readonly dialog: DialogCapability;
|
|
130
|
+
readonly fileTransfer: FileTransferCapability;
|
|
131
|
+
readonly fileViewer: FileViewerCapability;
|
|
132
|
+
readonly filesystem: FilesystemCapability;
|
|
133
|
+
readonly geolocation: GeolocationCapability;
|
|
134
|
+
readonly googleMaps: GoogleMapsCapability;
|
|
135
|
+
readonly haptics: HapticsCapability;
|
|
136
|
+
readonly healthFitness: HealthFitnessCapability;
|
|
137
|
+
readonly http: HttpCapability;
|
|
138
|
+
readonly inAppBrowser: InAppBrowserCapability;
|
|
139
|
+
readonly keyboard: KeyboardCapability;
|
|
140
|
+
readonly localLlm: LocalLlmCapability;
|
|
141
|
+
readonly localNotifications: LocalNotificationsCapability;
|
|
142
|
+
readonly motion: MotionCapability;
|
|
143
|
+
readonly network: NetworkCapability;
|
|
144
|
+
readonly preferences: PreferencesCapability;
|
|
145
|
+
readonly privacyScreen: PrivacyScreenCapability;
|
|
146
|
+
readonly pushNotifications: PushNotificationsCapability;
|
|
147
|
+
readonly screenOrientation: ScreenOrientationCapability;
|
|
148
|
+
readonly screenReader: ScreenReaderCapability;
|
|
149
|
+
readonly share: ShareCapability;
|
|
150
|
+
readonly splashScreen: SplashScreenCapability;
|
|
151
|
+
readonly statusBar: StatusBarCapability;
|
|
152
|
+
readonly systemBars: SystemBarsCapability;
|
|
153
|
+
readonly textZoom: TextZoomCapability;
|
|
154
|
+
readonly toast: ToastCapability;
|
|
22
155
|
}
|
|
23
156
|
export declare const NATIVE_CAPABILITIES: InjectionToken<NativeCapabilities>;
|
|
24
157
|
export declare function injectNativeCapabilities(): NativeCapabilities;
|
|
158
|
+
export {};
|