@ai-matrx/records-ui 0.110.5 → 0.110.7
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/CHANGELOG.md +12 -0
- package/dist/first-page.cjs +229 -41
- package/dist/first-page.cjs.map +1 -1
- package/dist/first-page.d.cts +14 -3
- package/dist/first-page.d.ts +14 -3
- package/dist/first-page.js +230 -43
- package/dist/first-page.js.map +1 -1
- package/dist/index.cjs +34 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +34 -10
- package/dist/index.js.map +1 -1
- package/dist/pickers.cjs +23 -3
- package/dist/pickers.cjs.map +1 -1
- package/dist/pickers.js +23 -3
- package/dist/pickers.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1093,12 +1093,33 @@ function inColumnWords(error, fields) {
|
|
|
1093
1093
|
|
|
1094
1094
|
// src/askOnce.ts
|
|
1095
1095
|
var asked = /* @__PURE__ */ new WeakMap();
|
|
1096
|
-
|
|
1096
|
+
var byPerson = /* @__PURE__ */ new WeakMap();
|
|
1097
|
+
function heldFor(client) {
|
|
1098
|
+
const config = client.config;
|
|
1099
|
+
const source = config?.dataSource;
|
|
1100
|
+
if (source && typeof source === "object" && config?.actor) {
|
|
1101
|
+
const who = [config.actor.actor ?? "-", config.actor.user_id ?? "-", config.actor.on_behalf_of ?? "-"].join("|");
|
|
1102
|
+
let persons = byPerson.get(source);
|
|
1103
|
+
if (!persons) {
|
|
1104
|
+
persons = /* @__PURE__ */ new Map();
|
|
1105
|
+
byPerson.set(source, persons);
|
|
1106
|
+
}
|
|
1107
|
+
let held2 = persons.get(who);
|
|
1108
|
+
if (!held2) {
|
|
1109
|
+
held2 = /* @__PURE__ */ new Map();
|
|
1110
|
+
persons.set(who, held2);
|
|
1111
|
+
}
|
|
1112
|
+
return held2;
|
|
1113
|
+
}
|
|
1097
1114
|
let held = asked.get(client);
|
|
1098
1115
|
if (!held) {
|
|
1099
1116
|
held = /* @__PURE__ */ new Map();
|
|
1100
1117
|
asked.set(client, held);
|
|
1101
1118
|
}
|
|
1119
|
+
return held;
|
|
1120
|
+
}
|
|
1121
|
+
function askOnce(client, key, ask, freshMs) {
|
|
1122
|
+
const held = heldFor(client);
|
|
1102
1123
|
const now = Date.now();
|
|
1103
1124
|
const kept = held.get(key);
|
|
1104
1125
|
if (kept && now - kept.at <= freshMs) return kept.answer;
|
|
@@ -1116,8 +1137,7 @@ function askOnce(client, key, ask, freshMs) {
|
|
|
1116
1137
|
return answer;
|
|
1117
1138
|
}
|
|
1118
1139
|
function forgetAsked(client, prefix) {
|
|
1119
|
-
const held =
|
|
1120
|
-
if (!held) return;
|
|
1140
|
+
const held = heldFor(client);
|
|
1121
1141
|
for (const key of [...held.keys()]) if (key.startsWith(prefix)) held.delete(key);
|
|
1122
1142
|
}
|
|
1123
1143
|
var FIELD_OPTIONS_FRESH_MS = 2e3;
|
|
@@ -2773,6 +2793,12 @@ function asRefusal(thrown, sentence2, remedy, code = "internal") {
|
|
|
2773
2793
|
return refusalFromThrown(thrown, sentence2, remedy, code);
|
|
2774
2794
|
}
|
|
2775
2795
|
|
|
2796
|
+
// src/rowVersion.ts
|
|
2797
|
+
function ownVersion(row) {
|
|
2798
|
+
const v = row.version;
|
|
2799
|
+
return typeof v === "number" ? v : null;
|
|
2800
|
+
}
|
|
2801
|
+
|
|
2776
2802
|
// src/recordVersions.ts
|
|
2777
2803
|
var STALE_MOVE_LABEL = "Changed by someone else";
|
|
2778
2804
|
var VERSION_UNREAD_LABEL = "Could not check for changes";
|
|
@@ -2789,10 +2815,6 @@ function isVersionUnread(error) {
|
|
|
2789
2815
|
function isChangedElsewhere(error) {
|
|
2790
2816
|
return error?.code === "stale_write";
|
|
2791
2817
|
}
|
|
2792
|
-
function ownVersion(row) {
|
|
2793
|
-
const v = row.version;
|
|
2794
|
-
return typeof v === "number" ? v : null;
|
|
2795
|
-
}
|
|
2796
2818
|
function signatureOf(row) {
|
|
2797
2819
|
const own3 = ownVersion(row);
|
|
2798
2820
|
if (own3 !== null) return `v${own3}`;
|
|
@@ -2802,6 +2824,7 @@ function signatureOf(row) {
|
|
|
2802
2824
|
return String(Math.random());
|
|
2803
2825
|
}
|
|
2804
2826
|
}
|
|
2827
|
+
var HEADERS_SHARED_MS = 3e3;
|
|
2805
2828
|
function useRecordVersions(client, rows, mayRead) {
|
|
2806
2829
|
const versions = useRef4(/* @__PURE__ */ new Map());
|
|
2807
2830
|
const drawn = useRef4(/* @__PURE__ */ new Map());
|
|
@@ -2819,7 +2842,7 @@ function useRecordVersions(client, rows, mayRead) {
|
|
|
2819
2842
|
unread.current.delete(id);
|
|
2820
2843
|
};
|
|
2821
2844
|
const readHeaders = useCallback2(
|
|
2822
|
-
(toRead) => {
|
|
2845
|
+
(toRead, shared = false) => {
|
|
2823
2846
|
if (toRead.length === 0) return;
|
|
2824
2847
|
generation.current += 1;
|
|
2825
2848
|
const gen = generation.current;
|
|
@@ -2827,7 +2850,8 @@ function useRecordVersions(client, rows, mayRead) {
|
|
|
2827
2850
|
versions.current.delete(id);
|
|
2828
2851
|
unread.current.add(id);
|
|
2829
2852
|
};
|
|
2830
|
-
const
|
|
2853
|
+
const asking = shared ? askOnce(client, `record_headers:${toRead.join(",")}`, () => client.recordHeaders({ ids: toRead }), HEADERS_SHARED_MS) : client.recordHeaders({ ids: toRead });
|
|
2854
|
+
const read = asking.then(
|
|
2831
2855
|
(res) => {
|
|
2832
2856
|
const found = /* @__PURE__ */ new Set();
|
|
2833
2857
|
if (res.ok) {
|
|
@@ -2860,7 +2884,7 @@ function useRecordVersions(client, rows, mayRead) {
|
|
|
2860
2884
|
if (own3 !== null) raise(row.id, own3);
|
|
2861
2885
|
else toRead.push(row.id);
|
|
2862
2886
|
}
|
|
2863
|
-
readHeaders(toRead);
|
|
2887
|
+
readHeaders(toRead, true);
|
|
2864
2888
|
}, [readHeaders, key]);
|
|
2865
2889
|
const refresh = useCallback2((ids) => readHeaders([...ids]), [readHeaders]);
|
|
2866
2890
|
const seen = useCallback2(async (id) => {
|