mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-23 21:36:41 +02:00
Commit Message feat: implement comprehensive shared packages architecture for monorepo SUMMARY: Introduce 10 shared packages to unify common code across all 4 web apps, reducing ~3,000 lines of duplicated code and establishing consistent patterns for authentication, UI components, theming, and utilities. NEW SHARED PACKAGES: - @manacore/shared-auth: Unified auth logic (token management, JWT utils, fetch interceptor, storage/device/network adapters) - @manacore/shared-auth-ui: Reusable auth UI (LoginPage, RegisterPage, OAuth buttons for Google/Apple) - @manacore/shared-tailwind: Unified Tailwind config with 4 themes (lume, nature, stone, ocean) and light/dark mode support - @manacore/shared-icons: Phosphor-based icon library (40+ icons) - @manacore/shared-ui: Atomic design system (Text, Button, Badge, Toggle, Input, Modal) - @manacore/shared-i18n: Unified i18n setup with locale detection - @manacore/shared-config: Environment validation with Zod - @manacore/shared-subscriptio n-types: Subscription type definitions - @manacore/shared-subscriptio n-ui: Subscription UI components (planned) EXTENDED PACKAGES: - @manacore/shared-types: Added auth.ts, theme.ts, ui.ts, common.ts - @manacore/shared-utils: Added format.ts, validation.ts APP MIGRATIONS: - memoro/web: Migrated login (549→46 LOC), tailwind (165→12 LOC), removed 15+ duplicate components - manacore/web: Migrated to client-side auth with shared-auth, added new components (Icon, ThemeToggle, Logo) - manadeck/web: Replaced local authService/tokenManager with shared-auth, migrated auth pages - maerchenzauber/web: Added auth setup, stores, components, routes DELETED FILES (migrated to shared packages): - OAuth buttons (Google/Apple) from memoro, manacore, manadeck - Local authService, tokenManager, deviceManager, jwt utils - Duplicate Modal, Toggle, Text components - iconPaths and ManaIcon components - Subscription-related components (CostCard, PackageCard, etc.) BENEFITS: - 92% reduction in login page code - 93% reduction in tailwind config code - Consistent theming across all apps - Single source of truth for auth logic - Easier maintenance and updates BREAKING CHANGES: - Icon imports now from @manacore/shared-icons - Modal imports from @manacore/shared-ui - OAuth config via setGoogleCl ientId()/setAppleConfig()
This commit is contained in:
parent
725db638ea
commit
ef70a1af0b
198 changed files with 11113 additions and 3656 deletions
55
packages/shared-auth/src/adapters/network.ts
Normal file
55
packages/shared-auth/src/adapters/network.ts
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
import type { NetworkAdapter } from '../types';
|
||||
|
||||
let networkAdapter: NetworkAdapter | null = null;
|
||||
|
||||
/**
|
||||
* Set the network adapter for the auth service
|
||||
*/
|
||||
export function setNetworkAdapter(adapter: NetworkAdapter): void {
|
||||
networkAdapter = adapter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current network adapter
|
||||
*/
|
||||
export function getNetworkAdapter(): NetworkAdapter | null {
|
||||
return networkAdapter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if device is connected to the network
|
||||
*/
|
||||
export async function isDeviceConnected(): Promise<boolean> {
|
||||
if (!networkAdapter) {
|
||||
// Default to true if no adapter is set
|
||||
return true;
|
||||
}
|
||||
return networkAdapter.isDeviceConnected();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if device has a stable connection
|
||||
*/
|
||||
export async function hasStableConnection(): Promise<boolean> {
|
||||
if (!networkAdapter || !networkAdapter.hasStableConnection) {
|
||||
// Default to basic connectivity check
|
||||
return isDeviceConnected();
|
||||
}
|
||||
return networkAdapter.hasStableConnection();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a web-based network adapter
|
||||
*/
|
||||
export function createWebNetworkAdapter(): NetworkAdapter {
|
||||
return {
|
||||
async isDeviceConnected(): Promise<boolean> {
|
||||
return navigator.onLine;
|
||||
},
|
||||
async hasStableConnection(): Promise<boolean> {
|
||||
// For web, we just check online status
|
||||
// More sophisticated checks could be added
|
||||
return navigator.onLine;
|
||||
},
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue