mnfst 0.5.294 → 0.5.296

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.294';
5
+ const MANIFEST_BUILD_VERSION = '0.5.296';
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
@@ -194,13 +194,13 @@ export interface ManifestAppwriteBucketOps {
194
194
  $remove(fileId: string): Promise<void>;
195
195
  $delete(fileId: string | string[]): Promise<unknown>;
196
196
  $duplicate(fileId: string, options?: { newName?: string; newFileId?: string }): Promise<ManifestFile>;
197
- $filesFor(parentId: string, fieldName?: string): ManifestFile[];
197
+ $filesFor(tableName: string, entryId: string, fileIdsColumn?: string): Promise<ManifestFile[]>;
198
198
  $first(limit?: number): Promise<ManifestCursorPage<ManifestFile>>;
199
199
  $next(cursor: string, limit?: number): Promise<ManifestCursorPage<ManifestFile>>;
200
200
  $prev(cursor: string, limit?: number): Promise<ManifestCursorPage<ManifestFile>>;
201
201
  $page(page: number, limit?: number): Promise<ManifestOffsetPage<ManifestFile>>;
202
- $unlinkFrom(parentId: string, fileId: string): Promise<void>;
203
- $removeFrom(parentId: string, fileId: string): Promise<void>;
202
+ $unlinkFrom(tableName: string, entryId: string, file: string | { $id: string }, fileIdsColumn?: string): Promise<void>;
203
+ $removeFrom(tableName: string, entryId: string, file: string | { $id: string }, fileIdsColumn?: string): Promise<ManifestFile[] | null>;
204
204
  }
205
205
 
206
206
  /**
@@ -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.294';
5
+ const MANIFEST_BUILD_VERSION = '0.5.296';
6
6
 
7
7
  /* Manifest Data Sources - Configuration */
8
8
 
