@septkit/ui 0.0.84 → 0.0.86

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.
Files changed (12) hide show
  1. package/dist/dialecte/create-document-store.js +4 -4
  2. package/dist/external/.pnpm/{@dialecte_core@0.10.0/node_modules/@dialecte/core/dist/dialecte-CVLWSkgW.js → @dialecte_core@0.11.0/node_modules/@dialecte/core/dist/dialecte-Cs_XRP4I.js} +281 -270
  3. package/dist/external/.pnpm/@dialecte_core@0.11.0/node_modules/@dialecte/core/dist/index.js +6 -0
  4. package/dist/external/.pnpm/{@dialecte_core@0.10.0/node_modules/@dialecte/core/dist/running-operations-DCKvzlU7.js → @dialecte_core@0.11.0/node_modules/@dialecte/core/dist/open-connections-D59wm6nb.js} +33 -33
  5. package/dist/external/.pnpm/{@dialecte_core@0.10.0/node_modules/@dialecte/core/dist/project-key-2ccZ-0gu.js → @dialecte_core@0.11.0/node_modules/@dialecte/core/dist/project-key-sr4wkl2Q.js} +2 -1
  6. package/dist/external/.pnpm/{@dialecte_core@0.10.0 → @dialecte_core@0.11.0}/node_modules/@dialecte/core/dist/rolldown-runtime-CYdcPHCu.js +1 -1
  7. package/dist/external/.pnpm/{@dialecte_core@0.10.0/node_modules/@dialecte/core/dist/same-json-value-_AChwM_n.js → @dialecte_core@0.11.0/node_modules/@dialecte/core/dist/same-json-value-boJ4pSRe.js} +382 -192
  8. package/dist/external/.pnpm/{@dialecte_core@0.10.0 → @dialecte_core@0.11.0}/node_modules/@dialecte/core/dist/utils-Cv4oHia0.js +1 -1
  9. package/package.json +3 -3
  10. package/dist/external/.pnpm/@dialecte_core@0.10.0/node_modules/@dialecte/core/dist/index.js +0 -6
  11. /package/dist/external/.pnpm/{@dialecte_core@0.10.0 → @dialecte_core@0.11.0}/node_modules/@dialecte/core/dist/helpers-D8p0KiJu.js +0 -0
  12. /package/dist/external/.pnpm/{@dialecte_core@0.10.0 → @dialecte_core@0.11.0}/node_modules/@dialecte/core/dist/utils.js +0 -0
@@ -1,27 +1,28 @@
1
1
  import { G as e, V as t, W as n, f as r, j as i, k as a, z as o } from "./utils-Cv4oHia0.js";
2
2
  import { n as s, t as c } from "./rolldown-runtime-CYdcPHCu.js";
3
- import { A as l, B as u, K as d, L as f, M as p, P as m, V as h, a as g, c as _, f as v, m as y, o as b, p as x, s as S } from "./project-key-2ccZ-0gu.js";
3
+ import { A as l, B as u, K as d, L as f, M as p, P as m, V as h, a as g, c as _, f as v, m as y, o as b, p as x, s as S } from "./project-key-sr4wkl2Q.js";
4
4
  import { l as C } from "./helpers-D8p0KiJu.js";
