canvasframework 0.5.18 → 0.5.20

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 (113) hide show
  1. package/README.md +30 -0
  2. package/components/Accordion.js +265 -0
  3. package/components/AndroidDatePickerDialog.js +406 -0
  4. package/components/AppBar.js +398 -0
  5. package/components/AudioPlayer.js +611 -0
  6. package/components/Avatar.js +202 -0
  7. package/components/Banner.js +342 -0
  8. package/components/BottomNavigationBar.js +433 -0
  9. package/components/BottomSheet.js +234 -0
  10. package/components/Button.js +358 -0
  11. package/components/Camera.js +644 -0
  12. package/components/Card.js +193 -0
  13. package/components/Chart.js +700 -0
  14. package/components/Checkbox.js +166 -0
  15. package/components/Chip.js +212 -0
  16. package/components/CircularProgress.js +327 -0
  17. package/components/ContextMenu.js +116 -0
  18. package/components/DatePicker.js +298 -0
  19. package/components/Dialog.js +337 -0
  20. package/components/Divider.js +125 -0
  21. package/components/Drawer.js +276 -0
  22. package/components/FAB.js +270 -0
  23. package/components/FileUpload.js +315 -0
  24. package/components/FloatedCamera.js +644 -0
  25. package/components/IOSDatePickerWheel.js +430 -0
  26. package/components/ImageCarousel.js +219 -0
  27. package/components/ImageComponent.js +223 -0
  28. package/components/Input.js +831 -0
  29. package/components/InputDatalist.js +723 -0
  30. package/components/InputTags.js +624 -0
  31. package/components/List.js +95 -0
  32. package/components/ListItem.js +269 -0
  33. package/components/Modal.js +364 -0
  34. package/components/MorphingFAB.js +428 -0
  35. package/components/MultiSelectDialog.js +206 -0
  36. package/components/NumberInput.js +271 -0
  37. package/components/PasswordInput.js +462 -0
  38. package/components/ProgressBar.js +88 -0
  39. package/components/QRCodeReader.js +539 -0
  40. package/components/RadioButton.js +151 -0
  41. package/components/SearchInput.js +315 -0
  42. package/components/SegmentedControl.js +357 -0
  43. package/components/Select.js +199 -0
  44. package/components/SelectDialog.js +255 -0
  45. package/components/Slider.js +113 -0
  46. package/components/SliverAppBar.js +139 -0
  47. package/components/Snackbar.js +243 -0
  48. package/components/SpeedDialFAB.js +397 -0
  49. package/components/Stepper.js +281 -0
  50. package/components/SwipeableListItem.js +327 -0
  51. package/components/Switch.js +147 -0
  52. package/components/Table.js +492 -0
  53. package/components/Tabs.js +423 -0
  54. package/components/Text.js +141 -0
  55. package/components/TextField.js +151 -0
  56. package/components/TimePicker.js +934 -0
  57. package/components/Toast.js +236 -0
  58. package/components/TreeView.js +420 -0
  59. package/components/Video.js +397 -0
  60. package/components/View.js +140 -0
  61. package/components/VirtualList.js +120 -0
  62. package/core/CanvasFramework.js +3045 -0
  63. package/core/Component.js +243 -0
  64. package/core/ThemeManager.js +358 -0
  65. package/core/UIBuilder.js +267 -0
  66. package/core/WebGLCanvasAdapter.js +782 -0
  67. package/features/Column.js +43 -0
  68. package/features/Grid.js +47 -0
  69. package/features/LayoutComponent.js +43 -0
  70. package/features/OpenStreetMap.js +310 -0
  71. package/features/Positioned.js +33 -0
  72. package/features/PullToRefresh.js +328 -0
  73. package/features/Row.js +40 -0
  74. package/features/SignaturePad.js +257 -0
  75. package/features/Skeleton.js +193 -0
  76. package/features/Stack.js +21 -0
  77. package/index.js +119 -0
  78. package/manager/AccessibilityManager.js +107 -0
  79. package/manager/ErrorHandler.js +59 -0
  80. package/manager/FeatureFlags.js +60 -0
  81. package/manager/MemoryManager.js +107 -0
  82. package/manager/PerformanceMonitor.js +84 -0
  83. package/manager/SecurityManager.js +54 -0
  84. package/package.json +22 -16
  85. package/utils/AnimationEngine.js +734 -0
  86. package/utils/CryptoManager.js +303 -0
  87. package/utils/DataStore.js +403 -0
  88. package/utils/DevTools.js +1618 -0
  89. package/utils/DevToolsConsole.js +201 -0
  90. package/utils/EventBus.js +407 -0
  91. package/utils/FetchClient.js +74 -0
  92. package/utils/FirebaseAuth.js +653 -0
  93. package/utils/FirebaseCore.js +246 -0
  94. package/utils/FirebaseFirestore.js +581 -0
  95. package/utils/FirebaseFunctions.js +97 -0
  96. package/utils/FirebaseRealtimeDB.js +498 -0
  97. package/utils/FirebaseStorage.js +612 -0
  98. package/utils/FormValidator.js +355 -0
  99. package/utils/GeoLocationService.js +62 -0
  100. package/utils/I18n.js +207 -0
  101. package/utils/IndexedDBManager.js +273 -0
  102. package/utils/InspectionOverlay.js +308 -0
  103. package/utils/NotificationManager.js +60 -0
  104. package/utils/OfflineSyncManager.js +342 -0
  105. package/utils/PayPalPayment.js +678 -0
  106. package/utils/QueryBuilder.js +478 -0
  107. package/utils/SafeArea.js +64 -0
  108. package/utils/SecureStorage.js +289 -0
  109. package/utils/StateManager.js +207 -0
  110. package/utils/StripePayment.js +552 -0
  111. package/utils/WebSocketClient.js +66 -0
  112. package/dist/canvasframework.js +0 -2
  113. package/dist/canvasframework.js.LICENSE.txt +0 -1
