@lystech/core 3.0.86 → 3.0.88
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/bin/check-pwa.cjs +67 -13
- package/dist/index.d.ts +6 -0
- package/dist/lystech-core-provider.es.js +6628 -6580
- package/dist/lystech-core-provider.umd.js +167 -167
- package/package.json +1 -1
package/bin/check-pwa.cjs
CHANGED
|
@@ -19,9 +19,13 @@ function checkManifest(autoCreate = false) {
|
|
|
19
19
|
findFileUpwards("public/manifest.json"),
|
|
20
20
|
findFileUpwards("manifest.json"),
|
|
21
21
|
].filter(Boolean);
|
|
22
|
+
// Nom déduit du package.json de la BOUTIQUE : un manifeste créé automatiquement
|
|
23
|
+
// baptisait toute nouvelle boutique « Lystech Core » sur l'écran d'accueil des
|
|
24
|
+
// clients (le manifeste fait foi pour iOS 16.4+ et Android).
|
|
25
|
+
const fallbackName = resolveAppName(null);
|
|
22
26
|
const defaultManifest = {
|
|
23
|
-
name:
|
|
24
|
-
short_name:
|
|
27
|
+
name: fallbackName,
|
|
28
|
+
short_name: fallbackName,
|
|
25
29
|
start_url: ".",
|
|
26
30
|
display: "standalone",
|
|
27
31
|
background_color: "#ffffff",
|
|
@@ -184,7 +188,34 @@ function checkServiceWorker(autoCreate = false) {
|
|
|
184
188
|
return false;
|
|
185
189
|
}
|
|
186
190
|
|
|
187
|
-
|
|
191
|
+
/**
|
|
192
|
+
* Nom de l'app tel que LA BOUTIQUE le déclare. Le script tourne dans le CI de chaque
|
|
193
|
+
* boutique : il ne doit jamais y injecter le nom de la plateforme. Priorité au
|
|
194
|
+
* manifeste (qui fait foi pour iOS 16.4+), repli sur package.json.
|
|
195
|
+
*/
|
|
196
|
+
function resolveAppName(manifestPath) {
|
|
197
|
+
try {
|
|
198
|
+
if (manifestPath && fs.existsSync(manifestPath)) {
|
|
199
|
+
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
|
|
200
|
+
const name = manifest?.short_name || manifest?.name;
|
|
201
|
+
if (name) return String(name);
|
|
202
|
+
}
|
|
203
|
+
} catch {
|
|
204
|
+
/* manifeste illisible -> repli */
|
|
205
|
+
}
|
|
206
|
+
try {
|
|
207
|
+
const pkgPath = findFileUpwards("package.json");
|
|
208
|
+
if (pkgPath) {
|
|
209
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
|
210
|
+
if (pkg?.name) return String(pkg.name);
|
|
211
|
+
}
|
|
212
|
+
} catch {
|
|
213
|
+
/* ignore */
|
|
214
|
+
}
|
|
215
|
+
return "Lystech Core";
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function checkIndexHtmlForManifestAndAppleTags(autoCreate = false, appName = "Lystech Core") {
|
|
188
219
|
const indexPaths = [
|
|
189
220
|
findFileUpwards("public/index.html"),
|
|
190
221
|
findFileUpwards("index.html"),
|
|
@@ -198,16 +229,37 @@ function checkIndexHtmlForManifestAndAppleTags(autoCreate = false) {
|
|
|
198
229
|
const indexPath = indexPaths[0];
|
|
199
230
|
let lines = fs.readFileSync(indexPath, "utf8").split(/\r?\n/);
|
|
200
231
|
let ok = true;
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
232
|
+
// Détection par ATTRIBUT, pas par chaîne exacte. Avant, on cherchait la valeur
|
|
233
|
+
// littérale ('content="Lystech Core"') : une boutique brandée autrement ne matchait
|
|
234
|
+
// jamais, et --fix lui ajoutait une SECONDE balise contradictoire à chaque fois.
|
|
235
|
+
// On ne touche donc à rien si la balise existe déjà, quelle que soit sa valeur.
|
|
236
|
+
const requiredTags = [
|
|
237
|
+
{
|
|
238
|
+
detect: /rel=["']manifest["']/i,
|
|
239
|
+
tag: '<link rel="manifest" href="/manifest.json" />',
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
detect: /name=["']apple-mobile-web-app-capable["']/i,
|
|
243
|
+
tag: '<meta name="apple-mobile-web-app-capable" content="yes" />',
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
detect: /name=["']apple-mobile-web-app-status-bar-style["']/i,
|
|
247
|
+
tag: '<meta name="apple-mobile-web-app-status-bar-style" content="default" />',
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
detect: /name=["']apple-mobile-web-app-title["']/i,
|
|
251
|
+
// Nom DÉRIVÉ de la boutique : ce titre s'affiche sous l'icône iOS. Coder
|
|
252
|
+
// « Lystech Core » en dur y faisait fuiter le nom de la plateforme.
|
|
253
|
+
tag: `<meta name="apple-mobile-web-app-title" content="${appName}" />`,
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
detect: /rel=["']apple-touch-icon["']/i,
|
|
257
|
+
tag: '<link rel="apple-touch-icon" href="/logo.png" />',
|
|
258
|
+
},
|
|
207
259
|
];
|
|
208
260
|
let changed = false;
|
|
209
|
-
for (const tag of
|
|
210
|
-
if (lines.some((l) =>
|
|
261
|
+
for (const { detect, tag } of requiredTags) {
|
|
262
|
+
if (lines.some((l) => detect.test(l))) {
|
|
211
263
|
console.log(`✅ ${tag} trouvé dans`, indexPath);
|
|
212
264
|
} else {
|
|
213
265
|
ok = false;
|
|
@@ -237,8 +289,10 @@ function main() {
|
|
|
237
289
|
process.argv.includes("--fix") || process.argv.includes("--create");
|
|
238
290
|
const manifest = checkManifest(autoCreate);
|
|
239
291
|
const serviceWorker = checkServiceWorker(autoCreate);
|
|
240
|
-
const indexHasManifestAndApple =
|
|
241
|
-
|
|
292
|
+
const indexHasManifestAndApple = checkIndexHtmlForManifestAndAppleTags(
|
|
293
|
+
autoCreate,
|
|
294
|
+
resolveAppName(manifest),
|
|
295
|
+
);
|
|
242
296
|
|
|
243
297
|
// Ajout automatique du script check-pwa dans package.json si absent
|
|
244
298
|
const pkgPath = findFileUpwards("package.json");
|
package/dist/index.d.ts
CHANGED
|
@@ -750,6 +750,12 @@ declare type ProgressiveWebAppContextType = {
|
|
|
750
750
|
canInstallProgressiveWebApp: boolean;
|
|
751
751
|
progressiveWebAppMessage: string;
|
|
752
752
|
isMobile?: boolean;
|
|
753
|
+
/**
|
|
754
|
+
* iOS/Safari installe SANS prompt : l'app doit montrer la marche à suivre
|
|
755
|
+
* (Partager -> « Sur l'écran d'accueil ») au lieu d'appeler installProgressiveWebApp,
|
|
756
|
+
* qui n'a aucun prompt à déclencher là-bas.
|
|
757
|
+
*/
|
|
758
|
+
requiresManualInstall: boolean;
|
|
753
759
|
installProgressiveWebApp: () => Promise<void>;
|
|
754
760
|
};
|
|
755
761
|
|