mnfst 0.5.328 → 0.5.329
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 +60 -13
- 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.schema.json +5 -0
- package/lib/manifest.sw.js +1 -1
- package/lib/manifest.sw.min.js +1 -1
- package/package.json +1 -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.329';
|
|
6
6
|
|
|
7
7
|
/* Manifest Data Sources - Configuration */
|
|
8
8
|
|
|
@@ -410,6 +410,7 @@ function isRowPending(dataSourceName, id) {
|
|
|
410
410
|
|
|
411
411
|
// Structural edit in place: one reactive write (length to 0) wakes every reader, rows return on the raw array
|
|
412
412
|
function setRows(store, dataSourceName, next) {
|
|
413
|
+
markStructural(dataSourceName);
|
|
413
414
|
const raw = rawOf(store)[dataSourceName];
|
|
414
415
|
const cur = store[dataSourceName];
|
|
415
416
|
if (!Array.isArray(raw)) {
|
|
@@ -442,6 +443,7 @@ function removeRowAt(store, dataSourceName, index, replacement) {
|
|
|
442
443
|
|
|
443
444
|
function ensureStoreShape(store) {
|
|
444
445
|
if (!store._v) store._v = {};
|
|
446
|
+
if (!store._f) store._f = {};
|
|
445
447
|
}
|
|
446
448
|
|
|
447
449
|
// Version bump: per-source (`$x` reads subscribe here), `all`, and the legacy
|
|
@@ -458,10 +460,43 @@ function touchSources(store, sources) {
|
|
|
458
460
|
// Sync writes (they can run inside Alpine's flush) are re-bumped by the next post-settle hammer
|
|
459
461
|
const writtenSources = new Set();
|
|
460
462
|
|
|
461
|
-
|
|
463
|
+
// Granular sources (manifest.json data.<source>.granular): a change to row fields alone bumps
|
|
464
|
+
// _f[source] instead of _v[source], so readers of the list do not re-run; operator memos read both
|
|
465
|
+
const structural = new Set(); // sources whose membership or order changed in the write under way
|
|
466
|
+
function markStructural(dataSourceName) { if (dataSourceName) structural.add(dataSourceName); }
|
|
467
|
+
function isGranular(dataSourceName) {
|
|
468
|
+
try {
|
|
469
|
+
const config = window.ManifestDataConfig?.getManifest?.()?.data?.[dataSourceName];
|
|
470
|
+
return !!config && typeof config === 'object' && config.granular === true;
|
|
471
|
+
} catch (_) {
|
|
472
|
+
return false;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
function touchFields(store, sources) {
|
|
476
|
+
ensureStoreShape(store);
|
|
477
|
+
const f = store._f;
|
|
478
|
+
for (const source of sources) f[source] = (f[source] || 0) + 1;
|
|
479
|
+
f.all = (f.all || 0) + 1; // $x.all operators read these rows too
|
|
480
|
+
store._dataVersion = (store._dataVersion || 0) + 1;
|
|
481
|
+
}
|
|
482
|
+
// Bump for a finished write: fields-only where the source opted in and nothing structural happened
|
|
483
|
+
function touchWritten(store, sources) {
|
|
484
|
+
const full = [], fields = [];
|
|
485
|
+
for (const source of sources) {
|
|
486
|
+
(isGranular(source) && !structural.has(source) ? fields : full).push(source);
|
|
487
|
+
structural.delete(source);
|
|
488
|
+
}
|
|
489
|
+
if (full.length) touchSources(store, full);
|
|
490
|
+
if (fields.length) touchFields(store, fields);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
// fieldsOnly: the caller changed fields of existing rows and nothing else
|
|
494
|
+
function touchSource(dataSourceName, fieldsOnly = false) {
|
|
462
495
|
const store = typeof Alpine !== 'undefined' ? Alpine.store('data') : null;
|
|
463
496
|
writtenSources.add(dataSourceName);
|
|
464
|
-
if (
|
|
497
|
+
if (!fieldsOnly) markStructural(dataSourceName);
|
|
498
|
+
if (store) touchWritten(store, [dataSourceName]);
|
|
499
|
+
else structural.delete(dataSourceName);
|
|
465
500
|
}
|
|
466
501
|
|
|
467
502
|
// Post-settle hammer: re-run every `$x` reader (Alpine scheduler swallow)
|
|
@@ -500,7 +535,8 @@ function mergeRowFields(target, fields, dataSourceName) {
|
|
|
500
535
|
if (key === '$files') continue;
|
|
501
536
|
const value = fields[key];
|
|
502
537
|
if (sameScalarOrList(raw[key], value)) continue;
|
|
503
|
-
if (
|
|
538
|
+
if (target === raw) markStructural(dataSourceName); // not reactive: only the version can announce it
|
|
539
|
+
if (key === '$id') { dropRowIndex(rawDataStore.get(dataSourceName)); markStructural(dataSourceName); }
|
|
504
540
|
target[key] = createReactiveReferences(value, dataSourceName);
|
|
505
541
|
}
|
|
506
542
|
}
|
|
@@ -660,7 +696,7 @@ function touchPending(dataSourceName) {
|
|
|
660
696
|
function insertRow(store, dataSourceName, row) {
|
|
661
697
|
const target = store[dataSourceName];
|
|
662
698
|
const order = window.ManifestDataMain?.orderFor?.(dataSourceName);
|
|
663
|
-
if (!order) { target.push(row); extendRowIndex(rawOf(store)[dataSourceName]); return; }
|
|
699
|
+
if (!order) { markStructural(dataSourceName); target.push(row); extendRowIndex(rawOf(store)[dataSourceName]); return; }
|
|
664
700
|
insertRowAt(store, dataSourceName, sortedIndex(rawOf(store)[dataSourceName], rawOf(row), compareBy(order)), row);
|
|
665
701
|
}
|
|
666
702
|
|
|
@@ -806,7 +842,7 @@ function upsertOrdered(store, dataSourceName, rows, order) {
|
|
|
806
842
|
if (!next) next = curRaw.slice();
|
|
807
843
|
next.splice(sortedIndex(next, row, cmp), 0, rawOf(createReactiveReferences(row, dataSourceName)));
|
|
808
844
|
}
|
|
809
|
-
if (next) store[dataSourceName] = next;
|
|
845
|
+
if (next) { markStructural(dataSourceName); store[dataSourceName] = next; }
|
|
810
846
|
}
|
|
811
847
|
|
|
812
848
|
// Identity-preserving upsert by $id: existing rows are merged in place, new
|
|
@@ -816,6 +852,7 @@ function upsertRows(store, dataSourceName, rows, mode, order) {
|
|
|
816
852
|
const raw = rawOf(store);
|
|
817
853
|
const curRaw = Array.isArray(raw[dataSourceName]) ? raw[dataSourceName] : null;
|
|
818
854
|
if (!curRaw) {
|
|
855
|
+
markStructural(dataSourceName);
|
|
819
856
|
store[dataSourceName] = rows.map(row => createReactiveReferences(row, dataSourceName));
|
|
820
857
|
return;
|
|
821
858
|
}
|
|
@@ -844,8 +881,9 @@ function upsertRows(store, dataSourceName, rows, mode, order) {
|
|
|
844
881
|
(mode === 'replace' ? next : appended).push(created);
|
|
845
882
|
}
|
|
846
883
|
if (mode === 'replace') {
|
|
847
|
-
if (next.length !== curRaw.length || next.some((row, i) => row !== curRaw[i])) store[dataSourceName] = next;
|
|
884
|
+
if (next.length !== curRaw.length || next.some((row, i) => row !== curRaw[i])) { markStructural(dataSourceName); store[dataSourceName] = next; }
|
|
848
885
|
} else if (appended.length) {
|
|
886
|
+
markStructural(dataSourceName);
|
|
849
887
|
cur.push(...appended);
|
|
850
888
|
extendRowIndex(curRaw);
|
|
851
889
|
}
|
|
@@ -868,6 +906,8 @@ function writeSource(dataSourceName, data, options = {}) {
|
|
|
868
906
|
if (!store) return null;
|
|
869
907
|
ensureStoreShape(store);
|
|
870
908
|
const mode = options.mode === 'append' ? 'append' : 'replace';
|
|
909
|
+
// Loads and non-list data always announce on the list version
|
|
910
|
+
if (options.loading !== undefined || !Array.isArray(data)) markStructural(dataSourceName);
|
|
871
911
|
|
|
872
912
|
if (data === null || data === undefined) {
|
|
873
913
|
if (mode === 'replace') {
|
|
@@ -1026,6 +1066,7 @@ function flushLandings() {
|
|
|
1026
1066
|
if (startedAt) setTimeout(() => { landingEndedAt = performance.now(); landingCost = landingEndedAt - startedAt; }, 0);
|
|
1027
1067
|
const ops = pendingLandings.splice(0);
|
|
1028
1068
|
const resolvers = landingResolvers.splice(0);
|
|
1069
|
+
structural.clear();
|
|
1029
1070
|
const local = new Map(pendingLocal);
|
|
1030
1071
|
pendingLocal.clear();
|
|
1031
1072
|
if (!ops.length) return;
|
|
@@ -1059,7 +1100,7 @@ function flushLandings() {
|
|
|
1059
1100
|
const reads = ops
|
|
1060
1101
|
.filter(op => op.source === source && !skipped.has(op) && typeof op.options?.readToken === 'number' && Array.isArray(op.rows))
|
|
1061
1102
|
.map(op => ({ token: op.options.readToken, ids: op.options.mode === 'append' ? new Set(op.rows.map(rowKey)) : null }));
|
|
1062
|
-
reapplyPending(store, source, reads);
|
|
1103
|
+
if (reapplyPending(store, source, reads)) markStructural(source);
|
|
1063
1104
|
}
|
|
1064
1105
|
for (const [source, byId] of local) {
|
|
1065
1106
|
for (const [id, note] of byId) {
|
|
@@ -1071,7 +1112,7 @@ function flushLandings() {
|
|
|
1071
1112
|
if (i !== -1) { mergeRowFields(store[source][i], note.patch, source); touched.add(source); }
|
|
1072
1113
|
}
|
|
1073
1114
|
}
|
|
1074
|
-
if (touched.size)
|
|
1115
|
+
if (touched.size) touchWritten(store, touched);
|
|
1075
1116
|
}
|
|
1076
1117
|
resolvers.forEach((resolve, i) => resolve(!skipped.has(ops[i])));
|
|
1077
1118
|
if (landed.size) window.ManifestDataPersist?.onLanded?.(landed);
|
|
@@ -1371,6 +1412,7 @@ function initializeStore() {
|
|
|
1371
1412
|
_initialized: false,
|
|
1372
1413
|
_ready: false, // Flag to indicate when data is ready for Alpine evaluation
|
|
1373
1414
|
_v: {}, // Per-source versions: `$x.<source>` reads subscribe to _v[source]; _v.all for `$x.all`
|
|
1415
|
+
_f: {}, // Per-source field versions (granular sources): operator results read these too
|
|
1374
1416
|
_dataVersion: 0, // Legacy global counter, bumped once per flush for external readers
|
|
1375
1417
|
_currentUrl: window.location.pathname,
|
|
1376
1418
|
// Operation-specific loading states (for UI reactivity)
|
|
@@ -3397,7 +3439,7 @@ function updateEntryInStore(dataSourceName, entryId, updates, options = {}) {
|
|
|
3397
3439
|
const ds = window.ManifestDataStore;
|
|
3398
3440
|
ds.mergeRowFields(store[dataSourceName][index], updates, dataSourceName);
|
|
3399
3441
|
ds.noteLocalWrite(dataSourceName, entryId, { patch: updates });
|
|
3400
|
-
ds.touchSource(dataSourceName);
|
|
3442
|
+
ds.touchSource(dataSourceName, true);
|
|
3401
3443
|
clearSourceCaches(dataSourceName);
|
|
3402
3444
|
|
|
3403
3445
|
// Dispatch mutation event
|
|
@@ -4677,11 +4719,16 @@ function stableStringify(value, depth = 0) {
|
|
|
4677
4719
|
return `{${parts.join(',')}}`;
|
|
4678
4720
|
}
|
|
4679
4721
|
|
|
4680
|
-
// Reactive read of
|
|
4722
|
+
// Reactive read of the source's list and field versions: subscribes the caller
|
|
4681
4723
|
function sourceVersion(dataSourceName) {
|
|
4682
4724
|
if (!dataSourceName || typeof Alpine === 'undefined') return undefined;
|
|
4683
|
-
const
|
|
4684
|
-
|
|
4725
|
+
const store = Alpine.store('data');
|
|
4726
|
+
const v = store?._v;
|
|
4727
|
+
if (!v) return undefined;
|
|
4728
|
+
const list = v[dataSourceName];
|
|
4729
|
+
// Field-only changes of a granular source: results depend on them too
|
|
4730
|
+
const fields = store._f ? store._f[dataSourceName] : undefined;
|
|
4731
|
+
return list === undefined || fields === undefined ? list : `${list}:${fields}`;
|
|
4685
4732
|
}
|
|
4686
4733
|
|
|
4687
4734
|
// Run without tracking deps on the caller's effect (throwaway inner effect)
|