canvasframework 0.3.6

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 (85) hide show
  1. package/README.md +554 -0
  2. package/components/Accordion.js +252 -0
  3. package/components/AndroidDatePickerDialog.js +398 -0
  4. package/components/AppBar.js +225 -0
  5. package/components/Avatar.js +202 -0
  6. package/components/BottomNavigationBar.js +205 -0
  7. package/components/BottomSheet.js +374 -0
  8. package/components/Button.js +225 -0
  9. package/components/Card.js +193 -0
  10. package/components/Checkbox.js +180 -0
  11. package/components/Chip.js +212 -0
  12. package/components/CircularProgress.js +143 -0
  13. package/components/ContextMenu.js +116 -0
  14. package/components/DatePicker.js +257 -0
  15. package/components/Dialog.js +367 -0
  16. package/components/Divider.js +125 -0
  17. package/components/Drawer.js +261 -0
  18. package/components/FAB.js +270 -0
  19. package/components/FileUpload.js +315 -0
  20. package/components/IOSDatePickerWheel.js +268 -0
  21. package/components/ImageCarousel.js +193 -0
  22. package/components/ImageComponent.js +223 -0
  23. package/components/Input.js +309 -0
  24. package/components/List.js +94 -0
  25. package/components/ListItem.js +223 -0
  26. package/components/Modal.js +364 -0
  27. package/components/MultiSelectDialog.js +206 -0
  28. package/components/NumberInput.js +271 -0
  29. package/components/ProgressBar.js +88 -0
  30. package/components/RadioButton.js +142 -0
  31. package/components/SearchInput.js +315 -0
  32. package/components/SegmentedControl.js +202 -0
  33. package/components/Select.js +199 -0
  34. package/components/SelectDialog.js +255 -0
  35. package/components/Slider.js +113 -0
  36. package/components/Snackbar.js +243 -0
  37. package/components/Stepper.js +281 -0
  38. package/components/SwipeableListItem.js +179 -0
  39. package/components/Switch.js +147 -0
  40. package/components/Table.js +492 -0
  41. package/components/Tabs.js +125 -0
  42. package/components/Text.js +141 -0
  43. package/components/TextField.js +331 -0
  44. package/components/Toast.js +236 -0
  45. package/components/TreeView.js +420 -0
  46. package/components/Video.js +397 -0
  47. package/components/View.js +140 -0
  48. package/components/VirtualList.js +120 -0
  49. package/core/CanvasFramework.js +1271 -0
  50. package/core/CanvasWork.js +32 -0
  51. package/core/Component.js +153 -0
  52. package/core/LogicWorker.js +25 -0
  53. package/core/WebGLCanvasAdapter.js +1369 -0
  54. package/features/Column.js +43 -0
  55. package/features/Grid.js +47 -0
  56. package/features/LayoutComponent.js +43 -0
  57. package/features/OpenStreetMap.js +310 -0
  58. package/features/Positioned.js +33 -0
  59. package/features/PullToRefresh.js +328 -0
  60. package/features/Row.js +40 -0
  61. package/features/SignaturePad.js +257 -0
  62. package/features/Skeleton.js +84 -0
  63. package/features/Stack.js +21 -0
  64. package/index.js +101 -0
  65. package/manager/AccessibilityManager.js +107 -0
  66. package/manager/ErrorHandler.js +59 -0
  67. package/manager/FeatureFlags.js +60 -0
  68. package/manager/MemoryManager.js +107 -0
  69. package/manager/PerformanceMonitor.js +84 -0
  70. package/manager/SecurityManager.js +54 -0
  71. package/package.json +28 -0
  72. package/utils/AnimationEngine.js +428 -0
  73. package/utils/DataStore.js +403 -0
  74. package/utils/EventBus.js +407 -0
  75. package/utils/FetchClient.js +74 -0
  76. package/utils/FormValidator.js +355 -0
  77. package/utils/GeoLocationService.js +62 -0
  78. package/utils/I18n.js +207 -0
  79. package/utils/IndexedDBManager.js +273 -0
  80. package/utils/OfflineSyncManager.js +342 -0
  81. package/utils/QueryBuilder.js +478 -0
  82. package/utils/SafeArea.js +64 -0
  83. package/utils/SecureStorage.js +289 -0
  84. package/utils/StateManager.js +207 -0
  85. package/utils/WebSocketClient.js +66 -0