5
- //#region node_modules/.pnpm/@dialecte+core@0.10.0/node_modules/@dialecte/core/dist/same-json-value-_AChwM_n.js
6
- function w(e) {
5
+ //#region node_modules/.pnpm/@dialecte+core@0.11.0/node_modules/@dialecte/core/dist/same-json-value-boJ4pSRe.js
6
+ var w = 1e3, T = "start";
7
+ function E(e) {
7
8
  let { documents: t, writeId: n, isRunning: r } = e, i = t.find((e) => e.writeId === n);
8
9
  return i ? i.status === "importing" ? r?.({ writeId: n }) === !1 ? "not-applied" : "running" : "applied" : "not-applied";
9
10
  }
10
- function T(e) {
11
- let { documents: t, writeId: n, committed: r, isRunning: i } = e, a = w({
11
+ function D(e) {
12
+ let { documents: t, writeId: n, committed: r, isRunning: i } = e, a = E({
12
13
  documents: t,
13
14
  writeId: n,
14
15
  isRunning: i
15
16
  });
16
17
  return a === "not-applied" ? r ? "applied" : "not-applied" : a;
17
18
  }
18
- var E = 1024, D = /[\p{Cc}\p{Cf}\p{Zl}\p{Zp}]/u, O = [
19
+ var O = 1024, k = /[\p{Cc}\p{Cf}\p{Zl}\p{Zp}]/u, A = [
19
20
  "name",
20
21
  "path",
21
22
  "metadata"
22
- ], k = ".xml";
23
- function A(e) {
24
- let { path: t } = e, n = R({ path: t });
23
+ ], j = ".xml";
24
+ function M(e) {
25
+ let { path: t } = e, n = B({ path: t });
25
26
  n !== void 0 && u({
26
27
  path: t,
27
28
  reason: n
@@ -32,12 +33,12 @@ function A(e) {
32
33
  fileName: r.pop()
33
34
  };
34
35
  }
35
- function j(e) {
36
+ function N(e) {
36
37
  let { extensions: t } = e;
37
- return t.includes(".xml") ? t : [...t, k];
38
+ return t.includes(".xml") ? t : [...t, j];
38
39
  }
39
- function M(e) {
40
- let { path: t, extensions: n } = e, { fileName: r } = A({ path: t }), i = r.lastIndexOf(".");
40
+ function P(e) {
41
+ let { path: t, extensions: n } = e, { fileName: r } = M({ path: t }), i = r.lastIndexOf(".");
41
42
  return (i < 1 || i === r.length - 1) && u({
42
43
  path: t,
43
44
  reason: "its file name has no extension after a name"
@@ -49,10 +50,10 @@ function M(e) {
49
50
  extension: r.slice(i)
50
51
  };
51
52
  }
52
- function N(e) {
53
+ function F(e) {
53
54
  let { name: t, extension: n, path: r } = e.document;
54
55
  if (r === void 0) return;
55
- let { fileName: i } = A({ path: r });
56
+ let { fileName: i } = M({ path: r });
56
57
  (typeof t != "string" || typeof n != "string") && u({
57
58
  path: r,
58
59
  reason: "a path names a file of a name and an extension that are strings"
@@ -61,29 +62,29 @@ function N(e) {
61
62
  reason: `it does not end with the document's file name ${JSON.stringify(`${t}${n}`)}`
62
63
  });
63
64
  }
64
- function P(e) {
65
- let { document: t } = e, n = Object.fromEntries(O.filter((t) => e.updates[t] !== void 0).map((t) => [t, e.updates[t]])), r = {
65
+ function I(e) {
66
+ let { document: t } = e, n = Object.fromEntries(A.filter((t) => e.updates[t] !== void 0).map((t) => [t, e.updates[t]])), r = {
66
67
  ...t,
67
68
  ...n
68
69
  };
69
70
  if (n.path !== void 0) {
70
- let { fileName: e } = A({ path: n.path }), { extension: i } = t;
71
+ let { fileName: e } = M({ path: n.path }), { extension: i } = t;
71
72
  e.endsWith(i) && e.length !== i.length || u({
72
73
  path: n.path,
73
74
  reason: `it does not end with the document's extension ${JSON.stringify(i)}`
74
75
  }), r.name = n.name ?? e.slice(0, e.length - i.length);
75
76
  } else if (n.name !== void 0 && t.path !== void 0) {
76
- let { folders: e } = A({ path: t.path });
77
+ let { folders: e } = M({ path: t.path });
77
78
  r.path = [...e, `${n.name}${t.extension}`].join("/");
78
79
  }
79
- return (n.path !== void 0 || n.name !== void 0) && N({ document: r }), r;
80
+ return (n.path !== void 0 || n.name !== void 0) && F({ document: r }), r;
80
81
  }
81
- function F(e) {
82
+ function L(e) {
82
83
  let { document: t, documents: n } = e;
83
- N({ document: t });
84
+ F({ document: t });
84
85
  let { id: r, path: i } = t;
85
86
  if (i === void 0) return;
86
- let a = I({
87
+ let a = R({
87
88
  path: i,
88
89
  documents: n,
89
90
  documentId: r
@@ -94,22 +95,22 @@ function F(e) {
94
95
  takenBy: a
95
96
  });
96
97
  }
97
- function I(e) {
98
+ function R(e) {
98
99
  let { path: t, documents: n, documentId: r } = e;
99
- return n.find((e) => e.id !== r && e.path !== void 0 && L({
100
+ return n.find((e) => e.id !== r && e.path !== void 0 && z({
100
101
  path: t,
101
102
  other: e.path
102
103
  }))?.id;
103
104
  }
104
- function L(e) {
105
+ function z(e) {
105
106
  let { path: t, other: n } = e;
106
107
  return t === n || t.startsWith(`${n}/`) || n.startsWith(`${t}/`);
107
108
  }
108
- function R(e) {
109
+ function B(e) {
109
110
  let { path: t } = e;
110
111
  if (typeof t != "string") return "it is not a string";
111
112
  if (t.includes("\\")) return "it holds a backslash, a folder separator on Windows";
112
- if (D.test(t)) return "it holds an invisible format, separator or control character (Unicode Cc, Cf, Zl or Zp)";
113
+ if (k.test(t)) return "it holds an invisible format, separator or control character (Unicode Cc, Cf, Zl or Zp)";
113
114
  if (!t.isWellFormed()) return `it is ${d}`;
114
115
  if (t.normalize("NFC") !== t) return "it is not in Unicode NFC";
115
116
  let n = t.split("/");
@@ -117,9 +118,9 @@ function R(e) {
117
118
  if (n.some((e) => e === "." || e === "..")) return "it holds a folder or file name \".\" or \"..\"";
118
119
  let r = new TextEncoder();
119
120
  if (n.some((e) => r.encode(e).length > 255)) return "it holds a folder or file name of more than 255 bytes (UTF-8)";
120
- if (r.encode(t).length > 1024) return `it is more than ${E} bytes long (UTF-8)`;
121
+ if (r.encode(t).length > 1024) return `it is more than ${O} bytes long (UTF-8)`;
121
122
  }
122
- function z(e) {
123
+ function V(e) {
123
124
  let { record: t } = e, { id: n, tagName: r, namespace: i, attributes: a, value: o, parent: s, children: c } = t;
124
125
  return {
125
126
  id: n,
@@ -137,23 +138,23 @@ function z(e) {
137
138
  children: c
138
139
  };
139
140
  }
140
- function B(e) {
141
- return f({ value: e.records }).map((e) => z({ record: e }));
141
+ function H(e) {
142
+ return f({ value: e.records }).map((e) => V({ record: e }));
142
143
  }
143
- function V(e) {
144
+ function U(e) {
144
145
  let { record: t, patch: n } = e, { recordId: r, attributes: i, children: a, removeAttributes: o, ...s } = n, c = { ...t };
145
146
  for (let [e, t] of Object.entries(s)) t !== void 0 && Object.assign(c, { [e]: t });
146
- return i && (c.attributes = H({
147
+ return i && (c.attributes = W({
147
148
  held: t.attributes,
148
149
  given: i,
149
150
  key: "name"
150
- })), o?.length && (c.attributes = c.attributes.filter((e) => !o.includes(e.name))), a && (c.children = H({
151
+ })), o?.length && (c.attributes = c.attributes.filter((e) => !o.includes(e.name))), a && (c.children = W({
151
152
  held: t.children,
152
153
  given: a,
153
154
  key: "id"
154
- })), z({ record: c });
155
+ })), V({ record: c });
155
156
  }
156
- function H(e) {
157
+ function W(e) {
157
158
  let { held: t, given: n, key: r } = e, i = [...t];
158
159
  for (let e of n) {
159
160
  let t = i.findIndex((t) => t[r] === e[r]);
@@ -161,7 +162,7 @@ function H(e) {
161
162
  }
162
163
  return i;
163
164
  }
164
- function U(e) {
165
+ function G(e) {
165
166
  let { onProgress: t, parts: n } = e, r = n.reduce((e, t) => e + t, 0), i = 0, a = {};
166
167
  for (let e of n) i += e, p({
167
168
  listener: function(e) {
@@ -172,9 +173,94 @@ function U(e) {
172
173
  call: a
173
174
  });
174
175
  }
175
- var ee = /* @__PURE__ */ c(((e, t) => {
176
+ function K(e) {
177
+ let { totalBytes: t, listener: n, perf: r = y, intervalMs: i = 50, now: a = () => performance.now(), schedule: o = ee } = e, s = {}, c = 0, u, d = -Infinity, f, m, h, g = !1, _;
178
+ function v(e) {
179
+ f = void 0, _?.(), _ = void 0, u && ae({
180
+ left: u,
181
+ right: e
182
+ }) || (u = e, d = a(), p({
183
+ listener: n,
184
+ value: e,
185
+ of: l.importProgress,
186
+ call: s
187
+ }));
188
+ }
189
+ function b(e) {
190
+ e.phase !== m && (x(), m !== void 0 && r.stop(`import::phase.${m}`), m = e.phase, r.start(`import::phase.${m}`)), e.phase === "processing" && e.step !== h && (x(), h = e.step, h !== "start" && r.start(`import::hook.${h}`));
191
+ }
192
+ function x() {
193
+ h !== void 0 && h !== "start" && r.stop(`import::hook.${h}`), h = void 0;
194
+ }
195
+ return {
196
+ tell: function(e) {
197
+ if (g) return;
198
+ e.phase === "storing" && (c = e.bytesRead);
199
+ let n = te({
200
+ report: e,
201
+ bytesRead: c,
202
+ totalBytes: t
203
+ });
204
+ n.phase !== "indexing" && b(n);
205
+ let r = !u || !ne({
206
+ left: u,
207
+ right: n
208
+ });
209
+ if (r && f && v(f), r || !re(n) || ie(n)) {
210
+ v(n);
211
+ return;
212
+ }
213
+ let s = a() - d;
214
+ s >= i ? v(n) : (f = n, _ ??= o({
215
+ work: function() {
216
+ _ = void 0, f && v(f);
217
+ },
218
+ afterMs: i - s
219
+ }));
220
+ },
221
+ close: function() {
222
+ g || (g = !0, f = void 0, _?.(), _ = void 0, x(), m !== void 0 && r.stop(`import::phase.${m}`), m = void 0);
223
+ }
224
+ };
225
+ }
226
+ function ee(e) {
227
+ let t = setTimeout(e.work, e.afterMs);
228
+ return t.unref?.(), function() {
229
+ clearTimeout(t);
230
+ };
231
+ }
232
+ function te(e) {
233
+ let { report: t, bytesRead: n, totalBytes: r } = e;
234
+ return {
235
+ ...t,
236
+ bytesRead: n,
237
+ totalBytes: r
238
+ };
239
+ }
240
+ function ne(e) {
241
+ let { left: t, right: n } = e;
242
+ return t.phase === n.phase ? t.phase === "processing" && n.phase === "processing" ? t.step === n.step : t.phase === "indexing" && n.phase === "indexing" ? t.index === n.index : !0 : !1;
243
+ }
244
+ function re(e) {
245
+ return "done" in e && e.done !== void 0;
246
+ }
247
+ function ie(e) {
248
+ return "done" in e && "total" in e && e.done === e.total;
249
+ }
250
+ function ae(e) {
251
+ let { left: t, right: n } = e, r = Object.entries(t);
252
+ return r.length === Object.keys(n).length && r.every(([e, t]) => n[e] === t);
253
+ }
254
+ function oe(e) {
255
+ let { ops: t, control: n } = e, r = (t.creates?.length ?? 0) + (t.updates?.length ?? 0) + (t.deletes?.length ?? 0);
256
+ n?.onProgress?.({
257
+ done: r,
258
+ total: r
259
+ });
260
+ }
261
+ var se = /* @__PURE__ */ c(((e, t) => {
176
262
  t.exports = {};
177
- })), W = /* @__PURE__ */ s((/* @__PURE__ */ c(((e, t, n) => {
263
+ })), ce = /* @__PURE__ */ s((/* @__PURE__ */ c(((e, t, n) => {
178
264
  (function(e) {
179
265
  e.parser = function(e, t) {
180
266
  return new n(e, t);
@@ -268,7 +354,7 @@ var ee = /* @__PURE__ */ c(((e, t) => {
268
354
  };
269
355
  var o;
270
356
  try {
271
- o = ee().Stream;
357
+ o = se().Stream;
272
358
  } catch {
273
359
  o = function() {};
274
360
  }
@@ -995,7 +1081,7 @@ var ee = /* @__PURE__ */ c(((e, t) => {
995
1081
  }) : String.fromCodePoint = n;
996
1082
  })();
997
1083
  })(e === void 0 ? n.sax = {} : e);
998
- })))(), 1), G = class {
1084
+ })))(), 1), q = class {
999
1085
  constructor() {
1000
1086
  this.pendingChildren = /* @__PURE__ */ new Map();
1001
1087
  }
@@ -1014,42 +1100,42 @@ var ee = /* @__PURE__ */ c(((e, t) => {
1014
1100
  return this.pendingChildren.size;
1015
1101
  }
1016
1102
  };
1017
- function K(e) {
1103
+ function le(e) {
1018
1104
  return "prefix" in e && "uri" in e && !!e.prefix && !!e.uri;
1019
1105
  }
1020
- var te = {
1106
+ var ue = {
1021
1107
  lowercase: !1,
1022
1108
  trim: !1,
1023
1109
  normalize: !1,
1024
1110
  position: !1,
1025
1111
  xmlns: !0
1026
1112
  };
1027
- function ne(e) {
1113
+ function de(e) {
1028
1114
  let { dialecteConfig: t, useCustomRecordsIds: n, session: r, hooks: i, importSession: a, perf: o = y } = e, s = {
1029
1115
  defaultNamespace: null,
1030
1116
  stack: [],
1031
1117
  recordsBatch: [],
1032
1118
  sawRoot: !1
1033
- }, c = W.parser(!0, te), l = a?.recordTagNames && new Set(a.recordTagNames);
1119
+ }, c = ce.parser(!0, ue), l = a?.recordTagNames && new Set(a.recordTagNames);
1034
1120
  c.onopentag = (e) => {
1035
- re({
1121
+ fe({
1036
1122
  node: e,
1037
1123
  state: s,
1038
1124
  dialecteConfig: t,
1039
1125
  useCustomRecordsIds: n
1040
1126
  });
1041
1127
  }, c.ontext = (e) => {
1042
- ie({
1128
+ pe({
1043
1129
  text: e,
1044
1130
  state: s
1045
1131
  });
1046
1132
  }, c.oncdata = (e) => {
1047
- q({
1133
+ J({
1048
1134
  text: e,
1049
1135
  state: s
1050
1136
  });
1051
1137
  }, c.onclosetag = () => {
1052
- oe({
1138
+ he({
1053
1139
  state: s,
1054
1140
  hooks: i,
1055
1141
  importSession: a,
@@ -1058,7 +1144,7 @@ function ne(e) {
1058
1144
  dialecteConfig: t,
1059
1145
  perf: o
1060
1146
  });
1061
- }, c.onerror = se;
1147
+ }, c.onerror = ge;
1062
1148
  function u() {
1063
1149
  let e = s.recordsBatch;
1064
1150
  return s.recordsBatch = [], e;
@@ -1072,21 +1158,21 @@ function ne(e) {
1072
1158
  getSize: d
1073
1159
  };
1074
1160
  }
1075
- function re(e) {
1076
- let { node: t, state: r, dialecteConfig: i, useCustomRecordsIds: o } = e, s = ce(t);
1161
+ function fe(e) {
1162
+ let { node: t, state: r, dialecteConfig: i, useCustomRecordsIds: o } = e, s = _e(t);
1077
1163
  r.stack.length === 0 && (r.sawRoot && n("PARSE_ERROR", {
1078
1164
  detail: `XML parsing error: a second root element <${t.name}> after the root was closed`,
1079
1165
  meta: {
1080
1166
  reason: "second-root",
1081
1167
  tagName: t.name
1082
1168
  }
1083
- }), r.sawRoot = !0), r.defaultNamespace ||= le({
1169
+ }), r.sawRoot = !0), r.defaultNamespace ||= ve({
1084
1170
  element: t,
1085
1171
  defaultNamespace: i.namespaces.default,
1086
1172
  rootElementName: i.rootElementName
1087
1173
  });
1088
- let c = ue(t, r.defaultNamespace), l = {
1089
- id: pe({
1174
+ let c = ye(t, r.defaultNamespace), l = {
1175
+ id: Se({
1090
1176
  attributes: t.attributes,
1091
1177
  useCustomRecordsIds: o,
1092
1178
  tagName: s
@@ -1095,42 +1181,42 @@ function re(e) {
1095
1181
  namespace: c,
1096
1182
  attributes: a({
1097
1183
  dialecteConfig: i,
1098
- attributes: de(me({
1184
+ attributes: be(Ce({
1099
1185
  attributes: t.attributes,
1100
1186
  useCustomRecordsIds: o
1101
1187
  })),
1102
1188
  namespaceOf: (e) => t.ns[e]
1103
1189
  }),
1104
1190
  value: "",
1105
- parent: fe(r.stack),
1191
+ parent: xe(r.stack),
1106
1192
  children: []
1107
1193
  };
1108
1194
  r.stack.push(l);
1109
1195
  }
1110
- function ie(e) {
1196
+ function pe(e) {
1111
1197
  let { state: t } = e;
1112
- q({
1198
+ J({
1113
1199
  text: o({ text: e.text }),
1114
1200
  state: t
1115
1201
  });
1116
1202
  }
1117
- function q(e) {
1203
+ function J(e) {
1118
1204
  let { text: t, state: n } = e;
1119
1205
  t && n.stack.length > 0 && (n.stack[n.stack.length - 1].value += t);
1120
1206
  }
1121
- function ae(e) {
1207
+ function me(e) {
1122
1208
  let { record: t } = e, n = S({ record: t });
1123
1209
  if (!n) return;
1124
1210
  let r = b({
1125
1211
  place: n,
1126
1212
  element: `<${t.tagName}>`
1127
1213
  });
1128
- J({
1214
+ Y({
1129
1215
  character: n.character,
1130
1216
  where: r
1131
1217
  });
1132
1218
  }
1133
- function J(e) {
1219
+ function Y(e) {
1134
1220
  let { character: t, where: r } = e;
1135
1221
  n("PARSE_ERROR", {
1136
1222
  detail: `XML parsing error: ${r} holds ${t}, a character XML does not allow (as written or as a character reference)`,
@@ -1140,7 +1226,7 @@ function J(e) {
1140
1226
  }
1141
1227
  });
1142
1228
  }
1143
- function oe(e) {
1229
+ function he(e) {
1144
1230
  let { state: t, hooks: n, importSession: r, sessionTags: i, session: a, dialecteConfig: o, perf: s = y } = e, c = t.stack.pop();
1145
1231
  if (!c) return;
1146
1232
  let l = s.time("import::standardize", () => C({
@@ -1151,7 +1237,7 @@ function oe(e) {
1151
1237
  u && (!i || i.has(l.tagName)) && s.time("import::hooks.record", () => u({
1152
1238
  record: l,
1153
1239
  ancestry: t.stack
1154
- })), ae({ record: l });
1240
+ })), me({ record: l });
1155
1241
  let d = t.stack[t.stack.length - 1];
1156
1242
  d ? d.children.push({
1157
1243
  id: l.id,
@@ -1161,7 +1247,7 @@ function oe(e) {
1161
1247
  tagName: l.tagName
1162
1248
  }), t.recordsBatch.push(l);
1163
1249
  }
1164
- function se(e) {
1250
+ function ge(e) {
1165
1251
  n("PARSE_ERROR", {
1166
1252
  detail: `XML parsing error: ${e.message}`,
1167
1253
  meta: {
@@ -1170,23 +1256,23 @@ function se(e) {
1170
1256
  }
1171
1257
  });
1172
1258
  }
1173
- function ce(e) {
1259
+ function _e(e) {
1174
1260
  return e.local;
1175
1261
  }
1176
- function le(e) {
1262
+ function ve(e) {
1177
1263
  let { element: t, defaultNamespace: n, rootElementName: i } = e;
1178
1264
  return r(t.name === i, { detail: `Expected root element <${i}>, got <${t.name}>` }), t.attributes?.xmlns?.value ? {
1179
1265
  prefix: "",
1180
1266
  uri: t.attributes.xmlns.value
1181
1267
  } : n;
1182
1268
  }
1183
- function ue(e, t) {
1184
- return K(e) ? {
1269
+ function ye(e, t) {
1270
+ return le(e) ? {
1185
1271
  prefix: e.prefix,
1186
1272
  uri: e.uri
1187
1273
  } : t;
1188
1274
  }
1189
- function de(e) {
1275
+ function be(e) {
1190
1276
  return e.map((e) => {
1191
1277
  let t = e.prefix && e.uri ? {
1192
1278
  prefix: e.prefix,
@@ -1199,7 +1285,7 @@ function de(e) {
1199
1285
  };
1200
1286
  });
1201
1287
  }
1202
- function fe(e) {
1288
+ function xe(e) {
1203
1289
  if (e.length === 0) return null;
1204
1290
  let t = e[e.length - 1];
1205
1291
  return t ? {
@@ -1207,165 +1293,265 @@ function fe(e) {
1207
1293
  tagName: t.tagName
1208
1294
  } : null;
1209
1295
  }
1210
- function pe(e) {
1296
+ function Se(e) {
1211
1297
  let { attributes: t, useCustomRecordsIds: n, tagName: r } = e, a = t[i];
1212
1298
  if (!n || !a || !a.value) return crypto.randomUUID();
1213
1299
  let o = _({ text: a.value });
1214
- return o && J({
1300
+ return o && Y({
1215
1301
  character: o,
1216
1302
  where: `The attribute ${i} of <${r}>`
1217
1303
  }), a.value;
1218
1304
  }
1219
- function me(e) {
1305
+ function Ce(e) {
1220
1306
  let { attributes: t, useCustomRecordsIds: n } = e;
1221
1307
  return n ? Object.values(t).filter((e) => e.name !== i) : Object.values(t);
1222
1308
  }
1223
- async function Y(e, t = {}) {
1224
- let { documentId: n, configKey: i, store: a, config: o, useCustomRecordsIds: s = !1, chunkOptions: c, hooks: l, perf: u = y } = e, { file: d } = e;
1225
- if (r(j({ extensions: o.io.supportedFileExtensions }).some((e) => d.name.toLowerCase().endsWith(e)), {
1309
+ async function X(e, t = {}) {
1310
+ let { file: n, perf: r = y } = e, i = e.reporter ? void 0 : K({
1311
+ totalBytes: n.size,
1312
+ listener: t.onProgress,
1313
+ perf: r
1314
+ }), a = e.reporter ?? i;
1315
+ try {
1316
+ return await we({
1317
+ ...e,
1318
+ reporter: a
1319
+ }, t);
1320
+ } finally {
1321
+ i?.close();
1322
+ }
1323
+ }
1324
+ async function we(e, t) {
1325
+ let { documentId: n, configKey: i, store: a, config: o, useCustomRecordsIds: s = !1, chunkOptions: c, hooks: l, perf: u = y, reporter: d } = e, { file: f } = e;
1326
+ if (r(N({ extensions: o.io.supportedFileExtensions }).some((e) => f.name.toLowerCase().endsWith(e)), {
1226
1327
  key: "ASSERTION_FAILED",
1227
- detail: `Unsupported file type: ${d.name}`
1228
- }), d.size === 0) return {
1328
+ detail: `Unsupported file type: ${f.name}`
1329
+ }), f.size === 0) return {
1229
1330
  documentId: n,
1230
1331
  recordCount: 0,
1231
1332
  diagnostics: []
1232
1333
  };
1233
- let f = l?.beforeImport;
1234
- if (f) {
1235
- let e = f(await d.text());
1236
- d = new File([e], d.name, { type: d.type });
1334
+ let p = l?.beforeImport;
1335
+ if (p) {
1336
+ let e = p(await f.text());
1337
+ f = new File([e], f.name, { type: f.type });
1237
1338
  }
1238
- let p = c?.chunkSize ?? 32768, m = c?.batchSize ?? 2e3, h = new G(), g = l?.createImportSession?.({
1339
+ let m = c?.chunkSize ?? 32768, h = c?.batchSize ?? 2e3, g = new q(), _ = l?.createImportSession?.({
1239
1340
  documentId: n,
1240
1341
  configKey: i
1241
- }), _ = ne({
1342
+ }), v = de({
1242
1343
  dialecteConfig: o,
1243
1344
  useCustomRecordsIds: s,
1244
- session: h,
1345
+ session: g,
1245
1346
  hooks: l,
1246
- importSession: g,
1347
+ importSession: _,
1247
1348
  perf: u
1248
- }), v = await he({
1249
- file: d,
1250
- sax: _,
1251
- session: h,
1349
+ }), b = await Te({
1350
+ file: f,
1351
+ sax: v,
1352
+ session: g,
1252
1353
  store: a,
1253
1354
  documentId: n,
1254
- chunkSize: p,
1255
- batchSize: m,
1355
+ chunkSize: m,
1356
+ batchSize: h,
1256
1357
  perf: u,
1257
- control: t
1258
- }), { recordDelta: b, diagnostics: x } = await ge({
1259
- importSession: g,
1358
+ control: t,
1359
+ reporter: d
1360
+ }), { recordDelta: x, diagnostics: S } = await Ee({
1361
+ importSession: _,
1260
1362
  store: a,
1261
1363
  documentId: n,
1262
- file: d,
1364
+ file: f,
1263
1365
  perf: u,
1264
- signal: t.signal
1366
+ signal: t.signal,
1367
+ reporter: d
1265
1368
  });
1266
1369
  return {
1267
1370
  documentId: n,
1268
- recordCount: v + b,
1269
- diagnostics: x
1371
+ recordCount: b + x,
1372
+ diagnostics: S
1270
1373
  };
1271
1374
  }
1272
- async function he(e) {
1273
- let { file: t, sax: n, session: r, store: i, documentId: a, chunkSize: o, batchSize: s, perf: c, control: l } = e, u = {
1375
+ async function Te(e) {
1376
+ let { file: t, sax: n, session: r, store: i, documentId: a, chunkSize: o, batchSize: s, perf: c, control: l, reporter: u } = e, d = {
1274
1377
  sax: n,
1275
1378
  session: r,
1276
1379
  store: i,
1277
1380
  documentId: a,
1278
1381
  file: t,
1279
1382
  perf: c,
1280
- control: l
1281
- }, d = 0, f = 0, p = t.stream().getReader(), m = new TextDecoder(), h = /* @__PURE__ */ new Uint8Array(), g = !1;
1282
- for (; !g;) {
1283
- let e = await p.read();
1284
- if (g = e.done, e.value) {
1285
- let r = h.length === 0 ? e.value : ye(h, e.value), i = 0;
1286
- for (; i + o <= r.length;) {
1287
- let e = c.time("import::decode", () => m.decode(r.subarray(i, i + o), { stream: !0 }));
1288
- i += o, f += o, c.time("import::parse", () => n.parser.write(e)), d += await Z({
1289
- ...u,
1383
+ control: l,
1384
+ reporter: u
1385
+ }, f = 0, p = 0, m = t.stream().getReader(), h = new TextDecoder(), g = /* @__PURE__ */ new Uint8Array(), _ = !1;
1386
+ for (; !_;) {
1387
+ let e = await m.read();
1388
+ if (_ = e.done, e.value) {
1389
+ let t = g.length === 0 ? e.value : je(g, e.value), r = 0;
1390
+ for (; r + o <= t.length;) {
1391
+ let e = c.time("import::decode", () => h.decode(t.subarray(r, r + o), { stream: !0 }));
1392
+ r += o, p += o, c.time("import::parse", () => n.parser.write(e)), f += await $({
1393
+ ...d,
1290
1394
  threshold: s,
1291
- progress: {
1292
- phase: "storing",
1293
- bytesRead: f,
1294
- totalBytes: t.size
1295
- }
1395
+ bytesRead: p
1296
1396
  });
1297
1397
  }
1298
- h = i < r.length ? r.slice(i) : /* @__PURE__ */ new Uint8Array();
1398
+ g = r < t.length ? t.slice(r) : /* @__PURE__ */ new Uint8Array();
1299
1399
  }
1300
- if (g) {
1301
- if (h.length > 0) {
1302
- let e = c.time("import::decode", () => m.decode(h));
1303
- f += h.length, c.time("import::parse", () => n.parser.write(e));
1400
+ if (_) {
1401
+ if (g.length > 0) {
1402
+ let e = c.time("import::decode", () => h.decode(g));
1403
+ p += g.length, c.time("import::parse", () => n.parser.write(e));
1304
1404
  }
1305
- c.time("import::parse", () => n.parser.close()), d += await Z({
1306
- ...u,
1405
+ c.time("import::parse", () => n.parser.close()), f += await $({
1406
+ ...d,
1307
1407
  threshold: 0,
1308
- progress: {
1309
- phase: "storing",
1310
- bytesRead: f,
1311
- totalBytes: t.size
1312
- }
1408
+ bytesRead: p
1313
1409
  });
1314
1410
  }
1315
1411
  }
1316
- return d;
1412
+ return f;
1317
1413
  }
1318
- async function ge(e) {
1319
- let { importSession: t, store: n, documentId: r, file: i, perf: a, signal: o } = e;
1320
- if (X({
1321
- signal: o,
1414
+ async function Ee(e) {
1415
+ let { importSession: t, store: n, documentId: r, file: i, perf: a, reporter: o } = e, s = e.signal ?? new AbortController().signal;
1416
+ if (Q({
1417
+ signal: s,
1322
1418
  file: i
1419
+ }), o.tell({
1420
+ phase: "processing",
1421
+ step: T
1323
1422
  }), !t?.afterImport) return {
1324
1423
  recordDelta: 0,
1325
1424
  diagnostics: []
1326
1425
  };
1327
- a.start("import::hooks.after");
1328
- let s;
1329
- try {
1330
- s = await t.afterImport();
1331
- } finally {
1332
- a.stop("import::hooks.after");
1333
- }
1334
- let { creates: c, updates: l, deletes: u, diagnostics: d = [] } = s;
1335
- if (_e({ diagnostics: d }), ve({
1426
+ let { creates: c, updates: l, deletes: u, diagnostics: d = [] } = await De({
1427
+ afterImport: t.afterImport,
1428
+ file: i,
1429
+ perf: a,
1430
+ signal: s,
1431
+ reporter: o
1432
+ });
1433
+ Q({
1434
+ signal: s,
1435
+ file: i
1436
+ }), ke({
1437
+ diagnostics: d,
1336
1438
  creates: c,
1337
- updates: l
1338
- }), c?.length || l?.length || u?.length) {
1339
- X({
1340
- signal: o,
1439
+ updates: l,
1440
+ reporter: o
1441
+ });
1442
+ let f = (c?.length ?? 0) + (l?.length ?? 0) + (u?.length ?? 0);
1443
+ if (f > 0) {
1444
+ Q({
1445
+ signal: s,
1341
1446
  file: i
1447
+ }), o.tell({
1448
+ phase: "applying",
1449
+ done: 0,
1450
+ total: f
1342
1451
  }), a.start("import::writes.after");
1343
1452
  try {
1344
1453
  await n.writeSession(r, {
1345
1454
  creates: c,
1346
1455
  updates: l,
1347
1456
  deletes: u
1348
- });
1457
+ }, { onProgress: function(e) {
1458
+ o.tell({
1459
+ phase: "applying",
1460
+ ...e
1461
+ });
1462
+ } });
1349
1463
  } finally {
1350
1464
  a.stop("import::writes.after");
1351
1465
  }
1466
+ o.tell({
1467
+ phase: "applying",
1468
+ done: f,
1469
+ total: f
1470
+ });
1352
1471
  }
1353
1472
  return {
1354
1473
  recordDelta: (c?.length ?? 0) - (u?.length ?? 0),
1355
1474
  diagnostics: d
1356
1475
  };
1357
1476
  }
1358
- function _e(t) {
1477
+ async function De(e) {
1478
+ let { afterImport: t, file: n, perf: r, signal: i, reporter: a } = e, o = {
1479
+ report: function(e) {
1480
+ i.aborted || a.tell({
1481
+ phase: "processing",
1482
+ ...Oe({ step: e })
1483
+ });
1484
+ },
1485
+ signal: i
1486
+ };
1487
+ r.start("import::hooks.after");
1359
1488
  try {
1360
- m({ value: t.diagnostics });
1489
+ return await t(o);
1490
+ } catch (e) {
1491
+ throw Q({
1492
+ signal: i,
1493
+ file: n
1494
+ }), e;
1495
+ } finally {
1496
+ r.stop("import::hooks.after");
1497
+ }
1498
+ }
1499
+ function Oe(e) {
1500
+ let { step: t, done: n, total: r } = e.step;
1501
+ return {
1502
+ step: String(t),
1503
+ ...typeof n == "number" && { done: n },
1504
+ ...typeof r == "number" && { total: r }
1505
+ };
1506
+ }
1507
+ function ke(e) {
1508
+ let { diagnostics: t, creates: n = [], updates: r = [], reporter: i } = e, a = t.length + n.length + r.length, o = 0;
1509
+ i.tell({
1510
+ phase: "checking",
1511
+ done: o,
1512
+ total: a
1513
+ });
1514
+ for (let e = 0; e < t.length; e += w) {
1515
+ let n = t.slice(e, e + w);
1516
+ Ae({
1517
+ diagnostics: n,
1518
+ offset: e
1519
+ }), o += n.length, i.tell({
1520
+ phase: "checking",
1521
+ done: o,
1522
+ total: a
1523
+ });
1524
+ }
1525
+ for (let e = 0; e < n.length; e += w) {
1526
+ let t = n.slice(e, e + w);
1527
+ Z({ creates: t }), o += t.length, i.tell({
1528
+ phase: "checking",
1529
+ done: o,
1530
+ total: a
1531
+ });
1532
+ }
1533
+ for (let e = 0; e < r.length; e += w) {
1534
+ let t = r.slice(e, e + w);
1535
+ Z({ updates: t }), o += t.length, i.tell({
1536
+ phase: "checking",
1537
+ done: o,
1538
+ total: a
1539
+ });
1540
+ }
1541
+ }
1542
+ function Ae(t) {
1543
+ let { diagnostics: r, offset: i } = t;
1544
+ try {
1545
+ m({ value: r });
1361
1546
  } catch (t) {
1547
+ let a = `among the diagnostics ${i}-${i + r.length - 1}`;
1362
1548
  n("STORE_VALUE_NOT_JSON", {
1363
- detail: `A diagnostic of the import session: ${e(t)?.detail ?? String(t)}`,
1549
+ detail: `A diagnostic of the import session: ${e(t)?.detail ?? String(t)} (${a})`,
1364
1550
  cause: t instanceof Error ? t : void 0
1365
1551
  });
1366
1552
  }
1367
1553
  }
1368
- function ve(e) {
1554
+ function Z(e) {
1369
1555
  let { creates: t = [], updates: n = [] } = e;
1370
1556
  for (let e of t) g({ record: e });
1371
1557
  for (let e of n) g({ record: {
@@ -1373,21 +1559,21 @@ function ve(e) {
1373
1559
  id: e.recordId
1374
1560
  } });
1375
1561
  }
1376
- function X(e) {
1562
+ function Q(e) {
1377
1563
  let { signal: t, file: r } = e;
1378
1564
  t?.aborted && n("IMPORT_ABORTED", {
1379
1565
  detail: `The import of "${r.name}" was aborted`,
1380
1566
  meta: { fileName: r.name }
1381
1567
  });
1382
1568
  }
1383
- function ye(e, t) {
1569
+ function je(e, t) {
1384
1570
  let n = new Uint8Array(e.length + t.length);
1385
1571
  return n.set(e), n.set(t, e.length), n;
1386
1572
  }
1387
- async function Z(e) {
1388
- let { sax: t, session: n, store: r, documentId: i, file: a, threshold: o, perf: s, control: c, progress: u } = e;
1573
+ async function $(e) {
1574
+ let { sax: t, session: n, store: r, documentId: i, file: a, threshold: o, perf: s, control: c, reporter: l, bytesRead: u } = e;
1389
1575
  if (t.getSize() < o) return 0;
1390
- X({
1576
+ Q({
1391
1577
  signal: c.signal,
1392
1578
  file: a
1393
1579
  }), s.start("import::insert");
@@ -1398,19 +1584,17 @@ async function Z(e) {
1398
1584
  } finally {
1399
1585
  s.stop("import::insert");
1400
1586
  }
1401
- return p({
1402
- listener: c.onProgress,
1403
- value: u,
1404
- of: l.importProgress,
1405
- call: c
1587
+ return l.tell({
1588
+ phase: "storing",
1589
+ bytesRead: u
1406
1590
  }), d;
1407
1591
  }
1408
- async function be(n, r = {}) {
1592
+ async function Me(n, r = {}) {
1409
1593
  let { runtime: i, file: a, options: o, writeId: s } = n, c = n.perf ?? x({
1410
1594
  enabled: i.perf ?? !1,
1411
1595
  timeline: !1
1412
1596
  });
1413
- X({
1597
+ Q({
1414
1598
  signal: r.signal,
1415
1599
  file: a
1416
1600
  });
@@ -1420,7 +1604,7 @@ async function be(n, r = {}) {
1420
1604
  configKey: o?.configKey
1421
1605
  }), d = {
1422
1606
  id: crypto.randomUUID(),
1423
- ...Q({
1607
+ ...Ne({
1424
1608
  file: a,
1425
1609
  path: o?.path,
1426
1610
  config: u
@@ -1431,16 +1615,21 @@ async function be(n, r = {}) {
1431
1615
  status: "importing",
1432
1616
  writeId: s,
1433
1617
  ...o?.path !== void 0 && { path: o.path }
1434
- };
1618
+ }, f = K({
1619
+ totalBytes: a.size,
1620
+ listener: r.onProgress,
1621
+ perf: c
1622
+ });
1435
1623
  c.start("import");
1436
- let f;
1624
+ let p;
1437
1625
  try {
1438
- f = await xe({
1626
+ p = await Pe({
1439
1627
  ...n,
1440
1628
  control: r,
1441
1629
  registered: d,
1442
1630
  config: u,
1443
- perf: c
1631
+ perf: c,
1632
+ reporter: f
1444
1633
  });
1445
1634
  } catch (n) {
1446
1635
  throw e(n) ? n : t("IMPORT_FAILED", {
@@ -1448,25 +1637,25 @@ async function be(n, r = {}) {
1448
1637
  cause: n instanceof Error ? n : void 0
1449
1638
  });
1450
1639
  } finally {
1451
- c.stop("import");
1640
+ f.close(), c.stop("import");
1452
1641
  }
1453
1642
  return {
1454
- ...f,
1643
+ ...p,
1455
1644
  ...i.perf && { perf: c.snapshot() }
1456
1645
  };
1457
1646
  }
1458
- function Q(e) {
1459
- let { file: t, path: n, config: r } = e, i = j({ extensions: r.io.supportedFileExtensions });
1647
+ function Ne(e) {
1648
+ let { file: t, path: n, config: r } = e, i = N({ extensions: r.io.supportedFileExtensions });
1460
1649
  return n === void 0 ? {
1461
1650
  name: t.name.replace(/\.[^.]+$/, "") || "untitled",
1462
1651
  extension: t.name.includes(".") ? `.${t.name.split(".").pop()}` : i[0]
1463
- } : M({
1652
+ } : P({
1464
1653
  path: n,
1465
1654
  extensions: i
1466
1655
  });
1467
1656
  }
1468
- async function xe(e) {
1469
- let { store: t, runtime: r, file: i, options: a, control: o, registered: s, config: c, perf: l } = e;
1657
+ async function Pe(e) {
1658
+ let { store: t, runtime: r, file: i, options: a, control: o, registered: s, config: c, perf: l, reporter: u } = e;
1470
1659
  l.start("import::register");
1471
1660
  try {
1472
1661
  await t.registerDocument(s);
@@ -1474,7 +1663,7 @@ async function xe(e) {
1474
1663
  l.stop("import::register");
1475
1664
  }
1476
1665
  try {
1477
- let e = await Y({
1666
+ let e = await X({
1478
1667
  file: i,
1479
1668
  documentId: s.id,
1480
1669
  configKey: s.configKey,
@@ -1483,12 +1672,13 @@ async function xe(e) {
1483
1672
  useCustomRecordsIds: a?.useCustomRecordsIds,
1484
1673
  chunkOptions: a?.chunkOptions,
1485
1674
  hooks: r.hooks,
1486
- perf: l
1675
+ perf: l,
1676
+ reporter: u
1487
1677
  }, o);
1488
- X({
1678
+ Q({
1489
1679
  signal: o.signal,
1490
1680
  file: i
1491
- }), l.start("import::finalize");
1681
+ }), u.tell({ phase: "finishing" }), l.start("import::finalize");
1492
1682
  try {
1493
1683
  await t.getDocument(s.id) || n("DOCUMENT_NOT_REGISTERED", {
1494
1684
  detail: `Document "${s.id}" of "${i.name}" was removed while it imported`,
@@ -1506,33 +1696,33 @@ async function xe(e) {
1506
1696
  diagnostics: e.diagnostics
1507
1697
  };
1508
1698
  } catch (e) {
1509
- throw await Se({
1699
+ throw await Fe({
1510
1700
  store: t,
1511
1701
  documentId: s.id
1512
1702
  }), e;
1513
1703
  }
1514
1704
  }
1515
- async function Se(e) {
1705
+ async function Fe(e) {
1516
1706
  let { store: t, documentId: n } = e;
1517
1707
  try {
1518
1708
  await t.removeDocument(n);
1519
1709
  } catch {}
1520
1710
  }
1521
- var Ce = {
1711
+ var Ie = {
1522
1712
  import: "IMPORT_FAILED",
1523
1713
  export: "ASSERTION_FAILED"
1524
1714
  };
1525
- function we(e) {
1715
+ function Le(e) {
1526
1716
  let { runtime: t, storeName: r, operation: i } = e;
1527
- return t || n(Ce[i], { detail: `Store "${r}" has no dialecte to ${i} with: build it with a runtime` }), t;
1717
+ return t || n(Ie[i], { detail: `Store "${r}" has no dialecte to ${i} with: build it with a runtime` }), t;
1528
1718
  }
1529
- function Te(e, t) {
1719
+ function Re(e, t) {
1530
1720
  return e.id < t.id ? -1 : +(e.id > t.id);
1531
1721
  }
1532
- function Ee(e) {
1533
- return $({ value: e.first }) === $({ value: e.second });
1722
+ function ze(e) {
1723
+ return Be({ value: e.first }) === Be({ value: e.second });
1534
1724
  }
1535
- function $(e) {
1725
+ function Be(e) {
1536
1726
  return JSON.stringify(e.value, function(e, t) {
1537
1727
  return typeof t != "object" || !t || Array.isArray(t) ? t : Object.fromEntries(Object.entries(t).sort(function([e], [t]) {
1538
1728
  return e < t ? -1 : +(e > t);
@@ -1540,4 +1730,4 @@ function $(e) {
1540
1730
  });
1541
1731
  }
1542
1732
  //#endregion
1543
- export { O as C, T, j as _, Y as a, E as b, V as d, B as f, I as g, A as h, be as i, F as m, Te as n, X as o, P as p, we as r, G as s, Ee as t, U as u, M as v, w, D as y };
1733
+ export { D as E, E as T, R as _, X as a, k as b, G as d, U as f, M as g, L as h, Me as i, I as m, Re as n, Q as o, H as p, Le as r, q as s, ze as t, oe as u, N as v, A as w, O as x, P as y };