mnfst 0.5.293 → 0.5.295

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.293';
5
+ const MANIFEST_BUILD_VERSION = '0.5.295';
6
6
 
7
7
  /* Manifest Data Sources - Appwrite Integration */
8
8
 
@@ -84,7 +84,7 @@
84
84
  opacity: 0.85
85
85
  }
86
86
 
87
- /* Dense line hover dot */
87
+ /* Line hover dot */
88
88
  & circle.focus {
89
89
  pointer-events: none
90
90
  }
@@ -183,6 +183,24 @@
183
183
  try { return Alpine.store('locale')?.current || document.documentElement.lang || 'en'; } catch (_) { return 'en'; }
184
184
  }
185
185
 
186
+ // `format` (Intl.NumberFormat options) for tooltip and label values; the axis
187
+ // adds compact notation and keeps up to one decimal so ticks stay distinct.
188
+ const DIGIT_OPTS = ['minimumFractionDigits', 'maximumFractionDigits', 'minimumSignificantDigits', 'maximumSignificantDigits', 'roundingIncrement', 'roundingPriority'];
189
+ function numberFormats(cfg) {
190
+ const locale = chartLocale();
191
+ const opts = cfg.format && typeof cfg.format === 'object' && !Array.isArray(cfg.format) ? cfg.format : null;
192
+ let value = v => v, axis = { format: String };
193
+ if (opts) { try { const f = new Intl.NumberFormat(locale, opts); value = v => f.format(v); } catch (_) { } }
194
+ const ax = Object.assign({}, opts || {});
195
+ DIGIT_OPTS.forEach(k => delete ax[k]);
196
+ Object.assign(ax, { notation: 'compact', minimumFractionDigits: 0, maximumFractionDigits: 1 });
197
+ try { axis = new Intl.NumberFormat(locale, ax); } catch (_) { try { axis = new Intl.NumberFormat(locale, { notation: 'compact', maximumFractionDigits: 1 }); } catch (_) { } }
198
+ return { value, axis: t => axis.format(t) };
199
+ }
200
+
201
+ // Author `min`/`max` widen a cartesian y-domain (shared fixed scales); data still extends it.
202
+ function limit(v) { return typeof v === 'number' || (typeof v === 'string' && v.trim() !== '') ? Number(v) : NaN; }
203
+
186
204
  function configFromDom(el) {
187
205
  // Declarative authoring: <figure x-chart.line><data series="Revenue" :values="..."></data></figure>
188
206
  const cfg = { series: [], labels: [] };
@@ -428,6 +446,7 @@
428
446
  function drawChart(state) {
429
447
  const cfg = state.config; const d3 = state.d3; const el = state.el;
430
448
  if (!cfg || !d3) return;
449
+ state.nf = numberFormats(cfg);
431
450
  const width = Math.max(120, el.clientWidth || el.getBoundingClientRect().width || 600);
432
451
 
433
452
  // Maps have their own data shape, async geo deps, and aspect-based
@@ -546,8 +565,6 @@
546
565
  }
547
566
  }
548
567
  const ih = height - m.top - m.bottom;
549
- const locale = (() => { try { return Alpine.store('locale')?.current || document.documentElement.lang || 'en'; } catch (_) { return 'en'; } })();
550
- const nf = (() => { try { return new Intl.NumberFormat(locale, { notation: 'compact', maximumFractionDigits: 1 }); } catch (_) { return { format: String }; } })();
551
568
 
552
569
  const isCandle = cfg.type === 'candlestick' || cfg.type === 'ohlc';
553
570
 
@@ -565,6 +582,7 @@
565
582
  // In combo, only line/area/bar series carry plain numeric data.
566
583
  cfg.series.forEach(s => (s.data || []).forEach(v => { if (v && typeof v === 'object') return; const n = num(v, 0); if (n > yMax) yMax = n; if (n < yMin) yMin = n; }));
567
584
  }
585
+ [limit(cfg.min), limit(cfg.max)].forEach(v => { if (isFinite(v)) { if (v < yMin) yMin = v; if (v > yMax) yMax = v; } });
568
586
  if (yMax === -Infinity) yMax = 1;
569
587
  if (yMax === yMin) yMax += 1;
570
588
 
@@ -577,7 +595,7 @@
577
595
  ticks.forEach(t => {
578
596
  const yy = y(t);
579
597
  if (cfg.grid) svg('line', { x1: 0, x2: iw, y1: yy, y2: yy }, plot);
580
- if (cfg.axis) text(plot, nf.format(t), { x: -8, y: yy, 'text-anchor': 'end', 'dominant-baseline': 'central' });
598
+ if (cfg.axis) text(plot, state.nf.axis(t), { x: -8, y: yy, 'text-anchor': 'end', 'dominant-baseline': 'central' });
581
599
  });
