@uniweb/core 0.3.2 → 0.3.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/package.json +1 -1
- package/src/uniweb.js +14 -0
package/package.json
CHANGED
package/src/uniweb.js
CHANGED
|
@@ -22,6 +22,10 @@ export default class Uniweb {
|
|
|
22
22
|
// Set by runtime based on site config
|
|
23
23
|
this.iconResolver = null
|
|
24
24
|
|
|
25
|
+
// Pre-populated icon cache for SSR: Map<"family:name", svgString>
|
|
26
|
+
// Populated by prerender before rendering, read synchronously by Icon component
|
|
27
|
+
this.iconCache = new Map()
|
|
28
|
+
|
|
25
29
|
// Initialize analytics (disabled by default, configure via site config)
|
|
26
30
|
this.analytics = new Analytics(configData.analytics || {})
|
|
27
31
|
}
|
|
@@ -40,6 +44,16 @@ export default class Uniweb {
|
|
|
40
44
|
return this.iconResolver(library, name)
|
|
41
45
|
}
|
|
42
46
|
|
|
47
|
+
/**
|
|
48
|
+
* Get a cached icon synchronously (for SSR/prerender)
|
|
49
|
+
* @param {string} library - Icon family code
|
|
50
|
+
* @param {string} name - Icon name
|
|
51
|
+
* @returns {string|null} SVG string or null if not cached
|
|
52
|
+
*/
|
|
53
|
+
getIconSync(library, name) {
|
|
54
|
+
return this.iconCache.get(`${library}:${name}`) || null
|
|
55
|
+
}
|
|
56
|
+
|
|
43
57
|
/**
|
|
44
58
|
* Set the foundation module after loading
|
|
45
59
|
* @param {Object} foundation - The loaded ESM foundation module
|