@open-mova/core 0.1.9

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Open Mova contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,76 @@
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/rgarciadelongoria/open-mova/main/assets/brand/open-mova-logo-title-rectangle.png" alt="Open Mova" width="720">
3
+ </p>
4
+
5
+ # Open Mova Core
6
+
7
+ `open-mova-core` es la librería base del framework. Su objetivo es contener
8
+ contratos, tipos y utilidades transversales que puedan utilizar la shell y los
9
+ microfrontales.
10
+
11
+ Actualmente define el contrato `NativeCapabilities` v1 para Device y Camera,
12
+ el token de DI Angular y `injectNativeCapabilities()`. No depende de Capacitor.
13
+
14
+ ## Instalación
15
+
16
+ El microfrontal y la shell deben usar una versión compatible de Angular.
17
+
18
+ ```bash
19
+ npm install @open-mova/core
20
+ ```
21
+
22
+ ## Qué debe contener
23
+
24
+ Puede contener, por ejemplo:
25
+
26
+ - Contratos para servicios comunes.
27
+ - Tipos de configuración compartidos.
28
+ - Interfaces para capacidades nativas.
29
+ - Utilidades que no pertenezcan a una aplicación concreta.
30
+
31
+ ## Qué no debe contener
32
+
33
+ El core no debe incluir:
34
+
35
+ - Componentes ni lógica de interfaz de una aplicación.
36
+ - Dependencias de Capacitor.
37
+ - Lógica de negocio de un proveedor.
38
+ - Configuración de la shell.
39
+ - Código específico de un microfrontal.
40
+
41
+ La separación permite definir un contrato en el core y dejar que la shell
42
+ aporte su implementación. Por ejemplo, el core podría definir una interfaz de
43
+ almacenamiento y la shell implementarla más adelante con una API web o nativa.
44
+
45
+ ## Desarrollo
46
+
47
+ Este proyecto es autónomo y tiene sus propias dependencias:
48
+
49
+ ```bash
50
+ cd open-mova-core
51
+ npm install
52
+ npm run typecheck
53
+ npm run build
54
+ ```
55
+
56
+ El paquete se identifica como `@open-mova/core`. Cuando se añada una pieza
57
+ pública, debe exportarse desde `src/index.ts`.
58
+
59
+ La shell proporciona el token `NATIVE_CAPABILITIES` y el MF accede a él por DI:
60
+
61
+ ```ts
62
+ import { injectNativeCapabilities } from '@open-mova/core';
63
+
64
+ const native = injectNativeCapabilities(); // Dentro de un contexto de inyección Angular.
65
+ const device = await native.device.getInfo();
66
+ const photo = await native.camera.takePhoto();
67
+ const selected = await native.camera.choosePhoto();
68
+ ```
69
+
70
+ `photo.webPath` sirve para mostrar la imagen; `photo.uri` puede existir en
71
+ móvil. `choosePhoto()` devuelve `undefined` si la galería devuelve una lista
72
+ vacía; cancelar el diálogo puede rechazar la promesa según la plataforma.
73
+ 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`; en el
75
+ monorepo se instala por ruta local tras compilar la librería. Shell y MF deben
76
+ compartir una sola instancia de core mediante Native Federation.
@@ -0,0 +1,2 @@
1
+ export type { CameraCapability, DeviceCapability, DeviceDetails, NativeCapabilities, PhotoResult, } from './native.js';
2
+ export { NATIVE_CAPABILITIES, injectNativeCapabilities } from './native.js';
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export { NATIVE_CAPABILITIES, injectNativeCapabilities } from './native.js';
@@ -0,0 +1,24 @@
1
+ import { InjectionToken } from '@angular/core';
2
+ export interface DeviceDetails {
3
+ readonly model: string;
4
+ readonly platform: 'ios' | 'android' | 'web';
5
+ readonly osVersion: string;
6
+ }
7
+ export interface DeviceCapability {
8
+ getInfo(): Promise<DeviceDetails>;
9
+ }
10
+ export interface PhotoResult {
11
+ readonly webPath?: string;
12
+ readonly uri?: string;
13
+ }
14
+ export interface CameraCapability {
15
+ takePhoto(): Promise<PhotoResult>;
16
+ choosePhoto(): Promise<PhotoResult | undefined>;
17
+ }
18
+ export interface NativeCapabilities {
19
+ readonly version: 1;
20
+ readonly device: DeviceCapability;
21
+ readonly camera: CameraCapability;
22
+ }
23
+ export declare const NATIVE_CAPABILITIES: InjectionToken<NativeCapabilities>;
24
+ export declare function injectNativeCapabilities(): NativeCapabilities;
package/dist/native.js ADDED
@@ -0,0 +1,10 @@
1
+ import { InjectionToken, inject } from '@angular/core';
2
+ // Shell y remotos deben compartir una sola instancia de este token.
3
+ export const NATIVE_CAPABILITIES = new InjectionToken('Open Mova native capabilities');
4
+ export function injectNativeCapabilities() {
5
+ const capabilities = inject(NATIVE_CAPABILITIES);
6
+ if (capabilities.version !== 1) {
7
+ throw new Error('La shell no ofrece el contrato nativo Open Mova v1.');
8
+ }
9
+ return capabilities;
10
+ }
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@open-mova/core",
3
+ "version": "0.1.9",
4
+ "description": "Contratos y utilidades Angular compartidas de Open Mova",
5
+ "license": "MIT",
6
+ "author": "Open Mova contributors",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/rgarciadelongoria/open-mova.git",
10
+ "directory": "open-mova-core"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/rgarciadelongoria/open-mova/issues"
14
+ },
15
+ "homepage": "https://github.com/rgarciadelongoria/open-mova#readme",
16
+ "keywords": [
17
+ "angular",
18
+ "capacitor",
19
+ "dependency-injection",
20
+ "microfrontends",
21
+ "open-mova"
22
+ ],
23
+ "engines": {
24
+ "node": ">=22"
25
+ },
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "files": [
30
+ "dist",
31
+ "README.md",
32
+ "LICENSE"
33
+ ],
34
+ "type": "module",
35
+ "main": "dist/index.js",
36
+ "types": "dist/index.d.ts",
37
+ "exports": {
38
+ ".": {
39
+ "types": "./dist/index.d.ts",
40
+ "import": "./dist/index.js"
41
+ }
42
+ },
43
+ "scripts": {
44
+ "build": "tsc -p tsconfig.json",
45
+ "typecheck": "tsc -p tsconfig.json --noEmit"
46
+ },
47
+ "peerDependencies": {
48
+ "@angular/core": "^21.2.23"
49
+ },
50
+ "devDependencies": {
51
+ "@angular/core": "^21.2.23",
52
+ "typescript": "^5.9.3"
53
+ }
54
+ }