582
600
  }
583
601
 
@@ -664,8 +682,10 @@
664
682
  const X = xScheme(cfg, d3, labels.length, iw), x = X.x, step = X.step;
665
683
  const curve = curveFor(d3, cfg.curve);
666
684
  const items = list || cfg.series.map((s, i) => ({ s, i, area: cfg.type === 'area' }));
667
- // Dense: no per-point dots; hover columns carry the tooltip instead.
685
+ // Dense or `points: false`: no per-point dots; hover columns carry the tooltip instead.
668
686
  const dense = labels.length > 1 && step < 10;
687
+ const columns = dense || cfg.points === false;
688
+ const fv = state.nf.value;
669
689
  items.forEach(({ s, i: si, area }) => {
670
690
  const color = seriesColorVar(si, s.color);
671
691
  const points = labels.map((l, i) => [x(i), y(num(s.data[i], 0))]);
@@ -677,22 +697,23 @@
677
697
  const line = d3.line().x(p => p[0]).y(p => p[1]).curve(curve);
678
698
  const lp = svg('path', { class: 'line', d: line(points), style: `--color-chart-color:${color}`, fill: 'none' }, plot);
679
699
  try { const len = lp.getTotalLength(); animate(lp, [{ strokeDashoffset: len, strokeDasharray: len }, { strokeDashoffset: 0, strokeDasharray: len }], { duration: 700 }); } catch (_) { }
680
- // points
681
700
  if (!dense) points.forEach((p, i) => {
682
- const dot = svg('circle', { cx: p[0], cy: p[1], r: 3, style: `--color-chart-color:${color}` }, plot);
683
701
  const v = num(s.data[i], 0);
684
- applyTip(dot, (s.name ? s.name + ': ' : '') + v, cfg, tipHead(cfg, labels[i]));
685
- animate(dot, [{ opacity: 0, transform: 'scale(0)' }, { opacity: 1, transform: 'scale(1)' }], { duration: 300, delay: 200 + i * 20 });
686
- if (cfg.dataLabels) dataLabel(plot, v, p[0], p[1] - 8);
702
+ if (!columns) {
703
+ const dot = svg('circle', { cx: p[0], cy: p[1], r: 3, style: `--color-chart-color:${color}` }, plot);
704
+ applyTip(dot, (s.name ? s.name + ': ' : '') + fv(v), cfg, tipHead(cfg, labels[i]));
705
+ animate(dot, [{ opacity: 0, transform: 'scale(0)' }, { opacity: 1, transform: 'scale(1)' }], { duration: 300, delay: 200 + i * 20 });
706
+ }
707
+ if (cfg.dataLabels) dataLabel(plot, fv(v), p[0], p[1] - 8);
687
708
  });
688
709
  });
689
- if (dense) {
710
+ if (columns) {
690
711
  const g = svg('g', { class: 'hover' }, plot);
691
712
  const focus = items.map(({ s, i: si }) => svg('circle', { class: 'focus', r: 3, display: 'none', style: `--color-chart-color:${seriesColorVar(si, s.color)}` }, g));
692
713
  labels.forEach((l, i) => {
693
714
  const cx = x(i);
694
715
  const hit = svg('rect', { class: 'hit', x: cx - step / 2, y: 0, width: step, height: ih, style: 'fill:transparent' }, g);
695
- applyTip(hit, cfg.series.map(s => (s.name ? s.name + ': ' : '') + num(s.data[i], 0)), cfg, tipHead(cfg, l));
716
+ applyTip(hit, cfg.series.map(s => (s.name ? s.name + ': ' : '') + fv(num(s.data[i], 0))), cfg, tipHead(cfg, l));
696
717
  const bars = (barsAt && barsAt[i]) || [];
697
718
  hit.addEventListener('mouseenter', () => {
698
719
  focus.forEach((f, k) => { f.setAttribute('cx', cx); f.setAttribute('cy', y(num(items[k].s.data[i], 0))); f.removeAttribute('display'); });
@@ -718,9 +739,9 @@
718
739
  const v = num(s.data[i], 0);
719
740
  const yTop = y(acc + v), yBot = y(acc);
720
741
  const rect = svg('rect', { x: x0(i), y: yTop, width: x0.bandwidth(), height: Math.max(0, yBot - yTop), style: `--color-chart-color:${seriesColorVar(si, s.color)}` }, plot);
721
- applyTip(rect, (s.name ? s.name + ': ' : '') + v, cfg, tipHead(cfg, l));
742
+ applyTip(rect, (s.name ? s.name + ': ' : '') + state.nf.value(v), cfg, tipHead(cfg, l));
722
743
  animateBar(rect, ih);
723
- if (cfg.dataLabels && (yBot - yTop) > 14) dataLabel(plot, v, x0(i) + x0.bandwidth() / 2, (yTop + yBot) / 2, 'middle', 'central', 'inverse');
744
+ if (cfg.dataLabels && (yBot - yTop) > 14) dataLabel(plot, state.nf.value(v), x0(i) + x0.bandwidth() / 2, (yTop + yBot) / 2, 'middle', 'central', 'inverse');
724
745
  acc += v;
725
746
  });
726
747
  });
@@ -735,9 +756,9 @@
735
756
  const yy = y(Math.max(0, v));
736
757
  const rect = svg('rect', { x: x0(i) + x1(String(k)), y: yy, width: x1.bandwidth(), height: Math.abs(y(v) - y(0)), style: `--color-chart-color:${seriesColorVar(si, s.color)}` }, plot);
737
758
  byIndex[i].push(rect);
738
- applyTip(rect, (s.name ? s.name + ': ' : '') + v, cfg, tipHead(cfg, l));
759
+ applyTip(rect, (s.name ? s.name + ': ' : '') + state.nf.value(v), cfg, tipHead(cfg, l));
739
760
  animateBar(rect, ih);
740
- if (cfg.dataLabels) dataLabel(plot, v, x0(i) + x1(String(k)) + x1.bandwidth() / 2, yy - 4);
761
+ if (cfg.dataLabels) dataLabel(plot, state.nf.value(v), x0(i) + x1(String(k)) + x1.bandwidth() / 2, yy - 4);
741
762
  });
