@hamak/ui-shell 0.5.1

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 (143) hide show
  1. package/README.md +414 -0
  2. package/dist/api/api/IFeatureManager.d.ts +56 -0
  3. package/dist/api/api/IFeatureManager.d.ts.map +1 -0
  4. package/dist/api/api/IFeatureManager.js +5 -0
  5. package/dist/api/api/ILayoutManager.d.ts +40 -0
  6. package/dist/api/api/ILayoutManager.d.ts.map +1 -0
  7. package/dist/api/api/ILayoutManager.js +5 -0
  8. package/dist/api/api/IRouter.d.ts +40 -0
  9. package/dist/api/api/IRouter.d.ts.map +1 -0
  10. package/dist/api/api/IRouter.js +5 -0
  11. package/dist/api/api/IShell.d.ts +55 -0
  12. package/dist/api/api/IShell.d.ts.map +1 -0
  13. package/dist/api/api/IShell.js +5 -0
  14. package/dist/api/api/IThemeManager.d.ts +36 -0
  15. package/dist/api/api/IThemeManager.d.ts.map +1 -0
  16. package/dist/api/api/IThemeManager.js +5 -0
  17. package/dist/api/api/index.d.ts +10 -0
  18. package/dist/api/api/index.d.ts.map +1 -0
  19. package/dist/api/api/index.js +9 -0
  20. package/dist/api/index.d.ts +11 -0
  21. package/dist/api/index.d.ts.map +1 -0
  22. package/dist/api/index.js +13 -0
  23. package/dist/api/tokens/index.d.ts +6 -0
  24. package/dist/api/tokens/index.d.ts.map +1 -0
  25. package/dist/api/tokens/index.js +5 -0
  26. package/dist/api/tokens/service-tokens.d.ts +57 -0
  27. package/dist/api/tokens/service-tokens.d.ts.map +1 -0
  28. package/dist/api/tokens/service-tokens.js +56 -0
  29. package/dist/api/types/event-types.d.ts +14 -0
  30. package/dist/api/types/event-types.d.ts.map +1 -0
  31. package/dist/api/types/event-types.js +5 -0
  32. package/dist/api/types/feature-types.d.ts +26 -0
  33. package/dist/api/types/feature-types.d.ts.map +1 -0
  34. package/dist/api/types/feature-types.js +26 -0
  35. package/dist/api/types/index.d.ts +11 -0
  36. package/dist/api/types/index.d.ts.map +1 -0
  37. package/dist/api/types/index.js +10 -0
  38. package/dist/api/types/layout-types.d.ts +29 -0
  39. package/dist/api/types/layout-types.d.ts.map +1 -0
  40. package/dist/api/types/layout-types.js +5 -0
  41. package/dist/api/types/route-types.d.ts +22 -0
  42. package/dist/api/types/route-types.d.ts.map +1 -0
  43. package/dist/api/types/route-types.js +5 -0
  44. package/dist/api/types/shell-context.d.ts +34 -0
  45. package/dist/api/types/shell-context.d.ts.map +1 -0
  46. package/dist/api/types/shell-context.js +5 -0
  47. package/dist/api/types/theme-types.d.ts +13 -0
  48. package/dist/api/types/theme-types.d.ts.map +1 -0
  49. package/dist/api/types/theme-types.js +5 -0
  50. package/dist/impl/core/DefaultFeatureManager.d.ts +24 -0
  51. package/dist/impl/core/DefaultFeatureManager.d.ts.map +1 -0
  52. package/dist/impl/core/DefaultFeatureManager.js +90 -0
  53. package/dist/impl/core/DefaultLayoutManager.d.ts +19 -0
  54. package/dist/impl/core/DefaultLayoutManager.d.ts.map +1 -0
  55. package/dist/impl/core/DefaultLayoutManager.js +71 -0
  56. package/dist/impl/core/DefaultRouter.d.ts +30 -0
  57. package/dist/impl/core/DefaultRouter.d.ts.map +1 -0
  58. package/dist/impl/core/DefaultRouter.js +136 -0
  59. package/dist/impl/core/DefaultShell.d.ts +30 -0
  60. package/dist/impl/core/DefaultShell.d.ts.map +1 -0
  61. package/dist/impl/core/DefaultShell.js +187 -0
  62. package/dist/impl/core/DefaultThemeManager.d.ts +27 -0
  63. package/dist/impl/core/DefaultThemeManager.d.ts.map +1 -0
  64. package/dist/impl/core/DefaultThemeManager.js +101 -0
  65. package/dist/impl/core/index.d.ts +10 -0
  66. package/dist/impl/core/index.d.ts.map +1 -0
  67. package/dist/impl/core/index.js +9 -0
  68. package/dist/impl/index.d.ts +21 -0
  69. package/dist/impl/index.d.ts.map +1 -0
  70. package/dist/impl/index.js +41 -0
  71. package/dist/impl/plugin/ShellPluginFactory.d.ts +11 -0
  72. package/dist/impl/plugin/ShellPluginFactory.d.ts.map +1 -0
  73. package/dist/impl/plugin/ShellPluginFactory.js +73 -0
  74. package/dist/impl/plugin/index.d.ts +6 -0
  75. package/dist/impl/plugin/index.d.ts.map +1 -0
  76. package/dist/impl/plugin/index.js +5 -0
  77. package/dist/impl/providers/CSSVariablesThemeProvider.d.ts +16 -0
  78. package/dist/impl/providers/CSSVariablesThemeProvider.d.ts.map +1 -0
  79. package/dist/impl/providers/CSSVariablesThemeProvider.js +64 -0
  80. package/dist/impl/providers/HashRouterStrategy.d.ts +20 -0
  81. package/dist/impl/providers/HashRouterStrategy.d.ts.map +1 -0
  82. package/dist/impl/providers/HashRouterStrategy.js +67 -0
  83. package/dist/impl/providers/HistoryRouterStrategy.d.ts +21 -0
  84. package/dist/impl/providers/HistoryRouterStrategy.d.ts.map +1 -0
  85. package/dist/impl/providers/HistoryRouterStrategy.js +79 -0
  86. package/dist/impl/providers/LocalStorageProvider.d.ts +13 -0
  87. package/dist/impl/providers/LocalStorageProvider.d.ts.map +1 -0
  88. package/dist/impl/providers/LocalStorageProvider.js +50 -0
  89. package/dist/impl/providers/MemoryStorageProvider.d.ts +14 -0
  90. package/dist/impl/providers/MemoryStorageProvider.d.ts.map +1 -0
  91. package/dist/impl/providers/MemoryStorageProvider.js +29 -0
  92. package/dist/impl/providers/index.d.ts +10 -0
  93. package/dist/impl/providers/index.d.ts.map +1 -0
  94. package/dist/impl/providers/index.js +9 -0
  95. package/dist/impl/utils/index.d.ts +6 -0
  96. package/dist/impl/utils/index.d.ts.map +1 -0
  97. package/dist/impl/utils/index.js +5 -0
  98. package/dist/impl/utils/viewport-utils.d.ts +16 -0
  99. package/dist/impl/utils/viewport-utils.d.ts.map +1 -0
  100. package/dist/impl/utils/viewport-utils.js +52 -0
  101. package/dist/index.d.ts +11 -0
  102. package/dist/index.d.ts.map +1 -0
  103. package/dist/index.js +11 -0
  104. package/dist/spi/guards/NavigationGuard.d.ts +18 -0
  105. package/dist/spi/guards/NavigationGuard.d.ts.map +1 -0
  106. package/dist/spi/guards/NavigationGuard.js +5 -0
  107. package/dist/spi/guards/index.d.ts +6 -0
  108. package/dist/spi/guards/index.d.ts.map +1 -0
  109. package/dist/spi/guards/index.js +5 -0
  110. package/dist/spi/hooks/ShellHooks.d.ts +40 -0
  111. package/dist/spi/hooks/ShellHooks.d.ts.map +1 -0
  112. package/dist/spi/hooks/ShellHooks.js +5 -0
  113. package/dist/spi/hooks/index.d.ts +6 -0
  114. package/dist/spi/hooks/index.d.ts.map +1 -0
  115. package/dist/spi/hooks/index.js +5 -0
  116. package/dist/spi/index.d.ts +18 -0
  117. package/dist/spi/index.d.ts.map +1 -0
  118. package/dist/spi/index.js +22 -0
  119. package/dist/spi/providers/IRouterStrategy.d.ts +35 -0
  120. package/dist/spi/providers/IRouterStrategy.d.ts.map +1 -0
  121. package/dist/spi/providers/IRouterStrategy.js +5 -0
  122. package/dist/spi/providers/IStorageProvider.d.ts +27 -0
  123. package/dist/spi/providers/IStorageProvider.d.ts.map +1 -0
  124. package/dist/spi/providers/IStorageProvider.js +5 -0
  125. package/dist/spi/providers/ITemplateProvider.d.ts +36 -0
  126. package/dist/spi/providers/ITemplateProvider.d.ts.map +1 -0
  127. package/dist/spi/providers/ITemplateProvider.js +5 -0
  128. package/dist/spi/providers/IThemeProvider.d.ts +24 -0
  129. package/dist/spi/providers/IThemeProvider.d.ts.map +1 -0
  130. package/dist/spi/providers/IThemeProvider.js +5 -0
  131. package/dist/spi/providers/index.d.ts +9 -0
  132. package/dist/spi/providers/index.d.ts.map +1 -0
  133. package/dist/spi/providers/index.js +8 -0
  134. package/dist/spi/slots/LayoutSlotProvider.d.ts +31 -0
  135. package/dist/spi/slots/LayoutSlotProvider.d.ts.map +1 -0
  136. package/dist/spi/slots/LayoutSlotProvider.js +5 -0
  137. package/dist/spi/slots/TemplateSlot.d.ts +34 -0
  138. package/dist/spi/slots/TemplateSlot.d.ts.map +1 -0
  139. package/dist/spi/slots/TemplateSlot.js +5 -0
  140. package/dist/spi/slots/index.d.ts +7 -0
  141. package/dist/spi/slots/index.d.ts.map +1 -0
  142. package/dist/spi/slots/index.js +6 -0
  143. package/package.json +67 -0
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Default Layout Manager Implementation
3
+ */
4
+ export class DefaultLayoutManager {
5
+ constructor() {
6
+ Object.defineProperty(this, "slots", {
7
+ enumerable: true,
8
+ configurable: true,
9
+ writable: true,
10
+ value: new Map()
11
+ });
12
+ Object.defineProperty(this, "listeners", {
13
+ enumerable: true,
14
+ configurable: true,
15
+ writable: true,
16
+ value: new Set()
17
+ });
18
+ }
19
+ registerSlot(slot) {
20
+ const area = slot.area;
21
+ if (!this.slots.has(area)) {
22
+ this.slots.set(area, new Set());
23
+ }
24
+ this.slots.get(area).add(slot);
25
+ this.notifyListeners();
26
+ return () => this.unregisterSlot(slot);
27
+ }
28
+ unregisterSlot(slot) {
29
+ const area = slot.area;
30
+ const slots = this.slots.get(area);
31
+ if (slots) {
32
+ slots.delete(slot);
33
+ if (slots.size === 0) {
34
+ this.slots.delete(area);
35
+ }
36
+ this.notifyListeners();
37
+ }
38
+ }
39
+ getSlots(area) {
40
+ const slots = this.slots.get(area);
41
+ if (!slots)
42
+ return [];
43
+ return Array.from(slots).sort((a, b) => {
44
+ const priorityA = a.priority || 0;
45
+ const priorityB = b.priority || 0;
46
+ return priorityB - priorityA; // Higher priority first
47
+ });
48
+ }
49
+ getAreas() {
50
+ return Array.from(this.slots.keys());
51
+ }
52
+ hasSlots(area) {
53
+ const slots = this.slots.get(area);
54
+ return Boolean(slots && slots.size > 0);
55
+ }
56
+ subscribe(listener) {
57
+ this.listeners.add(listener);
58
+ return () => this.listeners.delete(listener);
59
+ }
60
+ clear() {
61
+ this.slots.clear();
62
+ this.notifyListeners();
63
+ }
64
+ destroy() {
65
+ this.slots.clear();
66
+ this.listeners.clear();
67
+ }
68
+ notifyListeners() {
69
+ this.listeners.forEach(listener => listener());
70
+ }
71
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Default Router Implementation
3
+ */
4
+ import type { IRouter } from '../../api';
5
+ import type { RouteConfig, RouterOptions } from '../../api';
6
+ import type { IRouterStrategy } from '../../spi';
7
+ import type { NavigationGuard } from '../../spi';
8
+ export declare class DefaultRouter implements IRouter {
9
+ private routes;
10
+ private currentRoute;
11
+ private guards;
12
+ private listeners;
13
+ private strategy;
14
+ constructor(options: RouterOptions, strategy: IRouterStrategy);
15
+ private registerRoutes;
16
+ push(path: string): Promise<boolean>;
17
+ replace(path: string): Promise<boolean>;
18
+ back(): void;
19
+ forward(): void;
20
+ getCurrentRoute(): RouteConfig | null;
21
+ subscribe(listener: (route: RouteConfig) => void): () => void;
22
+ loadRouteComponent(route: RouteConfig): Promise<any>;
23
+ addGuard(guard: NavigationGuard): () => void;
24
+ destroy(): void;
25
+ private matchRoute;
26
+ private runGuards;
27
+ private setupNavigationListener;
28
+ private notifyListeners;
29
+ }
30
+ //# sourceMappingURL=DefaultRouter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DefaultRouter.d.ts","sourceRoot":"","sources":["../../../src/impl/core/DefaultRouter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEjD,qBAAa,aAAc,YAAW,OAAO;IAC3C,OAAO,CAAC,MAAM,CAAuC;IACrD,OAAO,CAAC,YAAY,CAA4B;IAChD,OAAO,CAAC,MAAM,CAAyB;IACvC,OAAO,CAAC,SAAS,CAAgD;IACjE,OAAO,CAAC,QAAQ,CAAkB;gBAEtB,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,eAAe;IAO7D,OAAO,CAAC,cAAc;IAShB,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAqBpC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAiB7C,IAAI,IAAI,IAAI;IAIZ,OAAO,IAAI,IAAI;IAIf,eAAe,IAAI,WAAW,GAAG,IAAI;IAIrC,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,GAAG,MAAM,IAAI;IAKvD,kBAAkB,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC;IAU1D,QAAQ,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,IAAI;IAU5C,OAAO,IAAI,IAAI;IAMf,OAAO,CAAC,UAAU;YAIJ,SAAS;IAQvB,OAAO,CAAC,uBAAuB;IAM/B,OAAO,CAAC,eAAe;CAGxB"}
@@ -0,0 +1,136 @@
1
+ /**
2
+ * Default Router Implementation
3
+ */
4
+ export class DefaultRouter {
5
+ constructor(options, strategy) {
6
+ Object.defineProperty(this, "routes", {
7
+ enumerable: true,
8
+ configurable: true,
9
+ writable: true,
10
+ value: new Map()
11
+ });
12
+ Object.defineProperty(this, "currentRoute", {
13
+ enumerable: true,
14
+ configurable: true,
15
+ writable: true,
16
+ value: null
17
+ });
18
+ Object.defineProperty(this, "guards", {
19
+ enumerable: true,
20
+ configurable: true,
21
+ writable: true,
22
+ value: []
23
+ });
24
+ Object.defineProperty(this, "listeners", {
25
+ enumerable: true,
26
+ configurable: true,
27
+ writable: true,
28
+ value: new Set()
29
+ });
30
+ Object.defineProperty(this, "strategy", {
31
+ enumerable: true,
32
+ configurable: true,
33
+ writable: true,
34
+ value: void 0
35
+ });
36
+ this.strategy = strategy;
37
+ this.guards = [];
38
+ this.registerRoutes(options.routes);
39
+ this.setupNavigationListener();
40
+ }
41
+ registerRoutes(routes) {
42
+ routes.forEach(route => {
43
+ this.routes.set(route.path, route);
44
+ if (route.children) {
45
+ this.registerRoutes(route.children);
46
+ }
47
+ });
48
+ }
49
+ async push(path) {
50
+ const route = this.matchRoute(path);
51
+ if (!route) {
52
+ console.error(`Route not found: ${path}`);
53
+ return false;
54
+ }
55
+ if (!(await this.runGuards(route))) {
56
+ return false;
57
+ }
58
+ if (route.beforeEnter && !(await route.beforeEnter(route, this.currentRoute))) {
59
+ return false;
60
+ }
61
+ this.currentRoute = route;
62
+ this.strategy.push(path);
63
+ this.notifyListeners(route);
64
+ return true;
65
+ }
66
+ async replace(path) {
67
+ const route = this.matchRoute(path);
68
+ if (!route) {
69
+ console.error(`Route not found: ${path}`);
70
+ return false;
71
+ }
72
+ if (!(await this.runGuards(route))) {
73
+ return false;
74
+ }
75
+ this.currentRoute = route;
76
+ this.strategy.replace(path);
77
+ this.notifyListeners(route);
78
+ return true;
79
+ }
80
+ back() {
81
+ this.strategy.back();
82
+ }
83
+ forward() {
84
+ this.strategy.forward();
85
+ }
86
+ getCurrentRoute() {
87
+ return this.currentRoute;
88
+ }
89
+ subscribe(listener) {
90
+ this.listeners.add(listener);
91
+ return () => this.listeners.delete(listener);
92
+ }
93
+ async loadRouteComponent(route) {
94
+ try {
95
+ const component = await route.component();
96
+ return component;
97
+ }
98
+ catch (error) {
99
+ console.error(`Failed to load route component for ${route.path}:`, error);
100
+ throw error;
101
+ }
102
+ }
103
+ addGuard(guard) {
104
+ this.guards.push(guard);
105
+ return () => {
106
+ const index = this.guards.indexOf(guard);
107
+ if (index > -1) {
108
+ this.guards.splice(index, 1);
109
+ }
110
+ };
111
+ }
112
+ destroy() {
113
+ this.strategy.destroy();
114
+ this.listeners.clear();
115
+ this.guards = [];
116
+ }
117
+ matchRoute(path) {
118
+ return this.routes.get(path) || null;
119
+ }
120
+ async runGuards(to) {
121
+ for (const guard of this.guards) {
122
+ const result = await guard(to, this.currentRoute);
123
+ if (!result)
124
+ return false;
125
+ }
126
+ return true;
127
+ }
128
+ setupNavigationListener() {
129
+ this.strategy.listen((path) => {
130
+ this.push(path);
131
+ });
132
+ }
133
+ notifyListeners(route) {
134
+ this.listeners.forEach(listener => listener(route));
135
+ }
136
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Default Shell Implementation
3
+ */
4
+ import type { IShell, IThemeManager, IFeatureManager, IRouter } from '../../api';
5
+ import type { ShellConfig, ShellContext, ShellEventListener, ShellEventType } from '../../api';
6
+ export declare class DefaultShell implements IShell {
7
+ private themeManager;
8
+ private featureManager;
9
+ private router;
10
+ private eventListeners;
11
+ private viewportState;
12
+ private config;
13
+ private isReady;
14
+ constructor(config?: ShellConfig);
15
+ initialize(): Promise<void>;
16
+ getContext(): ShellContext;
17
+ getThemeManager(): IThemeManager;
18
+ getFeatureManager(): IFeatureManager;
19
+ getRouter(): IRouter | null;
20
+ setRouter(router: IRouter): void;
21
+ emit(type: ShellEventType, payload?: any): void;
22
+ on(type: ShellEventType | '*', listener: ShellEventListener): () => void;
23
+ off(type: ShellEventType | '*', listener: ShellEventListener): void;
24
+ ready(): boolean;
25
+ getConfig(): Readonly<ShellConfig>;
26
+ destroy(): void;
27
+ private setupViewportListener;
28
+ private handleResize;
29
+ }
30
+ //# sourceMappingURL=DefaultShell.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DefaultShell.d.ts","sourceRoot":"","sources":["../../../src/impl/core/DefaultShell.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACjF,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAc,kBAAkB,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAM3G,qBAAa,YAAa,YAAW,MAAM;IACzC,OAAO,CAAC,YAAY,CAAgB;IACpC,OAAO,CAAC,cAAc,CAAkB;IACxC,OAAO,CAAC,MAAM,CAAwB;IACtC,OAAO,CAAC,cAAc,CAAmD;IACzE,OAAO,CAAC,aAAa,CAGnB;IACF,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,OAAO,CAAS;gBAEZ,MAAM,GAAE,WAAgB;IAc9B,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAuBjC,UAAU,IAAI,YAAY;IAiB1B,eAAe,IAAI,aAAa;IAIhC,iBAAiB,IAAI,eAAe;IAIpC,SAAS,IAAI,OAAO,GAAG,IAAI;IAI3B,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI;IAOhC,IAAI,CAAC,IAAI,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,IAAI;IAkB/C,EAAE,CAAC,IAAI,EAAE,cAAc,GAAG,GAAG,EAAE,QAAQ,EAAE,kBAAkB,GAAG,MAAM,IAAI;IAiBxE,GAAG,CAAC,IAAI,EAAE,cAAc,GAAG,GAAG,EAAE,QAAQ,EAAE,kBAAkB,GAAG,IAAI;IAOnE,KAAK,IAAI,OAAO;IAIhB,SAAS,IAAI,QAAQ,CAAC,WAAW,CAAC;IAIlC,OAAO,IAAI,IAAI;IAaf,OAAO,CAAC,qBAAqB;IAK7B,OAAO,CAAC,YAAY,CAUlB;CACH"}
@@ -0,0 +1,187 @@
1
+ /**
2
+ * Default Shell Implementation
3
+ */
4
+ import { DefaultThemeManager } from './DefaultThemeManager';
5
+ import { DefaultFeatureManager } from './DefaultFeatureManager';
6
+ import { LocalStorageProvider } from '../providers/LocalStorageProvider';
7
+ import { CSSVariablesThemeProvider } from '../providers/CSSVariablesThemeProvider';
8
+ export class DefaultShell {
9
+ constructor(config = {}) {
10
+ Object.defineProperty(this, "themeManager", {
11
+ enumerable: true,
12
+ configurable: true,
13
+ writable: true,
14
+ value: void 0
15
+ });
16
+ Object.defineProperty(this, "featureManager", {
17
+ enumerable: true,
18
+ configurable: true,
19
+ writable: true,
20
+ value: void 0
21
+ });
22
+ Object.defineProperty(this, "router", {
23
+ enumerable: true,
24
+ configurable: true,
25
+ writable: true,
26
+ value: null
27
+ });
28
+ Object.defineProperty(this, "eventListeners", {
29
+ enumerable: true,
30
+ configurable: true,
31
+ writable: true,
32
+ value: new Map()
33
+ });
34
+ Object.defineProperty(this, "viewportState", {
35
+ enumerable: true,
36
+ configurable: true,
37
+ writable: true,
38
+ value: {
39
+ width: typeof window !== 'undefined' ? window.innerWidth : 0,
40
+ height: typeof window !== 'undefined' ? window.innerHeight : 0,
41
+ }
42
+ });
43
+ Object.defineProperty(this, "config", {
44
+ enumerable: true,
45
+ configurable: true,
46
+ writable: true,
47
+ value: void 0
48
+ });
49
+ Object.defineProperty(this, "isReady", {
50
+ enumerable: true,
51
+ configurable: true,
52
+ writable: true,
53
+ value: false
54
+ });
55
+ Object.defineProperty(this, "handleResize", {
56
+ enumerable: true,
57
+ configurable: true,
58
+ writable: true,
59
+ value: () => {
60
+ if (typeof window === 'undefined')
61
+ return;
62
+ this.viewportState.width = window.innerWidth;
63
+ this.viewportState.height = window.innerHeight;
64
+ this.emit('viewport:resized', {
65
+ width: this.viewportState.width,
66
+ height: this.viewportState.height,
67
+ });
68
+ }
69
+ });
70
+ this.config = config;
71
+ // Create theme manager with providers
72
+ const storageProvider = new LocalStorageProvider();
73
+ const themeProvider = new CSSVariablesThemeProvider();
74
+ this.themeManager = new DefaultThemeManager(config.theme, storageProvider, themeProvider);
75
+ // Create feature manager
76
+ this.featureManager = new DefaultFeatureManager(config.features);
77
+ this.setupViewportListener();
78
+ }
79
+ async initialize() {
80
+ if (this.isReady) {
81
+ console.warn('Shell is already initialized');
82
+ return;
83
+ }
84
+ // Apply initial theme
85
+ this.themeManager.setTheme(this.themeManager.getTheme());
86
+ // Subscribe to theme changes
87
+ this.themeManager.subscribe(theme => {
88
+ this.emit('theme:changed', { theme });
89
+ });
90
+ // Subscribe to feature changes
91
+ this.featureManager.subscribeAll((key, value) => {
92
+ this.emit('feature:toggled', { key, value });
93
+ });
94
+ this.isReady = true;
95
+ this.emit('shell:ready', {});
96
+ }
97
+ getContext() {
98
+ return {
99
+ theme: this.themeManager.getTheme(),
100
+ setTheme: (mode) => this.themeManager.setTheme(mode),
101
+ features: this.featureManager.getAll(),
102
+ isFeatureEnabled: (key) => this.featureManager.isEnabled(key),
103
+ getFeature: (key, defaultValue) => this.featureManager.get(key, defaultValue),
104
+ viewport: {
105
+ width: this.viewportState.width,
106
+ height: this.viewportState.height,
107
+ isMobile: this.viewportState.width < 768,
108
+ isTablet: this.viewportState.width >= 768 && this.viewportState.width < 1024,
109
+ isDesktop: this.viewportState.width >= 1024,
110
+ },
111
+ };
112
+ }
113
+ getThemeManager() {
114
+ return this.themeManager;
115
+ }
116
+ getFeatureManager() {
117
+ return this.featureManager;
118
+ }
119
+ getRouter() {
120
+ return this.router;
121
+ }
122
+ setRouter(router) {
123
+ this.router = router;
124
+ this.router.subscribe(route => {
125
+ this.emit('route:changed', { route });
126
+ });
127
+ }
128
+ emit(type, payload) {
129
+ const event = {
130
+ type,
131
+ payload,
132
+ timestamp: Date.now(),
133
+ };
134
+ const listeners = this.eventListeners.get(type);
135
+ if (listeners) {
136
+ listeners.forEach(listener => listener(event));
137
+ }
138
+ const wildcardListeners = this.eventListeners.get('*');
139
+ if (wildcardListeners) {
140
+ wildcardListeners.forEach(listener => listener(event));
141
+ }
142
+ }
143
+ on(type, listener) {
144
+ if (!this.eventListeners.has(type)) {
145
+ this.eventListeners.set(type, new Set());
146
+ }
147
+ this.eventListeners.get(type).add(listener);
148
+ return () => {
149
+ const listeners = this.eventListeners.get(type);
150
+ if (listeners) {
151
+ listeners.delete(listener);
152
+ if (listeners.size === 0) {
153
+ this.eventListeners.delete(type);
154
+ }
155
+ }
156
+ };
157
+ }
158
+ off(type, listener) {
159
+ const listeners = this.eventListeners.get(type);
160
+ if (listeners) {
161
+ listeners.delete(listener);
162
+ }
163
+ }
164
+ ready() {
165
+ return this.isReady;
166
+ }
167
+ getConfig() {
168
+ return { ...this.config };
169
+ }
170
+ destroy() {
171
+ this.themeManager.destroy();
172
+ this.featureManager.destroy();
173
+ if (this.router) {
174
+ this.router.destroy();
175
+ }
176
+ if (typeof window !== 'undefined') {
177
+ window.removeEventListener('resize', this.handleResize);
178
+ }
179
+ this.eventListeners.clear();
180
+ this.isReady = false;
181
+ }
182
+ setupViewportListener() {
183
+ if (typeof window === 'undefined')
184
+ return;
185
+ window.addEventListener('resize', this.handleResize);
186
+ }
187
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Default Theme Manager Implementation
3
+ */
4
+ import type { IThemeManager } from '../../api';
5
+ import type { ThemeMode, ThemeConfig } from '../../api';
6
+ import type { IStorageProvider, IThemeProvider } from '../../spi';
7
+ export declare class DefaultThemeManager implements IThemeManager {
8
+ private currentTheme;
9
+ private config;
10
+ private listeners;
11
+ private storageProvider;
12
+ private themeProvider;
13
+ constructor(config: ThemeConfig | undefined, storageProvider: IStorageProvider, themeProvider: IThemeProvider);
14
+ getTheme(): ThemeMode;
15
+ getResolvedTheme(): 'light' | 'dark';
16
+ setTheme(mode: ThemeMode): void;
17
+ toggleTheme(): void;
18
+ subscribe(listener: (theme: ThemeMode) => void): () => void;
19
+ setCSSVariables(variables: Record<string, string>): void;
20
+ destroy(): void;
21
+ private setupSystemThemeListener;
22
+ private applyTheme;
23
+ private loadPersistedTheme;
24
+ private persistTheme;
25
+ private notifyListeners;
26
+ }
27
+ //# sourceMappingURL=DefaultThemeManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DefaultThemeManager.d.ts","sourceRoot":"","sources":["../../../src/impl/core/DefaultThemeManager.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAIlE,qBAAa,mBAAoB,YAAW,aAAa;IACvD,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,SAAS,CAA8C;IAC/D,OAAO,CAAC,eAAe,CAAmB;IAC1C,OAAO,CAAC,aAAa,CAAiB;gBAGpC,MAAM,EAAE,WAAW,YAAqB,EACxC,eAAe,EAAE,gBAAgB,EACjC,aAAa,EAAE,cAAc;IAU/B,QAAQ,IAAI,SAAS;IAIrB,gBAAgB,IAAI,OAAO,GAAG,MAAM;IAOpC,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI;IAS/B,WAAW,IAAI,IAAI;IAKnB,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,GAAG,MAAM,IAAI;IAK3D,eAAe,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAKxD,OAAO,IAAI,IAAI;IAKf,OAAO,CAAC,wBAAwB;IAShC,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,kBAAkB;IAQ1B,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,eAAe;CAGxB"}
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Default Theme Manager Implementation
3
+ */
4
+ const THEME_STORAGE_KEY = 'ui-shell-theme';
5
+ export class DefaultThemeManager {
6
+ constructor(config = { mode: 'system' }, storageProvider, themeProvider) {
7
+ Object.defineProperty(this, "currentTheme", {
8
+ enumerable: true,
9
+ configurable: true,
10
+ writable: true,
11
+ value: 'system'
12
+ });
13
+ Object.defineProperty(this, "config", {
14
+ enumerable: true,
15
+ configurable: true,
16
+ writable: true,
17
+ value: void 0
18
+ });
19
+ Object.defineProperty(this, "listeners", {
20
+ enumerable: true,
21
+ configurable: true,
22
+ writable: true,
23
+ value: new Set()
24
+ });
25
+ Object.defineProperty(this, "storageProvider", {
26
+ enumerable: true,
27
+ configurable: true,
28
+ writable: true,
29
+ value: void 0
30
+ });
31
+ Object.defineProperty(this, "themeProvider", {
32
+ enumerable: true,
33
+ configurable: true,
34
+ writable: true,
35
+ value: void 0
36
+ });
37
+ this.config = config;
38
+ this.storageProvider = storageProvider;
39
+ this.themeProvider = themeProvider;
40
+ this.currentTheme = config.mode || this.loadPersistedTheme();
41
+ this.setupSystemThemeListener();
42
+ this.applyTheme();
43
+ }
44
+ getTheme() {
45
+ return this.currentTheme;
46
+ }
47
+ getResolvedTheme() {
48
+ if (this.currentTheme === 'system') {
49
+ return this.themeProvider.getSystemPreference();
50
+ }
51
+ return this.currentTheme;
52
+ }
53
+ setTheme(mode) {
54
+ if (this.currentTheme === mode)
55
+ return;
56
+ this.currentTheme = mode;
57
+ this.persistTheme(mode);
58
+ this.applyTheme();
59
+ this.notifyListeners();
60
+ }
61
+ toggleTheme() {
62
+ const resolved = this.getResolvedTheme();
63
+ this.setTheme(resolved === 'light' ? 'dark' : 'light');
64
+ }
65
+ subscribe(listener) {
66
+ this.listeners.add(listener);
67
+ return () => this.listeners.delete(listener);
68
+ }
69
+ setCSSVariables(variables) {
70
+ this.config.cssVariables = { ...this.config.cssVariables, ...variables };
71
+ this.applyTheme();
72
+ }
73
+ destroy() {
74
+ this.themeProvider.destroy();
75
+ this.listeners.clear();
76
+ }
77
+ setupSystemThemeListener() {
78
+ this.themeProvider.onSystemThemeChange(() => {
79
+ if (this.currentTheme === 'system') {
80
+ this.applyTheme();
81
+ this.notifyListeners();
82
+ }
83
+ });
84
+ }
85
+ applyTheme() {
86
+ this.themeProvider.applyTheme(this.currentTheme, this.config);
87
+ }
88
+ loadPersistedTheme() {
89
+ const stored = this.storageProvider.getItem(THEME_STORAGE_KEY);
90
+ if (stored === 'light' || stored === 'dark' || stored === 'system') {
91
+ return stored;
92
+ }
93
+ return 'system';
94
+ }
95
+ persistTheme(mode) {
96
+ this.storageProvider.setItem(THEME_STORAGE_KEY, mode);
97
+ }
98
+ notifyListeners() {
99
+ this.listeners.forEach(listener => listener(this.currentTheme));
100
+ }
101
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Core Implementations
3
+ * Export all core implementation classes
4
+ */
5
+ export * from './DefaultShell';
6
+ export * from './DefaultThemeManager';
7
+ export * from './DefaultFeatureManager';
8
+ export * from './DefaultLayoutManager';
9
+ export * from './DefaultRouter';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/impl/core/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Core Implementations
3
+ * Export all core implementation classes
4
+ */
5
+ export * from './DefaultShell';
6
+ export * from './DefaultThemeManager';
7
+ export * from './DefaultFeatureManager';
8
+ export * from './DefaultLayoutManager';
9
+ export * from './DefaultRouter';
@@ -0,0 +1,21 @@
1
+ /**
2
+ * UI Shell Implementation
3
+ * Concrete implementations of UI Shell interfaces
4
+ *
5
+ * This module provides default implementations that can be used directly
6
+ * or extended for custom behavior.
7
+ */
8
+ export * from '../api';
9
+ export * from '../spi';
10
+ export * from './core';
11
+ export * from './providers';
12
+ export * from './utils';
13
+ export * from './plugin';
14
+ import { DefaultShell } from './core/DefaultShell';
15
+ import { DefaultLayoutManager } from './core/DefaultLayoutManager';
16
+ import type { ShellConfig } from '../api';
17
+ export declare function createShell(config?: ShellConfig): DefaultShell;
18
+ export declare function createLayoutManager(): DefaultLayoutManager;
19
+ export declare function getShell(config?: ShellConfig): DefaultShell;
20
+ export declare function resetShell(): void;
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/impl/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AAGvB,cAAc,QAAQ,CAAC;AAGvB,cAAc,aAAa,CAAC;AAG5B,cAAc,SAAS,CAAC;AAGxB,cAAc,UAAU,CAAC;AAGzB,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAE1C,wBAAgB,WAAW,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,YAAY,CAE9D;AAED,wBAAgB,mBAAmB,IAAI,oBAAoB,CAE1D;AAKD,wBAAgB,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,YAAY,CAK3D;AAED,wBAAgB,UAAU,IAAI,IAAI,CAKjC"}