@julien-lin/universal-pwa-core 1.2.2 → 1.2.3
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/README.fr.md +183 -0
- package/README.md +61 -28
- package/package.json +6 -4
package/README.fr.md
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# @julien-lin/universal-pwa-core
|
|
2
|
+
|
|
3
|
+
[](https://github.com/sponsors/julien-lin)
|
|
4
|
+
[](https://www.npmjs.com/package/@julien-lin/universal-pwa-core)
|
|
5
|
+
|
|
6
|
+
Moteur de scan, génération et injection pour UniversalPWA.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @julien-lin/universal-pwa-core
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Ou avec pnpm :
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pnpm add @julien-lin/universal-pwa-core
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Utilisation
|
|
21
|
+
|
|
22
|
+
### Scanner un projet
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { scanProject } from '@julien-lin/universal-pwa-core'
|
|
26
|
+
|
|
27
|
+
const result = await scanProject({
|
|
28
|
+
projectPath: './my-project',
|
|
29
|
+
includeAssets: true,
|
|
30
|
+
includeArchitecture: true,
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
console.log(result.framework.framework) // 'react', 'wordpress', etc.
|
|
34
|
+
console.log(result.architecture.architecture) // 'spa', 'ssr', 'static'
|
|
35
|
+
console.log(result.assets.javascript.length) // Nombre de fichiers JS
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Générer un manifest
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
import { generateManifest, writeManifest } from '@julien-lin/universal-pwa-core'
|
|
42
|
+
|
|
43
|
+
const manifest = generateManifest({
|
|
44
|
+
name: 'My App',
|
|
45
|
+
shortName: 'MyApp',
|
|
46
|
+
startUrl: '/',
|
|
47
|
+
scope: '/',
|
|
48
|
+
display: 'standalone',
|
|
49
|
+
themeColor: '#2c3e50',
|
|
50
|
+
backgroundColor: '#ffffff',
|
|
51
|
+
icons: [
|
|
52
|
+
{
|
|
53
|
+
src: '/icon-192x192.png',
|
|
54
|
+
sizes: '192x192',
|
|
55
|
+
type: 'image/png',
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
writeManifest(manifest, './public')
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Générer des icônes
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
import { generateIcons } from '@julien-lin/universal-pwa-core'
|
|
67
|
+
|
|
68
|
+
const result = await generateIcons({
|
|
69
|
+
sourceImage: './logo.png',
|
|
70
|
+
outputDir: './public/icons',
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
console.log(result.icons) // Tableau de ManifestIcon
|
|
74
|
+
console.log(result.splashScreens) // Tableau de ManifestSplashScreen
|
|
75
|
+
console.log(result.generatedFiles) // Tableau des chemins de fichiers générés
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
La fonction génère automatiquement :
|
|
79
|
+
- Icônes PWA en multiples tailles (72x72 à 512x512)
|
|
80
|
+
- Apple Touch Icon (180x180)
|
|
81
|
+
- Splash screens pour iOS
|
|
82
|
+
|
|
83
|
+
### Générer un service worker
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
import { generateServiceWorker } from '@julien-lin/universal-pwa-core'
|
|
87
|
+
|
|
88
|
+
const result = await generateServiceWorker({
|
|
89
|
+
projectPath: './my-project',
|
|
90
|
+
outputDir: './public',
|
|
91
|
+
architecture: 'spa',
|
|
92
|
+
framework: 'react',
|
|
93
|
+
globDirectory: './public',
|
|
94
|
+
globPatterns: ['**/*.{html,js,css,png,jpg,svg}'],
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
console.log(result.swPath) // Chemin vers le service worker généré
|
|
98
|
+
console.log(result.count) // Nombre de fichiers pré-cachés
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Injecter des meta tags
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
import { injectMetaTagsInFile } from '@julien-lin/universal-pwa-core'
|
|
105
|
+
|
|
106
|
+
const result = injectMetaTagsInFile('./index.html', {
|
|
107
|
+
manifestPath: '/manifest.json',
|
|
108
|
+
themeColor: '#2c3e50',
|
|
109
|
+
backgroundColor: '#ffffff',
|
|
110
|
+
appleTouchIcon: '/apple-touch-icon.png',
|
|
111
|
+
serviceWorkerPath: '/sw.js',
|
|
112
|
+
appleMobileWebAppCapable: true,
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
console.log(result.injected) // Tags injectés
|
|
116
|
+
console.log(result.skipped) // Tags déjà présents
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Référence API
|
|
120
|
+
|
|
121
|
+
### Scanner
|
|
122
|
+
|
|
123
|
+
- `scanProject(options)` : Scanne un projet et retourne un rapport complet
|
|
124
|
+
- `detectFramework(projectPath)` : Détecte le framework utilisé
|
|
125
|
+
- `detectAssets(projectPath)` : Détecte les assets (JS, CSS, images, polices)
|
|
126
|
+
- `detectArchitecture(projectPath)` : Détecte l'architecture (SPA, SSR, static)
|
|
127
|
+
|
|
128
|
+
### Générateur
|
|
129
|
+
|
|
130
|
+
- `generateManifest(options)` : Génère un manifest.json
|
|
131
|
+
- `writeManifest(manifest, outputDir)` : Écrit le manifest dans un fichier
|
|
132
|
+
- `generateAndWriteManifest(options, outputDir)` : Génère et écrit le manifest en une seule fois
|
|
133
|
+
- `generateIcons(options)` : Génère les icônes PWA à partir d'une image source
|
|
134
|
+
- `generateServiceWorker(options)` : Génère un service worker avec Workbox
|
|
135
|
+
- `checkProjectHttps(options)` : Vérifie le statut HTTPS d'un projet
|
|
136
|
+
|
|
137
|
+
### Injecteur
|
|
138
|
+
|
|
139
|
+
- `parseHTML(htmlContent)` : Parse du contenu HTML
|
|
140
|
+
- `parseHTMLFile(filePath)` : Parse un fichier HTML
|
|
141
|
+
- `injectMetaTags(htmlContent, options)` : Injecte des meta-tags PWA
|
|
142
|
+
- `injectMetaTagsInFile(filePath, options)` : Injecte des meta-tags dans un fichier
|
|
143
|
+
|
|
144
|
+
## Types
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
import type {
|
|
148
|
+
Framework,
|
|
149
|
+
Architecture,
|
|
150
|
+
ScannerResult,
|
|
151
|
+
Manifest,
|
|
152
|
+
ManifestIcon,
|
|
153
|
+
ManifestSplashScreen,
|
|
154
|
+
ServiceWorkerGenerationResult,
|
|
155
|
+
} from '@julien-lin/universal-pwa-core'
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## 💝 Sponsoring
|
|
159
|
+
|
|
160
|
+
Si UniversalPWA vous est utile, envisagez de [sponsoriser le projet](https://github.com/sponsors/julien-lin) pour aider à le maintenir et l'améliorer.
|
|
161
|
+
|
|
162
|
+
## Développement
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
# Installer les dépendances
|
|
166
|
+
pnpm install
|
|
167
|
+
|
|
168
|
+
# Build
|
|
169
|
+
pnpm build
|
|
170
|
+
|
|
171
|
+
# Tests
|
|
172
|
+
pnpm test
|
|
173
|
+
|
|
174
|
+
# Lint
|
|
175
|
+
pnpm lint
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Liens
|
|
179
|
+
|
|
180
|
+
- **Page d'accueil** : https://github.com/julien-lin/UniversalPWA
|
|
181
|
+
- **Support** : Pour les problèmes et questions, utilisez [GitHub Discussions](https://github.com/julien-lin/UniversalPWA/discussions)
|
|
182
|
+
- **Sponsor** : https://github.com/sponsors/julien-lin
|
|
183
|
+
|
package/README.md
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
# @julien-lin/universal-pwa-core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/sponsors/julien-lin)
|
|
4
|
+
[](https://www.npmjs.com/package/@julien-lin/universal-pwa-core)
|
|
5
|
+
|
|
6
|
+
Core engine for scanning, generation, and injection for UniversalPWA.
|
|
7
|
+
|
|
8
|
+
**🇫🇷 [Documentation en français](./README.fr.md)**
|
|
4
9
|
|
|
5
10
|
## Installation
|
|
6
11
|
|
|
@@ -8,9 +13,15 @@ Moteur de scan, génération et injection pour UniversalPWA.
|
|
|
8
13
|
npm install @julien-lin/universal-pwa-core
|
|
9
14
|
```
|
|
10
15
|
|
|
11
|
-
|
|
16
|
+
Or with pnpm:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pnpm add @julien-lin/universal-pwa-core
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
12
23
|
|
|
13
|
-
###
|
|
24
|
+
### Scan a Project
|
|
14
25
|
|
|
15
26
|
```typescript
|
|
16
27
|
import { scanProject } from '@julien-lin/universal-pwa-core'
|
|
@@ -23,9 +34,10 @@ const result = await scanProject({
|
|
|
23
34
|
|
|
24
35
|
console.log(result.framework.framework) // 'react', 'wordpress', etc.
|
|
25
36
|
console.log(result.architecture.architecture) // 'spa', 'ssr', 'static'
|
|
37
|
+
console.log(result.assets.javascript.length) // Number of JS files
|
|
26
38
|
```
|
|
27
39
|
|
|
28
|
-
###
|
|
40
|
+
### Generate a Manifest
|
|
29
41
|
|
|
30
42
|
```typescript
|
|
31
43
|
import { generateManifest, writeManifest } from '@julien-lin/universal-pwa-core'
|
|
@@ -50,7 +62,7 @@ const manifest = generateManifest({
|
|
|
50
62
|
writeManifest(manifest, './public')
|
|
51
63
|
```
|
|
52
64
|
|
|
53
|
-
###
|
|
65
|
+
### Generate Icons
|
|
54
66
|
|
|
55
67
|
```typescript
|
|
56
68
|
import { generateIcons } from '@julien-lin/universal-pwa-core'
|
|
@@ -62,9 +74,15 @@ const result = await generateIcons({
|
|
|
62
74
|
|
|
63
75
|
console.log(result.icons) // Array of ManifestIcon
|
|
64
76
|
console.log(result.splashScreens) // Array of ManifestSplashScreen
|
|
77
|
+
console.log(result.generatedFiles) // Array of generated file paths
|
|
65
78
|
```
|
|
66
79
|
|
|
67
|
-
|
|
80
|
+
The function automatically generates:
|
|
81
|
+
- PWA icons in multiple sizes (72x72 to 512x512)
|
|
82
|
+
- Apple Touch Icon (180x180)
|
|
83
|
+
- Splash screens for iOS
|
|
84
|
+
|
|
85
|
+
### Generate a Service Worker
|
|
68
86
|
|
|
69
87
|
```typescript
|
|
70
88
|
import { generateServiceWorker } from '@julien-lin/universal-pwa-core'
|
|
@@ -78,10 +96,11 @@ const result = await generateServiceWorker({
|
|
|
78
96
|
globPatterns: ['**/*.{html,js,css,png,jpg,svg}'],
|
|
79
97
|
})
|
|
80
98
|
|
|
81
|
-
console.log(result.swPath) //
|
|
99
|
+
console.log(result.swPath) // Path to generated service worker
|
|
100
|
+
console.log(result.count) // Number of files pre-cached
|
|
82
101
|
```
|
|
83
102
|
|
|
84
|
-
###
|
|
103
|
+
### Inject Meta Tags
|
|
85
104
|
|
|
86
105
|
```typescript
|
|
87
106
|
import { injectMetaTagsInFile } from '@julien-lin/universal-pwa-core'
|
|
@@ -89,37 +108,40 @@ import { injectMetaTagsInFile } from '@julien-lin/universal-pwa-core'
|
|
|
89
108
|
const result = injectMetaTagsInFile('./index.html', {
|
|
90
109
|
manifestPath: '/manifest.json',
|
|
91
110
|
themeColor: '#2c3e50',
|
|
111
|
+
backgroundColor: '#ffffff',
|
|
92
112
|
appleTouchIcon: '/apple-touch-icon.png',
|
|
93
113
|
serviceWorkerPath: '/sw.js',
|
|
114
|
+
appleMobileWebAppCapable: true,
|
|
94
115
|
})
|
|
95
116
|
|
|
96
|
-
console.log(result.injected) // Tags
|
|
97
|
-
console.log(result.skipped) // Tags
|
|
117
|
+
console.log(result.injected) // Tags injected
|
|
118
|
+
console.log(result.skipped) // Tags already present
|
|
98
119
|
```
|
|
99
120
|
|
|
100
|
-
## API
|
|
121
|
+
## API Reference
|
|
101
122
|
|
|
102
123
|
### Scanner
|
|
103
124
|
|
|
104
|
-
- `scanProject(options)` :
|
|
105
|
-
- `detectFramework(projectPath)` :
|
|
106
|
-
- `detectAssets(projectPath)` :
|
|
107
|
-
- `detectArchitecture(projectPath)` :
|
|
125
|
+
- `scanProject(options)` : Scan a project and return a complete report
|
|
126
|
+
- `detectFramework(projectPath)` : Detect the framework used
|
|
127
|
+
- `detectAssets(projectPath)` : Detect assets (JS, CSS, images, fonts)
|
|
128
|
+
- `detectArchitecture(projectPath)` : Detect architecture (SPA, SSR, static)
|
|
108
129
|
|
|
109
|
-
###
|
|
130
|
+
### Generator
|
|
110
131
|
|
|
111
|
-
- `generateManifest(options)` :
|
|
112
|
-
- `writeManifest(manifest, outputDir)` :
|
|
113
|
-
- `
|
|
114
|
-
- `
|
|
115
|
-
- `
|
|
132
|
+
- `generateManifest(options)` : Generate a manifest.json
|
|
133
|
+
- `writeManifest(manifest, outputDir)` : Write manifest to a file
|
|
134
|
+
- `generateAndWriteManifest(options, outputDir)` : Generate and write manifest in one call
|
|
135
|
+
- `generateIcons(options)` : Generate PWA icons from a source image
|
|
136
|
+
- `generateServiceWorker(options)` : Generate a service worker with Workbox
|
|
137
|
+
- `checkProjectHttps(options)` : Check project HTTPS status
|
|
116
138
|
|
|
117
|
-
###
|
|
139
|
+
### Injector
|
|
118
140
|
|
|
119
|
-
- `parseHTML(htmlContent)` : Parse
|
|
120
|
-
- `parseHTMLFile(filePath)` : Parse
|
|
121
|
-
- `injectMetaTags(htmlContent, options)` :
|
|
122
|
-
- `injectMetaTagsInFile(filePath, options)` :
|
|
141
|
+
- `parseHTML(htmlContent)` : Parse HTML content
|
|
142
|
+
- `parseHTMLFile(filePath)` : Parse an HTML file
|
|
143
|
+
- `injectMetaTags(htmlContent, options)` : Inject PWA meta-tags
|
|
144
|
+
- `injectMetaTagsInFile(filePath, options)` : Inject meta-tags in a file
|
|
123
145
|
|
|
124
146
|
## Types
|
|
125
147
|
|
|
@@ -130,14 +152,19 @@ import type {
|
|
|
130
152
|
ScannerResult,
|
|
131
153
|
Manifest,
|
|
132
154
|
ManifestIcon,
|
|
155
|
+
ManifestSplashScreen,
|
|
133
156
|
ServiceWorkerGenerationResult,
|
|
134
157
|
} from '@julien-lin/universal-pwa-core'
|
|
135
158
|
```
|
|
136
159
|
|
|
137
|
-
##
|
|
160
|
+
## 💝 Sponsoring
|
|
161
|
+
|
|
162
|
+
If UniversalPWA is useful to you, please consider [sponsoring the project](https://github.com/sponsors/julien-lin) to help maintain and improve it.
|
|
163
|
+
|
|
164
|
+
## Development
|
|
138
165
|
|
|
139
166
|
```bash
|
|
140
|
-
#
|
|
167
|
+
# Install dependencies
|
|
141
168
|
pnpm install
|
|
142
169
|
|
|
143
170
|
# Build
|
|
@@ -149,3 +176,9 @@ pnpm test
|
|
|
149
176
|
# Lint
|
|
150
177
|
pnpm lint
|
|
151
178
|
```
|
|
179
|
+
|
|
180
|
+
## Links
|
|
181
|
+
|
|
182
|
+
- **Homepage**: https://github.com/julien-lin/UniversalPWA
|
|
183
|
+
- **Support**: For issues and questions, please use [GitHub Discussions](https://github.com/julien-lin/UniversalPWA/discussions)
|
|
184
|
+
- **Sponsor**: https://github.com/sponsors/julien-lin
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@julien-lin/universal-pwa-core",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "Moteur de scan, génération et injection pour UniversalPWA",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pwa",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"homepage": "https://github.com/julien-lin/UniversalPWA#readme",
|
|
20
20
|
"bugs": {
|
|
21
|
-
"url": "https://github.com/julien-lin/UniversalPWA/
|
|
21
|
+
"url": "https://github.com/julien-lin/UniversalPWA/discussions"
|
|
22
22
|
},
|
|
23
23
|
"type": "module",
|
|
24
24
|
"main": "dist/index.js",
|
|
@@ -32,7 +32,9 @@
|
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
34
|
"files": [
|
|
35
|
-
"dist"
|
|
35
|
+
"dist",
|
|
36
|
+
"README.md",
|
|
37
|
+
"README.fr.md"
|
|
36
38
|
],
|
|
37
39
|
"dependencies": {
|
|
38
40
|
"dom-serializer": "^2.0.0",
|
|
@@ -49,7 +51,7 @@
|
|
|
49
51
|
"workbox-routing": "^7.4.0",
|
|
50
52
|
"workbox-strategies": "^7.4.0",
|
|
51
53
|
"zod": "^4.2.1",
|
|
52
|
-
"@julien-lin/universal-pwa-templates": "^1.2.
|
|
54
|
+
"@julien-lin/universal-pwa-templates": "^1.2.3"
|
|
53
55
|
},
|
|
54
56
|
"devDependencies": {
|
|
55
57
|
"@vitest/coverage-v8": "^2.1.4",
|