742
763
  });
743
764
  return byIndex;
@@ -762,6 +783,7 @@
762
783
  const cfg = state.config, d3 = state.d3;
763
784
  const cs = candleData(cfg.series[0].data);
764
785
  const X = xScheme(cfg, d3, labels.length, iw), bw = X.band.bandwidth();
786
+ const fv = state.nf.value;
765
787
  cs.forEach((c, i) => {
766
788
  const cx = X.x(i);
767
789
  const up = c.c >= c.o;
@@ -769,7 +791,7 @@
769
791
  svg('line', { x1: cx, x2: cx, y1: y(c.h), y2: y(c.l) }, g);
770
792
  const yTop = Math.min(y(c.o), y(c.c)), bodyH = Math.max(1, Math.abs(y(c.c) - y(c.o)));
771
793
  const rect = svg('rect', { x: cx - bw * 0.3, y: yTop, width: bw * 0.6, height: bodyH }, g);
772
- applyTip(rect, `${labels[i]} · O ${c.o} H ${c.h} L ${c.l} C ${c.c}`, cfg);
794
+ applyTip(rect, `${labels[i]} · O ${fv(c.o)} H ${fv(c.h)} L ${fv(c.l)} C ${fv(c.c)}`, cfg);
773
795
  animate(g, [{ opacity: 0 }, { opacity: 1 }], { duration: 300, delay: i * 15 });
774
796
  });
775
797
  }
@@ -786,9 +808,9 @@
786
808
  labels.forEach((l, i) => {
787
809
  const v = num(s.data[i], 0);
788
810
  const dot = svg('circle', { class: 'scatter', cx: x(i), cy: y(v), r: 5, style: `--color-chart-color:${seriesColorVar(si, s.color)}` }, plot);
789
- applyTip(dot, (s.name ? s.name + ': ' : '') + v, cfg, tipHead(cfg, l));
811
+ applyTip(dot, (s.name ? s.name + ': ' : '') + state.nf.value(v), cfg, tipHead(cfg, l));
790
812
  animate(dot, [{ opacity: 0, transform: 'scale(0)' }, { opacity: 1, transform: 'scale(1)' }], { duration: 350, delay: i * 25 });
791
- if (cfg.dataLabels) dataLabel(plot, v, x(i), y(v) - 9);
813
+ if (cfg.dataLabels) dataLabel(plot, state.nf.value(v), x(i), y(v) - 9);
792
814
  });
793
815
  });
794
816
  }
@@ -804,8 +826,8 @@
804
826
  const arc = d3.arc().innerRadius(inner).outerRadius(r);
