kimu-core 0.4.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 (146) hide show
  1. package/.editorconfig +30 -0
  2. package/.gitattributes +11 -0
  3. package/.github/FUNDING.yml +8 -0
  4. package/.github/copilot-instructions.md +103 -0
  5. package/.github/kimu-copilot-instructions.md +3779 -0
  6. package/.github/workflows/deploy-demo.yml +39 -0
  7. package/AUTHORS.md +20 -0
  8. package/CHANGELOG.md +20 -0
  9. package/CODE_GUIDELINES.md +165 -0
  10. package/CODE_OF_CONDUCT.md +47 -0
  11. package/CONTRIBUTING.md +62 -0
  12. package/FUNDING.md +31 -0
  13. package/ISSUE_GUIDELINES.md +74 -0
  14. package/LICENSE +17 -0
  15. package/LICENSE.it.md +17 -0
  16. package/MPL-2.0.txt +373 -0
  17. package/NOTICE +65 -0
  18. package/README-KIMU.md +40 -0
  19. package/README.it.md +208 -0
  20. package/README.md +266 -0
  21. package/SECURITY.md +64 -0
  22. package/docs/get-started-en.md +207 -0
  23. package/docs/images/icon.svg +64 -0
  24. package/docs/images/logo_kimu.png +0 -0
  25. package/docs/index.md +29 -0
  26. package/env/dev.config.json +6 -0
  27. package/env/local.config.json +6 -0
  28. package/env/prod.config.json +6 -0
  29. package/env/staging.config.json +6 -0
  30. package/env/test.config.json +4 -0
  31. package/icon.svg +10 -0
  32. package/logo_kimu.png +0 -0
  33. package/package.json +79 -0
  34. package/public/favicon.svg +64 -0
  35. package/public/logo_kimu.svg +1 -0
  36. package/scripts/build-all-config.js +59 -0
  37. package/scripts/build-all-core.js +65 -0
  38. package/scripts/build-all-extensions.js +64 -0
  39. package/scripts/build-all-modules.js +99 -0
  40. package/scripts/build-extension.js +60 -0
  41. package/scripts/clear-kimu-build.js +31 -0
  42. package/scripts/generate-kimu-build-config.js +79 -0
  43. package/scripts/install-module.js +162 -0
  44. package/scripts/list-modules.js +109 -0
  45. package/scripts/minify-css-assets.js +82 -0
  46. package/scripts/remove-module.js +122 -0
  47. package/scripts/utils/fix-imports.js +85 -0
  48. package/src/assets/index.css +43 -0
  49. package/src/assets/kimu-style.css +84 -0
  50. package/src/assets/style.css +116 -0
  51. package/src/config/kimu-base-config.json +5 -0
  52. package/src/core/index.ts +47 -0
  53. package/src/core/kimu-app.ts +76 -0
  54. package/src/core/kimu-asset-manager.ts +167 -0
  55. package/src/core/kimu-component-element.ts +325 -0
  56. package/src/core/kimu-component.ts +33 -0
  57. package/src/core/kimu-engine.ts +188 -0
  58. package/src/core/kimu-extension-manager.ts +281 -0
  59. package/src/core/kimu-global-styles.ts +136 -0
  60. package/src/core/kimu-module-manager.ts +69 -0
  61. package/src/core/kimu-module.ts +21 -0
  62. package/src/core/kimu-path-config.ts +127 -0
  63. package/src/core/kimu-reactive.ts +196 -0
  64. package/src/core/kimu-render.ts +91 -0
  65. package/src/core/kimu-store.ts +147 -0
  66. package/src/core/kimu-types.ts +65 -0
  67. package/src/extensions/.gitkeep +0 -0
  68. package/src/extensions/extensions-manifest.json +13 -0
  69. package/src/extensions/kimu-home/component.ts +80 -0
  70. package/src/extensions/kimu-home/lang/en.json +5 -0
  71. package/src/extensions/kimu-home/lang/it.json +5 -0
  72. package/src/extensions/kimu-home/style.css +61 -0
  73. package/src/extensions/kimu-home/view.html +51 -0
  74. package/src/index.html +26 -0
  75. package/src/main.ts +68 -0
  76. package/src/modules/.gitkeep +0 -0
  77. package/src/modules/README.md +79 -0
  78. package/src/modules/i18n/README.it.md +63 -0
  79. package/src/modules/i18n/README.md +63 -0
  80. package/src/modules/i18n/kimu-global-lang.ts +26 -0
  81. package/src/modules/i18n/kimu-i18n-service.ts +108 -0
  82. package/src/modules/i18n/manifest.json +22 -0
  83. package/src/modules/i18n/module.ts +39 -0
  84. package/src/modules/modules-manifest.json +12 -0
  85. package/src/modules-repository/README.md +108 -0
  86. package/src/modules-repository/api-axios/CHANGELOG.md +48 -0
  87. package/src/modules-repository/api-axios/QUICK-REFERENCE.md +178 -0
  88. package/src/modules-repository/api-axios/README.md +304 -0
  89. package/src/modules-repository/api-axios/api-axios-service.ts +355 -0
  90. package/src/modules-repository/api-axios/examples.ts +293 -0
  91. package/src/modules-repository/api-axios/index.ts +19 -0
  92. package/src/modules-repository/api-axios/interfaces.ts +71 -0
  93. package/src/modules-repository/api-axios/module.ts +41 -0
  94. package/src/modules-repository/api-core/CHANGELOG.md +42 -0
  95. package/src/modules-repository/api-core/QUICK-REFERENCE.md +192 -0
  96. package/src/modules-repository/api-core/README.md +435 -0
  97. package/src/modules-repository/api-core/api-core-service.ts +289 -0
  98. package/src/modules-repository/api-core/examples.ts +432 -0
  99. package/src/modules-repository/api-core/index.ts +8 -0
  100. package/src/modules-repository/api-core/interfaces.ts +83 -0
  101. package/src/modules-repository/api-core/module.ts +30 -0
  102. package/src/modules-repository/event-bus/README.md +273 -0
  103. package/src/modules-repository/event-bus/event-bus-service.ts +176 -0
  104. package/src/modules-repository/event-bus/module.ts +30 -0
  105. package/src/modules-repository/i18n/README.it.md +63 -0
  106. package/src/modules-repository/i18n/README.md +63 -0
  107. package/src/modules-repository/i18n/kimu-global-lang.ts +26 -0
  108. package/src/modules-repository/i18n/kimu-i18n-service.ts +108 -0
  109. package/src/modules-repository/i18n/manifest.json +22 -0
  110. package/src/modules-repository/i18n/module.ts +39 -0
  111. package/src/modules-repository/notification/README.md +423 -0
  112. package/src/modules-repository/notification/module.ts +30 -0
  113. package/src/modules-repository/notification/notification-service.ts +436 -0
  114. package/src/modules-repository/router/README.it.md +39 -0
  115. package/src/modules-repository/router/README.md +39 -0
  116. package/src/modules-repository/router/manifest.json +21 -0
  117. package/src/modules-repository/router/module.ts +23 -0
  118. package/src/modules-repository/router/router.ts +144 -0
  119. package/src/modules-repository/state/README.md +409 -0
  120. package/src/modules-repository/state/module.ts +30 -0
  121. package/src/modules-repository/state/state-service.ts +296 -0
  122. package/src/modules-repository/theme/README.md +267 -0
  123. package/src/modules-repository/theme/module.ts +30 -0
  124. package/src/modules-repository/theme/pre-build.js +40 -0
  125. package/src/modules-repository/theme/theme-service.ts +389 -0
  126. package/src/modules-repository/theme/themes/theme-cherry-blossom.css +78 -0
  127. package/src/modules-repository/theme/themes/theme-cozy.css +111 -0
  128. package/src/modules-repository/theme/themes/theme-cyberpunk.css +150 -0
  129. package/src/modules-repository/theme/themes/theme-dark.css +79 -0
  130. package/src/modules-repository/theme/themes/theme-forest.css +171 -0
  131. package/src/modules-repository/theme/themes/theme-gold.css +100 -0
  132. package/src/modules-repository/theme/themes/theme-high-contrast.css +126 -0
  133. package/src/modules-repository/theme/themes/theme-lava.css +101 -0
  134. package/src/modules-repository/theme/themes/theme-lavender.css +90 -0
  135. package/src/modules-repository/theme/themes/theme-light.css +79 -0
  136. package/src/modules-repository/theme/themes/theme-matrix.css +103 -0
  137. package/src/modules-repository/theme/themes/theme-midnight.css +81 -0
  138. package/src/modules-repository/theme/themes/theme-nord.css +94 -0
  139. package/src/modules-repository/theme/themes/theme-ocean.css +84 -0
  140. package/src/modules-repository/theme/themes/theme-retro80s.css +343 -0
  141. package/src/modules-repository/theme/themes/theme-sunset.css +62 -0
  142. package/src/modules-repository/theme/themes-config.d.ts +27 -0
  143. package/src/modules-repository/theme/themes-config.json +213 -0
  144. package/src/vite-env.d.ts +1 -0
  145. package/tsconfig.json +33 -0
  146. package/vite.config.ts +99 -0
