@rajeev02/app-shell 0.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.
Files changed (41) hide show
  1. package/lib/analytics/index.d.ts +42 -0
  2. package/lib/analytics/index.d.ts.map +1 -0
  3. package/lib/analytics/index.js +69 -0
  4. package/lib/analytics/index.js.map +1 -0
  5. package/lib/api/index.d.ts +84 -0
  6. package/lib/api/index.d.ts.map +1 -0
  7. package/lib/api/index.js +219 -0
  8. package/lib/api/index.js.map +1 -0
  9. package/lib/cart/index.d.ts +97 -0
  10. package/lib/cart/index.d.ts.map +1 -0
  11. package/lib/cart/index.js +134 -0
  12. package/lib/cart/index.js.map +1 -0
  13. package/lib/chat/index.d.ts +111 -0
  14. package/lib/chat/index.d.ts.map +1 -0
  15. package/lib/chat/index.js +169 -0
  16. package/lib/chat/index.js.map +1 -0
  17. package/lib/config/index.d.ts +33 -0
  18. package/lib/config/index.d.ts.map +1 -0
  19. package/lib/config/index.js +62 -0
  20. package/lib/config/index.js.map +1 -0
  21. package/lib/forms/index.d.ts +78 -0
  22. package/lib/forms/index.d.ts.map +1 -0
  23. package/lib/forms/index.js +292 -0
  24. package/lib/forms/index.js.map +1 -0
  25. package/lib/index.d.ts +23 -0
  26. package/lib/index.d.ts.map +1 -0
  27. package/lib/index.js +35 -0
  28. package/lib/index.js.map +1 -0
  29. package/lib/onboarding/index.d.ts +62 -0
  30. package/lib/onboarding/index.d.ts.map +1 -0
  31. package/lib/onboarding/index.js +117 -0
  32. package/lib/onboarding/index.js.map +1 -0
  33. package/package.json +51 -0
  34. package/src/analytics/index.ts +92 -0
  35. package/src/api/index.ts +322 -0
  36. package/src/cart/index.ts +213 -0
  37. package/src/chat/index.ts +260 -0
  38. package/src/config/index.ts +69 -0
  39. package/src/forms/index.ts +376 -0
  40. package/src/index.ts +68 -0
  41. package/src/onboarding/index.ts +159 -0