@@ -0,0 +1,21 @@
1
+ import LayoutComponent from './LayoutComponent.js';
2
+
3
+ class Stack extends LayoutComponent {
4
+ constructor(framework, options = {}) {
5
+ super(framework, options);
6
+ }
7
+
8
+ layoutRecursive() {
9
+ for (const child of this.children) {
10
+ child.layoutRecursive ? child.layoutRecursive() : child.layout?.();
11
+ }
12
+ }
13
+
14
+ draw(ctx) {
15
+ for (const child of this.children) {
16
+ child.draw(ctx);
17
+ }
18
+ }
19
+ }
20
+
21
+ export default Stack;
package/index.js ADDED
@@ -0,0 +1,101 @@
1
+ // framework/index.js
2
+
3
+ // Core
4
+ export { default as CanvasFramework } from './core/CanvasFramework.js';
5
+ export { default as Component } from './core/Component.js';
6
+
7
+ // Components
8
+ export { default as Button } from './components/Button.js';
9
+ export { default as SegmentedControl } from './components/SegmentedControl.js';
10
+ export { default as Input } from './components/Input.js';
11
+ export { default as Slider } from './components/Slider.js';
12
+ export { default as Text } from './components/Text.js';
13
+ export { default as View } from './components/View.js';
14
+ export { default as Card } from './components/Card.js';
15
+ export { default as FAB } from './components/FAB.js';
16
+ export { default as CircularProgress } from './components/CircularProgress.js';
17
+ export { default as ImageComponent } from './components/ImageComponent.js';
18
+ export { default as DatePicker } from './components/DatePicker.js';
19
+ export { default as IOSDatePickerWheel } from './components/IOSDatePickerWheel.js';
20
+ export { default as AndroidDatePickerDialog } from './components/AndroidDatePickerDialog.js';
21
+ export { default as Avatar } from './components/Avatar.js';
22
+ export { default as Snackbar } from './components/Snackbar.js';
23
+ export { default as BottomNavigationBar } from './components/BottomNavigationBar.js';
24
+ export { default as Video } from './components/Video.js';
25
+ export { default as Modal } from './components/Modal.js';
26
+ export { default as Drawer } from './components/Drawer.js';
27
+ export { default as AppBar } from './components/AppBar.js';
28
+ export { default as Chip } from './components/Chip.js';
29
+ export { default as Stepper } from './components/Stepper.js';
30
+ export { default as Accordion } from './components/Accordion.js';
31
+ export { default as Tabs } from './components/Tabs.js';
32
+ export { default as Switch } from './components/Switch.js';
33
+ export { default as ListItem } from './components/ListItem.js';
34
+ export { default as SwipeableListItem } from './components/SwipeableListItem.js';
35
+ export { default as List } from './components/List.js';
36
+ export { default as VirtualList } from './components/VirtualList.js';
37
+ export { default as BottomSheet } from './components/BottomSheet.js';
38
+ export { default as ProgressBar } from './components/ProgressBar.js';
39
+ export { default as RadioButton } from './components/RadioButton.js';
40
+ export { default as Dialog } from './components/Dialog.js';
41
+ export { default as ContextMenu } from './components/ContextMenu.js';
42
+ export { default as Checkbox } from './components/Checkbox.js';
43
+ export { default as Toast } from './components/Toast.js';
44
+ export { default as NumberInput } from './components/NumberInput.js';
45
+ export { default as TextField } from './components/TextField.js';
46
+ export { default as SelectDialog } from './components/SelectDialog.js';
47
+ export { default as Select } from './components/Select.js';
48
+ export { default as MultiSelectDialog } from './components/MultiSelectDialog.js';
49
+ export { default as Divider } from './components/Divider.js';
50
+ export { default as FileUpload } from './components/FileUpload.js';
51
+ export { default as Table } from './components/Table.js';
52
+ export { default as TreeView } from './components/TreeView.js';
53
+ export { default as SearchInput } from './components/SearchInput.js';
54
+ export { default as ImageCarousel } from './components/ImageCarousel.js';
55
+
56
+ // Utils
57
+ export { default as SafeArea } from './utils/SafeArea.js';
58
+ export { default as StateManager } from './utils/StateManager.js';
59
+ export { default as I18n } from './utils/I18n.js';
60
+ export { default as SecureStorage } from './utils/SecureStorage.js';
61
+ export { default as FormValidator } from './utils/FormValidator.js';
62
+ export { default as DataStore } from './utils/DataStore.js';
63
+ export { default as EventBus } from './utils/EventBus.js';
64
+ export { default as IndexedDBManager } from './utils/IndexedDBManager.js';
65
+ export { default as QueryBuilder } from './utils/QueryBuilder.js';
66
+ export { default as OfflineSyncManager } from './utils/OfflineSyncManager.js';
67
+ export { default as FetchClient } from './utils/FetchClient.js';
68
+ export { default as GeoLocationService } from './utils/GeoLocationService.js';
69
+ export { default as WebSocketClient } from './utils/WebSocketClient.js';
70
+ export { default as AnimationEngine } from './utils/AnimationEngine.js';
71
+
72
+ // Features
73
+ export { default as PullToRefresh } from './features/PullToRefresh.js';
74
+ export { default as Skeleton } from './features/Skeleton.js';
75
+ export { default as SignaturePad } from './features/SignaturePad.js';
76
+ export { default as OpenStreetMap } from './features/OpenStreetMap.js';
77
+ export { default as LayoutComponent } from './features/LayoutComponent.js';
78
+ export { default as Grid } from './features/Grid.js';
79
+ export { default as Row } from './features/Row.js';
80
+ export { default as Column } from './features/Column.js';
81
+ export { default as Positioned } from './features/Positioned.js';
82
+ export { default as Stack } from './features/Stack.js';
83
+
84
+ // Manager
85
+ export { default as ErrorHandler } from './manager/ErrorHandler.js';
86
+ export { default as PerformanceMonitor } from './manager/PerformanceMonitor.js';
87
+ export { default as AccessibilityManager } from './manager/AccessibilityManager.js';
88
+ export { default as MemoryManager } from './manager/MemoryManager.js';
89
+ export { default as SecurityManager } from './manager/SecurityManager.js';
90
+ export { default as FeatureFlags } from './manager/FeatureFlags.js';
91
+
92
+ // Version du framework
93
+
94
+ export const VERSION = '0.3.6';
95
+
96
+
97
+
98
+
99
+
100
+
101
+
@@ -0,0 +1,107 @@
1
+ // ==========================================
2
+ // 3. ACCESSIBILITY (A11Y)
3
+ // ==========================================
4
+
5
+ class AccessibilityManager {
6
+ constructor(framework) {
7
+ this.framework = framework;
8
+ this.focusedComponent = null;
9
+ this.ariaLiveRegion = null;
10
+ this.setupAccessibility();
11
+ }
12
+
13
+ setupAccessibility() {
14
+ // Créer une région ARIA live pour les annonces
15
+ this.ariaLiveRegion = document.createElement('div');
16
+ this.ariaLiveRegion.setAttribute('role', 'status');
17
+ this.ariaLiveRegion.setAttribute('aria-live', 'polite');
18
+ this.ariaLiveRegion.setAttribute('aria-atomic', 'true');
19
+ this.ariaLiveRegion.style.position = 'absolute';
20
+ this.ariaLiveRegion.style.left = '-10000px';
21
+ this.ariaLiveRegion.style.width = '1px';
22
+ this.ariaLiveRegion.style.height = '1px';
23
+ this.ariaLiveRegion.style.overflow = 'hidden';
24
+ document.body.appendChild(this.ariaLiveRegion);
25
+
26
+ // Rendre le canvas accessible au clavier
27
+ this.framework.canvas.setAttribute('tabindex', '0');
28
+ this.framework.canvas.setAttribute('role', 'application');
29
+ this.framework.canvas.setAttribute('aria-label', 'Interactive canvas application');
30
+
31
+ // Navigation au clavier
32
+ this.framework.canvas.addEventListener('keydown', this.handleKeyDown.bind(this));
33
+ }
34
+
35
+ announce(message) {
36
+ this.ariaLiveRegion.textContent = message;
37
+
38
+ // Clear après 100ms pour permettre de ré-annoncer le même message
39
+ setTimeout(() => {
40
+ this.ariaLiveRegion.textContent = '';
41
+ }, 100);
42
+ }
43
+
44
+ handleKeyDown(e) {
45
+ const components = this.framework.components.filter(c => c.visible);
46
+ const currentIndex = components.indexOf(this.focusedComponent);
47
+
48
+ switch (e.key) {
49
+ case 'Tab':
50
+ e.preventDefault();
51
+ const nextIndex = e.shiftKey
52
+ ? (currentIndex - 1 + components.length) % components.length
53
+ : (currentIndex + 1) % components.length;
54
+
55
+ this.focusComponent(components[nextIndex]);
56
+ break;
57
+
58
+ case 'Enter':
59
+ case ' ':
60
+ e.preventDefault();
61
+ if (this.focusedComponent && this.focusedComponent.onClick) {
62
+ this.focusedComponent.onClick();
63
+ this.announce(`Activated: ${this.getComponentLabel(this.focusedComponent)}`);
64
+ }
65
+ break;
66
+
67
+ case 'Escape':
68
+ e.preventDefault();
69
+ this.blur();
70
+ break;
71
+ }
72
+ }
73
+
74
+ focusComponent(component) {
75
+ if (this.focusedComponent) {
76
+ this.focusedComponent.focused = false;
77
+ }
78
+
79
+ this.focusedComponent = component;
80
+ component.focused = true;
81
+
82
+ // Annoncer le composant focalisé
83
+ this.announce(`Focused: ${this.getComponentLabel(component)}`);
84
+ }
85
+
86
+ blur() {
87
+ if (this.focusedComponent) {
88
+ this.focusedComponent.focused = false;
89
+ this.focusedComponent = null;
90
+ }
91
+ }
92
+
93
+ getComponentLabel(component) {
94
+ return component.text ||
95
+ component.label ||
96
+ component.ariaLabel ||
97
+ component.constructor.name;
98
+ }
99
+
100
+ destroy() {
101
+ if (this.ariaLiveRegion) {
102
+ this.ariaLiveRegion.remove();
103
+ }
104
+ }
105
+ }
106
+
107
+ export default AccessibilityManager;
@@ -0,0 +1,59 @@
1
+ // ==========================================
2
+ // 1. ERROR HANDLING & LOGGING
3
+ // ==========================================
4
+
5
+ class ErrorHandler {
6
+ constructor(options = {}) {
7
+ this.sentryDsn = options.sentryDsn;
8
+ this.environment = options.environment || 'production';
9
+ this.logLevel = options.logLevel || 'error';
10
+ this.errors = [];
11
+ }
12
+
13
+ captureError(error, context = {}) {
14
+ const errorLog = {
15
+ message: error.message,
16
+ stack: error.stack,
17
+ context,
18
+ timestamp: Date.now(),
19
+ userAgent: navigator.userAgent,
20
+ url: window.location.href
21
+ };
22
+
23
+ this.errors.push(errorLog);
24
+
25
+ // Log to console in dev
26
+ if (this.environment === 'development') {
27
+ console.error('🚨 Error captured:', errorLog);
28
+ }
29
+
30
+ // Send to Sentry in production
31
+ if (this.sentryDsn && this.environment === 'production') {
32
+ this.sendToSentry(errorLog);
33
+ }
34
+
35
+ return errorLog;
36
+ }
37
+
38
+ sendToSentry(errorLog) {
39
+ // Integration avec Sentry
40
+ if (window.Sentry) {
41
+ window.Sentry.captureException(new Error(errorLog.message), {
42
+ extra: errorLog.context
43
+ });
44
+ }
45
+ }
46
+
47
+ wrap(fn, context = '') {
48
+ return (...args) => {
49
+ try {
50
+ return fn(...args);
51
+ } catch (error) {
52
+ this.captureError(error, { context, args });
53
+ throw error;
54
+ }
55
+ };
56
+ }
57
+ }
58
+
59
+ export default ErrorHandler;
@@ -0,0 +1,60 @@
1
+ // ==========================================
2
+ // 6. FEATURE FLAGS & AB TESTING
3
+ // ==========================================
4
+
5
+ class FeatureFlags {
6
+ constructor(config = {}) {
7
+ this.flags = config.flags || {};
8
+ this.userId = config.userId;
9
+ this.experiments = {};
10
+ }
11
+
12
+ isEnabled(flagName) {
13
+ const flag = this.flags[flagName];
14
+
15
+ if (typeof flag === 'boolean') {
16
+ return flag;
17
+ }
18
+
19
+ if (typeof flag === 'object') {
20
+ // Percentage rollout
21
+ if (flag.percentage && this.userId) {
22
+ const hash = this.hashUserId(this.userId);
23
+ return hash < flag.percentage;
24
+ }
25
+
26
+ // A/B test
27
+ if (flag.variants) {
28
+ return this.getVariant(flagName, flag.variants);
29
+ }
30
+ }
31
+
32
+ return false;
33
+ }
34
+
35
+ getVariant(experimentName, variants) {
36
+ if (!this.userId) return variants[0];
37
+
38
+ const hash = this.hashUserId(this.userId + experimentName);
39
+ const variantIndex = hash % variants.length;
40
+
41
+ this.experiments[experimentName] = variants[variantIndex];
42
+ return variants[variantIndex];
43
+ }
44
+
45
+ hashUserId(str) {
46
+ let hash = 0;
47
+ for (let i = 0; i < str.length; i++) {
48
+ hash = ((hash << 5) - hash) + str.charCodeAt(i);
49
+ hash = hash & hash;
50
+ }
51
+ return Math.abs(hash) % 100;
52
+ }
53
+
54
+ trackExperiment(experimentName) {
55
+ // Envoyer à analytics
56
+ console.log('Experiment:', experimentName, this.experiments[experimentName]);
57
+ }
58
+ }
59
+
60
+ export default FeatureFlags;
@@ -0,0 +1,107 @@
1
+ // ==========================================
2
+ // 4. MEMORY MANAGEMENT
3
+ // ==========================================
4
+
5
+ class MemoryManager {
6
+ constructor(framework) {
7
+ this.framework = framework;
8
+ this.imageCache = new Map();
9
+ this.maxCacheSize = 50 * 1024 * 1024; // 50MB
10
+ this.currentCacheSize = 0;
11
+ this.componentRegistry = new WeakMap();
12
+ }
13
+
14
+ cacheImage(url, image) {
15
+ const size = this.estimateImageSize(image);
16
+
17
+ // Éviction si dépassement
18
+ if (this.currentCacheSize + size > this.maxCacheSize) {
19
+ this.evictOldest();
20
+ }
21
+
22
+ this.imageCache.set(url, {
23
+ image,
24
+ size,
25
+ lastAccessed: Date.now(),
26
+ accessCount: 0
27
+ });
28
+
29
+ this.currentCacheSize += size;
30
+ }
31
+
32
+ getImage(url) {
33
+ const cached = this.imageCache.get(url);
34
+ if (cached) {
35
+ cached.lastAccessed = Date.now();
36
+ cached.accessCount++;
37
+ return cached.image;
38
+ }
39
+ return null;
40
+ }
41
+
42
+ evictOldest() {
43
+ let oldest = null;
44
+ let oldestTime = Infinity;
45
+
46
+ for (let [url, data] of this.imageCache) {
47
+ if (data.lastAccessed < oldestTime) {
48
+ oldestTime = data.lastAccessed;
49
+ oldest = url;
50
+ }
51
+ }
52
+
53
+ if (oldest) {
54
+ const data = this.imageCache.get(oldest);
55
+ this.currentCacheSize -= data.size;
56
+ this.imageCache.delete(oldest);
57
+ }
58
+ }
59
+
60
+ estimateImageSize(image) {
61
+ // Estimation approximative
62
+ return image.width * image.height * 4; // 4 bytes per pixel (RGBA)
63
+ }
64
+
65
+ registerComponent(component) {
66
+ this.componentRegistry.set(component, {
67
+ created: Date.now(),
68
+ listeners: []
69
+ });
70
+ }
71
+
72
+ unregisterComponent(component) {
73
+ const data = this.componentRegistry.get(component);
74
+ if (data) {
75
+ // Nettoyer tous les event listeners
76
+ data.listeners.forEach(({ element, event, handler }) => {
77
+ element.removeEventListener(event, handler);
78
+ });
79
+ }
80
+ this.componentRegistry.delete(component);
81
+ }
82
+
83
+ trackListener(component, element, event, handler) {
84
+ const data = this.componentRegistry.get(component);
85
+ if (data) {
86
+ data.listeners.push({ element, event, handler });
87
+ }
88
+ }
89
+
90
+ clearAll() {
91
+ this.imageCache.clear();
92
+ this.currentCacheSize = 0;
93
+ }
94
+
95
+ getMemoryReport() {
96
+ return {
97
+ imageCacheSize: `${(this.currentCacheSize / 1024 / 1024).toFixed(2)} MB`,
98
+ imageCacheCount: this.imageCache.size,
99
+ componentCount: this.framework.components.length,
100
+ heapSize: performance.memory
101
+ ? `${(performance.memory.usedJSHeapSize / 1024 / 1024).toFixed(2)} MB`
102
+ : 'N/A'
103
+ };
104
+ }
105
+ }
106
+
107
+ export default MemoryManager;
@@ -0,0 +1,84 @@
1
+ // ==========================================
2
+ // 2. PERFORMANCE MONITORING
3
+ // ==========================================
4
+
5
+ class PerformanceMonitor {
6
+ constructor() {
7
+ this.metrics = {
8
+ fps: 60,
9
+ frameTime: 0,
10
+ memoryUsage: 0,
11
+ renderTime: 0,
12
+ componentCount: 0
13
+ };
14
+
15
+ this.fpsHistory = [];
16
+ this.frameCount = 0;
17
+ this.lastTime = performance.now();
18
+ this.isMonitoring = false;
19
+ }
20
+
21
+ startMonitoring() {
22
+ this.isMonitoring = true;
23
+ this.updateMetrics();
24
+ }
25
+
26
+ stopMonitoring() {
27
+ this.isMonitoring = false;
28
+ }
29
+
30
+ updateMetrics() {
31
+ if (!this.isMonitoring) return;
32
+
33
+ const now = performance.now();
34
+ const deltaTime = now - this.lastTime;
35
+
36
+ // Calculer FPS
37
+ this.frameCount++;
38
+ if (deltaTime >= 1000) {
39
+ this.metrics.fps = Math.round((this.frameCount * 1000) / deltaTime);
40
+ this.fpsHistory.push(this.metrics.fps);
41
+
42
+ // Garder seulement les 60 dernières secondes
43
+ if (this.fpsHistory.length > 60) {
44
+ this.fpsHistory.shift();
45
+ }
46
+
47
+ this.frameCount = 0;
48
+ this.lastTime = now;
49
+
50
+ // Alerter si FPS < 30
51
+ if (this.metrics.fps < 30) {
52
+ console.warn('⚠️ Low FPS detected:', this.metrics.fps);
53
+ }
54
+ }
55
+
56
+ // Mémoire (si disponible)
57
+ if (performance.memory) {
58
+ this.metrics.memoryUsage = Math.round(
59
+ performance.memory.usedJSHeapSize / 1048576
60
+ ); // MB
61
+ }
62
+
63
+ requestAnimationFrame(() => this.updateMetrics());
64
+ }
65
+
66
+ measureRender(fn) {
67
+ const start = performance.now();
68
+ fn();
69
+ const end = performance.now();
70
+ this.metrics.renderTime = end - start;
71
+ return this.metrics.renderTime;
72
+ }
73
+
74
+ getReport() {
75
+ return {
76
+ current: this.metrics,
77
+ averageFPS: this.fpsHistory.reduce((a, b) => a + b, 0) / this.fpsHistory.length,
78
+ minFPS: Math.min(...this.fpsHistory),
79
+ maxFPS: Math.max(...this.fpsHistory)
80
+ };
81
+ }
82
+ }
83
+
84
+ export default PerformanceMonitor;
@@ -0,0 +1,54 @@
1
+ // ==========================================
2
+ // 5. SECURITY
3
+ // ==========================================
4
+
5
+ class SecurityManager {
6
+ static sanitizeInput(input) {
7
+ if (typeof input !== 'string') return input;
8
+
9
+ // Échapper les caractères HTML dangereux
10
+ return input
11
+ .replace(/&/g, '&amp;')
12
+ .replace(/</g, '&lt;')
13
+ .replace(/>/g, '&gt;')
14
+ .replace(/"/g, '&quot;')
15
+ .replace(/'/g, '&#x27;')
16
+ .replace(/\//g, '&#x2F;');
17
+ }
18
+
19
+ static validateUrl(url) {
20
+ try {
21
+ const parsed = new URL(url);
22
+ // Autoriser seulement http(s)
23
+ if (!['http:', 'https:'].includes(parsed.protocol)) {
24
+ throw new Error('Invalid protocol');
25
+ }
26
+ return true;
27
+ } catch {
28
+ return false;
29
+ }
30
+ }
31
+
32
+ static rateLimit(fn, limit = 100, window = 1000) {
33
+ const calls = [];
34
+
35
+ return function(...args) {
36
+ const now = Date.now();
37
+
38
+ // Nettoyer les appels trop anciens
39
+ while (calls.length && calls[0] < now - window) {
40
+ calls.shift();
41
+ }
42
+
43
+ if (calls.length >= limit) {
44
+ console.warn('⚠️ Rate limit exceeded');
45
+ return null;
46
+ }
47
+
48
+ calls.push(now);
49
+ return fn.apply(this, args);
50
+ };
51
+ }
52
+ }
53
+
54
+ export default SecurityManager;
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "canvasframework",
3
+ "version": "0.3.6",
4
+ "description": "Canvas-based cross-platform UI framework (Material & Cupertino)",
5
+ "type": "module",
6
+ "main": "./index.js",
7
+ "exports": {
8
+ ".": "./index.js"
9
+ },
10
+ "files": [
11
+ "index.js",
12
+ "components",
13
+ "core",
14
+ "features",
15
+ "manager",
16
+ "layout",
17
+ "utils"
18
+ ],
19
+ "keywords": [
20
+ "canvas",
21
+ "ui",
22
+ "framework",
23
+ "material",
24
+ "cupertino",
25
+ "mobile"
26
+ ],
27
+ "license": "MIT"
28
+ }