805
827
  pie.forEach((slice, i) => {
806
828
  const path = svg('path', { class: 'slice', d: arc(slice), style: `--color-chart-color:${seriesColorVar(i)}` }, g);
807
- applyTip(path, labels[i] + ': ' + data[i], cfg);
808
- if (cfg.dataLabels) { const c = arc.centroid(slice); dataLabel(g, data[i], c[0], c[1], 'middle', 'central', 'inverse'); }
829
+ applyTip(path, labels[i] + ': ' + state.nf.value(data[i]), cfg);
830
+ if (cfg.dataLabels) { const c = arc.centroid(slice); dataLabel(g, state.nf.value(data[i]), c[0], c[1], 'middle', 'central', 'inverse'); }
809
831
  if (!_suppressAnim && !prefersReducedMotion() && typeof path.animate === 'function') {
810
832
  path.style.transformBox = 'fill-box'; path.style.transformOrigin = 'center';
811
833
  try { path.animate([{ opacity: 0, transform: 'scale(0.85)' }, { opacity: 1, transform: 'scale(1)' }], { duration: 450, delay: i * 60, easing: 'cubic-bezier(0.22,1,0.36,1)', fill: 'backwards' }); } catch (_) { }
@@ -867,15 +889,16 @@
867
889
  const color = (cfg.series[0] && cfg.series[0].color) || 'var(--color-chart-1)';
868
890
  const valueAngle = scale(value);
869
891
  const vArc = svg('path', { class: 'gauge-value', d: arc({ startAngle: START, endAngle: valueAngle }), style: `--color-chart-color:${color}` }, ring);
870
- applyTip(vArc, (cfg.title ? cfg.title + ': ' : '') + value + unit, cfg);
892
+ const fv = state.nf.value;
893
+ applyTip(vArc, (cfg.title ? cfg.title + ': ' : '') + fv(value) + unit, cfg);
871
894
  animate(vArc, [{ opacity: 0 }, { opacity: 1 }], { duration: 500 });
872
895
 
873
896
  // Centered readout + range end labels.
874
- text(g, value + unit, { class: 'gauge-label', x: 0, y: -r * 0.12, 'text-anchor': 'middle', 'dominant-baseline': 'central' });
897
+ text(g, fv(value) + unit, { class: 'gauge-label', x: 0, y: -r * 0.12, 'text-anchor': 'middle', 'dominant-baseline': 'central' });
875
898
  if (cfg.axis) {
876
899
  const lr = r - thickness / 2;
877
- text(g, String(min), { x: -lr, y: 16, 'text-anchor': 'middle' });
878
- text(g, String(max), { x: lr, y: 16, 'text-anchor': 'middle' });
900
+ text(g, String(fv(min)), { x: -lr, y: 16, 'text-anchor': 'middle' });
901
+ text(g, String(fv(max)), { x: lr, y: 16, 'text-anchor': 'middle' });
879
902
  }
880
903
  }
881
904
 
@@ -923,9 +946,9 @@
923
946
  const v = num(r.data[ci], 0);
924
947
  const t = Math.round(((v - lo) / (hi - lo)) * 100);
925
948
  const cell = svg('rect', { class: 'heat-cell', x: x(String(c)), y: yy, width: cw, height: ch, style: `--heat:${t}%` }, cellsG);
926
- applyTip(cell, (r.name ? r.name + ' · ' : '') + c + ': ' + v, cfg);
949
+ applyTip(cell, (r.name ? r.name + ' · ' : '') + c + ': ' + state.nf.value(v), cfg);
927
950
  animate(cell, [{ opacity: 0 }, { opacity: 1 }], { duration: 300, delay: (ri + ci) * 20 });
928
- if (cfg.dataLabels) dataLabel(plot, v, x(String(c)) + x.bandwidth() / 2, yy + yb.bandwidth() / 2, 'middle', 'central', 'inverse');
951
+ if (cfg.dataLabels) dataLabel(plot, state.nf.value(v), x(String(c)) + x.bandwidth() / 2, yy + yb.bandwidth() / 2, 'middle', 'central', 'inverse');
929
952
  });
930
953
  });
931
954
 
@@ -945,9 +968,9 @@
945
968
  footer.className = 'heat-legend';
946
969
  footer.style.paddingLeft = m.left + 'px';
947
970
  footer.style.paddingRight = m.right + 'px';
948
- const a = document.createElement('span'); a.textContent = lo;
971
+ const a = document.createElement('span'); a.textContent = state.nf.value(lo);
949
972
  const bar = document.createElement('i');
950
- const b = document.createElement('span'); b.textContent = hi;
973
+ const b = document.createElement('span'); b.textContent = state.nf.value(hi);
951
974
  footer.append(a, bar, b);
952
975
  state.el.appendChild(footer);
953
976
  }
