samre-cli 1.0.5 → 1.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.
- package/package.json +1 -1
- package/src/templates/flutter_sdk.js +15 -15
- package/src/utils/flutter.js +10 -9
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
// Modèle complet pour lib/samre_sdk.dart (Version 100%
|
|
1
|
+
// Modèle complet pour lib/samre_sdk.dart (Version Professionnelle 100% Autonome)
|
|
2
2
|
|
|
3
3
|
export function generateFlutterSdkCode({ apiUrl, apiKey, appId, appName, dureeJours }) {
|
|
4
4
|
return `// =================================================================
|
|
5
|
-
// SDK Samré Mobile pour Flutter (Généré
|
|
5
|
+
// SDK Samré Mobile pour Flutter (Généré par samre-cli)
|
|
6
6
|
// Application : ${appName || 'App Samré'} (ID: ${appId})
|
|
7
7
|
// Campagne : ${dureeJours || 12} jours
|
|
8
8
|
// =================================================================
|
|
@@ -18,7 +18,7 @@ class SamreConfig {
|
|
|
18
18
|
static const String apiUrl = "${apiUrl}";
|
|
19
19
|
static const String apiKey = "${apiKey}";
|
|
20
20
|
static const String appId = "${appId}";
|
|
21
|
-
static const int requiredDurationSeconds = 25; // Compteur
|
|
21
|
+
static const int requiredDurationSeconds = 25; // Compteur anti-triche
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
/// Overlay automatique avec compteur de sécurité de 25 secondes
|
|
@@ -79,27 +79,27 @@ class _SamreOverlayState extends State<SamreOverlay> {
|
|
|
79
79
|
children: [
|
|
80
80
|
widget.child,
|
|
81
81
|
|
|
82
|
-
// ── Bouton Flottant Rehaussé avec SafeArea
|
|
82
|
+
// ── Bouton Flottant Rehaussé avec SafeArea ─────────────────────────
|
|
83
83
|
Positioned(
|
|
84
|
-
bottom:
|
|
84
|
+
bottom: 56,
|
|
85
85
|
right: 18,
|
|
86
86
|
child: SafeArea(
|
|
87
87
|
child: Material(
|
|
88
88
|
elevation: 10,
|
|
89
|
-
borderRadius: BorderRadius.circular(
|
|
89
|
+
borderRadius: BorderRadius.circular(30),
|
|
90
90
|
color: _canSubmit ? const Color(0xFF2563EB) : Colors.black.withOpacity(0.85),
|
|
91
91
|
child: InkWell(
|
|
92
|
-
borderRadius: BorderRadius.circular(
|
|
92
|
+
borderRadius: BorderRadius.circular(30),
|
|
93
93
|
onTap: _canSubmit ? _openDialog : null,
|
|
94
94
|
child: Padding(
|
|
95
|
-
padding: const EdgeInsets.symmetric(horizontal:
|
|
95
|
+
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
|
96
96
|
child: Row(
|
|
97
97
|
mainAxisSize: MainAxisSize.min,
|
|
98
98
|
children: [
|
|
99
99
|
Icon(
|
|
100
|
-
_canSubmit ? Icons.
|
|
100
|
+
_canSubmit ? Icons.verified_user_rounded : Icons.timer_outlined,
|
|
101
101
|
color: Colors.white,
|
|
102
|
-
size:
|
|
102
|
+
size: 20,
|
|
103
103
|
),
|
|
104
104
|
const SizedBox(width: 8),
|
|
105
105
|
Text(
|
|
@@ -107,7 +107,7 @@ class _SamreOverlayState extends State<SamreOverlay> {
|
|
|
107
107
|
style: const TextStyle(
|
|
108
108
|
color: Colors.white,
|
|
109
109
|
fontWeight: FontWeight.bold,
|
|
110
|
-
fontSize:
|
|
110
|
+
fontSize: 13,
|
|
111
111
|
decoration: TextDecoration.none,
|
|
112
112
|
),
|
|
113
113
|
),
|
|
@@ -119,7 +119,7 @@ class _SamreOverlayState extends State<SamreOverlay> {
|
|
|
119
119
|
),
|
|
120
120
|
),
|
|
121
121
|
|
|
122
|
-
// ── Fenêtre Modale de Validation (Indépendante du Navigator)
|
|
122
|
+
// ── Fenêtre Modale de Validation (100% Indépendante du Navigator) ──
|
|
123
123
|
if (_showValidationDialog)
|
|
124
124
|
Positioned.fill(
|
|
125
125
|
child: Container(
|
|
@@ -233,8 +233,8 @@ class _SamreValidationCardState extends State<SamreValidationCard> {
|
|
|
233
233
|
border: Border.all(color: const Color(0xFF334155), width: 1.5),
|
|
234
234
|
boxShadow: [
|
|
235
235
|
BoxShadow(
|
|
236
|
-
color: Colors.black.withOpacity(0.
|
|
237
|
-
blurRadius:
|
|
236
|
+
color: Colors.black.withOpacity(0.6),
|
|
237
|
+
blurRadius: 30,
|
|
238
238
|
spreadRadius: 5,
|
|
239
239
|
),
|
|
240
240
|
],
|
|
@@ -244,7 +244,7 @@ class _SamreValidationCardState extends State<SamreValidationCard> {
|
|
|
244
244
|
mainAxisSize: MainAxisSize.min,
|
|
245
245
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
246
246
|
children: [
|
|
247
|
-
//
|
|
247
|
+
// En-tête
|
|
248
248
|
Row(
|
|
249
249
|
children: [
|
|
250
250
|
Container(
|
package/src/utils/flutter.js
CHANGED
|
@@ -57,9 +57,9 @@ export const FlutterUtil = {
|
|
|
57
57
|
cleanMainDartContent(rawContent) {
|
|
58
58
|
let content = rawContent;
|
|
59
59
|
|
|
60
|
-
// 1. Supprimer l'import du SDK Samré
|
|
60
|
+
// 1. Supprimer l'import du SDK Samré et les commentaires associés
|
|
61
61
|
content = content.replace(/import\s+['"]samre_sdk\.dart['"];\s*\n?/g, '');
|
|
62
|
-
content = content.replace(/\/\/\s*SDK
|
|
62
|
+
content = content.replace(/\/\/\s*SDK Samré[^\n]*\n?/gi, '');
|
|
63
63
|
content = content.replace(/\/\/\s*👉\s*SamreOverlay[^\n]*\n?/gi, '');
|
|
64
64
|
|
|
65
65
|
// 2. Supprimer la propriété builder SamreOverlay dans MaterialApp
|
|
@@ -82,23 +82,24 @@ export const FlutterUtil = {
|
|
|
82
82
|
|
|
83
83
|
const originalContent = fs.readFileSync(mainPath, 'utf-8');
|
|
84
84
|
|
|
85
|
-
// Nettoyer d'abord tout résidu ou ancienne injection
|
|
85
|
+
// Nettoyer d'abord tout résidu ou ancienne injection pour garantir l'idempotence
|
|
86
86
|
let cleanContent = this.cleanMainDartContent(originalContent);
|
|
87
87
|
|
|
88
|
-
// Sauvegarde de secours du fichier propre
|
|
88
|
+
// Sauvegarde de secours du fichier propre initial
|
|
89
89
|
if (!fs.existsSync(backupPath)) {
|
|
90
90
|
fs.writeFileSync(backupPath, cleanContent, 'utf-8');
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
let modified = cleanContent;
|
|
94
94
|
|
|
95
|
-
// 1. Ajouter l'import de samre_sdk en haut (sans dupliquer)
|
|
95
|
+
// 1. Ajouter l'import de samre_sdk en haut (sans dupliquer material.dart)
|
|
96
96
|
if (!modified.includes('samre_sdk.dart')) {
|
|
97
97
|
modified = "import 'samre_sdk.dart';\n" + modified;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
// 2. Injecter proprement dans builder de MaterialApp
|
|
101
|
-
|
|
100
|
+
// 2. Injecter proprement dans builder de MaterialApp (supporte MaterialApp, MaterialApp.router, GetMaterialApp)
|
|
101
|
+
const appRegex = /((?:Get)?MaterialApp(?:\.router)?\s*\()/;
|
|
102
|
+
if (appRegex.test(modified)) {
|
|
102
103
|
// Si MaterialApp a déjà une propriété builder existante
|
|
103
104
|
const builderRegex = /builder\s*:\s*\(([^)]*)\)\s*=>\s*([^,\n;]+)/;
|
|
104
105
|
if (builderRegex.test(modified)) {
|
|
@@ -108,8 +109,8 @@ export const FlutterUtil = {
|
|
|
108
109
|
} else {
|
|
109
110
|
// Sinon insérer builder: (context, child) => SamreOverlay(...)
|
|
110
111
|
modified = modified.replace(
|
|
111
|
-
|
|
112
|
-
'
|
|
112
|
+
appRegex,
|
|
113
|
+
'$1\n builder: (context, child) => SamreOverlay(child: child ?? const SizedBox()),'
|
|
113
114
|
);
|
|
114
115
|
}
|
|
115
116
|
fs.writeFileSync(mainPath, modified, 'utf-8');
|