mnfst 0.5.54 → 0.5.55

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.
@@ -11760,20 +11760,51 @@ async function initializeDataSourcesPlugin() {
11760
11760
  _currentUrl: existingStore._currentUrl || window.location.pathname
11761
11761
  });
11762
11762
 
11763
- // Pre-load manifest and critical data sources so $x.content (etc.) is ready before components render
11763
+ // Pre-load all local file-backed data sources so $x.* accessors see
11764
+ // real data on the very first render pass.
11765
+ //
11766
+ // Each source is at most ONE fetch regardless of type:
11767
+ // - Simple string paths (e.g. "/data/clients.yaml") → one file.
11768
+ // - Localized objects (e.g. { "en": "...", "fr": "..." }) → only the
11769
+ // current locale file is fetched (+ default locale for fallback
11770
+ // merging if different), NOT all 35 variants.
11771
+ // - Single CSV with embedded locales → one file.
11772
+ //
11773
+ // Skipped (remain on-demand):
11774
+ // - Appwrite collections / buckets — require auth/session context.
11775
+ // - API-URL sources — may have side-effects or auth requirements.
11776
+ // - The special "manifest" key — handled separately below.
11777
+ //
11778
+ // Without pre-loading, sources like $x.clients load asynchronously on
11779
+ // first access, causing a visible flash in the SPA and missing data in
11780
+ // prerender snapshots.
11764
11781
  try {
11765
11782
  const manifest = await window.ManifestDataConfig.ensureManifest();
11766
11783
  const locale = (typeof document !== 'undefined' && document.documentElement?.lang) || (typeof Alpine !== 'undefined' && Alpine.store('locale')?.current) || 'en';
11784
+ const isAppwriteCollection = window.ManifestDataConfig.isAppwriteCollection;
11767
11785
 
11768
- // Pre-load content so first $x.content access (e.g. in header) sees data; avoids race with on-demand load
11769
- if (manifest?.data?.content) {
11770
- try {
11771
- const content = await loadDataSource('content', locale);
11772
- if (content != null && window.ManifestDataStore?.updateStore) {
11773
- window.ManifestDataStore.updateStore('content', content, { loading: false, error: null, ready: true, allowDuringInit: true });
11774
- }
11775
- } catch (contentErr) {
11776
- console.warn('[Manifest Data] Failed to pre-load content:', contentErr);
11786
+ if (manifest?.data) {
11787
+ const preloadNames = [];
11788
+ for (const [name, source] of Object.entries(manifest.data)) {
11789
+ if (name === 'manifest') continue; // handled separately below
11790
+ if (isAppwriteCollection(source)) continue;
11791
+ if (source && typeof source === 'object' && source.url) continue;
11792
+ preloadNames.push(name);
11793
+ }
11794
+
11795
+ if (preloadNames.length > 0) {
11796
+ await Promise.all(
11797
+ preloadNames.map(async (name) => {
11798
+ try {
11799
+ const data = await loadDataSource(name, locale);
11800
+ if (data != null && window.ManifestDataStore?.updateStore) {
11801
+ window.ManifestDataStore.updateStore(name, data, { loading: false, error: null, ready: true, allowDuringInit: true });
11802
+ }
11803
+ } catch (err) {
11804
+ console.warn(`[Manifest Data] Failed to pre-load ${name}:`, err);
11805
+ }
11806
+ })
11807
+ );
11777
11808
  }
11778
11809
  }
11779
11810
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mnfst",
3
- "version": "0.5.54",
3
+ "version": "0.5.55",
4
4
  "private": false,
5
5
  "workspaces": [
6
6
  "templates/starter",