@egen-civitas/esm-styleguide 1.5.0 → 1.5.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @egen-civitas/esm-styleguide
2
2
 
3
+ ## 1.5.1
4
+
5
+ ### Patch Changes
6
+
7
+ - cd162d1: Corrige 1.4.0 : importer le styleguide déclenchait le préchargement réseau de la scène Spline (1,3 Mo) pour toutes les apps. `SplineScene` charge désormais Spline à la demande (`React.lazy`) et le préchargement devient explicite via `preloadSplineScene(url)`.
8
+
3
9
  ## 1.5.0
4
10
 
5
11
  ### Minor Changes
@@ -4,6 +4,11 @@ interface SplineSceneProps {
4
4
  className?: string;
5
5
  onLoad?: (splineApp: unknown) => void;
6
6
  }
7
+ /**
8
+ * Préchauffe le cache navigateur avec une scène Spline (~1,3 Mo). À appeler explicitement
9
+ * (ouverture de l'assistant, idle…) — jamais au chargement du module.
10
+ */
11
+ export declare function preloadSplineScene(url: string): void;
7
12
  export declare function SplineScene({ scene, className, onLoad }: SplineSceneProps): React.JSX.Element;
8
13
  export default SplineScene;
9
14
  //# sourceMappingURL=spline-scene.component.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"spline-scene.component.d.ts","sourceRoot":"","sources":["../../src/assistant/spline-scene.component.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAGnD,UAAU,gBAAgB;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CACvC;AAiBD,wBAAgB,WAAW,CAAC,EAAE,KAAK,EAAE,SAA2B,EAAE,MAAM,EAAE,EAAE,gBAAgB,qBA4B3F;AAED,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"spline-scene.component.d.ts","sourceRoot":"","sources":["../../src/assistant/spline-scene.component.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmC,MAAM,OAAO,CAAC;AAMxD,UAAU,gBAAgB;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CACvC;AAID;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CASpD;AAED,wBAAgB,WAAW,CAAC,EAAE,KAAK,EAAE,SAA2B,EAAE,MAAM,EAAE,EAAE,gBAAgB,qBA8B3F;AAED,eAAe,WAAW,CAAC"}
@@ -1,21 +1,22 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import React, { useState } from "react";
4
- import Spline from "@splinetool/react-spline";
5
- // Global preload helper to pre-fetch the 1.3MB 3D scene immediately into browser cache
6
- if (typeof window !== 'undefined') {
7
- const PRELOAD_URL = "https://prod.spline.design/kZDDjO5HuC9GJUM2/scene.splinecode";
8
- // Preload link tag
3
+ import React, { Suspense, lazy, useState } from "react";
4
+ // Spline (runtime WebGL ~ plusieurs centaines de Ko) est chargé à la demande : importer le
5
+ // styleguide ne doit JAMAIS déclencher de téléchargement ni d'effet de bord réseau.
6
+ const Spline = /*#__PURE__*/ lazy(()=>import("@splinetool/react-spline"));
7
+ const preloaded = new Set();
8
+ /**
9
+ * Préchauffe le cache navigateur avec une scène Spline (~1,3 Mo). À appeler explicitement
10
+ * (ouverture de l'assistant, idle…) — jamais au chargement du module.
11
+ */ export function preloadSplineScene(url) {
12
+ if (typeof document === 'undefined' || preloaded.has(url)) return;
13
+ preloaded.add(url);
9
14
  const link = document.createElement('link');
10
15
  link.rel = 'preload';
11
16
  link.as = 'fetch';
12
17
  link.crossOrigin = 'anonymous';
13
- link.href = PRELOAD_URL;
18
+ link.href = url;
14
19
  document.head.appendChild(link);
15
- // Background fetch to cache it in memory
16
- fetch(PRELOAD_URL, {
17
- mode: 'cors'
18
- }).catch(()=>{});
19
20
  }
20
21
  export function SplineScene({ scene, className = 'w-full h-full', onLoad }) {
21
22
  const [isLoaded, setIsLoaded] = useState(false);
@@ -36,13 +37,16 @@ export function SplineScene({ scene, className = 'w-full h-full', onLoad }) {
36
37
  }),
37
38
  /*#__PURE__*/ _jsx("div", {
38
39
  className: `w-full h-full transition-opacity duration-500 ${isLoaded ? 'opacity-100' : 'opacity-0'}`,
39
- children: /*#__PURE__*/ _jsx(Spline, {
40
- scene: scene,
41
- className: "w-full h-full",
42
- onLoad: (splineApp)=>{
43
- setIsLoaded(true);
44
- if (onLoad) onLoad(splineApp);
45
- }
40
+ children: /*#__PURE__*/ _jsx(Suspense, {
41
+ fallback: null,
42
+ children: /*#__PURE__*/ _jsx(Spline, {
43
+ scene: scene,
44
+ className: "w-full h-full",
45
+ onLoad: (splineApp)=>{
46
+ setIsLoaded(true);
47
+ if (onLoad) onLoad(splineApp);
48
+ }
49
+ })
46
50
  })
47
51
  })
48
52
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@egen-civitas/esm-styleguide",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "license": "MPL-2.0",
5
5
  "description": "The styleguide for Egen SPA",
6
6
  "main": "dist/internal.js",