@@ -7518,11 +7518,16 @@ function queueEntryFileWrite(tableName, entryId, fileIdsColumn, write) {
7518
7518
 
7519
7519
  // Link a file to a table entry by adding the file ID to the entry's fileIds array
7520
7520
  // Generic function - works with any table and any scope
7521
- function linkFileToEntry(tableName, entryId, fileId, fileIdsColumn = 'fileIds') {
7522
- return queueEntryFileWrite(tableName, entryId, fileIdsColumn, () => writeFileLink(tableName, entryId, fileId, fileIdsColumn));
7521
+ // The table's generation is captured at the call, so a queued write never lands for a later identity
7522
+ function linkFileToEntry(tableName, entryId, fileId, fileIdsColumn = 'fileIds', options = {}) {
7523
+ const isCurrent = identityGuard(tableName, options.isCurrent);
7524
+ return queueEntryFileWrite(tableName, entryId, fileIdsColumn, () => writeFileLink(tableName, entryId, fileId, fileIdsColumn, { ...options, isCurrent }));
7523
7525
  }
7524
7526
 
7525
- async function writeFileLink(tableName, entryId, fileId, fileIdsColumn) {
7527
+ // options.isCurrent: false once the identity that started the write is gone
7528
+ async function writeFileLink(tableName, entryId, fileId, fileIdsColumn, options = {}) {
7529
+ const stale = () => !!options.isCurrent && !options.isCurrent();
7530
+ if (stale()) return false;
7526
7531
  const manifest = await window.ManifestDataConfig.ensureManifest();
7527
7532
  const tableDataSource = manifest?.data?.[tableName];
7528
7533
 
@@ -7544,6 +7549,8 @@ async function writeFileLink(tableName, entryId, fileId, fileIdsColumn) {
7544
7549
  entryId
7545
7550
  );
7546
7551
 
7552
+ if (stale()) return false;
7553
+
7547
7554
  if (!entry) {
7548
7555
  throw new Error(`[Manifest Data] Entry "${entryId}" not found in table "${tableName}"`);
7549
7556
  }
@@ -7748,10 +7755,13 @@ function fileIdOf(id) {
7748
7755
  return id && typeof id === 'object' ? id.$id : id;
7749
7756
  }
7750
7757
 
7751
- // True while the source's generation (bumped on sign-out / account switch) and the caller's guard hold
7758
+ // True while the identity epoch and the source's generation (both bumped on sign-out / account switch) and the caller's guard hold
7752
7759
  function identityGuard(dataSourceName, outer) {
7760
+ const epoch = window.ManifestDataMain?.identityEpoch?.() ?? 0;
7753
7761
  const generation = window.ManifestDataStore?.sourceGeneration?.(dataSourceName);
7754
- return () => (!outer || outer()) && window.ManifestDataStore?.sourceGeneration?.(dataSourceName) === generation;
7762
+ return () => (!outer || outer())
7763
+ && (window.ManifestDataMain?.identityEpoch?.() ?? 0) === epoch
7764
+ && window.ManifestDataStore?.sourceGeneration?.(dataSourceName) === generation;
7755
7765
  }
7756
7766
 
7757
7767
  // options.isCurrent: false once the identity that started the write is gone
@@ -8315,6 +8325,11 @@ function createAppwriteMethodsHandler(dataSourceName, reloadDataSource) {
8315
8325
  } else if (method === '$duplicate') {
8316
8326
  const [entryId, options = {}] = args;
8317
8327
  const { files = 'same', newRowId, ...overrides } = options;
8328
+ // The copy (and its file links) lands only for the identity that read the original
8329
+ const isCurrent = window.ManifestDataProxiesFiles?.identityGuard?.(dataSourceName) || (() => true);
8330
+ const stopIfStale = () => {
8331
+ if (!isCurrent()) throw new Error('[Manifest Data] $duplicate stopped: the signed-in user changed');
8332
+ };
8318
8333
 
8319
8334
  // Get the original entry
8320
8335
  const originalEntry = await window.ManifestDataAppwrite.getTableRow(
@@ -8384,6 +8399,7 @@ function createAppwriteMethodsHandler(dataSourceName, reloadDataSource) {
8384
8399
  // Duplicate each file
8385
8400
  const newFileIds = [];
8386
8401
  for (const file of originalFiles) {
8402
+ stopIfStale();
8387
8403
  try {
8388
8404
  // Download file content
8389
8405
  const fileBlob = await window.ManifestDataAppwrite.getFileContentAsBlob(bucketId, file.$id);
@@ -8423,6 +8439,7 @@ function createAppwriteMethodsHandler(dataSourceName, reloadDataSource) {
8423
8439
  }
8424
8440
 
8425
8441
  // Create the duplicate entry using existing $create logic
8442
+ stopIfStale();
8426
8443
  return await handleMethod('$create', duplicateData, newRowId);
8427
8444
  } else if (method === '$query') {
8428
8445
  let [queries] = args;
@@ -8566,6 +8583,8 @@ function createAppwriteMethodsHandler(dataSourceName, reloadDataSource) {
8566
8583
 
8567
8584
  if (method === '$create') {
8568
8585
  let [fileId, file, permissions, onProgress] = args;
8586
+ // The entry link lands only for the identity that started the upload
8587
+ const linkCurrent = window.ManifestDataProxiesFiles?.identityGuard?.(dataSourceName, onProgress?.isCurrent) || (() => true);
8569
8588
 
8570
8589
  // Appwrite requires fileId to be provided - it doesn't auto-generate
8571
8590
  // If fileId is not provided or is a File object (first arg is file), generate one
@@ -8847,7 +8866,7 @@ function createAppwriteMethodsHandler(dataSourceName, reloadDataSource) {
8847
8866
  try {
8848
8867
  const linkFileToEntry = window.ManifestDataProxiesFiles?.linkFileToEntry;
8849
8868
  if (linkFileToEntry) {
8850
- await linkFileToEntry(tableName, entryId, result.$id, fileIdsColumn);
8869
+ await linkFileToEntry(tableName, entryId, result.$id, fileIdsColumn, { isCurrent: linkCurrent });
8851
8870
  }
8852
8871
  } catch (linkError) {
8853
8872
  // Check if error is about missing column
@@ -9387,6 +9406,8 @@ window.ManifestDataProxiesMagic.createFilesMethod = createFilesMethod;
9387
9406
 
9388
9407
  function createUploadMethod(dataSourceName, reloadDataSource) {
9389
9408
  return async function (entryId, fileOrEvent, bucketName) {
9409
+ // Links land only for the identity that started the upload
9410
+ const isCurrent = window.ManifestDataProxiesFiles?.identityGuard?.(dataSourceName);
9390
9411
  const manifest = await window.ManifestDataConfig.ensureManifest();
9391
9412
  if (!manifest?.data) {
9392
9413
  throw new Error('[Manifest Data] Manifest not available');
@@ -9490,7 +9511,8 @@ function createUploadMethod(dataSourceName, reloadDataSource) {
9490
9511
  entryId: entryId,
9491
9512
  table: dataSourceName,
9492
9513
  fileIdsColumn: resolvedColumnName,
9493
- sourceUnloaded
9514
+ sourceUnloaded,
9515
+ isCurrent
9494
9516
  }).then(result => {
9495
9517
  // Clear uploading state for this file
9496
9518
  if (clearUploadingFile) {
@@ -11434,6 +11456,8 @@ function registerFilesDirective() {
11434
11456
 
11435
11457
  // Set new timeout for debouncing
11436
11458
  loadTimeout = setTimeout(async () => {
11459
+ // The fileIds sync writes only for the identity that read them
11460
+ const isCurrent = window.ManifestDataProxiesFiles?.identityGuard?.('projects') || (() => true);
11437
11461
  // Double-check project still exists before making API call using projectId
11438
11462
  const store = Alpine.store('data');
11439
11463
  const projects = store?.projects;
@@ -11586,7 +11610,7 @@ function registerFilesDirective() {
11586
11610
  const databaseFileIdsJson = JSON.stringify(databaseFileIdsArray);
11587
11611
  const databaseIsStale = databaseFileIds && databaseFileIdsJson !== lastFileIds;
11588
11612
 
11589
- if (storeIsStale || databaseIsStale) {
11613
+ if ((storeIsStale || databaseIsStale) && isCurrent()) {
11590
11614
  console.warn('[Manifest Data] Store/Database fileIds is STALE - cleaning up:', {
11591
11615
  directiveInstanceId,
11592
11616
  projectId: currentProjectId,
@@ -11617,7 +11641,7 @@ function registerFilesDirective() {
11617
11641
  const tableId = window.ManifestDataConfig.getAppwriteTableId(tableDataSource);
11618
11642
  const appwriteConfig = await window.ManifestDataConfig.getAppwriteConfig(tableDataSource);
11619
11643
 
11620
- if (appwriteConfig && window.ManifestDataAppwrite?.updateRow) {
11644
+ if (appwriteConfig && window.ManifestDataAppwrite?.updateRow && isCurrent()) {
11621
11645
  await window.ManifestDataAppwrite.updateRow(
11622
11646
  appwriteConfig.databaseId,
11623
11647
  tableId,
@@ -12012,6 +12036,9 @@ function confirmedIdentity() {
12012
12036
  return auth.isAuthenticated === true ? (authUserId(auth) || '') : '';
12013
12037
  }
12014
12038
 
12039
+ // Bumped synchronously when an identity ends (sign-out, account switch), before any source reset; covers never-loaded sources
12040
+ let identityEpoch = 0;
12041
+
12015
12042
  // Identity change (sign-in, sign-out, account switch): identity-bound sources reload for the new identity.
12016
12043
  // A previous user's rows drop at once; rows read signed out stay live until the reload lands.
12017
12044
  function setupAuthResetListener() {
@@ -12058,6 +12085,7 @@ function setupAuthResetListener() {
12058
12085
  return;
12059
12086
  }
12060
12087
  // An identity switch (A to B) starts clean with the defaults; a first sign-in keeps the $query
12088
+ if (prev !== '') identityEpoch++;
12061
12089
  reset(prev !== '', prev === '' && next !== '');
12062
12090
  };
12063
12091
  ['manifest:auth:logout', 'manifest:auth:session-cleared', 'manifest:auth:login', 'manifest:auth:anonymous', 'manifest:auth:initialized']
@@ -13594,6 +13622,7 @@ async function initializeDataSourcesPlugin() {
13594
13622
  noteQueryIntent: (dataSourceName, queries) => queryIntents.set(dataSourceName, queries),
13595
13623
  dropQueryIntent: (dataSourceName, queries) => { if (queryIntents.get(dataSourceName) === queries) queryIntents.delete(dataSourceName); },
13596
13624
  withRetry,
13625
+ identityEpoch: () => identityEpoch,
13597
13626
  pagingSpec,
13598
13627
  fetchPagedRows,
13599
13628
  pagedWant,
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "manifest.appwrite.auth.js": "sha384-gWLSeVPqCLMiUZB8MU7GqMg3x2yULFUsp8nTTZrPp/9Dlkix42rBn9yIimvwrHqZ",
3
- "manifest.appwrite.data.js": "sha384-D4IDXhPPTWazy1vPyx9ueWuH2Y6Yf6xb4Dfs/BYeylYbMZZB8QHAnePWHrlinvS+",
3
+ "manifest.appwrite.data.js": "sha384-vdb9hvvueWGiqC3UvTLSPbDbAsBLJQrsw7DPYNSEPQaBUsQWj6JeFDYgGcomjmOo",
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-FHjyoAiA9YsEYv1ptbFBidS1QjHwZT0kPhqsaT55TlhNUnHWPLh4WQa0fc3QPvl0",
14
+ "manifest.data.js": "sha384-DQak77AJpDsrzpFYz5RhzM6xlKu7GvqVqd1BDjlEjc5V3zC3OzNE9y1u/R34AY09",
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-35dDeHB4G6W8nej4SWrNaDIlayoLDnlbK3/52ZGdBAHibtG5GwFMq5gsas+rqxfh",
32
+ "manifest.sw.js": "sha384-Ycob/D+vbscUJxYPlrhHm/E/Ig4h16w074LlBskWgWYJB0WwHA8G8yEkrTXQMPSX",
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.294';
19
+ const BUILD_VERSION = '0.5.296';
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.294",
3
+ "version": "0.5.296",
4
4
  "private": false,
5
5
  "workspaces": [
6
6
  "templates/starter",