@@ -0,0 +1,342 @@
1
+ /**
2
+ * Gestionnaire de synchronisation hors ligne
3
+ * Queue les opérations offline et les sync quand online
4
+ * @class
5
+ * @property {Array} queue - File d'attente des opérations
6
+ * @property {boolean} isOnline - État de connexion
7
+ * @property {Map} syncHandlers - Handlers de sync par type
8
+ */
9
+ class OfflineSyncManager {
10
+ /**
11
+ * Crée une instance de OfflineSyncManager
12
+ * @param {Object} [options={}] - Options
13
+ * @param {string} [options.storageKey='offline_queue'] - Clé de stockage
14
+ * @param {number} [options.retryDelay=5000] - Délai entre tentatives (ms)
15
+ * @param {number} [options.maxRetries=3] - Tentatives max
16
+ */
17
+ constructor(options = {}) {
18
+ this.storageKey = options.storageKey || 'offline_queue';
19
+ this.retryDelay = options.retryDelay || 5000;
20
+ this.maxRetries = options.maxRetries || 3;
21
+
22
+ this.queue = [];
23
+ this.isOnline = navigator.onLine;
24
+ this.syncHandlers = new Map();
25
+ this.isSyncing = false;
26
+
27
+ // Charger la queue sauvegardée
28
+ this.loadQueue();
29
+
30
+ // Écouter les changements de connexion
31
+ this.setupConnectionListeners();
32
+ }
33
+
34
+ /**
35
+ * Configure les listeners de connexion
36
+ * @private
37
+ */
38
+ setupConnectionListeners() {
39
+ window.addEventListener('online', () => {
40
+ console.log('🟢 Connection restored');
41
+ this.isOnline = true;
42
+ this.syncAll();
43
+ });
44
+
45
+ window.addEventListener('offline', () => {
46
+ console.log('🔴 Connection lost');
47
+ this.isOnline = false;
48
+ });
49
+ }
50
+
51
+ /**
52
+ * Enregistre un handler de sync
53
+ * @param {string} type - Type d'opération
54
+ * @param {Function} handler - Handler async (operation) => Promise
55
+ */
56
+ registerSyncHandler(type, handler) {
57
+ this.syncHandlers.set(type, handler);
58
+ }
59
+
60
+ /**
61
+ * Ajoute une opération à la queue
62
+ * @param {string} type - Type d'opération
63
+ * @param {Object} data - Données
64
+ * @param {Object} [options={}] - Options
65
+ * @returns {Promise<*>} Résultat
66
+ */
67
+ async queue(type, data, options = {}) {
68
+ const operation = {
69
+ id: this.generateId(),
70
+ type,
71
+ data,
72
+ timestamp: Date.now(),
73
+ retries: 0,
74
+ status: 'pending',
75
+ ...options
76
+ };
77
+
78
+ // Si online, essayer d'exécuter directement
79
+ if (this.isOnline && !options.forceQueue) {
80
+ try {
81
+ const result = await this.executeOperation(operation);
82
+ return result;
83
+ } catch (error) {
84
+ console.warn('Failed to execute immediately, queuing...', error);
85
+ // Continuer pour ajouter à la queue
86
+ }
87
+ }
88
+
89
+ // Ajouter à la queue
90
+ this.queue.push(operation);
91
+ this.saveQueue();
92
+
93
+ console.log(`📋 Operation queued: ${type}`, operation.id);
94
+
95
+ // Essayer de sync immédiatement si online
96
+ if (this.isOnline) {
97
+ this.syncAll();
98
+ }
99
+
100
+ return operation;
101
+ }
102
+
103
+ /**
104
+ * Exécute une opération
105
+ * @param {Object} operation - Opération
106
+ * @returns {Promise<*>} Résultat
107
+ * @private
108
+ */
109
+ async executeOperation(operation) {
110
+ const handler = this.syncHandlers.get(operation.type);
111
+
112
+ if (!handler) {
113
+ throw new Error(`No sync handler for type: ${operation.type}`);
114
+ }
115
+
116
+ return await handler(operation.data);
117
+ }
118
+
119
+ /**
120
+ * Synchronise toutes les opérations en attente
121
+ * @returns {Promise<Object>} Résultats
122
+ */
123
+ async syncAll() {
124
+ if (this.isSyncing || !this.isOnline) return;
125
+
126
+ this.isSyncing = true;
127
+ console.log('🔄 Starting sync...', this.queue.length, 'operations');
128
+
129
+ const results = {
130
+ success: [],
131
+ failed: [],
132
+ skipped: []
133
+ };
134
+
135
+ // Trier par timestamp (FIFO)
136
+ this.queue.sort((a, b) => a.timestamp - b.timestamp);
137
+
138
+ for (let i = 0; i < this.queue.length; i++) {
139
+ const operation = this.queue[i];
140
+
141
+ if (operation.status === 'success') {
142
+ results.skipped.push(operation);
143
+ continue;
144
+ }
145
+
146
+ try {
147
+ console.log(`⏳ Syncing: ${operation.type}`, operation.id);
148
+
149
+ const result = await this.executeOperation(operation);
150
+
151
+ operation.status = 'success';
152
+ operation.result = result;
153
+ operation.syncedAt = Date.now();
154
+
155
+ results.success.push(operation);
156
+ console.log(`✅ Synced: ${operation.type}`, operation.id);
157
+
158
+ } catch (error) {
159
+ operation.retries++;
160
+ operation.lastError = error.message;
161
+
162
+ if (operation.retries >= this.maxRetries) {
163
+ operation.status = 'failed';
164
+ results.failed.push(operation);
165
+ console.error(`❌ Failed permanently: ${operation.type}`, operation.id);
166
+ } else {
167
+ operation.status = 'pending';
168
+ console.warn(`⚠️ Retry ${operation.retries}/${this.maxRetries}:`, operation.type);
169
+ }
170
+ }
171
+ }
172
+
173
+ // Supprimer les opérations réussies de la queue
174
+ this.queue = this.queue.filter(op => op.status !== 'success');
175
+ this.saveQueue();
176
+
177
+ this.isSyncing = false;
178
+
179
+ console.log('✅ Sync complete:', results);
180
+
181
+ // Réessayer les échecs après un délai
182
+ if (results.failed.length > 0 || this.queue.length > 0) {
183
+ setTimeout(() => this.syncAll(), this.retryDelay);
184
+ }
185
+
186
+ return results;
187
+ }
188
+
189
+ /**
190
+ * Synchronise un type spécifique
191
+ * @param {string} type - Type d'opération
192
+ * @returns {Promise<Object>} Résultats
193
+ */
194
+ async syncType(type) {
195
+ const operations = this.queue.filter(op => op.type === type && op.status !== 'success');
196
+
197
+ const results = {
198
+ success: [],
199
+ failed: []
200
+ };
201
+
202
+ for (let operation of operations) {
203
+ try {
204
+ const result = await this.executeOperation(operation);
205
+ operation.status = 'success';
206
+ operation.result = result;
207
+ results.success.push(operation);
208
+ } catch (error) {
209
+ operation.retries++;
210
+ operation.lastError = error.message;
211
+
212
+ if (operation.retries >= this.maxRetries) {
213
+ operation.status = 'failed';
214
+ results.failed.push(operation);
215
+ }
216
+ }
217
+ }
218
+
219
+ this.queue = this.queue.filter(op => op.status !== 'success');
220
+ this.saveQueue();
221
+
222
+ return results;
223
+ }
224
+
225
+ /**
226
+ * Obtient les opérations en attente
227
+ * @param {string} [type] - Filtrer par type
228
+ * @returns {Array} Opérations
229
+ */
230
+ getPending(type) {
231
+ if (type) {
232
+ return this.queue.filter(op => op.type === type && op.status === 'pending');
233
+ }
234
+ return this.queue.filter(op => op.status === 'pending');
235
+ }
236
+
237
+ /**
238
+ * Obtient les opérations échouées
239
+ * @returns {Array} Opérations
240
+ */
241
+ getFailed() {
242
+ return this.queue.filter(op => op.status === 'failed');
243
+ }
244
+
245
+ /**
246
+ * Supprime une opération
247
+ * @param {string} id - ID de l'opération
248
+ * @returns {boolean} True si supprimé
249
+ */
250
+ remove(id) {
251
+ const index = this.queue.findIndex(op => op.id === id);
252
+
253
+ if (index > -1) {
254
+ this.queue.splice(index, 1);
255
+ this.saveQueue();
256
+ return true;
257
+ }
258
+
259
+ return false;
260
+ }
261
+
262
+ /**
263
+ * Réinitialise une opération échouée
264
+ * @param {string} id - ID de l'opération
265
+ */
266
+ retry(id) {
267
+ const operation = this.queue.find(op => op.id === id);
268
+
269
+ if (operation) {
270
+ operation.status = 'pending';
271
+ operation.retries = 0;
272
+ operation.lastError = null;
273
+ this.saveQueue();
274
+
275
+ if (this.isOnline) {
276
+ this.syncAll();
277
+ }
278
+ }
279
+ }
280
+
281
+ /**
282
+ * Vide la queue
283
+ */
284
+ clear() {
285
+ this.queue = [];
286
+ this.saveQueue();
287
+ }
288
+
289
+ /**
290
+ * Sauvegarde la queue
291
+ * @private
292
+ */
293
+ saveQueue() {
294
+ try {
295
+ localStorage.setItem(this.storageKey, JSON.stringify(this.queue));
296
+ } catch (error) {
297
+ console.error('Failed to save queue:', error);
298
+ }
299
+ }
300
+
301
+ /**
302
+ * Charge la queue
303
+ * @private
304
+ */
305
+ loadQueue() {
306
+ try {
307
+ const saved = localStorage.getItem(this.storageKey);
308
+ if (saved) {
309
+ this.queue = JSON.parse(saved);
310
+ console.log('📋 Loaded queue:', this.queue.length, 'operations');
311
+ }
312
+ } catch (error) {
313
+ console.error('Failed to load queue:', error);
314
+ this.queue = [];
315
+ }
316
+ }
317
+
318
+ /**
319
+ * Génère un ID unique
320
+ * @returns {string} ID
321
+ * @private
322
+ */
323
+ generateId() {
324
+ return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
325
+ }
326
+
327
+ /**
328
+ * Obtient les statistiques
329
+ * @returns {Object} Stats
330
+ */
331
+ getStats() {
332
+ return {
333
+ total: this.queue.length,
334
+ pending: this.queue.filter(op => op.status === 'pending').length,
335
+ failed: this.queue.filter(op => op.status === 'failed').length,
336
+ isOnline: this.isOnline,
337
+ isSyncing: this.isSyncing
338
+ };
339
+ }
340
+ }
341
+
342
+ export default OfflineSyncManager;