mnfst 0.5.317 → 0.5.318
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/lib/manifest.appwrite.data.js +1 -1
- package/lib/manifest.data.js +46 -10
- package/lib/manifest.data.min.js +1 -1
- package/lib/manifest.data.min.js.map +1 -1
- package/lib/manifest.integrity.json +8 -8
- package/lib/manifest.js +2 -2
- package/lib/manifest.min.js +1 -1
- package/lib/manifest.modules.integrity.json +5 -5
- package/lib/manifest.sw.js +1 -1
- package/lib/manifest.sw.min.js +1 -1
- package/package.json +2 -1
package/lib/manifest.data.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
(function () {
|
|
4
4
|
|
|
5
|
-
const MANIFEST_BUILD_VERSION = '0.5.
|
|
5
|
+
const MANIFEST_BUILD_VERSION = '0.5.318';
|
|
6
6
|
|
|
7
7
|
/* Manifest Data Sources - Configuration */
|
|
8
8
|
|
|
@@ -839,8 +839,9 @@ function updateStore(dataSourceName, data, options = {}) {
|
|
|
839
839
|
|
|
840
840
|
// Network landing (page load, paged append, realtime batch): buffered, applied
|
|
841
841
|
// with every other landing of the same frame in ONE flush. Resolves once visible.
|
|
842
|
+
// Resolves true once applied, false when skipped (stale generation, or a newer read began)
|
|
842
843
|
function landRows(dataSourceName, rows, options = {}) {
|
|
843
|
-
if (isStaleWrite(dataSourceName, options)) return Promise.resolve();
|
|
844
|
+
if (isStaleWrite(dataSourceName, options)) return Promise.resolve(false);
|
|
844
845
|
return queueLanding({ source: dataSourceName, rows, options: { mode: 'replace', ...options } });
|
|
845
846
|
}
|
|
846
847
|
|
|
@@ -891,6 +892,7 @@ function flushLandings() {
|
|
|
891
892
|
const store = typeof Alpine !== 'undefined' ? Alpine.store('data') : null;
|
|
892
893
|
const touched = new Set();
|
|
893
894
|
const landed = new Set(); // network-origin landings (persistence snapshots these)
|
|
895
|
+
const skipped = new Set();
|
|
894
896
|
let settled = false;
|
|
895
897
|
if (store) {
|
|
896
898
|
for (const op of ops) {
|
|
@@ -899,6 +901,8 @@ function flushLandings() {
|
|
|
899
901
|
if (removeRows(store, op.source, op.remove)) { touched.add(op.source); landed.add(op.source); }
|
|
900
902
|
continue;
|
|
901
903
|
}
|
|
904
|
+
// A newer read began since this landing was queued (e.g. an identity change): it never applies
|
|
905
|
+
if (typeof op.options?.readToken === 'number' && !isLatestRead(op.source, op.options.readToken)) { skipped.add(op); continue; }
|
|
902
906
|
const state = writeSource(op.source, op.rows, op.options);
|
|
903
907
|
if (!state) continue;
|
|
904
908
|
touched.add(op.source);
|
|
@@ -911,7 +915,7 @@ function flushLandings() {
|
|
|
911
915
|
}
|
|
912
916
|
for (const source of [...touched]) {
|
|
913
917
|
const reads = ops
|
|
914
|
-
.filter(op => op.source === source && typeof op.options?.readToken === 'number' && Array.isArray(op.rows))
|
|
918
|
+
.filter(op => op.source === source && !skipped.has(op) && typeof op.options?.readToken === 'number' && Array.isArray(op.rows))
|
|
915
919
|
.map(op => ({ token: op.options.readToken, ids: op.options.mode === 'append' ? new Set(op.rows.map(rowKey)) : null }));
|
|
916
920
|
reapplyPending(store, source, reads);
|
|
917
921
|
}
|
|
@@ -928,7 +932,7 @@ function flushLandings() {
|
|
|
928
932
|
}
|
|
929
933
|
if (touched.size) touchSources(store, touched);
|
|
930
934
|
}
|
|
931
|
-
resolvers.forEach(resolve => resolve());
|
|
935
|
+
resolvers.forEach((resolve, i) => resolve(!skipped.has(ops[i])));
|
|
932
936
|
if (landed.size) window.ManifestDataPersist?.onLanded?.(landed);
|
|
933
937
|
if (settled) checkAndDispatchRenderReady();
|
|
934
938
|
}
|
|
@@ -11127,6 +11131,9 @@ function setupAuthResetListener() {
|
|
|
11127
11131
|
if (clear) {
|
|
11128
11132
|
window.ManifestDataRealtime?.unsubscribeFromDataSource?.(name);
|
|
11129
11133
|
ds.resetSource(name);
|
|
11134
|
+
} else if (ds.dataSourceCache) {
|
|
11135
|
+
// Rows read under the previous identity never serve a lazy read while this reload runs
|
|
11136
|
+
for (const key of [...ds.dataSourceCache.keys()]) if (key.startsWith(`${name}:`)) ds.dataSourceCache.delete(key);
|
|
11130
11137
|
}
|
|
11131
11138
|
const handler = active && window.ManifestDataProxiesAppwrite?.createAppwriteMethodsHandler?.(name, reloadDataSource);
|
|
11132
11139
|
if (handler) Promise.resolve(handler('$query', active)).catch(() => { /* $error carries it */ });
|
|
@@ -11661,7 +11668,11 @@ async function loadMoreOnce(dataSourceName) {
|
|
|
11661
11668
|
}
|
|
11662
11669
|
// Overtaken by a load or $query: its window replaces the rows, then this runs again
|
|
11663
11670
|
if (!page || !isCurrent()) { if (page) requeueMore(dataSourceName); return 0; }
|
|
11664
|
-
|
|
11671
|
+
// Skipped (a newer read began): the cursor stays; this runs again after that read
|
|
11672
|
+
if (await landRows(dataSourceName, page.rows, { mode: 'append', generation, readToken: read, order: state.order || undefined }) === false) {
|
|
11673
|
+
if (sourceGeneration(dataSourceName) === generation) requeueMore(dataSourceName);
|
|
11674
|
+
return 0;
|
|
11675
|
+
}
|
|
11665
11676
|
setPagingState(dataSourceName, { ...page, spec }, { append: true });
|
|
11666
11677
|
return page.rows.length;
|
|
11667
11678
|
} finally {
|
|
@@ -12024,6 +12035,14 @@ function liveLocale() {
|
|
|
12024
12035
|
|| 'en';
|
|
12025
12036
|
}
|
|
12026
12037
|
|
|
12038
|
+
// cacheKey → { identity, bound, abandoned, replacement } of the load in flight
|
|
12039
|
+
const loadIdentities = new Map();
|
|
12040
|
+
|
|
12041
|
+
// Callers and joiners of an abandoned load get the fresh load's result
|
|
12042
|
+
function followReplacement(load, promise) {
|
|
12043
|
+
return load ? promise.then(value => (load.abandoned && load.replacement) ? load.replacement : value) : promise;
|
|
12044
|
+
}
|
|
12045
|
+
|
|
12027
12046
|
// Load dataSource data. options.reload: bypass the memory cache and refetch;
|
|
12028
12047
|
// existing rows stay live ($loading only), fresh rows merge by $id.
|
|
12029
12048
|
async function loadDataSource(dataSourceName, locale = 'en', options = {}) {
|
|
@@ -12059,11 +12078,23 @@ async function loadDataSource(dataSourceName, locale = 'en', options = {}) {
|
|
|
12059
12078
|
.then(() => loadDataSource(dataSourceName, locale, { ...options, issuedRead: issued }));
|
|
12060
12079
|
}
|
|
12061
12080
|
|
|
12081
|
+
// A reload under another identity than the load in flight started with never joins it:
|
|
12082
|
+
// that load is abandoned (never lands, binds or saves) and a fresh one starts
|
|
12083
|
+
let replaced = loadIdentities.get(cacheKey);
|
|
12084
|
+
const inflight = replaced;
|
|
12085
|
+
if (options.reload && inflight && loadingPromises.has(cacheKey) && inflight.bound !== false
|
|
12086
|
+
&& confirmedIdentity() !== null && inflight.identity !== confirmedIdentity()) {
|
|
12087
|
+
inflight.abandoned = true;
|
|
12088
|
+
loadingPromises.delete(cacheKey);
|
|
12089
|
+
dataSourceCache.delete(cacheKey);
|
|
12090
|
+
window.ManifestDataStore.loadReadTokens?.delete(cacheKey);
|
|
12091
|
+
} else replaced = null;
|
|
12092
|
+
|
|
12062
12093
|
// In flight for this source+locale: share it (every entry path lands here);
|
|
12063
12094
|
// joining makes it the latest read again
|
|
12064
12095
|
if (loadingPromises.has(cacheKey)) {
|
|
12065
12096
|
window.ManifestDataStore.adoptRead?.(dataSourceName, window.ManifestDataStore.loadReadTokens?.get(cacheKey));
|
|
12066
|
-
return loadingPromises.get(cacheKey);
|
|
12097
|
+
return followReplacement(loadIdentities.get(cacheKey), loadingPromises.get(cacheKey));
|
|
12067
12098
|
}
|
|
12068
12099
|
|
|
12069
12100
|
// Reads are ordered by call: a $query issued after this load wins over it
|
|
@@ -12085,9 +12116,11 @@ async function loadDataSource(dataSourceName, locale = 'en', options = {}) {
|
|
|
12085
12116
|
else updateStore(dataSourceName, null, { loading: true, error: null, ready: false });
|
|
12086
12117
|
}
|
|
12087
12118
|
|
|
12088
|
-
// Scope reset (persistence) during this load → its result is discarded
|
|
12119
|
+
// Scope reset (persistence) or a reload under another identity during this load → its result is discarded
|
|
12089
12120
|
const generation = sourceGeneration ? sourceGeneration(dataSourceName) : 0;
|
|
12090
|
-
const
|
|
12121
|
+
const load = { identity: confirmedIdentity(), bound: undefined, abandoned: false, replacement: null };
|
|
12122
|
+
loadIdentities.set(cacheKey, load);
|
|
12123
|
+
const superseded = () => load.abandoned || (sourceGeneration && sourceGeneration(dataSourceName) !== generation);
|
|
12091
12124
|
|
|
12092
12125
|
// Unresolvable scope (signed out, or teamless): settle empty, not $loading forever; auth events reload.
|
|
12093
12126
|
// A pending sign-in holds the source unsettled (one render-ready), bounded by its deadline.
|
|
@@ -12135,6 +12168,7 @@ async function loadDataSource(dataSourceName, locale = 'en', options = {}) {
|
|
|
12135
12168
|
// This prevents warnings for test references that might exist in HTML
|
|
12136
12169
|
return null;
|
|
12137
12170
|
}
|
|
12171
|
+
load.bound = isIdentityBound(dataSource);
|
|
12138
12172
|
|
|
12139
12173
|
// Get bucketId early to check if this is a bucket (needed for data enhancement)
|
|
12140
12174
|
const bucketId = window.ManifestDataConfig.getAppwriteBucketId?.(dataSource) || null;
|
|
@@ -12485,9 +12519,11 @@ async function loadDataSource(dataSourceName, locale = 'en', options = {}) {
|
|
|
12485
12519
|
if (!landed && keepRows && !isInitializing && !superseded()) setSourceState(dataSourceName, { loading: false });
|
|
12486
12520
|
}
|
|
12487
12521
|
});
|
|
12488
|
-
const done = () => { settled(); deferredLoads.delete(cacheKey); };
|
|
12522
|
+
const done = () => { settled(); deferredLoads.delete(cacheKey); if (loadIdentities.get(cacheKey) === load) loadIdentities.delete(cacheKey); };
|
|
12489
12523
|
run.then(done, done);
|
|
12490
|
-
|
|
12524
|
+
const result = followReplacement(load, run);
|
|
12525
|
+
if (replaced) replaced.replacement = result;
|
|
12526
|
+
return result;
|
|
12491
12527
|
}
|
|
12492
12528
|
|
|
12493
12529
|
// $reload(): fetch again what the source shows — its active $query, else its default
|