@@ -1174,7 +1197,7 @@
1174
1197
  if (v != null && v !== '') {
1175
1198
  if (numeric) { const t = Math.round((+v - lo) / (hi - lo) * 100); region.setAttribute('style', `--color-chart-color:color-mix(in oklch, var(--color-chart-heat-high) ${t}%, var(--color-chart-heat-low))`); }
1176
1199
  else { if (!(v in palette)) palette[v] = seriesColorVar(pIdx++); region.setAttribute('style', `--color-chart-color:${palette[v]}`); }
1177
- applyTip(region, name + ': ' + v, cfg);
1200
+ applyTip(region, name + ': ' + (numeric && cfg.format ? state.nf.value(+v) : v), cfg);
1178
1201
  animate(region, [{ opacity: 0 }, { opacity: 1 }], { duration: 250 });
1179
1202
  } else {
1180
1203
  applyTip(region, name, cfg);
@@ -1206,7 +1229,7 @@
1206
1229
  if (!xy) return;
1207
1230
  const label = p.label || p.name || p.city || '';
1208
1231
  const dot = svg('circle', { class: 'map-point', cx: xy[0], cy: xy[1], r: rOf(p.value), style: p.color ? `--color-chart-color:${p.color}` : '' }, plot);
1209
- applyTip(dot, label + (p.value != null ? (label ? ': ' : '') + p.value : ''), cfg);
1232
+ applyTip(dot, label + (p.value != null ? (label ? ': ' : '') + (typeof p.value === 'number' ? state.nf.value(p.value) : p.value) : ''), cfg);
1210
1233
  animate(dot, [{ opacity: 0 }, { opacity: 1 }], { duration: 250 });
1211
1234
  });
1212
1235
  }
package/lib/manifest.css CHANGED
@@ -794,7 +794,7 @@
794
794
  opacity: 0.85
795
795
  }
796
796
 
797
- /* Dense line hover dot */
797
+ /* Line hover dot */
798
798
  & circle.focus {
799
799
  pointer-events: none
800
800
  }
