@mauroandre/velojs 0.0.56 → 0.0.57
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/README.md +121 -24
- package/agent/AGENTS.md +84 -17
- package/agent/skills/velojs-live-loader/SKILL.md +105 -24
- package/dist/channels.d.ts +109 -28
- package/dist/channels.js +285 -192
- package/dist/client.js +8 -7
- package/dist/live-loader.d.ts +40 -7
- package/dist/live-loader.js +91 -81
- package/dist/server.d.ts +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.js +231 -228
- package/dist/testing/types.d.ts +21 -4
- package/package.json +1 -1
package/dist/channels.js
CHANGED
|
@@ -1,110 +1,156 @@
|
|
|
1
|
-
import { DEFAULT_HEARTBEAT_MS as
|
|
2
|
-
const
|
|
3
|
-
let
|
|
4
|
-
function
|
|
5
|
-
|
|
1
|
+
import { DEFAULT_HEARTBEAT_MS as J } from "./events.js";
|
|
2
|
+
const U = "snapshot", V = "slice", ne = "error", oe = "close", H = 50, W = 3e5;
|
|
3
|
+
let d = {}, O = H, M = W, N = J, F = !0;
|
|
4
|
+
function ye(e, t) {
|
|
5
|
+
d = e ? { ...e } : {}, O = t?.coalesceMs ?? H, M = t?.idleMs ?? W, N = t?.heartbeatMs ?? J, F = t?.logEmits ?? !0, Q(), E.clear();
|
|
6
6
|
}
|
|
7
|
-
function
|
|
8
|
-
return
|
|
7
|
+
function we() {
|
|
8
|
+
return d;
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
return Object.keys(
|
|
10
|
+
function ge() {
|
|
11
|
+
return Object.keys(d);
|
|
12
12
|
}
|
|
13
|
-
const
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
v.delete(n), G(e, t);
|
|
22
|
-
}, C), r = o.unref;
|
|
23
|
-
typeof r == "function" && r.call(o), v.set(n, { timer: o, channel: e, partition: t });
|
|
13
|
+
const f = /* @__PURE__ */ new Map(), E = /* @__PURE__ */ new Map(), $ = /* @__PURE__ */ new Map();
|
|
14
|
+
function se(e, t) {
|
|
15
|
+
const r = P(e, t);
|
|
16
|
+
if ($.has(r)) return;
|
|
17
|
+
const n = setTimeout(() => {
|
|
18
|
+
$.delete(r), Y(e, t);
|
|
19
|
+
}, O), o = n.unref;
|
|
20
|
+
typeof o == "function" && o.call(n), $.set(r, { timer: n, channel: e, partition: t });
|
|
24
21
|
}
|
|
25
|
-
function
|
|
26
|
-
for (const e of
|
|
27
|
-
|
|
22
|
+
function Q() {
|
|
23
|
+
for (const e of $.values()) clearTimeout(e.timer);
|
|
24
|
+
$.clear();
|
|
28
25
|
}
|
|
29
|
-
function
|
|
26
|
+
function ve() {
|
|
30
27
|
const e = [];
|
|
31
28
|
let t = 0;
|
|
32
|
-
for (const [
|
|
33
|
-
const
|
|
34
|
-
for (const [
|
|
35
|
-
const
|
|
36
|
-
for (const
|
|
37
|
-
const
|
|
38
|
-
|
|
29
|
+
for (const [n, o] of f) {
|
|
30
|
+
const s = [];
|
|
31
|
+
for (const [l, c] of o) {
|
|
32
|
+
const p = /* @__PURE__ */ new Map();
|
|
33
|
+
for (const a of c) {
|
|
34
|
+
const u = p.get(a.moduleId) ?? { count: 0, last: void 0 };
|
|
35
|
+
u.count += 1, a.lastDeliveryAt !== void 0 && (u.last === void 0 || a.lastDeliveryAt > u.last) && (u.last = a.lastDeliveryAt), p.set(a.moduleId, u);
|
|
39
36
|
}
|
|
40
|
-
for (const [
|
|
41
|
-
|
|
42
|
-
moduleId:
|
|
43
|
-
partition:
|
|
44
|
-
connections:
|
|
45
|
-
lastDeliveryAt:
|
|
37
|
+
for (const [a, u] of p)
|
|
38
|
+
s.push({
|
|
39
|
+
moduleId: a,
|
|
40
|
+
partition: l,
|
|
41
|
+
connections: u.count,
|
|
42
|
+
lastDeliveryAt: u.last === void 0 ? null : new Date(u.last).toISOString()
|
|
46
43
|
});
|
|
47
44
|
}
|
|
48
45
|
e.push({
|
|
49
|
-
channel:
|
|
50
|
-
groups:
|
|
51
|
-
connections:
|
|
52
|
-
}), t +=
|
|
46
|
+
channel: n,
|
|
47
|
+
groups: s,
|
|
48
|
+
connections: q(o)
|
|
49
|
+
}), t += q(o);
|
|
53
50
|
}
|
|
54
|
-
const
|
|
55
|
-
for (const
|
|
56
|
-
|
|
57
|
-
return { channels: e, openCoalesceWindows:
|
|
51
|
+
const r = [];
|
|
52
|
+
for (const n of $.values())
|
|
53
|
+
r.push({ channel: n.channel, partition: n.partition });
|
|
54
|
+
return { channels: e, openCoalesceWindows: r, totalConnections: t };
|
|
58
55
|
}
|
|
59
|
-
function
|
|
56
|
+
function q(e) {
|
|
60
57
|
let t = 0;
|
|
61
|
-
for (const
|
|
58
|
+
for (const r of e.values()) t += r.size;
|
|
62
59
|
return t;
|
|
63
60
|
}
|
|
64
|
-
function
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
61
|
+
function P(e, t) {
|
|
62
|
+
return `${e}\0${t}`;
|
|
63
|
+
}
|
|
64
|
+
function ie(e) {
|
|
65
|
+
let t = f.get(e.channel);
|
|
66
|
+
t || (t = /* @__PURE__ */ new Map(), f.set(e.channel, t));
|
|
67
|
+
let r = t.get(e.partition);
|
|
68
|
+
r || (r = /* @__PURE__ */ new Set(), t.set(e.partition, r));
|
|
69
|
+
const n = r.size === 0;
|
|
70
|
+
return r.add(e), n;
|
|
71
|
+
}
|
|
72
|
+
function x(e) {
|
|
73
|
+
const t = f.get(e.channel), r = t?.get(e.partition);
|
|
74
|
+
if (!t || !r) return !1;
|
|
75
|
+
r.delete(e);
|
|
76
|
+
const n = r.size === 0;
|
|
77
|
+
return n && t.delete(e.partition), t.size === 0 && f.delete(e.channel), n;
|
|
69
78
|
}
|
|
70
|
-
function
|
|
71
|
-
const
|
|
72
|
-
|
|
79
|
+
function B(e, t, r) {
|
|
80
|
+
const n = P(e, t), o = d[e]?.onGroupOpen, s = (async () => {
|
|
81
|
+
if (typeof o == "function")
|
|
82
|
+
try {
|
|
83
|
+
await o({ partition: t, params: r });
|
|
84
|
+
} catch (l) {
|
|
85
|
+
console.error(
|
|
86
|
+
`[velojs] channel "${e}" onGroupOpen failed for partition "${t}":`,
|
|
87
|
+
l
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
})();
|
|
91
|
+
return E.set(n, s), s.then(() => {
|
|
92
|
+
E.get(n) === s && E.delete(n);
|
|
93
|
+
}), s;
|
|
94
|
+
}
|
|
95
|
+
async function ae(e) {
|
|
96
|
+
const t = P(e.channel, e.partition), r = E.get(t);
|
|
97
|
+
r && await r;
|
|
98
|
+
const n = f.get(e.channel)?.get(e.partition);
|
|
99
|
+
if (!n || !n.has(e) || n.size > 1) {
|
|
100
|
+
x(e);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const o = d[e.channel]?.onGroupClose;
|
|
104
|
+
if (typeof o == "function")
|
|
105
|
+
try {
|
|
106
|
+
await o({ partition: e.partition });
|
|
107
|
+
} catch (c) {
|
|
108
|
+
console.error(
|
|
109
|
+
`[velojs] channel "${e.channel}" onGroupClose failed for partition "${e.partition}":`,
|
|
110
|
+
c
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
x(e);
|
|
114
|
+
const s = f.get(e.channel)?.get(e.partition), l = s ? [...s][0] : void 0;
|
|
115
|
+
l && await B(e.channel, e.partition, l.params);
|
|
73
116
|
}
|
|
74
|
-
function
|
|
75
|
-
|
|
117
|
+
function Ee() {
|
|
118
|
+
f.clear(), E.clear(), Q();
|
|
76
119
|
}
|
|
77
|
-
async function
|
|
78
|
-
const
|
|
79
|
-
return typeof
|
|
120
|
+
async function T(e, t) {
|
|
121
|
+
const r = e.scope;
|
|
122
|
+
return typeof r != "function" ? "all" : await r(t);
|
|
80
123
|
}
|
|
81
|
-
function
|
|
124
|
+
function le(e, t) {
|
|
82
125
|
return e.get(t);
|
|
83
126
|
}
|
|
84
|
-
async function
|
|
85
|
-
const
|
|
86
|
-
if (!
|
|
87
|
-
const
|
|
88
|
-
for (const
|
|
89
|
-
let
|
|
127
|
+
async function K(e, t) {
|
|
128
|
+
const r = f.get(e)?.get(t);
|
|
129
|
+
if (!r || r.size === 0) return null;
|
|
130
|
+
const n = d[e], o = [];
|
|
131
|
+
for (const s of [...r]) {
|
|
132
|
+
let l;
|
|
90
133
|
try {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
134
|
+
l = await T(n, {
|
|
135
|
+
user: s.principal,
|
|
136
|
+
params: s.params
|
|
137
|
+
});
|
|
138
|
+
} catch (c) {
|
|
139
|
+
console.error(`[velojs] channel "${e}" scope threw on emit:`, c), l = null;
|
|
94
140
|
}
|
|
95
|
-
if (
|
|
96
|
-
await
|
|
141
|
+
if (l == null || l !== t) {
|
|
142
|
+
await s.terminate();
|
|
97
143
|
continue;
|
|
98
144
|
}
|
|
99
|
-
|
|
145
|
+
o.push(s);
|
|
100
146
|
}
|
|
101
|
-
return
|
|
147
|
+
return o.length > 0 ? o : null;
|
|
102
148
|
}
|
|
103
|
-
async function
|
|
104
|
-
const
|
|
105
|
-
|
|
149
|
+
async function Y(e, t) {
|
|
150
|
+
const r = await K(e, t);
|
|
151
|
+
r && await Promise.all(r.map((n) => X(n)));
|
|
106
152
|
}
|
|
107
|
-
async function
|
|
153
|
+
async function X(e) {
|
|
108
154
|
let t;
|
|
109
155
|
try {
|
|
110
156
|
t = await e.loader({
|
|
@@ -112,172 +158,219 @@ async function J(e) {
|
|
|
112
158
|
query: e.query,
|
|
113
159
|
c: e.c
|
|
114
160
|
});
|
|
115
|
-
} catch (
|
|
161
|
+
} catch (r) {
|
|
116
162
|
await e.send(
|
|
117
|
-
|
|
163
|
+
ne,
|
|
118
164
|
JSON.stringify({
|
|
119
|
-
message:
|
|
165
|
+
message: r instanceof Error ? r.message : String(r)
|
|
120
166
|
})
|
|
121
167
|
);
|
|
122
168
|
return;
|
|
123
169
|
}
|
|
124
|
-
t instanceof Response || await e.send(
|
|
170
|
+
t instanceof Response || await e.send(U, JSON.stringify(t ?? null));
|
|
125
171
|
}
|
|
126
|
-
function
|
|
127
|
-
return typeof e == "string" ?
|
|
172
|
+
function $e(e, t, r, n) {
|
|
173
|
+
return typeof e == "string" ? ue(e, t ?? {}) : ce(e, t, r, n);
|
|
128
174
|
}
|
|
129
|
-
async function
|
|
130
|
-
const
|
|
131
|
-
if (!
|
|
175
|
+
async function ue(e, t) {
|
|
176
|
+
const r = d[e];
|
|
177
|
+
if (!r)
|
|
132
178
|
throw new Error(
|
|
133
179
|
`[velojs] emit("${e}"): this channel has no entry in app/channels.ts. Add one — a typo or a renamed channel would otherwise be a silent no-op.`
|
|
134
180
|
);
|
|
135
|
-
const
|
|
136
|
-
if (
|
|
137
|
-
if (
|
|
138
|
-
await
|
|
181
|
+
const n = await T(r, t), o = n == null ? 0 : f.get(e)?.get(n)?.size ?? 0;
|
|
182
|
+
if (Z(e, n, "invalidate", o), n != null && o !== 0) {
|
|
183
|
+
if (O <= 0) {
|
|
184
|
+
await Y(e, n);
|
|
139
185
|
return;
|
|
140
186
|
}
|
|
141
|
-
|
|
187
|
+
se(e, n);
|
|
142
188
|
}
|
|
143
189
|
}
|
|
144
|
-
async function
|
|
145
|
-
const
|
|
146
|
-
if (!
|
|
190
|
+
async function ce(e, t, r, n) {
|
|
191
|
+
const o = e?.metadata?.moduleId;
|
|
192
|
+
if (!o)
|
|
147
193
|
throw new Error(
|
|
148
194
|
`[velojs] emit(module, "${t}", …): the module has no metadata.moduleId — pass the imported route module (the Vite plugin injects its metadata), the same object the route tree uses.`
|
|
149
195
|
);
|
|
150
|
-
const
|
|
151
|
-
if (!Array.isArray(
|
|
196
|
+
const s = e.channels;
|
|
197
|
+
if (!Array.isArray(s) || !s.includes(t))
|
|
152
198
|
throw new Error(
|
|
153
|
-
`[velojs] emit(module, "${t}", …): module "${
|
|
199
|
+
`[velojs] emit(module, "${t}", …): module "${o}" does not declare channel "${t}" — add it to the module's \`channels\` export, or use emit("${t}", ctx) for the invalidation mode.`
|
|
154
200
|
);
|
|
155
201
|
if (typeof e.loader != "function")
|
|
156
202
|
throw new Error(
|
|
157
|
-
`[velojs] emit(module, "${t}", …): module "${
|
|
203
|
+
`[velojs] emit(module, "${t}", …): module "${o}" has no \`loader\` — there is no data shape to slice.`
|
|
158
204
|
);
|
|
159
|
-
const
|
|
160
|
-
if (!
|
|
205
|
+
const l = d[t];
|
|
206
|
+
if (!l)
|
|
161
207
|
throw new Error(
|
|
162
208
|
`[velojs] emit(module, "${t}", …): this channel has no entry in app/channels.ts. Add one — a typo or a renamed channel would otherwise be a silent no-op.`
|
|
163
209
|
);
|
|
164
|
-
if (
|
|
210
|
+
if (n === null || typeof n != "object" || Array.isArray(n))
|
|
165
211
|
throw new Error(
|
|
166
|
-
`[velojs] emit(module, "${t}", …): the slice must be the object of changed keys — got ${
|
|
212
|
+
`[velojs] emit(module, "${t}", …): the slice must be the object of changed keys — got ${n === null ? "null" : Array.isArray(n) ? "an array" : typeof n}.`
|
|
167
213
|
);
|
|
168
|
-
const
|
|
169
|
-
if (
|
|
170
|
-
const
|
|
171
|
-
if (!
|
|
172
|
-
const
|
|
173
|
-
if (
|
|
174
|
-
const
|
|
175
|
-
await Promise.all(
|
|
214
|
+
const c = await T(l, r), p = c == null ? void 0 : f.get(t)?.get(c), a = p?.size ?? 0;
|
|
215
|
+
if (Z(t, c, "slice", a), c == null || !p || a === 0) return;
|
|
216
|
+
const u = await K(t, c);
|
|
217
|
+
if (!u) return;
|
|
218
|
+
const w = u.filter((g) => g.moduleId === o);
|
|
219
|
+
if (w.length === 0) return;
|
|
220
|
+
const S = JSON.stringify(n);
|
|
221
|
+
await Promise.all(w.map((g) => g.send(V, S)));
|
|
176
222
|
}
|
|
177
|
-
function
|
|
178
|
-
if (!
|
|
179
|
-
const
|
|
223
|
+
function Z(e, t, r, n) {
|
|
224
|
+
if (!F) return;
|
|
225
|
+
const o = typeof t == "string" ? `"${t}"` : "null";
|
|
180
226
|
console.log(
|
|
181
|
-
`[velojs] emit kind=${
|
|
227
|
+
`[velojs] emit kind=${r} channel="${e}" partition=${o} connections=${n} at=${(/* @__PURE__ */ new Date()).toISOString()}`
|
|
182
228
|
);
|
|
183
229
|
}
|
|
184
|
-
function
|
|
185
|
-
let
|
|
186
|
-
return (
|
|
187
|
-
}).catch((
|
|
230
|
+
function fe(e, t) {
|
|
231
|
+
let r = Promise.resolve();
|
|
232
|
+
return (n) => (r = r.then(() => t(n)).then(() => {
|
|
233
|
+
}).catch((o) => {
|
|
188
234
|
console.warn(
|
|
189
235
|
`[velojs] channel "${e}": SSE write failed — the snapshot did not reach the client:`,
|
|
190
|
-
|
|
236
|
+
o
|
|
191
237
|
);
|
|
192
|
-
}),
|
|
238
|
+
}), r);
|
|
239
|
+
}
|
|
240
|
+
const C = "_route";
|
|
241
|
+
function de(e) {
|
|
242
|
+
return e ? e.split("/").filter((t) => t.startsWith(":")).map((t) => t.slice(1)) : [];
|
|
243
|
+
}
|
|
244
|
+
function pe(e, t) {
|
|
245
|
+
if (e == null || e === "")
|
|
246
|
+
return { params: {}, error: null };
|
|
247
|
+
let r;
|
|
248
|
+
try {
|
|
249
|
+
r = JSON.parse(e);
|
|
250
|
+
} catch {
|
|
251
|
+
return { params: {}, error: `the ?${C}= payload is not valid JSON` };
|
|
252
|
+
}
|
|
253
|
+
if (r === null || typeof r != "object" || Array.isArray(r))
|
|
254
|
+
return {
|
|
255
|
+
params: {},
|
|
256
|
+
error: `the ?${C}= payload must be an object of route params`
|
|
257
|
+
};
|
|
258
|
+
const n = {};
|
|
259
|
+
for (const [o, s] of Object.entries(r)) {
|
|
260
|
+
if (!t.includes(o)) {
|
|
261
|
+
const l = t.length > 0 ? t.join(", ") : "none";
|
|
262
|
+
return {
|
|
263
|
+
params: {},
|
|
264
|
+
error: `route param "${o}" is not declared by the module's path (declared: ${l})`
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
if (typeof s != "string")
|
|
268
|
+
return { params: {}, error: `route param "${o}" must be a URL string` };
|
|
269
|
+
n[o] = s;
|
|
270
|
+
}
|
|
271
|
+
return { params: n, error: null };
|
|
193
272
|
}
|
|
194
|
-
function
|
|
195
|
-
if (typeof
|
|
273
|
+
function Se(e, t, r, n, o, s) {
|
|
274
|
+
if (typeof n.loader != "function")
|
|
196
275
|
throw new Error(
|
|
197
|
-
`[velojs] module "${
|
|
276
|
+
`[velojs] module "${o}" declares \`channels\` without a \`loader\` — there is nothing to synchronize. Add a loader or remove the export.`
|
|
198
277
|
);
|
|
199
|
-
if (!
|
|
278
|
+
if (!d[r])
|
|
200
279
|
throw new Error(
|
|
201
|
-
`[velojs] module "${
|
|
280
|
+
`[velojs] module "${o}" declares channel "${r}" with no entry in app/channels.ts — add the partition resolver for "${r}".`
|
|
281
|
+
);
|
|
282
|
+
const l = n.loader, c = de(n.metadata?.fullPath), p = async (a) => {
|
|
283
|
+
const u = d[r], w = pe(
|
|
284
|
+
a.req.query(C),
|
|
285
|
+
c
|
|
202
286
|
);
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
287
|
+
if (w.error)
|
|
288
|
+
return console.error(`[velojs] channel "${r}": rejecting subscription — ${w.error}`), a.json({ error: "invalid-route-params", message: w.error }, 400);
|
|
289
|
+
const S = w.params, g = le(a, "user");
|
|
290
|
+
let b;
|
|
206
291
|
try {
|
|
207
|
-
|
|
208
|
-
} catch (
|
|
209
|
-
return console.error(`[velojs] channel "${
|
|
292
|
+
b = await T(u, { user: g, params: S });
|
|
293
|
+
} catch (h) {
|
|
294
|
+
return console.error(`[velojs] channel "${r}" scope threw:`, h), a.json({ error: "forbidden" }, 403);
|
|
210
295
|
}
|
|
211
|
-
if (
|
|
296
|
+
if (b == null)
|
|
212
297
|
return a.json({ error: "forbidden" }, 403);
|
|
213
|
-
const { streamSSE:
|
|
214
|
-
|
|
298
|
+
const { streamSSE: ee } = await import("hono/streaming"), D = {};
|
|
299
|
+
for (const [h, m] of Object.entries(a.req.query()))
|
|
300
|
+
h !== C && (D[h] = m);
|
|
301
|
+
const A = await ee(a, async (h) => {
|
|
302
|
+
let m = !1, R = () => {
|
|
215
303
|
};
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
}),
|
|
219
|
-
|
|
220
|
-
(i) => typeof i == "string" ?
|
|
221
|
-
),
|
|
222
|
-
channel:
|
|
223
|
-
partition:
|
|
224
|
-
moduleId:
|
|
225
|
-
principal:
|
|
226
|
-
loader:
|
|
304
|
+
const te = new Promise((i) => {
|
|
305
|
+
R = i;
|
|
306
|
+
}), _ = fe(
|
|
307
|
+
r,
|
|
308
|
+
(i) => typeof i == "string" ? h.write(i) : h.writeSSE(i)
|
|
309
|
+
), j = {
|
|
310
|
+
channel: r,
|
|
311
|
+
partition: b,
|
|
312
|
+
moduleId: o,
|
|
313
|
+
principal: g,
|
|
314
|
+
loader: l,
|
|
227
315
|
c: a,
|
|
228
|
-
params:
|
|
229
|
-
query:
|
|
230
|
-
send: (i,
|
|
231
|
-
|
|
232
|
-
}) :
|
|
233
|
-
terminate: (i) =>
|
|
234
|
-
},
|
|
235
|
-
|
|
236
|
-
},
|
|
237
|
-
|
|
316
|
+
params: S,
|
|
317
|
+
query: D,
|
|
318
|
+
send: (i, G) => m ? Promise.resolve() : i === U || i === V ? _({ event: i, data: G }).then(() => {
|
|
319
|
+
m || (j.lastDeliveryAt = Date.now(), L());
|
|
320
|
+
}) : _({ event: i, data: G }),
|
|
321
|
+
terminate: (i) => z(i)
|
|
322
|
+
}, k = () => {
|
|
323
|
+
m || (m = !0, y !== null && clearTimeout(y), v !== null && clearInterval(v), R(), ae(j));
|
|
324
|
+
}, z = async (i = "partition") => {
|
|
325
|
+
m || (await j.send(oe, JSON.stringify({ reason: i })), k());
|
|
238
326
|
};
|
|
239
|
-
let
|
|
240
|
-
const
|
|
241
|
-
if (
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
},
|
|
245
|
-
const i =
|
|
246
|
-
typeof i == "function" && i.call(
|
|
327
|
+
let y = null;
|
|
328
|
+
const L = () => {
|
|
329
|
+
if (M <= 0 || m) return;
|
|
330
|
+
y !== null && clearTimeout(y), y = setTimeout(() => {
|
|
331
|
+
y = null, z("idle");
|
|
332
|
+
}, M);
|
|
333
|
+
const i = y.unref;
|
|
334
|
+
typeof i == "function" && i.call(y);
|
|
247
335
|
};
|
|
248
|
-
let
|
|
249
|
-
|
|
250
|
-
|
|
336
|
+
let v = null;
|
|
337
|
+
N > 0 && (v = setInterval(() => {
|
|
338
|
+
m || _(`: ping
|
|
251
339
|
|
|
252
340
|
`);
|
|
253
|
-
},
|
|
254
|
-
|
|
255
|
-
|
|
341
|
+
}, N));
|
|
342
|
+
const re = ie(j);
|
|
343
|
+
if (h.onAbort(k), L(), v !== null) {
|
|
344
|
+
const i = v.unref;
|
|
345
|
+
typeof i == "function" && i.call(v);
|
|
256
346
|
}
|
|
257
|
-
await
|
|
258
|
-
}),
|
|
259
|
-
return
|
|
260
|
-
status:
|
|
261
|
-
statusText:
|
|
262
|
-
headers:
|
|
347
|
+
re && await B(r, b, S), await X(j), await te;
|
|
348
|
+
}), I = new Headers(A.headers);
|
|
349
|
+
return I.set("Cache-Control", "no-store"), new Response(A.body, {
|
|
350
|
+
status: A.status,
|
|
351
|
+
statusText: A.statusText,
|
|
352
|
+
headers: I
|
|
263
353
|
});
|
|
264
354
|
};
|
|
265
|
-
|
|
355
|
+
s.length > 0 ? e.on(["GET"], [t], ...s, p) : e.on(["GET"], [t], p);
|
|
266
356
|
}
|
|
267
357
|
export {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
358
|
+
oe as CHANNEL_CLOSE_EVENT,
|
|
359
|
+
ne as CHANNEL_ERROR_EVENT,
|
|
360
|
+
H as DEFAULT_COALESCE_MS,
|
|
361
|
+
W as DEFAULT_IDLE_MS,
|
|
362
|
+
C as ROUTE_PARAMS_QUERY,
|
|
363
|
+
V as SLICE_EVENT,
|
|
364
|
+
U as SNAPSHOT_EVENT,
|
|
365
|
+
Ee as __resetChannels,
|
|
366
|
+
ge as channelNames,
|
|
367
|
+
fe as createChannelWriteChain,
|
|
368
|
+
de as declaredRouteParams,
|
|
369
|
+
$e as emit,
|
|
370
|
+
we as getChannelMap,
|
|
371
|
+
ve as inspectChannels,
|
|
372
|
+
pe as parseRouteParamsQuery,
|
|
373
|
+
X as pushSnapshot,
|
|
374
|
+
Se as registerChannelRoute,
|
|
375
|
+
ye as registerChannels
|
|
283
376
|
};
|
package/dist/client.js
CHANGED
|
@@ -33,15 +33,15 @@ const l = (t, n, e) => n ? e && n === "/" ? t || "/" : n.startsWith("/") ? t + n
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
return null;
|
|
36
|
-
}, R = (t, n) => n ? [...t, /* @__PURE__ */ r(f, { children: /* @__PURE__ */ r(n, {}) }, "__notfound")] : t,
|
|
36
|
+
}, R = (t, n) => n ? [...t, /* @__PURE__ */ r(f, { children: /* @__PURE__ */ r(n, {}) }, "__notfound")] : t, h = (t, n, e, c) => {
|
|
37
37
|
const i = [];
|
|
38
|
-
for (let
|
|
39
|
-
const o = t[
|
|
38
|
+
for (let a = 0; a < t.length; a++) {
|
|
39
|
+
const o = t[a], s = `${c}${a}`;
|
|
40
40
|
if (o.path === "*") continue;
|
|
41
41
|
if (!o.module) {
|
|
42
42
|
if (o.children) {
|
|
43
43
|
const u = l(n, o.path, !1);
|
|
44
|
-
i.push(...
|
|
44
|
+
i.push(...h(o.children, u, e, `${s}-`));
|
|
45
45
|
}
|
|
46
46
|
continue;
|
|
47
47
|
}
|
|
@@ -50,6 +50,7 @@ const l = (t, n, e) => n ? e && n === "/" ? t || "/" : n.startsWith("/") ? t + n
|
|
|
50
50
|
{
|
|
51
51
|
moduleId: o.module?.metadata?.moduleId,
|
|
52
52
|
channels: o.module?.channels,
|
|
53
|
+
fullPath: o.module?.metadata?.fullPath,
|
|
53
54
|
children: u
|
|
54
55
|
}
|
|
55
56
|
);
|
|
@@ -63,7 +64,7 @@ const l = (t, n, e) => n ? e && n === "/" ? t || "/" : n.startsWith("/") ? t + n
|
|
|
63
64
|
if (o.isRoot) {
|
|
64
65
|
i.push(
|
|
65
66
|
/* @__PURE__ */ r(y, { children: R(
|
|
66
|
-
|
|
67
|
+
h(o.children, "", e, `${s}-`),
|
|
67
68
|
e
|
|
68
69
|
) }, s)
|
|
69
70
|
);
|
|
@@ -73,7 +74,7 @@ const l = (t, n, e) => n ? e && n === "/" ? t || "/" : n.startsWith("/") ? t + n
|
|
|
73
74
|
i.push(
|
|
74
75
|
/* @__PURE__ */ r(f, { path: j, children: m(
|
|
75
76
|
/* @__PURE__ */ r(p, { children: /* @__PURE__ */ r(y, { children: R(
|
|
76
|
-
|
|
77
|
+
h(o.children, $, e, `${s}-`),
|
|
77
78
|
e
|
|
78
79
|
) }) })
|
|
79
80
|
) }, s)
|
|
@@ -87,7 +88,7 @@ const l = (t, n, e) => n ? e && n === "/" ? t || "/" : n.startsWith("/") ? t + n
|
|
|
87
88
|
}, [t]), null;
|
|
88
89
|
}, k = ({ routes: t }) => {
|
|
89
90
|
L(t);
|
|
90
|
-
const n = C(t), e =
|
|
91
|
+
const n = C(t), e = h(t, "", n, "");
|
|
91
92
|
return /* @__PURE__ */ w(S, { children: [
|
|
92
93
|
/* @__PURE__ */ r(g, {}),
|
|
93
94
|
e
|