mnfst 0.5.325 → 0.5.326
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 +156 -73
- 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 +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.326';
|
|
6
6
|
|
|
7
7
|
/* Manifest Data Sources - Configuration */
|
|
8
8
|
|
|
@@ -479,8 +479,11 @@ function bumpAllVersions(only) {
|
|
|
479
479
|
touchSources(store, sources);
|
|
480
480
|
}
|
|
481
481
|
|
|
482
|
+
const isDateValue = (value) => Object.prototype.toString.call(value) === '[object Date]';
|
|
483
|
+
|
|
482
484
|
function sameScalarOrList(a, b) {
|
|
483
485
|
if (a === b) return true;
|
|
486
|
+
if (isDateValue(a) && isDateValue(b)) return a.getTime() === b.getTime();
|
|
484
487
|
if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) return false;
|
|
485
488
|
for (let i = 0; i < a.length; i++) {
|
|
486
489
|
const x = a[i];
|
|
@@ -1119,6 +1122,9 @@ function createReactiveReferences(data, dataSourceName = null) {
|
|
|
1119
1122
|
return data.map(item => createReactiveReferences(item, dataSourceName));
|
|
1120
1123
|
}
|
|
1121
1124
|
|
|
1125
|
+
// A date (YAML sources parse them) stays a date: copied key by key it would become {}
|
|
1126
|
+
if (isDateValue(data)) return new Date(data.getTime());
|
|
1127
|
+
|
|
1122
1128
|
if (typeof data === 'object') {
|
|
1123
1129
|
// Object.keys, not for…in + .hasOwnProperty (see deepSeal). Hot path for
|
|
1124
1130
|
// every Appwrite mutation result and realtime event.
|
|
@@ -1976,6 +1982,7 @@ window.ManifestDataStore = {
|
|
|
1976
1982
|
const STORE_NAME = 'sources';
|
|
1977
1983
|
const DB_VERSION = 1;
|
|
1978
1984
|
const WRITE_DEBOUNCE_MS = 500;
|
|
1985
|
+
const WRITE_MAX_WAIT_MS = 5000; // a source landing more often than the debounce still snapshots
|
|
1979
1986
|
const BOOT_HYDRATE_MAX_WAIT_MS = 100;
|
|
1980
1987
|
const DEFAULT_TTL_MS = 7 * 24 * 60 * 60 * 1000;
|
|
1981
1988
|
const DEFAULT_MAX_ROWS = 1000;
|
|
@@ -2005,6 +2012,7 @@ window.ManifestDataStore = {
|
|
|
2005
2012
|
scope: '',
|
|
2006
2013
|
generation: 0,
|
|
2007
2014
|
pending: new Map(), // source -> time its debounced write is due
|
|
2015
|
+
pendingSince: new Map(), // source -> when its unwritten landings began
|
|
2008
2016
|
landedIdentity: new Map(), // source -> identity its pending rows were read under
|
|
2009
2017
|
writeTimer: null,
|
|
2010
2018
|
hydrated: new Set(), // sources hydrated (or attempted) this generation
|
|
@@ -2470,7 +2478,7 @@ window.ManifestDataStore = {
|
|
|
2470
2478
|
// Every source whose debounce has elapsed is written in ONE transaction
|
|
2471
2479
|
function flush(sources) {
|
|
2472
2480
|
const landedIdentity = new Map(sources.map(source => [source, state.landedIdentity.get(source)]));
|
|
2473
|
-
for (const source of sources) { state.pending.delete(source); state.landedIdentity.delete(source); }
|
|
2481
|
+
for (const source of sources) { state.pending.delete(source); state.pendingSince.delete(source); state.landedIdentity.delete(source); }
|
|
2474
2482
|
if (!state.enabled || state.disabled) return Promise.resolve();
|
|
2475
2483
|
const records = sources.map(source => snapshotRecord(source, landedIdentity.get(source))).filter(Boolean);
|
|
2476
2484
|
if (!records.length) return Promise.resolve();
|
|
@@ -2504,20 +2512,22 @@ window.ManifestDataStore = {
|
|
|
2504
2512
|
}
|
|
2505
2513
|
|
|
2506
2514
|
function cancelWrites(source) {
|
|
2507
|
-
if (source !== undefined) { state.pending.delete(source); state.landedIdentity.delete(source); return; }
|
|
2515
|
+
if (source !== undefined) { state.pending.delete(source); state.pendingSince.delete(source); state.landedIdentity.delete(source); return; }
|
|
2508
2516
|
state.pending.clear();
|
|
2517
|
+
state.pendingSince.clear();
|
|
2509
2518
|
state.landedIdentity.clear();
|
|
2510
2519
|
if (state.writeTimer !== null) { clearTimeout(state.writeTimer); state.writeTimer = null; }
|
|
2511
2520
|
}
|
|
2512
2521
|
|
|
2513
|
-
// Landing hook (store flush): each landing restarts that source's 500ms debounce
|
|
2522
|
+
// Landing hook (store flush): each landing restarts that source's 500ms debounce, up to the maximum wait
|
|
2514
2523
|
function onLanded(sources) {
|
|
2515
2524
|
if (!state.enabled || state.disabled || state.scopePending) return; // nothing is keyed under an unresolved scope
|
|
2516
|
-
const
|
|
2525
|
+
const now = Date.now();
|
|
2517
2526
|
const identity = hydrationIdentity();
|
|
2518
2527
|
for (const source of sources) {
|
|
2519
2528
|
if (!state.sources.has(source)) continue;
|
|
2520
|
-
state.
|
|
2529
|
+
if (!state.pendingSince.has(source)) state.pendingSince.set(source, now);
|
|
2530
|
+
state.pending.set(source, Math.min(now + WRITE_DEBOUNCE_MS, state.pendingSince.get(source) + WRITE_MAX_WAIT_MS));
|
|
2521
2531
|
if (state.sources.get(source).authDependent) state.landedIdentity.set(source, identity);
|
|
2522
2532
|
}
|
|
2523
2533
|
if (state.writeTimer !== null) { clearTimeout(state.writeTimer); state.writeTimer = null; }
|
|
@@ -2702,6 +2712,7 @@ window.ManifestDataStore = {
|
|
|
2702
2712
|
window.ManifestDataPersist = {
|
|
2703
2713
|
BOOT_HYDRATE_MAX_WAIT_MS,
|
|
2704
2714
|
WRITE_DEBOUNCE_MS,
|
|
2715
|
+
WRITE_MAX_WAIT_MS,
|
|
2705
2716
|
configure,
|
|
2706
2717
|
register,
|
|
2707
2718
|
setScope,
|
|
@@ -4682,11 +4693,56 @@ function untracked(fn) {
|
|
|
4682
4693
|
return out;
|
|
4683
4694
|
}
|
|
4684
4695
|
|
|
4696
|
+
const IDENTITY = (value) => value;
|
|
4697
|
+
const toRaw = (value) => (value && typeof Alpine !== 'undefined' && Alpine.raw ? Alpine.raw(value) : value);
|
|
4698
|
+
|
|
4699
|
+
// Operators read raw rows (no proxy traps, no dependency bookkeeping) and hand back the rows the array holds:
|
|
4700
|
+
// live (reactive) ones when the array itself is, so bindings on a result row still update
|
|
4701
|
+
function operatorRows(array) {
|
|
4702
|
+
const base = toRaw(array);
|
|
4703
|
+
const live = base !== array && typeof Alpine !== 'undefined' && !!Alpine.reactive;
|
|
4704
|
+
// Already raw rows on a raw array: nothing to unwrap or map back
|
|
4705
|
+
if (!live && (base.length === 0 || (toRaw(base[0]) === base[0] && toRaw(base[base.length - 1]) === base[base.length - 1]))) {
|
|
4706
|
+
return { raws: base, out: IDENTITY };
|
|
4707
|
+
}
|
|
4708
|
+
const raws = new Array(base.length);
|
|
4709
|
+
let back = null;
|
|
4710
|
+
for (let i = 0; i < base.length; i++) {
|
|
4711
|
+
const item = base[i];
|
|
4712
|
+
const raw = toRaw(item);
|
|
4713
|
+
raws[i] = raw;
|
|
4714
|
+
if (raw !== item) (back || (back = new Map())).set(raw, item);
|
|
4715
|
+
}
|
|
4716
|
+
const out = (raw) => {
|
|
4717
|
+
if (raw === null || typeof raw !== 'object') return raw;
|
|
4718
|
+
if (back && back.has(raw)) return back.get(raw);
|
|
4719
|
+
return live ? Alpine.reactive(raw) : raw;
|
|
4720
|
+
};
|
|
4721
|
+
return { raws, out };
|
|
4722
|
+
}
|
|
4723
|
+
|
|
4724
|
+
const SEARCH_SEP = '\u0000';
|
|
4725
|
+
const isDate = (value) => Object.prototype.toString.call(value) === '[object Date]';
|
|
4726
|
+
|
|
4727
|
+
// Searchable text of a field: scalars, dates and lists of them (a plain object would read "[object Object]")
|
|
4728
|
+
function searchText(value, depth = 0) {
|
|
4729
|
+
if (value == null) return '';
|
|
4730
|
+
if (typeof value !== 'object') return String(value).toLowerCase();
|
|
4731
|
+
if (isDate(value)) return String(value).toLowerCase();
|
|
4732
|
+
if (!Array.isArray(value) || depth > 3) return '';
|
|
4733
|
+
let text = '';
|
|
4734
|
+
for (const part of value) {
|
|
4735
|
+
const piece = searchText(part, depth + 1);
|
|
4736
|
+
if (piece) text += (text ? ',' : '') + piece;
|
|
4737
|
+
}
|
|
4738
|
+
return text;
|
|
4739
|
+
}
|
|
4740
|
+
|
|
4685
4741
|
function memoOp(array, dataSourceName, op, args, compute) {
|
|
4686
4742
|
const version = sourceVersion(dataSourceName);
|
|
4687
|
-
if (version === undefined) return compute();
|
|
4743
|
+
if (version === undefined) return compute(null);
|
|
4688
4744
|
const argsKey = stableStringify(args);
|
|
4689
|
-
if (argsKey === undefined) return compute();
|
|
4745
|
+
if (argsKey === undefined) return compute(null);
|
|
4690
4746
|
const raw = Alpine.raw ? Alpine.raw(array) : array;
|
|
4691
4747
|
let entry = opCaches.get(raw);
|
|
4692
4748
|
if (!entry || entry.v !== version) {
|
|
@@ -4701,7 +4757,7 @@ function memoOp(array, dataSourceName, op, args, compute) {
|
|
|
4701
4757
|
map.set(key, hit);
|
|
4702
4758
|
return hit;
|
|
4703
4759
|
}
|
|
4704
|
-
const result = untracked(compute);
|
|
4760
|
+
const result = untracked(() => compute(entry));
|
|
4705
4761
|
map.set(key, result);
|
|
4706
4762
|
if (map.size > OP_CACHE_MAX) map.delete(map.keys().next().value);
|
|
4707
4763
|
return result;
|
|
@@ -4822,12 +4878,13 @@ function attachArrayMethods(array, dataSourceName, reloadDataSource) {
|
|
|
4822
4878
|
return array;
|
|
4823
4879
|
}
|
|
4824
4880
|
|
|
4825
|
-
return memoOp(array, dataSourceName, 'search', [searchTerm, ...attributes], () => runSearch(searchTerm, attributes));
|
|
4881
|
+
return memoOp(array, dataSourceName, 'search', [searchTerm, ...attributes], (memo) => runSearch(searchTerm, attributes, memo));
|
|
4826
4882
|
}
|
|
4827
4883
|
});
|
|
4828
4884
|
|
|
4829
|
-
function runSearch(searchTerm, attributes) {
|
|
4885
|
+
function runSearch(searchTerm, attributes, memo) {
|
|
4830
4886
|
const term = searchTerm.toLowerCase().trim();
|
|
4887
|
+
const { raws, out } = operatorRows(array);
|
|
4831
4888
|
|
|
4832
4889
|
// Weighted mode: $search(term, { title: 3, body: 1 }) — ranks by the
|
|
4833
4890
|
// best-matching field's weight per whitespace-separated term (prefix
|
|
@@ -4837,16 +4894,14 @@ function attachArrayMethods(array, dataSourceName, reloadDataSource) {
|
|
|
4837
4894
|
const fields = Object.keys(first);
|
|
4838
4895
|
const terms = term.split(/\s+/).filter(Boolean);
|
|
4839
4896
|
const scored = [];
|
|
4840
|
-
for (const item of
|
|
4897
|
+
for (const item of raws) {
|
|
4841
4898
|
if (!item || typeof item !== 'object') continue;
|
|
4842
4899
|
let total = 0, ok = true;
|
|
4843
4900
|
for (const t of terms) {
|
|
4844
4901
|
let best = 0;
|
|
4845
4902
|
for (const f of fields) {
|
|
4846
|
-
const
|
|
4847
|
-
if (
|
|
4848
|
-
const s = String(v).toLowerCase();
|
|
4849
|
-
if (!s.includes(t)) continue;
|
|
4903
|
+
const s = searchText(item[f]);
|
|
4904
|
+
if (!s || !s.includes(t)) continue;
|
|
4850
4905
|
let w = Number(first[f]) || 0;
|
|
4851
4906
|
if (s.startsWith(t)) w *= 1.2;
|
|
4852
4907
|
if (w > best) best = w;
|
|
@@ -4857,21 +4912,40 @@ function attachArrayMethods(array, dataSourceName, reloadDataSource) {
|
|
|
4857
4912
|
if (ok) scored.push([total, item]);
|
|
4858
4913
|
}
|
|
4859
4914
|
scored.sort((a, b) => b[0] - a[0]);
|
|
4860
|
-
const ranked = scored.map(e => e[1]);
|
|
4915
|
+
const ranked = scored.map(e => out(e[1]));
|
|
4861
4916
|
attachArrayMethods(ranked, dataSourceName, reloadDataSource);
|
|
4862
4917
|
return ranked;
|
|
4863
4918
|
}
|
|
4864
4919
|
|
|
4865
|
-
const attrs = attributes.length > 0 ? attributes : Object.keys(
|
|
4920
|
+
const attrs = attributes.length > 0 ? attributes : Object.keys(raws[0] || {}).filter(key => key !== '$files');
|
|
4866
4921
|
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
}
|
|
4922
|
+
// One lowercase string per row, kept for this source version and checked against the row it was
|
|
4923
|
+
// built from (an array changed in place re-reads the rows that moved): a keystroke is one includes() per row
|
|
4924
|
+
const rowText = (item) => {
|
|
4925
|
+
if (!item || typeof item !== 'object') return null;
|
|
4926
|
+
let text = '';
|
|
4927
|
+
for (const attr of attrs) text += searchText(item[attr]) + SEARCH_SEP;
|
|
4928
|
+
return text;
|
|
4929
|
+
};
|
|
4930
|
+
const hays = memo && !term.includes(SEARCH_SEP) ? (memo.hay || (memo.hay = new Map())) : null;
|
|
4931
|
+
const hayKey = hays ? attrs.map(String).join(SEARCH_SEP) : '';
|
|
4932
|
+
let hay = hays ? hays.get(hayKey) : null;
|
|
4933
|
+
if (!hay) {
|
|
4934
|
+
hay = { rows: [], text: [] };
|
|
4935
|
+
if (hays) {
|
|
4936
|
+
if (hays.size >= 4) hays.delete(hays.keys().next().value);
|
|
4937
|
+
hays.set(hayKey, hay);
|
|
4938
|
+
}
|
|
4939
|
+
}
|
|
4940
|
+
hay.rows.length = hay.text.length = raws.length;
|
|
4941
|
+
|
|
4942
|
+
const filtered = [];
|
|
4943
|
+
for (let i = 0; i < raws.length; i++) {
|
|
4944
|
+
const item = raws[i];
|
|
4945
|
+
if (hay.rows[i] !== item) { hay.rows[i] = item; hay.text[i] = rowText(item); }
|
|
4946
|
+
const text = hay.text[i];
|
|
4947
|
+
if (text !== null && text !== undefined && text.includes(term)) filtered.push(out(item));
|
|
4948
|
+
}
|
|
4875
4949
|
|
|
4876
4950
|
// Re-attach so chaining works (.$search().$query())
|
|
4877
4951
|
attachArrayMethods(filtered, dataSourceName, reloadDataSource);
|
|
@@ -5005,14 +5079,18 @@ function attachArrayMethods(array, dataSourceName, reloadDataSource) {
|
|
|
5005
5079
|
return array;
|
|
5006
5080
|
}
|
|
5007
5081
|
// orderRandom reshuffles per call — never memoized
|
|
5008
|
-
if (queries.some(q => Array.isArray(q) && q[0] === 'orderRandom'))
|
|
5082
|
+
if (queries.some(q => Array.isArray(q) && q[0] === 'orderRandom')) {
|
|
5083
|
+
void sourceVersion(dataSourceName); // still re-runs the caller when the source changes
|
|
5084
|
+
return runQuery(queries);
|
|
5085
|
+
}
|
|
5009
5086
|
return memoOp(array, dataSourceName, 'query', [queries], () => runQuery(queries));
|
|
5010
5087
|
}
|
|
5011
5088
|
});
|
|
5012
5089
|
}
|
|
5013
5090
|
|
|
5014
5091
|
function runQuery(queries) {
|
|
5015
|
-
|
|
5092
|
+
const { raws, out } = operatorRows(array);
|
|
5093
|
+
let result = raws;
|
|
5016
5094
|
|
|
5017
5095
|
// Process each query in order
|
|
5018
5096
|
for (const query of queries) {
|
|
@@ -5064,6 +5142,7 @@ function attachArrayMethods(array, dataSourceName, reloadDataSource) {
|
|
|
5064
5142
|
// Sorting methods
|
|
5065
5143
|
else if (method === 'orderAsc' && args.length >= 1) {
|
|
5066
5144
|
const [attr] = args;
|
|
5145
|
+
if (result === raws) result = raws.slice();
|
|
5067
5146
|
result.sort((a, b) => {
|
|
5068
5147
|
const aVal = a && a[attr];
|
|
5069
5148
|
const bVal = b && b[attr];
|
|
@@ -5077,6 +5156,7 @@ function attachArrayMethods(array, dataSourceName, reloadDataSource) {
|
|
|
5077
5156
|
});
|
|
5078
5157
|
} else if (method === 'orderDesc' && args.length >= 1) {
|
|
5079
5158
|
const [attr] = args;
|
|
5159
|
+
if (result === raws) result = raws.slice();
|
|
5080
5160
|
result.sort((a, b) => {
|
|
5081
5161
|
const aVal = a && a[attr];
|
|
5082
5162
|
const bVal = b && b[attr];
|
|
@@ -5089,6 +5169,7 @@ function attachArrayMethods(array, dataSourceName, reloadDataSource) {
|
|
|
5089
5169
|
return aVal > bVal ? -1 : aVal < bVal ? 1 : 0;
|
|
5090
5170
|
});
|
|
5091
5171
|
} else if (method === 'orderRandom') {
|
|
5172
|
+
if (result === raws) result = raws.slice();
|
|
5092
5173
|
// Fisher-Yates shuffle
|
|
5093
5174
|
for (let i = result.length - 1; i > 0; i--) {
|
|
5094
5175
|
const j = Math.floor(Math.random() * (i + 1));
|
|
@@ -5105,6 +5186,7 @@ function attachArrayMethods(array, dataSourceName, reloadDataSource) {
|
|
|
5105
5186
|
}
|
|
5106
5187
|
}
|
|
5107
5188
|
|
|
5189
|
+
result = out === IDENTITY ? (result === raws ? raws.slice() : result) : result.map(out);
|
|
5108
5190
|
// Re-attach so chaining works (.$query().$search())
|
|
5109
5191
|
attachArrayMethods(result, dataSourceName, reloadDataSource);
|
|
5110
5192
|
|
|
@@ -6847,6 +6929,14 @@ function createComputedFilesArray(tableName, entryId, bucketName, columnName = '
|
|
|
6847
6929
|
? Alpine.reactive({ value: null })
|
|
6848
6930
|
: { value: null };
|
|
6849
6931
|
|
|
6932
|
+
// Position of a row in a source by $id (cached index; -1 when absent)
|
|
6933
|
+
const positionOf = (rows, id) => {
|
|
6934
|
+
const ds = window.ManifestDataStore;
|
|
6935
|
+
const raw = ds?.rawOf ? ds.rawOf(rows) : rows;
|
|
6936
|
+
if (ds?.indexOfRow) return ds.indexOfRow(raw, id);
|
|
6937
|
+
return raw.findIndex(row => row && row.$id === id);
|
|
6938
|
+
};
|
|
6939
|
+
|
|
6850
6940
|
// Function to recompute files array from bucket and entry's fileIds
|
|
6851
6941
|
const recomputeFiles = () => {
|
|
6852
6942
|
try {
|
|
@@ -6882,7 +6972,8 @@ function createComputedFilesArray(tableName, entryId, bucketName, columnName = '
|
|
|
6882
6972
|
return;
|
|
6883
6973
|
}
|
|
6884
6974
|
|
|
6885
|
-
const
|
|
6975
|
+
const entryAt = positionOf(entries, entryId);
|
|
6976
|
+
const entry = entryAt === -1 ? null : entries[entryAt];
|
|
6886
6977
|
if (!entry) {
|
|
6887
6978
|
computedFiles.length = 0;
|
|
6888
6979
|
loadingState.value = bucketLoading;
|
|
@@ -6899,10 +6990,14 @@ function createComputedFilesArray(tableName, entryId, bucketName, columnName = '
|
|
|
6899
6990
|
return;
|
|
6900
6991
|
}
|
|
6901
6992
|
|
|
6902
|
-
//
|
|
6903
|
-
const
|
|
6904
|
-
|
|
6905
|
-
|
|
6993
|
+
// The entry's files, in bucket order
|
|
6994
|
+
const positions = [];
|
|
6995
|
+
for (const id of new Set(fileIds)) {
|
|
6996
|
+
const at = positionOf(bucketFiles, id);
|
|
6997
|
+
if (at !== -1) positions.push(at);
|
|
6998
|
+
}
|
|
6999
|
+
positions.sort((a, b) => a - b);
|
|
7000
|
+
const filteredFiles = positions.map(at => bucketFiles[at]);
|
|
6906
7001
|
|
|
6907
7002
|
// Update computed array (maintains reactivity)
|
|
6908
7003
|
computedFiles.length = 0;
|
|
@@ -6919,74 +7014,61 @@ function createComputedFilesArray(tableName, entryId, bucketName, columnName = '
|
|
|
6919
7014
|
}
|
|
6920
7015
|
};
|
|
6921
7016
|
|
|
6922
|
-
//
|
|
7017
|
+
// Started on first read: a row whose $files nobody reads costs no effect.
|
|
7018
|
+
// Tracks the table and bucket membership (length), the entry's fileIds and the bucket state.
|
|
6923
7019
|
let filesEffect = null;
|
|
6924
|
-
|
|
7020
|
+
let started = false;
|
|
7021
|
+
const start = () => {
|
|
7022
|
+
if (started) return;
|
|
7023
|
+
started = true;
|
|
7024
|
+
if (typeof Alpine === 'undefined' || !Alpine.effect) { recomputeFiles(); return; }
|
|
6925
7025
|
filesEffect = Alpine.effect(() => {
|
|
6926
|
-
// Access store to track changes
|
|
6927
7026
|
const store = Alpine.store('data');
|
|
6928
7027
|
if (!store) {
|
|
6929
7028
|
recomputeFiles();
|
|
6930
7029
|
return;
|
|
6931
7030
|
}
|
|
6932
7031
|
|
|
6933
|
-
|
|
6934
|
-
|
|
6935
|
-
|
|
7032
|
+
const rows = store[tableName];
|
|
7033
|
+
if (owner && Array.isArray(rows)) {
|
|
7034
|
+
void rows.length;
|
|
7035
|
+
const raw = Alpine.raw ? Alpine.raw(rows) : rows;
|
|
7036
|
+
const at = positionOf(rows, entryId);
|
|
7037
|
+
const held = at === -1 ? null : raw[at];
|
|
7038
|
+
// Another row may hold the same $id for a moment (a rebuilt row): then look for this one itself
|
|
7039
|
+
if ((Alpine.raw && held ? Alpine.raw(held) : held) !== owner && !raw.includes(owner)) {
|
|
6936
7040
|
queueMicrotask(() => { if (filesEffect) Alpine.release(filesEffect); });
|
|
6937
7041
|
return;
|
|
6938
7042
|
}
|
|
6939
7043
|
}
|
|
6940
7044
|
|
|
6941
|
-
// Track bucket array changes - access the array itself and iterate to track all elements
|
|
6942
7045
|
const bucketFiles = store[bucketName];
|
|
6943
|
-
if (
|
|
6944
|
-
// Access length and iterate to track all file changes
|
|
6945
|
-
const _ = bucketFiles.length;
|
|
6946
|
-
// Iterate through files to track individual file changes
|
|
6947
|
-
bucketFiles.forEach(file => {
|
|
6948
|
-
if (file && file.$id) {
|
|
6949
|
-
const __ = file.$id; // Track file ID changes
|
|
6950
|
-
}
|
|
6951
|
-
});
|
|
6952
|
-
}
|
|
7046
|
+
if (Array.isArray(bucketFiles)) void bucketFiles.length;
|
|
6953
7047
|
|
|
6954
|
-
|
|
6955
|
-
|
|
6956
|
-
|
|
6957
|
-
const
|
|
6958
|
-
if (
|
|
6959
|
-
|
|
6960
|
-
|
|
6961
|
-
if (Array.isArray(fileIds)) {
|
|
6962
|
-
const _ = fileIds.length;
|
|
6963
|
-
// Iterate through fileIds to track individual ID changes
|
|
6964
|
-
fileIds.forEach(id => {
|
|
6965
|
-
const __ = id; // Track individual fileId changes
|
|
6966
|
-
});
|
|
6967
|
-
}
|
|
7048
|
+
if (Array.isArray(rows)) {
|
|
7049
|
+
const at = positionOf(rows, entryId);
|
|
7050
|
+
const entry = at === -1 ? null : rows[at];
|
|
7051
|
+
const fileIds = entry ? entry[columnName] : null;
|
|
7052
|
+
if (Array.isArray(fileIds)) {
|
|
7053
|
+
void fileIds.length;
|
|
7054
|
+
for (let i = 0; i < fileIds.length; i++) void fileIds[i];
|
|
6968
7055
|
}
|
|
6969
7056
|
}
|
|
6970
7057
|
|
|
6971
|
-
// Track bucket loading state
|
|
6972
7058
|
const bucketState = store[`_${bucketName}_state`];
|
|
6973
7059
|
if (bucketState) {
|
|
6974
|
-
|
|
6975
|
-
|
|
7060
|
+
void bucketState.loading;
|
|
7061
|
+
void bucketState.error;
|
|
6976
7062
|
}
|
|
6977
7063
|
|
|
6978
|
-
// Recompute files after tracking all dependencies
|
|
6979
7064
|
recomputeFiles();
|
|
6980
7065
|
});
|
|
6981
|
-
}
|
|
6982
|
-
|
|
6983
|
-
// Initial computation
|
|
6984
|
-
recomputeFiles();
|
|
7066
|
+
};
|
|
6985
7067
|
|
|
6986
7068
|
// Create proxy that adds loading/error properties
|
|
6987
7069
|
const computedProxy = new Proxy(computedFiles, {
|
|
6988
7070
|
get(target, key) {
|
|
6989
|
-
if (key !== 'toJSON') requestInline();
|
|
7071
|
+
if (key !== 'toJSON') { requestInline(); start(); }
|
|
6990
7072
|
if (key === '$loading') return loadingState.value;
|
|
6991
7073
|
if (key === '$error') return errorState.value;
|
|
6992
7074
|
if (key === Symbol.iterator) return target[Symbol.iterator].bind(target);
|
|
@@ -6998,6 +7080,7 @@ function createComputedFilesArray(tableName, entryId, bucketName, columnName = '
|
|
|
6998
7080
|
},
|
|
6999
7081
|
has(target, key) {
|
|
7000
7082
|
requestInline();
|
|
7083
|
+
start();
|
|
7001
7084
|
return key in target || key === '$loading' || key === '$error';
|
|
7002
7085
|
}
|
|
7003
7086
|
});
|