package/lib/manifest.d.ts CHANGED
@@ -387,6 +387,33 @@ export interface ManifestPresence {
387
387
  /** `$date(id?)` from the datepicker plugin — the picker API for the nearest (or given) instance. */
388
388
  export type ManifestDate = (id?: string) => Record<string, unknown>;
389
389
 
390
+ /** `x-chart` config object (standalone; annotate config objects with it). */
391
+ export interface ManifestChartConfig {
392
+ type?: 'line' | 'area' | 'bar' | 'combo' | 'scatter' | 'candlestick' | 'ohlc' | 'pie' | 'donut' | 'gauge' | 'heatmap' | 'gantt' | 'map' | (string & {});
393
+ labels?: unknown[];
394
+ series?: Array<{ name?: string; data?: unknown[]; color?: string; type?: string }>;
395
+ data?: unknown;
396
+ height?: number;
397
+ stacked?: boolean;
398
+ legend?: boolean;
399
+ axis?: boolean;
400
+ grid?: boolean;
401
+ tooltip?: boolean;
402
+ dataLabels?: boolean;
403
+ curve?: 'monotone' | 'linear' | 'step' | 'step-after' | 'step-before' | 'natural' | (string & {});
404
+ ticks?: Array<number | { at: number; label?: string }>;
405
+ tickAnchor?: 'start' | 'end';
406
+ /** Line/area/combo: `false` drops per-point dots; hover columns show every series at that label. Map: marker list. */
407
+ points?: boolean | Array<Record<string, unknown>>;
408
+ /** Cartesian (incl. candlestick): widens the y-axis to include it. Gauge: range start. Gantt: axis start (number or date). */
409
+ min?: number | string | Date;
410
+ /** Cartesian (incl. candlestick): widens the y-axis to include it. Gauge: range end. Gantt: axis end (number or date). */
411
+ max?: number | string | Date;
412
+ /** Intl.NumberFormat options for tooltip and data-label values; axis ticks add compact notation. */
413
+ format?: Intl.NumberFormatOptions;
414
+ [key: string]: unknown;
415
+ }
416
+
390
417
  /** `$chart(id?)` from the charts plugin — the chart API for the nearest (or given) instance. */
391
418
  export type ManifestChart = (id?: string) => Record<string, unknown>;
392
419
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  (function () {
4
4
 
5
- const MANIFEST_BUILD_VERSION = '0.5.293';
5
+ const MANIFEST_BUILD_VERSION = '0.5.295';
6
6
 
7
7
  /* Manifest Data Sources - Configuration */
8
8
 
@@ -7289,7 +7289,9 @@ function createReactiveFileManager(tableName, entryId, bucketName, columnName) {
7289
7289
 
7290
7290
  // Get files for a specific table entry (generic - works with any table)
7291
7291
  // Supports any scope (user/team/teams) - files are filtered by permissions automatically
7292
- async function getFilesForEntry(tableName, entryId, bucketId, fileIdsColumn = 'fileIds') {
7292
+ // options.isCurrent: false once the caller's identity is gone (gates the stale-id cleanup)
7293
+ async function getFilesForEntry(tableName, entryId, bucketId, fileIdsColumn = 'fileIds', options = {}) {
7294
+ const isCurrent = identityGuard(tableName, options.isCurrent);
7293
7295
  const manifest = await window.ManifestDataConfig.ensureManifest();
7294
7296
  const tableDataSource = manifest?.data?.[tableName];
7295
7297
 
@@ -7469,15 +7471,15 @@ async function getFilesForEntry(tableName, entryId, bucketId, fileIdsColumn = 'f
7469
7471
  }
7470
7472
  }
7471
7473
 
7472
- // Clean up confirmed-missing fileIds from the database entry
7473
- if (confirmedMissingFileIds.length > 0) {
7474
+ // Clean up confirmed-missing fileIds from the database entry, only for the identity that read them
7475
+ if (confirmedMissingFileIds.length > 0 && isCurrent()) {
7474
7476
  try {
7475
7477
  const unlinkFileFromEntry = window.ManifestDataProxiesFiles?.unlinkFileFromEntry;
7476
7478
  if (unlinkFileFromEntry) {
7477
7479
  // Remove all confirmed-missing fileIds in parallel
7478
7480
  await Promise.all(
7479
7481
  confirmedMissingFileIds.map(fileId =>
7480
- unlinkFileFromEntry(tableName, entryId, fileId, fileIdsColumn)
7482
+ unlinkFileFromEntry(tableName, entryId, fileId, fileIdsColumn, { isCurrent })
7481
7483
  .catch(err => {
7482
7484
  console.warn('[Manifest Data] Failed to unlink stale fileId:', {
7483
7485
  fileId,
@@ -7670,7 +7672,7 @@ async function unlinkFileFromAllEntries(fileId, options = {}) {
7670
7672
  return {};
7671
7673
  }
7672
7674
 
7673
- const fileIds = (Array.isArray(fileId) ? fileId : [fileId]).map(id => id?.$id || id).filter(Boolean);
7675
+ const fileIds = (Array.isArray(fileId) ? fileId : [fileId]).map(fileIdOf).filter(Boolean);
7674
7676
  if (!fileIds.length) {
7675
7677
  return {};
7676
7678
  }
@@ -7702,9 +7704,7 @@ async function unlinkFileFromAllEntries(fileId, options = {}) {
7702
7704
 
7703
7705
  const columns = fileLinkColumns(manifest, tableName, tableConfig, options.bucketId);
7704
7706
  const affected = new Set();
7705
- const generation = window.ManifestDataStore?.sourceGeneration?.(tableName);
7706
- const isCurrent = () => (!options.isCurrent || options.isCurrent())
7707
- && window.ManifestDataStore?.sourceGeneration?.(tableName) === generation;
7707
+ const isCurrent = identityGuard(tableName, options.isCurrent);
7708
7708
 
7709
7709
  for (const entry of entries) {
7710
7710
  for (const column of columns) {
@@ -7737,8 +7737,21 @@ async function unlinkFileFromAllEntries(fileId, options = {}) {
7737
7737
 
7738
7738
  // Unlink a file from a table entry by removing the file ID from the entry's fileIds array
7739
7739
  // Generic function - works with any table and any scope
7740
+ // The table's generation is captured at the call, so a queued write never lands for a later identity
7740
7741
  function unlinkFileFromEntry(tableName, entryId, fileId, fileIdsColumn = 'fileIds', options = {}) {
7741
- return queueEntryFileWrite(tableName, entryId, fileIdsColumn, () => writeFileUnlink(tableName, entryId, fileId, fileIdsColumn, options));
7742
+ const isCurrent = identityGuard(tableName, options.isCurrent);
7743
+ return queueEntryFileWrite(tableName, entryId, fileIdsColumn, () => writeFileUnlink(tableName, entryId, fileId, fileIdsColumn, { ...options, isCurrent }));
7744
+ }
7745
+
7746
+ // A file reference as its id (none for an object without $id)
7747
+ function fileIdOf(id) {
7748
+ return id && typeof id === 'object' ? id.$id : id;
7749
+ }
7750
+
7751
+ // True while the source's generation (bumped on sign-out / account switch) and the caller's guard hold
7752
+ function identityGuard(dataSourceName, outer) {
7753
+ const generation = window.ManifestDataStore?.sourceGeneration?.(dataSourceName);
7754
+ return () => (!outer || outer()) && window.ManifestDataStore?.sourceGeneration?.(dataSourceName) === generation;
7742
7755
  }
7743
7756
 
7744
7757
  // options.isCurrent: false once the identity that started the write is gone
@@ -7996,6 +8009,7 @@ window.ManifestDataProxiesFiles.getFilesForEntry = getFilesForEntry;
7996
8009
  window.ManifestDataProxiesFiles.linkFileToEntry = linkFileToEntry;
7997
8010
  window.ManifestDataProxiesFiles.unlinkFileFromEntry = unlinkFileFromEntry;
7998
8011
  window.ManifestDataProxiesFiles.unlinkFileFromAllEntries = unlinkFileFromAllEntries;
8012
+ window.ManifestDataProxiesFiles.identityGuard = identityGuard;
7999
8013
  window.ManifestDataProxiesFiles.buildStoragePermissions = buildStoragePermissions;
8000
8014
  window.ManifestDataProxiesFiles.reactiveFileManagers = reactiveFileManagers; // Legacy - will be removed
8001
8015
 
@@ -8483,6 +8497,9 @@ function createAppwriteMethodsHandler(dataSourceName, reloadDataSource) {
8483
8497
 
8484
8498
  // Handle storage operations
8485
8499
  if (bucketId) {
8500
+ // Link writes a call starts land only for the identity that started it
8501
+ const bucketCurrent = () => window.ManifestDataProxiesFiles?.identityGuard?.(dataSourceName) || (() => true);
8502
+
8486
8503
  // $delete / $remove: delete each file, land successes locally, then unlink them
8487
8504
  const deleteBucketFiles = async (fileId) => {
8488
8505
  const ids = (Array.isArray(fileId) ? fileId : [fileId]).map(id => id && typeof id === 'object' ? id.$id : id);
@@ -8999,7 +9016,7 @@ function createAppwriteMethodsHandler(dataSourceName, reloadDataSource) {
8999
9016
  if (!getFilesForEntry) {
9000
9017
  throw new Error('[Manifest Data] File management functions not available');
9001
9018
  }
9002
- return await getFilesForEntry(tableName, entryId, bucketId, fileIdsColumn || 'fileIds');
9019
+ return await getFilesForEntry(tableName, entryId, bucketId, fileIdsColumn || 'fileIds', { isCurrent: bucketCurrent() });
9003
9020
  } else if (method === '$preview') {
9004
9021
  const [fileId, widthOrOptions, height] = args;
9005
9022
  // Extract file ID - handle both object with $id property and string ID
@@ -9101,7 +9118,8 @@ function createAppwriteMethodsHandler(dataSourceName, reloadDataSource) {
9101
9118
  throw error;
9102
9119
  }
9103
9120
  } else if (method === '$unlinkFrom') {
9104
- const [tableName, entryId, fileId, fileIdsColumn] = args;
9121
+ const [tableName, entryId, fileRef, fileIdsColumn] = args;
9122
+ const fileId = fileRef && typeof fileRef === 'object' ? fileRef.$id : fileRef;
9105
9123
  if (!tableName || !entryId || !fileId) {
9106
9124
  throw new Error('[Manifest Data] $unlinkFrom requires table name, entry ID, and file ID');
9107
9125
  }
@@ -9109,25 +9127,27 @@ function createAppwriteMethodsHandler(dataSourceName, reloadDataSource) {
9109
9127
  if (!unlinkFileFromEntry) {
9110
9128
  throw new Error('[Manifest Data] File management functions not available');
9111
9129
  }
9112
- return await unlinkFileFromEntry(tableName, entryId, fileId.$id || fileId, fileIdsColumn || 'fileIds');
9130
+ return await unlinkFileFromEntry(tableName, entryId, fileId, fileIdsColumn || 'fileIds', { isCurrent: bucketCurrent() });
9113
9131
  } else if (method === '$removeFrom') {
9114
9132
  // Convenience method: unlink file from entry with automatic refresh
9115
9133
  // Usage: $x.assets.$removeFrom('projects', projectId, fileId)
9116
9134
  // Automatically refreshes and returns the files list for that table/entry
9117
- const [tableName, entryId, fileId, fileIdsColumn] = args;
9135
+ const [tableName, entryId, fileRef, fileIdsColumn] = args;
9136
+ const fileId = fileRef && typeof fileRef === 'object' ? fileRef.$id : fileRef;
9118
9137
  if (!tableName || !entryId || !fileId) {
9119
9138
  throw new Error('[Manifest Data] $removeFrom requires table name, entry ID, and file ID');
9120
9139
  }
9121
9140
 
9141
+ const isCurrent = bucketCurrent();
9122
9142
  const unlinkFileFromEntry = window.ManifestDataProxiesFiles?.unlinkFileFromEntry;
9123
9143
  if (unlinkFileFromEntry) {
9124
- await unlinkFileFromEntry(tableName, entryId, fileId.$id || fileId, fileIdsColumn || 'fileIds');
9144
+ await unlinkFileFromEntry(tableName, entryId, fileId, fileIdsColumn || 'fileIds', { isCurrent });
9125
9145
  }
9126
9146
 
9127
9147
  // Return the entry's refreshed files list
9128
9148
  const getFilesForEntry = window.ManifestDataProxiesFiles?.getFilesForEntry;
9129
9149
  if (getFilesForEntry) {
9130
- return await getFilesForEntry(tableName, entryId, bucketId, fileIdsColumn || 'fileIds');
9150
+ return await getFilesForEntry(tableName, entryId, bucketId, fileIdsColumn || 'fileIds', { isCurrent });
9131
9151
  }
9132
9152
  return null;
9133
9153
  } else if (method === '$remove') {
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "manifest.appwrite.auth.js": "sha384-gWLSeVPqCLMiUZB8MU7GqMg3x2yULFUsp8nTTZrPp/9Dlkix42rBn9yIimvwrHqZ",
3
- "manifest.appwrite.data.js": "sha384-0E/Yzi22qXISJBiU9WW1T221NbxCR5FZCNcvG4G71gAe2xWgf+ArI+bvGgS0B/mv",
3
+ "manifest.appwrite.data.js": "sha384-vpsdC1jM27OXG1o/Lqvy8VG1mHxTuTDM/Gid5eQ0sUYpurdugM/tV1TOQlcsq/cp",
4
4
  "manifest.appwrite.presences.js": "sha384-LINPhIPTCK+rA8zd+HPUzMSEgH6Sl2vQMEyItT97bnEE2FYGYKqjXX+CWdt6nl9z",
5
5
  "manifest.bindings.js": "sha384-lPtMf8Ykaic9gNVZKq8Scia1881ZeMAyxer3WCIkUNwwrgzGBWto1OXADUwjvORF",
6
- "manifest.charts.js": "sha384-AFbP7mQnigy7DU1s+YE30yKTeQAKfgNazhbfSNbfd9ZpLgeulZKaPi/fAq3gJHDO",
6
+ "manifest.charts.js": "sha384-cf1N+ssSR5IL2qufv8noB5QOJrSvL7J0sLKgbJmyTDl1HodQ/Bkyf/QntO6Iynvi",
7
7
  "manifest.chat.js": "sha384-8kxS2HImRVeRiarqaGiNFlCTqB7inp/y7Hn0kIPNzADl130s4JgnmJ7uCmW0Mmvt",
8
8
  "manifest.code.js": "sha384-WGPlZE5Sp9GygUzJSmCdpLyYQTgvmEKc9BQS9Hmq1VTQwkqYJzPSWibHvPekcres",
9
9
  "manifest.color.js": "sha384-tLmmr7KwPIjznXr2tJfJtuAOV9pohdr+Ojj4L4BaOZ8WngCNOPUp27Dfz47YqU2R",
@@ -11,7 +11,7 @@
11
11
  "manifest.combobox.js": "sha384-/lJo6vaxKjgnBSRs/dzkhK1dzGk3GBw8FISoNJZB70mwAVwu1k5veZyBXjOb4keS",
12
12
  "manifest.components.js": "sha384-7lu4Nw2GqpAUn63c3gYEvgfM58PYsdoPv3wzqPQfZ5bravqOY/lfE8HFKHsKflQj",
13
13
  "manifest.computed.js": "sha384-GYML/e81gQfN+iDbqhPUgny8bINCyL+SrbTofoGk4hlCnLLjv51mCv42JMqq+ku5",
14
- "manifest.data.js": "sha384-C56SScwt4+3951hiFRRlPZyrCYcNs7kDPNVgFQzf5+LZJ7ze3gl1ODNYQwFahHNY",
14
+ "manifest.data.js": "sha384-MY08UMqVNj9XO7Lwlu5amMRPzjFWrjEKRN5cryNUn8NW5BrjfW67WAc2a9theuJd",
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-p8Rlt/o2cOPzgeSnTbLKyh3iC9VHw+CwkiTn4pcmuIsQV3yyncLd9NmWAju4fEkr",
32
+ "manifest.sw.js": "sha384-bhlRTHccsPyrkKyzpejm386tYIklNr3ZQrMqCkZiVnv576W/kzqtAh8BMyBrSVnr",
33
33
  "manifest.tabs.js": "sha384-otU09H7jnawVKQdLAYpMCd3jx00tgyPVr42D2hLIBzN5dG4se505YesavdnMqEi1",
34
34
  "manifest.tailwind.js": "sha384-yuP3LEvWU+QVjxjkZ0YhErtC9RrGmhOmHjjFjhS9obqZbp5/KTIEnSR0CXDvHE0B",
35
35
  "manifest.toasts.js": "sha384-UpOz9fAdGeGUhL0NamBg5iPepEfIy73p9HYdcxfOQC5b7CVsl7Our0skdZzaLNcC",
@@ -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.293';
19
+ const BUILD_VERSION = '0.5.295';
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.293",
3
+ "version": "0.5.295",
4
4
  "private": false,
5
5
  "workspaces": [
6
6
  "templates/starter",