@universal-pwa/core 0.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/LICENSE +22 -0
- package/README.md +151 -0
- package/dist/index.cjs +1368 -0
- package/dist/index.d.cts +348 -0
- package/dist/index.d.ts +348 -0
- package/dist/index.js +1301 -0
- package/package.json +67 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ServiceWorkerTemplateType } from '@universal-pwa/templates';
|
|
3
|
+
import { Document, Element } from 'domhandler';
|
|
4
|
+
|
|
5
|
+
type Framework = 'wordpress' | 'symfony' | 'laravel' | 'react' | 'vue' | 'angular' | 'nextjs' | 'nuxt' | 'static';
|
|
6
|
+
interface FrameworkDetectionResult {
|
|
7
|
+
framework: Framework | null;
|
|
8
|
+
confidence: 'high' | 'medium' | 'low';
|
|
9
|
+
indicators: string[];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Détecte le framework utilisé dans un projet
|
|
13
|
+
*/
|
|
14
|
+
declare function detectFramework(projectPath: string): FrameworkDetectionResult;
|
|
15
|
+
|
|
16
|
+
interface AssetDetectionResult {
|
|
17
|
+
javascript: string[];
|
|
18
|
+
css: string[];
|
|
19
|
+
images: string[];
|
|
20
|
+
fonts: string[];
|
|
21
|
+
apiRoutes: string[];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Détecte tous les assets dans un projet
|
|
25
|
+
*/
|
|
26
|
+
declare function detectAssets(projectPath: string): Promise<AssetDetectionResult>;
|
|
27
|
+
|
|
28
|
+
type Architecture = 'spa' | 'ssr' | 'static';
|
|
29
|
+
type BuildTool = 'vite' | 'webpack' | 'rollup' | 'esbuild' | 'parcel' | 'turbopack' | 'unknown';
|
|
30
|
+
interface ArchitectureDetectionResult {
|
|
31
|
+
architecture: Architecture;
|
|
32
|
+
buildTool: BuildTool | null;
|
|
33
|
+
confidence: 'high' | 'medium' | 'low';
|
|
34
|
+
indicators: string[];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Détecte l'architecture d'un projet (SPA, SSR, statique)
|
|
38
|
+
*/
|
|
39
|
+
declare function detectArchitecture(projectPath: string): Promise<ArchitectureDetectionResult>;
|
|
40
|
+
|
|
41
|
+
interface ScannerResult {
|
|
42
|
+
framework: FrameworkDetectionResult;
|
|
43
|
+
assets: AssetDetectionResult;
|
|
44
|
+
architecture: ArchitectureDetectionResult;
|
|
45
|
+
timestamp: string;
|
|
46
|
+
projectPath: string;
|
|
47
|
+
}
|
|
48
|
+
interface ScannerOptions {
|
|
49
|
+
projectPath: string;
|
|
50
|
+
includeAssets?: boolean;
|
|
51
|
+
includeArchitecture?: boolean;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Orchestrateur principal du scanner
|
|
55
|
+
* Combine les résultats de détection framework, assets et architecture
|
|
56
|
+
*/
|
|
57
|
+
declare function scanProject(options: ScannerOptions): Promise<ScannerResult>;
|
|
58
|
+
/**
|
|
59
|
+
* Génère un rapport JSON du scan
|
|
60
|
+
*/
|
|
61
|
+
declare function generateReport(result: ScannerResult): string;
|
|
62
|
+
/**
|
|
63
|
+
* Valide qu'un chemin de projet existe
|
|
64
|
+
*/
|
|
65
|
+
declare function validateProjectPath(projectPath: string): boolean;
|
|
66
|
+
|
|
67
|
+
declare const ManifestIconSchema: z.ZodObject<{
|
|
68
|
+
src: z.ZodString;
|
|
69
|
+
sizes: z.ZodString;
|
|
70
|
+
type: z.ZodOptional<z.ZodString>;
|
|
71
|
+
purpose: z.ZodOptional<z.ZodString>;
|
|
72
|
+
}, z.core.$strip>;
|
|
73
|
+
declare const ManifestSplashScreenSchema: z.ZodObject<{
|
|
74
|
+
src: z.ZodString;
|
|
75
|
+
sizes: z.ZodString;
|
|
76
|
+
type: z.ZodOptional<z.ZodString>;
|
|
77
|
+
}, z.core.$strip>;
|
|
78
|
+
declare const ManifestSchema: z.ZodObject<{
|
|
79
|
+
name: z.ZodString;
|
|
80
|
+
short_name: z.ZodString;
|
|
81
|
+
description: z.ZodOptional<z.ZodString>;
|
|
82
|
+
start_url: z.ZodDefault<z.ZodString>;
|
|
83
|
+
scope: z.ZodDefault<z.ZodString>;
|
|
84
|
+
display: z.ZodDefault<z.ZodEnum<{
|
|
85
|
+
standalone: "standalone";
|
|
86
|
+
fullscreen: "fullscreen";
|
|
87
|
+
"minimal-ui": "minimal-ui";
|
|
88
|
+
browser: "browser";
|
|
89
|
+
}>>;
|
|
90
|
+
orientation: z.ZodOptional<z.ZodEnum<{
|
|
91
|
+
any: "any";
|
|
92
|
+
portrait: "portrait";
|
|
93
|
+
landscape: "landscape";
|
|
94
|
+
}>>;
|
|
95
|
+
theme_color: z.ZodOptional<z.ZodString>;
|
|
96
|
+
background_color: z.ZodOptional<z.ZodString>;
|
|
97
|
+
icons: z.ZodArray<z.ZodObject<{
|
|
98
|
+
src: z.ZodString;
|
|
99
|
+
sizes: z.ZodString;
|
|
100
|
+
type: z.ZodOptional<z.ZodString>;
|
|
101
|
+
purpose: z.ZodOptional<z.ZodString>;
|
|
102
|
+
}, z.core.$strip>>;
|
|
103
|
+
splash_screens: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
104
|
+
src: z.ZodString;
|
|
105
|
+
sizes: z.ZodString;
|
|
106
|
+
type: z.ZodOptional<z.ZodString>;
|
|
107
|
+
}, z.core.$strip>>>;
|
|
108
|
+
categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
109
|
+
lang: z.ZodOptional<z.ZodString>;
|
|
110
|
+
dir: z.ZodOptional<z.ZodEnum<{
|
|
111
|
+
ltr: "ltr";
|
|
112
|
+
rtl: "rtl";
|
|
113
|
+
auto: "auto";
|
|
114
|
+
}>>;
|
|
115
|
+
prefer_related_applications: z.ZodOptional<z.ZodBoolean>;
|
|
116
|
+
related_applications: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
117
|
+
}, z.core.$strip>;
|
|
118
|
+
type Manifest = z.infer<typeof ManifestSchema>;
|
|
119
|
+
type ManifestIcon = z.infer<typeof ManifestIconSchema>;
|
|
120
|
+
type ManifestSplashScreen = z.infer<typeof ManifestSplashScreenSchema>;
|
|
121
|
+
interface ManifestGeneratorOptions {
|
|
122
|
+
name: string;
|
|
123
|
+
shortName: string;
|
|
124
|
+
description?: string;
|
|
125
|
+
startUrl?: string;
|
|
126
|
+
scope?: string;
|
|
127
|
+
display?: 'standalone' | 'fullscreen' | 'minimal-ui' | 'browser';
|
|
128
|
+
orientation?: 'any' | 'portrait' | 'landscape';
|
|
129
|
+
themeColor?: string;
|
|
130
|
+
backgroundColor?: string;
|
|
131
|
+
icons: ManifestIcon[];
|
|
132
|
+
splashScreens?: ManifestSplashScreen[];
|
|
133
|
+
categories?: string[];
|
|
134
|
+
lang?: string;
|
|
135
|
+
dir?: 'ltr' | 'rtl' | 'auto';
|
|
136
|
+
preferRelatedApplications?: boolean;
|
|
137
|
+
relatedApplications?: unknown[];
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Génère un manifest.json pour PWA
|
|
141
|
+
*/
|
|
142
|
+
declare function generateManifest(options: ManifestGeneratorOptions): Manifest;
|
|
143
|
+
/**
|
|
144
|
+
* Écrit le manifest.json dans le répertoire de sortie
|
|
145
|
+
*/
|
|
146
|
+
declare function writeManifest(manifest: Manifest, outputDir: string): string;
|
|
147
|
+
/**
|
|
148
|
+
* Génère et écrit le manifest.json
|
|
149
|
+
*/
|
|
150
|
+
declare function generateAndWriteManifest(options: ManifestGeneratorOptions, outputDir: string): string;
|
|
151
|
+
|
|
152
|
+
interface IconSize {
|
|
153
|
+
width: number;
|
|
154
|
+
height: number;
|
|
155
|
+
name: string;
|
|
156
|
+
}
|
|
157
|
+
interface SplashScreenSize {
|
|
158
|
+
width: number;
|
|
159
|
+
height: number;
|
|
160
|
+
name: string;
|
|
161
|
+
}
|
|
162
|
+
declare const STANDARD_ICON_SIZES: IconSize[];
|
|
163
|
+
declare const STANDARD_SPLASH_SIZES: SplashScreenSize[];
|
|
164
|
+
interface IconGeneratorOptions {
|
|
165
|
+
sourceImage: string;
|
|
166
|
+
outputDir: string;
|
|
167
|
+
iconSizes?: IconSize[];
|
|
168
|
+
splashSizes?: SplashScreenSize[];
|
|
169
|
+
format?: 'png' | 'webp';
|
|
170
|
+
quality?: number;
|
|
171
|
+
}
|
|
172
|
+
interface IconGenerationResult {
|
|
173
|
+
icons: ManifestIcon[];
|
|
174
|
+
splashScreens: ManifestSplashScreen[];
|
|
175
|
+
generatedFiles: string[];
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Génère toutes les icônes PWA à partir d'une image source
|
|
179
|
+
*/
|
|
180
|
+
declare function generateIcons(options: IconGeneratorOptions): Promise<IconGenerationResult>;
|
|
181
|
+
/**
|
|
182
|
+
* Génère uniquement les icônes (sans splash screens)
|
|
183
|
+
*/
|
|
184
|
+
declare function generateIconsOnly(options: IconGeneratorOptions): Promise<{
|
|
185
|
+
icons: ManifestIcon[];
|
|
186
|
+
generatedFiles: string[];
|
|
187
|
+
}>;
|
|
188
|
+
/**
|
|
189
|
+
* Génère uniquement les splash screens (sans icônes)
|
|
190
|
+
*/
|
|
191
|
+
declare function generateSplashScreensOnly(options: IconGeneratorOptions): Promise<{
|
|
192
|
+
splashScreens: ManifestSplashScreen[];
|
|
193
|
+
generatedFiles: string[];
|
|
194
|
+
}>;
|
|
195
|
+
/**
|
|
196
|
+
* Génère une favicon.ico à partir de l'image source
|
|
197
|
+
*/
|
|
198
|
+
declare function generateFavicon(sourceImage: string, outputDir: string): Promise<string>;
|
|
199
|
+
/**
|
|
200
|
+
* Génère un apple-touch-icon (180x180)
|
|
201
|
+
*/
|
|
202
|
+
declare function generateAppleTouchIcon(sourceImage: string, outputDir: string): Promise<string>;
|
|
203
|
+
|
|
204
|
+
interface ServiceWorkerGeneratorOptions {
|
|
205
|
+
projectPath: string;
|
|
206
|
+
outputDir: string;
|
|
207
|
+
architecture: Architecture;
|
|
208
|
+
framework?: string | null;
|
|
209
|
+
templateType?: ServiceWorkerTemplateType;
|
|
210
|
+
globDirectory?: string;
|
|
211
|
+
globPatterns?: string[];
|
|
212
|
+
swDest?: string;
|
|
213
|
+
swSrc?: string;
|
|
214
|
+
skipWaiting?: boolean;
|
|
215
|
+
clientsClaim?: boolean;
|
|
216
|
+
offlinePage?: string;
|
|
217
|
+
runtimeCaching?: Array<{
|
|
218
|
+
urlPattern: RegExp | string;
|
|
219
|
+
handler: 'NetworkFirst' | 'CacheFirst' | 'StaleWhileRevalidate' | 'NetworkOnly' | 'CacheOnly';
|
|
220
|
+
options?: {
|
|
221
|
+
cacheName?: string;
|
|
222
|
+
expiration?: {
|
|
223
|
+
maxEntries?: number;
|
|
224
|
+
maxAgeSeconds?: number;
|
|
225
|
+
};
|
|
226
|
+
};
|
|
227
|
+
}>;
|
|
228
|
+
}
|
|
229
|
+
interface ServiceWorkerGenerationResult {
|
|
230
|
+
swPath: string;
|
|
231
|
+
count: number;
|
|
232
|
+
size: number;
|
|
233
|
+
warnings: string[];
|
|
234
|
+
filePaths: string[];
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Génère un service worker avec Workbox
|
|
238
|
+
*/
|
|
239
|
+
declare function generateServiceWorker(options: ServiceWorkerGeneratorOptions): Promise<ServiceWorkerGenerationResult>;
|
|
240
|
+
/**
|
|
241
|
+
* Génère un service worker simple sans template (utilise generateSW)
|
|
242
|
+
*/
|
|
243
|
+
declare function generateSimpleServiceWorker(options: Omit<ServiceWorkerGeneratorOptions, 'templateType' | 'swSrc'>): Promise<ServiceWorkerGenerationResult>;
|
|
244
|
+
/**
|
|
245
|
+
* Génère et écrit le service worker avec template
|
|
246
|
+
*/
|
|
247
|
+
declare function generateAndWriteServiceWorker(options: ServiceWorkerGeneratorOptions): Promise<ServiceWorkerGenerationResult>;
|
|
248
|
+
|
|
249
|
+
interface HttpsCheckResult {
|
|
250
|
+
isSecure: boolean;
|
|
251
|
+
isLocalhost: boolean;
|
|
252
|
+
isProduction: boolean;
|
|
253
|
+
protocol: 'https' | 'http' | 'unknown';
|
|
254
|
+
hostname: string | null;
|
|
255
|
+
warning?: string;
|
|
256
|
+
recommendation?: string;
|
|
257
|
+
}
|
|
258
|
+
interface HttpsCheckerOptions {
|
|
259
|
+
url?: string;
|
|
260
|
+
projectPath?: string;
|
|
261
|
+
allowHttpLocalhost?: boolean;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Vérifie si une URL est en HTTPS ou localhost
|
|
265
|
+
*/
|
|
266
|
+
declare function checkHttps(url: string, allowHttpLocalhost?: boolean): HttpsCheckResult;
|
|
267
|
+
/**
|
|
268
|
+
* Détecte l'URL du projet à partir de fichiers de configuration
|
|
269
|
+
*/
|
|
270
|
+
declare function detectProjectUrl(projectPath: string): string | null;
|
|
271
|
+
/**
|
|
272
|
+
* Vérifie HTTPS pour un projet
|
|
273
|
+
*/
|
|
274
|
+
declare function checkProjectHttps(options?: HttpsCheckerOptions): HttpsCheckResult;
|
|
275
|
+
|
|
276
|
+
interface ParsedHTML {
|
|
277
|
+
document: Document;
|
|
278
|
+
head: Element | null;
|
|
279
|
+
body: Element | null;
|
|
280
|
+
html: Element | null;
|
|
281
|
+
originalContent: string;
|
|
282
|
+
}
|
|
283
|
+
interface HTMLParserOptions {
|
|
284
|
+
decodeEntities?: boolean;
|
|
285
|
+
lowerCaseAttributeNames?: boolean;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Parse un fichier HTML et retourne la structure du document
|
|
289
|
+
*/
|
|
290
|
+
declare function parseHTMLFile(filePath: string, options?: HTMLParserOptions): ParsedHTML;
|
|
291
|
+
/**
|
|
292
|
+
* Parse une chaîne HTML et retourne la structure du document
|
|
293
|
+
*/
|
|
294
|
+
declare function parseHTML(htmlContent: string, options?: HTMLParserOptions): ParsedHTML;
|
|
295
|
+
/**
|
|
296
|
+
* Trouve un élément dans le document par tag name
|
|
297
|
+
*/
|
|
298
|
+
declare function findElement(parsed: ParsedHTML, tagName: string, attribute?: {
|
|
299
|
+
name: string;
|
|
300
|
+
value: string;
|
|
301
|
+
}): Element | null;
|
|
302
|
+
/**
|
|
303
|
+
* Trouve tous les éléments correspondant à un tag name
|
|
304
|
+
*/
|
|
305
|
+
declare function findAllElements(parsed: ParsedHTML, tagName: string, attribute?: {
|
|
306
|
+
name: string;
|
|
307
|
+
value?: string;
|
|
308
|
+
}): Element[];
|
|
309
|
+
/**
|
|
310
|
+
* Vérifie si un élément existe déjà dans le document
|
|
311
|
+
*/
|
|
312
|
+
declare function elementExists(parsed: ParsedHTML, tagName: string, attribute: {
|
|
313
|
+
name: string;
|
|
314
|
+
value: string;
|
|
315
|
+
}): boolean;
|
|
316
|
+
/**
|
|
317
|
+
* Convertit un document parsé en HTML string
|
|
318
|
+
*/
|
|
319
|
+
declare function serializeHTML(parsed: ParsedHTML): string;
|
|
320
|
+
|
|
321
|
+
interface MetaInjectorOptions {
|
|
322
|
+
manifestPath?: string;
|
|
323
|
+
themeColor?: string;
|
|
324
|
+
backgroundColor?: string;
|
|
325
|
+
appleTouchIcon?: string;
|
|
326
|
+
appleMobileWebAppCapable?: boolean;
|
|
327
|
+
appleMobileWebAppStatusBarStyle?: 'default' | 'black' | 'black-translucent';
|
|
328
|
+
appleMobileWebAppTitle?: string;
|
|
329
|
+
serviceWorkerPath?: string;
|
|
330
|
+
}
|
|
331
|
+
interface InjectionResult {
|
|
332
|
+
injected: string[];
|
|
333
|
+
skipped: string[];
|
|
334
|
+
warnings: string[];
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Injecte les meta-tags PWA dans le HTML
|
|
338
|
+
*/
|
|
339
|
+
declare function injectMetaTags(htmlContent: string, options?: MetaInjectorOptions): {
|
|
340
|
+
html: string;
|
|
341
|
+
result: InjectionResult;
|
|
342
|
+
};
|
|
343
|
+
/**
|
|
344
|
+
* Injecte les meta-tags dans un fichier HTML
|
|
345
|
+
*/
|
|
346
|
+
declare function injectMetaTagsInFile(filePath: string, options?: MetaInjectorOptions): InjectionResult;
|
|
347
|
+
|
|
348
|
+
export { type Architecture, type ArchitectureDetectionResult, type AssetDetectionResult, type BuildTool, type Framework, type FrameworkDetectionResult, type HTMLParserOptions, type HttpsCheckResult, type HttpsCheckerOptions, type IconGenerationResult, type IconGeneratorOptions, type IconSize, type InjectionResult, type Manifest, type ManifestGeneratorOptions, type ManifestIcon, ManifestSchema, type ManifestSplashScreen, type MetaInjectorOptions, type ParsedHTML, STANDARD_ICON_SIZES, STANDARD_SPLASH_SIZES, type ScannerOptions, type ScannerResult, type ServiceWorkerGenerationResult, type ServiceWorkerGeneratorOptions, type SplashScreenSize, checkHttps, checkProjectHttps, detectArchitecture, detectAssets, detectFramework, detectProjectUrl, elementExists, findAllElements, findElement, generateAndWriteManifest, generateAndWriteServiceWorker, generateAppleTouchIcon, generateFavicon, generateIcons, generateIconsOnly, generateManifest, generateReport, generateServiceWorker, generateSimpleServiceWorker, generateSplashScreensOnly, injectMetaTags, injectMetaTagsInFile, parseHTML, parseHTMLFile, scanProject, serializeHTML, validateProjectPath, writeManifest };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ServiceWorkerTemplateType } from '@universal-pwa/templates';
|
|
3
|
+
import { Document, Element } from 'domhandler';
|
|
4
|
+
|
|
5
|
+
type Framework = 'wordpress' | 'symfony' | 'laravel' | 'react' | 'vue' | 'angular' | 'nextjs' | 'nuxt' | 'static';
|
|
6
|
+
interface FrameworkDetectionResult {
|
|
7
|
+
framework: Framework | null;
|
|
8
|
+
confidence: 'high' | 'medium' | 'low';
|
|
9
|
+
indicators: string[];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Détecte le framework utilisé dans un projet
|
|
13
|
+
*/
|
|
14
|
+
declare function detectFramework(projectPath: string): FrameworkDetectionResult;
|
|
15
|
+
|
|
16
|
+
interface AssetDetectionResult {
|
|
17
|
+
javascript: string[];
|
|
18
|
+
css: string[];
|
|
19
|
+
images: string[];
|
|
20
|
+
fonts: string[];
|
|
21
|
+
apiRoutes: string[];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Détecte tous les assets dans un projet
|
|
25
|
+
*/
|
|
26
|
+
declare function detectAssets(projectPath: string): Promise<AssetDetectionResult>;
|
|
27
|
+
|
|
28
|
+
type Architecture = 'spa' | 'ssr' | 'static';
|
|
29
|
+
type BuildTool = 'vite' | 'webpack' | 'rollup' | 'esbuild' | 'parcel' | 'turbopack' | 'unknown';
|
|
30
|
+
interface ArchitectureDetectionResult {
|
|
31
|
+
architecture: Architecture;
|
|
32
|
+
buildTool: BuildTool | null;
|
|
33
|
+
confidence: 'high' | 'medium' | 'low';
|
|
34
|
+
indicators: string[];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Détecte l'architecture d'un projet (SPA, SSR, statique)
|
|
38
|
+
*/
|
|
39
|
+
declare function detectArchitecture(projectPath: string): Promise<ArchitectureDetectionResult>;
|
|
40
|
+
|
|
41
|
+
interface ScannerResult {
|
|
42
|
+
framework: FrameworkDetectionResult;
|
|
43
|
+
assets: AssetDetectionResult;
|
|
44
|
+
architecture: ArchitectureDetectionResult;
|
|
45
|
+
timestamp: string;
|
|
46
|
+
projectPath: string;
|
|
47
|
+
}
|
|
48
|
+
interface ScannerOptions {
|
|
49
|
+
projectPath: string;
|
|
50
|
+
includeAssets?: boolean;
|
|
51
|
+
includeArchitecture?: boolean;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Orchestrateur principal du scanner
|
|
55
|
+
* Combine les résultats de détection framework, assets et architecture
|
|
56
|
+
*/
|
|
57
|
+
declare function scanProject(options: ScannerOptions): Promise<ScannerResult>;
|
|
58
|
+
/**
|
|
59
|
+
* Génère un rapport JSON du scan
|
|
60
|
+
*/
|
|
61
|
+
declare function generateReport(result: ScannerResult): string;
|
|
62
|
+
/**
|
|
63
|
+
* Valide qu'un chemin de projet existe
|
|
64
|
+
*/
|
|
65
|
+
declare function validateProjectPath(projectPath: string): boolean;
|
|
66
|
+
|
|
67
|
+
declare const ManifestIconSchema: z.ZodObject<{
|
|
68
|
+
src: z.ZodString;
|
|
69
|
+
sizes: z.ZodString;
|
|
70
|
+
type: z.ZodOptional<z.ZodString>;
|
|
71
|
+
purpose: z.ZodOptional<z.ZodString>;
|
|
72
|
+
}, z.core.$strip>;
|
|
73
|
+
declare const ManifestSplashScreenSchema: z.ZodObject<{
|
|
74
|
+
src: z.ZodString;
|
|
75
|
+
sizes: z.ZodString;
|
|
76
|
+
type: z.ZodOptional<z.ZodString>;
|
|
77
|
+
}, z.core.$strip>;
|
|
78
|
+
declare const ManifestSchema: z.ZodObject<{
|
|
79
|
+
name: z.ZodString;
|
|
80
|
+
short_name: z.ZodString;
|
|
81
|
+
description: z.ZodOptional<z.ZodString>;
|
|
82
|
+
start_url: z.ZodDefault<z.ZodString>;
|
|
83
|
+
scope: z.ZodDefault<z.ZodString>;
|
|
84
|
+
display: z.ZodDefault<z.ZodEnum<{
|
|
85
|
+
standalone: "standalone";
|
|
86
|
+
fullscreen: "fullscreen";
|
|
87
|
+
"minimal-ui": "minimal-ui";
|
|
88
|
+
browser: "browser";
|
|
89
|
+
}>>;
|
|
90
|
+
orientation: z.ZodOptional<z.ZodEnum<{
|
|
91
|
+
any: "any";
|
|
92
|
+
portrait: "portrait";
|
|
93
|
+
landscape: "landscape";
|
|
94
|
+
}>>;
|
|
95
|
+
theme_color: z.ZodOptional<z.ZodString>;
|
|
96
|
+
background_color: z.ZodOptional<z.ZodString>;
|
|
97
|
+
icons: z.ZodArray<z.ZodObject<{
|
|
98
|
+
src: z.ZodString;
|
|
99
|
+
sizes: z.ZodString;
|
|
100
|
+
type: z.ZodOptional<z.ZodString>;
|
|
101
|
+
purpose: z.ZodOptional<z.ZodString>;
|
|
102
|
+
}, z.core.$strip>>;
|
|
103
|
+
splash_screens: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
104
|
+
src: z.ZodString;
|
|
105
|
+
sizes: z.ZodString;
|
|
106
|
+
type: z.ZodOptional<z.ZodString>;
|
|
107
|
+
}, z.core.$strip>>>;
|
|
108
|
+
categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
109
|
+
lang: z.ZodOptional<z.ZodString>;
|
|
110
|
+
dir: z.ZodOptional<z.ZodEnum<{
|
|
111
|
+
ltr: "ltr";
|
|
112
|
+
rtl: "rtl";
|
|
113
|
+
auto: "auto";
|
|
114
|
+
}>>;
|
|
115
|
+
prefer_related_applications: z.ZodOptional<z.ZodBoolean>;
|
|
116
|
+
related_applications: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
117
|
+
}, z.core.$strip>;
|
|
118
|
+
type Manifest = z.infer<typeof ManifestSchema>;
|
|
119
|
+
type ManifestIcon = z.infer<typeof ManifestIconSchema>;
|
|
120
|
+
type ManifestSplashScreen = z.infer<typeof ManifestSplashScreenSchema>;
|
|
121
|
+
interface ManifestGeneratorOptions {
|
|
122
|
+
name: string;
|
|
123
|
+
shortName: string;
|
|
124
|
+
description?: string;
|
|
125
|
+
startUrl?: string;
|
|
126
|
+
scope?: string;
|
|
127
|
+
display?: 'standalone' | 'fullscreen' | 'minimal-ui' | 'browser';
|
|
128
|
+
orientation?: 'any' | 'portrait' | 'landscape';
|
|
129
|
+
themeColor?: string;
|
|
130
|
+
backgroundColor?: string;
|
|
131
|
+
icons: ManifestIcon[];
|
|
132
|
+
splashScreens?: ManifestSplashScreen[];
|
|
133
|
+
categories?: string[];
|
|
134
|
+
lang?: string;
|
|
135
|
+
dir?: 'ltr' | 'rtl' | 'auto';
|
|
136
|
+
preferRelatedApplications?: boolean;
|
|
137
|
+
relatedApplications?: unknown[];
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Génère un manifest.json pour PWA
|
|
141
|
+
*/
|
|
142
|
+
declare function generateManifest(options: ManifestGeneratorOptions): Manifest;
|
|
143
|
+
/**
|
|
144
|
+
* Écrit le manifest.json dans le répertoire de sortie
|
|
145
|
+
*/
|
|
146
|
+
declare function writeManifest(manifest: Manifest, outputDir: string): string;
|
|
147
|
+
/**
|
|
148
|
+
* Génère et écrit le manifest.json
|
|
149
|
+
*/
|
|
150
|
+
declare function generateAndWriteManifest(options: ManifestGeneratorOptions, outputDir: string): string;
|
|
151
|
+
|
|
152
|
+
interface IconSize {
|
|
153
|
+
width: number;
|
|
154
|
+
height: number;
|
|
155
|
+
name: string;
|
|
156
|
+
}
|
|
157
|
+
interface SplashScreenSize {
|
|
158
|
+
width: number;
|
|
159
|
+
height: number;
|
|
160
|
+
name: string;
|
|
161
|
+
}
|
|
162
|
+
declare const STANDARD_ICON_SIZES: IconSize[];
|
|
163
|
+
declare const STANDARD_SPLASH_SIZES: SplashScreenSize[];
|
|
164
|
+
interface IconGeneratorOptions {
|
|
165
|
+
sourceImage: string;
|
|
166
|
+
outputDir: string;
|
|
167
|
+
iconSizes?: IconSize[];
|
|
168
|
+
splashSizes?: SplashScreenSize[];
|
|
169
|
+
format?: 'png' | 'webp';
|
|
170
|
+
quality?: number;
|
|
171
|
+
}
|
|
172
|
+
interface IconGenerationResult {
|
|
173
|
+
icons: ManifestIcon[];
|
|
174
|
+
splashScreens: ManifestSplashScreen[];
|
|
175
|
+
generatedFiles: string[];
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Génère toutes les icônes PWA à partir d'une image source
|
|
179
|
+
*/
|
|
180
|
+
declare function generateIcons(options: IconGeneratorOptions): Promise<IconGenerationResult>;
|
|
181
|
+
/**
|
|
182
|
+
* Génère uniquement les icônes (sans splash screens)
|
|
183
|
+
*/
|
|
184
|
+
declare function generateIconsOnly(options: IconGeneratorOptions): Promise<{
|
|
185
|
+
icons: ManifestIcon[];
|
|
186
|
+
generatedFiles: string[];
|
|
187
|
+
}>;
|
|
188
|
+
/**
|
|
189
|
+
* Génère uniquement les splash screens (sans icônes)
|
|
190
|
+
*/
|
|
191
|
+
declare function generateSplashScreensOnly(options: IconGeneratorOptions): Promise<{
|
|
192
|
+
splashScreens: ManifestSplashScreen[];
|
|
193
|
+
generatedFiles: string[];
|
|
194
|
+
}>;
|
|
195
|
+
/**
|
|
196
|
+
* Génère une favicon.ico à partir de l'image source
|
|
197
|
+
*/
|
|
198
|
+
declare function generateFavicon(sourceImage: string, outputDir: string): Promise<string>;
|
|
199
|
+
/**
|
|
200
|
+
* Génère un apple-touch-icon (180x180)
|
|
201
|
+
*/
|
|
202
|
+
declare function generateAppleTouchIcon(sourceImage: string, outputDir: string): Promise<string>;
|
|
203
|
+
|
|
204
|
+
interface ServiceWorkerGeneratorOptions {
|
|
205
|
+
projectPath: string;
|
|
206
|
+
outputDir: string;
|
|
207
|
+
architecture: Architecture;
|
|
208
|
+
framework?: string | null;
|
|
209
|
+
templateType?: ServiceWorkerTemplateType;
|
|
210
|
+
globDirectory?: string;
|
|
211
|
+
globPatterns?: string[];
|
|
212
|
+
swDest?: string;
|
|
213
|
+
swSrc?: string;
|
|
214
|
+
skipWaiting?: boolean;
|
|
215
|
+
clientsClaim?: boolean;
|
|
216
|
+
offlinePage?: string;
|
|
217
|
+
runtimeCaching?: Array<{
|
|
218
|
+
urlPattern: RegExp | string;
|
|
219
|
+
handler: 'NetworkFirst' | 'CacheFirst' | 'StaleWhileRevalidate' | 'NetworkOnly' | 'CacheOnly';
|
|
220
|
+
options?: {
|
|
221
|
+
cacheName?: string;
|
|
222
|
+
expiration?: {
|
|
223
|
+
maxEntries?: number;
|
|
224
|
+
maxAgeSeconds?: number;
|
|
225
|
+
};
|
|
226
|
+
};
|
|
227
|
+
}>;
|
|
228
|
+
}
|
|
229
|
+
interface ServiceWorkerGenerationResult {
|
|
230
|
+
swPath: string;
|
|
231
|
+
count: number;
|
|
232
|
+
size: number;
|
|
233
|
+
warnings: string[];
|
|
234
|
+
filePaths: string[];
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Génère un service worker avec Workbox
|
|
238
|
+
*/
|
|
239
|
+
declare function generateServiceWorker(options: ServiceWorkerGeneratorOptions): Promise<ServiceWorkerGenerationResult>;
|
|
240
|
+
/**
|
|
241
|
+
* Génère un service worker simple sans template (utilise generateSW)
|
|
242
|
+
*/
|
|
243
|
+
declare function generateSimpleServiceWorker(options: Omit<ServiceWorkerGeneratorOptions, 'templateType' | 'swSrc'>): Promise<ServiceWorkerGenerationResult>;
|
|
244
|
+
/**
|
|
245
|
+
* Génère et écrit le service worker avec template
|
|
246
|
+
*/
|
|
247
|
+
declare function generateAndWriteServiceWorker(options: ServiceWorkerGeneratorOptions): Promise<ServiceWorkerGenerationResult>;
|
|
248
|
+
|
|
249
|
+
interface HttpsCheckResult {
|
|
250
|
+
isSecure: boolean;
|
|
251
|
+
isLocalhost: boolean;
|
|
252
|
+
isProduction: boolean;
|
|
253
|
+
protocol: 'https' | 'http' | 'unknown';
|
|
254
|
+
hostname: string | null;
|
|
255
|
+
warning?: string;
|
|
256
|
+
recommendation?: string;
|
|
257
|
+
}
|
|
258
|
+
interface HttpsCheckerOptions {
|
|
259
|
+
url?: string;
|
|
260
|
+
projectPath?: string;
|
|
261
|
+
allowHttpLocalhost?: boolean;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Vérifie si une URL est en HTTPS ou localhost
|
|
265
|
+
*/
|
|
266
|
+
declare function checkHttps(url: string, allowHttpLocalhost?: boolean): HttpsCheckResult;
|
|
267
|
+
/**
|
|
268
|
+
* Détecte l'URL du projet à partir de fichiers de configuration
|
|
269
|
+
*/
|
|
270
|
+
declare function detectProjectUrl(projectPath: string): string | null;
|
|
271
|
+
/**
|
|
272
|
+
* Vérifie HTTPS pour un projet
|
|
273
|
+
*/
|
|
274
|
+
declare function checkProjectHttps(options?: HttpsCheckerOptions): HttpsCheckResult;
|
|
275
|
+
|
|
276
|
+
interface ParsedHTML {
|
|
277
|
+
document: Document;
|
|
278
|
+
head: Element | null;
|
|
279
|
+
body: Element | null;
|
|
280
|
+
html: Element | null;
|
|
281
|
+
originalContent: string;
|
|
282
|
+
}
|
|
283
|
+
interface HTMLParserOptions {
|
|
284
|
+
decodeEntities?: boolean;
|
|
285
|
+
lowerCaseAttributeNames?: boolean;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Parse un fichier HTML et retourne la structure du document
|
|
289
|
+
*/
|
|
290
|
+
declare function parseHTMLFile(filePath: string, options?: HTMLParserOptions): ParsedHTML;
|
|
291
|
+
/**
|
|
292
|
+
* Parse une chaîne HTML et retourne la structure du document
|
|
293
|
+
*/
|
|
294
|
+
declare function parseHTML(htmlContent: string, options?: HTMLParserOptions): ParsedHTML;
|
|
295
|
+
/**
|
|
296
|
+
* Trouve un élément dans le document par tag name
|
|
297
|
+
*/
|
|
298
|
+
declare function findElement(parsed: ParsedHTML, tagName: string, attribute?: {
|
|
299
|
+
name: string;
|
|
300
|
+
value: string;
|
|
301
|
+
}): Element | null;
|
|
302
|
+
/**
|
|
303
|
+
* Trouve tous les éléments correspondant à un tag name
|
|
304
|
+
*/
|
|
305
|
+
declare function findAllElements(parsed: ParsedHTML, tagName: string, attribute?: {
|
|
306
|
+
name: string;
|
|
307
|
+
value?: string;
|
|
308
|
+
}): Element[];
|
|
309
|
+
/**
|
|
310
|
+
* Vérifie si un élément existe déjà dans le document
|
|
311
|
+
*/
|
|
312
|
+
declare function elementExists(parsed: ParsedHTML, tagName: string, attribute: {
|
|
313
|
+
name: string;
|
|
314
|
+
value: string;
|
|
315
|
+
}): boolean;
|
|
316
|
+
/**
|
|
317
|
+
* Convertit un document parsé en HTML string
|
|
318
|
+
*/
|
|
319
|
+
declare function serializeHTML(parsed: ParsedHTML): string;
|
|
320
|
+
|
|
321
|
+
interface MetaInjectorOptions {
|
|
322
|
+
manifestPath?: string;
|
|
323
|
+
themeColor?: string;
|
|
324
|
+
backgroundColor?: string;
|
|
325
|
+
appleTouchIcon?: string;
|
|
326
|
+
appleMobileWebAppCapable?: boolean;
|
|
327
|
+
appleMobileWebAppStatusBarStyle?: 'default' | 'black' | 'black-translucent';
|
|
328
|
+
appleMobileWebAppTitle?: string;
|
|
329
|
+
serviceWorkerPath?: string;
|
|
330
|
+
}
|
|
331
|
+
interface InjectionResult {
|
|
332
|
+
injected: string[];
|
|
333
|
+
skipped: string[];
|
|
334
|
+
warnings: string[];
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Injecte les meta-tags PWA dans le HTML
|
|
338
|
+
*/
|
|
339
|
+
declare function injectMetaTags(htmlContent: string, options?: MetaInjectorOptions): {
|
|
340
|
+
html: string;
|
|
341
|
+
result: InjectionResult;
|
|
342
|
+
};
|
|
343
|
+
/**
|
|
344
|
+
* Injecte les meta-tags dans un fichier HTML
|
|
345
|
+
*/
|
|
346
|
+
declare function injectMetaTagsInFile(filePath: string, options?: MetaInjectorOptions): InjectionResult;
|
|
347
|
+
|
|
348
|
+
export { type Architecture, type ArchitectureDetectionResult, type AssetDetectionResult, type BuildTool, type Framework, type FrameworkDetectionResult, type HTMLParserOptions, type HttpsCheckResult, type HttpsCheckerOptions, type IconGenerationResult, type IconGeneratorOptions, type IconSize, type InjectionResult, type Manifest, type ManifestGeneratorOptions, type ManifestIcon, ManifestSchema, type ManifestSplashScreen, type MetaInjectorOptions, type ParsedHTML, STANDARD_ICON_SIZES, STANDARD_SPLASH_SIZES, type ScannerOptions, type ScannerResult, type ServiceWorkerGenerationResult, type ServiceWorkerGeneratorOptions, type SplashScreenSize, checkHttps, checkProjectHttps, detectArchitecture, detectAssets, detectFramework, detectProjectUrl, elementExists, findAllElements, findElement, generateAndWriteManifest, generateAndWriteServiceWorker, generateAppleTouchIcon, generateFavicon, generateIcons, generateIconsOnly, generateManifest, generateReport, generateServiceWorker, generateSimpleServiceWorker, generateSplashScreensOnly, injectMetaTags, injectMetaTagsInFile, parseHTML, parseHTMLFile, scanProject, serializeHTML, validateProjectPath, writeManifest };
|