@@ -0,0 +1,71 @@
1
+ /**
2
+ * HTTP method types supported by the API service
3
+ */
4
+ export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
5
+
6
+ /**
7
+ * Configuration options for HTTP requests
8
+ */
9
+ export interface ApiRequestConfig {
10
+ /** HTTP headers to include in the request */
11
+ headers?: Record<string, string>;
12
+ /** Query parameters to append to the URL */
13
+ params?: Record<string, string | number | boolean>;
14
+ /** Request timeout in milliseconds */
15
+ timeout?: number;
16
+ /** Whether to include credentials (cookies) in the request */
17
+ withCredentials?: boolean;
18
+ /** Response type expected from the server */
19
+ responseType?: 'json' | 'text' | 'blob' | 'arraybuffer';
20
+ /** Callback for upload progress */
21
+ onUploadProgress?: (progressEvent: ProgressEvent) => void;
22
+ /** Callback for download progress */
23
+ onDownloadProgress?: (progressEvent: ProgressEvent) => void;
24
+ /** Custom axios config to merge */
25
+ axiosConfig?: any;
26
+ }
27
+
28
+ /**
29
+ * Standard API response structure
30
+ */
31
+ export interface ApiResponse<T = any> {
32
+ /** Response data from the server */
33
+ data: T;
34
+ /** HTTP status code */
35
+ status: number;
36
+ /** HTTP status text */
37
+ statusText: string;
38
+ /** Response headers */
39
+ headers: Record<string, string>;
40
+ /** Original request configuration */
41
+ config: ApiRequestConfig;
42
+ }
43
+
44
+ /**
45
+ * Error response structure for failed requests
46
+ */
47
+ export interface ApiError {
48
+ /** Error message */
49
+ message: string;
50
+ /** HTTP status code (if available) */
51
+ status?: number;
52
+ /** Response data from the server (if available) */
53
+ data?: any;
54
+ /** Original error object */
55
+ originalError?: any;
56
+ }
57
+
58
+ /**
59
+ * Interceptor function for requests
60
+ */
61
+ export type RequestInterceptor = (config: ApiRequestConfig) => ApiRequestConfig | Promise<ApiRequestConfig>;
62
+
63
+ /**
64
+ * Interceptor function for responses
65
+ */
66
+ export type ResponseInterceptor = (response: ApiResponse) => ApiResponse | Promise<ApiResponse>;
67
+
68
+ /**
69
+ * Interceptor function for errors
70
+ */
71
+ export type ErrorInterceptor = (error: ApiError) => any;
@@ -0,0 +1,41 @@
1
+ /**
2
+ * API Axios Module
3
+ *
4
+ * Advanced HTTP client module based on Axios library.
5
+ * Provides enhanced features over the basic api-core module.
6
+ *
7
+ * @module api-axios
8
+ * @author UnicòVerso
9
+ * @version 1.0.0
10
+ */
11
+
12
+ import { KimuModule } from '../../core/kimu-module';
13
+ import { apiAxiosService } from './api-axios-service';
14
+
15
+ /**
16
+ * ApiAxiosModule - Module wrapper for the Axios-based API service
17
+ *
18
+ * This module provides an advanced HTTP client with features like:
19
+ * - Request/response interceptors
20
+ * - Automatic retry logic
21
+ * - Request cancellation
22
+ * - Progress tracking
23
+ * - Response caching
24
+ */
25
+ export default class ApiAxiosModule extends KimuModule {
26
+ constructor(name = 'api-axios', version = '1.0.0', options?: any) {
27
+ super(name, version, options);
28
+ }
29
+
30
+ /**
31
+ * Returns the singleton instance of the API Axios service
32
+ */
33
+ getService() {
34
+ return apiAxiosService;
35
+ }
36
+ }
37
+
38
+ // Re-export for convenience
39
+ export { apiAxiosService } from './api-axios-service';
40
+ export { ApiAxiosService } from './api-axios-service';
41
+ export * from './interfaces';
@@ -0,0 +1,42 @@
1
+ # API Core Module - Changelog
2
+
3
+ ## [1.0.0] - 2025-11-01
4
+
5
+ ### Added
6
+ - Initial release of API Core module
7
+ - Basic HTTP client functionality based on native fetch API
8
+ - Support for all HTTP methods (GET, POST, PUT, PATCH, DELETE)
9
+ - Request/Response/Error interceptors
10
+ - Query parameters and headers management
11
+ - Timeout and request cancellation support
12
+ - Multiple response types (JSON, text, blob, arraybuffer)
13
+ - Global configuration with baseURL
14
+ - TypeScript-first with complete type safety
15
+ - Zero external dependencies (~2KB minified)
16
+ - Comprehensive documentation and examples
17
+
18
+ ### Features
19
+ - ✅ Promise-based async/await API
20
+ - ✅ Automatic JSON parsing
21
+ - ✅ Error handling with structured ApiError
22
+ - ✅ Request/Response transformation via interceptors
23
+ - ✅ Configurable timeout
24
+ - ✅ AbortController support for request cancellation
25
+ - ✅ Query parameters serialization
26
+ - ✅ Custom headers support
27
+ - ✅ Credentials and cache mode configuration
28
+ - ✅ Lightweight and performant
29
+
30
+ ### Documentation
31
+ - Complete README with usage examples
32
+ - TypeScript interfaces and type definitions
33
+ - Example file with 17+ practical use cases
34
+ - Integration examples with KIMU components
35
+
36
+ ### Future Roadmap
37
+ - Automatic retry logic
38
+ - Request caching
39
+ - Request deduplication
40
+ - Upload/Download progress tracking
41
+ - Request queue with priority
42
+ - Mock/test utilities
@@ -0,0 +1,192 @@
1
+ # KIMU API Core Module - Quick Reference
2
+
3
+ ## Installation
4
+ ```bash
5
+ # Using kimu-cli (when available)
6
+ kimu install module api-core
7
+
8
+ # Manual installation
9
+ # Copy src/modules/api-core to your project
10
+ ```
11
+
12
+ ## Quick Start
13
+
14
+ ```typescript
15
+ import { apiCoreService } from './modules/api-core/api-core-service';
16
+
17
+ // Configure
18
+ apiCoreService.configure({
19
+ baseURL: 'https://api.example.com',
20
+ timeout: 10000,
21
+ headers: {
22
+ 'Authorization': 'Bearer YOUR_TOKEN'
23
+ }
24
+ });
25
+
26
+ // Make requests
27
+ const users = await apiCoreService.get('/users');
28
+ const newUser = await apiCoreService.post('/users', { name: 'Mario' });
29
+ const updated = await apiCoreService.patch('/users/1', { age: 30 });
30
+ await apiCoreService.delete('/users/1');
31
+ ```
32
+
33
+ ## Key Features
34
+ - ✅ **Zero dependencies** - Based on native fetch
35
+ - ✅ **Lightweight** - ~2KB minified
36
+ - ✅ **TypeScript-first** - Complete type safety
37
+ - ✅ **Interceptors** - Request/Response/Error hooks
38
+ - ✅ **Timeout** - Configurable request timeout
39
+ - ✅ **Cancellation** - AbortController support
40
+ - ✅ **Query params** - Automatic serialization
41
+ - ✅ **Multiple formats** - JSON, text, blob, arraybuffer
42
+
43
+ ## API Methods
44
+ - `get<T>(url, options?)` - GET request
45
+ - `post<T>(url, data, options?)` - POST request
46
+ - `put<T>(url, data, options?)` - PUT request
47
+ - `patch<T>(url, data, options?)` - PATCH request
48
+ - `delete<T>(url, options?)` - DELETE request
49
+ - `request<T>(url, options)` - Generic request
50
+
51
+ ## Configuration Options
52
+ ```typescript
53
+ interface ApiConfig {
54
+ baseURL?: string;
55
+ timeout?: number;
56
+ headers?: Record<string, string>;
57
+ requestInterceptor?: (config) => config;
58
+ responseInterceptor?: (response) => response;
59
+ errorInterceptor?: (error) => error;
60
+ }
61
+ ```
62
+
63
+ ## Request Options
64
+ ```typescript
65
+ interface ApiRequestOptions {
66
+ method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
67
+ headers?: Record<string, string>;
68
+ body?: any;
69
+ params?: Record<string, string | number | boolean>;
70
+ timeout?: number;
71
+ responseType?: 'json' | 'text' | 'blob' | 'arraybuffer';
72
+ credentials?: RequestCredentials;
73
+ cache?: RequestCache;
74
+ signal?: AbortSignal;
75
+ }
76
+ ```
77
+
78
+ ## Response Structure
79
+ ```typescript
80
+ interface ApiResponse<T> {
81
+ data: T;
82
+ status: number;
83
+ statusText: string;
84
+ headers: Headers;
85
+ raw: Response;
86
+ }
87
+ ```
88
+
89
+ ## Error Structure
90
+ ```typescript
91
+ interface ApiError {
92
+ message: string;
93
+ status?: number;
94
+ statusText?: string;
95
+ data?: any;
96
+ originalError: Error;
97
+ }
98
+ ```
99
+
100
+ ## Common Patterns
101
+
102
+ ### Authentication
103
+ ```typescript
104
+ apiCoreService.configure({
105
+ requestInterceptor: (config) => {
106
+ const token = getToken();
107
+ config.headers = {
108
+ ...config.headers,
109
+ 'Authorization': `Bearer ${token}`
110
+ };
111
+ return config;
112
+ }
113
+ });
114
+ ```
115
+
116
+ ### Error Handling
117
+ ```typescript
118
+ try {
119
+ const response = await apiCoreService.get('/data');
120
+ } catch (error) {
121
+ if (error.status === 401) {
122
+ // Handle unauthorized
123
+ } else if (error.status >= 500) {
124
+ // Handle server error
125
+ }
126
+ }
127
+ ```
128
+
129
+ ### Timeout & Cancellation
130
+ ```typescript
131
+ // With timeout
132
+ await apiCoreService.get('/data', { timeout: 3000 });
133
+
134
+ // With AbortController
135
+ const controller = new AbortController();
136
+ apiCoreService.get('/data', { signal: controller.signal });
137
+ setTimeout(() => controller.abort(), 2000);
138
+ ```
139
+
140
+ ## Integration with KIMU
141
+
142
+ ```typescript
143
+ import { KimuComponentElement } from '@kimu/core';
144
+ import { KimuModuleManager } from '@kimu/core';
145
+
146
+ export class MyComponent extends KimuComponentElement {
147
+ private api: any;
148
+
149
+ async onInit() {
150
+ this.api = KimuModuleManager.getInstance().getService('api-core');
151
+ await this.loadData();
152
+ }
153
+
154
+ async loadData() {
155
+ const response = await this.api.get('/data');
156
+ this.data = response.data;
157
+ this.onRender();
158
+ }
159
+ }
160
+ ```
161
+
162
+ ## Files Structure
163
+ ```
164
+ api-core/
165
+ ├── api-core-service.ts # Main service implementation
166
+ ├── interfaces.ts # TypeScript type definitions
167
+ ├── module.ts # Module class and exports
168
+ ├── index.ts # Main entry point
169
+ ├── examples.ts # Usage examples
170
+ ├── README.md # Complete documentation
171
+ ├── CHANGELOG.md # Version history
172
+ └── QUICK-REFERENCE.md # This file
173
+ ```
174
+
175
+ ## Performance
176
+ - Bundle size: ~2KB minified
177
+ - First request: ~5ms (after DNS)
178
+ - Subsequent requests: ~2ms (with HTTP/2)
179
+ - Zero overhead compared to native fetch
180
+
181
+ ## Browser Support
182
+ - Chrome/Edge: ✅ 90+
183
+ - Firefox: ✅ 88+
184
+ - Safari: ✅ 14+
185
+ - Opera: ✅ 76+
186
+
187
+ ## License
188
+ MPL-2.0 (part of KIMU-Core)
189
+
190
+ ## Support
191
+ - GitHub: [kimu-core/issues](https://github.com/UnicoVerso/kimu-core/issues)
192
+ - Docs: [kimu-docs](https://github.com/UnicoVerso/kimu-docs)