mnfst 0.5.278 → 0.5.280

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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  (function () {
4
4
 
5
- const MANIFEST_BUILD_VERSION = '0.5.278';
5
+ const MANIFEST_BUILD_VERSION = '0.5.280';
6
6
 
7
7
  /* Manifest Data Sources - Appwrite Integration */
8
8
 
package/lib/manifest.d.ts CHANGED
@@ -69,6 +69,8 @@ export interface ManifestSourceState {
69
69
  readonly $stale: boolean;
70
70
  /** Resolves once fresh data has landed. */
71
71
  readonly $fresh: Promise<void>;
72
+ /** Fetch again; Appwrite tables keep the active `$query` and paged rows. */
73
+ $reload(): Promise<unknown>;
72
74
  }
73
75
 
74
76
  /** Fields Appwrite adds to every row. */
@@ -153,7 +155,6 @@ export interface ManifestAppwriteTableOps<T> {
153
155
  $next(cursor: string, limit?: number): Promise<ManifestCursorPage<T>>;
154
156
  $prev(cursor: string, limit?: number): Promise<ManifestCursorPage<T>>;
155
157
  $page(page: number, limit?: number): Promise<ManifestOffsetPage<T>>;
156
- $reload(): Promise<void>;
157
158
  /** Realtime events skipped by the growth cap since the last load. */
158
159
  readonly $realtimeOverflow: number;
159
160
  /** Loads the next page into the source (`paging` sources only); resolves with the rows added. */
@@ -2,7 +2,7 @@
2
2
 
3
3
  (function () {
4
4
 
5
- const MANIFEST_BUILD_VERSION = '0.5.278';
5
+ const MANIFEST_BUILD_VERSION = '0.5.280';
6
6
 
7
7
  /* Manifest Data Sources - Configuration */
8
8
 
@@ -7970,7 +7970,9 @@ function createAppwriteMethodsHandler(dataSourceName, reloadDataSource) {
7970
7970
  if (!sourceUnloaded) clearErrorState();
7971
7971
  // Reads are ordered by call, not by network start: the last-issued one lands
7972
7972
  let readToken = method === '$query' ? window.ManifestDataStore?.beginRead?.(dataSourceName) : undefined;
7973
- let queryIntentRef = null;
7973
+ // Recorded at call time: a lazy first load started after this defers to it
7974
+ const queryIntentRef = method === '$query' ? { queries: args[0] ?? [] } : null;
7975
+ if (queryIntentRef) window.ManifestDataMain?.noteQueryIntent?.(dataSourceName, queryIntentRef);
7974
7976
 
7975
7977
  try {
7976
7978
  const manifest = await window.ManifestDataConfig?.ensureManifest?.();
@@ -8344,8 +8346,6 @@ function createAppwriteMethodsHandler(dataSourceName, reloadDataSource) {
8344
8346
  queries = named;
8345
8347
  }
8346
8348
  window.ManifestDataStore?.setSourceState?.(dataSourceName, { loading: true });
8347
- queryIntentRef = [...(queries || [])]; // own copy: a named query's array is shared
8348
- window.ManifestDataMain?.noteQueryIntent?.(dataSourceName, queryIntentRef);
8349
8349
  // A $auth. value or scope not resolved yet: wait for auth once, then run
8350
8350
  const build = () => window.ManifestDataQueries.buildAppwriteQueries(queries || [], scope, scopeColumns);
8351
8351
  let appwriteQueries = await build();
@@ -9161,13 +9161,13 @@ function createAppwriteMethodsHandler(dataSourceName, reloadDataSource) {
9161
9161
 
9162
9162
  throw new Error(`[Manifest Data] Method "${method}" not supported for this data source`);
9163
9163
  } catch (error) {
9164
- // A $query that failed is not what the source shows: a sign-in doesn't re-run it
9165
- if (method === '$query') window.ManifestDataMain?.dropQueryIntent?.(dataSourceName, queryIntentRef);
9166
9164
  // Automatically set error state - no need for inline .catch() in HTML
9167
9165
  setErrorState(error);
9168
9166
  // Re-throw so promise chain still works if caller wants to handle it
9169
9167
  throw error;
9170
9168
  } finally {
9169
+ // In flight no longer: landed, it shows as the active query; failed, it never shows
9170
+ if (queryIntentRef) window.ManifestDataMain?.dropQueryIntent?.(dataSourceName, queryIntentRef);
9171
9171
  if (readToken !== undefined) {
9172
9172
  const ds = window.ManifestDataStore;
9173
9173
  ds?.endRead?.(dataSourceName, readToken);
@@ -12022,7 +12022,7 @@ function setupAuthResetListener() {
12022
12022
  if (!isIdentityBound(config) || raw[`_${name}_state`] === undefined) continue;
12023
12023
  if (!clear && keepQuery && awaitingQueries.has(name)) continue; // a $query waiting on this sign-in runs it
12024
12024
  if (!clear && readAtEvent !== undefined && (ds.currentRead?.(name) ?? 0) > readAtEvent) continue;
12025
- const active = keepQuery ? (queryIntents.get(name) || activeQueries.get(name)) : null;
12025
+ const active = keepQuery ? (queryIntents.get(name)?.queries || activeQueries.get(name)) : null;
12026
12026
  if (clear) {
12027
12027
  window.ManifestDataRealtime?.unsubscribeFromDataSource?.(name);
12028
12028
  ds.resetSource(name);
@@ -12300,7 +12300,8 @@ function configureRealtimeMeta(dataSourceName, config, initialCount, limitQuery)
12300
12300
  // server-filters by it until the next default load replaces the rows
12301
12301
  const activeQueries = new Map();
12302
12302
  const awaitingQueries = new Set(); // sources with a $query waiting for auth to settle
12303
- const queryIntents = new Map(); // the latest $query asked of a source (cleared by a default load)
12303
+ const queryIntents = new Map(); // a $query in flight for a source, { queries }
12304
+ const deferredLoads = new Set(); // source:locale keys of in-flight loads that deferred to a $query
12304
12305
  const realtimeBinds = new Map(); // Map<name, { config, mode, rebind }>
12305
12306
 
12306
12307
  function realtimeQueriesFor(dataSourceName, defaults) {
@@ -12931,8 +12932,12 @@ async function loadDataSource(dataSourceName, locale = 'en', options = {}) {
12931
12932
  // Memory cache (this page-load's fetches). Serving cached data is fine, but
12932
12933
  // writing an old locale to the live store would clobber a concurrent locale
12933
12934
  // switch — so guard the store write via the `_locale` stamp.
12935
+ // A $query in flight, or its rows showing: lazy reads defer to it (see below)
12936
+ const queryHolds = () => queryIntents.has(dataSourceName) || (activeQueries.has(dataSourceName) && hasLiveRows(dataSourceName));
12937
+
12934
12938
  if (!options.reload && dataSourceCache.has(cacheKey)) {
12935
12939
  const cachedData = dataSourceCache.get(cacheKey);
12940
+ if (queryHolds()) return cachedData;
12936
12941
  const live = (window.Alpine && Alpine.store('locale')?.current)
12937
12942
  || document.documentElement.lang || locale;
12938
12943
  const staleLocaleHit = locale !== live && !!(cachedData && cachedData._locale);
@@ -12943,6 +12948,15 @@ async function loadDataSource(dataSourceName, locale = 'en', options = {}) {
12943
12948
  return cachedData;
12944
12949
  }
12945
12950
 
12951
+ // An explicit reload never joins a load that deferred to a $query: it runs after it
12952
+ // It counts as issued now: a $query called after it still wins
12953
+ if (options.reload && deferredLoads.has(cacheKey) && loadingPromises.has(cacheKey)) {
12954
+ const issued = options.issuedRead ?? window.ManifestDataStore.beginRead?.(dataSourceName);
12955
+ if (options.issuedRead === undefined) queryIntents.delete(dataSourceName);
12956
+ return loadingPromises.get(cacheKey).catch(() => null)
12957
+ .then(() => loadDataSource(dataSourceName, locale, { ...options, issuedRead: issued }));
12958
+ }
12959
+
12946
12960
  // In flight for this source+locale: share it (every entry path lands here);
12947
12961
  // joining makes it the latest read again
12948
12962
  if (loadingPromises.has(cacheKey)) {
@@ -12951,8 +12965,14 @@ async function loadDataSource(dataSourceName, locale = 'en', options = {}) {
12951
12965
  }
12952
12966
 
12953
12967
  // Reads are ordered by call: a $query issued after this load wins over it
12954
- const readToken = window.ManifestDataStore.beginRead?.(dataSourceName);
12955
- queryIntents.delete(dataSourceName);
12968
+ // A lazy read while a $query is in flight, or while a $query's rows are showing, only binds
12969
+ // realtime: it neither outranks that $query nor lands default rows. An explicit reload does both.
12970
+ // (A listener that clears the rows first — locale, team — gets the defaults as before.)
12971
+ const deferred = !options.reload && queryHolds();
12972
+ const deferToQuery = () => deferred && queryHolds();
12973
+ const readToken = deferred ? undefined : (options.issuedRead ?? window.ManifestDataStore.beginRead?.(dataSourceName));
12974
+ if (deferred) deferredLoads.add(cacheKey);
12975
+ if (options.reload && options.issuedRead === undefined) queryIntents.delete(dataSourceName);
12956
12976
  let pagedResult = null;
12957
12977
  window.ManifestDataStore.loadReadTokens?.set(cacheKey, readToken);
12958
12978
 
@@ -13297,8 +13317,8 @@ async function loadDataSource(dataSourceName, locale = 'en', options = {}) {
13297
13317
 
13298
13318
  if (superseded()) { landed = true; return null; }
13299
13319
 
13300
- // A $query issued since this load began: its rows stand, this result never lands
13301
- if (window.ManifestDataStore.isLatestRead && !window.ManifestDataStore.isLatestRead(dataSourceName, readToken)) {
13320
+ // A $query issued since this load began (or one it deferred to): its rows stand, this result never lands
13321
+ if (deferToQuery() || (window.ManifestDataStore.isLatestRead && !window.ManifestDataStore.isLatestRead(dataSourceName, readToken))) {
13302
13322
  landed = true;
13303
13323
  if (!isInitializing) setSourceState(dataSourceName, { loading: false });
13304
13324
  return enhancedData;
@@ -13363,7 +13383,8 @@ async function loadDataSource(dataSourceName, locale = 'en', options = {}) {
13363
13383
  if (!landed && keepRows && !isInitializing && !superseded()) setSourceState(dataSourceName, { loading: false });
13364
13384
  }
13365
13385
  });
13366
- run.then(settled, settled);
13386
+ const done = () => { settled(); deferredLoads.delete(cacheKey); };
13387
+ run.then(done, done);
13367
13388
  return run;
13368
13389
  }
13369
13390
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "manifest.appwrite.auth.js": "sha384-gWLSeVPqCLMiUZB8MU7GqMg3x2yULFUsp8nTTZrPp/9Dlkix42rBn9yIimvwrHqZ",
3
- "manifest.appwrite.data.js": "sha384-cVP8/j1hDbYLj+EugdI/S15lvavKOqM8Hw5I7CV2WUhp33nLyzipjgR90REGD43f",
3
+ "manifest.appwrite.data.js": "sha384-0EGUWEr42z0dZpjupRpAESbafLNh8EM0qSLkOSFiHQ/Hsmxd9iTLjujJ0ikRkWBJ",
4
4
  "manifest.appwrite.presences.js": "sha384-LINPhIPTCK+rA8zd+HPUzMSEgH6Sl2vQMEyItT97bnEE2FYGYKqjXX+CWdt6nl9z",
5
5
  "manifest.bindings.js": "sha384-lPtMf8Ykaic9gNVZKq8Scia1881ZeMAyxer3WCIkUNwwrgzGBWto1OXADUwjvORF",
6
6
  "manifest.charts.js": "sha384-AFbP7mQnigy7DU1s+YE30yKTeQAKfgNazhbfSNbfd9ZpLgeulZKaPi/fAq3gJHDO",
@@ -11,7 +11,7 @@
11
11
  "manifest.combobox.js": "sha384-/lJo6vaxKjgnBSRs/dzkhK1dzGk3GBw8FISoNJZB70mwAVwu1k5veZyBXjOb4keS",
12
12
  "manifest.components.js": "sha384-1el5WMdgmzu/2ocaYN21OjLi/lfjllvA8aju1J3knYuOizw+XFfJU1+rvGqYW7qk",
13
13
  "manifest.computed.js": "sha384-GYML/e81gQfN+iDbqhPUgny8bINCyL+SrbTofoGk4hlCnLLjv51mCv42JMqq+ku5",
14
- "manifest.data.js": "sha384-eEwDOCsUPZyJ+MXk0dRmLV1O+I1fMDb5vtmGNnBcxic2LWbF/vY2IDukPsnol+9s",
14
+ "manifest.data.js": "sha384-aNfAjA6DMSGz5FwvlI6/9Q3osRBfEEcCAXB1VYZDO/Ftuzo0Vuq3SkvJ4WLTuGEk",
15
15
  "manifest.datepicker.js": "sha384-EzlMwvIxlla/0BuyhAEqxN0M8TGcWIWgEIg840V0akKQQK1uY648wPWMkobvtq/o",
16
16
  "manifest.defer.js": "sha384-PRp7+dCZHnnl55rX2xrHutLrQnszHo7o5o9Tq28M/yjLZPuXDzcwQNxCdvbtCYSz",
17
17
  "manifest.device.js": "sha384-YeQaS56L8IILqrQNBSeAOLwIh5DuAOrE60cYLK1+46qJtUrXlAvqGe2j5mbV4Vq7",
@@ -29,7 +29,7 @@
29
29
  "manifest.status.js": "sha384-ofu7nBnVIGZ1U1o2R9d2H3V8aEMPUCVbl5FO3gIToXqi0oa36fTviEdh5UU7Kitw",
30
30
  "manifest.submissions.js": "sha384-v9eS47ytAfTGIKAyVnbd0QWegucVS7yduvigqfsxxoqXmbaEoy0M2y+BiI4xeZBd",
31
31
  "manifest.svg.js": "sha384-qr/8H9+2cIhSXNbRWRtIdrDlTOxKlNJqwEefHvCYoiBNW/kKhPTFa109Orv/EBnb",
32
- "manifest.sw.js": "sha384-j96v7U8po0Jwk5UjnsPdJTOydgilWGDsF2s9w/YAaPyL5JeVlbVCxXnL8gotSYU4",
32
+ "manifest.sw.js": "sha384-qb/Yr73VTXtWXo055Ff4oKPsdbz+nSwF66KAGxSIlu9hlNYCfOOOkm6ychI9qWaG",
33
33
  "manifest.tabs.js": "sha384-otU09H7jnawVKQdLAYpMCd3jx00tgyPVr42D2hLIBzN5dG4se505YesavdnMqEi1",
34
34
  "manifest.tailwind.js": "sha384-yuP3LEvWU+QVjxjkZ0YhErtC9RrGmhOmHjjFjhS9obqZbp5/KTIEnSR0CXDvHE0B",
35
35
  "manifest.toasts.js": "sha384-UpOz9fAdGeGUhL0NamBg5iPepEfIy73p9HYdcxfOQC5b7CVsl7Our0skdZzaLNcC",
@@ -275,6 +275,20 @@
275
275
  }
276
276
  ]
277
277
  },
278
+ "retry": {
279
+ "description": "Retries for transient load failures (network, timeouts, 5xx, 429) before $error shows, on API, Appwrite table and bucket sources. false turns them off; default { attempts: 3, delay: 500 } (ms, backing off).",
280
+ "oneOf": [
281
+ { "type": "boolean", "enum": [false] },
282
+ {
283
+ "type": "object",
284
+ "properties": {
285
+ "attempts": { "type": "integer", "minimum": 0 },
286
+ "delay": { "type": "number", "minimum": 0 }
287
+ },
288
+ "additionalProperties": false
289
+ }
290
+ ]
291
+ },
278
292
  "paging": {
279
293
  "description": "Load an Appwrite table in pages that stay live. 'all' walks every page (up to max, default 5000); 'window' loads the first page (size, default 100, at most 4999) and $more() appends the next.",
280
294
  "oneOf": [
@@ -16,7 +16,7 @@
16
16
 
17
17
  // Build stamps the published version here; unstamped (dev) falls back to the
18
18
  // registration URL's `v`, then 'dev'.
19
- const BUILD_VERSION = '0.5.278';
19
+ const BUILD_VERSION = '0.5.280';
20
20
  const CACHE_PREFIX = 'mnfst-sw:';
21
21
  const META_CACHE = CACHE_PREFIX + 'meta';
22
22
  // Sized to hold a full precache.json warm-up (PRECACHE_MAX_ENTRIES server-side)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mnfst",
3
- "version": "0.5.278",
3
+ "version": "0.5.280",
4
4
  "private": false,
5
5
  "workspaces": [
6
6
  "templates/starter",