@nocode-factory/sanity-kit 2.5.0 → 2.6.1

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.md ADDED
@@ -0,0 +1,43 @@
1
+ # @nocode-factory/sanity-kit
2
+
3
+ Outils Sanity Studio de NoCode Factory : **Pages** (liste + board), **Composants**,
4
+ **Historique**, aperçu multi-environnements et partage de préversion. Plus, côté
5
+ site Next.js : garde de préproduction, bascule brouillons / en ligne, bandeau.
6
+
7
+ ## Installer
8
+
9
+ Public sur npmjs, sans jeton. Dans le studio **et** dans le site :
10
+
11
+ ```bash
12
+ npm install @nocode-factory/sanity-kit@latest
13
+ ```
14
+
15
+ Un `.npmrc` qui envoie `@nocode-factory` vers `npm.pkg.github.com` est un
16
+ reste d'avant la 2.0.0 (figé en 1.8.0) : le retirer.
17
+
18
+ ## Checklist d'un projet complet
19
+
20
+ | Où | Quoi |
21
+ |---|---|
22
+ | `studio/sanity.config.ts` | `ncfKit(options)` ; `presentationTool({allowOrigins: ncfAllowedOrigins(options), …})` |
23
+ | `studio/.env` (+ `.env.production.local`) | `SANITY_STUDIO_PREVIEW_URL` = site en ligne, `SANITY_STUDIO_PREVIEW_URL_PREPROD` = `https://preview-<projet>.vercel.app`, `SANITY_STUDIO_NCF_PROJECT_KEY` |
24
+ | Vercel | domaine fixe `preview-<projet>.vercel.app` assigné à la branche `preprod` ; pas de Vercel Authentication sur les préversions (la garde du kit gère l'accès) |
25
+ | `web/proxy.ts` | `const guarded = await ncfPreviewGuard(req); if (guarded) return guarded` |
26
+ | `web/app/api/draft-mode/toggle/route.ts` | `export const {GET} = ncfDraftModeToggle()` |
27
+ | layout racine du site | `{isPreviewSite() && <NcfPreviewBanner isDraft={isDraft} />}` |
28
+ | `.github/workflows/` | captures `public/sections/<bloc>.png` (workflow du starter) |
29
+ | Studio | `npx ncf-kit setup --types <types de pages>` (journal), puis `npx sanity deploy` |
30
+
31
+ Puis, depuis `studio/` :
32
+
33
+ ```bash
34
+ npx ncf-kit doctor
35
+ ```
36
+
37
+ Zéro ✖ = projet complet. Sortie 1 sinon (utilisable en CI).
38
+
39
+ ## Documentation
40
+
41
+ Dans le dépôt `nocode-factory/ncf-sanity-kit` : `docs/INSTALL.md` (options),
42
+ `docs/NOUVEAU-PROJET.md` (prompt d'installation), `docs/CHANGELOG.md`. Le
43
+ starter `nocode-factory/sanity-next-starter` est déjà câblé de bout en bout.
package/bin/ncf-kit.mjs CHANGED
@@ -7,9 +7,12 @@
7
7
  // 3. crée le webhook du journal via l'API de gestion Sanity, avec la bonne
8
8
  // forme (brouillons inclus, projection, secret), sans jamais supprimer un
9
9
  // webhook existant : au quota, elle s'arrête et le dit.
10
+ //
11
+ // Et `npx ncf-kit doctor` : vérifie qu'un projet est complet (registre, version,
12
+ // préproduction, bandeau, garde, captures) et dit quoi corriger.
10
13
  // Aucune dépendance : Node 22 suffit.
11
- import {readFileSync, writeFileSync, existsSync} from 'node:fs'
12
- import {join, resolve} from 'node:path'
14
+ import {readFileSync, writeFileSync, existsSync, readdirSync, statSync} from 'node:fs'
15
+ import {dirname, join, resolve} from 'node:path'
13
16
  import {homedir} from 'node:os'
14
17
 
15
18
  const DEFAULT_ENDPOINT = 'https://dkoxgivytgsmvqmjvmjt.supabase.co/functions/v1'
@@ -27,11 +30,17 @@ const flag = (name) => {
27
30
  const has = (name) => args.includes(`--${name}`)
28
31
 
29
32
  function usage(code = 0) {
30
- console.log(`Usage : npx ncf-kit setup --types page,homePage [options]
33
+ console.log(`Usage :
34
+ npx ncf-kit setup --types page,homePage [options] active le projet, clé du journal, webhook
35
+ npx ncf-kit doctor [--web <dossier>] [--offline] vérifie que le projet est complet
31
36
 
32
37
  Depuis le dossier du studio (celui de sanity.config.ts et de .env).
33
38
 
34
- Options :
39
+ doctor :
40
+ --web <chemin> Dossier du site Next.js (défaut : ../web, sinon ../frontend).
41
+ --offline Saute les vérifications en ligne (site, préproduction, npm).
42
+
43
+ Options de setup :
35
44
  --types <a,b> Types de documents journalisés (obligatoire) : les types de pages.
36
45
  --name <nom> Nom du client dans le registre (défaut : nom du projet Sanity).
37
46
  --dir <chemin> Dossier du studio (défaut : dossier courant).
@@ -191,8 +200,160 @@ Reste à faire :
191
200
  Le journal part de maintenant : rien n'est reconstitué en arrière.`)
192
201
  }
193
202
 
203
+ /* ------------------------------------------------------------------------ */
204
+ /* doctor : un projet est-il complet ? */
205
+ /* ------------------------------------------------------------------------ */
206
+
207
+ const PKG = '@nocode-factory/sanity-kit'
208
+
209
+ /** Fichiers texte d'un dossier, sans node_modules ni sorties de build. */
210
+ function walk(dir, out = [], depth = 0) {
211
+ if (!existsSync(dir) || depth > 8) return out
212
+ for (const name of readdirSync(dir)) {
213
+ if (['node_modules', '.next', 'dist', '.git', '.sanity', '.vercel', 'out'].includes(name)) continue
214
+ const path = join(dir, name)
215
+ const stat = statSync(path)
216
+ if (stat.isDirectory()) walk(path, out, depth + 1)
217
+ else if (/\.(m?[jt]sx?|json|ya?ml)$/.test(name)) out.push(path)
218
+ }
219
+ return out
220
+ }
221
+
222
+ const read = (file) => (existsSync(file) ? readFileSync(file, 'utf8') : '')
223
+ const findUsage = (files, needle) => files.find((f) => read(f).includes(needle))
224
+
225
+ async function probe(url, init = {}) {
226
+ try {
227
+ const response = await fetch(url, {redirect: 'manual', ...init, signal: AbortSignal.timeout(15000)})
228
+ const body = response.status === 401 ? await response.text() : ''
229
+ return {status: response.status, headers: response.headers, body}
230
+ } catch (error) {
231
+ return {status: 0, error: error?.message ?? String(error)}
232
+ }
233
+ }
234
+
235
+ function deducedPreprod(previewUrl) {
236
+ try {
237
+ const {protocol, hostname} = new URL(previewUrl)
238
+ if (!hostname.endsWith('.vercel.app')) return null
239
+ return `${protocol}//preview-${hostname}`
240
+ } catch {
241
+ return null
242
+ }
243
+ }
244
+
245
+ async function doctor() {
246
+ const studio = resolve(flag('dir') ?? process.cwd())
247
+ const root = dirname(studio)
248
+ const offline = has('offline')
249
+ const web = resolve(flag('web') ?? [join(root, 'web'), join(root, 'frontend')].find((d) => existsSync(join(d, 'package.json'))) ?? join(root, 'web'))
250
+
251
+ const results = []
252
+ const ok = (label, detail) => results.push({level: 'ok', label, detail})
253
+ const warn = (label, detail) => results.push({level: 'warn', label, detail})
254
+ const ko = (label, detail) => results.push({level: 'ko', label, detail})
255
+
256
+ if (!existsSync(join(studio, 'package.json'))) fail(`Pas de package.json dans ${studio} : lance doctor depuis le dossier du studio, ou passe --dir.`)
257
+ const env = {
258
+ ...parseEnv(read(join(studio, '.env'))),
259
+ ...parseEnv(read(join(studio, '.env.production.local'))), // prioritaire au déploiement
260
+ }
261
+
262
+ /* Registre : le kit est sur npmjs depuis la 2.0.0 */
263
+ const npmrcs = [join(studio, '.npmrc'), join(web, '.npmrc'), join(root, '.npmrc')]
264
+ const stale = npmrcs.find((f) => /@nocode-factory:registry\s*=\s*https:\/\/npm\.pkg\.github\.com/.test(read(f)))
265
+ if (stale) ko('Registre', `${stale.replace(root + '/', '')} envoie @nocode-factory vers GitHub Packages, figé en 1.8.0 et qui exige un jeton. Le kit est public sur npmjs depuis la 2.0.0 : retirer ces lignes, puis réinstaller.`)
266
+ else ok('Registre', 'npmjs (public, sans jeton)')
267
+
268
+ /* Version installée */
269
+ const installed = [studio, root].map((d) => read(join(d, 'node_modules', PKG, 'package.json'))).find(Boolean)
270
+ const version = installed ? JSON.parse(installed).version : null
271
+ let latest = null
272
+ if (!offline) {
273
+ const r = await probe(`https://registry.npmjs.org/${PKG}/latest`)
274
+ if (r.status === 200) latest = (await (await fetch(`https://registry.npmjs.org/${PKG}/latest`)).json()).version
275
+ }
276
+ if (!version) ko('Version du kit', 'non installé dans le studio')
277
+ else if (latest && version !== latest) warn('Version du kit', `${version} installée, ${latest} disponible : npm install ${PKG}@latest (studio et site)`)
278
+ else ok('Version du kit', version)
279
+
280
+ /* Studio : URLs et clés */
281
+ const previewUrl = env.SANITY_STUDIO_PREVIEW_URL
282
+ if (!previewUrl) ko('Aperçu (Presentation)', 'SANITY_STUDIO_PREVIEW_URL absent : le Studio en ligne ne saura pas quel site afficher.')
283
+ else if (/localhost|127\.0\.0\.1/.test(previewUrl)) warn('Aperçu (Presentation)', `${previewUrl} : valable en local seulement. Avant \`sanity deploy\`, mettre l'URL du site en ligne (studio/.env.production.local).`)
284
+ else ok('Aperçu (Presentation)', previewUrl)
285
+
286
+ const preprod = env.SANITY_STUDIO_PREVIEW_URL_PREPROD || (previewUrl ? deducedPreprod(previewUrl) : null)
287
+ if (!env.SANITY_STUDIO_PREVIEW_URL_PREPROD) ko('Préproduction', `SANITY_STUDIO_PREVIEW_URL_PREPROD absent${preprod ? ` (déduite : ${preprod})` : ''}. Vercel → Settings → Domains : preview-<projet>.vercel.app sur la branche \`preprod\`, puis le recopier dans studio/.env.`)
288
+ else ok('Préproduction', env.SANITY_STUDIO_PREVIEW_URL_PREPROD)
289
+
290
+ if (!env.SANITY_STUDIO_NCF_PROJECT_KEY) ko('Historique', 'SANITY_STUDIO_NCF_PROJECT_KEY absent : lancer `npx ncf-kit setup --types …`.')
291
+ else ok('Historique', 'clé du journal présente')
292
+
293
+ const config = ['sanity.config.ts', 'sanity.config.tsx', 'sanity.config.js'].map((f) => read(join(studio, f))).find(Boolean) ?? ''
294
+ if (!config.includes('ncfKit(')) ko('Plugin', 'ncfKit(...) absent de sanity.config')
295
+ else ok('Plugin', 'ncfKit branché')
296
+ if (!config.includes('ncfAllowedOrigins')) ko('Origines autorisées', "presentationTool sans allowOrigins: ncfAllowedOrigins(options) : l'aperçu de la préproduction s'affiche mais reste muet.")
297
+ else ok('Origines autorisées', 'ncfAllowedOrigins')
298
+ if (/preprodUrl\s*:\s*false/.test(config)) ko('Préproduction désactivée', "sanity.config contient preprodUrl: false : la préproduction conventionnelle est retirée. À n'utiliser que si le projet n'en a vraiment pas.")
299
+ if (/as\s+NcfKitConfig/.test(config)) warn('Typage', 'sanity.config force le type (as NcfKitConfig) : une option inconnue ou mal écrite passerait inaperçue.')
300
+
301
+ /* Site */
302
+ const webPkg = read(join(web, 'package.json'))
303
+ if (!webPkg) warn('Site', `aucun site trouvé (${web}) : passer --web <dossier>.`)
304
+ else {
305
+ const files = walk(web).filter((f) => !f.endsWith('package.json') && !f.endsWith('package-lock.json'))
306
+ if (!webPkg.includes(PKG)) ko('Kit côté site', `${PKG} absent de ${web.replace(root + '/', '')}/package.json (bandeau, bascule et garde en dépendent).`)
307
+ else ok('Kit côté site', 'installé')
308
+ const banner = findUsage(files, 'NcfPreviewBanner')
309
+ banner ? ok('Bandeau de préversion', banner.replace(root + '/', '')) : ko('Bandeau de préversion', "NcfPreviewBanner absent du layout : {isPreviewSite() && <NcfPreviewBanner isDraft={isDraft} />}")
310
+ const toggle = findUsage(files, 'ncfDraftModeToggle')
311
+ toggle ? ok('Bascule brouillons', toggle.replace(root + '/', '')) : ko('Bascule brouillons', 'app/api/draft-mode/toggle/route.ts : export const {GET} = ncfDraftModeToggle()')
312
+ const guard = findUsage(files, 'ncfPreviewGuard')
313
+ guard ? ok('Garde de préproduction', guard.replace(root + '/', '')) : ko('Garde de préproduction', 'ncfPreviewGuard absent de proxy.ts (ou middleware.ts) : la préproduction serait publique.')
314
+ }
315
+
316
+ /* Captures des composants */
317
+ const workflows = walk(join(root, '.github', 'workflows'))
318
+ const captures = workflows.find((f) => /public\/sections/.test(read(f)))
319
+ captures ? ok('Captures des composants', captures.replace(root + '/', '')) : warn('Captures des composants', "aucun workflow ne produit public/sections/<bloc>.png : l'onglet Composants affichera « Pas de capture ». Reprendre .github/workflows/section-screenshots.yml du starter.")
320
+
321
+ /* En ligne */
322
+ if (!offline) {
323
+ if (previewUrl && !/localhost/.test(previewUrl)) {
324
+ const r = await probe(previewUrl)
325
+ r.status && r.status < 500 ? ok('Site en ligne', `${previewUrl} répond (${r.status})`) : ko('Site en ligne', `${previewUrl} : ${r.error ?? r.status}`)
326
+ }
327
+ if (preprod) {
328
+ const r = await probe(preprod)
329
+ // Vercel Authentication : redirection vers vercel.com/sso-api, ou 401 « Vercel Authentication ».
330
+ const location = r.headers?.get('location') ?? ''
331
+ const vercelAuth = (r.status >= 300 && r.status < 400 && /vercel\.com\/sso/.test(location)) || (r.status === 401 && /vercel authentication/i.test(r.body))
332
+ if (!r.status) ko('Préproduction en ligne', `${preprod} injoignable (${r.error}) : domaine non créé, ou branche \`preprod\` jamais poussée.`)
333
+ else if (r.status === 404) ko('Préproduction en ligne', `${preprod} : 404, domaine non assigné à la branche \`preprod\`.`)
334
+ else if (vercelAuth) ko('Préproduction en ligne', `${preprod} demande une connexion Vercel (Vercel Authentication) : le lien « Partager la préversion » et l'aperçu du Studio tombent sur la connexion Vercel. Vercel → Settings → Deployment Protection : la désactiver pour les préversions, la garde du kit gère l'accès.`)
335
+ else if (r.status === 401) ok('Préproduction en ligne', `${preprod} protégée par la garde du kit (401 sans laissez-passer)`)
336
+ else if (r.status < 500) {
337
+ const noindex = /noindex/i.test(r.headers.get('x-robots-tag') ?? '')
338
+ noindex ? ok('Préproduction en ligne', `${preprod} répond (${r.status}), noindex`) : warn('Préproduction en ligne', `${preprod} répond (${r.status}) sans garde ni noindex : elle est publique.`)
339
+ } else ko('Préproduction en ligne', `${preprod} : erreur ${r.status}`)
340
+ }
341
+ }
342
+
343
+ /* Rapport */
344
+ const icon = {ok: '✔', warn: '⚠', ko: '✖'}
345
+ console.log(`\nNCF Kit — diagnostic de ${root}\n`)
346
+ for (const r of results) console.log(`${icon[r.level]} ${r.label}${r.detail ? ` : ${r.detail}` : ''}`)
347
+ const kos = results.filter((r) => r.level === 'ko').length
348
+ const warns = results.filter((r) => r.level === 'warn').length
349
+ console.log(`\n${kos ? `${kos} point(s) à corriger` : 'Rien de bloquant'}${warns ? `, ${warns} avertissement(s)` : ''}.`)
350
+ process.exit(kos ? 1 : 0)
351
+ }
352
+
194
353
  if (command === 'setup') {
195
354
  setup().catch((error) => fail(error?.message ?? String(error)))
355
+ } else if (command === 'doctor') {
356
+ doctor().catch((error) => fail(error?.message ?? String(error)))
196
357
  } else if (!command || command === 'help' || has('help')) {
197
358
  usage(command ? 0 : 1)
198
359
  } else {
package/dist/index.d.ts CHANGED
@@ -1270,7 +1270,7 @@ export declare function ActorName(props: {
1270
1270
  * Version du kit, rapportée au service pour savoir quels projets tournent sur
1271
1271
  * quelle version. Tenue à jour avec `package.json`.
1272
1272
  */
1273
- export declare const KIT_VERSION = "2.5.0";
1273
+ export declare const KIT_VERSION = "2.6.1";
1274
1274
  /**
1275
1275
  * Données de la page proposées comme colonnes.
1276
1276
  *
package/dist/index.js CHANGED
@@ -996,17 +996,30 @@ function urlOn(environment, path) {
996
996
  return environment?.url ? path ? `${trimEnd(environment.url)}${path.startsWith("/") ? path : `/${path}`}` : trimEnd(environment.url) : null;
997
997
  }
998
998
  /**
999
+ * L'environnement est-il le site public ?
1000
+ *
1001
+ * La production n'a ni garde ni brouillons : on y va par l'URL simple. Tout le
1002
+ * reste est une préversion, gardée — y compris une adresse collée à la volée.
1003
+ */
1004
+ function isPublicEnvironment(environment, previewUrl) {
1005
+ return environment ? environment.id === "production" || !!previewUrl && trimEnd(environment.url) === trimEnd(previewUrl) : !1;
1006
+ }
1007
+ /**
999
1008
  * URL du vrai site, en ligne, pour un environnement et un état de contenu.
1000
1009
  *
1001
- * Les brouillons passent par la route de bascule du site, qui pose le cookie
1002
- * de mode brouillon puis renvoie à l'accueil. La production ne montre jamais
1003
- * de brouillons : on y retombe sur l'URL simple, et la route refuserait de
1004
- * toute façon.
1010
+ * - Production : l'URL simple. Elle ne montre jamais de brouillons, et la
1011
+ * route de bascule y refuserait.
1012
+ * - Préversion, brouillons : la route de bascule pose le cookie de mode
1013
+ * brouillon, puis renvoie vers la page **avec le laissez-passer** — c'est la
1014
+ * page d'arrivée que la garde contrôle, pas la route, toujours ouverte.
1015
+ * - Préversion, en ligne : la page avec le laissez-passer.
1005
1016
  */
1006
- function onlineUrl(environment, perspective) {
1017
+ function onlineUrl(environment, perspective, options = {}) {
1007
1018
  if (!environment?.url) return null;
1008
- let base = environment.url.replace(/\/+$/, "");
1009
- return perspective === "drafts" && environment.id !== "production" ? `${base}/api/draft-mode/toggle?enable=true&redirect=/` : base;
1019
+ let base = trimEnd(environment.url), path = options.path ? options.path.startsWith("/") ? options.path : `/${options.path}` : "/";
1020
+ if (environment.id === "production" || isPublicEnvironment(environment, options.previewUrl)) return path === "/" ? base : `${base}${path}`;
1021
+ let landing = options.grant ? `${path}${path.includes("?") ? "&" : "?"}ncf_preview=${encodeURIComponent(options.grant)}` : path;
1022
+ return perspective === "drafts" ? `${base}/api/draft-mode/toggle?enable=true&redirect=${options.grant ? encodeURIComponent(landing) : landing}` : landing === "/" ? base : `${base}${landing}`;
1010
1023
  }
1011
1024
  /**
1012
1025
  * Liens internes au Studio.
@@ -1287,7 +1300,7 @@ function explainGrantError(error) {
1287
1300
  * Version du kit, rapportée au service pour savoir quels projets tournent sur
1288
1301
  * quelle version. Tenue à jour avec `package.json`.
1289
1302
  */
1290
- const KIT_VERSION = "2.5.0";
1303
+ const KIT_VERSION = "2.6.1";
1291
1304
  /**
1292
1305
  * Signale ce Studio au service du kit, une fois par montage.
1293
1306
  *
@@ -1472,6 +1485,65 @@ function InlinePopover(props) {
1472
1485
  })
1473
1486
  })] });
1474
1487
  }
1488
+ /** Libellé des laissez-passer délivrés pour soi, distinct des liens partagés. */
1489
+ const cache = /* @__PURE__ */ new Map();
1490
+ /**
1491
+ * Ouvre le vrai site, en ligne, dans un nouvel onglet.
1492
+ *
1493
+ * Sur une préversion gardée par `ncfPreviewGuard`, un lien nu tombe sur
1494
+ * « Cette version du site est privée » — même pour l'éditeur connecté au
1495
+ * Studio. On demande donc au service un laissez-passer pour soi (le même que
1496
+ * « Partager la préversion », délivré seulement à qui a accès au projet Sanity)
1497
+ * et on le pose sur l'URL.
1498
+ *
1499
+ * L'onglet est ouvert **avant** l'appel réseau : un navigateur bloque une
1500
+ * fenêtre ouverte après un `await`, faute de geste de l'utilisateur.
1501
+ */
1502
+ function useOpenOnline() {
1503
+ let config = useKitConfig(), client = useKitClient();
1504
+ return useCallback(async (environment, options = {}) => {
1505
+ let perspective = options.perspective ?? "published", plain = onlineUrl(environment, perspective, {
1506
+ path: options.path,
1507
+ previewUrl: config.previewUrl
1508
+ });
1509
+ if (!environment || !plain) return;
1510
+ if (isPublicEnvironment(environment, config.previewUrl) || !config.serviceEndpoint) {
1511
+ window.open(plain, "_blank", "noopener");
1512
+ return;
1513
+ }
1514
+ let tab = window.open("about:blank", "_blank");
1515
+ if (tab) {
1516
+ tab.opener = null, tab.document.title = "Ouverture de la préversion…", tab.document.body.innerHTML = "<p style=\"font:15px/1.6 system-ui,sans-serif;color:#57534e;padding:2rem\">Ouverture de la préversion…</p>";
1517
+ try {
1518
+ let { projectId, dataset, token } = client.config();
1519
+ if (!projectId || !dataset) throw Error("unknown_project");
1520
+ let key = `${config.serviceEndpoint}|${projectId}|${dataset}`, grant = cache.get(key);
1521
+ (!grant || new Date(grant.expiresAt).getTime() - Date.now() < 36e5) && (grant = await requestPreviewGrant(config.serviceEndpoint, {
1522
+ projectId,
1523
+ dataset,
1524
+ sanityToken: token ?? "",
1525
+ label: "Ouverture depuis le Studio",
1526
+ days: 1
1527
+ }), cache.set(key, grant));
1528
+ let signed = onlineUrl(environment, perspective, {
1529
+ path: options.path,
1530
+ grant: grant.token,
1531
+ previewUrl: config.previewUrl
1532
+ });
1533
+ tab.location.href = signed ?? plain;
1534
+ } catch (cause) {
1535
+ let message = explainGrantError(cause);
1536
+ tab.document.title = "Préversion indisponible", tab.document.body.innerHTML = "<main style=\"font:15px/1.6 system-ui,sans-serif;color:#1c1917;padding:2rem;max-width:32rem\"><h1 style=\"font-size:18px\">Impossible d'ouvrir la préversion</h1><p style=\"color:#57534e\"></p></main>";
1537
+ let paragraph = tab.document.querySelector("p");
1538
+ paragraph && (paragraph.textContent = message);
1539
+ }
1540
+ }
1541
+ }, [
1542
+ client,
1543
+ config.previewUrl,
1544
+ config.serviceEndpoint
1545
+ ]);
1546
+ }
1475
1547
  /**
1476
1548
  * Jetons partagés par les vues du kit.
1477
1549
  *
@@ -1539,7 +1611,7 @@ function useKitUpdate() {
1539
1611
  !controller.signal.aborted && body?.version && setLatest(body.version);
1540
1612
  }).catch(() => {}), () => controller.abort();
1541
1613
  }, []);
1542
- let available = !!(latest && !isPrerelease(latest) && compareVersions(latest, "2.5.0") > 0);
1614
+ let available = !!(latest && !isPrerelease(latest) && compareVersions(latest, "2.6.1") > 0);
1543
1615
  return {
1544
1616
  current: KIT_VERSION,
1545
1617
  latest,
@@ -1676,7 +1748,7 @@ function NcfKitUpdate(props) {
1676
1748
  * regarde ailleurs.
1677
1749
  */
1678
1750
  function NcfPreviewLauncher(props) {
1679
- let config = useKitConfig(), router = useRouter(), environments = config.environments;
1751
+ let config = useKitConfig(), router = useRouter(), open = useOpenOnline(), environments = config.environments;
1680
1752
  if (environments.length === 0) return /* @__PURE__ */ jsxs(Flex, {
1681
1753
  align: "center",
1682
1754
  gap: 2,
@@ -1689,8 +1761,7 @@ function NcfPreviewLauncher(props) {
1689
1761
  });
1690
1762
  path && router.navigateUrl({ path });
1691
1763
  }, openOnline = (environment, perspective) => {
1692
- let target = onlineUrl(environment, perspective);
1693
- target && window.open(target, "_blank", "noopener");
1764
+ open(environment, { perspective });
1694
1765
  }, inline = props.context === "topbar";
1695
1766
  return /* @__PURE__ */ jsxs(Flex, {
1696
1767
  align: inline ? "center" : "stretch",
@@ -3403,7 +3474,7 @@ function AddColumn(props) {
3403
3474
  * concurrence plus le segment qui la distingue.
3404
3475
  */
3405
3476
  function PathCell(props) {
3406
- let { path, locale, showLocale, url } = props;
3477
+ let { path, locale, showLocale, url } = props, config = useKitConfig(), { environment, perspective } = usePreviewTarget(), open = useOpenOnline(), guarded = !!environment && !isPublicEnvironment(environment, config.previewUrl);
3407
3478
  if (!path) return /* @__PURE__ */ jsx(Text, {
3408
3479
  size: 1,
3409
3480
  muted: !0,
@@ -3430,6 +3501,12 @@ function PathCell(props) {
3430
3501
  target: "_blank",
3431
3502
  rel: "noreferrer",
3432
3503
  title: `Ouvrir ${url}`,
3504
+ onClick: (event) => {
3505
+ guarded && (event.preventDefault(), open(environment, {
3506
+ path: pathnameOf(url),
3507
+ perspective
3508
+ }));
3509
+ },
3433
3510
  style: {
3434
3511
  color: "inherit",
3435
3512
  textDecoration: "none",
@@ -3455,6 +3532,14 @@ function PathCell(props) {
3455
3532
  })]
3456
3533
  });
3457
3534
  }
3535
+ /** Chemin d'une URL absolue, ou la valeur telle quelle. */
3536
+ function pathnameOf(url) {
3537
+ try {
3538
+ return new URL(url).pathname;
3539
+ } catch {
3540
+ return url;
3541
+ }
3542
+ }
3458
3543
  /**
3459
3544
  * Étiquette d'une page, modifiable sur place.
3460
3545
  *
@@ -4032,7 +4117,7 @@ function pageThumbnailUrl(template, previewUrl, input) {
4032
4117
  * sélecteur, et c'est pourtant là qu'on veut qualifier les pages.
4033
4118
  */
4034
4119
  function PagePanel(props) {
4035
- let { row, thumbnailUrl, tag, tags, colorLabel, color, incoming, outgoing, columns, values, onTag, onField, onAddOption, onRemoveOption, onOptionColor, onOpen, onClose } = props, [failed, setFailed] = useState(!1), { siteUrlFor, environments, environment } = usePreviewTarget(), siteUrl = siteUrlFor(row.url);
4120
+ let { row, thumbnailUrl, tag, tags, colorLabel, color, incoming, outgoing, columns, values, onTag, onField, onAddOption, onRemoveOption, onOptionColor, onOpen, onClose } = props, [failed, setFailed] = useState(!1), { siteUrlFor, environments, environment, perspective } = usePreviewTarget(), openOnline = useOpenOnline(), config = useKitConfig(), siteUrl = siteUrlFor(row.url);
4036
4121
  return /* @__PURE__ */ jsx(Card, {
4037
4122
  radius: 3,
4038
4123
  shadow: 1,
@@ -4218,6 +4303,12 @@ function PagePanel(props) {
4218
4303
  href: siteUrl,
4219
4304
  target: "_blank",
4220
4305
  rel: "noreferrer",
4306
+ onClick: (event) => {
4307
+ environment && !isPublicEnvironment(environment, config.previewUrl) && (event.preventDefault(), openOnline(environment, {
4308
+ path: new URL(siteUrl).pathname,
4309
+ perspective
4310
+ }));
4311
+ },
4221
4312
  mode: "ghost",
4222
4313
  fontSize: 1,
4223
4314
  padding: 2,