@redocly/replay 0.27.0-next.8 → 0.27.0
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/dist/{replay-AiChatProvider-DHIxHTKX.js → replay-AiChatProvider-LQhrLIDL.js} +44 -44
- package/dist/{replay-AiChatProvider-O8HHQobN.js → replay-AiChatProvider-Oms5CFgT.js} +1 -1
- package/dist/{replay-AiChatSqliteDBStorage-DNMrzkJg.js → replay-AiChatSqliteDBStorage-3-p1mthX.js} +1 -1
- package/dist/{replay-AiChatSqliteDBStorage-DjUq9VX3.js → replay-AiChatSqliteDBStorage-GZibdHOQ.js} +1 -1
- package/dist/replay-AiPanel-BvwwBTh1.js +742 -0
- package/dist/{replay-AiPanel-CR815YqV.js → replay-AiPanel-lcDNvgo0.js} +973 -1176
- package/dist/replay-FileWatcher-ClVd_wG0.js +1 -0
- package/dist/replay-FileWatcher-DR-wJLe2.js +343 -0
- package/dist/replay-Observable-D6wKbFwB.js +31 -0
- package/dist/replay-Observable-bjJ6wkRB.js +1 -0
- package/dist/replay-SemanticSearchService-CCqwCRo6.js +1 -0
- package/dist/replay-SemanticSearchService-U1eXQGfF.js +723 -0
- package/dist/{replay-SqliteDBStorage-B3oYWXem.js → replay-SqliteDBStorage-Dn6DoVWW.js} +1 -1
- package/dist/{replay-SqliteDBStorage-CC9kLioX.js → replay-SqliteDBStorage-d_ZK6ScA.js} +1 -1
- package/dist/replay-TauriFileSystemAdapter-CpiUuG3T.js +99 -0
- package/dist/replay-TauriFileSystemAdapter-dwJ0xBYr.js +1 -0
- package/dist/replay-TauriRootStorage-CuVbYMXX.js +605 -0
- package/dist/replay-TauriRootStorage-DhzbAahU.js +1 -0
- package/dist/{replay-agent-loop-CTq5eJ4u.js → replay-agent-loop-BLSu4v_O.js} +1 -1
- package/dist/{replay-agent-loop-CCYOzyHo.js → replay-agent-loop-DgEHdXUt.js} +11 -11
- package/dist/{replay-ai-chat-mappers-C8y5UhCq.js → replay-ai-chat-mappers-BvfcEubB.js} +5 -5
- package/dist/{replay-ai-chat-mappers-B_wovMvG.js → replay-ai-chat-mappers-Dy2kJ7ZG.js} +1 -1
- package/dist/replay-core-BJmXmoC5.js +1 -0
- package/dist/replay-core-B_hiOZZr.js +10 -0
- package/dist/{replay-create-model-C5yvtnXA.js → replay-create-model-DNPFcOIp.js} +579 -578
- package/dist/{replay-create-model-CBCmuEKC.js → replay-create-model-bOIDB-e8.js} +10 -10
- package/dist/{replay-db-CCBQadnT.js → replay-db-BQGv3PGw.js} +1 -1
- package/dist/{replay-db-DfOjLqsq.js → replay-db-CMXZZs9v.js} +1 -1
- package/dist/{replay-external-resolver-BRouROm6.js → replay-external-resolver-mrykFC2h.js} +2 -2
- package/dist/{replay-external-resolver-B6tpqUZt.js → replay-external-resolver-n5OvQMRF.js} +1 -1
- package/dist/replay-index-3lwhSmvi.js +1 -0
- package/dist/{replay-index-BzzBKjHm.js → replay-index-Bc5RHu5L.js} +23771 -25420
- package/dist/replay-index-CFLu-XMV.js +25 -0
- package/dist/{replay-index-Xq6K7XSm.js → replay-index-CHGVyIdG.js} +1 -1
- package/dist/{replay-index-Cpkh9r0X.js → replay-index-CSR_qlua.js} +1 -1
- package/dist/replay-index-CepJ5Z0m.js +6875 -0
- package/dist/{replay-index-Bzttek8l.js → replay-index-CgCGhu4l.js} +6 -6
- package/dist/replay-index-DDjmUXWm.js +1 -0
- package/dist/replay-index-DiSy_1OY.js +21 -0
- package/dist/replay-index-Oct6Dygd.js +1 -0
- package/dist/{replay-index-B_OHqSlS.js → replay-index-QXosJxRc.js} +18 -18
- package/dist/replay-index-jkDlU0Lx.js +32 -0
- package/dist/{replay-lint-gtuMJgII.js → replay-lint-DoHQIATV.js} +122 -122
- package/dist/{replay-lint-DlDmPTBV.js → replay-lint-PWaLESz5.js} +8921 -8880
- package/dist/{replay-lint-graphql-DHOq8lRT.js → replay-lint-graphql-xh8VoAwd.js} +1 -1
- package/dist/{replay-lint-graphql-BQJ00lU4.js → replay-lint-graphql-zO8zunug.js} +1 -1
- package/dist/replay-periodic-revalidation-BoyLQHtg.js +1 -0
- package/dist/replay-periodic-revalidation-Dsp-n7ui.js +21 -0
- package/dist/replay-promise-map-limit-DRDkHc-b.js +1 -0
- package/dist/replay-promise-map-limit-Db_42GvV.js +14 -0
- package/dist/replay-resolve-B0AjmaE9.js +47 -0
- package/dist/{replay-resolve-DsgcWnjC.js → replay-resolve-MVe_8Ube.js} +1364 -1329
- package/dist/{replay-respect-run-7Cwe1_ri.js → replay-respect-run-BJsR4a4m.js} +1 -1
- package/dist/{replay-respect-run-D1zyh-5j.js → replay-respect-run-X4PSO6Fj.js} +3 -3
- package/dist/{replay-tauri-path-BAY3g5sW.js → replay-tauri-path-CkGiQWsb.js} +5 -5
- package/dist/{replay-tauri-path-CaVeI3a-.js → replay-tauri-path-D8FJsoZb.js} +1 -1
- package/dist/replay-useAiChatQueries-BXL-_N2Q.js +215 -0
- package/dist/{replay-useAiChatQueries-CxZNLVje.js → replay-useAiChatQueries-D7sHNAfV.js} +1078 -1022
- package/dist/{replay-validate-key-Cv0mvYDS.js → replay-validate-key-CmzSfORv.js} +1 -1
- package/dist/{replay-validate-key-Di8MCBz7.js → replay-validate-key-CtZEJRP7.js} +2 -2
- package/dist/replay.cjs +1 -1
- package/dist/replay.js +11 -11
- package/package.json +10 -9
- package/dist/replay-AiPanel-CfYBCkrN.js +0 -868
- package/dist/replay-index-C6SJPGDO.js +0 -23
- package/dist/replay-index-CUs62_1f.js +0 -1
- package/dist/replay-index-Dfnqt_IZ.js +0 -6899
- package/dist/replay-resolve-DqFS69S_.js +0 -47
- package/dist/replay-useAiChatQueries-D99tAUpY.js +0 -215
|
@@ -0,0 +1,605 @@
|
|
|
1
|
+
import { g as he, a as fe, S as D, l as de, c as W, r as J, R as pe, b as F, d as O, i as me, y as ve, e as _e, P as we } from "./replay-index-Bc5RHu5L.js";
|
|
2
|
+
import { p as H } from "./replay-promise-map-limit-Db_42GvV.js";
|
|
3
|
+
import { TauriFileSystemAdapter as X } from "./replay-TauriFileSystemAdapter-CpiUuG3T.js";
|
|
4
|
+
var Y = { exports: {} }, Z;
|
|
5
|
+
function ye() {
|
|
6
|
+
return Z || (Z = 1, (function(i) {
|
|
7
|
+
var e = Object.prototype.hasOwnProperty, t = "~";
|
|
8
|
+
function r() {
|
|
9
|
+
}
|
|
10
|
+
Object.create && (r.prototype = /* @__PURE__ */ Object.create(null), new r().__proto__ || (t = !1));
|
|
11
|
+
function n(a, l, f) {
|
|
12
|
+
this.fn = a, this.context = l, this.once = f || !1;
|
|
13
|
+
}
|
|
14
|
+
function o(a, l, f, u, y) {
|
|
15
|
+
if (typeof f != "function")
|
|
16
|
+
throw new TypeError("The listener must be a function");
|
|
17
|
+
var w = new n(f, u || a, y), p = t ? t + l : l;
|
|
18
|
+
return a._events[p] ? a._events[p].fn ? a._events[p] = [a._events[p], w] : a._events[p].push(w) : (a._events[p] = w, a._eventsCount++), a;
|
|
19
|
+
}
|
|
20
|
+
function d(a, l) {
|
|
21
|
+
--a._eventsCount === 0 ? a._events = new r() : delete a._events[l];
|
|
22
|
+
}
|
|
23
|
+
function h() {
|
|
24
|
+
this._events = new r(), this._eventsCount = 0;
|
|
25
|
+
}
|
|
26
|
+
h.prototype.eventNames = function() {
|
|
27
|
+
var l = [], f, u;
|
|
28
|
+
if (this._eventsCount === 0) return l;
|
|
29
|
+
for (u in f = this._events)
|
|
30
|
+
e.call(f, u) && l.push(t ? u.slice(1) : u);
|
|
31
|
+
return Object.getOwnPropertySymbols ? l.concat(Object.getOwnPropertySymbols(f)) : l;
|
|
32
|
+
}, h.prototype.listeners = function(l) {
|
|
33
|
+
var f = t ? t + l : l, u = this._events[f];
|
|
34
|
+
if (!u) return [];
|
|
35
|
+
if (u.fn) return [u.fn];
|
|
36
|
+
for (var y = 0, w = u.length, p = new Array(w); y < w; y++)
|
|
37
|
+
p[y] = u[y].fn;
|
|
38
|
+
return p;
|
|
39
|
+
}, h.prototype.listenerCount = function(l) {
|
|
40
|
+
var f = t ? t + l : l, u = this._events[f];
|
|
41
|
+
return u ? u.fn ? 1 : u.length : 0;
|
|
42
|
+
}, h.prototype.emit = function(l, f, u, y, w, p) {
|
|
43
|
+
var b = t ? t + l : l;
|
|
44
|
+
if (!this._events[b]) return !1;
|
|
45
|
+
var c = this._events[b], A = arguments.length, T, _;
|
|
46
|
+
if (c.fn) {
|
|
47
|
+
switch (c.once && this.removeListener(l, c.fn, void 0, !0), A) {
|
|
48
|
+
case 1:
|
|
49
|
+
return c.fn.call(c.context), !0;
|
|
50
|
+
case 2:
|
|
51
|
+
return c.fn.call(c.context, f), !0;
|
|
52
|
+
case 3:
|
|
53
|
+
return c.fn.call(c.context, f, u), !0;
|
|
54
|
+
case 4:
|
|
55
|
+
return c.fn.call(c.context, f, u, y), !0;
|
|
56
|
+
case 5:
|
|
57
|
+
return c.fn.call(c.context, f, u, y, w), !0;
|
|
58
|
+
case 6:
|
|
59
|
+
return c.fn.call(c.context, f, u, y, w, p), !0;
|
|
60
|
+
}
|
|
61
|
+
for (_ = 1, T = new Array(A - 1); _ < A; _++)
|
|
62
|
+
T[_ - 1] = arguments[_];
|
|
63
|
+
c.fn.apply(c.context, T);
|
|
64
|
+
} else {
|
|
65
|
+
var ce = c.length, x;
|
|
66
|
+
for (_ = 0; _ < ce; _++)
|
|
67
|
+
switch (c[_].once && this.removeListener(l, c[_].fn, void 0, !0), A) {
|
|
68
|
+
case 1:
|
|
69
|
+
c[_].fn.call(c[_].context);
|
|
70
|
+
break;
|
|
71
|
+
case 2:
|
|
72
|
+
c[_].fn.call(c[_].context, f);
|
|
73
|
+
break;
|
|
74
|
+
case 3:
|
|
75
|
+
c[_].fn.call(c[_].context, f, u);
|
|
76
|
+
break;
|
|
77
|
+
case 4:
|
|
78
|
+
c[_].fn.call(c[_].context, f, u, y);
|
|
79
|
+
break;
|
|
80
|
+
default:
|
|
81
|
+
if (!T) for (x = 1, T = new Array(A - 1); x < A; x++)
|
|
82
|
+
T[x - 1] = arguments[x];
|
|
83
|
+
c[_].fn.apply(c[_].context, T);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return !0;
|
|
87
|
+
}, h.prototype.on = function(l, f, u) {
|
|
88
|
+
return o(this, l, f, u, !1);
|
|
89
|
+
}, h.prototype.once = function(l, f, u) {
|
|
90
|
+
return o(this, l, f, u, !0);
|
|
91
|
+
}, h.prototype.removeListener = function(l, f, u, y) {
|
|
92
|
+
var w = t ? t + l : l;
|
|
93
|
+
if (!this._events[w]) return this;
|
|
94
|
+
if (!f)
|
|
95
|
+
return d(this, w), this;
|
|
96
|
+
var p = this._events[w];
|
|
97
|
+
if (p.fn)
|
|
98
|
+
p.fn === f && (!y || p.once) && (!u || p.context === u) && d(this, w);
|
|
99
|
+
else {
|
|
100
|
+
for (var b = 0, c = [], A = p.length; b < A; b++)
|
|
101
|
+
(p[b].fn !== f || y && !p[b].once || u && p[b].context !== u) && c.push(p[b]);
|
|
102
|
+
c.length ? this._events[w] = c.length === 1 ? c[0] : c : d(this, w);
|
|
103
|
+
}
|
|
104
|
+
return this;
|
|
105
|
+
}, h.prototype.removeAllListeners = function(l) {
|
|
106
|
+
var f;
|
|
107
|
+
return l ? (f = t ? t + l : l, this._events[f] && d(this, f)) : (this._events = new r(), this._eventsCount = 0), this;
|
|
108
|
+
}, h.prototype.off = h.prototype.removeListener, h.prototype.addListener = h.prototype.on, h.prefixed = t, h.EventEmitter = h, i.exports = h;
|
|
109
|
+
})(Y)), Y.exports;
|
|
110
|
+
}
|
|
111
|
+
var ge = ye();
|
|
112
|
+
const Pe = /* @__PURE__ */ he(ge);
|
|
113
|
+
class ae extends Error {
|
|
114
|
+
constructor(e) {
|
|
115
|
+
super(e), this.name = "TimeoutError";
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
let be = class extends Error {
|
|
119
|
+
constructor(e) {
|
|
120
|
+
super(), this.name = "AbortError", this.message = e;
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
const ee = (i) => globalThis.DOMException === void 0 ? new be(i) : new DOMException(i), te = (i) => {
|
|
124
|
+
const e = i.reason === void 0 ? ee("This operation was aborted.") : i.reason;
|
|
125
|
+
return e instanceof Error ? e : ee(e);
|
|
126
|
+
};
|
|
127
|
+
function Ee(i, e, t, r) {
|
|
128
|
+
let n;
|
|
129
|
+
const o = new Promise((d, h) => {
|
|
130
|
+
if (typeof e != "number" || Math.sign(e) !== 1)
|
|
131
|
+
throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${e}\``);
|
|
132
|
+
if (e === Number.POSITIVE_INFINITY) {
|
|
133
|
+
d(i);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (r = {
|
|
137
|
+
customTimers: { setTimeout, clearTimeout },
|
|
138
|
+
...r
|
|
139
|
+
}, r.signal) {
|
|
140
|
+
const { signal: a } = r;
|
|
141
|
+
a.aborted && h(te(a)), a.addEventListener("abort", () => {
|
|
142
|
+
h(te(a));
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
n = r.customTimers.setTimeout.call(void 0, () => {
|
|
146
|
+
const a = `Promise timed out after ${e} milliseconds`, l = t instanceof Error ? t : new ae(a);
|
|
147
|
+
typeof i.cancel == "function" && i.cancel(), h(l);
|
|
148
|
+
}, e), (async () => {
|
|
149
|
+
try {
|
|
150
|
+
d(await i);
|
|
151
|
+
} catch (a) {
|
|
152
|
+
h(a);
|
|
153
|
+
} finally {
|
|
154
|
+
r.customTimers.clearTimeout.call(void 0, n);
|
|
155
|
+
}
|
|
156
|
+
})();
|
|
157
|
+
});
|
|
158
|
+
return o.clear = () => {
|
|
159
|
+
clearTimeout(n), n = void 0;
|
|
160
|
+
}, o;
|
|
161
|
+
}
|
|
162
|
+
function Se(i, e, t) {
|
|
163
|
+
let r = 0, n = i.length;
|
|
164
|
+
for (; n > 0; ) {
|
|
165
|
+
const o = Math.trunc(n / 2);
|
|
166
|
+
let d = r + o;
|
|
167
|
+
t(i[d], e) <= 0 ? (r = ++d, n -= o + 1) : n = o;
|
|
168
|
+
}
|
|
169
|
+
return r;
|
|
170
|
+
}
|
|
171
|
+
var Q = function(i, e, t, r) {
|
|
172
|
+
if (t === "a" && !r) throw new TypeError("Private accessor was defined without a getter");
|
|
173
|
+
if (typeof e == "function" ? i !== e || !r : !e.has(i)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
174
|
+
return t === "m" ? r : t === "a" ? r.call(i) : r ? r.value : e.get(i);
|
|
175
|
+
}, S;
|
|
176
|
+
class Ae {
|
|
177
|
+
constructor() {
|
|
178
|
+
S.set(this, []);
|
|
179
|
+
}
|
|
180
|
+
enqueue(e, t) {
|
|
181
|
+
t = {
|
|
182
|
+
priority: 0,
|
|
183
|
+
...t
|
|
184
|
+
};
|
|
185
|
+
const r = {
|
|
186
|
+
priority: t.priority,
|
|
187
|
+
run: e
|
|
188
|
+
};
|
|
189
|
+
if (this.size && Q(this, S, "f")[this.size - 1].priority >= t.priority) {
|
|
190
|
+
Q(this, S, "f").push(r);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
const n = Se(Q(this, S, "f"), r, (o, d) => d.priority - o.priority);
|
|
194
|
+
Q(this, S, "f").splice(n, 0, r);
|
|
195
|
+
}
|
|
196
|
+
dequeue() {
|
|
197
|
+
const e = Q(this, S, "f").shift();
|
|
198
|
+
return e?.run;
|
|
199
|
+
}
|
|
200
|
+
filter(e) {
|
|
201
|
+
return Q(this, S, "f").filter((t) => t.priority === e.priority).map((t) => t.run);
|
|
202
|
+
}
|
|
203
|
+
get size() {
|
|
204
|
+
return Q(this, S, "f").length;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
S = /* @__PURE__ */ new WeakMap();
|
|
208
|
+
var m = function(i, e, t, r, n) {
|
|
209
|
+
if (r === "m") throw new TypeError("Private method is not writable");
|
|
210
|
+
if (r === "a" && !n) throw new TypeError("Private accessor was defined without a setter");
|
|
211
|
+
if (typeof e == "function" ? i !== e || !n : !e.has(i)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
212
|
+
return r === "a" ? n.call(i, t) : n ? n.value = t : e.set(i, t), t;
|
|
213
|
+
}, s = function(i, e, t, r) {
|
|
214
|
+
if (t === "a" && !r) throw new TypeError("Private accessor was defined without a getter");
|
|
215
|
+
if (typeof e == "function" ? i !== e || !r : !e.has(i)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
216
|
+
return t === "m" ? r : t === "a" ? r.call(i) : r ? r.value : e.get(i);
|
|
217
|
+
}, v, z, M, C, B, N, j, E, L, g, q, P, k, I, $, re, se, oe, ie, ne, R, G, V, K, le, U;
|
|
218
|
+
class ue extends Error {
|
|
219
|
+
}
|
|
220
|
+
class Ie extends Pe {
|
|
221
|
+
// TODO: The `throwOnTimeout` option should affect the return types of `add()` and `addAll()`
|
|
222
|
+
constructor(e) {
|
|
223
|
+
var t, r, n, o;
|
|
224
|
+
if (super(), v.add(this), z.set(this, void 0), M.set(this, void 0), C.set(this, 0), B.set(this, void 0), N.set(this, void 0), j.set(this, 0), E.set(this, void 0), L.set(this, void 0), g.set(this, void 0), q.set(this, void 0), P.set(this, 0), k.set(this, void 0), I.set(this, void 0), $.set(this, void 0), Object.defineProperty(this, "timeout", {
|
|
225
|
+
enumerable: !0,
|
|
226
|
+
configurable: !0,
|
|
227
|
+
writable: !0,
|
|
228
|
+
value: void 0
|
|
229
|
+
}), e = {
|
|
230
|
+
carryoverConcurrencyCount: !1,
|
|
231
|
+
intervalCap: Number.POSITIVE_INFINITY,
|
|
232
|
+
interval: 0,
|
|
233
|
+
concurrency: Number.POSITIVE_INFINITY,
|
|
234
|
+
autoStart: !0,
|
|
235
|
+
queueClass: Ae,
|
|
236
|
+
...e
|
|
237
|
+
}, !(typeof e.intervalCap == "number" && e.intervalCap >= 1))
|
|
238
|
+
throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(r = (t = e.intervalCap) === null || t === void 0 ? void 0 : t.toString()) !== null && r !== void 0 ? r : ""}\` (${typeof e.intervalCap})`);
|
|
239
|
+
if (e.interval === void 0 || !(Number.isFinite(e.interval) && e.interval >= 0))
|
|
240
|
+
throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${(o = (n = e.interval) === null || n === void 0 ? void 0 : n.toString()) !== null && o !== void 0 ? o : ""}\` (${typeof e.interval})`);
|
|
241
|
+
m(this, z, e.carryoverConcurrencyCount, "f"), m(this, M, e.intervalCap === Number.POSITIVE_INFINITY || e.interval === 0, "f"), m(this, B, e.intervalCap, "f"), m(this, N, e.interval, "f"), m(this, g, new e.queueClass(), "f"), m(this, q, e.queueClass, "f"), this.concurrency = e.concurrency, this.timeout = e.timeout, m(this, $, e.throwOnTimeout === !0, "f"), m(this, I, e.autoStart === !1, "f");
|
|
242
|
+
}
|
|
243
|
+
get concurrency() {
|
|
244
|
+
return s(this, k, "f");
|
|
245
|
+
}
|
|
246
|
+
set concurrency(e) {
|
|
247
|
+
if (!(typeof e == "number" && e >= 1))
|
|
248
|
+
throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);
|
|
249
|
+
m(this, k, e, "f"), s(this, v, "m", K).call(this);
|
|
250
|
+
}
|
|
251
|
+
async add(e, t = {}) {
|
|
252
|
+
return t = {
|
|
253
|
+
timeout: this.timeout,
|
|
254
|
+
throwOnTimeout: s(this, $, "f"),
|
|
255
|
+
...t
|
|
256
|
+
}, new Promise((r, n) => {
|
|
257
|
+
s(this, g, "f").enqueue(async () => {
|
|
258
|
+
var o, d, h;
|
|
259
|
+
m(this, P, (d = s(this, P, "f"), d++, d), "f"), m(this, C, (h = s(this, C, "f"), h++, h), "f");
|
|
260
|
+
try {
|
|
261
|
+
if (!((o = t.signal) === null || o === void 0) && o.aborted)
|
|
262
|
+
throw new ue("The task was aborted.");
|
|
263
|
+
let a = e({ signal: t.signal });
|
|
264
|
+
t.timeout && (a = Ee(Promise.resolve(a), t.timeout)), t.signal && (a = Promise.race([a, s(this, v, "m", le).call(this, t.signal)]));
|
|
265
|
+
const l = await a;
|
|
266
|
+
r(l), this.emit("completed", l);
|
|
267
|
+
} catch (a) {
|
|
268
|
+
if (a instanceof ae && !t.throwOnTimeout) {
|
|
269
|
+
r();
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
n(a), this.emit("error", a);
|
|
273
|
+
} finally {
|
|
274
|
+
s(this, v, "m", oe).call(this);
|
|
275
|
+
}
|
|
276
|
+
}, t), this.emit("add"), s(this, v, "m", R).call(this);
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
async addAll(e, t) {
|
|
280
|
+
return Promise.all(e.map(async (r) => this.add(r, t)));
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
Start (or resume) executing enqueued tasks within concurrency limit. No need to call this if queue is not paused (via `options.autoStart = false` or by `.pause()` method.)
|
|
284
|
+
*/
|
|
285
|
+
start() {
|
|
286
|
+
return s(this, I, "f") ? (m(this, I, !1, "f"), s(this, v, "m", K).call(this), this) : this;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
Put queue execution on hold.
|
|
290
|
+
*/
|
|
291
|
+
pause() {
|
|
292
|
+
m(this, I, !0, "f");
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
Clear the queue.
|
|
296
|
+
*/
|
|
297
|
+
clear() {
|
|
298
|
+
m(this, g, new (s(this, q, "f"))(), "f");
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
Can be called multiple times. Useful if you for example add additional items at a later time.
|
|
302
|
+
|
|
303
|
+
@returns A promise that settles when the queue becomes empty.
|
|
304
|
+
*/
|
|
305
|
+
async onEmpty() {
|
|
306
|
+
s(this, g, "f").size !== 0 && await s(this, v, "m", U).call(this, "empty");
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
@returns A promise that settles when the queue size is less than the given limit: `queue.size < limit`.
|
|
310
|
+
|
|
311
|
+
If you want to avoid having the queue grow beyond a certain size you can `await queue.onSizeLessThan()` before adding a new item.
|
|
312
|
+
|
|
313
|
+
Note that this only limits the number of items waiting to start. There could still be up to `concurrency` jobs already running that this call does not include in its calculation.
|
|
314
|
+
*/
|
|
315
|
+
async onSizeLessThan(e) {
|
|
316
|
+
s(this, g, "f").size < e || await s(this, v, "m", U).call(this, "next", () => s(this, g, "f").size < e);
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
The difference with `.onEmpty` is that `.onIdle` guarantees that all work from the queue has finished. `.onEmpty` merely signals that the queue is empty, but it could mean that some promises haven't completed yet.
|
|
320
|
+
|
|
321
|
+
@returns A promise that settles when the queue becomes empty, and all promises have completed; `queue.size === 0 && queue.pending === 0`.
|
|
322
|
+
*/
|
|
323
|
+
async onIdle() {
|
|
324
|
+
s(this, P, "f") === 0 && s(this, g, "f").size === 0 || await s(this, v, "m", U).call(this, "idle");
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
Size of the queue, the number of queued items waiting to run.
|
|
328
|
+
*/
|
|
329
|
+
get size() {
|
|
330
|
+
return s(this, g, "f").size;
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
Size of the queue, filtered by the given options.
|
|
334
|
+
|
|
335
|
+
For example, this can be used to find the number of items remaining in the queue with a specific priority level.
|
|
336
|
+
*/
|
|
337
|
+
sizeBy(e) {
|
|
338
|
+
return s(this, g, "f").filter(e).length;
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
Number of running items (no longer in the queue).
|
|
342
|
+
*/
|
|
343
|
+
get pending() {
|
|
344
|
+
return s(this, P, "f");
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
Whether the queue is currently paused.
|
|
348
|
+
*/
|
|
349
|
+
get isPaused() {
|
|
350
|
+
return s(this, I, "f");
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
z = /* @__PURE__ */ new WeakMap(), M = /* @__PURE__ */ new WeakMap(), C = /* @__PURE__ */ new WeakMap(), B = /* @__PURE__ */ new WeakMap(), N = /* @__PURE__ */ new WeakMap(), j = /* @__PURE__ */ new WeakMap(), E = /* @__PURE__ */ new WeakMap(), L = /* @__PURE__ */ new WeakMap(), g = /* @__PURE__ */ new WeakMap(), q = /* @__PURE__ */ new WeakMap(), P = /* @__PURE__ */ new WeakMap(), k = /* @__PURE__ */ new WeakMap(), I = /* @__PURE__ */ new WeakMap(), $ = /* @__PURE__ */ new WeakMap(), v = /* @__PURE__ */ new WeakSet(), re = function() {
|
|
354
|
+
return s(this, M, "f") || s(this, C, "f") < s(this, B, "f");
|
|
355
|
+
}, se = function() {
|
|
356
|
+
return s(this, P, "f") < s(this, k, "f");
|
|
357
|
+
}, oe = function() {
|
|
358
|
+
var e;
|
|
359
|
+
m(this, P, (e = s(this, P, "f"), e--, e), "f"), s(this, v, "m", R).call(this), this.emit("next");
|
|
360
|
+
}, ie = function() {
|
|
361
|
+
s(this, v, "m", V).call(this), s(this, v, "m", G).call(this), m(this, L, void 0, "f");
|
|
362
|
+
}, ne = function() {
|
|
363
|
+
const e = Date.now();
|
|
364
|
+
if (s(this, E, "f") === void 0) {
|
|
365
|
+
const t = s(this, j, "f") - e;
|
|
366
|
+
if (t < 0)
|
|
367
|
+
m(this, C, s(this, z, "f") ? s(this, P, "f") : 0, "f");
|
|
368
|
+
else
|
|
369
|
+
return s(this, L, "f") === void 0 && m(this, L, setTimeout(() => {
|
|
370
|
+
s(this, v, "m", ie).call(this);
|
|
371
|
+
}, t), "f"), !0;
|
|
372
|
+
}
|
|
373
|
+
return !1;
|
|
374
|
+
}, R = function() {
|
|
375
|
+
if (s(this, g, "f").size === 0)
|
|
376
|
+
return s(this, E, "f") && clearInterval(s(this, E, "f")), m(this, E, void 0, "f"), this.emit("empty"), s(this, P, "f") === 0 && this.emit("idle"), !1;
|
|
377
|
+
if (!s(this, I, "f")) {
|
|
378
|
+
const e = !s(this, v, "a", ne);
|
|
379
|
+
if (s(this, v, "a", re) && s(this, v, "a", se)) {
|
|
380
|
+
const t = s(this, g, "f").dequeue();
|
|
381
|
+
return t ? (this.emit("active"), t(), e && s(this, v, "m", G).call(this), !0) : !1;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
return !1;
|
|
385
|
+
}, G = function() {
|
|
386
|
+
s(this, M, "f") || s(this, E, "f") !== void 0 || (m(this, E, setInterval(() => {
|
|
387
|
+
s(this, v, "m", V).call(this);
|
|
388
|
+
}, s(this, N, "f")), "f"), m(this, j, Date.now() + s(this, N, "f"), "f"));
|
|
389
|
+
}, V = function() {
|
|
390
|
+
s(this, C, "f") === 0 && s(this, P, "f") === 0 && s(this, E, "f") && (clearInterval(s(this, E, "f")), m(this, E, void 0, "f")), m(this, C, s(this, z, "f") ? s(this, P, "f") : 0, "f"), s(this, v, "m", K).call(this);
|
|
391
|
+
}, K = function() {
|
|
392
|
+
for (; s(this, v, "m", R).call(this); )
|
|
393
|
+
;
|
|
394
|
+
}, le = async function(e) {
|
|
395
|
+
return new Promise((t, r) => {
|
|
396
|
+
e.addEventListener("abort", () => {
|
|
397
|
+
r(new ue("The task was aborted."));
|
|
398
|
+
}, { once: !0 });
|
|
399
|
+
});
|
|
400
|
+
}, U = async function(e, t) {
|
|
401
|
+
return new Promise((r) => {
|
|
402
|
+
const n = () => {
|
|
403
|
+
t && !t() || (this.off(e, n), r());
|
|
404
|
+
};
|
|
405
|
+
this.on(e, n);
|
|
406
|
+
});
|
|
407
|
+
};
|
|
408
|
+
class Ce {
|
|
409
|
+
constructor(e) {
|
|
410
|
+
this.apisStorage = e;
|
|
411
|
+
}
|
|
412
|
+
apisStorage;
|
|
413
|
+
data = /* @__PURE__ */ new Map();
|
|
414
|
+
loading = /* @__PURE__ */ new Set();
|
|
415
|
+
pQueue = new Ie({ concurrency: 20 });
|
|
416
|
+
async get(e) {
|
|
417
|
+
return this.data.has(e) ? this.data.get(e) ?? null : (await this.loadAndParse(e), this.data.get(e) ?? null);
|
|
418
|
+
}
|
|
419
|
+
async load(e, t = !1) {
|
|
420
|
+
this.data.has(e) && !t || await this.loadAndParse(e, t);
|
|
421
|
+
}
|
|
422
|
+
async loadAndParse(e, t = !1) {
|
|
423
|
+
if (this.loading.has(e)) {
|
|
424
|
+
await this.pQueue.add(() => this.get(e));
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
t && this.data.delete(e), this.loading.add(e), await this.pQueue.add(async () => {
|
|
428
|
+
const r = fe(e) ? D.WEB : D.FS, n = r === D.WEB ? e : await this.apisStorage.getAbsolutePath(e);
|
|
429
|
+
try {
|
|
430
|
+
const { definition: o, fileDependencies: d } = await de(n);
|
|
431
|
+
if (!o) {
|
|
432
|
+
this.data.set(e, null), await W(e);
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
const h = this.apisStorage.parse({ uri: e, type: r, content: o });
|
|
436
|
+
this.data.set(e, {
|
|
437
|
+
...h,
|
|
438
|
+
fileDependencies: d
|
|
439
|
+
}), await W(e);
|
|
440
|
+
} catch (o) {
|
|
441
|
+
if (this.data.set(e, null), o instanceof Error && (o.message.includes("Unsupported specification") || o.message.includes("File not found"))) {
|
|
442
|
+
await W(e);
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
console.info("Error loading api " + e, o), await J(e, o);
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
}), this.loading.delete(e);
|
|
449
|
+
}
|
|
450
|
+
get size() {
|
|
451
|
+
return this.data.size;
|
|
452
|
+
}
|
|
453
|
+
delete(e) {
|
|
454
|
+
this.data.delete(e);
|
|
455
|
+
}
|
|
456
|
+
getAll() {
|
|
457
|
+
return Array.from(this.data.values()).filter((e) => e !== null);
|
|
458
|
+
}
|
|
459
|
+
clear() {
|
|
460
|
+
this.data.clear(), this.loading.clear();
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
class Oe extends pe {
|
|
464
|
+
apiLoader;
|
|
465
|
+
constructor(e, t, r) {
|
|
466
|
+
const n = new X(e.systemFilesDir), o = new X(e.userFilesDir);
|
|
467
|
+
super(
|
|
468
|
+
n,
|
|
469
|
+
o,
|
|
470
|
+
e,
|
|
471
|
+
!0,
|
|
472
|
+
t,
|
|
473
|
+
r
|
|
474
|
+
), this.apiLoader = new Ce(this.apisStorage), this.setupWriteListeners(o);
|
|
475
|
+
}
|
|
476
|
+
setupWriteListeners(e) {
|
|
477
|
+
e.on("write-start", (t) => {
|
|
478
|
+
this.addWatchExcludedId(t);
|
|
479
|
+
}), e.on("write-end", (t) => {
|
|
480
|
+
this.removeWatchExcludedId(t);
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
async read() {
|
|
484
|
+
const e = this.telemetry?.startSpan(
|
|
485
|
+
"com.redocly.storage.read",
|
|
486
|
+
[F("storageOperation", "read", "storage")],
|
|
487
|
+
void 0
|
|
488
|
+
), t = this.telemetry?.startSpan(
|
|
489
|
+
"com.redocly.storage.loadUserState",
|
|
490
|
+
[F("storageOperation", "loadUserState", "storage")],
|
|
491
|
+
e?.parentCtx
|
|
492
|
+
), [r, n, o] = await Promise.all([
|
|
493
|
+
this.activeEnvironmentIdStorage.read(),
|
|
494
|
+
this.tabsStateStorage.read(),
|
|
495
|
+
this.environmentsStorage.read()
|
|
496
|
+
]);
|
|
497
|
+
t?.setAttribute("status", "completed"), t?.setAttribute("environmentCount", o.length), t?.setStatus(O.OK), t?.end();
|
|
498
|
+
const { apiFiles: d, collectionFiles: h } = await this.detectProjectFiles(e);
|
|
499
|
+
await this.loadAndParseApis(d, e);
|
|
500
|
+
const l = (await this.loadAndParseCollections(h, e)).filter((u) => u !== null);
|
|
501
|
+
this.collectionsStorage.setItemIds(l.map((u) => u.id));
|
|
502
|
+
const f = this.apiLoader.getAll();
|
|
503
|
+
return this.apisStorage.setItemIds(f.map((u) => u.id)), e?.setAttribute("status", "completed"), e?.setStatus(O.OK), e?.end(), {
|
|
504
|
+
project: this.project,
|
|
505
|
+
activeEnvironmentId: r,
|
|
506
|
+
tabsState: n,
|
|
507
|
+
environments: o,
|
|
508
|
+
apis: f,
|
|
509
|
+
collections: l
|
|
510
|
+
};
|
|
511
|
+
}
|
|
512
|
+
async detectProjectFiles(e) {
|
|
513
|
+
const t = this.telemetry?.startSpan(
|
|
514
|
+
"com.redocly.storage.detectFiles",
|
|
515
|
+
[F("storageOperation", "detectFiles", "storage")],
|
|
516
|
+
e?.parentCtx
|
|
517
|
+
), { api_files: r, collection_files: n } = await me(
|
|
518
|
+
"fs_scan",
|
|
519
|
+
{ dir: this.project.userFilesDir }
|
|
520
|
+
);
|
|
521
|
+
return t?.setAttribute("status", "completed"), t?.setAttribute("filesCount", r.length + n.length), t?.setAttribute("apiFilesCount", r.length), t?.setAttribute("collectionFilesCount", n.length), t?.setStatus(O.OK), t?.end(), {
|
|
522
|
+
apiFiles: r,
|
|
523
|
+
collectionFiles: n
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
readEnviroments() {
|
|
527
|
+
return this.environmentsStorage.read();
|
|
528
|
+
}
|
|
529
|
+
deleteApiFromCache(e) {
|
|
530
|
+
this.apiLoader.delete(e);
|
|
531
|
+
}
|
|
532
|
+
async loadAndParseApis(e, t, r = !1) {
|
|
533
|
+
const n = this.telemetry?.startSpan(
|
|
534
|
+
"com.redocly.storage.parseApis",
|
|
535
|
+
[
|
|
536
|
+
{
|
|
537
|
+
...F("storageOperation", "parseApis", "storage"),
|
|
538
|
+
apisCount: e.length
|
|
539
|
+
}
|
|
540
|
+
],
|
|
541
|
+
t?.parentCtx
|
|
542
|
+
), o = await H(e, 20, async (d) => {
|
|
543
|
+
try {
|
|
544
|
+
return await this.apiLoader.load(d.relative_path, r), this.apiLoader.get(d.relative_path);
|
|
545
|
+
} catch (h) {
|
|
546
|
+
return console.info(`Error parsing YAML/JSON file ${d.absolute_path}:`, h), await J(d.relative_path, h), null;
|
|
547
|
+
}
|
|
548
|
+
});
|
|
549
|
+
return n?.setAttribute("status", "completed"), n?.setAttribute("parsedApisCount", this.apiLoader.size), n?.setStatus(O.OK), n?.end(), o;
|
|
550
|
+
}
|
|
551
|
+
async loadAndParseCollections(e, t) {
|
|
552
|
+
const r = this.telemetry?.startSpan(
|
|
553
|
+
"com.redocly.storage.parseCollections",
|
|
554
|
+
[
|
|
555
|
+
{
|
|
556
|
+
...F("storageOperation", "parseCollections", "storage"),
|
|
557
|
+
collectionsCount: e.length
|
|
558
|
+
}
|
|
559
|
+
],
|
|
560
|
+
t?.parentCtx
|
|
561
|
+
), n = await H(e, 20, async (o) => {
|
|
562
|
+
try {
|
|
563
|
+
const d = await this.userFilesStorage.get(o.relative_path);
|
|
564
|
+
if (!d)
|
|
565
|
+
return null;
|
|
566
|
+
const h = ve.load(d);
|
|
567
|
+
if (typeof h != "object" || h === null || typeof h.arazzo != "string")
|
|
568
|
+
return await W(o.relative_path), null;
|
|
569
|
+
const a = [];
|
|
570
|
+
await Promise.all(
|
|
571
|
+
h.sourceDescriptions?.map(async (u) => {
|
|
572
|
+
const y = u.type, w = u.url, p = !y || y === "openapi", b = await _e({
|
|
573
|
+
projectPath: this.project.userFilesDir,
|
|
574
|
+
apiUrl: w,
|
|
575
|
+
collectionId: o.relative_path
|
|
576
|
+
});
|
|
577
|
+
if (p) {
|
|
578
|
+
const c = await this.apiLoader.get(b);
|
|
579
|
+
c && a.push(c);
|
|
580
|
+
}
|
|
581
|
+
})
|
|
582
|
+
);
|
|
583
|
+
const l = await we.join(
|
|
584
|
+
this.project.userFilesDir,
|
|
585
|
+
o.relative_path
|
|
586
|
+
), f = await this.collectionsStorage.parse(
|
|
587
|
+
{
|
|
588
|
+
uri: o.relative_path,
|
|
589
|
+
type: D.FS,
|
|
590
|
+
content: h,
|
|
591
|
+
fileDependencies: /* @__PURE__ */ new Set([l])
|
|
592
|
+
},
|
|
593
|
+
a
|
|
594
|
+
);
|
|
595
|
+
return await W(o.relative_path), f;
|
|
596
|
+
} catch (d) {
|
|
597
|
+
return console.info(`Error parsing Arazzo file ${o.relative_path}:`, d), await J(o.relative_path, d), null;
|
|
598
|
+
}
|
|
599
|
+
});
|
|
600
|
+
return r?.setAttribute("status", "completed"), r?.setAttribute("parsedCollectionsCount", n.length), r?.setStatus(O.OK), r?.end(), n;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
export {
|
|
604
|
+
Oe as TauriRootStorage
|
|
605
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("./replay-index-CepJ5Z0m.js"),Y=require("./replay-promise-map-limit-DRDkHc-b.js"),G=require("./replay-TauriFileSystemAdapter-dwJ0xBYr.js");var U={exports:{}},V;function oe(){return V||(V=1,(function(s){var e=Object.prototype.hasOwnProperty,t="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(t=!1));function n(a,u,f){this.fn=a,this.context=u,this.once=f||!1}function o(a,u,f,l,g){if(typeof f!="function")throw new TypeError("The listener must be a function");var y=new n(f,l||a,g),m=t?t+u:u;return a._events[m]?a._events[m].fn?a._events[m]=[a._events[m],y]:a._events[m].push(y):(a._events[m]=y,a._eventsCount++),a}function d(a,u){--a._eventsCount===0?a._events=new r:delete a._events[u]}function h(){this._events=new r,this._eventsCount=0}h.prototype.eventNames=function(){var u=[],f,l;if(this._eventsCount===0)return u;for(l in f=this._events)e.call(f,l)&&u.push(t?l.slice(1):l);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(f)):u},h.prototype.listeners=function(u){var f=t?t+u:u,l=this._events[f];if(!l)return[];if(l.fn)return[l.fn];for(var g=0,y=l.length,m=new Array(y);g<y;g++)m[g]=l[g].fn;return m},h.prototype.listenerCount=function(u){var f=t?t+u:u,l=this._events[f];return l?l.fn?1:l.length:0},h.prototype.emit=function(u,f,l,g,y,m){var b=t?t+u:u;if(!this._events[b])return!1;var c=this._events[b],T=arguments.length,Q,w;if(c.fn){switch(c.once&&this.removeListener(u,c.fn,void 0,!0),T){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,f),!0;case 3:return c.fn.call(c.context,f,l),!0;case 4:return c.fn.call(c.context,f,l,g),!0;case 5:return c.fn.call(c.context,f,l,g,y),!0;case 6:return c.fn.call(c.context,f,l,g,y,m),!0}for(w=1,Q=new Array(T-1);w<T;w++)Q[w-1]=arguments[w];c.fn.apply(c.context,Q)}else{var ae=c.length,x;for(w=0;w<ae;w++)switch(c[w].once&&this.removeListener(u,c[w].fn,void 0,!0),T){case 1:c[w].fn.call(c[w].context);break;case 2:c[w].fn.call(c[w].context,f);break;case 3:c[w].fn.call(c[w].context,f,l);break;case 4:c[w].fn.call(c[w].context,f,l,g);break;default:if(!Q)for(x=1,Q=new Array(T-1);x<T;x++)Q[x-1]=arguments[x];c[w].fn.apply(c[w].context,Q)}}return!0},h.prototype.on=function(u,f,l){return o(this,u,f,l,!1)},h.prototype.once=function(u,f,l){return o(this,u,f,l,!0)},h.prototype.removeListener=function(u,f,l,g){var y=t?t+u:u;if(!this._events[y])return this;if(!f)return d(this,y),this;var m=this._events[y];if(m.fn)m.fn===f&&(!g||m.once)&&(!l||m.context===l)&&d(this,y);else{for(var b=0,c=[],T=m.length;b<T;b++)(m[b].fn!==f||g&&!m[b].once||l&&m[b].context!==l)&&c.push(m[b]);c.length?this._events[y]=c.length===1?c[0]:c:d(this,y)}return this},h.prototype.removeAllListeners=function(u){var f;return u?(f=t?t+u:u,this._events[f]&&d(this,f)):(this._events=new r,this._eventsCount=0),this},h.prototype.off=h.prototype.removeListener,h.prototype.addListener=h.prototype.on,h.prefixed=t,h.EventEmitter=h,s.exports=h})(U)),U.exports}var ue=oe();const le=p.getDefaultExportFromCjs(ue);class re extends Error{constructor(e){super(e),this.name="TimeoutError"}}let ce=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}};const J=s=>globalThis.DOMException===void 0?new ce(s):new DOMException(s),H=s=>{const e=s.reason===void 0?J("This operation was aborted."):s.reason;return e instanceof Error?e:J(e)};function he(s,e,t,r){let n;const o=new Promise((d,h)=>{if(typeof e!="number"||Math.sign(e)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${e}\``);if(e===Number.POSITIVE_INFINITY){d(s);return}if(r={customTimers:{setTimeout,clearTimeout},...r},r.signal){const{signal:a}=r;a.aborted&&h(H(a)),a.addEventListener("abort",()=>{h(H(a))})}n=r.customTimers.setTimeout.call(void 0,()=>{const a=`Promise timed out after ${e} milliseconds`,u=t instanceof Error?t:new re(a);typeof s.cancel=="function"&&s.cancel(),h(u)},e),(async()=>{try{d(await s)}catch(a){h(a)}finally{r.customTimers.clearTimeout.call(void 0,n)}})()});return o.clear=()=>{clearTimeout(n),n=void 0},o}function fe(s,e,t){let r=0,n=s.length;for(;n>0;){const o=Math.trunc(n/2);let d=r+o;t(s[d],e)<=0?(r=++d,n-=o+1):n=o}return r}var F=function(s,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?s!==e||!r:!e.has(s))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(s):r?r.value:e.get(s)},A;class de{constructor(){A.set(this,[])}enqueue(e,t){t={priority:0,...t};const r={priority:t.priority,run:e};if(this.size&&F(this,A,"f")[this.size-1].priority>=t.priority){F(this,A,"f").push(r);return}const n=fe(F(this,A,"f"),r,(o,d)=>d.priority-o.priority);F(this,A,"f").splice(n,0,r)}dequeue(){const e=F(this,A,"f").shift();return e?.run}filter(e){return F(this,A,"f").filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return F(this,A,"f").length}}A=new WeakMap;var v=function(s,e,t,r,n){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?s!==e||!n:!e.has(s))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?n.call(s,t):n?n.value=t:e.set(s,t),t},i=function(s,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?s!==e||!r:!e.has(s))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(s):r?r.value:e.get(s)},_,L,M,I,R,N,z,E,O,P,k,S,W,C,q,X,Z,ie,ee,te,D,B,K,$,se,j;class ne extends Error{}class pe extends le{constructor(e){var t,r,n,o;if(super(),_.add(this),L.set(this,void 0),M.set(this,void 0),I.set(this,0),R.set(this,void 0),N.set(this,void 0),z.set(this,0),E.set(this,void 0),O.set(this,void 0),P.set(this,void 0),k.set(this,void 0),S.set(this,0),W.set(this,void 0),C.set(this,void 0),q.set(this,void 0),Object.defineProperty(this,"timeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:de,...e},!(typeof e.intervalCap=="number"&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(r=(t=e.intervalCap)===null||t===void 0?void 0:t.toString())!==null&&r!==void 0?r:""}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${(o=(n=e.interval)===null||n===void 0?void 0:n.toString())!==null&&o!==void 0?o:""}\` (${typeof e.interval})`);v(this,L,e.carryoverConcurrencyCount,"f"),v(this,M,e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,"f"),v(this,R,e.intervalCap,"f"),v(this,N,e.interval,"f"),v(this,P,new e.queueClass,"f"),v(this,k,e.queueClass,"f"),this.concurrency=e.concurrency,this.timeout=e.timeout,v(this,q,e.throwOnTimeout===!0,"f"),v(this,C,e.autoStart===!1,"f")}get concurrency(){return i(this,W,"f")}set concurrency(e){if(!(typeof e=="number"&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);v(this,W,e,"f"),i(this,_,"m",$).call(this)}async add(e,t={}){return t={timeout:this.timeout,throwOnTimeout:i(this,q,"f"),...t},new Promise((r,n)=>{i(this,P,"f").enqueue(async()=>{var o,d,h;v(this,S,(d=i(this,S,"f"),d++,d),"f"),v(this,I,(h=i(this,I,"f"),h++,h),"f");try{if(!((o=t.signal)===null||o===void 0)&&o.aborted)throw new ne("The task was aborted.");let a=e({signal:t.signal});t.timeout&&(a=he(Promise.resolve(a),t.timeout)),t.signal&&(a=Promise.race([a,i(this,_,"m",se).call(this,t.signal)]));const u=await a;r(u),this.emit("completed",u)}catch(a){if(a instanceof re&&!t.throwOnTimeout){r();return}n(a),this.emit("error",a)}finally{i(this,_,"m",ie).call(this)}},t),this.emit("add"),i(this,_,"m",D).call(this)})}async addAll(e,t){return Promise.all(e.map(async r=>this.add(r,t)))}start(){return i(this,C,"f")?(v(this,C,!1,"f"),i(this,_,"m",$).call(this),this):this}pause(){v(this,C,!0,"f")}clear(){v(this,P,new(i(this,k,"f")),"f")}async onEmpty(){i(this,P,"f").size!==0&&await i(this,_,"m",j).call(this,"empty")}async onSizeLessThan(e){i(this,P,"f").size<e||await i(this,_,"m",j).call(this,"next",()=>i(this,P,"f").size<e)}async onIdle(){i(this,S,"f")===0&&i(this,P,"f").size===0||await i(this,_,"m",j).call(this,"idle")}get size(){return i(this,P,"f").size}sizeBy(e){return i(this,P,"f").filter(e).length}get pending(){return i(this,S,"f")}get isPaused(){return i(this,C,"f")}}L=new WeakMap,M=new WeakMap,I=new WeakMap,R=new WeakMap,N=new WeakMap,z=new WeakMap,E=new WeakMap,O=new WeakMap,P=new WeakMap,k=new WeakMap,S=new WeakMap,W=new WeakMap,C=new WeakMap,q=new WeakMap,_=new WeakSet,X=function(){return i(this,M,"f")||i(this,I,"f")<i(this,R,"f")},Z=function(){return i(this,S,"f")<i(this,W,"f")},ie=function(){var e;v(this,S,(e=i(this,S,"f"),e--,e),"f"),i(this,_,"m",D).call(this),this.emit("next")},ee=function(){i(this,_,"m",K).call(this),i(this,_,"m",B).call(this),v(this,O,void 0,"f")},te=function(){const e=Date.now();if(i(this,E,"f")===void 0){const t=i(this,z,"f")-e;if(t<0)v(this,I,i(this,L,"f")?i(this,S,"f"):0,"f");else return i(this,O,"f")===void 0&&v(this,O,setTimeout(()=>{i(this,_,"m",ee).call(this)},t),"f"),!0}return!1},D=function(){if(i(this,P,"f").size===0)return i(this,E,"f")&&clearInterval(i(this,E,"f")),v(this,E,void 0,"f"),this.emit("empty"),i(this,S,"f")===0&&this.emit("idle"),!1;if(!i(this,C,"f")){const e=!i(this,_,"a",te);if(i(this,_,"a",X)&&i(this,_,"a",Z)){const t=i(this,P,"f").dequeue();return t?(this.emit("active"),t(),e&&i(this,_,"m",B).call(this),!0):!1}}return!1},B=function(){i(this,M,"f")||i(this,E,"f")!==void 0||(v(this,E,setInterval(()=>{i(this,_,"m",K).call(this)},i(this,N,"f")),"f"),v(this,z,Date.now()+i(this,N,"f"),"f"))},K=function(){i(this,I,"f")===0&&i(this,S,"f")===0&&i(this,E,"f")&&(clearInterval(i(this,E,"f")),v(this,E,void 0,"f")),v(this,I,i(this,L,"f")?i(this,S,"f"):0,"f"),i(this,_,"m",$).call(this)},$=function(){for(;i(this,_,"m",D).call(this););},se=async function(e){return new Promise((t,r)=>{e.addEventListener("abort",()=>{r(new ne("The task was aborted."))},{once:!0})})},j=async function(e,t){return new Promise(r=>{const n=()=>{t&&!t()||(this.off(e,n),r())};this.on(e,n)})};class me{constructor(e){this.apisStorage=e}apisStorage;data=new Map;loading=new Set;pQueue=new pe({concurrency:20});async get(e){return this.data.has(e)?this.data.get(e)??null:(await this.loadAndParse(e),this.data.get(e)??null)}async load(e,t=!1){this.data.has(e)&&!t||await this.loadAndParse(e,t)}async loadAndParse(e,t=!1){if(this.loading.has(e)){await this.pQueue.add(()=>this.get(e));return}t&&this.data.delete(e),this.loading.add(e),await this.pQueue.add(async()=>{const r=p.isWebUrl(e)?p.SourceType.WEB:p.SourceType.FS,n=r===p.SourceType.WEB?e:await this.apisStorage.getAbsolutePath(e);try{const{definition:o,fileDependencies:d}=await p.loadAndBundleDefinition(n);if(!o){this.data.set(e,null),await p.clearNotificationsForSource(e);return}const h=this.apisStorage.parse({uri:e,type:r,content:o});this.data.set(e,{...h,fileDependencies:d}),await p.clearNotificationsForSource(e)}catch(o){if(this.data.set(e,null),o instanceof Error&&(o.message.includes("Unsupported specification")||o.message.includes("File not found"))){await p.clearNotificationsForSource(e);return}console.info("Error loading api "+e,o),await p.reportParseError(e,o);return}}),this.loading.delete(e)}get size(){return this.data.size}delete(e){this.data.delete(e)}getAll(){return Array.from(this.data.values()).filter(e=>e!==null)}clear(){this.data.clear(),this.loading.clear()}}class ve extends p.RootStorage{apiLoader;constructor(e,t,r){const n=new G.TauriFileSystemAdapter(e.systemFilesDir),o=new G.TauriFileSystemAdapter(e.userFilesDir);super(n,o,e,!0,t,r),this.apiLoader=new me(this.apisStorage),this.setupWriteListeners(o)}setupWriteListeners(e){e.on("write-start",t=>{this.addWatchExcludedId(t)}),e.on("write-end",t=>{this.removeWatchExcludedId(t)})}async read(){const e=this.telemetry?.startSpan("com.redocly.storage.read",[p.createResource("storageOperation","read","storage")],void 0),t=this.telemetry?.startSpan("com.redocly.storage.loadUserState",[p.createResource("storageOperation","loadUserState","storage")],e?.parentCtx),[r,n,o]=await Promise.all([this.activeEnvironmentIdStorage.read(),this.tabsStateStorage.read(),this.environmentsStorage.read()]);t?.setAttribute("status","completed"),t?.setAttribute("environmentCount",o.length),t?.setStatus(p.SpanStatusCode.OK),t?.end();const{apiFiles:d,collectionFiles:h}=await this.detectProjectFiles(e);await this.loadAndParseApis(d,e);const u=(await this.loadAndParseCollections(h,e)).filter(l=>l!==null);this.collectionsStorage.setItemIds(u.map(l=>l.id));const f=this.apiLoader.getAll();return this.apisStorage.setItemIds(f.map(l=>l.id)),e?.setAttribute("status","completed"),e?.setStatus(p.SpanStatusCode.OK),e?.end(),{project:this.project,activeEnvironmentId:r,tabsState:n,environments:o,apis:f,collections:u}}async detectProjectFiles(e){const t=this.telemetry?.startSpan("com.redocly.storage.detectFiles",[p.createResource("storageOperation","detectFiles","storage")],e?.parentCtx),{api_files:r,collection_files:n}=await p.invoke("fs_scan",{dir:this.project.userFilesDir});return t?.setAttribute("status","completed"),t?.setAttribute("filesCount",r.length+n.length),t?.setAttribute("apiFilesCount",r.length),t?.setAttribute("collectionFilesCount",n.length),t?.setStatus(p.SpanStatusCode.OK),t?.end(),{apiFiles:r,collectionFiles:n}}readEnviroments(){return this.environmentsStorage.read()}deleteApiFromCache(e){this.apiLoader.delete(e)}async loadAndParseApis(e,t,r=!1){const n=this.telemetry?.startSpan("com.redocly.storage.parseApis",[{...p.createResource("storageOperation","parseApis","storage"),apisCount:e.length}],t?.parentCtx),o=await Y.promiseMapLimit(e,20,async d=>{try{return await this.apiLoader.load(d.relative_path,r),this.apiLoader.get(d.relative_path)}catch(h){return console.info(`Error parsing YAML/JSON file ${d.absolute_path}:`,h),await p.reportParseError(d.relative_path,h),null}});return n?.setAttribute("status","completed"),n?.setAttribute("parsedApisCount",this.apiLoader.size),n?.setStatus(p.SpanStatusCode.OK),n?.end(),o}async loadAndParseCollections(e,t){const r=this.telemetry?.startSpan("com.redocly.storage.parseCollections",[{...p.createResource("storageOperation","parseCollections","storage"),collectionsCount:e.length}],t?.parentCtx),n=await Y.promiseMapLimit(e,20,async o=>{try{const d=await this.userFilesStorage.get(o.relative_path);if(!d)return null;const h=p.yaml.load(d);if(typeof h!="object"||h===null||typeof h.arazzo!="string")return await p.clearNotificationsForSource(o.relative_path),null;const a=[];await Promise.all(h.sourceDescriptions?.map(async l=>{const g=l.type,y=l.url,m=!g||g==="openapi",b=await p.apiUrlToApiId({projectPath:this.project.userFilesDir,apiUrl:y,collectionId:o.relative_path});if(m){const c=await this.apiLoader.get(b);c&&a.push(c)}}));const u=await p.PathUtils.join(this.project.userFilesDir,o.relative_path),f=await this.collectionsStorage.parse({uri:o.relative_path,type:p.SourceType.FS,content:h,fileDependencies:new Set([u])},a);return await p.clearNotificationsForSource(o.relative_path),f}catch(d){return console.info(`Error parsing Arazzo file ${o.relative_path}:`,d),await p.reportParseError(o.relative_path,d),null}});return r?.setAttribute("status","completed"),r?.setAttribute("parsedCollectionsCount",n.length),r?.setStatus(p.SpanStatusCode.OK),r?.end(),n}}exports.TauriRootStorage=ve;
|