package/src/index.ts ADDED
@@ -0,0 +1,68 @@
1
+ /**
2
+ * @rajeev02/app-shell
3
+ * Feature-Slice App Architecture
4
+ * API client, onboarding, chat, forms/KYC, cart/checkout, analytics, feature flags
5
+ *
6
+ * @author Rajeev Kumar Joshi
7
+ * @license MIT
8
+ */
9
+
10
+ // API Client
11
+ export { ApiClient } from "./api";
12
+ export type {
13
+ ApiConfig,
14
+ ApiRequest,
15
+ ApiResponse,
16
+ CacheStrategy,
17
+ RequestInterceptor,
18
+ ResponseInterceptor,
19
+ } from "./api";
20
+
21
+ // Onboarding
22
+ export { OnboardingManager, getDefaultOnboardingSlides } from "./onboarding";
23
+ export type {
24
+ SplashConfig,
25
+ OnboardingSlide,
26
+ FeatureTooltip,
27
+ OnboardingConfig,
28
+ } from "./onboarding";
29
+
30
+ // Chat
31
+ export { ChatEngine } from "./chat";
32
+ export type {
33
+ ChatMessage,
34
+ ChatRoom,
35
+ MessageType,
36
+ MessageStatus,
37
+ TypingIndicator,
38
+ ChatEvent,
39
+ } from "./chat";
40
+
41
+ // Cart & Checkout
42
+ export { CartManager } from "./cart";
43
+ export type {
44
+ CartItem,
45
+ CartSummary,
46
+ Address,
47
+ Order,
48
+ OrderStatus,
49
+ } from "./cart";
50
+
51
+ // Analytics
52
+ export { AnalyticsEngine } from "./analytics";
53
+ export type { AnalyticsEvent, AnalyticsConfig } from "./analytics";
54
+
55
+ // Feature Flags
56
+ export { FeatureFlagManager } from "./config";
57
+ export type { FeatureFlag } from "./config";
58
+
59
+ // Forms & KYC
60
+ export { FormEngine, getKycFormConfig } from "./forms";
61
+ export type {
62
+ FormField,
63
+ FormStep,
64
+ FormConfig,
65
+ FormState,
66
+ FieldType,
67
+ ValidationRule,
68
+ } from "./forms";
@@ -0,0 +1,159 @@
1
+ /**
2
+ * @rajeev02/app-shell — Onboarding
3
+ * Splash screen, feature carousel, tooltips, first-launch detection
4
+ */
5
+
6
+ export interface SplashConfig {
7
+ logoSource: string;
8
+ backgroundColor: string;
9
+ minDisplayMs?: number;
10
+ animation?: "fade" | "scale" | "slide" | "none";
11
+ }
12
+
13
+ export interface OnboardingSlide {
14
+ id: string;
15
+ title: string;
16
+ description: string;
17
+ image?: string;
18
+ lottieSource?: string;
19
+ backgroundColor?: string;
20
+ textColor?: string;
21
+ }
22
+
23
+ export interface FeatureTooltip {
24
+ id: string;
25
+ targetElementId: string;
26
+ title: string;
27
+ description: string;
28
+ position?: "top" | "bottom" | "left" | "right";
29
+ showOnce?: boolean;
30
+ }
31
+
32
+ export interface OnboardingConfig {
33
+ splash: SplashConfig;
34
+ slides: OnboardingSlide[];
35
+ tooltips?: FeatureTooltip[];
36
+ skipText?: string;
37
+ nextText?: string;
38
+ doneText?: string;
39
+ showDots?: boolean;
40
+ }
41
+
42
+ /**
43
+ * Onboarding Manager
44
+ */
45
+ export class OnboardingManager {
46
+ private shownSlides: Set<string> = new Set();
47
+ private seenTooltips: Set<string> = new Set();
48
+ private completedOnboarding: boolean = false;
49
+ private launchCount: number = 0;
50
+ private listeners: Set<(event: string) => void> = new Set();
51
+
52
+ recordLaunch(): void {
53
+ this.launchCount++;
54
+ }
55
+ isFirstLaunch(): boolean {
56
+ return this.launchCount <= 1;
57
+ }
58
+ getLaunchCount(): number {
59
+ return this.launchCount;
60
+ }
61
+
62
+ completeOnboarding(): void {
63
+ this.completedOnboarding = true;
64
+ this.emit("onboarding_complete");
65
+ }
66
+
67
+ isOnboardingComplete(): boolean {
68
+ return this.completedOnboarding;
69
+ }
70
+ markSlideShown(slideId: string): void {
71
+ this.shownSlides.add(slideId);
72
+ }
73
+ markTooltipSeen(tooltipId: string): void {
74
+ this.seenTooltips.add(tooltipId);
75
+ }
76
+
77
+ shouldShowTooltip(tooltip: FeatureTooltip): boolean {
78
+ if (tooltip.showOnce && this.seenTooltips.has(tooltip.id)) return false;
79
+ return true;
80
+ }
81
+
82
+ getUnseenTooltips(tooltips: FeatureTooltip[]): FeatureTooltip[] {
83
+ return tooltips.filter((t) => this.shouldShowTooltip(t));
84
+ }
85
+
86
+ onEvent(listener: (event: string) => void): () => void {
87
+ this.listeners.add(listener);
88
+ return () => this.listeners.delete(listener);
89
+ }
90
+
91
+ exportState(): Record<string, unknown> {
92
+ return {
93
+ shownSlides: Array.from(this.shownSlides),
94
+ seenTooltips: Array.from(this.seenTooltips),
95
+ completedOnboarding: this.completedOnboarding,
96
+ launchCount: this.launchCount,
97
+ };
98
+ }
99
+
100
+ importState(state: Record<string, unknown>): void {
101
+ if (Array.isArray(state.shownSlides))
102
+ this.shownSlides = new Set(state.shownSlides as string[]);
103
+ if (Array.isArray(state.seenTooltips))
104
+ this.seenTooltips = new Set(state.seenTooltips as string[]);
105
+ if (typeof state.completedOnboarding === "boolean")
106
+ this.completedOnboarding = state.completedOnboarding;
107
+ if (typeof state.launchCount === "number")
108
+ this.launchCount = state.launchCount;
109
+ }
110
+
111
+ private emit(event: string): void {
112
+ for (const l of this.listeners) {
113
+ try {
114
+ l(event);
115
+ } catch {}
116
+ }
117
+ }
118
+ }
119
+
120
+ /** Default onboarding slides for a super app */
121
+ export function getDefaultOnboardingSlides(): OnboardingSlide[] {
122
+ return [
123
+ {
124
+ id: "welcome",
125
+ title: "Welcome to Rajeev App",
126
+ description:
127
+ "One app for payments, shopping, health, government services, and more",
128
+ backgroundColor: "#4F46E5",
129
+ },
130
+ {
131
+ id: "payments",
132
+ title: "Pay Instantly",
133
+ description:
134
+ "UPI payments, bill pay, and money transfers — works even on slow networks",
135
+ backgroundColor: "#059669",
136
+ },
137
+ {
138
+ id: "offline",
139
+ title: "Works Offline",
140
+ description:
141
+ "Core features work without internet. Data syncs automatically when you're back online",
142
+ backgroundColor: "#D97706",
143
+ },
144
+ {
145
+ id: "language",
146
+ title: "Your Language",
147
+ description:
148
+ "Use the app in Hindi, Tamil, Bengali, Telugu, and 6 more Indian languages",
149
+ backgroundColor: "#DC2626",
150
+ },
151
+ {
152
+ id: "voice",
153
+ title: "Voice First",
154
+ description:
155
+ "Just speak! Navigate, search, and pay using voice commands in your language",
156
+ backgroundColor: "#7C3AED",
157
+ },
158
+ ];
159
+ }