@mohamedatia/fly-design-system 1.0.0 → 1.1.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.
|
@@ -1,21 +1,229 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, signal, computed, Injectable, inject, Pipe } from '@angular/core';
|
|
2
3
|
|
|
3
4
|
const WINDOW_DATA = new InjectionToken('WINDOW_DATA');
|
|
4
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Shared AuthService for Business Apps.
|
|
8
|
+
*
|
|
9
|
+
* This is a **read-only signal store** — Business Apps inject it to read the
|
|
10
|
+
* current user and access token. The FlyOS shell populates it after PKCE login
|
|
11
|
+
* and silent refresh. Business Apps must never call setSession() directly.
|
|
12
|
+
*
|
|
13
|
+
* When running as a Module Federation remote, the shell and the Business App
|
|
14
|
+
* share this singleton via the `@mohamedatia/fly-design-system` shared mapping
|
|
15
|
+
* in federation.config.js — so the shell's populated instance is the same
|
|
16
|
+
* object the Business App reads.
|
|
17
|
+
*
|
|
18
|
+
* When running standalone (without the shell), call initFromToken() with a
|
|
19
|
+
* JWT stored in localStorage to hydrate the user.
|
|
20
|
+
*/
|
|
21
|
+
class AuthService {
|
|
22
|
+
_session = signal(null, ...(ngDevMode ? [{ debugName: "_session" }] : /* istanbul ignore next */ []));
|
|
23
|
+
currentUser = computed(() => this._session()?.user ?? null, ...(ngDevMode ? [{ debugName: "currentUser" }] : /* istanbul ignore next */ []));
|
|
24
|
+
accessToken = computed(() => this._session()?.accessToken ?? null, ...(ngDevMode ? [{ debugName: "accessToken" }] : /* istanbul ignore next */ []));
|
|
25
|
+
isAuthenticated = computed(() => {
|
|
26
|
+
const s = this._session();
|
|
27
|
+
return s !== null && s.expiresAt > Date.now();
|
|
28
|
+
}, ...(ngDevMode ? [{ debugName: "isAuthenticated" }] : /* istanbul ignore next */ []));
|
|
29
|
+
/**
|
|
30
|
+
* Called by the shell after a successful login or silent refresh.
|
|
31
|
+
* Business Apps should not call this directly.
|
|
32
|
+
*/
|
|
33
|
+
setSession(user, accessToken, expiresAt) {
|
|
34
|
+
this._session.set({ user, accessToken, expiresAt });
|
|
35
|
+
}
|
|
36
|
+
/** Clears the in-memory session (called by the shell on logout). */
|
|
37
|
+
clearSession() {
|
|
38
|
+
this._session.set(null);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Standalone mode: parse a JWT from localStorage and hydrate the user.
|
|
42
|
+
* Key defaults to "circles_token" but can be overridden.
|
|
43
|
+
*/
|
|
44
|
+
initFromToken(storageKey = 'circles_token') {
|
|
45
|
+
const token = localStorage.getItem(storageKey);
|
|
46
|
+
if (!token)
|
|
47
|
+
return;
|
|
48
|
+
try {
|
|
49
|
+
const base64 = token.split('.')[1].replace(/-/g, '+').replace(/_/g, '/');
|
|
50
|
+
const payload = JSON.parse(decodeURIComponent(atob(base64).split('').map(c => '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)).join('')));
|
|
51
|
+
const rawRole = payload['role'];
|
|
52
|
+
const roles = Array.isArray(rawRole) ? rawRole : rawRole ? [rawRole] : [];
|
|
53
|
+
const rawApps = payload['apps'];
|
|
54
|
+
const apps = Array.isArray(rawApps) ? rawApps : rawApps ? [rawApps] : [];
|
|
55
|
+
const name = payload['name'] ?? '';
|
|
56
|
+
const nameParts = name.split(' ');
|
|
57
|
+
const user = {
|
|
58
|
+
id: payload['sub'] ?? '',
|
|
59
|
+
tenantId: payload['tenant_id'] ?? payload['tid'] ?? null,
|
|
60
|
+
email: payload['email'] ?? '',
|
|
61
|
+
fullName: name,
|
|
62
|
+
firstName: nameParts[0] ?? '',
|
|
63
|
+
lastName: nameParts.slice(1).join(' '),
|
|
64
|
+
preferredLocale: payload['locale'] ?? 'en',
|
|
65
|
+
roles,
|
|
66
|
+
apps,
|
|
67
|
+
ou: payload['ou'],
|
|
68
|
+
};
|
|
69
|
+
const expiresAt = (payload['exp'] ?? 0) * 1000;
|
|
70
|
+
this.setSession(user, token, expiresAt);
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
// Invalid token — stay unauthenticated
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: AuthService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
77
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: AuthService, providedIn: 'root' });
|
|
78
|
+
}
|
|
79
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: AuthService, decorators: [{
|
|
80
|
+
type: Injectable,
|
|
81
|
+
args: [{ providedIn: 'root' }]
|
|
82
|
+
}] });
|
|
83
|
+
|
|
84
|
+
const RTL_LOCALES = new Set(['ar', 'ur']);
|
|
85
|
+
/**
|
|
86
|
+
* Shared I18nService for Business Apps.
|
|
87
|
+
*
|
|
88
|
+
* Loads locale JSON files from a configurable base URL and exposes a `t()`
|
|
89
|
+
* method for key-based translation with optional interpolation.
|
|
90
|
+
*
|
|
91
|
+
* In FlyOS-integrated mode the shell calls loadLocale() on startup and
|
|
92
|
+
* whenever the user switches language — the singleton is shared via Module
|
|
93
|
+
* Federation so Business Apps automatically see the updated translations.
|
|
94
|
+
*
|
|
95
|
+
* In standalone mode, call loadLocale() from your app bootstrap with the
|
|
96
|
+
* locale base URL configured in your backend (Frontend:LocaleBaseUrl).
|
|
97
|
+
*/
|
|
98
|
+
class I18nService {
|
|
99
|
+
_translations = signal({}, ...(ngDevMode ? [{ debugName: "_translations" }] : /* istanbul ignore next */ []));
|
|
100
|
+
_locale = signal('en', ...(ngDevMode ? [{ debugName: "_locale" }] : /* istanbul ignore next */ []));
|
|
101
|
+
locale = this._locale.asReadonly();
|
|
102
|
+
isRtl = computed(() => RTL_LOCALES.has(this._locale()), ...(ngDevMode ? [{ debugName: "isRtl" }] : /* istanbul ignore next */ []));
|
|
103
|
+
direction = computed(() => RTL_LOCALES.has(this._locale()) ? 'rtl' : 'ltr', ...(ngDevMode ? [{ debugName: "direction" }] : /* istanbul ignore next */ []));
|
|
104
|
+
/**
|
|
105
|
+
* Loads translations from `{localeBaseUrl}{lang}.json` and merges them into
|
|
106
|
+
* the current translation map. Subsequent calls for the same language
|
|
107
|
+
* replace the previous entries for that language.
|
|
108
|
+
*
|
|
109
|
+
* @param localeBaseUrl Base URL ending with `/`, e.g. `https://cdn.example.com/locale/`
|
|
110
|
+
* @param lang Locale code, e.g. `'en'`, `'ar'`
|
|
111
|
+
*/
|
|
112
|
+
async loadLocale(localeBaseUrl, lang) {
|
|
113
|
+
try {
|
|
114
|
+
const url = localeBaseUrl.endsWith('/') ? `${localeBaseUrl}${lang}.json` : `${localeBaseUrl}/${lang}.json`;
|
|
115
|
+
const resp = await fetch(url);
|
|
116
|
+
if (!resp.ok)
|
|
117
|
+
throw new Error(`HTTP ${resp.status}`);
|
|
118
|
+
const data = await resp.json();
|
|
119
|
+
this._translations.update(current => ({ ...current, ...data }));
|
|
120
|
+
this._locale.set(lang);
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
// Locale file not available — keep existing translations
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Merges a pre-loaded translations object directly (useful when the shell
|
|
128
|
+
* has already fetched the locale and wants to push it to Business Apps).
|
|
129
|
+
*/
|
|
130
|
+
mergeTranslations(translations, lang) {
|
|
131
|
+
this._translations.update(current => ({ ...current, ...translations }));
|
|
132
|
+
if (lang)
|
|
133
|
+
this._locale.set(lang);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Translates a key, with optional `{{param}}` interpolation.
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* i18n.t('circles.signals.title')
|
|
140
|
+
* i18n.t('circles.items_count', { n: '5' })
|
|
141
|
+
*/
|
|
142
|
+
t(key, params) {
|
|
143
|
+
const val = this._translations()[key] ?? key;
|
|
144
|
+
if (!params)
|
|
145
|
+
return val;
|
|
146
|
+
return Object.entries(params).reduce((result, [k, v]) => result.replace(new RegExp(`{{\\s*${k}\\s*}}`, 'g'), String(v)), val);
|
|
147
|
+
}
|
|
148
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: I18nService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
149
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: I18nService, providedIn: 'root' });
|
|
150
|
+
}
|
|
151
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: I18nService, decorators: [{
|
|
152
|
+
type: Injectable,
|
|
153
|
+
args: [{ providedIn: 'root' }]
|
|
154
|
+
}] });
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Abstract interface for the WindowManager.
|
|
158
|
+
* The FlyOS shell provides the concrete implementation; Business Apps
|
|
159
|
+
* inject this token to open, close, and focus windows without depending
|
|
160
|
+
* on the shell's internal implementation.
|
|
161
|
+
*/
|
|
162
|
+
class WindowManagerService {
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* No-op fallback implementation used when running a Business App in
|
|
166
|
+
* standalone mode (outside the FlyOS shell). Logs a warning instead of
|
|
167
|
+
* throwing so standalone dev/test flows are not broken.
|
|
168
|
+
*/
|
|
169
|
+
class StandaloneWindowManagerService extends WindowManagerService {
|
|
170
|
+
openChildWindow(options) {
|
|
171
|
+
console.warn('[WindowManagerService] openChildWindow called in standalone mode — no shell available.', options);
|
|
172
|
+
}
|
|
173
|
+
closeWindow(windowId) {
|
|
174
|
+
console.warn('[WindowManagerService] closeWindow called in standalone mode — no shell available.', windowId);
|
|
175
|
+
}
|
|
176
|
+
focusWindow(windowId) {
|
|
177
|
+
console.warn('[WindowManagerService] focusWindow called in standalone mode — no shell available.', windowId);
|
|
178
|
+
}
|
|
179
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: StandaloneWindowManagerService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
180
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: StandaloneWindowManagerService });
|
|
181
|
+
}
|
|
182
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: StandaloneWindowManagerService, decorators: [{
|
|
183
|
+
type: Injectable
|
|
184
|
+
}] });
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Translates a key using the shared I18nService.
|
|
188
|
+
*
|
|
189
|
+
* @example
|
|
190
|
+
* {{ 'circles.signals.title' | translate }}
|
|
191
|
+
* {{ 'circles.items_count' | translate:{ n: count() } }}
|
|
192
|
+
*/
|
|
193
|
+
class TranslatePipe {
|
|
194
|
+
i18n = inject(I18nService);
|
|
195
|
+
transform(key, params) {
|
|
196
|
+
return this.i18n.t(key, params);
|
|
197
|
+
}
|
|
198
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: TranslatePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
199
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.2.5", ngImport: i0, type: TranslatePipe, isStandalone: true, name: "translate", pure: false });
|
|
200
|
+
}
|
|
201
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: TranslatePipe, decorators: [{
|
|
202
|
+
type: Pipe,
|
|
203
|
+
args: [{
|
|
204
|
+
name: 'translate',
|
|
205
|
+
standalone: true,
|
|
206
|
+
pure: false,
|
|
207
|
+
}]
|
|
208
|
+
}] });
|
|
209
|
+
|
|
5
210
|
/*
|
|
6
|
-
* @fly
|
|
211
|
+
* @mohamedatia/fly-design-system — Public API
|
|
212
|
+
* https://www.npmjs.com/package/@mohamedatia/fly-design-system
|
|
7
213
|
*
|
|
8
214
|
* This is the single entry point for Business App developers.
|
|
9
|
-
* Import everything from '@fly
|
|
215
|
+
* Import everything from '@mohamedatia/fly-design-system' — never from relative shell paths.
|
|
216
|
+
*
|
|
217
|
+
* NOTE: This package is published under @mohamedatia/fly-design-system until the @fly
|
|
218
|
+
* npm org is created. It will be republished as @fly/design-system once available.
|
|
10
219
|
*
|
|
11
|
-
* v1.
|
|
12
|
-
*
|
|
13
|
-
* subsequent releases as they are extracted from the shell.
|
|
220
|
+
* v1.1.0 adds AuthService, I18nService, WindowManagerService, TranslatePipe, and the
|
|
221
|
+
* User model — the full set of shared services documented in BusinessAppsGuide/03-frontend-app.md.
|
|
14
222
|
*/
|
|
15
223
|
|
|
16
224
|
/**
|
|
17
225
|
* Generated bundle index. Do not edit.
|
|
18
226
|
*/
|
|
19
227
|
|
|
20
|
-
export { WINDOW_DATA };
|
|
228
|
+
export { AuthService, I18nService, StandaloneWindowManagerService, TranslatePipe, WINDOW_DATA, WindowManagerService };
|
|
21
229
|
//# sourceMappingURL=mohamedatia-fly-design-system.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mohamedatia-fly-design-system.mjs","sources":["../../../projects/design-system/src/lib/models/window.model.ts","../../../projects/design-system/src/public-api.ts","../../../projects/design-system/src/mohamedatia-fly-design-system.ts"],"sourcesContent":["import { InjectionToken, Type } from '@angular/core';\r\n\r\nexport type WindowState = 'normal' | 'minimized' | 'maximized';\r\n\r\nexport interface ChildWindowData {\r\n childComponent: Type<unknown>;\r\n [key: string]: unknown;\r\n}\r\n\r\nexport interface WindowInstance {\r\n id: string;\r\n appId: string;\r\n title: string;\r\n icon: string;\r\n iconBg: string;\r\n state: WindowState;\r\n position: { x: number; y: number };\r\n size: { width: number; height: number };\r\n zIndex: number;\r\n isFocused: boolean;\r\n isClosing?: boolean;\r\n isMinimizing?: boolean;\r\n isRestoring?: boolean;\r\n isMaximizing?: boolean;\r\n isUnmaximizing?: boolean;\r\n parentWindowId?: string;\r\n childData?: ChildWindowData;\r\n}\r\n\r\nexport const WINDOW_DATA = new InjectionToken<WindowInstance>('WINDOW_DATA');\r\n","/*\r\n * @fly/design-system — Public API\r\n *\r\n * This is the single entry point for Business App developers.\r\n * Import everything from '@fly/design-system' — never from relative shell paths.\r\n *\r\n * v1.0.0 exports the core models and tokens needed to integrate with the\r\n * FlyOS desktop shell. Components, directives, and pipes will be added in\r\n * subsequent releases as they are extracted from the shell.\r\n */\r\n\r\n// ─── Models ──────────────────────────────────────────────────────────────────\r\nexport type { DesktopApp } from './lib/models/app.model';\r\nexport type {\r\n WindowInstance,\r\n WindowState,\r\n ChildWindowData,\r\n} from './lib/models/window.model';\r\nexport { WINDOW_DATA } from './lib/models/window.model';\r\n\r\n// ─── Remote App Registration ─────────────────────────────────────────────────\r\nexport type { RemoteAppDef } from './lib/models/remote-app.model';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;MA6Ba,WAAW,GAAG,IAAI,cAAc,CAAiB,aAAa;;AC7B3E;;;;;;;;;AASG;;ACTH;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"mohamedatia-fly-design-system.mjs","sources":["../../../projects/design-system/src/lib/models/window.model.ts","../../../projects/design-system/src/lib/services/auth.service.ts","../../../projects/design-system/src/lib/services/i18n.service.ts","../../../projects/design-system/src/lib/services/window-manager.service.ts","../../../projects/design-system/src/lib/pipes/translate.pipe.ts","../../../projects/design-system/src/public-api.ts","../../../projects/design-system/src/mohamedatia-fly-design-system.ts"],"sourcesContent":["import { InjectionToken, Type } from '@angular/core';\r\n\r\nexport type WindowState = 'normal' | 'minimized' | 'maximized';\r\n\r\nexport interface ChildWindowData {\r\n childComponent: Type<unknown>;\r\n [key: string]: unknown;\r\n}\r\n\r\nexport interface WindowInstance {\r\n id: string;\r\n appId: string;\r\n title: string;\r\n icon: string;\r\n iconBg: string;\r\n state: WindowState;\r\n position: { x: number; y: number };\r\n size: { width: number; height: number };\r\n zIndex: number;\r\n isFocused: boolean;\r\n isClosing?: boolean;\r\n isMinimizing?: boolean;\r\n isRestoring?: boolean;\r\n isMaximizing?: boolean;\r\n isUnmaximizing?: boolean;\r\n parentWindowId?: string;\r\n childData?: ChildWindowData;\r\n}\r\n\r\nexport const WINDOW_DATA = new InjectionToken<WindowInstance>('WINDOW_DATA');\r\n","import { Injectable, computed, signal } from '@angular/core';\nimport { User } from '../models/user.model';\n\ninterface AuthSession {\n user: User;\n accessToken: string;\n expiresAt: number;\n}\n\n/**\n * Shared AuthService for Business Apps.\n *\n * This is a **read-only signal store** — Business Apps inject it to read the\n * current user and access token. The FlyOS shell populates it after PKCE login\n * and silent refresh. Business Apps must never call setSession() directly.\n *\n * When running as a Module Federation remote, the shell and the Business App\n * share this singleton via the `@mohamedatia/fly-design-system` shared mapping\n * in federation.config.js — so the shell's populated instance is the same\n * object the Business App reads.\n *\n * When running standalone (without the shell), call initFromToken() with a\n * JWT stored in localStorage to hydrate the user.\n */\n@Injectable({ providedIn: 'root' })\nexport class AuthService {\n private _session = signal<AuthSession | null>(null);\n\n readonly currentUser = computed(() => this._session()?.user ?? null);\n readonly accessToken = computed(() => this._session()?.accessToken ?? null);\n readonly isAuthenticated = computed(() => {\n const s = this._session();\n return s !== null && s.expiresAt > Date.now();\n });\n\n /**\n * Called by the shell after a successful login or silent refresh.\n * Business Apps should not call this directly.\n */\n setSession(user: User, accessToken: string, expiresAt: number): void {\n this._session.set({ user, accessToken, expiresAt });\n }\n\n /** Clears the in-memory session (called by the shell on logout). */\n clearSession(): void {\n this._session.set(null);\n }\n\n /**\n * Standalone mode: parse a JWT from localStorage and hydrate the user.\n * Key defaults to \"circles_token\" but can be overridden.\n */\n initFromToken(storageKey = 'circles_token'): void {\n const token = localStorage.getItem(storageKey);\n if (!token) return;\n try {\n const base64 = token.split('.')[1].replace(/-/g, '+').replace(/_/g, '/');\n const payload = JSON.parse(decodeURIComponent(\n atob(base64).split('').map(c => '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)).join('')\n )) as Record<string, unknown>;\n\n const rawRole = payload['role'];\n const roles = Array.isArray(rawRole) ? rawRole as string[] : rawRole ? [rawRole as string] : [];\n const rawApps = payload['apps'];\n const apps = Array.isArray(rawApps) ? rawApps as string[] : rawApps ? [rawApps as string] : [];\n const name = (payload['name'] as string) ?? '';\n const nameParts = name.split(' ');\n\n const user: User = {\n id: (payload['sub'] as string) ?? '',\n tenantId: (payload['tenant_id'] as string) ?? (payload['tid'] as string) ?? null,\n email: (payload['email'] as string) ?? '',\n fullName: name,\n firstName: nameParts[0] ?? '',\n lastName: nameParts.slice(1).join(' '),\n preferredLocale: (payload['locale'] as string) ?? 'en',\n roles,\n apps,\n ou: payload['ou'] as string | undefined,\n };\n\n const expiresAt = ((payload['exp'] as number) ?? 0) * 1000;\n this.setSession(user, token, expiresAt);\n } catch {\n // Invalid token — stay unauthenticated\n }\n }\n}\n","import { Injectable, computed, signal } from '@angular/core';\n\nconst RTL_LOCALES: ReadonlySet<string> = new Set(['ar', 'ur']);\n\n/**\n * Shared I18nService for Business Apps.\n *\n * Loads locale JSON files from a configurable base URL and exposes a `t()`\n * method for key-based translation with optional interpolation.\n *\n * In FlyOS-integrated mode the shell calls loadLocale() on startup and\n * whenever the user switches language — the singleton is shared via Module\n * Federation so Business Apps automatically see the updated translations.\n *\n * In standalone mode, call loadLocale() from your app bootstrap with the\n * locale base URL configured in your backend (Frontend:LocaleBaseUrl).\n */\n@Injectable({ providedIn: 'root' })\nexport class I18nService {\n private _translations = signal<Record<string, string>>({});\n private _locale = signal<string>('en');\n\n readonly locale = this._locale.asReadonly();\n readonly isRtl = computed(() => RTL_LOCALES.has(this._locale()));\n readonly direction = computed(() => RTL_LOCALES.has(this._locale()) ? 'rtl' : 'ltr');\n\n /**\n * Loads translations from `{localeBaseUrl}{lang}.json` and merges them into\n * the current translation map. Subsequent calls for the same language\n * replace the previous entries for that language.\n *\n * @param localeBaseUrl Base URL ending with `/`, e.g. `https://cdn.example.com/locale/`\n * @param lang Locale code, e.g. `'en'`, `'ar'`\n */\n async loadLocale(localeBaseUrl: string, lang: string): Promise<void> {\n try {\n const url = localeBaseUrl.endsWith('/') ? `${localeBaseUrl}${lang}.json` : `${localeBaseUrl}/${lang}.json`;\n const resp = await fetch(url);\n if (!resp.ok) throw new Error(`HTTP ${resp.status}`);\n const data = await resp.json() as Record<string, string>;\n this._translations.update(current => ({ ...current, ...data }));\n this._locale.set(lang);\n } catch {\n // Locale file not available — keep existing translations\n }\n }\n\n /**\n * Merges a pre-loaded translations object directly (useful when the shell\n * has already fetched the locale and wants to push it to Business Apps).\n */\n mergeTranslations(translations: Record<string, string>, lang?: string): void {\n this._translations.update(current => ({ ...current, ...translations }));\n if (lang) this._locale.set(lang);\n }\n\n /**\n * Translates a key, with optional `{{param}}` interpolation.\n *\n * @example\n * i18n.t('circles.signals.title')\n * i18n.t('circles.items_count', { n: '5' })\n */\n t(key: string, params?: Record<string, string | number>): string {\n const val = this._translations()[key] ?? key;\n if (!params) return val;\n return Object.entries(params).reduce(\n (result, [k, v]) => result.replace(new RegExp(`{{\\\\s*${k}\\\\s*}}`, 'g'), String(v)),\n val,\n );\n }\n}\n","import { Injectable } from '@angular/core';\n\n/** Options for opening a child window. */\nexport interface OpenWindowOptions {\n /** Unique identifier for the window instance. */\n windowId: string;\n /** Display title shown in the window chrome. */\n title: string;\n /** Route path or URL to load inside the window. */\n route: string;\n /** Initial width in pixels. Defaults to 900. */\n width?: number;\n /** Initial height in pixels. Defaults to 600. */\n height?: number;\n /** Whether the window can be resized. Defaults to true. */\n resizable?: boolean;\n /** Whether the window can be maximised. Defaults to true. */\n maximizable?: boolean;\n /** Arbitrary data passed to the child window via WINDOW_DATA. */\n data?: unknown;\n}\n\n/**\n * Abstract interface for the WindowManager.\n * The FlyOS shell provides the concrete implementation; Business Apps\n * inject this token to open, close, and focus windows without depending\n * on the shell's internal implementation.\n */\nexport abstract class WindowManagerService {\n abstract openChildWindow(options: OpenWindowOptions): void;\n abstract closeWindow(windowId: string): void;\n abstract focusWindow(windowId: string): void;\n}\n\n/**\n * No-op fallback implementation used when running a Business App in\n * standalone mode (outside the FlyOS shell). Logs a warning instead of\n * throwing so standalone dev/test flows are not broken.\n */\n@Injectable()\nexport class StandaloneWindowManagerService extends WindowManagerService {\n openChildWindow(options: OpenWindowOptions): void {\n console.warn('[WindowManagerService] openChildWindow called in standalone mode — no shell available.', options);\n }\n\n closeWindow(windowId: string): void {\n console.warn('[WindowManagerService] closeWindow called in standalone mode — no shell available.', windowId);\n }\n\n focusWindow(windowId: string): void {\n console.warn('[WindowManagerService] focusWindow called in standalone mode — no shell available.', windowId);\n }\n}\n\n","import { Pipe, PipeTransform, inject } from '@angular/core';\nimport { I18nService } from '../services/i18n.service';\n\n/**\n * Translates a key using the shared I18nService.\n *\n * @example\n * {{ 'circles.signals.title' | translate }}\n * {{ 'circles.items_count' | translate:{ n: count() } }}\n */\n@Pipe({\n name: 'translate',\n standalone: true,\n pure: false,\n})\nexport class TranslatePipe implements PipeTransform {\n private readonly i18n = inject(I18nService);\n\n transform(key: string, params?: Record<string, string | number>): string {\n return this.i18n.t(key, params);\n }\n}\n","/*\r\n * @mohamedatia/fly-design-system — Public API\r\n * https://www.npmjs.com/package/@mohamedatia/fly-design-system\r\n *\r\n * This is the single entry point for Business App developers.\r\n * Import everything from '@mohamedatia/fly-design-system' — never from relative shell paths.\r\n *\r\n * NOTE: This package is published under @mohamedatia/fly-design-system until the @fly\r\n * npm org is created. It will be republished as @fly/design-system once available.\r\n *\r\n * v1.1.0 adds AuthService, I18nService, WindowManagerService, TranslatePipe, and the\r\n * User model — the full set of shared services documented in BusinessAppsGuide/03-frontend-app.md.\r\n */\r\n\r\n// ─── Models ──────────────────────────────────────────────────────────────────\r\nexport type { DesktopApp } from './lib/models/app.model';\r\nexport type {\r\n WindowInstance,\r\n WindowState,\r\n ChildWindowData,\r\n} from './lib/models/window.model';\r\nexport { WINDOW_DATA } from './lib/models/window.model';\r\nexport type { User } from './lib/models/user.model';\r\n\r\n// ─── Remote App Registration ─────────────────────────────────────────────────\r\nexport type { RemoteAppDef } from './lib/models/remote-app.model';\r\n\r\n// ─── Services ────────────────────────────────────────────────────────────────\r\nexport { AuthService } from './lib/services/auth.service';\r\nexport { I18nService } from './lib/services/i18n.service';\r\nexport {\r\n WindowManagerService,\r\n StandaloneWindowManagerService,\r\n type OpenWindowOptions,\r\n} from './lib/services/window-manager.service';\r\n\r\n// ─── Pipes ───────────────────────────────────────────────────────────────────\r\nexport { TranslatePipe } from './lib/pipes/translate.pipe';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;MA6Ba,WAAW,GAAG,IAAI,cAAc,CAAiB,aAAa;;ACpB3E;;;;;;;;;;;;;;AAcG;MAEU,WAAW,CAAA;AACd,IAAA,QAAQ,GAAG,MAAM,CAAqB,IAAI,+EAAC;AAE1C,IAAA,WAAW,GAAG,QAAQ,CAAC,MAAM,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,IAAI,IAAI,kFAAC;AAC3D,IAAA,WAAW,GAAG,QAAQ,CAAC,MAAM,IAAI,CAAC,QAAQ,EAAE,EAAE,WAAW,IAAI,IAAI,kFAAC;AAClE,IAAA,eAAe,GAAG,QAAQ,CAAC,MAAK;AACvC,QAAA,MAAM,CAAC,GAAG,IAAI,CAAC,QAAQ,EAAE;AACzB,QAAA,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE;AAC/C,IAAA,CAAC,sFAAC;AAEF;;;AAGG;AACH,IAAA,UAAU,CAAC,IAAU,EAAE,WAAmB,EAAE,SAAiB,EAAA;AAC3D,QAAA,IAAI,CAAC,QAAQ,CAAC,GA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 from '@angular/core';
|
|
2
|
+
import { Type, InjectionToken, PipeTransform } from '@angular/core';
|
|
2
3
|
|
|
3
4
|
interface DesktopApp {
|
|
4
5
|
id: string;
|
|
@@ -52,6 +53,19 @@ interface WindowInstance {
|
|
|
52
53
|
}
|
|
53
54
|
declare const WINDOW_DATA: InjectionToken<WindowInstance>;
|
|
54
55
|
|
|
56
|
+
interface User {
|
|
57
|
+
id: string;
|
|
58
|
+
tenantId: string | null;
|
|
59
|
+
email: string;
|
|
60
|
+
fullName: string;
|
|
61
|
+
firstName: string;
|
|
62
|
+
lastName: string;
|
|
63
|
+
preferredLocale: string;
|
|
64
|
+
roles: string[];
|
|
65
|
+
apps: string[];
|
|
66
|
+
ou?: string;
|
|
67
|
+
}
|
|
68
|
+
|
|
55
69
|
/**
|
|
56
70
|
* Describes a Business App remote registered via the Controller App's
|
|
57
71
|
* /api/apps/manifest endpoint. The shell loads the component at runtime
|
|
@@ -80,6 +94,144 @@ interface RemoteAppDef {
|
|
|
80
94
|
chromeless?: boolean;
|
|
81
95
|
}
|
|
82
96
|
|
|
83
|
-
|
|
84
|
-
|
|
97
|
+
/**
|
|
98
|
+
* Shared AuthService for Business Apps.
|
|
99
|
+
*
|
|
100
|
+
* This is a **read-only signal store** — Business Apps inject it to read the
|
|
101
|
+
* current user and access token. The FlyOS shell populates it after PKCE login
|
|
102
|
+
* and silent refresh. Business Apps must never call setSession() directly.
|
|
103
|
+
*
|
|
104
|
+
* When running as a Module Federation remote, the shell and the Business App
|
|
105
|
+
* share this singleton via the `@mohamedatia/fly-design-system` shared mapping
|
|
106
|
+
* in federation.config.js — so the shell's populated instance is the same
|
|
107
|
+
* object the Business App reads.
|
|
108
|
+
*
|
|
109
|
+
* When running standalone (without the shell), call initFromToken() with a
|
|
110
|
+
* JWT stored in localStorage to hydrate the user.
|
|
111
|
+
*/
|
|
112
|
+
declare class AuthService {
|
|
113
|
+
private _session;
|
|
114
|
+
readonly currentUser: i0.Signal<User | null>;
|
|
115
|
+
readonly accessToken: i0.Signal<string | null>;
|
|
116
|
+
readonly isAuthenticated: i0.Signal<boolean>;
|
|
117
|
+
/**
|
|
118
|
+
* Called by the shell after a successful login or silent refresh.
|
|
119
|
+
* Business Apps should not call this directly.
|
|
120
|
+
*/
|
|
121
|
+
setSession(user: User, accessToken: string, expiresAt: number): void;
|
|
122
|
+
/** Clears the in-memory session (called by the shell on logout). */
|
|
123
|
+
clearSession(): void;
|
|
124
|
+
/**
|
|
125
|
+
* Standalone mode: parse a JWT from localStorage and hydrate the user.
|
|
126
|
+
* Key defaults to "circles_token" but can be overridden.
|
|
127
|
+
*/
|
|
128
|
+
initFromToken(storageKey?: string): void;
|
|
129
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AuthService, never>;
|
|
130
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<AuthService>;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Shared I18nService for Business Apps.
|
|
135
|
+
*
|
|
136
|
+
* Loads locale JSON files from a configurable base URL and exposes a `t()`
|
|
137
|
+
* method for key-based translation with optional interpolation.
|
|
138
|
+
*
|
|
139
|
+
* In FlyOS-integrated mode the shell calls loadLocale() on startup and
|
|
140
|
+
* whenever the user switches language — the singleton is shared via Module
|
|
141
|
+
* Federation so Business Apps automatically see the updated translations.
|
|
142
|
+
*
|
|
143
|
+
* In standalone mode, call loadLocale() from your app bootstrap with the
|
|
144
|
+
* locale base URL configured in your backend (Frontend:LocaleBaseUrl).
|
|
145
|
+
*/
|
|
146
|
+
declare class I18nService {
|
|
147
|
+
private _translations;
|
|
148
|
+
private _locale;
|
|
149
|
+
readonly locale: i0.Signal<string>;
|
|
150
|
+
readonly isRtl: i0.Signal<boolean>;
|
|
151
|
+
readonly direction: i0.Signal<"rtl" | "ltr">;
|
|
152
|
+
/**
|
|
153
|
+
* Loads translations from `{localeBaseUrl}{lang}.json` and merges them into
|
|
154
|
+
* the current translation map. Subsequent calls for the same language
|
|
155
|
+
* replace the previous entries for that language.
|
|
156
|
+
*
|
|
157
|
+
* @param localeBaseUrl Base URL ending with `/`, e.g. `https://cdn.example.com/locale/`
|
|
158
|
+
* @param lang Locale code, e.g. `'en'`, `'ar'`
|
|
159
|
+
*/
|
|
160
|
+
loadLocale(localeBaseUrl: string, lang: string): Promise<void>;
|
|
161
|
+
/**
|
|
162
|
+
* Merges a pre-loaded translations object directly (useful when the shell
|
|
163
|
+
* has already fetched the locale and wants to push it to Business Apps).
|
|
164
|
+
*/
|
|
165
|
+
mergeTranslations(translations: Record<string, string>, lang?: string): void;
|
|
166
|
+
/**
|
|
167
|
+
* Translates a key, with optional `{{param}}` interpolation.
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* i18n.t('circles.signals.title')
|
|
171
|
+
* i18n.t('circles.items_count', { n: '5' })
|
|
172
|
+
*/
|
|
173
|
+
t(key: string, params?: Record<string, string | number>): string;
|
|
174
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<I18nService, never>;
|
|
175
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<I18nService>;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** Options for opening a child window. */
|
|
179
|
+
interface OpenWindowOptions {
|
|
180
|
+
/** Unique identifier for the window instance. */
|
|
181
|
+
windowId: string;
|
|
182
|
+
/** Display title shown in the window chrome. */
|
|
183
|
+
title: string;
|
|
184
|
+
/** Route path or URL to load inside the window. */
|
|
185
|
+
route: string;
|
|
186
|
+
/** Initial width in pixels. Defaults to 900. */
|
|
187
|
+
width?: number;
|
|
188
|
+
/** Initial height in pixels. Defaults to 600. */
|
|
189
|
+
height?: number;
|
|
190
|
+
/** Whether the window can be resized. Defaults to true. */
|
|
191
|
+
resizable?: boolean;
|
|
192
|
+
/** Whether the window can be maximised. Defaults to true. */
|
|
193
|
+
maximizable?: boolean;
|
|
194
|
+
/** Arbitrary data passed to the child window via WINDOW_DATA. */
|
|
195
|
+
data?: unknown;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Abstract interface for the WindowManager.
|
|
199
|
+
* The FlyOS shell provides the concrete implementation; Business Apps
|
|
200
|
+
* inject this token to open, close, and focus windows without depending
|
|
201
|
+
* on the shell's internal implementation.
|
|
202
|
+
*/
|
|
203
|
+
declare abstract class WindowManagerService {
|
|
204
|
+
abstract openChildWindow(options: OpenWindowOptions): void;
|
|
205
|
+
abstract closeWindow(windowId: string): void;
|
|
206
|
+
abstract focusWindow(windowId: string): void;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* No-op fallback implementation used when running a Business App in
|
|
210
|
+
* standalone mode (outside the FlyOS shell). Logs a warning instead of
|
|
211
|
+
* throwing so standalone dev/test flows are not broken.
|
|
212
|
+
*/
|
|
213
|
+
declare class StandaloneWindowManagerService extends WindowManagerService {
|
|
214
|
+
openChildWindow(options: OpenWindowOptions): void;
|
|
215
|
+
closeWindow(windowId: string): void;
|
|
216
|
+
focusWindow(windowId: string): void;
|
|
217
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<StandaloneWindowManagerService, never>;
|
|
218
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<StandaloneWindowManagerService>;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Translates a key using the shared I18nService.
|
|
223
|
+
*
|
|
224
|
+
* @example
|
|
225
|
+
* {{ 'circles.signals.title' | translate }}
|
|
226
|
+
* {{ 'circles.items_count' | translate:{ n: count() } }}
|
|
227
|
+
*/
|
|
228
|
+
declare class TranslatePipe implements PipeTransform {
|
|
229
|
+
private readonly i18n;
|
|
230
|
+
transform(key: string, params?: Record<string, string | number>): string;
|
|
231
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<TranslatePipe, never>;
|
|
232
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<TranslatePipe, "translate", true>;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export { AuthService, I18nService, StandaloneWindowManagerService, TranslatePipe, WINDOW_DATA, WindowManagerService };
|
|
236
|
+
export type { ChildWindowData, DesktopApp, OpenWindowOptions, RemoteAppDef, User, WindowInstance, WindowState };
|
|
85
237
|
//# sourceMappingURL=mohamedatia-fly-design-system.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mohamedatia-fly-design-system.d.ts","sources":["../../../projects/design-system/src/lib/models/app.model.ts","../../../projects/design-system/src/lib/models/window.model.ts","../../../projects/design-system/src/lib/models/remote-app.model.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"mohamedatia-fly-design-system.d.ts","sources":["../../../projects/design-system/src/lib/models/app.model.ts","../../../projects/design-system/src/lib/models/window.model.ts","../../../projects/design-system/src/lib/models/user.model.ts","../../../projects/design-system/src/lib/models/remote-app.model.ts","../../../projects/design-system/src/lib/services/auth.service.ts","../../../projects/design-system/src/lib/services/i18n.service.ts","../../../projects/design-system/src/lib/services/window-manager.service.ts","../../../projects/design-system/src/lib/pipes/translate.pipe.ts"],"mappings":";;;UAEiB,UAAU;;;;;;yBAMJ,OAAO,CAAC,IAAI;AACjC;;;;AACA;;;;;;;AAID;;ACZK,KAAM,WAAW;UAEN,eAAe;AAC9B,oBAAgB,IAAI;AACpB;AACD;UAEgB,cAAc;;;;;;WAMtB,WAAW;AAClB;;;;AACA;;;;;;;;;;;;gBASY,eAAe;AAC5B;AAED,cAAa,WAAW,EAAA,cAAA,CAAA,cAAA;;UC7BP,IAAI;;AAEnB;;;;;;;;;AASD;;ACTD;;;;AAIG;UACc,YAAY;;;;;;;;;;AAU3B;;;;AACA;;;;;AAEA,cAAU,UAAU;;AAErB;;ACbD;;;;;;;;;;;;;;AAcG;AACH,cACa,WAAW;;0BAGFA,EAAA,CAAA,MAAA,CAAA,IAAA;0BACAA,EAAA,CAAA,MAAA;8BACIA,EAAA,CAAA,MAAA;AAKxB;;;AAGG;AACH,qBAAiB,IAAI;;AAKrB;AAIA;;;AAGG;AACH;yCA3BW,WAAW;6CAAX,WAAW;AA8DvB;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