@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 ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 UniversalPWA
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
package/README.md ADDED
@@ -0,0 +1,151 @@
1
+ # @universal-pwa/core
2
+
3
+ Moteur de scan, génération et injection pour UniversalPWA.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @universal-pwa/core
9
+ ```
10
+
11
+ ## Utilisation
12
+
13
+ ### Scanner un projet
14
+
15
+ ```typescript
16
+ import { scanProject } from '@universal-pwa/core'
17
+
18
+ const result = await scanProject({
19
+ projectPath: './my-project',
20
+ includeAssets: true,
21
+ includeArchitecture: true,
22
+ })
23
+
24
+ console.log(result.framework.framework) // 'react', 'wordpress', etc.
25
+ console.log(result.architecture.architecture) // 'spa', 'ssr', 'static'
26
+ ```
27
+
28
+ ### Générer un manifest
29
+
30
+ ```typescript
31
+ import { generateManifest, writeManifest } from '@universal-pwa/core'
32
+
33
+ const manifest = generateManifest({
34
+ name: 'My App',
35
+ shortName: 'MyApp',
36
+ startUrl: '/',
37
+ scope: '/',
38
+ display: 'standalone',
39
+ themeColor: '#2c3e50',
40
+ backgroundColor: '#ffffff',
41
+ icons: [
42
+ {
43
+ src: '/icon-192x192.png',
44
+ sizes: '192x192',
45
+ type: 'image/png',
46
+ },
47
+ ],
48
+ })
49
+
50
+ writeManifest(manifest, './public')
51
+ ```
52
+
53
+ ### Générer des icônes
54
+
55
+ ```typescript
56
+ import { generateIcons } from '@universal-pwa/core'
57
+
58
+ const result = await generateIcons({
59
+ sourceImage: './logo.png',
60
+ outputDir: './public/icons',
61
+ })
62
+
63
+ console.log(result.icons) // Array of ManifestIcon
64
+ console.log(result.splashScreens) // Array of ManifestSplashScreen
65
+ ```
66
+
67
+ ### Générer un service worker
68
+
69
+ ```typescript
70
+ import { generateServiceWorker } from '@universal-pwa/core'
71
+
72
+ const result = await generateServiceWorker({
73
+ projectPath: './my-project',
74
+ outputDir: './public',
75
+ architecture: 'spa',
76
+ framework: 'react',
77
+ globDirectory: './public',
78
+ globPatterns: ['**/*.{html,js,css,png,jpg,svg}'],
79
+ })
80
+
81
+ console.log(result.swPath) // Chemin du service worker généré
82
+ ```
83
+
84
+ ### Injecter des meta-tags
85
+
86
+ ```typescript
87
+ import { injectMetaTagsInFile } from '@universal-pwa/core'
88
+
89
+ const result = injectMetaTagsInFile('./index.html', {
90
+ manifestPath: '/manifest.json',
91
+ themeColor: '#2c3e50',
92
+ appleTouchIcon: '/apple-touch-icon.png',
93
+ serviceWorkerPath: '/sw.js',
94
+ })
95
+
96
+ console.log(result.injected) // Tags injectés
97
+ console.log(result.skipped) // Tags déjà présents
98
+ ```
99
+
100
+ ## API
101
+
102
+ ### Scanner
103
+
104
+ - `scanProject(options)` : Scanne un projet et retourne un rapport complet
105
+ - `detectFramework(projectPath)` : Détecte le framework utilisé
106
+ - `detectAssets(projectPath)` : Détecte les assets (JS, CSS, images, fonts)
107
+ - `detectArchitecture(projectPath)` : Détecte l'architecture (SPA, SSR, static)
108
+
109
+ ### Générateur
110
+
111
+ - `generateManifest(options)` : Génère un manifest.json
112
+ - `writeManifest(manifest, outputDir)` : Écrit le manifest dans un fichier
113
+ - `generateIcons(options)` : Génère les icônes PWA à partir d'une image source
114
+ - `generateServiceWorker(options)` : Génère un service worker avec Workbox
115
+ - `checkProjectHttps(options)` : Vérifie le statut HTTPS d'un projet
116
+
117
+ ### Injecteur
118
+
119
+ - `parseHTML(htmlContent)` : Parse du HTML
120
+ - `parseHTMLFile(filePath)` : Parse un fichier HTML
121
+ - `injectMetaTags(htmlContent, options)` : Injecte des meta-tags PWA
122
+ - `injectMetaTagsInFile(filePath, options)` : Injecte des meta-tags dans un fichier
123
+
124
+ ## Types
125
+
126
+ ```typescript
127
+ import type {
128
+ Framework,
129
+ Architecture,
130
+ ScannerResult,
131
+ Manifest,
132
+ ManifestIcon,
133
+ ServiceWorkerGenerationResult,
134
+ } from '@universal-pwa/core'
135
+ ```
136
+
137
+ ## Développement
138
+
139
+ ```bash
140
+ # Installer les dépendances
141
+ pnpm install
142
+
143
+ # Build
144
+ pnpm build
145
+
146
+ # Tests
147
+ pnpm test
148
+
149
+ # Lint
150
+ pnpm lint
151
+ ```